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.
100 lines
2.5 KiB
C++
100 lines
2.5 KiB
C++
#include "stdafx.h"
|
|
#include "ItemBranchCurveEdit.h"
|
|
|
|
NItem::CItemBranchCurveEdit::CItemBranchCurveEdit(CSigmaDoc * pDoc, CPositionList & selectionCache, BOOL bPopupToolbar)
|
|
: CItemCurveEditDeleteMulNodes(pDoc, selectionCache, bPopupToolbar)
|
|
{
|
|
this->SetType(ITEM_WELL_BRANCH_CURVE_EDIT);
|
|
POSITION posEdit = GetPos();
|
|
|
|
for (const auto &value : pDoc->m_BranchElements) {
|
|
if (value.DataPosition == posEdit) {
|
|
this->m_BranchInfo = value;
|
|
break;
|
|
}
|
|
}
|
|
for (const auto &value : pDoc->m_BranchElements)
|
|
{
|
|
if (value.BranchIndex == this->m_BranchInfo.BranchIndex
|
|
&& value.DataType != this->m_BranchInfo.DataType) {
|
|
this->m_BranchInfoOther = value;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
NItem::CItemBranchCurveEdit::~CItemBranchCurveEdit(void)
|
|
{
|
|
}
|
|
void CItemBranchCurveEdit::OnLButtonUp(CDC * pDC, UINT nFlags, CPoint point, int vk)
|
|
{
|
|
int i = GetHandleIndex();
|
|
CItemCurveEditDeleteMulNodes::OnLButtonUp(pDC, nFlags, point, vk);
|
|
|
|
COne* pOneOther = GetDoc()->GetDraw()->GetAt(this->m_BranchInfoOther.DataPosition);
|
|
|
|
CCurveEx* pValue = GetCurCurve();
|
|
CCurveEx* pCurveOther = (CCurveEx*)pOneOther->value;
|
|
|
|
dfPoint pt;
|
|
// ±à¼µÄÊÇˮƽ¶Î
|
|
if (this->m_BranchInfo.DataType == 1&& i == 0)
|
|
{
|
|
pCurveOther->x[1] = pValue->x[0];
|
|
pCurveOther->y[1] = pValue->y[0];
|
|
}
|
|
else if (this->m_BranchInfo.DataType == 0 && i == 1)
|
|
{
|
|
pCurveOther->x[0] = pValue->x[1];
|
|
pCurveOther->y[0] = pValue->y[1];
|
|
}
|
|
}
|
|
void NItem::CItemBranchCurveEdit::DrawMoveLine(void)
|
|
{
|
|
CItemCurveEditDeleteMulNodes::DrawMoveLine();
|
|
COne* pOneOther = GetDoc()->GetDraw()->GetAt(this->m_BranchInfoOther.DataPosition);
|
|
CCurveEx* pCurveOther = (CCurveEx*)pOneOther->value;
|
|
CXyDC* pDC = GetDC();
|
|
|
|
int i = GetHandleIndex();
|
|
CPoint2D c_down = GetCDown();
|
|
CPoint2D c_last = GetCLast();
|
|
double dx = c_last.x0 - c_down.x0;
|
|
double dy = c_last.y0 - c_down.y0;
|
|
|
|
dfPoint ptDest;
|
|
CCurveEx* pValue = GetCurCurve();
|
|
GetXY(pValue, i, ptDest);
|
|
ptDest.x0 += dx;
|
|
ptDest.y0 += dy;
|
|
CPoint ptDestS = pDC->GetScreen(ptDest);
|
|
|
|
CPen pen(PS_SOLID, 0, DRAG_LINE_COLOR);
|
|
CPen* op = (CPen*)m_pScreenDC->SelectObject(&pen);
|
|
int od = m_pScreenDC->SetROP2(R2_NOTXORPEN);
|
|
|
|
dfPoint pt;
|
|
// ±à¼µÄÊÇˮƽ¶Î
|
|
if (this->m_BranchInfo.DataType == 1
|
|
&& i==0) {
|
|
GetXY(pCurveOther, 0, pt);
|
|
CPoint ptS1 = pDC->GetScreen(pt);
|
|
m_pScreenDC->MoveTo(ptS1);
|
|
|
|
m_pScreenDC->LineTo(ptDestS.x, ptDestS.y);
|
|
}
|
|
else if (this->m_BranchInfo.DataType == 0 && i == 1)
|
|
{
|
|
GetXY(pCurveOther, 1, pt);
|
|
CPoint ptS1 = pDC->GetScreen(pt);
|
|
m_pScreenDC->MoveTo(ptS1);
|
|
|
|
m_pScreenDC->LineTo(ptDestS.x, ptDestS.y);
|
|
}
|
|
|
|
m_pScreenDC->SetROP2(od);
|
|
m_pScreenDC->SelectObject(op);
|
|
}
|
|
|
|
|