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.
242 lines
4.7 KiB
C++
242 lines
4.7 KiB
C++
#include "StdAfx.h"
|
|
#include "ItemCutOut.h"
|
|
#include "SigmaDoc.h"
|
|
#include "SigmaView.h"
|
|
#include ".\itemcutout.h"
|
|
#include "DrawOperator\cutout.h"
|
|
#include "ActionListItem.h"
|
|
#include "ActionAddItem.h"
|
|
|
|
CItemCutOut::CItemCutOut(CSigmaDoc* ppDoc)
|
|
:CItem(ppDoc),
|
|
m_nInfoID(0)
|
|
{
|
|
this->SetType(ITEM_CUT_OUT);
|
|
//SetProcessIdea(CUT_OUT_RECTANGLE);
|
|
m_range.SetRect(0,0,0,0);
|
|
m_nMode=0;
|
|
|
|
m_pSelectCurve = new CItemSelectCurve(GetDoc());
|
|
m_pSelectCurve->SetNumber(-1);
|
|
m_pSelectCurve->EnableSelectOtherType(TRUE);
|
|
m_pSelectCurve->AddOtherType(DOUBLEFOX_ELLIPSE);
|
|
m_pSelectCurve->AddOtherType(DOUBLEFOX_ARC);
|
|
m_pSelectCurve->AddOtherType(DOUBLEFOX_CIRCLE);
|
|
m_pSelectCurve->AddOtherType(DOUBLEFOX_CRECT);
|
|
|
|
}
|
|
|
|
CItemCutOut::~CItemCutOut(void)
|
|
{
|
|
if(m_pSelectCurve) delete m_pSelectCurve;
|
|
m_pSelectCurve=NULL;
|
|
}
|
|
|
|
|
|
void CItemCutOut::OnLButtonDown(CDC *pDC, UINT nFlags, CPoint point, int vk)
|
|
{
|
|
m_pSelectCurve->OnLButtonDown(pDC, nFlags, point, vk);
|
|
if (m_pSelectCurve->GetSelectCount() > 0)
|
|
CutOutPickup();
|
|
}
|
|
|
|
int CItemCutOut::GetCountOfPickup()
|
|
{
|
|
return m_pSelectCurve->GetSelectCount();
|
|
}
|
|
|
|
int CItemCutOut::CutOut(CCurveEx* pCurveRange, CCurveEx* pSourceCurveRange)
|
|
{
|
|
CCutOut co;
|
|
co.SetSourceCurveRange(pSourceCurveRange);
|
|
co.SetXY(GetXY());
|
|
co.m_dMiniCurveSmoothStep=GetDC()->GetMiniSmoothStep();
|
|
|
|
//GetDoc()->BeginProgress("Cut out...");
|
|
co.CutOut(pCurveRange);
|
|
|
|
//CActionDeleteItem deleteItem(GetDoc(), IDS_STRING_ACTION_DELETE, co.m_plDel);
|
|
//deleteItem.Do();
|
|
|
|
if (m_nInfoID == 0) m_nInfoID = ID_CUT_OUT_MAP_RECTANGLE;
|
|
|
|
//for undo/redo
|
|
CActionListItem *pAction = new CActionListItem(GetDoc(), m_nInfoID);
|
|
//ÔªËØÉ¾³ý²Ù×÷
|
|
pAction->AddDeleteItem(co.m_plDel);
|
|
//ÔªËØÔö¼Ó²Ù×÷
|
|
CActionAddItem* pItem = new CActionAddItem(GetDoc(), 0, co.m_plAdd);
|
|
pAction->AddTailItem(pItem);
|
|
GetDoc()->SetActionItem(pAction);
|
|
|
|
return 1;
|
|
}
|
|
|
|
int CItemCutOut::CutOutRectangle(CRect8 rect)
|
|
{
|
|
CCurveEx ceRange;
|
|
ceRange.CreateCurveFromRect(&rect);
|
|
return CutOut(&ceRange);
|
|
}
|
|
|
|
int CItemCutOut::CutOutPickup(void)
|
|
{
|
|
POSITION pos=m_pSelectCurve->GetSelectItem(0);
|
|
if(pos==NULL)
|
|
return 0;
|
|
|
|
BOOL bDeleteCurve=FALSE;
|
|
CCurveEx* pRgn=m_pSelectCurve->GetRangeCurve(pos, bDeleteCurve);
|
|
if(pRgn==NULL)
|
|
return 0;
|
|
|
|
int rt=0;
|
|
if(pRgn->IsClosed())
|
|
rt=CutOut(pRgn, pRgn);
|
|
else
|
|
{
|
|
CCurveEx* pc=new CCurveEx;
|
|
*pc=*pRgn;
|
|
pc->SetToClose();
|
|
pc->num+=1;
|
|
pc->GetLocation();
|
|
rt=CutOut(pc, pRgn);
|
|
delete pc;
|
|
}
|
|
|
|
if(bDeleteCurve)
|
|
delete pRgn;
|
|
return rt;
|
|
}
|
|
|
|
int CItemCutOut::CutOutAccurately(void)
|
|
{
|
|
return 0;
|
|
/*
|
|
CPropertiesSheet sheet(IDS_STRING_CUT_OUT_MAP,GetView(),0,FALSE);
|
|
sheet.SetItem(this);
|
|
if(sheet.DoModal()!=IDOK) return 0;
|
|
|
|
CRect8 rect=m_range;
|
|
CCurveEx ceRange;
|
|
switch(m_nMode)
|
|
{
|
|
case 0:
|
|
ceRange.CreateCurveFromRect(&rect);
|
|
break;
|
|
case 2://¶È·ÖÃë, ת»»Îª¶È
|
|
rect.left=AfxGetPublicFunction()->ToDegree(rect.left);
|
|
rect.top=AfxGetPublicFunction()->ToDegree(rect.top);
|
|
rect.right=AfxGetPublicFunction()->ToDegree(rect.right);
|
|
rect.bottom=AfxGetPublicFunction()->ToDegree(rect.bottom);
|
|
case 1://¶È ת»»Îª·Ö
|
|
rect.left*=60;
|
|
rect.top*=60;
|
|
rect.right*=60;
|
|
rect.bottom*=60;
|
|
if(CreateCurveWidthBL(rect, ceRange)==0)
|
|
return 0;
|
|
//¸ù¾Ý¾Î³¶ÈÉú³É·¶Î§ÇúÏß
|
|
break;
|
|
}
|
|
return CutAccurately(&ceRange);
|
|
*/
|
|
}
|
|
|
|
int NItem::CItemCutOut::CutAccurately(CCurveEx* pCurveRange)
|
|
{
|
|
return CutOut(pCurveRange);
|
|
}
|
|
|
|
int CItemCutOut::CreateCurveWidthBL(CRect8& rect, CCurveEx& curve)
|
|
{
|
|
CExchangeXYZ net;
|
|
net.SetProjection(&(GetXY()->m_ExchangeXYZ));
|
|
|
|
dfPoint dp;
|
|
CPointList list;
|
|
|
|
double dl=rect.Width()*0.02;
|
|
double db=rect.Height()*0.02;
|
|
|
|
double v=rect.left;
|
|
dp.x0=v;
|
|
dp.y0=rect.top;
|
|
net.ToXY_M(dp.x0, dp.y0);
|
|
list.AddTail(dp);
|
|
|
|
//Point(left,top)--->Point(right,top);
|
|
v+=dl;
|
|
while(v<rect.right)
|
|
{
|
|
dp.x0=v;
|
|
dp.y0=rect.top;
|
|
net.ToXY_M(dp.x0, dp.y0);
|
|
list.AddTail(dp);
|
|
v+=dl;
|
|
}
|
|
v=rect.top;
|
|
dp.x0=rect.right;
|
|
dp.y0=v;
|
|
net.ToXY_M(dp.x0, dp.y0);
|
|
list.AddTail(dp);
|
|
|
|
//Point(right,top)--->Point(right,bottom);
|
|
v-=db;
|
|
while(v>rect.bottom)
|
|
{
|
|
dp.x0=rect.right;
|
|
dp.y0=v;
|
|
net.ToXY_M(dp.x0, dp.y0);
|
|
list.AddTail(dp);
|
|
v-=db;
|
|
}
|
|
v=rect.right;
|
|
dp.x0=v;
|
|
dp.y0=rect.bottom;
|
|
net.ToXY_M(dp.x0, dp.y0);
|
|
list.AddTail(dp);
|
|
|
|
//Point(right,bottom)--->Point(left,bottom);
|
|
v-=dl;
|
|
while(v>rect.left)
|
|
{
|
|
dp.x0=v;
|
|
dp.y0=rect.bottom;
|
|
net.ToXY_M(dp.x0, dp.y0);
|
|
list.AddTail(dp);
|
|
v-=dl;
|
|
}
|
|
v=rect.bottom;
|
|
dp.x0=rect.left;
|
|
dp.y0=v;
|
|
net.ToXY_M(dp.x0, dp.y0);
|
|
list.AddTail(dp);
|
|
|
|
//Point(left,bottom)--->Point(left,top);
|
|
v+=db;
|
|
while(v<rect.top)
|
|
{
|
|
dp.x0=rect.left;
|
|
dp.y0=v;
|
|
net.ToXY_M(dp.x0, dp.y0);
|
|
list.AddTail(dp);
|
|
v+=db;
|
|
}
|
|
v=rect.left;
|
|
dp.x0=v;
|
|
dp.y0=rect.top;
|
|
net.ToXY_M(dp.x0, dp.y0);
|
|
list.AddTail(dp);
|
|
|
|
curve.SetPoints(list, 2);
|
|
GetDC()->Draw(curve);
|
|
|
|
return 1;
|
|
}
|
|
|
|
CXy* NItem::CItemCutOut::GetXY(void)
|
|
{
|
|
return GetDoc()->GetDraw();
|
|
}
|