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.
TwoLaserHead-PushJig/LaiPuLaser/ObjPline.cpp

201 lines
5.4 KiB
C++

#include "StdAfx.h"
#include "ObjPline.h"
#include "GlobalDrawMgr.h"
#include "DataPoint.h"
#include "GlobalFunction.h"
#include "Propertie.h"
#include "PropertieMgr.h"
#include "WorkFileMgr.h"
CObjPline::CObjPline(void)
{
}
CObjPline::~CObjPline(void)
{
}
CString CObjPline::GetStr()
{
CString str = "多线段";
return str;
}
CMFCPropertyGridProperty *CObjPline::CreatSpecialGridProperty(CModule *pModule)
{
CString PropertyName;//属性名称
CString Description;//描述
CString Name;
//-------------------------------------------------------------------------------//
PropertyName = _T("特殊属性");
CMFCPropertyGridProperty* pGroup = new CMFCPropertyGridProperty(PropertyName);
//-------------------------------------------------------------------------------//
{
//添加属性变量映射
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_CutOffset.x);
pPropertie->SetType(_PROP_TYPE_DOUBLE);
pPropertie->SetpModule(pModule);
//添加属性显示
PropertyName = _T("切割偏移X");
Description = _T("区域内的切割偏移x(单位:mm)");
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName,(_variant_t)m_CutOffset.x, Description);
pGroup->AddSubItem(p1);
gDrawPropertieMgr.Insert(p1, pPropertie);
}
{
//添加属性变量映射
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_CutOffset.y);
pPropertie->SetType(_PROP_TYPE_DOUBLE);
pPropertie->SetpModule(pModule);
//添加属性显示
PropertyName = _T("切割偏移Y");
Description = _T("区域内的切割偏移y(单位:mm)");
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName,(_variant_t)m_CutOffset.y, Description);
pGroup->AddSubItem(p1);
gDrawPropertieMgr.Insert(p1, pPropertie);
}
return pGroup;
}
void CObjPline::WriteWorkFileExt(vector<CLab> &LabVec)
{
CObjBase::WriteWorkFileExt(LabVec);
LabVec.push_back(CLab(LAB_OBJ_RECT_OFFSET_X,m_CutOffset.x));
LabVec.push_back(CLab(LAB_OBJ_RECT_OFFSET_Y,m_CutOffset.y));
}
void CObjPline::ReadWorkFileExt(CLabVecRang &LabVecRang)
{
CObjBase::ReadWorkFileExt(LabVecRang);
CWorkFileMgr WorkFileMgr;
{
CLab Lab = WorkFileMgr.FindLab(LabVecRang,LAB_OBJ_RECT_OFFSET_X);
if(Lab.m_ValType != _TYPE_NULL)
{
m_CutOffset.x = Lab.m_Double;
}
}
{
CLab Lab = WorkFileMgr.FindLab(LabVecRang,LAB_OBJ_RECT_OFFSET_Y);
if(Lab.m_ValType != _TYPE_NULL)
{
m_CutOffset.y = Lab.m_Double;
}
}
}
#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();
{
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