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.
393 lines
10 KiB
C++
393 lines
10 KiB
C++
//////////////////////////////////////////////////////////////////////////////
|
|
//文件: CItem类扩展
|
|
//主要功能:
|
|
// 操作各类元素或完成一定的功能
|
|
//
|
|
//程序编写: 2006-12-07
|
|
//
|
|
//
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "StdAfx.h"
|
|
#include ".\itempointEdit.h"
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
//CItemPointEdit
|
|
|
|
CItemPointEdit::CItemPointEdit(CSigmaDoc * ppDoc)
|
|
: CItem(ppDoc)
|
|
, name(_T(""))
|
|
{
|
|
this->SetType(ITEM_POINT_EDIT);
|
|
}
|
|
|
|
CItemPointEdit::~CItemPointEdit(void)
|
|
{
|
|
}
|
|
|
|
/*
|
|
BOOL CItemPointEdit::InitPropertyGrid(CXTPPropertyGrid& grid)
|
|
{
|
|
CPropertyGridItemAdd ItemAdd(NULL);
|
|
COne* pOne=(COne*)GetDoc()->GetDraw()->GetAt(GetPos());
|
|
CPointNameEx* pValue=(CPointNameEx*)pOne->GetValue();
|
|
|
|
CString strFormat=GetFloatFormatString();
|
|
if(pValue->IsXYZ()) //散点数据
|
|
{
|
|
CXTPPropertyGridItem* pItem=grid.AddCategory(IDS_STRING_XYZ);
|
|
ItemAdd.SetItem(pItem); pItem->Expand();
|
|
|
|
pItem=ItemAdd.AddItem(new CCustomItemEmbellish(IDS_GI_EMBELLISH_SELF, pOne->HowToViewPoint,1, GetUnitMode()));
|
|
|
|
m_point.SetPoint(pValue->x0,pValue->y0);
|
|
ItemAdd.AddItemPoint(IDS_GI_COORDINATE,m_point,&m_point);
|
|
|
|
CString str;
|
|
str.Format("%ld", 1);
|
|
ItemAdd.AddItemDouble(str, pValue->z0, strFormat, NULL);
|
|
|
|
CPointXyz* px=(CPointXyz*)pValue;
|
|
for(int i=1;i<=px->m_nXyzNum;i++)
|
|
{
|
|
str.Format("%ld", i+1);
|
|
ItemAdd.AddItemDouble(str, px->m_pXyzValue[i], strFormat, NULL);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
CXTPPropertyGridItem* pItem=grid.AddCategory(IDS_STRING_Point);
|
|
ItemAdd.SetItem(pItem); pItem->Expand();
|
|
|
|
name=pValue->GetName();
|
|
ItemAdd.AddItemString(IDS_STRING_NAME, name, &name);
|
|
|
|
m_point.SetPoint(pValue->x0,pValue->y0);
|
|
ItemAdd.AddItemPoint(IDS_GI_COORDINATE,m_point,&m_point);
|
|
|
|
ItemAdd.AddItemDouble(IDS_STRING_ANGLE, pValue->angle, strFormat, NULL);
|
|
pItem=ItemAdd.AddItem(new CCustomItemEmbellish(IDS_GI_EMBELLISH_SELF, pOne->HowToViewPoint,1, GetUnitMode()));
|
|
}
|
|
|
|
CItem::InitPropertyGrid(grid);
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CItemPointEdit::OnGridItemChangeValue(CXTPPropertyGridItem* pItem)
|
|
{
|
|
COne* pOne=(COne*)GetDoc()->GetDraw()->GetAt(GetPos());
|
|
CPointNameEx* pValue=(CPointNameEx*)pOne->GetValue();
|
|
|
|
BOOL bUpdate=FALSE;
|
|
if(pValue->IsXYZ())
|
|
{
|
|
switch(pItem->GetID())
|
|
{
|
|
case IDS_GI_EMBELLISH_SELF:
|
|
{
|
|
CCustomItemEmbellish* pe=(CCustomItemEmbellish*)pItem;
|
|
if(pe->m_pHowToView)
|
|
{
|
|
if(pOne->HowToViewPoint==NULL)
|
|
pOne->HowToViewPoint=new CHowToViewPoint;
|
|
*(pOne->HowToViewPoint)=*(CHowToViewPoint*)(pe->m_pHowToView);
|
|
}
|
|
else if(pOne->HowToViewPoint)
|
|
{
|
|
delete pOne->HowToViewPoint;
|
|
pOne->HowToViewPoint=NULL;
|
|
}
|
|
}
|
|
bUpdate=TRUE;
|
|
break;
|
|
case IDS_GI_COORDINATE:
|
|
pValue->x0=m_point.x0;
|
|
pValue->y0=m_point.y0;
|
|
bUpdate=TRUE;
|
|
break;
|
|
default:
|
|
if(AfxGetPublicFunction()->IsDigit(pItem->GetCaption()))
|
|
{
|
|
int id=atol(pItem->GetCaption())-1;
|
|
CPointXyz* px=(CPointXyz*)pValue;
|
|
if(id<0||id>px->m_nXyzNum) break;
|
|
if(id == 0)
|
|
{
|
|
px->z0 = ((CXTPPropertyGridItemDouble*)pItem)->GetDouble();
|
|
px->SetName(); //设置显示名称
|
|
}
|
|
else
|
|
px->m_pXyzValue[id-1]=((CXTPPropertyGridItemDouble*)pItem)->GetDouble();
|
|
bUpdate=TRUE;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
switch(pItem->GetID())
|
|
{
|
|
case IDS_GI_EMBELLISH_SELF:
|
|
{
|
|
CCustomItemEmbellish* pe=(CCustomItemEmbellish*)pItem;
|
|
if(pe->m_pHowToView)
|
|
{
|
|
if(pOne->HowToViewPoint==NULL)
|
|
pOne->HowToViewPoint=new CHowToViewPoint;
|
|
*(pOne->HowToViewPoint)=*(CHowToViewPoint*)(pe->m_pHowToView);
|
|
}
|
|
else if(pOne->HowToViewPoint)
|
|
{
|
|
delete pOne->HowToViewPoint;
|
|
pOne->HowToViewPoint=NULL;
|
|
}
|
|
}
|
|
bUpdate=TRUE;
|
|
break;
|
|
case IDS_STRING_NAME:
|
|
pValue->SetName(name);
|
|
bUpdate=TRUE;
|
|
break;
|
|
case IDS_GI_COORDINATE:
|
|
pValue->x0=m_point.x0;
|
|
pValue->y0=m_point.y0;
|
|
bUpdate=TRUE;
|
|
break;
|
|
case IDS_STRING_ANGLE:
|
|
pValue->angle=((CXTPPropertyGridItemDouble*)pItem)->GetDouble();
|
|
bUpdate=TRUE;
|
|
break;
|
|
}
|
|
}
|
|
|
|
return bUpdate | CItem::OnGridItemChangeValue(pItem);
|
|
}
|
|
*/
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
//CItemPointTwoEdit
|
|
|
|
CItemPointTwoEdit::CItemPointTwoEdit(CSigmaDoc * ppDoc)
|
|
: CItem(ppDoc)
|
|
{
|
|
this->SetType(ITEM_TWOPOINT_EDIT);
|
|
}
|
|
|
|
CItemPointTwoEdit::~CItemPointTwoEdit(void)
|
|
{
|
|
}
|
|
|
|
/*
|
|
BOOL CItemPointTwoEdit::InitPropertyGrid(CXTPPropertyGrid& grid)
|
|
{
|
|
CPropertyGridItemAdd ItemAdd(NULL);
|
|
COne* pOne=(COne*)GetDoc()->GetDraw()->GetAt(GetPos());
|
|
CPointTwoName* pValue=(CPointTwoName*)pOne->GetValue();
|
|
|
|
CString strFormat=GetFloatFormatString();
|
|
CXTPPropertyGridItem* pItem=grid.AddCategory(IDS_STRING_Point);
|
|
ItemAdd.SetItem(pItem); pItem->Expand();
|
|
|
|
GetName(pValue->m_name1, name1); InitGridName(IDS_STRING_NUMERATOR, ItemAdd, name1);
|
|
GetName(pValue->m_name2, name2); InitGridName(IDS_STRING_DENOMINATOR, ItemAdd, name2);
|
|
|
|
m_point.SetPoint(pValue->x0,pValue->y0);
|
|
ItemAdd.AddItemPoint(IDS_GI_COORDINATE, m_point, &m_point);
|
|
|
|
ItemAdd.AddItemDouble(IDS_STRING_ANGLE, pValue->angle, strFormat, NULL);
|
|
pItem=ItemAdd.AddItem(new CCustomItemEmbellish(IDS_GI_EMBELLISH_SELF, pOne->HowToViewPoint,1, GetUnitMode()));
|
|
|
|
CItem::InitPropertyGrid(grid);
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
void NItem::CItemPointTwoEdit::InitGridName(UINT nID, CPropertyGridItemAdd& ItemAdd, CItemName& name)
|
|
{
|
|
CXTPPropertyGridItem* pItem=ItemAdd.AddItemString(nID, name.name, &(name.name));
|
|
CString strFormat=GetFloatFormatString();
|
|
|
|
CXTPPropertyGridItem* pBakItem=ItemAdd.GetItem();
|
|
ItemAdd.SetItem(pItem);
|
|
//pItem->Expand();
|
|
ItemAdd.AddItemSize8(IDS_STRING_OFFSET, name.delt, &(name.delt), "DX", "DY");
|
|
ItemAdd.AddItemDouble(IDS_STRING_ANGLE_SUB, name.angle, strFormat, &(name.angle));
|
|
|
|
ItemAdd.SetItem(pBakItem);
|
|
}
|
|
|
|
BOOL CItemPointTwoEdit::OnGridItemChangeValue(CXTPPropertyGridItem* pItem)
|
|
{
|
|
COne* pOne=(COne*)GetDoc()->GetDraw()->GetAt(GetPos());
|
|
CPointTwoName* pValue=(CPointTwoName*)pOne->GetValue();
|
|
|
|
BOOL bUpdate=FALSE;
|
|
switch(pItem->GetID())
|
|
{
|
|
case IDS_GI_EMBELLISH_SELF:
|
|
{
|
|
CCustomItemEmbellish* pe=(CCustomItemEmbellish*)pItem;
|
|
if(pe->m_pHowToView)
|
|
{
|
|
if(pOne->HowToViewPoint==NULL)
|
|
pOne->HowToViewPoint=new CHowToViewPoint;
|
|
*(pOne->HowToViewPoint)=*(CHowToViewPoint*)(pe->m_pHowToView);
|
|
}
|
|
else if(pOne->HowToViewPoint)
|
|
{
|
|
delete pOne->HowToViewPoint;
|
|
pOne->HowToViewPoint=NULL;
|
|
}
|
|
}
|
|
bUpdate=TRUE;
|
|
break;
|
|
case IDS_STRING_NUMERATOR:
|
|
SetName(pValue->m_name1, name1);
|
|
break;
|
|
case IDS_STRING_DENOMINATOR:
|
|
SetName(pValue->m_name2, name2);
|
|
break;
|
|
case IDS_STRING_OFFSET:
|
|
case IDS_STRING_ANGLE_SUB:
|
|
SetName(pValue->m_name1, name1);
|
|
SetName(pValue->m_name2, name2);
|
|
bUpdate=TRUE;
|
|
break;
|
|
case IDS_GI_COORDINATE:
|
|
pValue->x0=m_point.x0;
|
|
pValue->y0=m_point.y0;
|
|
bUpdate=TRUE;
|
|
break;
|
|
case IDS_STRING_ANGLE:
|
|
pValue->angle=((CXTPPropertyGridItemDouble*)pItem)->GetDouble();
|
|
bUpdate=TRUE;
|
|
break;
|
|
}
|
|
|
|
return bUpdate | CItem::OnGridItemChangeValue(pItem);
|
|
}
|
|
*/
|
|
|
|
void NItem::CItemPointTwoEdit::GetName(CPointNameBase& pn, CItemName& name)
|
|
{
|
|
name.name=pn.GetName();
|
|
name.delt.SetSize(pn.x0, pn.y0);
|
|
name.angle=pn.angle;
|
|
}
|
|
|
|
void NItem::CItemPointTwoEdit::SetName(CPointNameBase& pn, CItemName& name)
|
|
{
|
|
pn.SetName(name.name);
|
|
pn.angle=name.angle;
|
|
pn.x0=name.delt.cx;
|
|
pn.y0=name.delt.cy;
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
//CItemPointCrossEdit
|
|
|
|
CItemPointCrossEdit::CItemPointCrossEdit(CSigmaDoc * ppDoc)
|
|
: CItemPointTwoEdit(ppDoc)
|
|
{
|
|
m_nMode = 0;
|
|
this->SetType(ITEM_CROSSPOINT_EDIT);
|
|
}
|
|
|
|
CItemPointCrossEdit::~CItemPointCrossEdit(void)
|
|
{
|
|
}
|
|
|
|
/*
|
|
BOOL CItemPointCrossEdit::InitPropertyGrid(CXTPPropertyGrid& grid)
|
|
{
|
|
CPropertyGridItemAdd ItemAdd(NULL);
|
|
COne* pOne=(COne*)GetDoc()->GetDraw()->GetAt(GetPos());
|
|
CPointCrossName* pValue=(CPointCrossName*)pOne->GetValue();
|
|
|
|
CString strFormat=GetFloatFormatString();
|
|
CXTPPropertyGridItem* pItem=grid.AddCategory(IDS_STRING_Point);
|
|
ItemAdd.SetItem(pItem); pItem->Expand();
|
|
|
|
GetName(pValue->m_name1, name1); InitGridName(IDS_STRING_QUADRANT1, ItemAdd, name1);
|
|
GetName(pValue->m_name2, name2); InitGridName(IDS_STRING_QUADRANT2, ItemAdd, name2);
|
|
GetName(pValue->m_name3, name3); InitGridName(IDS_STRING_QUADRANT3, ItemAdd, name3);
|
|
GetName(pValue->m_name4, name4); InitGridName(IDS_STRING_QUADRANT4, ItemAdd, name4);
|
|
|
|
m_point.SetPoint(pValue->x0,pValue->y0);
|
|
ItemAdd.AddItemPoint(IDS_GI_COORDINATE, m_point, &m_point);
|
|
|
|
ItemAdd.AddItemDouble(IDS_STRING_ANGLE, pValue->angle, strFormat, NULL);
|
|
|
|
m_nMode = GetModeIndex(pValue->GetDisplayMode());
|
|
ItemAdd.AddItemCombo(IDS_GI_DISPLAY_IDEA, IDS_STRING_CROSSPOINT_MODE, m_nMode, &m_nMode);
|
|
|
|
pItem=ItemAdd.AddItem(new CCustomItemEmbellish(IDS_GI_EMBELLISH_SELF, pOne->HowToViewPoint,1, GetUnitMode()));
|
|
|
|
CItem::InitPropertyGrid(grid);
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CItemPointCrossEdit::OnGridItemChangeValue(CXTPPropertyGridItem* pItem)
|
|
{
|
|
COne* pOne=(COne*)GetDoc()->GetDraw()->GetAt(GetPos());
|
|
CPointCrossName* pValue=(CPointCrossName*)pOne->GetValue();
|
|
|
|
BOOL bUpdate=FALSE;
|
|
switch(pItem->GetID())
|
|
{
|
|
case IDS_STRING_QUADRANT1:
|
|
SetName(pValue->m_name1, name1);
|
|
break;
|
|
case IDS_STRING_QUADRANT2:
|
|
SetName(pValue->m_name2, name2);
|
|
break;
|
|
case IDS_STRING_QUADRANT3:
|
|
SetName(pValue->m_name3, name3);
|
|
break;
|
|
case IDS_STRING_QUADRANT4:
|
|
SetName(pValue->m_name4, name4);
|
|
break;
|
|
case IDS_STRING_OFFSET:
|
|
case IDS_STRING_ANGLE_SUB:
|
|
SetName(pValue->m_name1, name1);
|
|
SetName(pValue->m_name2, name2);
|
|
SetName(pValue->m_name3, name3);
|
|
SetName(pValue->m_name4, name4);
|
|
bUpdate=TRUE;
|
|
break;
|
|
case IDS_GI_DISPLAY_IDEA:
|
|
pValue->SetDisplayMode(SetModeIndex(m_nMode));
|
|
bUpdate=TRUE;
|
|
break;
|
|
default:
|
|
bUpdate = CItemPointTwoEdit::OnGridItemChangeValue(pItem);
|
|
break;
|
|
}
|
|
|
|
return bUpdate | CItem::OnGridItemChangeValue(pItem);
|
|
}
|
|
*/
|
|
|
|
int NItem::CItemPointCrossEdit::GetModeIndex(DWORD nFlags)
|
|
{
|
|
switch(nFlags)
|
|
{
|
|
case CPointTwoName::displayVertical: return 2;
|
|
case CPointTwoName::displayHorizontal: return 1;
|
|
case CPointTwoName::displayCross: return 0;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
DWORD NItem::CItemPointCrossEdit::SetModeIndex(int nIndex)
|
|
{
|
|
switch(nIndex)
|
|
{
|
|
default:
|
|
case 0: return CPointTwoName::displayCross;
|
|
case 1: return CPointTwoName::displayHorizontal;
|
|
case 2: return CPointTwoName::displayVertical;
|
|
}
|
|
return 0;
|
|
}
|