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.

295 lines
11 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"
#include "GlobalDrawMgr.h"
CWorkAreaMgr *gWorkAreaMgr = new CWorkAreaMgr;
CWorkAreaMgr::CWorkAreaMgr(void)
{
m_bDrawWorkArea = true;//<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ƹ<EFBFBD><C6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
m_bCircle = false;//<2F>Ƿ<EFBFBD>ΪԲ<CEAA><D4B2>
m_bFrame = false;//<2F>Ƿ<EFBFBD>ֻ<EFBFBD><D6BB>ʾ<EFBFBD>߿<EFBFBD>
m_WorkRectColor = RGB_RED; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>򷽿<EFBFBD><F2B7BDBF><EFBFBD>ɫ
m_WorkRectSize.w = 100;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>򷽿<EFBFBD><F2B7BDBF>ߴ<EFBFBD>(mm)
m_WorkRectSize.h = 100;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>򷽿<EFBFBD><F2B7BDBF>ߴ<EFBFBD>(mm)
RefrashWorkArea();
}
CWorkAreaMgr::~CWorkAreaMgr(void)
{
}
#if 1
CMFCPropertyGridProperty *CWorkAreaMgr::CreatGridProperty()
{
CString PropertyName;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
CString Description;//<2F><><EFBFBD><EFBFBD>
CString Path = _T("WorkArea");//<2F>洢·<E6B4A2><C2B7>
CString Name;
CString GroupName;
CString ModuleName;
//-------------------------------------------------------------------------------//
PropertyName = _T("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ");
GroupName = PropertyName;
CMFCPropertyGridProperty* pGroup = new CMFCPropertyGridProperty(PropertyName);
//-------------------------------------------------------------------------------//
if(gAuthorityMgr->CheckAuthority(_Authority_Engineer))
{
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD>ӳ<EFBFBD><D3B3>
Name = _T("m_bDrawWorkArea");//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
PropertyName = _T("<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ");
Description = _T("<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ڹ<EFBFBD><DAB9><EFBFBD><EFBFBD><EFBFBD>Χ֮<CEA7><D6AE>");
pPropertie->SetGroupName(GroupName);
pPropertie->SetShowName(PropertyName);
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bDrawWorkArea, Description);
pGroup->AddSubItem(p1);
gDevicePropertieMgr.Insert(p1, pPropertie);
}
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD>ӳ<EFBFBD><D3B3>
Name = _T("m_bCircle");//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_bCircle);
pPropertie->SetType(_PROP_TYPE_BOOL);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
PropertyName = _T("Բ<EFBFBD><EFBFBD>");
Description = _T("<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD>ʾΪԲ<EFBFBD><EFBFBD>");
pPropertie->SetGroupName(GroupName);
pPropertie->SetShowName(PropertyName);
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bCircle, Description);
pGroup->AddSubItem(p1);
gDevicePropertieMgr.Insert(p1, pPropertie);
}
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD>ӳ<EFBFBD><D3B3>
Name = _T("m_bFrame");//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_bFrame);
pPropertie->SetType(_PROP_TYPE_BOOL);
pPropertie->SetpModule(this);
pPropertie->SetPath(Path);
pPropertie->SetName(Name);
pPropertie->WriteRead(true);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
PropertyName = _T("<EFBFBD>߿<EFBFBD>");
Description = _T("<EFBFBD>Ƿ<EFBFBD>ֻ<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı߿<EFBFBD>");
pPropertie->SetGroupName(GroupName);
pPropertie->SetShowName(PropertyName);
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bFrame, Description);
pGroup->AddSubItem(p1);
gDevicePropertieMgr.Insert(p1, pPropertie);
}
//-------------------------------------------------------------------------------//
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD>ӳ<EFBFBD><D3B3>
Name = _T("m_WorkRectColor");//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
PropertyName = _T("<EFBFBD><EFBFBD>Χ<EFBFBD><EFBFBD>ɫ");
Description = _T("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ");
pPropertie->SetGroupName(GroupName);
pPropertie->SetShowName(PropertyName);
CMFCPropertyGridColorProperty* p1 = new CMFCPropertyGridColorProperty(PropertyName,m_WorkRectColor, NULL, Description);
p1->EnableOtherButton(_T("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>..."));
p1->EnableAutomaticButton(_T("Ĭ<EFBFBD><EFBFBD>"),RGB_BLACK);
pGroup->AddSubItem(p1);
gDevicePropertieMgr.Insert(p1, pPropertie);
}
//-------------------------------------------------------------------------------//
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD>ӳ<EFBFBD><D3B3>
Name = _T("m_WorkRectSize_w");//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
PropertyName = _T("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
Description = _T("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ<EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD>(<28><>λ:mm)");
pPropertie->SetGroupName(GroupName);
pPropertie->SetShowName(PropertyName);
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName,(_variant_t)m_WorkRectSize.w, Description);
pGroup->AddSubItem(p1);
gDevicePropertieMgr.Insert(p1, pPropertie);
}
//-------------------------------------------------------------------------------//
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD>ӳ<EFBFBD><D3B3>
Name = _T("m_WorkRectSize_h");//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
PropertyName = _T("<EFBFBD>߶<EFBFBD>");
Description = _T("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ<EFBFBD>ĸ߶<EFBFBD>(<28><>λ:mm)");
pPropertie->SetGroupName(GroupName);
pPropertie->SetShowName(PropertyName);
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName,(_variant_t)m_WorkRectSize.h, Description);
pGroup->AddSubItem(p1);
gDevicePropertieMgr.Insert(p1, pPropertie);
}
//-------------------------------------------------------------------------------//
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD>ӳ<EFBFBD><D3B3>
Name = _T("m_CenterPt_x");//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
PropertyName = _T("<EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>x");
Description = _T("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>x(<28><>λ:mm)");
pPropertie->SetGroupName(GroupName);
pPropertie->SetShowName(PropertyName);
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName,(_variant_t)m_CenterPt.x, Description);
pGroup->AddSubItem(p1);
gDevicePropertieMgr.Insert(p1, pPropertie);
}
//-------------------------------------------------------------------------------//
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD>ӳ<EFBFBD><D3B3>
Name = _T("m_CenterPt_y");//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
PropertyName = _T("<EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>y");
Description = _T("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>x(<28><>λ:mm)");
pPropertie->SetGroupName(GroupName);
pPropertie->SetShowName(PropertyName);
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName,(_variant_t)m_CenterPt.y, Description);
pGroup->AddSubItem(p1);
gDevicePropertieMgr.Insert(p1, pPropertie);
}
}
//-------------------------------------------------------------------------------//
return pGroup;
}
void CWorkAreaMgr::OnAppInitialize()
{
RefrashWorkArea();
}
void CWorkAreaMgr::OnPropertyChanged()
{
RefrashWorkArea();
//<2F><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
CLaiPuLaserView *pView = GetCurViewPtr();
if(pView)
{
pView->RefreshView();
}
}
void CWorkAreaMgr::Draw(CDC* pDC)
{
if(!m_bDrawWorkArea)
return;
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ɫ<EFBFBD>󷽿<EFBFBD>
if(gDraw->IsbDlgLayerViewShow())
{
DrawSolidRect(pDC,RGB_BLACK,DbRect(m_CenterPt,DbSize(1000,1000)));
}
if(!m_bFrame)
{
if(m_bCircle)
{
DrawSolidCircle(pDC,m_WorkRectColor,m_CenterPt,m_WorkRectSize.w/2);
}
else
{
DrawSolidRect(pDC,m_WorkRectColor,DbRect(m_CenterPt,m_WorkRectSize));
}
}
else
{
CPen pen;
pen.CreatePen(PS_INSIDEFRAME,1,m_WorkRectColor);
if(m_bCircle)
{
DrawCircle(pDC,pen,m_CenterPt,m_WorkRectSize.w/2,100);
}
else
{
DrawRect(pDC,pen,DbRect(m_CenterPt,m_WorkRectSize),false);
}
}
Dbxy pt;
pt.x = m_WorkRectSize.w/2 + 2;
gDraw->DrawTxt(pDC,"Noth",pt);
}
#endif
#if 1//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Rect
DbRect CWorkAreaMgr::GetWorkArea()
{
return m_DbWorkRect;
}
//ˢ<><CBA2>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();
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5>Ƿ<EFBFBD><C7B7>ھ<EFBFBD>Բ<EFBFBD><D4B2>Χ֮<CEA7><D6AE>
bool CWorkAreaMgr::IsPtInWorkArea(Dbxy pt)
{
double Dia = m_DbWorkRect.Width();
double R = Dia/2;
if(CalDistance(pt,Dbxy(0,0))>R)
return false;
return true;
}
#endif