functionpolygon.cpp

来自「一个简单的画图程序 可以画点线面等」· C++ 代码 · 共 87 行

CPP
87
字号
// FunctionPolygon.cpp: implementation of the CFunctionPolygon class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "smallcad203.h"
#include "FunctionPolygon.h"
#include "MainFrm.h" 
#include "SmallCAD203Doc.h"
#include "SmallCAD203View.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
extern CSmallCAD203App theApp;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CFunctionPolygon::CFunctionPolygon()
{
	a=0;
	l=NULL;
	mouseD=FALSE;

}

CFunctionPolygon::~CFunctionPolygon()
{

}
void CFunctionPolygon::OnLButtonDown(UINT nFlags, CPoint point)
{
	CMainFrame *pFrame=(CMainFrame *)theApp.GetMainWnd();
	CSmallCAD203Doc *pDoc=(CSmallCAD203Doc *)pFrame->GetActiveDocument();
	CSmallCAD203View *pView=(CSmallCAD203View *)pFrame->GetActiveView();
	mouseD=TRUE;
	CDC *pDC=pView->GetDC();
	a++;

	if(a==1)
	{
		l=new CGraphLine;
		l->SetStartPoint(point);
		l->SetEndPoint(point);
		l->SetColor(pDoc->GetCurrentColor());
		l->SetScale(pDoc->GetCurrentScale());
	
	}


	pView->ReleaseDC(pDC);
}
void CFunctionPolygon::OnLButtonUp(UINT nFlags, CPoint point)
{
	CMainFrame *pFrame=(CMainFrame *)theApp.GetMainWnd();
	CSmallCAD203Doc *pDoc=(CSmallCAD203Doc *)pFrame->GetActiveDocument();
	CSmallCAD203View *pView=(CSmallCAD203View *)pFrame->GetActiveView();
	CDC *pDC=pView->GetDC();
	mouseD = FALSE;
	l->SetEndPoint(point);
	l->Draw(pView->GetDC());
//	pDoc->my_list.InSert(l);
//	pDoc->AddGraph(l);
	l->SetStartPoint(point);
	pView->ReleaseDC(pDC);
}
void CFunctionPolygon::OnMouseMove(UINT nFlags, CPoint point)
{

	CMainFrame *pFrame=(CMainFrame *)theApp.GetMainWnd();
	CSmallCAD203Doc *pDoc=(CSmallCAD203Doc *)pFrame->GetActiveDocument();
	CSmallCAD203View *pView=(CSmallCAD203View *)pFrame->GetActiveView();

	CDC *pDC=pView->GetDC();
	if(!mouseD)
		return;
	pDC->SetROP2(R2_NOTXORPEN);
	l->Draw(pDC);
	l->SetEndPoint(point);
	l->Draw(pDC);
//	pDoc->AddGraph(l);
	
	pView->ReleaseDC(pDC);
}	

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?