⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 paintdoc.cpp

📁 这是书上的代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
	switch (m_nSelectedTool)
	{
		case ID_TOOL_SELECTOR:
			// okay - just delete m_pSelectedTool
			NoPaint();										
			break;
		case ID_TOOL_LINE_NORMAL:			
		case ID_TOOL_LINE_STARTNODE:		
		case ID_TOOL_LINE_STARTENDNODE:		
		case ID_TOOL_LINE_ANGLELENGTH:
			m_pSelectedTool = new CPaintLine();
			m_pSelectedTool->m_uFigureType=0;
			m_pSelectedTool->m_uObjectType=0;//地图对象的类型0=路径1=建筑2=设备
			NoPaint();
			m_bpaintLine=TRUE;	//TRUE表示正在画直线
			break;
		case ID_TOOL_CLOCKWISE_NORMAL:		
		case ID_TOOL_CLOCKWISE_RADIUS:			
		case ID_TOOL_CLOCKWISE_STARTNODE:			
		case ID_TOOL_CLOCKWISE_STARTENDNODE:
			m_pSelectedTool = new CPaintArc();
			m_pSelectedTool->m_uFigureType=1;
			m_pSelectedTool->m_uObjectType=0;//地图对象的类型0=路径1=建筑2=设备
			((CPaintArc*) m_pSelectedTool)->m_uArcPathDirection=1;
			NoPaint();
			m_bpaintarc=TRUE;//TRUE表示正在画弧			
			break;
		case ID_TOOL_ANTICLOCKWISE_NORMAL:		
		case ID_TOOL_ANTICLOCKWISE_RADIUS:			
		case ID_TOOL_ANTICLOCKWISE_STARTNODE:			
		case ID_TOOL_ANTICLOCKWISE_STARTENDNODE:
			m_pSelectedTool = new CPaintArc();
			m_pSelectedTool->m_uFigureType=1;
			m_pSelectedTool->m_uObjectType=0;//地图对象的类型0=路径1=建筑2=设备
			((CPaintArc*) m_pSelectedTool)->m_uArcPathDirection=0;
			NoPaint();
			m_bpaintarc=TRUE;//TRUE表示正在画弧
			break;
		case ID_TOOL_LAZYS_ANGLE:
		case ID_TOOL_LAZYS_ANGLESTARTNODE:
		case ID_TOOL_LAZYS_ANGLESTARTENDNODE:
			m_pSelectedTool = new CPaintLazys();
			m_pSelectedTool->m_uFigureType=2;
			m_pSelectedTool->m_uObjectType=0;//地图对象的类型0=路径1=建筑2=设备
			NoPaint();
			m_bpaintLazys=TRUE;	//TRUE表示正在画懒-S
			break;
		case ID_TOOL_SIDE_NORMAL:
		case ID_TOOL_SIDE_STARTNODE:
		case ID_TOOL_SIDE_STARTENDNODE:
			m_pSelectedTool = new CPaintSide();
			m_pSelectedTool->m_uFigureType=3;
			m_pSelectedTool->m_uObjectType=0;//地图对象的类型0=路径1=建筑2=设备
			NoPaint();
			m_bpaintSide=TRUE;	//TRUE表示正在画硬侧移
			break;
		case ID_TOOL_SCP_ANGLE:
		case ID_TOOL_SCP_ANGLESTARTNODE:
		case ID_TOOL_SCP_ANGLESTARTENDNODE:
			m_pSelectedTool = new CPaintScp();
			m_pSelectedTool->m_uFigureType=4;
			m_pSelectedTool->m_uObjectType=0;//地图对象的类型0=路径1=建筑2=设备
			NoPaint();
			m_bpaintScp=TRUE;	//TRUE表示正在画软侧移
			break;
		case ID_TOOL_ELLIPSE_NORMAL:
		case ID_TOOL_ELLIPSE_STARTENDNODE:
			m_pSelectedTool = new CPaintEllipse();
			m_pSelectedTool->m_uFigureType=5;
			m_pSelectedTool->m_uObjectType=1;//地图对象的类型0=路径1=建筑2=设备
			m_pSelectedTool->m_rgbPrimary= RGB(0, 0, 255);// blue
			NoPaint();
			m_bpaintEllipse=TRUE;//TRUE表示正在画椭圆
			break;
		case ID_TOOL_RECT_NORMAL:
		case ID_TOOL_RECT_STARTENDNODE:
			m_pSelectedTool = new CPaintRect();
			m_pSelectedTool->m_uFigureType=6;
			m_pSelectedTool->m_uObjectType=1;//地图对象的类型0=路径1=建筑2=设备
			m_pSelectedTool->m_rgbPrimary= RGB(0, 0, 255);// blue
			NoPaint();
			m_bpaintRect=TRUE;	//TRUE表示正在画矩形
			break;
		case ID_TOOL_POLYGON_NORMAL:
		case ID_TOOL_POLYGON_ALLNODE:
			m_pSelectedTool = new CPaintPolygon();
			m_pSelectedTool->m_uFigureType=7;
			m_pSelectedTool->m_uObjectType=1;//地图对象的类型0=路径1=建筑2=设备
			m_pSelectedTool->m_rgbPrimary= RGB(0, 0, 255);// blue
			NoPaint();
			m_bpaintPolygon=TRUE;//TRUE表示正在画多边形
			break;
		case ID_TOOL_ROUNDRECT_ELLIPSE:
		case ID_TOOL_ROUNDRECT_ELLIPSESTARTENDNODE:
			m_pSelectedTool = new CPaintRoundrect();
			m_pSelectedTool->m_uFigureType=8;
			m_pSelectedTool->m_uObjectType=1;//地图对象的类型0=路径1=建筑2=设备
			m_pSelectedTool->m_rgbPrimary= RGB(0, 0, 255);// blue
			NoPaint();
			m_bpaintRoundrect=TRUE;//TRUE表示正在画圆角矩形
			break;
		case ID_TOOL_CHORD_NORMAL:
		case ID_TOOL_CHORD_RADIUS:
		case ID_TOOL_CHORD_STARTNODE:
		case ID_TOOL_CHORD_STARTENDNODE:
			m_pSelectedTool = new CPaintChord();
			m_pSelectedTool->m_uFigureType=9;
			m_pSelectedTool->m_uObjectType=1;//地图对象的类型0=路径1=建筑2=设备
			m_pSelectedTool->m_rgbPrimary= RGB(0, 0, 255);// blue
			NoPaint();
			m_bpaintChord=TRUE;	//TRUE表示正在画弦
			break;
		case ID_TOOL_PIE_NORMAL:
		case ID_TOOL_PIE_RADIUS:
		case ID_TOOL_PIE_STARTNODE:
		case ID_TOOL_PIE_STARTENDNODE:
			m_pSelectedTool = new CPaintPie();
			m_pSelectedTool->m_uFigureType=10;
			m_pSelectedTool->m_uObjectType=1;//地图对象的类型0=路径1=建筑2=设备
			m_pSelectedTool->m_rgbPrimary= RGB(0, 0, 255);// blue
			NoPaint();
			m_bpaintPie=TRUE;	//TRUE表示正在画扇形
			break;

		case ID_TOOL_BUILDING_LINE_NORMAL:
		case ID_TOOL_BUILDING_LINE_STARTNODE:
		case ID_TOOL_BUILDING_LINE_STARTENDNODE:
			m_pSelectedTool = new CPaintLine();
			m_pSelectedTool->m_uFigureType=0;
			m_pSelectedTool->m_uObjectType=1;//地图对象的类型0=路径1=建筑2=设备
			m_pSelectedTool->m_rgbPrimary= RGB(0, 0, 255);// blue
			NoPaint();
			m_bpaintLine=TRUE;	//TRUE表示正在画直线
			break;

		case ID_TOOL_BUILDING_CLOCKWISE_NORMAL:
		case ID_TOOL_BUILDING_CLOCKWISE_RADIUS:
		case ID_TOOL_BUILDING_CLOCKWISE_STARTNODE:
		case ID_TOOL_BUILDING_CLOCKWISE_STARTENDNODE:
			m_pSelectedTool = new CPaintArc();
			m_pSelectedTool->m_uFigureType=1;
			m_pSelectedTool->m_uObjectType=1;//地图对象的类型0=路径1=建筑2=设备
			((CPaintArc*) m_pSelectedTool)->m_uArcPathDirection=1;
			m_pSelectedTool->m_rgbPrimary= RGB(0, 0, 255);// blue
			NoPaint();
			m_bpaintarc=TRUE;//TRUE表示正在画弧			
			break;

		case ID_TOOL_BUILDING_ANTICLOCKWISE_NORMAL:
		case ID_TOOL_BUILDING_ANTICLOCKWISE_RADIUS:
		case ID_TOOL_BUILDING_ANTICLOCKWISE_STARTNODE:
		case ID_TOOL_BUILDING_ANTICLOCKWISE_STARTENDNODE:
			m_pSelectedTool = new CPaintArc();
			m_pSelectedTool->m_uFigureType=1;
			m_pSelectedTool->m_uObjectType=1;//地图对象的类型0=路径1=建筑2=设备
			((CPaintArc*) m_pSelectedTool)->m_uArcPathDirection=0;
			m_pSelectedTool->m_rgbPrimary= RGB(0, 0, 255);// blue
			NoPaint();
			m_bpaintarc=TRUE;//TRUE表示正在画弧
			break;

		case ID_TOOL_BUILDING_LAZYS_ANGLESTARTENDNODE:
		case ID_TOOL_BUILDING_LAZYS_ANGLE:
		case ID_TOOL_BUILDING_LAZYS_ANGLESTARTNODE:
			m_pSelectedTool = new CPaintLazys();
			m_pSelectedTool->m_uFigureType=2;
			m_pSelectedTool->m_uObjectType=1;//地图对象的类型0=路径1=建筑2=设备
			m_pSelectedTool->m_rgbPrimary= RGB(0, 0, 255);// blue
			NoPaint();
			m_bpaintLazys=TRUE;	//TRUE表示正在画懒-S
			break;
		
		case ID_TOOL_DEVICE_LINE_NORMAL:
		case ID_TOOL_DEVICE_LINE_STARTNODE:
		case ID_TOOL_DEVICE_LINE_STARTENDNODE:
			m_pSelectedTool = new CPaintLine();
			m_pSelectedTool->m_uFigureType=0;
			m_pSelectedTool->m_uObjectType=2;//地图对象的类型0=路径1=建筑2=设备
			m_pSelectedTool->m_rgbPrimary= RGB(0, 255, 0);// blue
			NoPaint();
			m_bpaintLine=TRUE;	//TRUE表示正在画直线
			break;

		case ID_TOOL_DEVICE_CLOCKWISE_NORMAL:
		case ID_TOOL_DEVICE_CLOCKWISE_RADIUS:
		case ID_TOOL_DEVICE_CLOCKWISE_STARTNODE:
		case ID_TOOL_DEVICE_CLOCKWISE_STARTENDNODE:
			m_pSelectedTool = new CPaintArc();
			m_pSelectedTool->m_uFigureType=1;
			m_pSelectedTool->m_uObjectType=2;//地图对象的类型0=路径1=建筑2=设备
			((CPaintArc*) m_pSelectedTool)->m_uArcPathDirection=1;
			m_pSelectedTool->m_rgbPrimary= RGB(0, 255, 0);// blue
			NoPaint();
			m_bpaintarc=TRUE;//TRUE表示正在画弧			
			break;

		case ID_TOOL_DEVICE_ANTICLOCKWISE_NORMAL:
		case ID_TOOL_DEVICE_ANTICLOCKWISE_RADIUS:
		case ID_TOOL_DEVICE_ANTICLOCKWISE_STARTNODE:
		case ID_TOOL_DEVICE_ANTICLOCKWISE_STARTENDNODE:
			m_pSelectedTool = new CPaintArc();
			m_pSelectedTool->m_uFigureType=1;
			m_pSelectedTool->m_uObjectType=2;//地图对象的类型0=路径1=建筑2=设备
			((CPaintArc*) m_pSelectedTool)->m_uArcPathDirection=0;
			m_pSelectedTool->m_rgbPrimary= RGB(0, 255, 0);// blue
			NoPaint();
			m_bpaintarc=TRUE;//TRUE表示正在画弧
			break;

		case ID_TOOL_DEVICE_LAZYS_ANGLESTARTENDNODE:
		case ID_TOOL_DEVICE_LAZYS_ANGLESTARTNODE:
		case ID_TOOL_DEVICE_LAZYS_ANGLE:
			m_pSelectedTool = new CPaintLazys();
			m_pSelectedTool->m_uFigureType=2;
			m_pSelectedTool->m_uObjectType=2;//地图对象的类型0=路径1=建筑2=设备
			m_pSelectedTool->m_rgbPrimary= RGB(0, 255, 0);// blue
			NoPaint();
			m_bpaintLazys=TRUE;	//TRUE表示正在画懒-S
			break;
			
		case ID_TOOL_DEVICE_CHORD_NORMAL:
		case ID_TOOL_DEVICE_CHORD_RADIUS:
		case ID_TOOL_DEVICE_CHORD_STARTNODE:
		case ID_TOOL_DEVICE_CHORD_STARTENDNODE:
			m_pSelectedTool = new CPaintChord();
			m_pSelectedTool->m_uFigureType=9;
			m_pSelectedTool->m_uObjectType=2;//地图对象的类型0=路径1=建筑2=设备
			m_pSelectedTool->m_rgbPrimary= RGB(0, 255, 0);// blue
			NoPaint();
			m_bpaintChord=TRUE;	//TRUE表示正在画弦
			break;

		case ID_TOOL_DEVICE_ELLIPSE_STARTENDNODE:
		case ID_TOOL_DEVICE_ELLIPSE_NORMAL:	
			m_pSelectedTool = new CPaintEllipse();
			m_pSelectedTool->m_uFigureType=5;
			m_pSelectedTool->m_uObjectType=2;//地图对象的类型0=路径1=建筑2=设备
			m_pSelectedTool->m_rgbPrimary= RGB(0, 255, 0);// blue
			NoPaint();
			m_bpaintEllipse=TRUE;//TRUE表示正在画椭圆
			break;

		case ID_TOOL_DEVICE_PIE_NORMAL:
		case ID_TOOL_DEVICE_PIE_RADIUS:
		case ID_TOOL_DEVICE_PIE_STARTNODE:
		case ID_TOOL_DEVICE_PIE_STARTENDNODE:
			m_pSelectedTool = new CPaintPie();
			m_pSelectedTool->m_uFigureType=10;
			m_pSelectedTool->m_uObjectType=2;//地图对象的类型0=路径1=建筑2=设备
			m_pSelectedTool->m_rgbPrimary= RGB(0, 255, 0);// blue
			NoPaint();
			m_bpaintPie=TRUE;	//TRUE表示正在画扇形
			break;

		case ID_TOOL_DEVICE_POLYGON_NORMAL:
		case ID_TOOL_DEVICE_POLYGON_ALLNODE:
			m_pSelectedTool = new CPaintPolygon();
			m_pSelectedTool->m_uFigureType=7;
			m_pSelectedTool->m_uObjectType=2;//地图对象的类型0=路径1=建筑2=设备
			m_pSelectedTool->m_rgbPrimary= RGB(0, 255, 0);// blue
			NoPaint();
			m_bpaintPolygon=TRUE;//TRUE表示正在画多边形
			break;

		case ID_TOOL_DEVICE_RECT_NORMAL:
		case ID_TOOL_DEVICE_RECT_STARTENDNODE:
			m_pSelectedTool = new CPaintRect();
			m_pSelectedTool->m_uFigureType=6;
			m_pSelectedTool->m_uObjectType=2;//地图对象的类型0=路径1=建筑2=设备
			m_pSelectedTool->m_rgbPrimary= RGB(0, 255, 0);// blue
			NoPaint();
			m_bpaintRect=TRUE;	//TRUE表示正在画矩形
			break;

		case ID_TOOL_DEVICE_ROUNDRECT_ELLIPSE:
		case ID_TOOL_DEVICE_ROUNDRECT_ELLIPSESTARTENDNODE:	
			m_pSelectedTool = new CPaintRoundrect();
			m_pSelectedTool->m_uFigureType=8;
			m_pSelectedTool->m_uObjectType=2;//地图对象的类型0=路径1=建筑2=设备
			m_pSelectedTool->m_rgbPrimary= RGB(0, 255, 0);// blue
			NoPaint();
			m_bpaintRoundrect=TRUE;//TRUE表示正在画圆角矩形
			break;
			
		default:
			m_pSelectedTool = NULL;		
			break;
	}

	return;
}


