Circle.cpp
资源名称:基本GIS系统开发.rar [点击查看]
上传用户:yklx818
上传日期:2013-04-13
资源大小:459k
文件大小:3k
源码类别:
GIS编程
开发平台:
Visual C++
- // Circle.cpp: implementation of the CCircle class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "Draw.h"
- #include "Circle.h"
- //#include "DrawDoc.h"
- #include "Data.h"
- #define pi 3.1415926
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- //extern CGraphPara *p_GraphPara;
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- extern IsRectCross(float minx,float miny,float maxx,float maxy);
- CCircle::CCircle();
- /*float xMinScreen,yMinScreen,xMaxScreen,yMaxScreen;
- BOOL IsRectCross(float minx,float miny,float maxx,float maxy);
- BOOL CText::IsRectCross(float minx,float miny,float maxx,float maxy)
- {
- if(minx>xMaxScreen||maxx<xMinScreen||miny>yMaxScreen||maxy<yMinScreen)
- return FALSE; //如两个矩形不相交
- else
- return TRUE;
- }*/
- void CCircle::Draw(CDC* pDC,int m_DrawMode,int m_DrawModel,short BackColor)
- {
- int x,y,r;
- 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;
- short ColorBrush=m_ColorBrush;
- if(m_DrawModel==1)
- {
- if(m_LineType!=2)
- LineType=2;
- else
- LineType++;
- }
- else if(m_DrawModel==2)
- {
- ColorPen=BackColor;
- ColorBrush=BackColor;
- }
- CGraphPara m_GraphPara;
- CGraphPara *p_GraphPara;
- p_GraphPara=&m_GraphPara;
- CPen pen(LineType,LineWide,p_GraphPara->GetColor(ColorPen));
- CPen* pOldPen=pDC->SelectObject(&pen);
- CBrush brush(p_GraphPara->GetColor(m_ColorBrush));
- CBrush* pOldBrush=pDC->SelectObject(&brush);
- if(m_DrawMode==0)
- pDC->SetROP2(R2_COPYPEN);
- else if(m_DrawMode==1)
- pDC->SetROP2(R2_NOT);
- if(!m_bFill)
- pDC->SelectStockObject(NULL_BRUSH);
- DPtoVP(m_CircleX,m_CircleY,&x,&y);
- r=DLtoVL(m_CircleR);
- pDC->Ellipse(x-r,y-r,x+r,y+r);
- pDC->SelectObject(pOldPen);
- pDC->SelectObject(pOldBrush);
- }
- void CCircle::CalLong()
- {
- m_fLong=m_CircleR*2*pi;
- }
- void CCircle::CalArea()
- {
- m_fArea=pi*m_CircleR*m_CircleR;
- }
- void CCircle::GetRect(float* minX,float* minY,float* maxX,float* maxY)
- {
- *minX=m_CircleX-m_CircleR;
- *minY=m_CircleY-m_CircleR;
- *maxX=m_CircleX+m_CircleR;
- *maxY=m_CircleY+m_CircleR;
- }
- BOOL CCircle::IsPoint(float x,float y,float j1,float blc)
- {
- float xx;
- if(b_Delete)
- return FALSE;
- xx=CalDisp(x,y,m_CircleX,m_CircleY);
- if(!m_bFill)
- {
- if((xx>m_CircleR-j1&&xx<m_CircleR+j1))
- return TRUE;
- }
- else
- {
- if(xx<=m_CircleR)
- return TRUE;
- }
- return FALSE;
- }
- void CCircle::Move(float x_Move,float y_Move)
- {
- m_CircleX+=x_Move;
- m_CircleY+=y_Move;
- }
- void CCircle::Rotate(float baseX,float baseY,float angle)
- {
- RotatePoint(baseX,baseY,angle,&this->m_CircleX,&this->m_CircleY);
- }
- BOOL CCircle::IsFill()
- {
- return m_bFill;
- }
- CCircle::~CCircle()
- {
- }