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.
232 lines
7.4 KiB
C++
232 lines
7.4 KiB
C++
#include "StdAfx.h"
|
|
#include "MarkObjPropertieMgr.h"
|
|
#include "MainFrm.h"
|
|
#include "GlobalFunction.h"
|
|
#include "Propertie.h"
|
|
#include "PropertieMgr.h"
|
|
#include "CommandStretch.h"
|
|
#include "CommandMgr.h"
|
|
|
|
|
|
|
|
CMarkObjPropertieMgr *gMarkObjPropertieMgr = new CMarkObjPropertieMgr;
|
|
CMarkObjPropertieMgr::CMarkObjPropertieMgr(void)
|
|
{
|
|
m_PenNum = -1;//选择obj 的笔号
|
|
}
|
|
CMarkObjPropertieMgr::~CMarkObjPropertieMgr(void)
|
|
{
|
|
}
|
|
#if 1
|
|
//创建属性页
|
|
CMFCPropertyGridProperty *CMarkObjPropertieMgr::CreatGridProperty()
|
|
{
|
|
//更新公共属性值
|
|
UpdateCommonPropVal();
|
|
//-------------------------------------------------------------------------------//
|
|
CString PropertyName;//属性名称
|
|
CString Description;//描述
|
|
CString Name;
|
|
//-------------------------------------------------------------------------------//
|
|
PropertyName = _T("图形属性");
|
|
CMFCPropertyGridProperty* pGroup = new CMFCPropertyGridProperty(PropertyName);
|
|
|
|
PropertyName = _T("基本属性");
|
|
CMFCPropertyGridProperty* pGroup1 = new CMFCPropertyGridProperty(PropertyName);
|
|
//-------------------------------------------------------------------------------//
|
|
{
|
|
//添加属性变量映射
|
|
CPropertie *pPropertie = new CPropertie;
|
|
pPropertie->SetpVal((void*)&m_Coord.x);
|
|
pPropertie->SetType(_PROP_TYPE_DOUBLE);
|
|
pPropertie->SetpModule(this);
|
|
//添加属性显示
|
|
PropertyName = _T("x 坐标");
|
|
Description = _T("选择对象的x 方向坐标值(单位:mm)");
|
|
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName,(_variant_t)m_Coord.x, Description);
|
|
pGroup1->AddSubItem(p1);
|
|
gDrawPropertieMgr.Insert(p1, pPropertie);
|
|
}
|
|
//-------------------------------------------------------------------------------//
|
|
{
|
|
//添加属性变量映射
|
|
CPropertie *pPropertie = new CPropertie;
|
|
pPropertie->SetpVal((void*)&m_Coord.y);
|
|
pPropertie->SetType(_PROP_TYPE_DOUBLE);
|
|
pPropertie->SetpModule(this);
|
|
//添加属性显示
|
|
PropertyName = _T("y 坐标");
|
|
Description = _T("选择对象的y 方向坐标值(单位:mm)");
|
|
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName,(_variant_t)m_Coord.y, Description);
|
|
pGroup1->AddSubItem(p1);
|
|
gDrawPropertieMgr.Insert(p1, pPropertie);
|
|
}
|
|
//-------------------------------------------------------------------------------//
|
|
{
|
|
//添加属性变量映射
|
|
CPropertie *pPropertie = new CPropertie;
|
|
pPropertie->SetpVal((void*)&m_Size.w);
|
|
pPropertie->SetType(_PROP_TYPE_DOUBLE);
|
|
pPropertie->SetpModule(this);
|
|
//添加属性显示
|
|
PropertyName = _T("x 尺寸");
|
|
Description = _T("选择对象的宽度值(单位:mm)");
|
|
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName,(_variant_t)m_Size.w, Description);
|
|
pGroup1->AddSubItem(p1);
|
|
gDrawPropertieMgr.Insert(p1, pPropertie);
|
|
}
|
|
//-------------------------------------------------------------------------------//
|
|
{
|
|
//添加属性变量映射
|
|
CPropertie *pPropertie = new CPropertie;
|
|
pPropertie->SetpVal((void*)&m_Size.h);
|
|
pPropertie->SetType(_PROP_TYPE_DOUBLE);
|
|
pPropertie->SetpModule(this);
|
|
//添加属性显示
|
|
PropertyName = _T("y 尺寸");
|
|
Description = _T("选择对象的高度值(单位:mm)");
|
|
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName,(_variant_t)m_Size.h, Description);
|
|
pGroup1->AddSubItem(p1);
|
|
gDrawPropertieMgr.Insert(p1, pPropertie);
|
|
}
|
|
if(m_PenNum >=0)
|
|
{
|
|
//添加属性变量映射
|
|
CPropertie *pPropertie = new CPropertie;
|
|
pPropertie->SetpVal((void*)&m_PenNum);
|
|
pPropertie->SetType(_PROP_TYPE_INT);
|
|
pPropertie->SetpModule(this);
|
|
//添加属性显示
|
|
PropertyName = _T("笔号");
|
|
Description = _T("选择对象的笔号");
|
|
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName,(_variant_t)m_PenNum, Description);
|
|
pGroup1->AddSubItem(p1);
|
|
gDrawPropertieMgr.Insert(p1, pPropertie);
|
|
}
|
|
|
|
pGroup->AddSubItem(pGroup1);
|
|
|
|
//创建对象的特殊属性
|
|
CMFCPropertyGridProperty* pSpecialGrid = CreatSpecialGridProperty(this);
|
|
if(pSpecialGrid != NULL)
|
|
{
|
|
pGroup->AddSubItem(pSpecialGrid);
|
|
}
|
|
return pGroup;
|
|
}
|
|
//创建对象的特殊属性
|
|
CMFCPropertyGridProperty *CMarkObjPropertieMgr::CreatSpecialGridProperty(CModule *pModule)
|
|
{
|
|
CLayer &layer = gLayer;
|
|
return layer.CreatSpecialGridProperty(pModule);
|
|
}
|
|
//响应属性的改变
|
|
void CMarkObjPropertieMgr::OnPropertyChanged()
|
|
{
|
|
CLayer &layer = gLayer;
|
|
//移动
|
|
if(MoveSelObj()==false)
|
|
{
|
|
//改变尺寸
|
|
if(ResizeSelObj()==false)
|
|
{
|
|
//特殊属性
|
|
OnSpecialPropertyChanged();
|
|
}
|
|
}
|
|
|
|
//更新属性值
|
|
UpdateSelMarkObjPropertie();
|
|
//刷新
|
|
GetCurViewPtr()->RefreshView();
|
|
}
|
|
//相应特殊属性的变化
|
|
void CMarkObjPropertieMgr::OnSpecialPropertyChanged()
|
|
{
|
|
CLayer &layer = gLayer;
|
|
layer.OnSpecialPropertyChanged();
|
|
}
|
|
#endif
|
|
//更新选择对象的属性
|
|
void CMarkObjPropertieMgr::UpdateSelMarkObjPropertie()
|
|
{
|
|
if(gbFactoryMode)
|
|
{
|
|
GetFrame()->m_DlgGraphEdit.UpdateObjPropList();
|
|
}
|
|
}
|
|
//更新公共属性值
|
|
void CMarkObjPropertieMgr::UpdateCommonPropVal()
|
|
{
|
|
CObjContainer &ObjContainer = gLayer.GetObjContainer();
|
|
|
|
DbRect rect = ObjContainer.GetSelObjRect();
|
|
//尺寸
|
|
m_Size = rect.GetSize();
|
|
//坐标
|
|
m_Coord = rect.GetCenterPt();
|
|
m_PenNum = ObjContainer.GetSelObjPenNum();
|
|
}
|
|
//通过修改坐标移动obj
|
|
bool CMarkObjPropertieMgr::MoveSelObj()
|
|
{
|
|
CLayer &layer = gLayer;
|
|
Dbxy CoordOld = layer.GetSelObjRect().GetCenterPt();
|
|
if(!IsTwoDbEqual(m_Coord.x,CoordOld.x) || !IsTwoDbEqual(m_Coord.y,CoordOld.y))
|
|
{
|
|
layer.OnMove(m_Coord.x-CoordOld.x,m_Coord.y-CoordOld.y);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
//改变尺寸
|
|
bool CMarkObjPropertieMgr::ResizeSelObj()
|
|
{
|
|
CLayer &layer = gLayer;
|
|
DbRect rect = layer.GetSelObjRect();
|
|
DbSize SizeOld = rect.GetSize();
|
|
|
|
Dbxy BasePt;//基准点
|
|
double OldSize,NewSize;
|
|
double Diff;//新旧尺寸的差
|
|
X_OR_Y xy;
|
|
bool flg = false;
|
|
if(!IsTwoDbEqual(m_Size.w,SizeOld.w) && m_Size.w > 0)
|
|
{
|
|
BasePt = rect.GetCenterPt();//基准点
|
|
OldSize = SizeOld.w;
|
|
NewSize = m_Size.w;
|
|
Diff = m_Size.w-SizeOld.w;//最大移动量
|
|
xy = _X;
|
|
flg = true;
|
|
}
|
|
if(!IsTwoDbEqual(m_Size.h,SizeOld.h) && m_Size.h > 0)
|
|
{
|
|
BasePt = rect.GetCenterPt();//基准点
|
|
OldSize = SizeOld.h;
|
|
NewSize = m_Size.h;
|
|
Diff = m_Size.h-SizeOld.h;//最大移动量
|
|
xy = _Y;
|
|
flg = true;
|
|
}
|
|
if(flg)
|
|
{
|
|
SObjOperatePar par;
|
|
par.OpType = _OP_STRETCH;
|
|
par.BasePt = BasePt;
|
|
par.OldSize = OldSize;
|
|
par.NewSize = NewSize;
|
|
par.Diff = Diff;
|
|
par.xy = xy;
|
|
//创建undo 用的指令-----start
|
|
CCommandStretch *pCommand = new CCommandStretch;
|
|
pCommand->SetOperatePar(par);
|
|
gCommandMgr.AddUndoCommand(pCommand);
|
|
//创建undo 用的指令-----end
|
|
pCommand->Excute();
|
|
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|