void CPaintobjDoc::OnUpdateToolCheck(CCmdUI* pCmdUI) 
{
	pCmdUI->SetCheck(m_nSelectedTool == pCmdUI->m_nID);
}

void CPaintobjDoc::OnToolSelector() 
{	
	m_bZoomIn= FALSE;
	m_bZoomOut= FALSE;
	m_nSelectedTool = ID_TOOL_SELECTOR;
	GenerateTool();
}

void CPaintobjDoc::ExpandBounds(CRect* pRect)
{
	fxmin=(double) (1E+20); fxmax=(double) (1E-20);
	fymin=(double) (1E+20); fymax=(double) (1E-20);

	CPainted*	pPainted;
	int nShapes = m_Objects.GetSize();
	if(nShapes==0)
	{
		fxmin=0;
		fymin=0;		
		fxmax=50;
		fymax=50;
	}
	else
	{
		for (int index = 0; index < nShapes; index++)
		{	
			double minx,miny,maxx,maxy;
			pPainted =(CPainted*) m_Objects[index];
			pPainted->GetBoundingRect(minx,miny,maxx,maxy);		
			fxmin=min(fxmin, minx);
			fymin=min(fymin, miny);
			fxmax=max(fxmax, maxx);
			fymax=max(fymax, maxy);
		}
	}
	CPoint	ppp;
	CPnt pnt(fxmax,fymin);
	DPtoVP(pnt,ppp);
	m_size.cx = ppp.x+20;
	m_size.cy = ppp.y+20;

}


