#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(); double dx = GetCLast().x0 - GetCDown().x0; double dy = GetCLast().y0 - GetCDown().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); }