Добавил:
Studfiles2
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Лабораторная работа №38 / Laba3 / Laba3View
.cpp// Laba3View.cpp : implementation of the CLaba3View class
//
#include "stdafx.h"
#include "Laba3.h"
#include "Laba3Doc.h"
#include "Laba3View.h"
#include ".\laba3view.h"
#include "cTochka.h"
#include "cLomanaya.h"
#include "cOtrezok.h"
#include "cZmkLomanaya.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CLaba3View
IMPLEMENT_DYNCREATE(CLaba3View, CView)
BEGIN_MESSAGE_MAP(CLaba3View, CView)
ON_WM_LBUTTONDOWN()
END_MESSAGE_MAP()
// CLaba3View construction/destruction
CLaba3View::CLaba3View()
{
// TODO: add construction code here
}
CLaba3View::~CLaba3View()
{
}
BOOL CLaba3View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
// CLaba3View drawing
void CLaba3View::OnDraw(CDC* pDC)
{
CLaba3Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
list<cTochka>::iterator i;
list<cTochka>::iterator j;
switch(theApp.CurrentAction)
{
case ACTION_SET_ZMK_LOMANAYU:
i = theApp.ZmkLmn.Lmn.begin();
pDC->MoveTo((int)((*i).X), (int)((*i).Y));
pDC->Ellipse((int)((*i).X-4), (int)((*i).Y-4), (int)((*i).X+4), (int)((*i).Y+4));
i++;
for(; i!=theApp.ZmkLmn.Lmn.end(); i++)
{
pDC->LineTo((int)((*i).X), (int)((*i).Y));
pDC->Ellipse((int)((*i).X-4), (int)((*i).Y-4), (int)((*i).X+4), (int)((*i).Y+4));
}
i=theApp.ZmkLmn.Lmn.begin();
if(theApp.HaveZmkLmn)
pDC->LineTo((int)((*i).X), (int)((*i).Y));
break;
case ACTION_SET_OTREZOK_P1 :
i = theApp.ZmkLmn.Lmn.begin();
pDC->MoveTo((int)((*i).X), (int)((*i).Y));
pDC->Ellipse((int)((*i).X-4), (int)((*i).Y-4), (int)((*i).X+4), (int)((*i).Y+4));
i++;
for(; i!=theApp.ZmkLmn.Lmn.end(); i++)
{
pDC->LineTo((int)((*i).X), (int)((*i).Y));
pDC->Ellipse((int)((*i).X-4), (int)((*i).Y-4), (int)((*i).X+4), (int)((*i).Y+4));
}
i=theApp.ZmkLmn.Lmn.begin();
if(theApp.HaveZmkLmn)
pDC->LineTo((int)((*i).X), (int)((*i).Y));
pDC->MoveTo((int)(theApp.Otrezok.Tchk1.X), (int)(theApp.Otrezok.Tchk1.Y));
pDC->Ellipse((int)(theApp.Otrezok.Tchk1.X-4), (int)(theApp.Otrezok.Tchk1.Y-4), (int)(theApp.Otrezok.Tchk1.X+4), (int)(theApp.Otrezok.Tchk1.Y+4));
break;
case ACTION_SET_OTREZOK_P2 :
i = theApp.ZmkLmn.Lmn.begin();
pDC->MoveTo((int)((*i).X), (int)((*i).Y));
pDC->Ellipse((int)((*i).X-4), (int)((*i).Y-4), (int)((*i).X+4), (int)((*i).Y+4));
i++;
for(; i!=theApp.ZmkLmn.Lmn.end(); i++)
{
pDC->LineTo((int)((*i).X), (int)((*i).Y));
pDC->Ellipse((int)((*i).X-4), (int)((*i).Y-4), (int)((*i).X+4), (int)((*i).Y+4));
}
i=theApp.ZmkLmn.Lmn.begin();
if(theApp.HaveZmkLmn)
pDC->LineTo((int)((*i).X), (int)((*i).Y));
theApp.Otrezok.CreateLomanuyu();
i = theApp.Lomanaya.Lmn.begin();
j = theApp.Lomanaya.Lmn.begin();
j++;
pDC->MoveTo((int)((*i).X), (int)((*i).Y));
for(;j!=theApp.Lomanaya.Lmn.end();i++,j++)
{
pDC->Ellipse((int)((*i).X-4), (int)((*i).Y-4), (int)((*i).X+4), (int)((*i).Y+4));
if(theApp.StartType == OUT_LOMANAYA)
{
theApp.StartType = IN_LOMANAYA;
pDC->LineTo((int)((*j).X), (int)((*j).Y));
}
else
{
theApp.StartType = OUT_LOMANAYA;
pDC->MoveTo((int)((*j).X), (int)((*j).Y));
}
}
pDC->Ellipse((int)((*i).X-4), (int)((*i).Y-4), (int)((*i).X+4), (int)((*i).Y+4));
//pDC->MoveTo((int)(theApp.Otrezok.Tchk1.X), (int)(theApp.Otrezok.Tchk1.Y));
//pDC->Ellipse((int)(theApp.Otrezok.Tchk1.X-4), (int)(theApp.Otrezok.Tchk1.Y-4), (int)(theApp.Otrezok.Tchk1.X+4), (int)(theApp.Otrezok.Tchk1.Y+4));
//pDC->LineTo((int)(theApp.Otrezok.Tchk2.X), (int)(theApp.Otrezok.Tchk2.Y));
//pDC->Ellipse((int)(theApp.Otrezok.Tchk2.X-4), (int)(theApp.Otrezok.Tchk2.Y-4), (int)(theApp.Otrezok.Tchk2.X+4), (int)(theApp.Otrezok.Tchk2.Y+4));
break;
}
}
// CLaba3View diagnostics
#ifdef _DEBUG
void CLaba3View::AssertValid() const
{
CView::AssertValid();
}
void CLaba3View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CLaba3Doc* CLaba3View::GetDocument() const // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CLaba3Doc)));
return (CLaba3Doc*)m_pDocument;
}
#endif //_DEBUG
// CLaba3View message handlers
void CLaba3View::OnLButtonDown(UINT nFlags, CPoint point)
{
cTochka Tchk;
int ret;
CWnd* curWnd;
switch(theApp.CurrentAction)
{
case ACTION_SET_ZMK_LOMANAYU:
Tchk.X = point.x;
Tchk.Y = point.y;
ret = theApp.ZmkLmn.DobavitTochku(Tchk);
if(ret == LAST_TCHK)
{
theApp.HaveZmkLmn = 1;
curWnd = theApp.GetMainWnd();
curWnd->RedrawWindow();
theApp.CurrentAction = ACTION_SET_OTREZOK_P1;
}
else
{
curWnd = theApp.GetMainWnd();
curWnd->RedrawWindow();
}
break;
case ACTION_SET_OTREZOK_P1 :
theApp.Otrezok.Tchk1.X = point.x;
theApp.Otrezok.Tchk1.Y = point.y;
curWnd = theApp.GetMainWnd();
curWnd->RedrawWindow();
theApp.CurrentAction = ACTION_SET_OTREZOK_P2;
break;
case ACTION_SET_OTREZOK_P2 :
theApp.Otrezok.Tchk2.X = point.x;
theApp.Otrezok.Tchk2.Y = point.y;
curWnd = theApp.GetMainWnd();
curWnd->RedrawWindow();
theApp.CurrentAction = ACTION_SET_OTREZOK_P1;
theApp.Lomanaya.Clear();
break;
}
CView::OnLButtonDown(nFlags, point);
}
Соседние файлы в папке Laba3