Line.cpp
资源名称:基本GIS系统开发.rar [点击查看]
上传用户:yklx818
上传日期:2013-04-13
资源大小:459k
文件大小:2k
源码类别:
GIS编程
开发平台:
Visual C++
- // Line.cpp: implementation of the CLine class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "Draw.h"
- #include "Line.h"
- //#include "DrawDoc.h"
- //#include "Data.h"
- #include "math.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- //extern CGraphPara *p_GraphPara;
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- //CLine::CLine()
- //{
- //}
- extern BOOL IsRectCross(float minx,float miny,float maxx,float maxy);
- void CLine::Draw(CDC* pDC,int m_DrawMode,int m_DrawModel,short BackColor)
- {
- int x1,y1,x2,y2;
- if(b_Delete)
- return ;
- float minx,miny,maxx,maxy;
- GetRect(&minx,&miny,&maxx,&maxy);//得到边界矩形
- if(!IsRectCross(minx,miny,maxx,maxy))//如果边界矩形不与屏幕窗口相交
- {
- return;
- }
- short LineType=m_LineType;
- short LineWide=max(1,DLtoVL(m_LineWide));
- short ColorPen=m_ColorPen;
- if(m_DrawModel==1)
- {
- if(m_LineType!=2)
- LineType=2;
- else
- LineType++;
- }
- if(m_DrawModel==2)
- {
- ColorPen=BackColor;
- }
- CGraphPara m_GraphPara;
- CGraphPara *p_GraphPara;
- p_GraphPara=&m_GraphPara;
- CPen pen(LineType,LineWide,p_GraphPara->GetColor(ColorPen));
- CPen* pOldPen=pDC->SelectObject(&pen);
- if(m_DrawMode==0)
- {
- pDC->SetROP2(R2_COPYPEN);
- }
- else if(m_DrawMode==1)
- pDC->SetROP2(R2_NOT);
- DPtoVP(m_X1,m_Y1,&x1,&y1);
- DPtoVP(m_X2,m_Y2,&x2,&y2);
- pDC->MoveTo(x1,y1);
- pDC->MoveTo(x2,y2);
- pDC->SelectObject(pOldPen);
- }
- void CLine::GetRect(float* minX,float* minY,float* maxX,float* maxY)
- {
- *minX=min(m_X1,m_X2);
- *maxX=max(m_X1,m_X2);
- *minY=min(m_Y1,m_Y2);
- *minY=min(m_Y1,m_Y2);
- }
- void CLine::CalLong()
- {
- m_fLong=sqrt((m_X1-m_X2)*(m_X1-m_X2)+(m_Y1-m_Y2)*(m_Y1-m_Y2));
- }
- BOOL CLine::IsPoint(float x,float y,float j1,float blc)
- {
- float xx,x1,y1,x2,y2;
- if(b_Delete)
- return FALSE;
- GetRect(&x1,&y1,&x2,&y2);
- if(!(x>=x1&&x<=x2&&y>=y1&&y<=y2))
- return FALSE;
- xx=PointLine(x,y,m_X1,m_Y1,m_X2,m_Y2);
- if(xx<j1)
- return TRUE;
- return FALSE;
- }
- void CLine::Move(float x_Move,float y_Move)
- {
- m_X1+=x_Move;
- m_X2+=x_Move;
- m_Y1+=y_Move;
- m_Y2+=y_Move;
- }
- void CLine::Rotate(float baseX,float baseY,float angle)
- {
- RotatePoint(baseX,baseY,angle,&this->m_X1,&this->m_Y1);
- RotatePoint(baseX,baseY,angle,&this->m_X2,&this->m_Y2);
- }
- CLine::~CLine()
- {
- }