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++

#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;//ѡ<><D1A1>obj <20>ıʺ<C4B1>
}
CMarkObjPropertieMgr::~CMarkObjPropertieMgr(void)
{
}
#if 1
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ
CMFCPropertyGridProperty *CMarkObjPropertieMgr::CreatGridProperty()
{
//<2F><><EFBFBD>¹<EFBFBD><C2B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
UpdateCommonPropVal();
//-------------------------------------------------------------------------------//
CString PropertyName;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
CString Description;//<2F><><EFBFBD><EFBFBD>
CString Name;
//-------------------------------------------------------------------------------//
PropertyName = _T("ͼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
CMFCPropertyGridProperty* pGroup = new CMFCPropertyGridProperty(PropertyName);
PropertyName = _T("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
CMFCPropertyGridProperty* pGroup1 = new CMFCPropertyGridProperty(PropertyName);
//-------------------------------------------------------------------------------//
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD>ӳ<EFBFBD><D3B3>
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_Coord.x);
pPropertie->SetType(_PROP_TYPE_DOUBLE);
pPropertie->SetpModule(this);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
PropertyName = _T("x <20><><EFBFBD><EFBFBD>");
Description = _T("ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>x <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ(<28><>λ:mm)");
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName,(_variant_t)m_Coord.x, Description);
pGroup1->AddSubItem(p1);
gDrawPropertieMgr.Insert(p1, pPropertie);
}
//-------------------------------------------------------------------------------//
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD>ӳ<EFBFBD><D3B3>
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_Coord.y);
pPropertie->SetType(_PROP_TYPE_DOUBLE);
pPropertie->SetpModule(this);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
PropertyName = _T("y <20><><EFBFBD><EFBFBD>");
Description = _T("ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>y <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ(<28><>λ:mm)");
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName,(_variant_t)m_Coord.y, Description);
pGroup1->AddSubItem(p1);
gDrawPropertieMgr.Insert(p1, pPropertie);
}
//-------------------------------------------------------------------------------//
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD>ӳ<EFBFBD><D3B3>
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_Size.w);
pPropertie->SetType(_PROP_TYPE_DOUBLE);
pPropertie->SetpModule(this);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
PropertyName = _T("x <20>ߴ<EFBFBD>");
Description = _T("ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD>ֵ(<28><>λ:mm)");
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName,(_variant_t)m_Size.w, Description);
pGroup1->AddSubItem(p1);
gDrawPropertieMgr.Insert(p1, pPropertie);
}
//-------------------------------------------------------------------------------//
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD>ӳ<EFBFBD><D3B3>
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_Size.h);
pPropertie->SetType(_PROP_TYPE_DOUBLE);
pPropertie->SetpModule(this);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
PropertyName = _T("y <20>ߴ<EFBFBD>");
Description = _T("ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ߶<EFBFBD>ֵ(<28><>λ:mm)");
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName,(_variant_t)m_Size.h, Description);
pGroup1->AddSubItem(p1);
gDrawPropertieMgr.Insert(p1, pPropertie);
}
if(m_PenNum >=0)
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD>ӳ<EFBFBD><D3B3>
CPropertie *pPropertie = new CPropertie;
pPropertie->SetpVal((void*)&m_PenNum);
pPropertie->SetType(_PROP_TYPE_INT);
pPropertie->SetpModule(this);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
PropertyName = _T("<EFBFBD>ʺ<EFBFBD>");
Description = _T("ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ıʺ<EFBFBD>");
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName,(_variant_t)m_PenNum, Description);
pGroup1->AddSubItem(p1);
gDrawPropertieMgr.Insert(p1, pPropertie);
}
pGroup->AddSubItem(pGroup1);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
CMFCPropertyGridProperty* pSpecialGrid = CreatSpecialGridProperty(this);
if(pSpecialGrid != NULL)
{
pGroup->AddSubItem(pSpecialGrid);
}
return pGroup;
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
CMFCPropertyGridProperty *CMarkObjPropertieMgr::CreatSpecialGridProperty(CModule *pModule)
{
CLayer &layer = gLayer;
return layer.CreatSpecialGridProperty(pModule);
}
//<2F><>Ӧ<EFBFBD><D3A6><EFBFBD>Եĸı<C4B8>
void CMarkObjPropertieMgr::OnPropertyChanged()
{
CLayer &layer = gLayer;
//<2F>ƶ<EFBFBD>
if(MoveSelObj()==false)
{
//<2F>ı<EFBFBD><C4B1>ߴ<EFBFBD>
if(ResizeSelObj()==false)
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
OnSpecialPropertyChanged();
}
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
UpdateSelMarkObjPropertie();
//ˢ<><CBA2>
GetCurViewPtr()->RefreshView();
}
//<2F><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Եı
void CMarkObjPropertieMgr::OnSpecialPropertyChanged()
{
CLayer &layer = gLayer;
layer.OnSpecialPropertyChanged();
}
#endif
//<2F><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void CMarkObjPropertieMgr::UpdateSelMarkObjPropertie()
{
if(gbFactoryMode)
{
GetFrame()->m_DlgGraphEdit.UpdateObjPropList();
}
}
//<2F><><EFBFBD>¹<EFBFBD><C2B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
void CMarkObjPropertieMgr::UpdateCommonPropVal()
{
CObjContainer &ObjContainer = gLayer.GetObjContainer();
DbRect rect = ObjContainer.GetSelObjRect();
//<2F>ߴ<EFBFBD>
m_Size = rect.GetSize();
//<2F><><EFBFBD><EFBFBD>
m_Coord = rect.GetCenterPt();
m_PenNum = ObjContainer.GetSelObjPenNum();
}
//ͨ<><CDA8><EFBFBD>޸<EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD>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;
}
//<2F>ı<EFBFBD><C4B1>ߴ<EFBFBD>
bool CMarkObjPropertieMgr::ResizeSelObj()
{
CLayer &layer = gLayer;
DbRect rect = layer.GetSelObjRect();
DbSize SizeOld = rect.GetSize();
Dbxy BasePt;//<2F><>׼<EFBFBD><D7BC>
double OldSize,NewSize;
double Diff;//<2F>¾ɳߴ<C9B3><DFB4>IJ<EFBFBD>
X_OR_Y xy;
bool flg = false;
if(!IsTwoDbEqual(m_Size.w,SizeOld.w) && m_Size.w > 0)
{
BasePt = rect.GetCenterPt();//<2F><>׼<EFBFBD><D7BC>
OldSize = SizeOld.w;
NewSize = m_Size.w;
Diff = m_Size.w-SizeOld.w;//<2F><><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD>
xy = _X;
flg = true;
}
if(!IsTwoDbEqual(m_Size.h,SizeOld.h) && m_Size.h > 0)
{
BasePt = rect.GetCenterPt();//<2F><>׼<EFBFBD><D7BC>
OldSize = SizeOld.h;
NewSize = m_Size.h;
Diff = m_Size.h-SizeOld.h;//<2F><><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD>
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;
//<2F><><EFBFBD><EFBFBD>undo <20>õ<EFBFBD>ָ<EFBFBD><D6B8>-----start
CCommandStretch *pCommand = new CCommandStretch;
pCommand->SetOperatePar(par);
gCommandMgr.AddUndoCommand(pCommand);
//<2F><><EFBFBD><EFBFBD>undo <20>õ<EFBFBD>ָ<EFBFBD><D6B8>-----end
pCommand->Excute();
return true;
}
return false;
}