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.
152 lines
3.1 KiB
C++
152 lines
3.1 KiB
C++
#include "StdAfx.h"
|
|
#include "CurveEditorDefault.h"
|
|
#include "SigmaDoc.h"
|
|
#include "ActionCurveEdit.h"
|
|
|
|
namespace NItem
|
|
{
|
|
|
|
void CurveEditorDefault::OnDrawDragPreview()
|
|
{
|
|
// ========== ??????????????????? ==========
|
|
int i = GetHandleIndex();
|
|
if (i < 0) return;
|
|
|
|
CCurveEx* pValue = GetControlCurve();
|
|
if (pValue == nullptr || i >= pValue->num)
|
|
{
|
|
return;
|
|
}
|
|
|
|
CXyDC* pDC = GetDC();
|
|
CPen pen(PS_SOLID, 0, DRAG_LINE_COLOR);
|
|
CPen* op = (CPen*)m_pScreenDC->SelectObject(&pen);
|
|
int od = m_pScreenDC->SetROP2(R2_NOTXORPEN);
|
|
|
|
double dx = c_last.x0 - c_down.x0;
|
|
double dy = c_last.y0 - c_down.y0;
|
|
dfPoint pt;
|
|
|
|
// ????????????????????????
|
|
if (i > 0)
|
|
{
|
|
GetXY(pValue, i - 1, pt);
|
|
CPoint ptS1 = pDC->GetScreen(pt);
|
|
m_pScreenDC->MoveTo(ptS1);
|
|
|
|
GetXY(pValue, i, pt);
|
|
pt.x0 += dx;
|
|
pt.y0 += dy;
|
|
CPoint ptS2 = pDC->GetScreen(pt);
|
|
m_pScreenDC->LineTo(ptS2.x, ptS2.y);
|
|
}
|
|
|
|
// ?????????????????????????
|
|
if (i < pValue->num - 1)
|
|
{
|
|
GetXY(pValue, i + 1, pt);
|
|
CPoint ptS1 = pDC->GetScreen(pt);
|
|
m_pScreenDC->MoveTo(ptS1);
|
|
|
|
GetXY(pValue, i, pt);
|
|
pt.x0 += dx;
|
|
pt.y0 += dy;
|
|
CPoint ptS2 = pDC->GetScreen(pt);
|
|
m_pScreenDC->LineTo(ptS2.x, ptS2.y);
|
|
}
|
|
|
|
m_pScreenDC->SetROP2(od);
|
|
m_pScreenDC->SelectObject(op);
|
|
}
|
|
|
|
void CurveEditorDefault::OnCalculateDragEffect(CPointList* pList)
|
|
{
|
|
// pList != nullptr???????????????????????????????????
|
|
// pList == nullptr???????????????? Undo/Redo ??????
|
|
BOOL bRedraw = TRUE;
|
|
BOOL bAttachProcess = TRUE; // ??????????
|
|
CCurveEx* pValue = (CCurveEx*)GetDoc()->GetDraw()->GetAtValue(GetPos());
|
|
|
|
if (pList)
|
|
{
|
|
// ??????????????????
|
|
CCurveEx* pc = new CCurveEx;
|
|
*pc = *pValue;
|
|
pValue = pc;
|
|
bRedraw = FALSE;
|
|
bAttachProcess = FALSE;
|
|
}
|
|
|
|
CPointList oldPoints; // ???????????????????????
|
|
CPointList newPoints; // ???????????????????????
|
|
dfPoint pt;
|
|
CRect rt;
|
|
|
|
// ========== ??????????????????? ==========
|
|
int i = GetHandleIndex();
|
|
if (bRedraw)
|
|
{
|
|
// ??????????? GetRangeWidthIndex????????????????
|
|
// rt = GetRangeWidthIndex(i);
|
|
}
|
|
|
|
// ??????????????????
|
|
if (bAttachProcess)
|
|
{
|
|
if (i - 1 >= 0)
|
|
{
|
|
pValue->GetPoint(i - 1, pt); oldPoints.AddTail(pt);
|
|
}
|
|
pValue->GetPoint(i, pt); oldPoints.AddTail(pt);
|
|
if (i + 1 <= pValue->num - 1)
|
|
{
|
|
pValue->GetPoint(i + 1, pt); oldPoints.AddTail(pt);
|
|
}
|
|
}
|
|
|
|
CActionCurveEdit* pAction = 0;
|
|
if (pList == nullptr)
|
|
{
|
|
pAction = new CActionCurveEdit(GetDoc(), 0, GetPos());
|
|
pAction->BackupUndoNode(i, pValue->x[i], pValue->y[i]);
|
|
}
|
|
|
|
pValue->x[i] += (c_last.x0 - c_down.x0);
|
|
pValue->y[i] += (c_last.y0 - c_down.y0);
|
|
if (pValue->bAutoLocation) pValue->GetLocation();
|
|
|
|
if (pList == nullptr)
|
|
{
|
|
pAction->BackupRedoNode(i, pValue->x[i], pValue->y[i]);
|
|
GetDoc()->SetActionItem(pAction);
|
|
}
|
|
|
|
if (bAttachProcess)
|
|
{
|
|
// ???????????????????
|
|
if (i - 1 >= 0)
|
|
{
|
|
pValue->GetPoint(i - 1, pt); newPoints.AddTail(pt);
|
|
}
|
|
pValue->GetPoint(i, pt); newPoints.AddTail(pt);
|
|
if (i + 1 <= pValue->num - 1)
|
|
{
|
|
pValue->GetPoint(i + 1, pt); newPoints.AddTail(pt);
|
|
}
|
|
AttachProcess(oldPoints, newPoints);
|
|
}
|
|
|
|
if (bRedraw)
|
|
{
|
|
// rt = GetRangeWidthIndex(i);
|
|
}
|
|
|
|
if (pList)
|
|
{
|
|
pValue->GetPoint(*pList);
|
|
delete pValue;
|
|
}
|
|
}
|
|
|
|
}; // namespace
|