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;//是否绘制工作区域
m_bCircle = false;//是否为圆形
m_bFrame = false;//是否只显示边框
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;
CString GroupName;
CString ModuleName;
//-------------------------------------------------------------------------------//
PropertyName = _T("工作范围");
GroupName = PropertyName;
CMFCPropertyGridProperty* pGroup = new CMFCPropertyGridProperty(PropertyName);
//-------------------------------------------------------------------------------//
if(gAuthorityMgr->CheckAuthority(_Authority_Engineer))
{
{
//添加属性变量映射
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("是否显示工作范围,工作数据需要在工作范围之内");
pPropertie->SetGroupName(GroupName);
pPropertie->SetShowName(PropertyName);
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bDrawWorkArea, Description);
pGroup->AddSubItem(p1);
gDevicePropertieMgr.Insert(p1, pPropertie);
}
{
//添加属性变量映射
Name = _T("m_bCircle");//变量名字
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);//读取保存的属性
//添加属性显示
PropertyName = _T("圆形");
Description = _T("是否显示为圆形");
pPropertie->SetGroupName(GroupName);
pPropertie->SetShowName(PropertyName);
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bCircle, Description);
pGroup->AddSubItem(p1);
gDevicePropertieMgr.Insert(p1, pPropertie);
}
{
//添加属性变量映射
Name = _T("m_bFrame");//变量名字
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);//读取保存的属性
//添加属性显示
PropertyName = _T("边框");
Description = _T("是否只显示区域的边框");
pPropertie->SetGroupName(GroupName);
pPropertie->SetShowName(PropertyName);
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_bFrame, 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("工作范围的颜色");
pPropertie->SetGroupName(GroupName);
pPropertie->SetShowName(PropertyName);
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)");
pPropertie->SetGroupName(GroupName);
pPropertie->SetShowName(PropertyName);
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)");
pPropertie->SetGroupName(GroupName);
pPropertie->SetShowName(PropertyName);
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)");
pPropertie->SetGroupName(GroupName);
pPropertie->SetShowName(PropertyName);
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)");
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();
//获取当前视类指针
CLaiPuLaserView *pView = GetCurViewPtr();
if(pView)
{
pView->RefreshView();
}
}
void CWorkAreaMgr::Draw(CDC* pDC)
{
if(!m_bDrawWorkArea)
return;
//绘制一个黑色大方框
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//工作区域
//获取工作区域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::IsPtInWorkArea(Dbxy pt)
{
double Dia = m_DbWorkRect.Width();
double R = Dia/2;
if(CalDistance(pt,Dbxy(0,0))>R)
return false;
return true;
}
#endif