//
//    Get the specified node object.
//
CNode* CPaintobjDoc::GetNode(USHORT uId)
{	
	int nShapes = m_Objectsnode.GetSize();
	for (int i = 0; i < nShapes; i++)
	{
		if (m_Objectsnode[i]->m_uId == uId)
			return m_Objectsnode[i];
	}
	return NULL;
}

void CPaintobjDoc::GetBounds(CSize* pSize)
{
	*pSize = m_size;
}

void CPaintobjDoc::RecalcBoundary()
{
	m_size.cy = m_size.cx = 0;
	CPainted*	pPainted;
	int nShapes = m_Objects.GetSize();
    for (int index = 0; index < nShapes; index++)
    {
		double minx,miny,maxx,maxy;
        pPainted =(CPainted*) m_Objects[index];
		pPainted->GetBoundingRect(minx,miny,maxx,maxy);

		//m_size.cy = max(m_size.cy, miny);
		//m_size.cx = max(m_size.cx, maxx);
	 }
}



void CPaintobjDoc::OnViewZoomin() //图象缩小
{	
	m_bZoomOut= FALSE;
	m_bZoomIn= TRUE;
	m_nSelectedTool = IDC_CURSORZOOMIN;
	GenerateTool();

	// TODO: Add your command handler code here	

⌨️ 快捷键说明

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