QLineObj.cpp
资源名称:QGIS.rar [点击查看]
上传用户:oybseng
上传日期:2015-04-27
资源大小:7831k
文件大小:19k
源码类别:
GDI/图象编程
开发平台:
Visual C++
- // QLineObj.cpp: implementation of the CQLineObj class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "..StdAfx.h"
- #include "..includeQLineObj.h"
- #include "..includeQGISAlgorithmLib.h"
- #include "..includeQGlobalObj.h"
- #include <vector>
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- using namespace std;
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- CQLineObj::CQLineObj():CQBaseObj()
- {
- m_szObjName.Format("线条%ld",m_lObjID);
- m_nObjType = QGIS_LINE;
- m_nLineType = 0;
- m_bClosed = FALSE;
- m_lStartNode = -1;
- m_lEndNode = -1;
- m_lLeftArea = -1;
- m_lRightArea = -1;
- m_bShowPt = FALSE;
- m_Boundary.SetRect(0,0,0,0); //直线对象边界矩形初始化
- m_fElevation = 0.0f;
- m_nSplineType = 0; //普通折线
- }
- CQLineObj::~CQLineObj()
- {
- }
- CQLineObj::CQLineObj(CQLineObj & lObj):CQBaseObj(lObj)
- {
- m_szObjName = lObj.GetObjName();
- m_lStartNode = lObj.m_lStartNode;
- m_lEndNode = lObj.m_lEndNode;
- m_lLeftArea = lObj.m_lLeftArea;
- m_lRightArea = lObj.m_lRightArea;
- m_PtList.Copy(lObj.m_PtList);
- m_bClosed = lObj.IsClosed();
- m_bShowPt = lObj.GetShowPointFlag();
- m_PtList.Copy(lObj.m_PtList);
- lObj.GetBoundingRect(&m_Boundary);
- m_fElevation = lObj.GetElevation();
- m_nSplineType = lObj.GetSplineType();
- }
- void CQLineObj::Copy(CQLineObj & lObj)
- {
- CQBaseObj::Copy(lObj); //调用基类的拷贝函数
- if(lObj.GetObjType() == QGIS_LINE)
- {
- CQLineObj & p = (CQLineObj&)lObj;
- m_szObjName = p.GetObjName();
- m_lStartNode = p.m_lStartNode;
- m_lEndNode = p.m_lEndNode;
- m_lLeftArea = p.m_lLeftArea;
- m_lRightArea = p.m_lRightArea;
- m_PtList.Copy(p.m_PtList);
- m_bClosed = p.IsClosed();
- m_bShowPt = p.GetShowPointFlag();
- lObj.GetBoundingRect(&m_Boundary);
- m_fElevation = lObj.GetElevation();
- m_nSplineType = lObj.GetSplineType();
- }
- }
- BOOL CQLineObj::IsClosed()
- {
- return m_bClosed;
- }
- void CQLineObj::SetLineClosed(BOOL bClosed)
- {
- m_bClosed = bClosed;
- if(m_bClosed == FALSE) //假如是线条不闭合
- {
- int nPtCount = m_ptListDisplay.GetSize();
- if(nPtCount<=2) return;
- //两个点还闭合个屁啊
- CQPoint * pt1 = m_ptListDisplay.GetPoint(0);
- CQPoint * pt2 = m_ptListDisplay.GetPoint(nPtCount-1);
- if(*pt1 == *pt2) //假如当前点集的首末两点的值相同
- {
- m_ptListDisplay.Delete(nPtCount-1);
- }
- }
- }
- //////////////////////////////////////////
- ///***************CQGIS****************///
- ///函数名称:Create
- ///返回类型:无
- ///入口参数:CQPointArray & ptArray
- ///出口参数:无
- ///思路说明:有点阵创建线条对象
- ///***************CQGIS****************///
- //////////////////////////////////////////
- CQLineObj * CQLineObj::Create(CQPointArray & ptArray)
- {
- int nSize = ptArray.GetSize();
- if(nSize == 0) return NULL;
- CQLineObj * pLine = new CQLineObj;
- pLine->m_PtList.Copy(ptArray);
- pLine->CalculateBoundary();
- return pLine;
- }
- //显示图元
- //m_nDrawMode为下列值之一
- //R2_BLACK , //R2_COPYPEN , //R2_MASKNOTPEN
- //R2_MASKPEN //R2_MASKPENNOT //R2_MERGENOTPEN
- //R2_MERGEPEN //R2_MERGEPENNOT //R2_NOP
- //R2_NOT ///R2_NOTCOPYPEN //R2_NOTMASKPEN
- //R2_NOTMERGEPEN //R2_NOTXORPEN //R2_WHITE //R2_XORPEN
- void CQLineObj::Display(CQCoordSys * pSys,CDC * pDC,int nDrawMode,int nSpecialMode,COLORREF * pColor)
- {
- if(GetObjDeleted() || GetObjHided())return;
- int nPtCount = m_ptListDisplay.GetSize();
- if(nPtCount<2) return;
- pDC->SetROP2(nDrawMode); // 设置绘制模式
- if(m_bClosed)
- {
- m_PtList.AddPoint(m_ptListDisplay.GetPoint(0)->GetX(),m_ptListDisplay.GetPoint(0)->GetY());
- ++nPtCount;
- }
- //点数据准备,将其存放在ppoints内存块中,节点个数存放在ptCount;
- CPoint * ppt = new CPoint[nPtCount];
- for(int i=0;i<nPtCount;i++)
- {
- pSys->WPtoLP(*m_ptListDisplay.GetPoint(i),ppt+i);
- }
- COLORREF crPen,crBrush;
- if(nSpecialMode == 1) //假如是选中
- {
- crPen = RGB(255,0,0); //红
- crBrush = RGB(0,255,0);//绿
- }
- else if(nSpecialMode == 2) // 指定颜色绘制
- {
- crPen = *pColor;
- crBrush = *pColor;
- }
- else
- {
- crPen = m_crPenColor;
- crBrush = m_crBrushColor;
- }
- CPen newPen(m_nLineType,(int)m_fLineWidth,crPen);
- CPen * pOldPen = pDC->SelectObject(&newPen);
- pDC->Polyline(ppt,nPtCount);
- if(m_bShowPt) //假如要显示点
- {
- for(int j=0;j<nPtCount;j++)
- {
- CQPoint * pt = m_ptListDisplay.GetPoint(j);
- CPoint ptLogic;
- pSys->WPtoLP(*pt,&ptLogic);
- int nRadius = 3;
- pDC->Ellipse((int)(ptLogic.x-nRadius),(int)(ptLogic.y-nRadius),(int)(ptLogic.x+nRadius),(int)(ptLogic.y+nRadius));
- }
- }
- pDC->SelectObject(pOldPen);
- if(ppt) delete []ppt;
- }
- long CQLineObj::GetPtInWndport(CQCoordSys * pSys)
- {
- CRect rectClient;
- CBoundaryRect rectTemp;
- pSys->GetWndport(rectClient.left,rectClient.top,rectClient.right,rectClient.bottom);
- pSys->LPtoWP(rectClient,&rectTemp);
- long nPtInView = 0;
- long nPtCount = m_PtList.GetSize();
- for(int i=0;i<nPtCount;i++)
- {
- if(rectTemp.PtInRect(*m_PtList.GetPoint(i)))
- nPtInView++;
- }
- return nPtInView;
- }
- void CQLineObj::Move(double dx,double dy)
- {
- int nSize = m_PtList.GetSize();
- if(nSize == 0)return;
- for(int i=0;i<nSize;i++)
- {
- m_PtList.GetPoint(i)->Move(dx,dy);
- }
- m_Boundary.Offset(dx,dy);
- CalculateDisplayPtlist();
- }
- void CQLineObj::Rotate(CQPoint & pt,double & fAngleDegree)
- {
- int nSize = m_PtList.GetSize();
- for(int i=0;i<nSize;i++)
- {
- CQBaseObj::Rotate(m_PtList[i],pt,fAngleDegree);
- }
- CalculateBoundary();
- }
- void CQLineObj::GetBoundingRect(CBoundaryRect * pRect)
- {
- if(!pRect) return;
- CalculateBoundary(pRect);
- }
- //框选
- BOOL CQLineObj::Select(CQCoordSys * pSys,CBoundaryRect & rectSel)
- {
- int i = 0;
- CBoundaryRect rectTemp;
- GetBoundingRect(&rectTemp);
- //先判断边界矩形,如果边界矩形不相交 则肯定
- if(!rectTemp.IsCross(&rectSel)) return FALSE;
- //m_PtList被替换
- int NumPoint = m_ptListDisplay.GetSize(); //获得直线上的点数
- int nCount = 0;//边界矩形的一条边与折线某一条边的交点个数
- double dx,dy;
- CQPoint rectLeftBottom,rectLeftTop,rectRightBottom,rectRightTop;
- dx = rectSel.m_fMinX;
- dy = rectSel.m_fMinY;
- rectLeftBottom.SetPoint(dx,dy); //左下角坐标
- dx = rectSel.m_fMinX;
- dy = rectSel.m_fMaxY; //左上角坐标
- rectLeftTop.SetPoint(dx,dy);
- dx = rectSel.m_fMaxX;
- dy = rectSel.m_fMinY; //右下角坐标
- rectRightBottom.SetPoint(dx,dy);
- dx = rectSel.m_fMaxX;
- dy = rectSel.m_fMaxY; //右上角坐标
- rectRightTop.SetPoint(dx,dy);
- // 思路依次对线条的每一个点进行判断 如果有一个点选中则表示选中
- // 若没有直接选中某个角点则对折线对象中的每一个线条进行判断 看
- // 是否与边界矩形的边相交,若相交则表示选中
- CQPointArray ptArray;
- for(i=0;i<NumPoint-1;i++)
- {
- CQPoint * pt1 = m_ptListDisplay.GetPoint(i);
- CQPoint * pt2 = m_ptListDisplay.GetPoint(i+1);
- if(rectSel.PtInRect(*(m_ptListDisplay.GetPoint(i))))
- return TRUE;
- else
- {
- BOOL IsCross = FALSE;
- IsCross = CQGISAlgorithmLib::IsLineCross(*pt1,*pt2,rectLeftBottom,rectLeftTop);
- if(IsCross)return TRUE;
- IsCross = CQGISAlgorithmLib::IsLineCross(*pt1,*pt2,rectLeftTop,rectRightTop);
- if(IsCross)return TRUE;
- IsCross = CQGISAlgorithmLib::IsLineCross(*pt1,*pt2,rectRightTop,rectRightBottom);
- if(IsCross)return TRUE;
- IsCross = CQGISAlgorithmLib::IsLineCross(*pt1,*pt2,rectRightBottom,rectLeftBottom);
- if(IsCross)return TRUE;
- }
- }
- return FALSE;
- }
- //点选
- BOOL CQLineObj::Select(CQCoordSys * pSys,CQPoint & pt,double fEffactDistance)
- {
- CBoundaryRect bRect;
- GetBoundingRect(&bRect);
- if(!bRect.PtInRect(pt))
- return FALSE;
- //m_PtList被替换
- int nPtNum = m_ptListDisplay.GetSize();
- for(int i=0;i<nPtNum-1;i++)
- {
- CQPoint * pt1 = m_ptListDisplay.GetPoint(i);
- CQPoint * pt2 = m_ptListDisplay.GetPoint(i+1);
- double fDistance = CQPoint::Distance(pt,*pt1,*pt2);
- if(fDistance<=g_QObj.g_fEffectiveDistance)return TRUE;
- }
- return FALSE;
- }
- void CQLineObj::CalculateBoundary(CBoundaryRect * pRect)
- {
- int nSize = m_PtList.GetSize();
- if(nSize == 0)return;
- m_Boundary.m_fMinX = m_PtList[0]->GetX();
- m_Boundary.m_fMinY = m_PtList[0]->GetY();
- m_Boundary.m_fMaxX = m_PtList[0]->GetX();
- m_Boundary.m_fMaxY = m_PtList[0]->GetY();
- //获取边界矩形
- for(int i=1;i<nSize;i++)
- {
- m_Boundary.m_fMinX = min(m_Boundary.m_fMinX,m_PtList.GetPoint(i)->GetX());
- m_Boundary.m_fMinY = min(m_Boundary.m_fMinY,m_PtList.GetPoint(i)->GetY());
- m_Boundary.m_fMaxX = max(m_Boundary.m_fMaxX,m_PtList.GetPoint(i)->GetX());
- m_Boundary.m_fMaxY = max(m_Boundary.m_fMaxY,m_PtList.GetPoint(i)->GetY());
- }
- //判断是垂直线 或是水平线的情形
- if(m_Boundary.m_fMinX == m_Boundary.m_fMaxX) //垂直线
- {
- m_Boundary.m_fMinX -= 5;
- m_Boundary.m_fMaxX += 5;
- }
- else if(m_Boundary.m_fMinY == m_Boundary.m_fMaxY) //水平线
- {
- m_Boundary.m_fMinY -= 5;
- m_Boundary.m_fMaxY += 5;
- }
- CalculateDisplayPtlist();
- if(pRect)
- {
- pRect->m_fMinX = m_Boundary.m_fMinX;
- pRect->m_fMinY = m_Boundary.m_fMinY;
- pRect->m_fMaxX = m_Boundary.m_fMaxX;
- pRect->m_fMaxY = m_Boundary.m_fMaxY;
- }
- }
- CString CQLineObj::VarToStr()
- {
- CString szResult;
- CString szObj = CQBaseObj::VarToStr();
- CString szLine;
- szLine.Format("n是否圈闭:%d是否显示点:%d拓扑起始接点ID:%ld拓扑终止接点ID:%ld拓扑左多边形 ID:%ld拓扑右多边形 ID:%ld高程:%10.4fn",m_bClosed,m_bShowPt,m_lStartNode,m_lEndNode,m_lLeftArea,m_lRightArea,m_fElevation);
- int nSize = m_PtList.GetSize();
- CString szCount;
- szCount.Format("线条共有%d个结点n",nSize);
- szLine += szCount;
- CString szNode;
- for(int i=0;i<nSize;i++)
- {
- szNode.Format("结点X坐标:%f结点Y坐标:%fn",m_PtList.GetPoint(i)->GetX(),m_PtList.GetPoint(i)->GetY());
- szLine += szNode;
- }
- szResult = szObj+szLine;
- return szResult;
- }
- //////////////////////////////////////////
- ///***************CQGIS****************///
- ///函数名称:
- ///返回类型:
- ///入口参数:
- ///出口参数:
- ///思路说明:
- ///***************CQGIS****************///
- //////////////////////////////////////////
- void CQLineObj::Serialize(CArchive& ar)
- {
- CQBaseObj::Serialize(ar);
- if(ar.IsStoring())
- {
- ar.Write(&m_lStartNode,sizeof(long));
- ar.Write(&m_lEndNode,sizeof(long));
- ar.Write(&m_lLeftArea,sizeof(long));
- ar.Write(&m_lRightArea,sizeof(long));
- float fEle = static_cast<float>(m_fElevation);
- ar.Write(&fEle,sizeof(float));
- ar.Write(&m_nSplineType,sizeof(int));
- m_PtList.Serialize(ar);
- }
- else
- {
- ar.Read(&m_lStartNode,sizeof(long));
- ar.Read(&m_lEndNode,sizeof(long));
- ar.Read(&m_lLeftArea,sizeof(long));
- ar.Read(&m_lRightArea,sizeof(long));
- float fEle;
- ar.Read(&fEle,sizeof(float));
- m_fElevation = fEle;
- ar.Read(&m_nSplineType,sizeof(int));
- m_PtList.Serialize(ar);
- CalculateBoundary();
- }
- }
- void CQLineObj::XFlex(double dcp_x,double dFlex)
- {
- int nPtNum = m_PtList.GetSize();
- for(int i=0;i<nPtNum;i++)
- {
- double dx = m_PtList.GetPoint(i)->GetX();
- dx = (dx-dcp_x)*dFlex;
- m_PtList.GetPoint(i)->SetX(dx);
- }
- }
- void CQLineObj::YFlex(double dcp_y,double dFley)
- {
- int nPtNum = m_PtList.GetSize();
- for(int i=0;i<nPtNum;i++)
- {
- double dy = m_PtList.GetPoint(i)->GetY();
- dy = (dy-dcp_y)*dFley;
- m_PtList.GetPoint(i)->SetY(dy);
- }
- }
- double CQLineObj::GetLineLength()
- {
- int nPtNum = m_ptListDisplay.GetSize();
- if(nPtNum == 0)return 0;
- double fResult = 0;
- for(int i=0;i<nPtNum-1;i++)
- {
- CQPoint * pt1 = m_ptListDisplay.GetPoint(i);
- CQPoint * pt2 = m_ptListDisplay.GetPoint(i+1);
- fResult += pt1->Distance(*pt2);
- }
- return fResult;
- }
- void CQLineObj::SetShowPointFlag(BOOL bShowPt)
- {
- m_bShowPt = bShowPt;
- }
- BOOL CQLineObj::GetShowPointFlag()
- {
- return m_bShowPt;
- }
- void CQLineObj::SetStartNodeID(long lStartID)
- {
- m_lStartNode = lStartID;
- }
- void CQLineObj::SetEndNodeID(long lEndID)
- {
- m_lEndNode = lEndID;
- }
- void CQLineObj::SetLeftAreaID(long lLeftID)
- {
- m_lLeftArea = lLeftID;
- }
- void CQLineObj::SetRightAreaID(long lRightID)
- {
- m_lRightArea = lRightID;
- }
- long CQLineObj::GetStartNodeID()
- {
- return m_lStartNode;
- }
- long CQLineObj::GetEndNodeID()
- {
- return m_lEndNode;
- }
- long CQLineObj::GetLeftAreaID()
- {
- return m_lLeftArea;
- }
- long CQLineObj::GetRightAreaID()
- {
- return m_lRightArea;
- }
- void CQLineObj::WriteToFile(CFile * pFile)
- {
- CQBaseObj::WriteToFile(pFile);
- pFile->Write(&m_lStartNode,sizeof(long));
- pFile->Write(&m_lEndNode,sizeof(long));
- pFile->Write(&m_lLeftArea,sizeof(long));
- pFile->Write(&m_lRightArea,sizeof(long));
- float fEle = static_cast<float>(m_fElevation);
- pFile->Write(&fEle,sizeof(float));
- pFile->Write(&m_nSplineType,sizeof(int)); //输出线条的类型
- m_PtList.WritetoFile(pFile);
- }
- void CQLineObj::ReadFromFile(CFile * pFile)
- {
- CQBaseObj::ReadFromFile(pFile);
- pFile->Read(&m_lStartNode,sizeof(long));
- pFile->Read(&m_lEndNode,sizeof(long));
- pFile->Read(&m_lLeftArea,sizeof(long));
- pFile->Read(&m_lRightArea,sizeof(long));
- float fEle;
- pFile->Read(&fEle,sizeof(float));
- pFile->Read(&m_nSplineType,sizeof(int));
- m_fElevation = fEle;
- m_PtList.DeleteAll();
- m_PtList.ReadFromFile(pFile);
- CalculateDisplayPtlist();
- }
- //镜像操作 0-Y轴镜像1-X轴镜像2-原点镜像
- void CQLineObj::Mirror(int nMirrorType /* = 0 */,CQPoint & ptOrign,CQLineObj * pNewLine)
- {
- vector<double> dDisVector; //用于存放距离
- CQPointArray ptMirrorArray;
- int nPtSize = m_PtList.GetSize();
- if(nPtSize == 0)return;
- CQPoint ptTemp;
- double dx = 0,dy = 0;
- double dDis = 0;
- if(!pNewLine)return;
- switch(nMirrorType)
- {
- case 0: //Y轴镜像
- {
- //第一步
- for(int i=0;i<nPtSize;i++)
- {
- dx = ptOrign.GetX();
- dy = m_PtList.GetPoint(i)->GetY();
- ptTemp.SetPoint(dx,dy);
- dDis = 2*ptTemp.XAxisDistance(*m_PtList.GetPoint(i));
- dDisVector.push_back(dDis); //构造点距离数组
- }
- //第二步 构造镜像线坐标数组
- for(int j=0;j<nPtSize;j++)
- {
- dx = m_PtList.GetPoint(j)->GetX() + dDisVector[j];
- dy = m_PtList.GetPoint(j)->GetY();
- ptMirrorArray.AddPoint(dx,dy);
- }
- if(ptMirrorArray.GetSize()>0)
- {
- pNewLine->m_PtList.Copy(ptMirrorArray);
- }
- break;
- }
- case 1://X轴镜像
- {
- //第一步
- for(int i=0;i<nPtSize;i++)
- {
- dx = m_PtList.GetPoint(i)->GetX();
- dy = ptOrign.GetY(); //Y不变
- ptTemp.SetPoint(dx,dy);
- dDis = 2*ptTemp.YAxisDistance(*m_PtList.GetPoint(i));
- dDisVector.push_back(dDis);
- }
- //第二步 构造镜像线坐标数组
- for(int j=0;j<nPtSize;j++)
- {
- dx = m_PtList.GetPoint(j)->GetX();
- dy = m_PtList.GetPoint(j)->GetY() + dDisVector[j];
- ptMirrorArray.AddPoint(dx,dy);
- }
- if(ptMirrorArray.GetSize()>0)
- {
- pNewLine->m_PtList.Copy(ptMirrorArray);
- }
- break;
- }
- case 2: //原点镜像
- {
- Mirror(0,ptOrign,pNewLine);
- CQLineObj tmLine;
- pNewLine->Mirror(1,ptOrign,&tmLine);
- if(tmLine.m_PtList.GetSize()>=1)
- {
- pNewLine->m_PtList.Copy(tmLine.m_PtList);
- }
- break;
- }
- default:
- {
- //第一步
- for(int i=0;i<nPtSize;i++)
- {
- dx = ptOrign.GetX();
- dy = m_PtList.GetPoint(i)->GetY();
- ptTemp.SetPoint(dx,dy);
- dDis = 2*ptTemp.Distance(*m_PtList.GetPoint(i));
- dDisVector.push_back(dDis); //构造点距离数组
- }
- //第二步 构造镜像线坐标数组
- for(int j=0;j<nPtSize;j++)
- {
- dx = m_PtList.GetPoint(j)->GetX() + dDisVector[j];
- dy = m_PtList.GetPoint(j)->GetY();
- ptMirrorArray.AddPoint(dx,dy);
- }
- if(ptMirrorArray.GetSize()>0)
- {
- pNewLine = new CQLineObj;
- pNewLine->m_PtList.Copy(ptMirrorArray);
- }
- break;
- }
- }
- }
- inline void CQLineObj::SetElevation(double fEle)
- {
- m_fElevation = fEle;
- }
- double CQLineObj::GetElevation() const
- {
- return m_fElevation;
- }
- inline void CQLineObj::SetSplineType(int nSplineType)
- {
- if(nSplineType<0 || nSplineType>3)
- nSplineType = 0;
- m_nSplineType = nSplineType;
- CalculateDisplayPtlist(); //计算显示点的列表
- }
- //获取样条曲线的类型
- inline int CQLineObj::GetSplineType() const
- {
- return m_nSplineType;
- }
- void CQLineObj::CalculateDisplayPtlist() //计算折线显示时候的点阵
- {
- m_ptListDisplay.DeleteAll();
- int ptCount = m_PtList.GetSize();
- if(ptCount<2)
- {
- return ;
- }
- else if(ptCount==2)
- {
- for(int i=0;i<ptCount;i++)
- {
- m_ptListDisplay.AddPoint(m_PtList[i]->GetX(),m_PtList[i]->GetY());
- }
- }
- else
- {
- if( m_nSplineType==1 )//为插值曲线
- {
- //加入代码对m_PtList进行处理,要保证m_PtList中的数据不改变
- //另外新建一个CGeoPointArray temppointlist,将插值的结果全部放入其中
- //注意,要内存的使用与释放问题
- double *px = new double[ptCount];
- double *py = new double[ptCount];
- CQPoint * p=0;
- int i=0;
- for(;i<ptCount;i++)
- {
- p = m_PtList.GetPoint(i);
- *(px+i) = p->GetX();
- *(py+i) = p->GetY();
- }
- double * xx, * yy;
- int n = (ptCount-1)*10+1;
- xx = new double [n];
- yy = new double [n];
- CQGISAlgorithmLib::SplineClean2D(px, py, xx, yy, ptCount,10);
- for( i=0;i<n;i++)//将实际坐标转换成屏幕点阵坐标,存入ppoint
- {
- m_ptListDisplay.AddPoint(xx[i],yy[i]);
- }
- if(px) delete[] px;
- if(py) delete[] py;
- if(xx) delete[] xx;
- if(yy) delete[] yy;
- ptCount = n;
- }
- else if ( m_nSplineType==2 )//为2次B样条曲线
- {
- double *px = new double[ptCount];
- double *py = new double[ptCount];
- CQPoint * p=0;
- int i=0;
- for(;i<ptCount;i++)
- {
- p = m_PtList.GetPoint(i);
- *(px+i) = p->GetX();
- *(py+i) = p->GetY();
- }
- double * xx, * yy;
- int n = (ptCount-2)*10+1;
- xx = new double [n];
- yy = new double [n];
- CQGISAlgorithmLib::B2_curves(px, py, xx, yy, ptCount,10);
- for( i=0;i<n;i++)
- {
- m_ptListDisplay.AddPoint(xx[i],yy[i]);
- }
- if(px) delete[] px;
- if(py) delete[] py;
- if(xx) delete[] xx;
- if(yy) delete[] yy;
- ptCount = n;
- }
- else if ( m_nSplineType==3 )//为3次B样条曲线
- {
- double *px = new double[ptCount];
- double *py = new double[ptCount];
- CQPoint * p=0;
- int i=0;
- for(;i<ptCount;i++)
- {
- p = m_PtList.GetPoint(i);
- *(px+i) = p->GetX();
- *(py+i) = p->GetY();
- }
- double * xx, * yy;
- int n = (ptCount-3)*5+1;
- xx = new double [n];
- yy = new double [n];
- CQGISAlgorithmLib::B3_curves(px, py, xx, yy, ptCount,5);
- for( i=0;i<n;i++)
- {
- m_ptListDisplay.AddPoint(xx[i],yy[i]);
- }
- if(px) delete[] px;
- if(py) delete[] py;
- if(xx) delete[] xx;
- if(yy) delete[] yy;
- ptCount = n;
- }
- else //正常显示
- {
- for(int i=0;i<ptCount;i++)//将实际坐标转换成屏幕点阵坐标,存入ppoint
- {
- m_ptListDisplay.AddPoint(m_PtList[i]->GetX(),m_PtList[i]->GetY());
- }
- }
- if(m_bClosed)//如果是闭线
- {
- m_ptListDisplay.AddPoint( m_ptListDisplay[0]->GetX(),
- m_ptListDisplay[0]->GetY());
- }
- }
- }
- void CQLineObj::PtListBeThin(double dThinScale)
- {
- if(dThinScale<0)
- dThinScale = 0.0f;
- m_ptListDisplay.AddPoint(0,0);
- CQGISAlgorithmLib::PtListBeThin(m_PtList,dThinScale);
- }