|
|
#include "StdAfx.h"
|
|
|
#include ".\itemlinkcurve.h"
|
|
|
#include "SigmaDoc.h"
|
|
|
#include "SigmaView.h"
|
|
|
#include "ActionListItem.h"
|
|
|
#include "DrawOperator\CurveAnd.h"
|
|
|
//#include "PropertiesSheet.h"
|
|
|
|
|
|
CItemLinkCurve::CItemLinkCurve(CSigmaDoc * ppDoc)
|
|
|
: CItemSelectCurve(ppDoc)
|
|
|
, m_nMode(LINK_CURVE_DEFAULT)
|
|
|
, m_nMergeIdea(0)
|
|
|
, m_bIsDelete(TRUE)
|
|
|
{
|
|
|
this->SetType(ITEM_LINK_CURVE);
|
|
|
num=2;
|
|
|
EnableDrawSelectPoint(TRUE);
|
|
|
}
|
|
|
|
|
|
CItemLinkCurve::~CItemLinkCurve(void)
|
|
|
{
|
|
|
RemoveAllSelect();
|
|
|
}
|
|
|
|
|
|
int NItem::CItemLinkCurve::GetMergeIdea() const
|
|
|
{
|
|
|
return m_nMergeIdea;
|
|
|
}
|
|
|
|
|
|
bool NItem::CItemLinkCurve::SetMergeIdea(int mergeIdea)
|
|
|
{
|
|
|
if (mergeIdea < 0 || mergeIdea > 4)
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
m_nMergeIdea = mergeIdea;
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
bool NItem::CItemLinkCurve::IsDelete() const
|
|
|
{
|
|
|
return m_bIsDelete;
|
|
|
}
|
|
|
|
|
|
void NItem::CItemLinkCurve::SetDelete(bool isDelete)
|
|
|
{
|
|
|
m_bIsDelete = isDelete;
|
|
|
}
|
|
|
|
|
|
BOOL CItemLinkCurve::DoSelectEnd(void)
|
|
|
{
|
|
|
switch(m_nMode)
|
|
|
{
|
|
|
case LINK_CURVE_DEFAULT:
|
|
|
default:
|
|
|
if(!LinkCurve()) return FALSE;
|
|
|
break;
|
|
|
case LINK_CURVE_MERGE:
|
|
|
MergeCurve();
|
|
|
//GetDoc()->EnableDefaultTool();
|
|
|
break;
|
|
|
}
|
|
|
return CItemSelectCurve::DoSelectEnd();
|
|
|
}
|
|
|
|
|
|
void NItem::CItemLinkCurve::GetLinkPointList(CPointList& PointList, SELECT_ITEM &st1, SELECT_ITEM &st2)
|
|
|
{
|
|
|
CCurveEx *p1,*p2;
|
|
|
p1=(CCurveEx*)GetDoc()->GetDraw()->GetAtValue(st1.pos);
|
|
|
p2=(CCurveEx*)GetDoc()->GetDraw()->GetAtValue(st2.pos);
|
|
|
|
|
|
int n=p1->num-1;
|
|
|
if( AfxGetPublicFunction()->Distance2(st1.point.x0, st1.point.y0, p1->x[0], p1->y[0]) >
|
|
|
AfxGetPublicFunction()->Distance2(st1.point.x0, st1.point.y0, p1->x[n], p1->y[n]) )
|
|
|
p1->GetPoint(PointList,FALSE);
|
|
|
else
|
|
|
p1->GetPoint(PointList,TRUE);
|
|
|
|
|
|
n=p2->num-1;
|
|
|
if( AfxGetPublicFunction()->Distance2(st2.point.x0, st2.point.y0, p2->x[0], p2->y[0]) >
|
|
|
AfxGetPublicFunction()->Distance2(st2.point.x0, st2.point.y0, p2->x[n], p2->y[n]) )
|
|
|
p2->GetPoint(PointList,TRUE);
|
|
|
else
|
|
|
p2->GetPoint(PointList,FALSE);
|
|
|
}
|
|
|
|
|
|
BOOL NItem::CItemLinkCurve::LinkCurve(void)
|
|
|
{
|
|
|
if(SelectList.GetCount()<2) return FALSE;
|
|
|
SELECT_ITEM st1,st2;
|
|
|
st1=SelectList.GetHead();
|
|
|
st2=SelectList.GetTail();
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD>
|
|
|
CPointList PointList;
|
|
|
GetLinkPointList(PointList, st1, st2);
|
|
|
|
|
|
COne* pOne1=GetDoc()->GetDraw()->GetAt(st1.pos);
|
|
|
COne* pOne2=GetDoc()->GetDraw()->GetAt(st2.pos);
|
|
|
CCurveEx *p1,*p2;
|
|
|
p1=(CCurveEx*)pOne1->GetValue();
|
|
|
p2=(CCurveEx*)pOne2->GetValue();
|
|
|
|
|
|
CCurveEx *pCurve = new CCurveEx;
|
|
|
pCurve->CloneOtherParameter(*p2);
|
|
|
pCurve->SetPoints(PointList,min(p1->nPoint, p2->nPoint));
|
|
|
PointList.RemoveAll();
|
|
|
POSITION pos=this->AddElement(pCurve,DOUBLEFOX_CURVE,false,false);
|
|
|
if(pOne1->GetLayer()==pOne2->GetLayer())//<2F><><EFBFBD><EFBFBD>Ԫ<EFBFBD>صIJ<D8B5>λ<EFBFBD><CEBB>ͬʱ,<2C><>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD>ڸò<DAB8><C3B2><EFBFBD>
|
|
|
GetDoc()->GetDraw()->SetElementLayer(pos, pOne1->GetLayer());
|
|
|
|
|
|
//UNDO<44><4F><EFBFBD><EFBFBD>
|
|
|
CList<POSITION,POSITION> DelList, AddList;
|
|
|
DelList.AddTail(st1.pos);
|
|
|
DelList.AddTail(st2.pos);
|
|
|
AddList.AddTail(pos);
|
|
|
|
|
|
CActionListItem* pItem=new CActionListItem(GetDoc(),ID_EDIT_TOOL_LINKCURVE);
|
|
|
pItem->AddDeleteItem(DelList);
|
|
|
pItem->AddAddItem(AddList);
|
|
|
GetDoc()->SetActionItem(pItem);
|
|
|
|
|
|
return TRUE;
|
|
|
}
|
|
|
|
|
|
BOOL NItem::CItemLinkCurve::MergeCurve(void)
|
|
|
{
|
|
|
if(SelectList.GetCount()<2) return FALSE;
|
|
|
SELECT_ITEM st1,st2;
|
|
|
st1=SelectList.GetHead();
|
|
|
st2=SelectList.GetTail();
|
|
|
|
|
|
COne* pOne1=GetDoc()->GetDraw()->GetAt(st1.pos);
|
|
|
COne* pOne2=GetDoc()->GetDraw()->GetAt(st2.pos);
|
|
|
CCurveEx *p1,*p2;
|
|
|
p1=(CCurveEx*)pOne1->GetValue();
|
|
|
p2=(CCurveEx*)pOne2->GetValue();
|
|
|
|
|
|
CCurveAnd ca;
|
|
|
ca.SetCurve(p1, p2);
|
|
|
switch(m_nMergeIdea)
|
|
|
{
|
|
|
case 0: //And
|
|
|
ca.GetAndCurve();
|
|
|
break;
|
|
|
case 1: //Or
|
|
|
ca.GetOrCurve();
|
|
|
break;
|
|
|
case 2: //Xor
|
|
|
ca.GetXorCurve();
|
|
|
break;
|
|
|
case 3: //Cross
|
|
|
ca.GetCrossCurve();
|
|
|
break;
|
|
|
}
|
|
|
if(ca.m_ptrCurveList.GetCount()==0)
|
|
|
return FALSE;
|
|
|
|
|
|
//UNDO<44><4F><EFBFBD><EFBFBD>
|
|
|
CList<POSITION,POSITION> DelList, AddList;
|
|
|
CCurveEx* pac;
|
|
|
POSITION pos=ca.m_ptrCurveList.GetHeadPosition();
|
|
|
while(pos)
|
|
|
{
|
|
|
pac=(CCurveEx*)ca.m_ptrCurveList.GetNext(pos);
|
|
|
AddList.AddTail(GetDoc()->GetDraw()->AddElement(pac, DOUBLEFOX_CURVE));
|
|
|
}
|
|
|
|
|
|
CActionListItem* pItem = new CActionListItem(GetDoc(), ID_PROCESS_CURVE_MERGE);
|
|
|
if(m_bIsDelete)
|
|
|
{
|
|
|
DelList.AddTail(st1.pos);
|
|
|
DelList.AddTail(st2.pos);
|
|
|
pItem->AddDeleteItem(DelList);
|
|
|
}
|
|
|
pItem->AddAddItem(AddList);
|
|
|
GetDoc()->SetActionItem(pItem);
|
|
|
|
|
|
return TRUE;
|
|
|
}
|
|
|
|
|
|
BOOL NItem::CItemLinkCurve::MergeCurveDialog(void)
|
|
|
{
|
|
|
CString str;
|
|
|
str.LoadString(ID_PROCESS_CURVE_MERGE);
|
|
|
int i=str.Find("\n");
|
|
|
if(i>0) str=str.Left(i);
|
|
|
|
|
|
//CPropertiesSheet sheet(str,GetView(),0,FALSE);
|
|
|
//sheet.SetItem(this);
|
|
|
//if(sheet.DoModal()!=IDOK) return FALSE;
|
|
|
|
|
|
return TRUE;
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
BOOL CItemLinkCurve::InitPropertyGrid(CXTPPropertyGrid& grid)
|
|
|
{
|
|
|
if(m_nMode!=LINK_CURVE_MERGE) return FALSE;
|
|
|
|
|
|
CPropertyGridItemAdd ItemAdd(NULL);
|
|
|
|
|
|
CXTPPropertyGridItem* pItem=grid.AddCategory(ID_PROCESS_CURVE_MERGE);
|
|
|
ItemAdd.SetItem(pItem); pItem->Expand();
|
|
|
CString strFormat=GetFloatFormatString();
|
|
|
|
|
|
ItemAdd.AddItemCombo(ID_PROCESS_CURVE_MERGE, ID_PROCESS_CURVE_MERGE_MODE, m_nMergeIdea, &m_nMergeIdea);
|
|
|
ItemAdd.AddItemBool(IDS_GI_ARC_TO_CURVE_DELETE, m_bIsDelete,&m_bIsDelete);
|
|
|
|
|
|
return TRUE;
|
|
|
}
|
|
|
|
|
|
BOOL CItemLinkCurve::OnGridItemChangeValue(CXTPPropertyGridItem* pItem)
|
|
|
{
|
|
|
BOOL bUpdate=TRUE;
|
|
|
switch(pItem->GetID())
|
|
|
{
|
|
|
case 0:
|
|
|
bUpdate=FALSE;
|
|
|
break;
|
|
|
case ID_PROCESS_CURVE_MERGE:
|
|
|
break;
|
|
|
}
|
|
|
return bUpdate;
|
|
|
}
|
|
|
*/ |