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.
233 lines
8.9 KiB
C++
233 lines
8.9 KiB
C++
#include "StdAfx.h"
|
|
#include "WorkAreaMgr.h"
|
|
#include "GlobalFunction.h"
|
|
#include "Propertie.h"
|
|
#include "PropertieMgr.h"
|
|
#include "DrawSimpleShape.h"
|
|
#include "AuthorityMgr.h"
|
|
#include "MsgBox.h"
|
|
#include "LogMgr.h"
|
|
|
|
|
|
CWorkAreaMgr *gWorkAreaMgr = new CWorkAreaMgr;
|
|
CWorkAreaMgr::CWorkAreaMgr(void)
|
|
{
|
|
m_bDrawWorkArea = true;//是否绘制工作区域
|
|
m_WorkRectColor = RGB_RED; //工作区域方框颜色
|
|
m_WorkRectSize.w = 100;//工作区域方框尺寸(mm)
|
|
m_WorkRectSize.h = 100;//工作区域方框尺寸(mm)
|
|
RefrashWorkArea();
|
|
}
|
|
CWorkAreaMgr::~CWorkAreaMgr(void)
|
|
{
|
|
}
|
|
#if 1
|
|
CMFCPropertyGridProperty *CWorkAreaMgr::CreatGridProperty()
|
|
{
|
|
CString PropertyName;//属性名称
|
|
CString Description;//描述
|
|
CString Path = _T("WorkArea");//存储路径
|
|
CString Name;
|
|
//-------------------------------------------------------------------------------//
|
|
PropertyName = _T("工作范围");
|
|
CMFCPropertyGridProperty* pGroup = new CMFCPropertyGridProperty(PropertyName);
|
|
//-------------------------------------------------------------------------------//
|
|
if(gAuthorityMgr->CheckAuthority(_FACTORY))
|
|
{
|
|
{
|
|
//添加属性变量映射
|
|
Name = _T("m_bDrawWorkArea");//变量名字
|
|
CPropertie *pPropertie = new CPropertie;
|
|
pPropertie->SetpVal((void*)&m_bDrawWorkArea);
|
|
pPropertie->SetType(_PROP_TYPE_BOOL);
|
|
pPropertie->SetpModule(this);
|
|
pPropertie->SetPath(Path);
|
|
pPropertie->SetName(Name);
|
|
pPropertie->WriteRead(true);//读取保存的属性
|
|
|
|
//添加属性显示
|
|
PropertyName = _T("显示工作范围");
|
|
Description = _T("是否显示工作范围,工作数据需要在工作范围之内");
|
|
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bDrawWorkArea, Description);
|
|
pGroup->AddSubItem(p1);
|
|
gDevicePropertieMgr.Insert(p1, pPropertie);
|
|
}
|
|
//-------------------------------------------------------------------------------//
|
|
{
|
|
//添加属性变量映射
|
|
Name = _T("m_WorkRectColor");//变量名字
|
|
CPropertie *pPropertie = new CPropertie;
|
|
pPropertie->SetpVal((void*)&m_WorkRectColor);
|
|
pPropertie->SetType(_PROP_TYPE_COLOR);
|
|
pPropertie->SetpModule(this);
|
|
pPropertie->SetPath(Path);
|
|
pPropertie->SetName(Name);
|
|
pPropertie->WriteRead(true);//读取保存的属性
|
|
//添加属性显示
|
|
PropertyName = _T("范围边框颜色");
|
|
Description = _T("工作范围边框的颜色");
|
|
CMFCPropertyGridColorProperty* p1 = new CMFCPropertyGridColorProperty(PropertyName,m_WorkRectColor, NULL, Description);
|
|
p1->EnableOtherButton(_T("其他..."));
|
|
p1->EnableAutomaticButton(_T("默认"),RGB_BLACK);
|
|
pGroup->AddSubItem(p1);
|
|
gDevicePropertieMgr.Insert(p1, pPropertie);
|
|
}
|
|
//-------------------------------------------------------------------------------//
|
|
{
|
|
//添加属性变量映射
|
|
Name = _T("m_WorkRectSize_w");//变量名字
|
|
CPropertie *pPropertie = new CPropertie;
|
|
pPropertie->SetpVal((void*)&m_WorkRectSize.w);
|
|
pPropertie->SetType(_PROP_TYPE_DOUBLE);
|
|
pPropertie->SetpModule(this);
|
|
pPropertie->SetPath(Path);
|
|
pPropertie->SetName(Name);
|
|
pPropertie->WriteRead(true);//读取保存的属性
|
|
//添加属性显示
|
|
PropertyName = _T("宽度");
|
|
Description = _T("工作范围的宽度(单位:mm)");
|
|
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName,(_variant_t)m_WorkRectSize.w, Description);
|
|
pGroup->AddSubItem(p1);
|
|
gDevicePropertieMgr.Insert(p1, pPropertie);
|
|
}
|
|
//-------------------------------------------------------------------------------//
|
|
{
|
|
//添加属性变量映射
|
|
Name = _T("m_WorkRectSize_h");//变量名字
|
|
CPropertie *pPropertie = new CPropertie;
|
|
pPropertie->SetpVal((void*)&m_WorkRectSize.h);
|
|
pPropertie->SetType(_PROP_TYPE_DOUBLE);
|
|
pPropertie->SetpModule(this);
|
|
pPropertie->SetPath(Path);
|
|
pPropertie->SetName(Name);
|
|
pPropertie->WriteRead(true);//读取保存的属性
|
|
//添加属性显示
|
|
PropertyName = _T("高度");
|
|
Description = _T("工作范围的高度(单位:mm)");
|
|
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName,(_variant_t)m_WorkRectSize.h, Description);
|
|
pGroup->AddSubItem(p1);
|
|
gDevicePropertieMgr.Insert(p1, pPropertie);
|
|
}
|
|
//-------------------------------------------------------------------------------//
|
|
{
|
|
//添加属性变量映射
|
|
Name = _T("m_CenterPt_x");//变量名字
|
|
CPropertie *pPropertie = new CPropertie;
|
|
pPropertie->SetpVal((void*)&m_CenterPt.x);
|
|
pPropertie->SetType(_PROP_TYPE_DOUBLE);
|
|
pPropertie->SetpModule(this);
|
|
pPropertie->SetPath(Path);
|
|
pPropertie->SetName(Name);
|
|
pPropertie->WriteRead(true);//读取保存的属性
|
|
//添加属性显示
|
|
PropertyName = _T("中心点坐标x");
|
|
Description = _T("工作范围的中心点坐标x(单位:mm)");
|
|
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName,(_variant_t)m_CenterPt.x, Description);
|
|
pGroup->AddSubItem(p1);
|
|
gDevicePropertieMgr.Insert(p1, pPropertie);
|
|
}
|
|
//-------------------------------------------------------------------------------//
|
|
{
|
|
//添加属性变量映射
|
|
Name = _T("m_CenterPt_y");//变量名字
|
|
CPropertie *pPropertie = new CPropertie;
|
|
pPropertie->SetpVal((void*)&m_CenterPt.y);
|
|
pPropertie->SetType(_PROP_TYPE_DOUBLE);
|
|
pPropertie->SetpModule(this);
|
|
pPropertie->SetPath(Path);
|
|
pPropertie->SetName(Name);
|
|
pPropertie->WriteRead(true);//读取保存的属性
|
|
//添加属性显示
|
|
PropertyName = _T("中心点坐标y");
|
|
Description = _T("工作范围的中心点坐标x(单位:mm)");
|
|
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName,(_variant_t)m_CenterPt.y, Description);
|
|
pGroup->AddSubItem(p1);
|
|
gDevicePropertieMgr.Insert(p1, pPropertie);
|
|
}
|
|
}
|
|
//-------------------------------------------------------------------------------//
|
|
return pGroup;
|
|
}
|
|
void CWorkAreaMgr::Ini()
|
|
{
|
|
RefrashWorkArea();
|
|
}
|
|
void CWorkAreaMgr::ExportPar(ofstream *pFile)
|
|
{
|
|
(*pFile)<<"[模块] [CWorkAreaMgr]------------------------------------------------"<<endl;
|
|
(*pFile)<<"[显示工作范围][m_bDrawWorkArea] = "<<m_bDrawWorkArea<<endl;
|
|
(*pFile)<<"[宽度][m_WorkRectSize.w] = "<<m_WorkRectSize.w<<endl;
|
|
(*pFile)<<"[高度][m_WorkRectSize.h] = "<<m_WorkRectSize.h<<endl;
|
|
(*pFile)<<"[中心坐标][m_CenterPt.x] = "<<m_CenterPt.x<<endl;
|
|
(*pFile)<<"[中心坐标][m_CenterPt.y] = "<<m_CenterPt.y<<endl;
|
|
}
|
|
void CWorkAreaMgr::OnPropertyChanged()
|
|
{
|
|
RefrashWorkArea();
|
|
//获取当前视类指针
|
|
CLaiPuLaserView *pView = GetCurViewPtr();
|
|
if(pView)
|
|
{
|
|
pView->RefreshView();
|
|
}
|
|
}
|
|
void CWorkAreaMgr::Draw(CDC* pDC)
|
|
{
|
|
if(gDraw->IsShowPlatformPos()==false)
|
|
{
|
|
DrawWorkArea(pDC);
|
|
}
|
|
}
|
|
#endif
|
|
#if 1//工作区域
|
|
//获取工作区域Rect
|
|
DbRect CWorkAreaMgr::GetWorkArea()
|
|
{
|
|
return m_DbWorkRect;
|
|
}
|
|
//刷新WorkRect
|
|
void CWorkAreaMgr::RefrashWorkArea()
|
|
{
|
|
m_DbWorkRect.L = m_CenterPt.x - m_WorkRectSize.w/2;
|
|
m_DbWorkRect.R = m_CenterPt.x + m_WorkRectSize.w/2;
|
|
m_DbWorkRect.T = m_CenterPt.y + m_WorkRectSize.h/2;
|
|
m_DbWorkRect.B = m_CenterPt.y - m_WorkRectSize.h/2;
|
|
}
|
|
void CWorkAreaMgr::DrawWorkArea(CDC* pDC)
|
|
{
|
|
if(!m_bDrawWorkArea)
|
|
return;
|
|
CPen Pen;
|
|
Pen.CreatePen(PS_INSIDEFRAME,1,m_WorkRectColor);
|
|
DrawRect(pDC,Pen,m_DbWorkRect,false);
|
|
Pen.DeleteObject();
|
|
}
|
|
//检查数据是否在安全范围之内
|
|
bool CWorkAreaMgr::CheckWorkDataInSafeArea(vector<vector<Dbxy>> &vec)
|
|
{
|
|
DbRect rect = GetWorkArea();
|
|
|
|
vector<vector<Dbxy>>::iterator iter = vec.begin();
|
|
vector<vector<Dbxy>>::iterator iter_end = vec.end();
|
|
int size = vec.size();
|
|
//所有的点都需要在范围内
|
|
for(;iter!=iter_end;iter++)
|
|
{
|
|
vector<Dbxy>::iterator iter1 = (*iter).begin();
|
|
vector<Dbxy>::iterator iter1_end = (*iter).end();
|
|
for(;iter1!=iter1_end;iter1++)
|
|
{
|
|
if(IsPointInRect((*iter1),rect)==false)
|
|
{
|
|
CMsgBox MsgBox;
|
|
MsgBox.Show("数据不在安全范围之内!",true);
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
gLogMgr->WriteDebugLog("数据检查OK");
|
|
return true;
|
|
}
|
|
#endif
|
|
|