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.
196 lines
4.4 KiB
C++
196 lines
4.4 KiB
C++
#include "StdAfx.h"
|
|
#include ".\itemcurveeditdeletemulnodes.h"
|
|
#include "SigmaDoc.h"
|
|
#include "SigmaView.h"
|
|
//#include "MainFrm.h"
|
|
|
|
namespace NItem
|
|
{
|
|
|
|
CItemCurveEditDeleteMulNodes::CItemCurveEditDeleteMulNodes(CSigmaDoc * ppDoc, CPositionList & selectionCache, BOOL bPopupToolbar/*=TRUE*/)
|
|
: CItemCurveEdit(ppDoc)
|
|
, m_bDeleteMulNodes(FALSE)
|
|
, m_bBeginSelect(FALSE)
|
|
{
|
|
m_pFocusRect=new CItemFocusRect(ppDoc);
|
|
POSITION pos = selectionCache.GetHead();
|
|
CItemCurveEdit::SetPos(pos);
|
|
|
|
//m_selectionCache.AddTail(&selectionCache);
|
|
//if(bPopupToolbar)
|
|
//{
|
|
// //CMainFrame* pmf = (CMainFrame*)GetDoc()->GetMainFrame();
|
|
// //if(pmf)pmf->ShowToolBar(IDR_TOOLBAR_PLINE_EDIT, TRUE);
|
|
//}
|
|
}
|
|
|
|
CItemCurveEditDeleteMulNodes::~CItemCurveEditDeleteMulNodes(void)
|
|
{
|
|
if(m_pFocusRect)delete m_pFocusRect;
|
|
m_pFocusRect=NULL;
|
|
|
|
//CMainFrame* pmf = (CMainFrame*)GetDoc()->GetMainFrame();
|
|
//if(pmf)pmf->ShowToolBar(IDR_TOOLBAR_PLINE_EDIT, FALSE);
|
|
}
|
|
|
|
void CItemCurveEditDeleteMulNodes::DoLButtonUp(void)
|
|
{
|
|
CRect8 rt=m_pFocusRect->GetRect();
|
|
if(rt.IsEmpty()) return;
|
|
|
|
CRect irect;
|
|
CRect8 rr;
|
|
if(!GetDoc()->GetElementRect(GetPos(),rr))
|
|
rr=rt;
|
|
irect=GetDoc()->GetDC().GetScreen(rr);
|
|
|
|
//为了绑定处理/////////////////////////////////////////////////////////
|
|
//是否进行曲线绑定编辑
|
|
BOOL bAttachProcess = TRUE; // GetPreferences().WorkaroundEdit.m_bCurveBindEdit;
|
|
int nPointIndex = -1;
|
|
CPointList oldPoints;
|
|
CPointList newPoints;
|
|
dfPoint pt;
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
CCurveEx* pValue=GetCurCurve();//(CCurveEx*)GetDoc()->GetDraw()->GetAtValue(GetPos());
|
|
dfPoint dd;
|
|
for(int i=0;i<pValue->num;i++)
|
|
{
|
|
pValue->GetPoint(i, dd);
|
|
if(rt.PtInRect(dd.x0,dd.y0)) //需要删除的坐标点
|
|
{
|
|
if(bAttachProcess)
|
|
{
|
|
//为了绑定处理,备份原坐标点
|
|
if(nPointIndex == -1)
|
|
{
|
|
//增加第一个点
|
|
if(i>0)
|
|
{
|
|
pValue->GetPoint(i-1, pt);
|
|
oldPoints.AddTail(pt);
|
|
newPoints.AddTail(pt);
|
|
}
|
|
}
|
|
nPointIndex = i;
|
|
oldPoints.AddTail(dd);
|
|
}
|
|
|
|
continue;
|
|
}
|
|
if(bAttachProcess && oldPoints.GetCount()>0)
|
|
{
|
|
if(nPointIndex < pValue->num-1)
|
|
{
|
|
oldPoints.AddTail(dd);
|
|
newPoints.AddTail(dd);
|
|
}
|
|
AttachProcess(oldPoints, newPoints);
|
|
|
|
nPointIndex = -1;
|
|
oldPoints.RemoveAll();
|
|
newPoints.RemoveAll();
|
|
}
|
|
|
|
//非删除点
|
|
PointList.AddTail(dd);
|
|
}
|
|
if(PointList.GetCount()!=pValue->num)
|
|
{
|
|
pValue->SetPoints(PointList,pValue->nPoint,pValue->bAutoLocation);
|
|
GetDoc()->Modified();
|
|
SetModifiedFlag(TRUE);
|
|
//GetDoc()->Invalidate(&irect);
|
|
}
|
|
PointList.RemoveAll();
|
|
m_bBeginSelect = false;
|
|
}
|
|
|
|
void CItemCurveEditDeleteMulNodes::OnLButtonDblClk(UINT nFlags, CPoint point)
|
|
{
|
|
if(m_bDeleteMulNodes)
|
|
m_pFocusRect->OnLButtonDblClk(nFlags,point);
|
|
else
|
|
CItemCurveEdit::OnLButtonDblClk(nFlags,point);
|
|
}
|
|
|
|
void CItemCurveEditDeleteMulNodes::OnLButtonDown(CDC *pDC, UINT nFlags, CPoint point, int vk)
|
|
{
|
|
SetScreenDC(pDC);
|
|
if (m_bDeleteMulNodes)
|
|
{
|
|
if (m_bBeginSelect == false)
|
|
{
|
|
m_bBeginSelect = !m_bBeginSelect;
|
|
//return;
|
|
}
|
|
m_pFocusRect->OnLButtonDown(pDC, nFlags, point, vk);
|
|
}
|
|
else
|
|
CItemCurveEdit::OnLButtonDown(pDC, nFlags, point, vk);
|
|
}
|
|
|
|
void CItemCurveEditDeleteMulNodes::OnLButtonUp(CDC * pDC, UINT nFlags, CPoint point, int vk)
|
|
{
|
|
SetScreenDC(pDC);
|
|
if(m_bDeleteMulNodes)
|
|
{
|
|
m_pFocusRect->OnLButtonUp(pDC, nFlags,point, vk);
|
|
DoLButtonUp();
|
|
}
|
|
else
|
|
CItemCurveEdit::OnLButtonUp(pDC, nFlags,point, vk);
|
|
}
|
|
|
|
int CItemCurveEditDeleteMulNodes::OnMouseMove(CDC * pDC, UINT nFlags, CPoint point)
|
|
{
|
|
if(m_bDeleteMulNodes)
|
|
{
|
|
if (m_bBeginSelect == false) {
|
|
return 1;
|
|
}
|
|
m_pFocusRect->OnMouseMove(pDC, nFlags, point);
|
|
}
|
|
else
|
|
CItemCurveEdit::OnMouseMove(pDC, nFlags,point);
|
|
return 1;
|
|
}
|
|
|
|
BOOL CItemCurveEditDeleteMulNodes::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
|
|
{
|
|
/*
|
|
if(m_bDeleteMulNodes)
|
|
{
|
|
GetDoc()->GetCursor().SetCursor(CursorMulDeleteHandle);
|
|
return GetDoc()->GetCursor().SetCursor();
|
|
}
|
|
else
|
|
return CItemCurveEdit::OnSetCursor(pWnd,nHitTest,message);
|
|
*/
|
|
return FALSE;
|
|
}
|
|
|
|
void CItemCurveEditDeleteMulNodes::EnableMulDelete(BOOL bMulDelete)
|
|
{
|
|
m_bDeleteMulNodes=bMulDelete;
|
|
if(bMulDelete)
|
|
this->SetHandleIndex(-1);
|
|
}
|
|
|
|
BOOL CItemCurveEditDeleteMulNodes::IsMulDelete(void)
|
|
{
|
|
return m_bDeleteMulNodes;
|
|
}
|
|
|
|
//POSITION CItemCurveEditDeleteMulNodes::GetPos()
|
|
//{
|
|
// if (m_selectionCache.GetSize() == 0)
|
|
// return 0;
|
|
//
|
|
// POSITION pos = m_selectionCache.GetHeadPosition();
|
|
// return m_selectionCache.GetAt(pos);
|
|
//}
|
|
}//namespace
|
|
|