You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

148 lines
3.2 KiB
C++

#include "StdAfx.h"
#include "ObjPline.h"
#include "GlobalDrawMgr.h"
#include "DataPoint.h"
#include "GlobalFunction.h"
CObjPline::CObjPline(void)
{
}
CObjPline::~CObjPline(void)
{
}
CString CObjPline::GetStr()
{
CString str = "多线段";
return str;
}
#if 1
//通过矩形的形式创建多线段point1 是左下角的点
void CObjPline::Creat(Dbxy point1,double w,double h)
{
//删除所有数据点
DelAllPt();
Dbxy point2(point1.x+w,point1.y+h);
CreatRect(point1,point2);
}
//创建两点的直线
void CObjPline::Creat(Dbxy point1,Dbxy point2)
{
//删除所有数据点
DelAllPt();
if(point1 == point2)//相同的两个点
{
{
CDataPoint DataPoint(point1);
DataPoint.SetIsNode(true);
AddDataPoint(DataPoint);
}
}
else
{
{
CDataPoint DataPoint(point1);
DataPoint.SetIsNode(true);
AddDataPoint(DataPoint);
}
{
CDataPoint DataPoint(point2);
DataPoint.SetIsNode(true);
AddDataPoint(DataPoint);
}
AddMidNodePoint(point1,point2);
}
}
//添加一个obj 到多线段的后部(bReverse 为true 时反向)
void CObjPline::AddObj(Sptr<CObjBase> &pObj,bool bReverse)
{
if(bReverse)
{
vector<CDataPoint>&vec = pObj->GetPtContainer();
int size = vec.size();
for(int i=size-1;i>=0;i--)
{
AddDataPoint(vec[i]);
}
}
else
{
vector<CDataPoint>&vec = pObj->GetPtContainer();
int size = vec.size();
for(int i=0;i<size;i++)
{
AddDataPoint(vec[i]);
}
}
}
//创建所有线段的中间点为捕捉点
void CObjPline::CreatMidNode()
{
m_NodePtContainer.DelAllPt();
vector<CDataPoint>&vec = GetPtContainer();
int size = vec.size();
for(int i=0;i<size;i++)
{
if(i>0)
{
AddMidNodePoint(vec[i-1].GetPt(),vec[i].GetPt());
}
}
}
//添加一个中间节点用来捕捉
void CObjPline::AddMidNodePoint(Dbxy point1,Dbxy point2)
{
Dbxy pt = CenterPtOfTwoPoint(point1,point2);
CDataPoint DataPoint(pt);
DataPoint.SetIsNode(true);
AddNodePt(DataPoint);
}
void CObjPline::CreatRect(DbRect rect)
{
Dbxy point1(rect.L,rect.B);
Dbxy point2(rect.R,rect.T);
CreatRect(point1,point2);
}
void CObjPline::CreatRect(Dbxy point1,Dbxy point2)
{
Dbxy pt = point1;
{
CDataPoint DataPoint(pt);
DataPoint.SetIsNode(true);
AddDataPoint(DataPoint);
}
pt.y = point2.y;
{
CDataPoint DataPoint(pt);
DataPoint.SetIsNode(true);
AddDataPoint(DataPoint);
}
AddMidNodePoint(point1,pt);
AddMidNodePoint(point2,pt);
pt = point2;
{
CDataPoint DataPoint(pt);
DataPoint.SetIsNode(true);
AddDataPoint(DataPoint);
}
pt.y = point1.y;
{
CDataPoint DataPoint(pt);
DataPoint.SetIsNode(true);
AddDataPoint(DataPoint);
}
AddMidNodePoint(point1,pt);
AddMidNodePoint(point2,pt);
pt = point1;
{
CDataPoint DataPoint(pt);
DataPoint.SetIsNode(true);
AddDataPoint(DataPoint);
}
}
#endif
#if 1//通过正多边形的形式创建
#endif