Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // midptcircleView.cpp : implementation of the CmidptcircleView class
- //
- #include "stdafx.h"
- // SHARED_HANDLERS can be defined in an ATL project implementing preview, thumbnail
- // and search filter handlers and allows sharing of document code with that project.
- #ifndef SHARED_HANDLERS
- #include "midptcircle.h"
- #endif
- #include "midptcircleDoc.h"
- #include "midptcircleView.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #endif
- // CmidptcircleView
- IMPLEMENT_DYNCREATE(CmidptcircleView, CView)
- BEGIN_MESSAGE_MAP(CmidptcircleView, CView)
- ON_WM_CONTEXTMENU()
- ON_WM_RBUTTONUP()
- END_MESSAGE_MAP()
- // CmidptcircleView construction/destruction
- CmidptcircleView::CmidptcircleView()
- {
- // TODO: add construction code here
- }
- CmidptcircleView::~CmidptcircleView()
- {
- }
- BOOL CmidptcircleView::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- return CView::PreCreateWindow(cs);
- }
- // CmidptcircleView drawing
- void plot(CDC* PDC,int xc,int yc,int x,int y, COLORREF color)
- {
- PDC->SetPixel(xc+x,yc+y,color);
- PDC->SetPixel(xc+x,yc-y,color);
- PDC->SetPixel(xc-x,yc+y,color);
- PDC->SetPixel(xc-x,yc-y,color);
- PDC->SetPixel(xc+y,yc+x,color);
- PDC->SetPixel(xc-y,yc+x,color);
- PDC->SetPixel(xc+y,yc-x,color);
- PDC->SetPixel(xc-y,yc-x,color);
- }
- void drawcircle(CDC* pDC,int xc, int yc, int r, COLORREF color)
- {
- /*
- Set X = 0 and Y = R
- 2. Set P = 1 – R
- 3. Repeat While (X < Y)
- 4. Call Draw Circle(Xc, Yc, X, Y)
- 5. Set X = X + 1
- 6. If (P < 0) Then
- 7. P = P + 2X + 1
- 8. Else
- 9. Set Y = Y – 1
- 10. P = P + 2(X – Y) + 1
- [End of If]
- 11. Call Draw Circle(Xc, Yc, X, Y)
- [End of While]
- 12. Exit
- */
- int x=0,y=r;
- int p=1-r;
- while(x<y)
- {
- plot(pDC,xc,yc,x,y,color);
- x++;
- if(p<0)
- {
- p+=2*x+1;
- }
- else
- {
- y--;
- p+=2*(x-y)+1;
- }
- plot(pDC,xc,yc,x,y,color);
- }
- }
- void CmidptcircleView::OnDraw(CDC* pDC)
- {
- CmidptcircleDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- if (!pDoc)
- return;
- //Draws the audi logo
- drawcircle(pDC,100,100,50,RGB(128,128,128));
- drawcircle(pDC,100,100,48,RGB(128,128,128));
- drawcircle(pDC,100,100,46,RGB(128,128,128));
- drawcircle(pDC,100,100,52,RGB(128,128,128));
- drawcircle(pDC,100,100,54,RGB(128,128,128));
- drawcircle(pDC,100,100,56,RGB(128,128,128));
- drawcircle(pDC,156+20,100,50,RGB(128,128,128));
- drawcircle(pDC,156+20,100,48,RGB(128,128,128));
- drawcircle(pDC,156+20,100,46,RGB(128,128,128));
- drawcircle(pDC,156+20,100,52,RGB(128,128,128));
- drawcircle(pDC,156+20,100,54,RGB(128,128,128));
- drawcircle(pDC,156+20,100,56,RGB(128,128,128));
- drawcircle(pDC,212+40,100,50,RGB(128,128,128));
- drawcircle(pDC,212+40,100,48,RGB(128,128,128));
- drawcircle(pDC,212+40,100,46,RGB(128,128,128));
- drawcircle(pDC,212+40,100,52,RGB(128,128,128));
- drawcircle(pDC,212+40,100,54,RGB(128,128,128));
- drawcircle(pDC,212+40,100,56,RGB(128,128,128));
- drawcircle(pDC,268+60,100,50,RGB(128,128,128));
- drawcircle(pDC,268+60,100,48,RGB(128,128,128));
- drawcircle(pDC,268+60,100,46,RGB(128,128,128));
- drawcircle(pDC,268+60,100,52,RGB(128,128,128));
- drawcircle(pDC,268+60,100,54,RGB(128,128,128));
- drawcircle(pDC,268+60,100,56,RGB(128,128,128));
- // TODO: add draw code for native data here
- }
- void CmidptcircleView::OnRButtonUp(UINT /* nFlags */, CPoint point)
- {
- ClientToScreen(&point);
- OnContextMenu(this, point);
- }
- void CmidptcircleView::OnContextMenu(CWnd* /* pWnd */, CPoint point)
- {
- #ifndef SHARED_HANDLERS
- theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EDIT, point.x, point.y, this, TRUE);
- #endif
- }
- // CmidptcircleView diagnostics
- #ifdef _DEBUG
- void CmidptcircleView::AssertValid() const
- {
- CView::AssertValid();
- }
- void CmidptcircleView::Dump(CDumpContext& dc) const
- {
- CView::Dump(dc);
- }
- CmidptcircleDoc* CmidptcircleView::GetDocument() const // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CmidptcircleDoc)));
- return (CmidptcircleDoc*)m_pDocument;
- }
- #endif //_DEBUG
Advertisement
Add Comment
Please, Sign In to add comment