#include "StdAfx.h" #include "ItemSectionWell.h" #include "WellPoleLib/WellCommonDef.h" #include "WellPoleLib/WellBaseObj.h" #include "WellPoleLib/WellClassObjGroup.h" #include "WellPoleLib/TrackObj.h" #include "WellPoleLib/InclinedTrack.h" #include "WellPoleLib\TrackResult.h" #include "WellPoleLib\InTrackResult.h" #include "WellPoleLib\TrackStratum.h" #include "WellPoleLib\InTrackLayerGroup.h" #include "WellPoleLib/WellPole.h" #include "MultiWellSectionLib/BendObj.h" #include "MultiWellSectionLib/SectionWellObj.h" #include "MultiWellSectionLib\VirtualWellObj.h" #include "MultiWellSectionLib\WellSection.h" #include "ItemWcsTrack.h" #include "ItemWcsTrackIn.h" #include "MultiWellSectionDoc.h" #include "MultiWellSectionlView.h" #include "ActionMoveSectionWellItem.h" namespace NItem { CItemSectionWell::CItemSectionWell(CSigmaDoc* pDoc, BOOL bAdd) : CItemWcsSingleWell(pDoc) { SetType(ITEM_SECTIONWELL); m_bAddWell = bAdd; } CItemSectionWell::~CItemSectionWell(void) { } void CItemSectionWell::OnDraw(CXyDC* pXyDC, CDC* pDC) { if (m_bAddWell) { if(!m_bLDown) return; CPen pen(PS_DOT, 0, RGB(0, 0, 0)); CPen *pOldPen = (CPen *)pDC->SelectObject(&pen); int old = pDC->SetROP2(R2_NOTXORPEN); CPoint p1,p2; p1 = m_downPoint; p2 = m_lastPoint; p2.x = p1.x; pDC->MoveTo(p1); pDC->LineTo(p2); pDC->SelectObject(pOldPen); pen.DeleteObject(); pDC->SetROP2(old); } else { CItemWcsSingleWell::OnDraw(pXyDC ,pDC); } } void CItemSectionWell::OnLButtonDown(CDC *pDC, UINT nFlags, CPoint point, int vk) { if (m_bAddWell) { m_bLDown = TRUE; m_downPoint = m_firstPoint = m_lastPoint = point; OnDraw(GetDC(),pDC); //GetView()->SetCapture(); ////刷新属性页 } else { CItemWcsSingleWell::OnLButtonDown(pDC,nFlags,point ,vk); } } int CItemSectionWell::OnMouseMove(CDC *pDC, UINT nFlags, CPoint point) { if (m_bAddWell) { CPoint2D lastPoint = GetDC()->GetReal(point); if(IsCaptureState() && m_bLDown) { OnDraw(GetDC() ,pDC); m_bDrag = TRUE; m_lastPoint = point; OnDraw(GetDC(), pDC); } } else { CItemWcsSingleWell::OnMouseMove(pDC,nFlags, point); } return 1; } void CItemSectionWell::MoveWellInSection(CWellSection* pSection, CWellPole* pMoveWellObj, CPoint2D delta) { //井移动的原则,只横向移动,最左侧井不移动,其余井移动时带动右侧井一起移动,移动的井与左侧井的位置有变化。 std::vector wellArr; std::set wellsSet; int moveId = -1; POSITION pos = pSection->m_WellList.GetHeadPosition(); while (pos) { CWellPole* pWell = (CWellPole*)pSection->m_WellList.GetNext(pos); wellArr.push_back(pWell); if (pWell == pMoveWellObj) moveId = int(wellArr.size() - 1); } CRect8 preRect = wellArr[moveId - 1]->GetRect(); CRect8 oldRect = wellArr[moveId]->GetRect(); double left = preRect.right; double moveLeft = oldRect.left; if (preRect.right > (oldRect.left + delta.x0)) {//不能进入左侧井的范围 delta.x0 = preRect.right - oldRect.left + 20; } wellArr[moveId]->m_delta = delta; oldRect.OffsetRect(delta.x0, delta.y0); wellArr[moveId]->MoveTo(oldRect); CSectionWellObj* pSectionWell = (CSectionWellObj*)wellArr[moveId]; pSectionWell->m_fHorzDistance += pSection->ScreenCXToWidth(delta.x0); double right1 = moveLeft + delta.x0; pos = pSection->m_FaultList.GetHeadPosition(); while (pos) { CFaultObj* pFault = (CFaultObj*)pSection->m_FaultList.GetNext(pos); //移动的第一口井,其与左侧的井位置发生变化,计算一下它们中间断层的相对位置。 for (int j = 0; j < pFault->m_OrgCtrlPts.size(); j++) { dfPoint pt = pFault->m_OrgCtrlPts[j]; if (left < pt.x0 && pt.x0 < (moveLeft + 0.00001)) { pt.x0 = left + (pt.x0 - left) / (moveLeft - left) * (right1 - left); pFault->m_OrgCtrlPts[j] = pt; } else if (pt.x0 > moveLeft) { dfPoint pt = pFault->m_OrgCtrlPts[j]; pFault->m_OrgCtrlPts[j].x0 = pt.x0 + delta.x0; } } pFault->ComputedFaultCurvePoints(pFault->IsBSPline()); } for (int i = moveId + 1; i < wellArr.size(); i++) { oldRect = wellArr[i]->GetRect(); wellArr[i]->m_delta = delta; oldRect.OffsetRect(delta.x0, delta.y0); wellArr[i]->MoveTo(oldRect); } //井和断层移动到位置后,重新计算bend pos = pSection->m_BendList.GetHeadPosition(); while (pos) { CBendObj* pBend = (CBendObj*)pSection->m_BendList.GetNext(pos); std::vector::iterator lit = std::find(wellArr.begin() + (moveId - 1), wellArr.end(), pBend->m_pWellLeft); std::vector::iterator rit = std::find(wellArr.begin() + (moveId - 1), wellArr.end(), pBend->m_pWellRight); if (lit != wellArr.end() || rit != wellArr.end()) { pBend->ComputeBend(); } } } void CItemSectionWell::SetUndoRedoForMoveWell(POSITION pos, CWellPole* pMoveWellObj, CPoint2D delta) { CPositionList list; list.AddTail(pos); (GetDoc())->SetActionItem(new CActionMoveSectionWell(GetDoc(), IDS_STRING_ACTION_MOVE, list, pMoveWellObj, delta)); } void CItemSectionWell::MoveWell_ResForm(CDC* pDC, UINT nFlags, CPoint point, CWellPole* pMoveWellObj) { CWellSection* pSection = (CWellSection*)pMoveWellObj->GetParent(); CWellPole* pWell = (CWellPole*)pSection->m_WellList.GetHead(); if (pMoveWellObj == pWell) return; if (selectMode == CItemSelect::size) { SetReUnDoAction(); pSection->ReComputeBends(pMoveWellObj); } else { point.y = this->m_downPoint.y; //只能横向移动 //CItemWcsSingleWell::OnLButtonUp(nFlags, point); CPoint2D downPoint = GetDC()->GetReal(m_downPoint); CPoint2D lastPoint = GetDC()->GetReal(m_lastPoint); CPoint2D delta(lastPoint.x0 - downPoint.x0, 0); CWellPole* pWell = (CWellPole*)pSection->m_WellList.GetHead(); if (pWell == pMoveWellObj) return; //SetReUnDoAction(); SetUndoRedoForMoveWell(GetPos(), pMoveWellObj, delta); MoveWellInSection(pSection, pMoveWellObj, delta); } pSection->ReSetPosition(); //GetView()->SetScrollBarRange(); CMultiWellSectionView* pView = (CMultiWellSectionView*)GetView(); pView->m_pWndCallBack(eWellPoleCallbackMsgDef::tInvalidateWnd, 0); } void CItemSectionWell::MoveWell_oldDF(CDC* pDC, UINT nFlags, CPoint point, CWellPole* pWellObj) { SetReUnDoAction(); CWellSection* pSection = (CWellSection*)pWellObj->GetParent(); POSITION posBend = pSection->m_BendList.GetHeadPosition(); while (NULL != posBend) { CBendObj* pBend = (CBendObj*)pSection->m_BendList.GetNext(posBend); if (pBend->m_pWellLeft == pWellObj || pBend->m_pWellRight == pWellObj) { double XLeft = 0.0; double XRight = 0.0; pBend->GetBendXValue(XLeft, XRight); if (XLeft > XRight) { double temp; temp = XLeft; XLeft = XRight; XRight = temp; } for (int i = 0; i < pBend->m_faultArr.GetCount(); i++) { FaultOnBendStruct BendStruct = pBend->m_faultArr.GetAt(i); CFaultObj* pFault = BendStruct.pFault; for (int j = 0; j < pFault->m_ptArr.GetCount(); j++) { pFault->m_ptArr.GetAt(j).z0 = (pFault->m_ptArr.GetAt(j).x0 - XLeft) / (XRight - XLeft); } } } } CItemWcsSingleWell::OnLButtonUp(pDC, nFlags, point); CPoint2D downPoint = GetDC()->GetReal(m_downPoint); CPoint2D lastPoint = GetDC()->GetReal(m_lastPoint); CPoint2D delta(lastPoint.x0 - downPoint.x0, lastPoint.y0 - downPoint.y0); CRect8 position = pWellObj->GetPos(); if (selectMode == CItemSelect::move && m_firstPoint != m_downPoint && GetWellObject()->GetParent()->GetType() != KEP_FENCE) { //其他井上下移动 POSITION pos = pSection->m_WellList.GetHeadPosition(); while (pos != NULL) { CWellPole* pWell = (CWellPole*)pSection->m_WellList.GetNext(pos); if (pWell != pWellObj) { pWell->m_delta.x0 = 0; pWell->m_delta.y0 = delta.y0; position = pWell->GetPos(); position.OffsetRect(0, delta.y0); pWell->MoveTo(position); } } //井上下拖动后断层和虚拟井也跟着上下拖动 //判断断层链表 pos = pSection->m_FaultList.GetTailPosition(); while (pos != NULL) { CFaultObj* pObj = (CFaultObj*)pSection->m_FaultList.GetPrev(pos); pObj->m_delta.x0 = 0; pObj->m_delta.y0 = delta.y0; position = pObj->GetPos(); position.OffsetRect(0, pObj->m_delta.y0); pObj->MoveTo(position); } //取前后井 CWellPole* pWellNext = NULL; CWellPole* pWellPre = NULL; POSITION posFind = pSection->m_WellList.Find(pWellObj); pSection->m_WellList.GetNext(posFind); if (posFind != NULL) pWellNext = (CWellPole*)pSection->m_WellList.GetNext(posFind); posFind = pSection->m_WellList.Find(pWellObj); pSection->m_WellList.GetPrev(posFind); if (posFind != NULL) pWellPre = (CWellPole*)pSection->m_WellList.GetPrev(posFind); ///////////////////////////////////////////////////////////////////////////// //排列井对象数组(从左到右) //临时井对象数组 CArray wellArr; pos = pSection->m_WellList.GetHeadPosition(); while (pos != NULL) { CWellBaseObj* pWell = (CWellBaseObj*)pSection->m_WellList.GetNext(pos); wellArr.Add(pWell); } for (int i = 0; i < wellArr.GetCount() - 1; i++) { for (int j = i + 1; j < wellArr.GetCount(); j++) { if (wellArr[i]->GetPos().left > wellArr[j]->GetPos().left) { CWellBaseObj* pObj = wellArr[i]; wellArr[i] = wellArr[j]; wellArr[j] = pObj; } } } pSection->m_WellList.RemoveAll(); for (int ii = 0; ii < wellArr.GetCount(); ii++) { pSection->m_WellList.AddTail(wellArr[ii]); } //清空数组 wellArr.RemoveAll(); //取前后井 CWellPole* pWellNextNew = NULL; CWellPole* pWellPreNew = NULL; posFind = pSection->m_WellList.Find(pWellObj); pSection->m_WellList.GetNext(posFind); if (posFind != NULL) pWellNextNew = (CWellPole*)pSection->m_WellList.GetNext(posFind); posFind = pSection->m_WellList.Find(pWellObj); pSection->m_WellList.GetPrev(posFind); if (posFind != NULL) pWellPreNew = (CWellPole*)pSection->m_WellList.GetPrev(posFind); ///////////////////////////////////////////////////////////////////////////// if (pWellPre != pWellPreNew || pWellNext != pWellNextNew)//井位置发生互换 { POSITION pos = pSection->m_BendList.GetHeadPosition(); while (pos != NULL) { CBendObj* pBend = (CBendObj*)pSection->m_BendList.GetNext(pos); if (pBend->m_pLayerLeft != NULL && pBend->m_pLayerLeft->GetWell() == pWellObj || (pBend->m_pLayerRight != NULL && pBend->m_pLayerRight->GetWell() == pWellObj)) { POSITION posF = pSection->m_BendList.Find(pBend); pSection->m_BendList.RemoveAt(posF); //// 井位置发生变化时,在层的左右链表中删除相关的连层 pSection->DeleteBend(pBend); //delete pBend; } else if (pWellPre != pWellPreNew && pWellPre != NULL && pBend->m_pLayerLeft != NULL && pBend->m_pLayerRight == NULL) { POSITION posF = pSection->m_BendList.Find(pBend); pSection->m_BendList.RemoveAt(posF); /////// 井位置发生变化时,在层的左右链表中删除相关的连层 pSection->DeleteBend(pBend); //delete pBend; } else if (pWellNext != pWellNextNew && pWellNext != NULL && ((pBend->m_pLayerLeft != NULL && pBend->m_pLayerLeft->GetWell() == pWellNext) || (pBend->m_pLayerRight != NULL && pBend->m_pLayerRight->GetWell() == pWellNext))) { POSITION posF = pSection->m_BendList.Find(pBend); pSection->m_BendList.RemoveAt(posF); //////// 井位置发生变化时,在层的左右链表中删除相关的连层 pSection->DeleteBend(pBend); //delete pBend; } else if (pWellPreNew != NULL && (pBend->m_pLayerLeft != NULL && pBend->m_pLayerLeft->GetWell() == pWellPreNew || (pBend->m_pLayerRight != NULL && pBend->m_pLayerRight->GetWell() == pWellPreNew))) { POSITION posF = pSection->m_BendList.Find(pBend); pSection->m_BendList.RemoveAt(posF); //////// 井位置发生变化时,在层的左右链表中删除相关的连层 pSection->DeleteBend(pBend); //delete pBend; } else if (pWellNextNew != NULL && (pBend->m_pLayerLeft != NULL && pBend->m_pLayerLeft->GetWell() == pWellNextNew || (pBend->m_pLayerRight != NULL && pBend->m_pLayerRight->GetWell() == pWellNextNew))) { POSITION posF = pSection->m_BendList.Find(pBend); pSection->m_BendList.RemoveAt(posF); //////井位置发生变化时,在层的左右链表中删除相关的连层 pSection->DeleteBend(pBend); //delete pBend; } } } //pcg结果调整后的重新计算 pSection->ReComputeBends(pWellObj); CPoint2D ptDeltaY(0, pWellObj->m_delta.y0); if (fabs(ptDeltaY.y0) > 0) { pos = pSection->m_BendList.GetHeadPosition(); while (pos != NULL) { CBendObj* pBend = (CBendObj*)pSection->m_BendList.GetNext(pos); for (int i = 0; i < pBend->m_ptArrControls.GetCount(); i++) { pBend->m_ptArrControls[i].Y -= ptDeltaY.y0; } for (int kk = 0; kk < pBend->m_ptArrCurveTopOld.GetCount(); kk++) { pBend->m_ptArrCurveTopOld.GetAt(kk).y0 += ptDeltaY.y0; } for (int kk = 0; kk < pBend->m_ptArrCurveBotOld.GetCount(); kk++) { pBend->m_ptArrCurveBotOld.GetAt(kk).y0 += ptDeltaY.y0; } for (int kk = 0; kk < pBend->m_curveBreakLithoOld.num; kk++) { pBend->m_curveBreakLithoOld.y[kk] += ptDeltaY.y0; } for (int kk = 0; kk < pBend->m_curveBreakLitho.num; kk++) { pBend->m_curveBreakLitho.y[kk] += ptDeltaY.y0; } for (int kk = 0; kk < pBend->m_curveBreakLithoInteract.num; kk++) { pBend->m_curveBreakLithoInteract.y[kk] += ptDeltaY.y0; } pBend->m_ptLeft.y0 += ptDeltaY.y0; pBend->m_ptRight.y0 += ptDeltaY.y0; pBend->m_ptEndBreakInteract.y0 += ptDeltaY.y0; pBend->m_ptBeginBreak.y0 += ptDeltaY.y0; pBend->m_ptEndBreak.y0 += ptDeltaY.y0; pBend->ComputeSlopeAndConstant(); pBend->CreateBendLines(); pBend->CreateBendFills(); } } /// 断层相对左右井的位置关系 POSITION posBend1 = pSection->m_BendList.GetHeadPosition(); while (NULL != posBend1) { CBendObj* pBend = (CBendObj*)pSection->m_BendList.GetNext(posBend1); if (pBend->m_pWellLeft == pWellObj || pBend->m_pWellRight == pWellObj) { double XLeft = 0.0; double XRight = 0.0; pBend->GetBendXValue(XLeft, XRight); if (XLeft > XRight) { double temp; temp = XLeft; XLeft = XRight; XRight = temp; } for (int i = 0; i < pBend->m_faultArr.GetCount(); i++) { FaultOnBendStruct BendStruct = pBend->m_faultArr.GetAt(i); CFaultObj* pFault = BendStruct.pFault; for (int j = 0; j < pFault->m_ptArr.GetCount(); j++) { pFault->m_ptArr.GetAt(j).x0 = XLeft + (XRight - XLeft) * pFault->m_ptArr.GetAt(j).z0; } } } } //判断虚井链表 pos = pSection->m_VirtualWellList.GetTailPosition(); while (pos != NULL) { CVirtualWellObj* pObj = (CVirtualWellObj*)pSection->m_VirtualWellList.GetPrev(pos); pObj->m_delta.x0 = 0; pObj->m_delta.y0 = delta.y0; position = pObj->GetPos(); position.OffsetRect(0, pObj->m_delta.y0); pObj->MoveTo(position); } } else if (selectMode == CItemSelect::size) { pSection->ReComputeBends(pWellObj); } //断层重新切割层位 POSITION pos = pSection->m_FaultList.GetHeadPosition(); while (pos != NULL) { CWellBaseObj* pObj = pSection->m_FaultList.GetNext(pos); if (pObj->GetType() == KEP_SECTIONFAULT) { CFaultObj* FaultObj = (CFaultObj*)pObj; FaultObj->FaultReCut(); } } //计算剖面范围 pSection->ReSetPosition(); //刷新 CRect rect = GetDC()->GetScreen(pSection->GetRect()); //GetDoc()->Invalidate(rect); } void CItemSectionWell::OnLButtonUp(CDC *pDC, UINT nFlags, CPoint point, int vk) { if (m_bAddWell) { m_firstPoint = m_lastPoint = point; m_bLDown = FALSE; m_bDrag = FALSE; nDragHandle = 0; ReleaseCapture(); CPoint2D ptDown = GetDC()->GetReal(m_downPoint); CPoint2D ptLast = GetDC()->GetReal(m_lastPoint); double yMin = min(ptDown.y0,ptLast.y0); double yMax = max(ptDown.y0,ptLast.y0); if (fabs(yMin-yMax)==0.0) return; CItemWellSection* pItemWellSection = (CItemWellSection*)GetItemSection(); if(NULL != pItemWellSection) pItemWellSection->SetReUnDoAction(); CWellSection* pWellSection = GetItemSection()->GetWellSection(); CSectionWellObj* pSectionWell; pSectionWell = new CSectionWellObj; pSectionWell->m_fX = 0.0; pSectionWell->m_fY = 0.0; pSectionWell->m_fLevel = 0.0; pSectionWell->GetPos().left = ptDown.x0-20; pSectionWell->GetPos().right = ptDown.x0+20; pSectionWell->GetPos().bottom = min(ptDown.y0, ptLast.y0); pSectionWell->GetPos().top = max(ptDown.y0, ptLast.y0); pSectionWell->m_fProportion = pWellSection->m_fDepthScale; pSectionWell->SetParent(pWellSection); pWellSection->m_WellList.AddTail(pSectionWell); //临时井对象数组 CArray wellArr; POSITION pos = pWellSection->m_WellList.GetHeadPosition(); while (pos!=NULL) { CWellBaseObj* pWell = (CWellBaseObj*)pWellSection->m_WellList.GetNext(pos); wellArr.Add(pWell); } for (int i = 0; i < wellArr.GetCount() - 1; i++) { for (int j = i + 1; j < wellArr.GetCount(); j++) { if (wellArr[i]->GetPos().left > wellArr[j]->GetPos().left) { CWellBaseObj *pObj = wellArr[i]; wellArr[i] = wellArr[j]; wellArr[j] = pObj; } } } pWellSection->m_WellList.RemoveAll(); for (int ii=0;iim_WellList.AddTail(wellArr[ii]); } //清空数组 wellArr.RemoveAll(); CWellPole* pWell = NULL; pos = pWellSection->m_WellList.Find(pSectionWell); if (pWellSection->m_WellList.GetPrev(pos) != NULL) { pWell = (CWellPole*)pWellSection->m_WellList.GetPrev(pos); } if (NULL == pWell) { pos = pWellSection->m_WellList.Find(pSectionWell); if (pWellSection->m_WellList.GetNext(pos) != NULL) { pWell = (CWellPole*)pWellSection->m_WellList.GetNext(pos); } } if (NULL != pWell) { pWell->SetActionTemplate(TRUE); pWell->SetNoSaveCallouts(TRUE); CMemFile fw; AfxGetPublicFunction()->InitSaveCounter(); //AfxGetPublicFunction()->__CurrentSaveFilePath="";//filepathstr; AfxGetPublicFunction()->SetCodeType(CODE_GB2321); WriteDML_Head_Version(fw); WriteDML_Head_Xmlns(fw); pWell->WriteDML(fw, -1, 1); AfxGetPublicFunction()->WriteDML_Tail(fw,0); //AfxGetPublicFunction()->SetCodeType((DWORD)::GetPreferences().WorkaroundSave.m_nCodeMode); AfxGetPublicFunction()->InitSaveCounter(); //fw.Close(); pWell->SetActionTemplate(FALSE); pWell->SetNoSaveCallouts(FALSE); //选中 pItemWellSection->Select(pSectionWell); pItemWellSection->ApplingTemplateFile(fw,FALSE); pSectionWell->GetPos().left = ptDown.x0 - pWell->GetPos().Width()*0.5; pSectionWell->GetPos().right = ptDown.x0 + pWell->GetPos().Width()*0.5; pSectionWell->GetPos().top = yMax + pSectionWell->m_dHeightTrackHead + pSectionWell->m_dHeightWellHead; pSectionWell->GetPos().bottom = yMin; pSectionWell->m_dSdep = pWell->m_dSdep-pWell->m_fLevel - pWell->ScreenCYToHeight(yMax-(pWell->GetPos().top-pWell->m_dHeightWellHead-pWell->m_dHeightTrackHead)); pSectionWell->m_dEdep = pWell->m_dSdep-pWell->m_fLevel - pWell->ScreenCYToHeight(yMin-(pWell->GetPos().top-pWell->m_dHeightWellHead-pWell->m_dHeightTrackHead)); pSectionWell->AddWellInterval(pSectionWell->m_dSdep, pSectionWell->m_dEdep, 0); pSectionWell->CalculateSize(pSectionWell->GetPos().TopLeft()); } //取前后井 CWellPole* pWellNext = NULL; CWellPole* pWellPre = NULL; POSITION posFind = pWellSection->m_WellList.Find(pSectionWell); pWellSection->m_WellList.GetNext(posFind); if (posFind!=NULL) pWellNext = (CWellPole*)pWellSection->m_WellList.GetNext(posFind); posFind = pWellSection->m_WellList.Find(pSectionWell); pWellSection->m_WellList.GetPrev(posFind); if (posFind!=NULL) pWellPre = (CWellPole*)pWellSection->m_WellList.GetPrev(posFind); if (pWellNext != NULL && pWellPre != NULL) { POSITION pos = pWellSection->m_BendList.GetHeadPosition(); while (pos!=NULL) { CBendObj* pBend = (CBendObj*)pWellSection->m_BendList.GetNext(pos); BOOL bOne = pBend->m_pWellLeft == pWellPre && pBend->m_pWellRight == pWellNext; BOOL bTwo = pBend->m_pWellLeft == pWellNext && pBend->m_pWellRight == pWellPre; if (bOne || bTwo) { POSITION posF = pWellSection->m_BendList.Find(pBend); pWellSection->m_BendList.RemoveAt(posF); pWellSection->DeleteBend(pBend); } } } pWellSection->ReSetPosition(); //GetView()->SetScrollBarRange(); GetDoc()->Invalidate(); } else { CWellBaseObj* pObjSelected = NULL; if(this->m_WellObjSelectlist.GetCount() == 1) pObjSelected = m_WellObjSelectlist.GetHead(); if(m_pItemSelected!=NULL && pObjSelected!=NULL && m_bEditTrackInData) { m_bEditTrackInData = FALSE; m_pItemSelected->OnLButtonUp(pDC, nFlags, point ,vk); CPoint2D ptDown = GetDC()->GetReal(m_downPoint); CPoint2D ptLast = GetDC()->GetReal(m_lastPoint); double yMin = min(ptDown.y0,ptLast.y0); double yMax = max(ptDown.y0,ptLast.y0); if (fabs(yMin-yMax) > ZERO) { //CXTPPropertyGrid &grid = GetPropertyGrid(GetDoc()->GetMainFrame()); //if(pObjSelected->GetElementType()==GDOUBLEFOX_RESULT|| // pObjSelected->GetElementType()==GDOUBLEFOX_LAYERGROUP|| // pObjSelected->GetElementType()==GDOUBLEFOX_STANDARD) { if(m_pItemSelected != NULL) delete m_pItemSelected; CItemWcsTrackIn *pTrackIn = new CItemWcsTrackIn(GetDoc()); m_pItemSelected = pTrackIn; pTrackIn->SetDrawObj(pObjSelected); POSITION pos = m_WellObjSelectlist.GetHeadPosition(); while(pos) { pTrackIn->m_WellObjSelectlist.AddTail(m_WellObjSelectlist.GetNext(pos)); } pTrackIn->SetPos(GetPos()); // pTrackIn->InitPropertyGrid(grid); } } return; } m_firstPoint = m_lastPoint = point; CWellPole *pWellObj = GetWellObject(); CWellSection* pSection = (CWellSection*)pWellObj->GetParent(); if(pSection == NULL) { CItemWcsSingleWell::OnLButtonUp(pDC,nFlags,point,vk); return; } if((m_downPoint.x-m_lastPoint.x)!=0 || (m_downPoint.y-m_lastPoint.y)!=0) { if (pObjSelected == NULL) { if (IsCaptureState()) //拖动井 { if (pSection->m_bResForm) { MoveWell_ResForm(pDC,nFlags, point, pWellObj); GetDoc()->Invalidate(); } else { MoveWell_oldDF(pDC,nFlags, point, pWellObj); } } } else { CWellBaseObj* pObj = (CWellBaseObj* )pObjSelected; if (IsCaptureState()) { CRect8 rect = pObj->GetRect(); CItemWcsSingleWell::OnLButtonUp(pDC,nFlags, point ,vk); if(pObj->GetType()== KEP_RESULT || pObj->GetType()== KEP_LAYERGROUP) { CInTrackDepthSegment* pLayer = (CInTrackDepthSegment*)pObj; if (pSection->m_bResForm) {//251124 WELLOBJLIST::iterator it = pLayer->m_BendLeftList.begin(); for (; it != pLayer->m_BendLeftList.end(); it++) { CBendObj* pBend = (CBendObj*)*it; pBend->ComputeBend(); } it = pLayer->m_BendRightList.begin(); for (; it != pLayer->m_BendRightList.end(); it++) { CBendObj* pBend = (CBendObj*)*it; pBend->ComputeBend(); } POSITION pos = pSection->m_BendList.GetHeadPosition(); while (pos != NULL) { CBendObj* pBend = (CBendObj*)pSection->m_BendList.GetNext(pos); if (pBend->m_pLayerLeft == pObj && pBend->m_pLayerRight == NULL) { pBend->ComputeBend(); } } } else { ////////层左边连接的非尖灭连层的变化 pSection->ComputeBendControlsHeight(pLayer, TRUE); WELLOBJLIST::iterator it = pLayer->m_BendLeftList.begin(); for (; it != pLayer->m_BendLeftList.end(); it++) { CBendObj* pBend = (CBendObj*)*it; CInTrackDepthSegment* pLayerLeft = pBend->m_pLayerLeft; if (pBend->m_pLayerLeft->GetPos().left > pBend->m_pLayerRight->GetPos().left) pLayerLeft = pBend->m_pLayerRight; pSection->ComputeBendControlsHeight(pLayerLeft, FALSE); } ////////层右边连接的非尖灭连层的变化 pSection->ComputeBendControlsHeight(pLayer, FALSE); WELLOBJLIST::iterator itLeft = pLayer->m_BendRightList.begin(); for (; itLeft != pLayer->m_BendRightList.end(); itLeft++) { CBendObj* pBend = (CBendObj*)*itLeft; CInTrackDepthSegment* pLayerRight = pBend->m_pLayerRight; if (pBend->m_pLayerLeft->GetPos().left > pBend->m_pLayerRight->GetPos().left) pLayerRight = pBend->m_pLayerLeft; pSection->ComputeBendControlsHeight(pLayerRight, TRUE); } ////////层连接的尖灭连层的变化 POSITION pos = pSection->m_BendList.GetHeadPosition(); while (pos != NULL) { CBendObj* pBend = (CBendObj*)pSection->m_BendList.GetNext(pos); if (pBend->m_pLayerLeft == pObj && pBend->m_pLayerRight == NULL) { double a1, b1, a2, b2; double yRatio; double yLeftNew, yRightNew; if (rect.top != pObj->GetPos().top || rect.bottom != pObj->GetPos().bottom) { a1 = (pBend->m_ptEndBreak.y0 - rect.CenterPoint().y0) / (pBend->m_ptEndBreak.x0 - pBend->m_ptArrCurveTopOld.GetAt(0).x0); b1 = rect.CenterPoint().y0 - a1 * pBend->m_ptArrCurveTopOld.GetAt(0).x0; b2 = pObj->GetPos().CenterPoint().y0 - a1 * pBend->m_ptArrCurveTopOld.GetAt(0).x0; dfPoint dfpoint; for (int kk = 0; kk < pBend->m_ptArrCurveTopOld.GetCount(); kk++) { yRatio = (pBend->m_ptArrCurveTopOld.GetAt(kk).y0 - (a1 * pBend->m_ptArrCurveTopOld.GetAt(kk).x0 + b1)) / (rect.Height()); dfpoint.y0 = yRatio * pObj->GetPos().Height() + (a1 * pBend->m_ptArrCurveTopOld.GetAt(kk).x0 + b2); pBend->m_ptArrCurveTopOld.GetAt(kk).y0 = dfpoint.y0; } for (int kk = 0; kk < pBend->m_ptArrCurveBotOld.GetCount(); kk++) { yRatio = (pBend->m_ptArrCurveBotOld.GetAt(kk).y0 - (a1 * pBend->m_ptArrCurveBotOld.GetAt(kk).x0 + b1)) / (rect.Height()); dfpoint.y0 = yRatio * pObj->GetPos().Height() + (a1 * pBend->m_ptArrCurveBotOld.GetAt(kk).x0 + b2); pBend->m_ptArrCurveBotOld.GetAt(kk).y0 = dfpoint.y0; } yRatio = (pBend->m_ptEndBreak.y0 - (a1 * pBend->m_ptEndBreak.x0 + b1)) / (rect.Height()); dfpoint.y0 = yRatio * pObj->GetPos().Height() + (a1 * pBend->m_ptEndBreak.x0 + b2); pBend->m_ptEndBreak.y0 = dfpoint.y0; yRatio = (pBend->m_ptEndBreakInteract.y0 - (a1 * pBend->m_ptEndBreakInteract.x0 + b1)) / (rect.Height()); dfpoint.y0 = yRatio * pObj->GetPos().Height() + (a1 * pBend->m_ptEndBreakInteract.x0 + b2); pBend->m_ptEndBreakInteract.y0 = dfpoint.y0; } yLeftNew = pBend->m_ptArrCurveTopOld.GetAt(0).y0 - (pBend->m_ptArrCurveTopOld.GetAt(0).y0 - pBend->m_ptArrCurveBotOld.GetAt(0).y0) / 2; yRightNew = pBend->m_ptArrCurveTopOld.GetAt(pBend->m_ptArrCurveTopOld.GetCount() - 1).y0 - (pBend->m_ptArrCurveTopOld.GetAt(pBend->m_ptArrCurveTopOld.GetCount() - 1).y0 - pBend->m_ptArrCurveBotOld.GetAt(pBend->m_ptArrCurveBotOld.GetCount() - 1).y0) / 2; a2 = (yRightNew - yLeftNew) / (pBend->m_ptArrCurveTopOld.GetAt(pBend->m_ptArrCurveTopOld.GetCount() - 1).x0 - pBend->m_ptArrCurveTopOld.GetAt(0).x0); b2 = yLeftNew - a2 * pBend->m_ptArrCurveTopOld.GetAt(0).x0; for (int kk = 0; kk < pBend->m_ptArrControls.GetCount(); kk++) { pBend->m_ptArrControls[kk].Y = -(a2 * pBend->m_ptArrControls[kk].X + b2); } pBend->ComputeSlopeAndConstant(); pBend->CreateBendLines(); pBend->CreateBendFills(); } } } Invalidate(); } else { if(selectMode==CItemSelect::move || selectMode==CItemSelect::size) { if (pObj->GetType()==KEP_TRACK) { DWORD stick = GetTickCount(); pSection->ReComputeBends(pWellObj); if (pSection->m_bResForm == FALSE) { //断层重新切割层位 POSITION pos = pSection->m_FaultList.GetHeadPosition(); while (pos != NULL) { CWellBaseObj* pObj = pSection->m_FaultList.GetNext(pos); if (pObj->GetType() == KEP_SECTIONFAULT) { CFaultObj* FaultObj = (CFaultObj*)pObj; FaultObj->FaultReCut(); } } } DWORD etick = GetTickCount(); TRACE("Drag Track Size time=%d ---------------\r\n", (etick - stick)/100); CRect rect = GetDC()->GetScreen(pSection->GetRect()); GetDoc()->Invalidate(); } } } } // End dragging image if(m_pDragImage != NULL) { CWnd* pWnd = CWnd::FromHandle(GetView()->GetHWND()); m_pDragImage->DragLeave(pWnd); m_pDragImage->EndDrag(); delete m_pDragImage; m_pDragImage=NULL; } } } else { CItemWcsSingleWell::OnLButtonUp(pDC,nFlags, point,vk); } ReleaseCapture(); m_bDrag = FALSE; m_bLDown = FALSE; nDragHandle = 0; } } BOOL CItemSectionWell::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) { if(m_bAddWell) { ::SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR_RANGE)); return TRUE; } else return CItemWcsSingleWell::OnSetCursor(pWnd, nHitTest, message); //GetDoc()->GetCursor().SetCursor(CursorSelect); //return GetDoc()->GetCursor().SetCursor(); } void CItemSectionWell::ReSetWell(CWellPole* pWell) { CPoint2D pt = pWell->GetAnchorPoint(); pWell->CalculateSize(pt/*pWell->GetPos().TopLeft()*/); pWell->ReadCurveData(); pWell->ResetChildPosition(); CWellBaseObj *pObj = (CWellBaseObj*)pWell->GetParent(); if(pObj != NULL && pObj->GetType() == KEP_WELLSECTION) { //删除相关连层 CWellSection *pWellSection = (CWellSection*)pObj; POSITION posBend = pWellSection->m_BendList.GetHeadPosition(); while (posBend!=NULL) { CBendObj* pBend = (CBendObj*)pWellSection->m_BendList.GetNext(posBend); if (!pBend->m_pLayerLeft->IsView()||(pBend->m_pLayerRight!=NULL&&!pBend->m_pLayerRight->IsView())) { POSITION posFind = pWellSection->m_BendList.Find(pBend); if (posFind!=NULL) { pWellSection->DeleteBend(pBend); } } } pWellSection->ReSetPosition(); } //重设滚动条 SetScrollBarRange(); } int CItemSectionWell::GetSubMenu() { int iRMenu = CItemWcsSingleWell::GetSubMenu(); if (iRMenu == 42) iRMenu = 46; //将WellPole菜单更换为 SectionWell菜单 return iRMenu; } //bool CItemSectionWell::AddTrack() //{ // //if(NULL != m_pItemWellSection) // // m_pItemWellSection->SetReUnDoAction(); // return CItemWcsSingleWell::AddTrack(); //} int CItemSectionWell::DeleteSelection(void) { if(GetDrawObj() == NULL) return 0; if (m_pItemSelected!=NULL) { if (m_WellObjSelectlist.GetCount()>1) { delete m_pItemSelected; CItemWcsTrackIn *pItemTrackIn = new CItemWcsTrackIn(GetDoc()); m_pItemSelected = pItemTrackIn; POSITION pos = m_WellObjSelectlist.GetHeadPosition(); while(pos!=NULL) { CWellBaseObj* pObj = m_WellObjSelectlist.GetNext(pos); pItemTrackIn->SetDrawObj(pObj); CWellSection* pSection = (CWellSection*)m_pWell->GetParent(); pItemTrackIn->DeleteSelection(); } } else ((CItemWellBase*)m_pItemSelected)->DeleteSelection(); } else { m_pItemWellSection->RemoveWell(m_pWell); } m_pItemSelected = NULL; m_WellObjSelectlist.RemoveAll(); return 1; } BOOL CItemSectionWell::IsAddWell() { return m_bAddWell; } CWellPole *CItemSectionWell::GetWellObject() { return m_pWell; } }