#include "StdAfx.h" #include "WellPoleLib/WellBaseObj.h" #include "WellPoleLib/WellClassObjGroup.h" #include "WellPoleLib/InTrackDepthSegment.h" #include "WellPoleLib/TrackObj.h" #include "WellPoleLib/InclinedTrack.h" #include "WellPoleLib\InTrackResult.h" #include "WellPoleLib\InTrackLayerGroup.h" #include "WellPoleLib/WellPole.h" #include "MultiWellSectionLib/BendObj.h" #include "MultiWellSectionLib/FenceBendObj.h" #include "MultiWellSectionLib/FaultObj.h" #include "MultiWellSectionLib/SectionWellObj.h" #include "MultiWellSectionLib/WellSection.h" #include "MultiWellSectionLib/WellFence.h" #include "ItemWcsTrackIn.h" #include "ItemAddBend.h" #include "MultiWellSectionDoc.h" #include "MultiWellSectionlView.h" namespace NItem { CItemAddBend::CItemAddBend(CSigmaDoc *pDoc) : CItemWellBase(pDoc) { SetType(ITEM_ADDBEND); m_pItemTrackIn = NULL; m_pItemWell = NULL; } CItemAddBend::~CItemAddBend(void) { if(m_pItemTrackIn != NULL) { delete m_pItemTrackIn; m_pItemTrackIn = NULL; } } void CItemAddBend::OnDraw(CXyDC* pXyDC, CDC* pDC) { //CDC *pDC = GetDC()->GetDC(); CPen pen(PS_DOT, 0, RGB(0, 0, 0)); CPen *pOldPen = (CPen *)pDC->SelectObject(&pen); int old = pDC->SetROP2(R2_NOTXORPEN); if (m_bLDown) { pDC->MoveTo(m_firstPoint); pDC->LineTo(m_lastPoint); } pDC->SelectObject(pOldPen); pen.DeleteObject(); pDC->SetROP2(old); } void CItemAddBend::OnLButtonDown(CDC *pDC, UINT nFlags, CPoint point, int vk) { m_bLDown = TRUE; CPoint2D ptReal = GetDC()->GetReal(point); m_downPoint = m_firstPoint = m_lastPoint = point; OnDraw(GetDC(),pDC); } void CItemAddBend::MakeBendForOld(CWellSection* pSection, CWellPole * pWell ,UINT nFlags, CPoint point) { m_lastPoint = point; 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) { ReleaseCapture(); m_bLDown = FALSE; return; } SetReUnDoAction(); int nHandleSize = HANDLESIZE; CWellPole* pLeftWell = NULL; CWellPole* pRightWell = NULL; if (pSection->GetType() == KEP_FENCE) { if (m_pObj->GetType() == KEP_RESULT || m_pObj->GetType() == KEP_LAYERGROUP) { CWellFence* pFence = (CWellFence*)pSection; POSITION pos = pFence->m_WellList.GetHeadPosition(); while (pos != NULL) { CSectionWellObj* pSectionWell = (CSectionWellObj*)pFence->m_WellList.GetNext(pos); if (pSectionWell->GetPos().PtInRect(ptLast) && pSectionWell != pWell) { pRightWell = pSectionWell; break; } } if (pRightWell != NULL) { TRACKLIST tracklist; pRightWell->GetAllTrack(&tracklist); TRACKLIST::iterator pos = tracklist.begin(); for (; pos != tracklist.end(); pos++) { CTrackObj* pTrack = (CTrackObj*)*pos; if ((m_pObj->GetType() == KEP_RESULT && pTrack->GetTrackType() == Track_Result) || (m_pObj->GetType() == KEP_LAYERGROUP && pTrack->GetTrackType() == Track_Stratum)) { double xLeftValue, xRightValue; CFenceBendObj *pBend = new CFenceBendObj(); pBend->SetParent(pSection); pBend->m_pLayerLeft = m_pObj; pBend->m_ptBeginBreak.x0 = ptDown.x0; pBend->m_ptEndBreak.x0 = ptLast.x0; pBend->m_pWellLeft = pWell; pBend->m_pWellRight = pRightWell; //pBend->GetBendXValue(xLeftValue,xRightValue); xLeftValue = pWell->GetPos().right; xRightValue = pRightWell->GetPos().left; if (pWell->GetPos().CenterPoint().x0 > pRightWell->GetPos().CenterPoint().x0) { xLeftValue = pWell->GetPos().left; xRightValue = pRightWell->GetPos().right; } pBend->m_fEndBreakPos = (xRightValue - xLeftValue) / (xRightValue - xLeftValue); pBend->m_fEndBreakDepth = (ptLast.y0 - (pRightWell->GetPos().top - pRightWell->m_dHeightWellHead - pRightWell->m_dHeightTrackHead)) / (pRightWell->GetPos().Height() - pRightWell->m_dHeightWellHead - pRightWell->m_dHeightTrackHead); pBend->m_EndBreakXRatio = pBend->m_fEndBreakPos; pBend->m_EndYRatio = pBend->m_fEndBreakDepth; pBend->m_fBeginBreakPos = 0.5; pBend->m_fOutBendControlLevel = 0.0; BOOL bExist = FALSE; WELLOBJLIST::iterator posLayer = pTrack->GetChildren().begin(); // pTrack->GetChildObjList().GetHeadPosition(); for (; posLayer != pTrack->GetChildren().end(); posLayer++) { CWellBaseObj* pLayer = (CWellBaseObj*)*posLayer; // pTrack->GetChildObjList().GetNext(posLayer); CRect rect = GetDC()->GetScreen(pLayer->GetPos()); rect.NormalizeRect(); if (rect.PtInRect(m_lastPoint)) { bExist = TRUE; POSITION pos = pSection->m_BendList.GetHeadPosition(); while (pos != NULL) { CBendObj* p = (CBendObj*)pSection->m_BendList.GetNext(pos); if (p->m_pLayerLeft == m_pObj && p->m_pLayerRight == NULL && p->m_pWellRight == pRightWell) { if (pBend != NULL) { delete pBend; } GetDoc()->Invalidate(); ReleaseCapture(); m_bLDown = FALSE; return; } else if ((p->m_pLayerLeft == m_pObj && p->m_pLayerRight == pLayer) || (p->m_pLayerLeft == pLayer && p->m_pLayerRight == m_pObj)) { if (pBend != NULL) { delete pBend; } GetDoc()->Invalidate(); ReleaseCapture(); m_bLDown = FALSE; return; } } pBend->m_pLayerRight = (CInTrackDepthSegment*)pLayer; pBend->m_nLithoBreakStyle = 2; pBend->m_fLithoBreakWidth = 0.1; pBend->m_fTopLithoBreakPoint = 0.5; pBend->m_fBottomLithoBreakPoint = 0.5; if (m_pObj->GetType() == KEP_RESULT) { CInTrackResult* pLayerLeft = (CInTrackResult*)pBend->m_pLayerLeft; CInTrackResult* pLayerRight = (CInTrackResult*)pBend->m_pLayerRight; if ((pLayerLeft->m_strResult != pLayerRight->m_strResult) && !(pLayerLeft->m_strResult == "干层" || pLayerRight->m_strResult == "干层")) { pBend->m_fWaterTop = pBend->m_fGasBottom = pLayerLeft->GetPos().CenterPoint().y0 - (pLayerLeft->GetPos().CenterPoint().y0 - pLayerRight->GetPos().CenterPoint().y0) / 2; } } //重新计算控制点 double yLeftValue = pBend->m_pLayerLeft->GetPos().CenterPoint().y0; double yRightValue = pBend->m_pLayerRight->GetPos().CenterPoint().y0; pBend->AddControlPoints(xLeftValue, yLeftValue, xRightValue, yRightValue, xRightValue - xLeftValue); pBend->CreateBendLines(); CString strLithoLeft; CString strLithoRight; if (m_pObj->GetType() == KEP_RESULT) { CInTrackResult* pLayerLeft = (CInTrackResult*)pBend->m_pLayerLeft; strLithoLeft = pLayerLeft->m_strLitho; if (NULL != pBend->m_pLayerRight) { CInTrackResult* pLayerRight = (CInTrackResult*)pBend->m_pLayerRight; strLithoRight = pLayerRight->m_strLitho; } } else if (m_pObj->GetType() == KEP_LAYERGROUP) { CInTrackLayerGroup* pLayerLeft = (CInTrackLayerGroup*)pBend->m_pLayerLeft; strLithoLeft = pLayerLeft->m_strLitho; if (NULL != pBend->m_pLayerRight) { CInTrackLayerGroup* pLayerRight = (CInTrackLayerGroup*)pBend->m_pLayerRight; strLithoRight = pLayerRight->m_strLitho; } } if (/*!strLithoLeft.IsEmpty() && !strLithoRight.IsEmpty() && */strLithoLeft != strLithoRight) { pBend->bBreakLithoTemp = TRUE; pBend->CreateBendLithoBreak(); } pBend->CreateBendFills(); pBend->SetShowFill(TRUE); pBend->SetShowTopLine(TRUE); pBend->SetShowBotLine(TRUE); ////添加Bend的断层链表 //pBend->BendReCut(); //if (pTrack->GetTrackType()==Track_Result) //{ // pBend->SetBendLinkType(Bend_Layer); //} //else if (pTrack->GetTrackType()==Track_Text) //{ // pBend->SetBendLinkType(Bend_Text); //} pFence->m_BendList.AddTail(pBend); break; } } if (!bExist)//浮动连接层 { pBend->m_pLayerRight = NULL; pBend->m_pWellRight = pRightWell; pBend->m_ptEndBreak.x0 = xRightValue; pBend->m_ptEndBreak.y0 = ptLast.y0; pBend->m_ptBeginBreak.x0 = xLeftValue; pBend->m_ptBeginBreak.y0 = pBend->m_pLayerLeft->GetPos().CenterPoint().y0; //重新计算控制点 pBend->AddControlPoints(xLeftValue, m_pObj->GetPos().CenterPoint().y0, ptLast.x0, ptLast.y0, xRightValue - xLeftValue); pBend->CreateBendLines(); CString strLithoLeft; CString strLithoRight; if (m_pObj->GetType() == KEP_RESULT) { CInTrackResult* pLayerLeft = (CInTrackResult*)pBend->m_pLayerLeft; strLithoLeft = pLayerLeft->m_strLitho; if (NULL != pBend->m_pLayerRight) { CInTrackResult* pLayerRight = (CInTrackResult*)pBend->m_pLayerRight; strLithoRight = pLayerRight->m_strLitho; } } else if (m_pObj->GetType() == KEP_LAYERGROUP) { CInTrackLayerGroup* pLayerLeft = (CInTrackLayerGroup*)pBend->m_pLayerLeft; strLithoLeft = pLayerLeft->m_strLitho; if (NULL != pBend->m_pLayerRight) { CInTrackLayerGroup* pLayerRight = (CInTrackLayerGroup*)pBend->m_pLayerRight; strLithoRight = pLayerRight->m_strLitho; } } if (/*!strLithoLeft.IsEmpty() && !strLithoRight.IsEmpty() && */strLithoLeft != strLithoRight) { pBend->bBreakLithoTemp = TRUE; pBend->CreateBendLithoBreak(); } pBend->CreateBendFills(); pBend->SetShowFill(TRUE); pBend->SetShowTopLine(TRUE); pBend->SetShowBotLine(TRUE); //添加Bend的断层链表 //pBend->BendReCut(); //if (pTrack->GetTrackType()==Track_Result) //{ // pBend->SetBendLinkType(Bend_Layer); //} //else if (pTrack->GetTrackType()==Track_Text) //{ // pBend->SetBendLinkType(Bend_Text); //} pFence->m_BendList.AddTail(pBend); } break; } } tracklist.clear(); } } } else if (pSection->GetType() == KEP_WELLSECTION) { POSITION posFind = pSection->m_WellList.Find(pWell); pSection->m_WellList.GetNext(posFind); if (posFind != NULL) { pRightWell = (CWellPole*)pSection->m_WellList.GetNext(posFind); } if (ptLast.x0 > ptDown.x0&&pRightWell != NULL) { if (m_pObj->GetType() == KEP_RESULT || m_pObj->GetType() == KEP_LAYERGROUP || m_pObj->GetType() == KEP_STANDARD) { double xLeftValue, xRightValue; CBendObj *pBend = new CBendObj(); pBend->SetParent(pSection); pBend->m_pLayerLeft = m_pObj; /////////////////////////////////// pBend->m_ptBeginBreak.x0 = ptDown.x0; pBend->m_ptEndBreak.x0 = ptLast.x0; //////////////////////////////////// pBend->m_pWellLeft = pWell; pBend->m_pWellRight = pRightWell; //pBend->strLeftWellName = pWell->GetWellName(); //pBend->strRightWellName = pRightWell->GetWellName(); pBend->GetBendXValue(xLeftValue, xRightValue); pBend->m_fEndBreakPos = (ptLast.x0 - xLeftValue) / (xRightValue - xLeftValue) * 100; pBend->m_fBeginBreakPos = 0.5; pBend->m_fOutBendControlLevel = 0.0; if (ptLast.x0 > xLeftValue&&ptLast.x0 < xRightValue) { pBend->m_pLayerRight = NULL; ///////////////////////////////////// pBend->m_ptBeginBreak.x0 = xLeftValue; pBend->m_ptBeginBreak.y0 = m_pObj->GetPos().CenterPoint().y0; pBend->m_ptEndBreak.x0 = ptLast.x0; pBend->m_ptEndBreak.y0 = ptLast.y0; //////////////////////////////////// POSITION pos = pSection->m_BendList.GetHeadPosition(); while (pos != NULL) { CBendObj* p = (CBendObj*)pSection->m_BendList.GetNext(pos); if (p->m_pLayerLeft == m_pObj && p->m_pLayerRight == NULL && (p->m_ptEndBreak.x0 > xLeftValue&&p->m_ptEndBreak.x0 < xRightValue)) { pSection->DeleteBend(p); delete p; break; } else if (p->m_pLayerRight != NULL && (p->m_pLayerLeft == m_pObj || p->m_pLayerRight == m_pObj) && (p->m_pWellLeft == pBend->m_pWellLeft&&p->m_pWellRight == pBend->m_pWellRight || p->m_pWellLeft == pBend->m_pWellRight&&p->m_pWellRight == pBend->m_pWellLeft)) { if (pBend != NULL) { delete pBend; GetDoc()->Invalidate(); ReleaseCapture(); m_bLDown = FALSE; return; } } } pBend->AddControlPoints(xLeftValue, m_pObj->GetPos().CenterPoint().y0, pBend->m_ptEndBreak.x0, ptLast.y0, xRightValue - xLeftValue); ////////////////////////////////////////////////////////////////////////////// dfPoint TempPoint; TempPoint.x0 = xLeftValue; TempPoint.y0 = m_pObj->GetPos().top; pBend->m_ptArrCurveTopOld.Add(TempPoint); TempPoint.y0 = m_pObj->GetPos().bottom; pBend->m_ptArrCurveBotOld.Add(TempPoint); TempPoint.x0 = ptLast.x0; TempPoint.y0 = ptLast.y0; pBend->m_ptArrCurveTopOld.Add(TempPoint); pBend->m_ptArrCurveBotOld.Add(TempPoint); //添加Bend的断层链表 pBend->BendAddFault(); pBend->ComputeSlopeAndConstant(); if (m_pObj->GetType() == KEP_STANDARD) { pBend->SetSlotTypeStandardLayer(TRUE); } pBend->CreateBendLines(); CString strLithoLeft; CString strLithoRight; CString strResultLeft; CString strResultRight; if (m_pObj->GetType() == KEP_RESULT) { CInTrackResult* pLayerLeft = (CInTrackResult*)pBend->m_pLayerLeft; strLithoLeft = pLayerLeft->m_strLitho; strResultLeft = pLayerLeft->m_strResult; if (NULL != pBend->m_pLayerRight) { CInTrackResult* pLayerRight = (CInTrackResult*)pBend->m_pLayerRight; strLithoRight = pLayerRight->m_strLitho; strResultRight = pLayerRight->m_strResult; } } else if (m_pObj->GetType() == KEP_LAYERGROUP) { CInTrackLayerGroup* pLayerLeft = (CInTrackLayerGroup*)pBend->m_pLayerLeft; strLithoLeft = pLayerLeft->m_strLitho; if (NULL != pBend->m_pLayerRight) { CInTrackLayerGroup* pLayerRight = (CInTrackLayerGroup*)pBend->m_pLayerRight; strLithoRight = pLayerRight->m_strLitho; } } else if (m_pObj->GetType() == KEP_STANDARD) { } if ((/*!strLithoLeft.IsEmpty() && !strLithoRight.IsEmpty() && */strLithoLeft != strLithoRight) || (/*!strResultLeft.IsEmpty() && !strResultRight.IsEmpty() && */strResultLeft != strResultRight)) { pBend->bBreakLithoTemp = TRUE; pBend->CreateBendLithoBreak(); } pBend->CreateBendFills(); pBend->SetShowFill(TRUE); pBend->SetShowTopLine(TRUE); pBend->SetShowBotLine(TRUE); if (m_pObj->GetType() == KEP_RESULT) { pBend->SetSlotTypeResult(TRUE); } else if (m_pObj->GetType() == KEP_LAYERGROUP) { pBend->SetSlotTypeStratiUnit(TRUE); } //else if (m_pObj->GetType() == KEP_STANDARD) //{ // pBend->SetSlotTypeStandardLayer(TRUE); //} pSection->m_BendList.AddTail(pBend); if (pSection->IsStratumSmooth()) { pBend->SmoothBendLines(); } //break; } else if (ptLast.x0 > xRightValue) { TRACKLIST tracklist; pRightWell->GetAllTrack(&tracklist); TRACKLIST::iterator pos = tracklist.begin(); // GetHeadPosition(); for (; pos != tracklist.end(); pos++) { CTrackObj* pTrack = (CTrackObj*)*pos; // tracklist.GetNext(pos); if ((m_pObj->GetType() == KEP_RESULT && pTrack->GetTrackType() == Track_Result) || (m_pObj->GetType() == KEP_LAYERGROUP && pTrack->GetTrackType() == Track_Stratum) || (m_pObj->GetType() == KEP_STANDARD && pTrack->GetTrackType() == Track_StandardLayer)) { WELLOBJLIST::iterator posLayer = pTrack->GetChildren().begin(); // pTrack->GetChildObjList().GetHeadPosition(); for (; posLayer != pTrack->GetChildren().end(); posLayer++) { CWellBaseObj* pLayer = (CWellBaseObj*)*posLayer; // pTrack->GetChildObjList().GetNext(posLayer); CRect rect = GetDC()->GetScreen(pLayer->GetPos()); rect.NormalizeRect(); /////////标准层道时放大矩形的高度 if (m_pObj->GetType() == KEP_STANDARD) { rect.InflateRect(0, nHandleSize / 2); } if (rect.PtInRect(m_lastPoint)) { BOOL bThis = FALSE; BOOL bThat = FALSE; POSITION pos = pSection->m_BendList.GetHeadPosition(); while (pos != NULL) { CBendObj* p = (CBendObj*)pSection->m_BendList.GetNext(pos); if (p->m_pLayerLeft == m_pObj && p->m_pLayerRight == NULL && (p->m_ptEndBreak.x0 > xLeftValue&&p->m_ptEndBreak.x0 < xRightValue)) { pSection->DeleteBend(p); delete p; bThis = TRUE; } else if (p->m_pLayerLeft == pLayer && p->m_pLayerRight == NULL && (p->m_ptEndBreak.x0 > xLeftValue&&p->m_ptEndBreak.x0 < xRightValue)) { POSITION posBend = pSection->m_BendList.Find(p); pSection->DeleteBend(p); delete p; bThat = TRUE; } else if ((p->m_pLayerLeft == m_pObj && p->m_pLayerRight == pLayer) || (p->m_pLayerLeft == pLayer && p->m_pLayerRight == m_pObj)) { POSITION posBend = pSection->m_BendList.Find(p); if (posBend != NULL) { pSection->DeleteBend(p); } delete p; if (pBend != NULL) { delete pBend; } GetDoc()->Invalidate(); ReleaseCapture(); m_bLDown = FALSE; return; } if (bThis && bThat) break; } pBend->m_pLayerRight = (CInTrackDepthSegment*)pLayer; pBend->m_nLithoBreakStyle = 2; pBend->m_fLithoBreakWidth = 0.1; pBend->m_fTopLithoBreakPoint = 0.5; pBend->m_fBottomLithoBreakPoint = 0.5; ///// 若添加的连层与相关两口井之间已经存在的连层出现交叉情况则取消连层的创建 POSITION posTemp = pSection->m_BendList.GetHeadPosition(); while (posTemp != NULL) { CWellBaseObj* pObj = pSection->m_BendList.GetNext(posTemp); if (pObj->GetType() == KEP_SECTIONBEND) { CBendObj* pBendObj = (CBendObj*)pObj; double topLeft, topRight; if (pBendObj->m_pLayerRight != NULL) { CWellPole* pWellLeft = (CWellPole*)pBendObj->m_pLayerLeft->GetWell(); CWellPole* pWellRight = (CWellPole*)pBendObj->m_pLayerRight->GetWell(); if ((pWellLeft == pWell && pWellRight == pRightWell) || (pWellLeft == pRightWell && pWellRight == pWell)) { if (pBendObj->m_pLayerRight->GetPos().left > pBendObj->m_pLayerLeft->GetPos().left) { topLeft = pBendObj->m_pLayerLeft->GetPos().top; topRight = pBendObj->m_pLayerRight->GetPos().top; } else { topLeft = pBendObj->m_pLayerRight->GetPos().top; topRight = pBendObj->m_pLayerLeft->GetPos().top; } BOOL bOne = topLeft > pBend->m_pLayerLeft->GetPos().top&&topRight < pBend->m_pLayerRight->GetPos().top; BOOL bSecond = topLeft < pBend->m_pLayerLeft->GetPos().top&&topRight > pBend->m_pLayerRight->GetPos().top; if (bOne || bSecond) { pBend = NULL; delete pBend; AfxMessageBox("连层不能出现交叉情况!"); GetDoc()->Invalidate(); ReleaseCapture(); m_bLDown = FALSE; return; } } } } } ///// 若添加的连层与相关两口井之间已经存在的连层出现交叉情况则取消连层的创建 if (m_pObj->GetType() == KEP_RESULT) { CInTrackResult* pLayerLeft = (CInTrackResult*)pBend->m_pLayerLeft; CInTrackResult* pLayerRight = (CInTrackResult*)pBend->m_pLayerRight; if ((pLayerLeft->m_strResult != pLayerRight->m_strResult) && !(pLayerLeft->m_strResult == "干层" || pLayerRight->m_strResult == "干层")) { pBend->m_fWaterTop = pBend->m_fGasBottom = pLayerLeft->GetPos().CenterPoint().y0 - (pLayerLeft->GetPos().CenterPoint().y0 - pLayerRight->GetPos().CenterPoint().y0) / 2; } } double valueLeft = m_pObj->GetPos().CenterPoint().y0; double valueRight = pLayer->GetPos().CenterPoint().y0; double HeightLeft = m_pObj->GetPos().Height(); double HeightRight = pLayer->GetPos().Height(); ReBendLeftRightList(pBend); if (m_pObj->GetType() == KEP_STANDARD) { pBend->SetSlotTypeStandardLayer(TRUE); } pSection->ComputeBendPosition(pBend, valueLeft, valueRight, HeightLeft, HeightRight); pBend->AddControlPoints(xLeftValue, valueLeft, xRightValue, valueRight, xRightValue - xLeftValue); ////////////////////////////////////////////////////////////////////////// dfPoint ptTemp; ptTemp.x0 = xLeftValue; ptTemp.y0 = valueLeft + HeightLeft * 0.5; pBend->m_ptArrCurveTopOld.Add(ptTemp); ptTemp.y0 = valueLeft - HeightLeft * 0.5; pBend->m_ptArrCurveBotOld.Add(ptTemp); ptTemp.x0 = xRightValue; ptTemp.y0 = valueRight + HeightRight * 0.5; pBend->m_ptArrCurveTopOld.Add(ptTemp); ptTemp.y0 = valueRight - HeightRight * 0.5; pBend->m_ptArrCurveBotOld.Add(ptTemp); //添加Bend的断层链表 pBend->BendAddFault(); pBend->ComputeSlopeAndConstant(); pBend->CreateBendLines(); CString strLithoLeft; CString strLithoRight; CString strResultLeft; CString strResultRight; if (m_pObj->GetType() == KEP_RESULT) { CInTrackResult* pLayerLeft = (CInTrackResult*)pBend->m_pLayerLeft; strLithoLeft = pLayerLeft->m_strLitho; strResultLeft = pLayerLeft->m_strResult; if (NULL != pBend->m_pLayerRight) { CInTrackResult* pLayerRight = (CInTrackResult*)pBend->m_pLayerRight; strLithoRight = pLayerRight->m_strLitho; strResultRight = pLayerRight->m_strResult; } } else if (m_pObj->GetType() == KEP_LAYERGROUP) { CInTrackLayerGroup* pLayerLeft = (CInTrackLayerGroup*)pBend->m_pLayerLeft; strLithoLeft = pLayerLeft->m_strLitho; if (NULL != pBend->m_pLayerRight) { CInTrackLayerGroup* pLayerRight = (CInTrackLayerGroup*)pBend->m_pLayerRight; strLithoRight = pLayerRight->m_strLitho; } } if ((/*!strLithoLeft.IsEmpty() && !strLithoRight.IsEmpty() &&*/ strLithoLeft != strLithoRight) || (/*!strResultLeft.IsEmpty() && !strResultRight.IsEmpty() && */strResultLeft != strResultRight)) { pBend->bBreakLithoTemp = TRUE; pBend->CreateBendLithoBreak(); } pBend->CreateBendFills(); pBend->SetShowFill(TRUE); pBend->SetShowTopLine(TRUE); pBend->SetShowBotLine(TRUE); if (pTrack->GetTrackType() == Track_Result) { pBend->SetSlotTypeResult(TRUE); } else if (pTrack->GetTrackType() == Track_Stratum) { pBend->SetSlotTypeStratiUnit(TRUE); } else if (pTrack->GetTrackType() == Track_StandardLayer) { pBend->SetSlotTypeStandardLayer(TRUE); } if (pSection->IsStratumSmooth()) { pBend->SmoothBendLines(); } pSection->m_BendList.AddTail(pBend); break; } } } } tracklist.clear(); } } } posFind = pSection->m_WellList.Find(pWell); pSection->m_WellList.GetPrev(posFind); if (posFind != NULL) { pLeftWell = (CWellPole*)pSection->m_WellList.GetPrev(posFind); } if (ptLast.x0 < ptDown.x0&&pLeftWell != NULL) { if (m_pObj->GetType() == KEP_RESULT || m_pObj->GetType() == KEP_LAYERGROUP || m_pObj->GetType() == KEP_STANDARD) { double xLeftValue, xRightValue; CBendObj *pBend = new CBendObj(); pBend->SetParent(pSection); pBend->m_pLayerLeft = m_pObj; pBend->m_ptBeginBreak.x0 = ptDown.x0; pBend->m_ptEndBreak.x0 = ptLast.x0; pBend->m_pWellLeft = pWell; pBend->m_pWellRight = pLeftWell; //pBend->strLeftWellName = pWell->GetWellName(); //pBend->strRightWellName = pLeftWell->GetWellName(); pBend->GetBendXValue(xLeftValue, xRightValue); pBend->m_fEndBreakPos = (ptLast.x0 - xLeftValue) / (xRightValue - xLeftValue) * 100; pBend->m_fBeginBreakPos = 0.5; pBend->m_fOutBendControlLevel = 0.0; if (ptLast.x0 > xRightValue&&ptLast.x0 < xLeftValue) { pBend->m_pLayerRight = NULL; ///////////////////////////////////// pBend->m_ptBeginBreak.x0 = xLeftValue; pBend->m_ptBeginBreak.y0 = m_pObj->GetPos().CenterPoint().y0; pBend->m_ptEndBreak.x0 = ptLast.x0; pBend->m_ptEndBreak.y0 = ptLast.y0; //////////////////////////////////// POSITION pos = pSection->m_BendList.GetHeadPosition(); while (pos != NULL) { CBendObj* p = (CBendObj*)pSection->m_BendList.GetNext(pos); if (p->m_pLayerLeft == m_pObj && p->m_pLayerRight == NULL && (p->m_ptEndBreak.x0m_ptEndBreak.x0>xRightValue)) { POSITION posBend = pSection->m_BendList.Find(p); pSection->DeleteBend(p); delete p; break; } else if (p->m_pLayerRight != NULL && (p->m_pLayerLeft == m_pObj || p->m_pLayerRight == m_pObj) && (p->m_pWellLeft == pBend->m_pWellLeft&&p->m_pWellRight == pBend->m_pWellRight || p->m_pWellLeft == pBend->m_pWellRight&&p->m_pWellRight == pBend->m_pWellLeft)) { if (pBend != NULL) { delete pBend; GetDoc()->Invalidate(); ReleaseCapture(); m_bLDown = FALSE; return; } } } pBend->AddControlPoints(xLeftValue, m_pObj->GetPos().CenterPoint().y0, pBend->m_ptEndBreak.x0, ptLast.y0, xRightValue - xLeftValue); //////////////////////////////////////////////////////////////////////////////// dfPoint ptTemp; ptTemp.x0 = xLeftValue; ptTemp.y0 = pBend->m_pLayerLeft->GetPos().top; pBend->m_ptArrCurveTopOld.Add(ptTemp); ptTemp.y0 = pBend->m_pLayerLeft->GetPos().bottom; pBend->m_ptArrCurveBotOld.Add(ptTemp); ptTemp.x0 = ptLast.x0; ptTemp.y0 = ptLast.y0; pBend->m_ptArrCurveTopOld.Add(ptTemp); pBend->m_ptArrCurveBotOld.Add(ptTemp); ////////////////////////////////////////////////////////////////////////////// //添加Bend的断层链表 pBend->BendAddFault(); pBend->ComputeSlopeAndConstant(); if (m_pObj->GetType() == KEP_STANDARD) { pBend->SetSlotTypeStandardLayer(TRUE); } pBend->CreateBendLines(); CString strLithoLeft; CString strLithoRight; CString strResultLeft; CString strResultRight; if (m_pObj->GetType() == KEP_RESULT) { CInTrackResult* pLayerLeft = (CInTrackResult*)pBend->m_pLayerLeft; strLithoLeft = pLayerLeft->m_strLitho; strResultLeft = pLayerLeft->m_strResult; if (NULL != pBend->m_pLayerRight) { CInTrackResult* pLayerRight = (CInTrackResult*)pBend->m_pLayerRight; strLithoRight = pLayerRight->m_strLitho; strResultRight = pLayerRight->m_strResult; } } else if (m_pObj->GetType() == KEP_LAYERGROUP) { CInTrackLayerGroup* pLayerLeft = (CInTrackLayerGroup*)pBend->m_pLayerLeft; strLithoLeft = pLayerLeft->m_strLitho; if (NULL != pBend->m_pLayerRight) { CInTrackLayerGroup* pLayerRight = (CInTrackLayerGroup*)pBend->m_pLayerRight; strLithoRight = pLayerRight->m_strLitho; } } else if (m_pObj->GetType() == KEP_STANDARD) { } if ((/*!strLithoLeft.IsEmpty() && !strLithoRight.IsEmpty() && */strLithoLeft != strLithoRight) || (/*!strResultLeft.IsEmpty() && !strResultRight.IsEmpty() && */strResultLeft != strResultRight)) { pBend->bBreakLithoTemp = TRUE; pBend->CreateBendLithoBreak(); } pBend->CreateBendFills(); pBend->SetShowFill(TRUE); pBend->SetShowTopLine(TRUE); pBend->SetShowBotLine(TRUE); if (m_pObj->GetType() == KEP_RESULT) { pBend->SetSlotTypeResult(TRUE); } else if (m_pObj->GetType() == KEP_LAYERGROUP) { pBend->SetSlotTypeStratiUnit(TRUE); } //else if (m_pObj->GetType()==KEP_STANDARD) //{ // pBend->SetSlotTypeStandardLayer(TRUE); //} if (pSection->IsStratumSmooth()) { pBend->SmoothBendLines(); } pSection->m_BendList.AddTail(pBend); //break; } else if (ptLast.x0 < xLeftValue) { TRACKLIST tracklist; pLeftWell->GetAllTrack(&tracklist); TRACKLIST::iterator pos = tracklist.begin(); for (; pos != tracklist.end(); pos++) { CTrackObj* pTrack = (CTrackObj*)*pos; if ((m_pObj->GetType() == KEP_RESULT && pTrack->GetTrackType() == Track_Result) || (m_pObj->GetType() == KEP_LAYERGROUP && pTrack->GetTrackType() == Track_Stratum) || (m_pObj->GetType() == KEP_STANDARD && pTrack->GetTrackType() == Track_StandardLayer)) { WELLOBJLIST::iterator posLayer = pTrack->GetChildren().begin(); for (; posLayer != pTrack->GetChildren().end(); posLayer++) { CWellBaseObj* pLayer = (CWellBaseObj*)*posLayer; // pTrack->GetChildObjList().GetNext(posLayer); CRect rect = GetDC()->GetScreen(pLayer->GetPos()); rect.NormalizeRect(); /////////标准层道时放大矩形的高度 if (m_pObj->GetType() == KEP_STANDARD) { rect.InflateRect(0, nHandleSize / 2); } if (rect.PtInRect(m_lastPoint)) { BOOL bThis = FALSE; BOOL bThat = FALSE; POSITION pos = pSection->m_BendList.GetHeadPosition(); while (pos != NULL) { CBendObj* p = (CBendObj*)pSection->m_BendList.GetNext(pos); if (p->m_pLayerLeft == m_pObj && p->m_pLayerRight == NULL && (p->m_ptEndBreak.x0m_ptEndBreak.x0>xRightValue)) { POSITION posBend = pSection->m_BendList.Find(p); if (posBend != NULL) { pSection->DeleteBend(p); } delete p; bThis = TRUE; } else if (p->m_pLayerLeft == pLayer && p->m_pLayerRight == NULL && (p->m_ptEndBreak.x0m_ptEndBreak.x0>xRightValue)) { POSITION posBend = pSection->m_BendList.Find(p); if (posBend != NULL) { pSection->DeleteBend(p); } delete p; bThat = TRUE; } else if ((p->m_pLayerLeft == m_pObj && p->m_pLayerRight == pLayer) || (p->m_pLayerLeft == pLayer && p->m_pLayerRight == m_pObj)) { POSITION posBend = pSection->m_BendList.Find(p); if (posBend != NULL) { pSection->DeleteBend(p); } delete p; if (pBend != NULL) { delete pBend; } GetDoc()->Invalidate(); ReleaseCapture(); m_bLDown = FALSE; return; } if (bThis && bThat) break; } pBend->m_pLayerRight = (CInTrackDepthSegment*)pLayer; pBend->m_nLithoBreakStyle = 2; pBend->m_fLithoBreakWidth = 0.1; pBend->m_fTopLithoBreakPoint = 0.5; pBend->m_fBottomLithoBreakPoint = 0.5; //// 若添加的连层与相关两口井之间已经存在的连层出现交叉情况则取消连层的创建 POSITION posTemp = pSection->m_BendList.GetHeadPosition(); while (posTemp != NULL) { CWellBaseObj* pObj = pSection->m_BendList.GetNext(posTemp); if (pObj->GetType() == KEP_SECTIONBEND) { CBendObj* pBendObj = (CBendObj*)pObj; double topLeft, topRight; if (pBendObj->m_pLayerRight != NULL) { CWellPole* pWellLeft = (CWellPole*)pBendObj->m_pLayerLeft->GetWell(); CWellPole* pWellRight = (CWellPole*)pBendObj->m_pLayerRight->GetWell(); if ((pWellLeft == pWell && pWellRight == pLeftWell) || (pWellLeft == pLeftWell && pWellRight == pWell)) { if (pBendObj->m_pLayerRight->GetPos().left > pBendObj->m_pLayerLeft->GetPos().left) { topLeft = pBendObj->m_pLayerLeft->GetPos().top; topRight = pBendObj->m_pLayerRight->GetPos().top; } else { topLeft = pBendObj->m_pLayerRight->GetPos().top; topRight = pBendObj->m_pLayerLeft->GetPos().top; } BOOL bOne = topLeft > pBend->m_pLayerRight->GetPos().top&&topRight < pBend->m_pLayerLeft->GetPos().top; BOOL bSecond = topLeft < pBend->m_pLayerRight->GetPos().top&&topRight > pBend->m_pLayerLeft->GetPos().top; if (bOne || bSecond) { pBend = NULL; delete pBend; AfxMessageBox("连层不能出现交叉情况!"); GetDoc()->Invalidate(); ReleaseCapture(); m_bLDown = FALSE; return; } } } } } /////////HFX 2014.10.22 若添加的连层与相关两口井之间已经存在的连层出现交叉情况则取消连层的创建 if (m_pObj->GetType() == KEP_RESULT) { CInTrackResult* pLayerLeft = (CInTrackResult*)pBend->m_pLayerLeft; CInTrackResult* pLayerRight = (CInTrackResult*)pBend->m_pLayerRight; if ((pLayerLeft->m_strResult != pLayerRight->m_strResult) && !(pLayerLeft->m_strResult == "干层" || pLayerRight->m_strResult == "干层")) { pBend->m_fWaterTop = pBend->m_fGasBottom = pLayerLeft->GetPos().CenterPoint().y0 - (pLayerLeft->GetPos().CenterPoint().y0 - pLayerRight->GetPos().CenterPoint().y0) / 2; } } double valueLeft = m_pObj->GetPos().CenterPoint().y0; double valueRight = pLayer->GetPos().CenterPoint().y0; double HeightLeft = m_pObj->GetPos().Height(); double HeightRight = pLayer->GetPos().Height(); ////添加连层到左右层的连层链表中 ReBendLeftRightList(pBend); if (m_pObj->GetType() == KEP_STANDARD) { pBend->SetSlotTypeStandardLayer(TRUE); } pSection->ComputeBendPosition(pBend, valueRight, valueLeft, HeightRight, HeightLeft); pBend->AddControlPoints(xLeftValue, valueLeft, xRightValue, valueRight, xRightValue - xLeftValue); dfPoint ptTemp; ptTemp.x0 = xLeftValue; ptTemp.y0 = valueLeft + HeightLeft * 0.5; pBend->m_ptArrCurveTopOld.Add(ptTemp); ptTemp.y0 = valueLeft - HeightLeft * 0.5; pBend->m_ptArrCurveBotOld.Add(ptTemp); ptTemp.x0 = xRightValue; ptTemp.y0 = valueRight + HeightRight * 0.5; pBend->m_ptArrCurveTopOld.Add(ptTemp); ptTemp.y0 = valueRight - HeightRight * 0.5; pBend->m_ptArrCurveBotOld.Add(ptTemp); //添加Bend的断层链表 pBend->BendAddFault(); pBend->ComputeSlopeAndConstant(); pBend->CreateBendLines(); CString strLithoLeft; CString strLithoRight; CString strResultLeft; CString strResultRight; if (m_pObj->GetType() == KEP_RESULT) { CInTrackResult* pLayerLeft = (CInTrackResult*)pBend->m_pLayerLeft; strLithoLeft = pLayerLeft->m_strLitho; strResultLeft = pLayerLeft->m_strResult; if (NULL != pBend->m_pLayerRight) { CInTrackResult* pLayerRight = (CInTrackResult*)pBend->m_pLayerRight; strLithoRight = pLayerRight->m_strLitho; strResultRight = pLayerRight->m_strResult; } } else if (m_pObj->GetType() == KEP_LAYERGROUP) { CInTrackLayerGroup* pLayerLeft = (CInTrackLayerGroup*)pBend->m_pLayerLeft; strLithoLeft = pLayerLeft->m_strLitho; if (NULL != pBend->m_pLayerRight) { CInTrackLayerGroup* pLayerRight = (CInTrackLayerGroup*)pBend->m_pLayerRight; strLithoRight = pLayerRight->m_strLitho; } } if ((/*!strLithoLeft.IsEmpty() && !strLithoRight.IsEmpty() && */strLithoLeft != strLithoRight) || (/*!strResultLeft.IsEmpty() && !strResultRight.IsEmpty() && */strResultLeft != strResultRight)) { pBend->bBreakLithoTemp = TRUE; pBend->CreateBendLithoBreak(); } pBend->CreateBendFills(); pBend->SetShowFill(TRUE); pBend->SetShowTopLine(TRUE); pBend->SetShowBotLine(TRUE); if (pTrack->GetTrackType() == Track_Result) { pBend->SetSlotTypeResult(TRUE); } else if (pTrack->GetTrackType() == Track_Stratum) { pBend->SetSlotTypeStratiUnit(TRUE); } //else if (pTrack->GetTrackType()==Track_StandardLayer) //{ // pBend->SetSlotTypeStandardLayer(TRUE); //} if (pSection->IsStratumSmooth()) { pBend->SmoothBendLines(); } pSection->m_BendList.AddTail(pBend); break; } } } } } } } } } void CItemAddBend::MakeBendForResform(CWellSection* pSection, CWellPole * pWell ,UINT nFlags, CPoint point) { m_lastPoint = point; 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.0001) { ReleaseCapture(); m_bLDown = FALSE; return; } int nHandleSize = HANDLESIZE; CWellPole* pLeftWell = NULL; CWellPole* pRightWell = NULL; if (pSection->GetType() == KEP_WELLSECTION) { POSITION posFind = pSection->m_WellList.Find(pWell); pSection->m_WellList.GetNext(posFind); if (posFind != NULL) { pRightWell = (CWellPole*)pSection->m_WellList.GetNext(posFind); } posFind = pSection->m_WellList.Find(pWell); pSection->m_WellList.GetPrev(posFind); if (posFind != NULL) { pLeftWell = (CWellPole*)pSection->m_WellList.GetPrev(posFind); } CBendObj *pNewBend = NULL; CTrackObj * pDownTrack = (CTrackObj*)m_pObj->GetParent(); if (ptLast.x0 > ptDown.x0 && pRightWell != NULL &&(m_pObj->GetType() == KEP_RESULT || m_pObj->GetType() == KEP_LAYERGROUP)) {//朝右侧井建立连层 double xleft, xright; xleft = pWell->GetRect().right; xright = pRightWell->GetRect().left; if (xleft < ptLast.x0 && ptLast.x0 < xright) {//尖灭 if (pSection->FindBend(m_pObj, NULL, pWell, pRightWell) == NULL) { pNewBend = new CBendObj(); pNewBend->SetParent(pSection); pNewBend->m_pWellLeft = pWell; pNewBend->m_pWellRight = pRightWell; pNewBend->m_pLayerLeft = m_pObj; pNewBend->m_LeftLayerName = m_pObj->GetLayerName(); //m_pObj->m_BendRightList.push_back(pNewBend); //CWellSection::ReOrederBendList(m_pObj->m_BendRightList, 2); CPoint2D pchpt = GetDC()->GetReal(m_lastPoint); pNewBend->InitBendPchoutControlPoints(pchpt); } } else if (ptLast.x0 > xright) { TRACKLIST trackList; pRightWell->GetAllTrack(&trackList, pDownTrack->GetTrackType());//找同类型的道 if (trackList.size() > 0) { CTrackObj *pTrack = (*trackList.begin()); WELLOBJLIST::iterator it = pTrack->GetChildren().begin(); for (; it != pTrack->GetChildren().end(); it++) { if ((*it)->GetType() == m_pObj->GetType()) { CInTrackDepthSegment* pInTrack = (CInTrackDepthSegment*)*it; CRect rect = GetDC()->GetScreen(pInTrack->GetPos()); rect.NormalizeRect(); if (rect.PtInRect(m_lastPoint)) { if (pSection->FindBend(m_pObj, pInTrack,pWell,pRightWell) == NULL) { pNewBend = new CBendObj(); pNewBend->SetParent(pSection); pNewBend->m_pWellLeft = pWell; pNewBend->m_pWellRight = pRightWell; pNewBend->m_pLayerLeft = m_pObj; pNewBend->m_LeftLayerName = m_pObj->GetLayerName(); m_pObj->m_BendRightList.push_back(pNewBend); pNewBend->m_pLayerRight = pInTrack; pNewBend->m_RightLayerName = pInTrack->GetLayerName(); pInTrack->m_BendLeftList.push_back(pNewBend); CWellSection::ReOrederBendList(m_pObj->m_BendRightList, 2); CWellSection::ReOrederBendList(pInTrack->m_BendLeftList, 1); pNewBend->InitBendControlPoints(); break; } } } } } } } else if (ptLast.x0 < ptDown.x0 && pLeftWell != NULL && (m_pObj->GetType() == KEP_RESULT || m_pObj->GetType() == KEP_LAYERGROUP)) { double xleft, xright; xleft = pLeftWell->GetRect().right; xright = pWell->GetRect().left; if (xleft < ptLast.x0 && ptLast.x0 < xright) {//朝右侧尖灭 if (pSection->FindBend(m_pObj, NULL, pWell, pLeftWell) == NULL) { pNewBend = new CBendObj(); pNewBend->SetParent(pSection); pNewBend->m_pWellLeft = pWell; pNewBend->m_pWellRight = pLeftWell; pNewBend->m_pLayerLeft = m_pObj; pNewBend->m_LeftLayerName = m_pObj->GetLayerName(); //m_pObj->m_BendRightList.push_back(pNewBend); CPoint2D pchpt = GetDC()->GetReal(m_lastPoint); pNewBend->InitBendPchoutControlPoints(pchpt); } } else if (ptLast.x0 < xleft) { TRACKLIST trackList; pLeftWell->GetAllTrack(&trackList, pDownTrack->GetTrackType());//找同类型的道 if (trackList.size() > 0) { CTrackObj *pTrack = (*trackList.begin()); WELLOBJLIST::iterator it = pTrack->GetChildren().begin(); for (; it != pTrack->GetChildren().end(); it++) { if ((*it)->GetType() == m_pObj->GetType()) { CInTrackDepthSegment* pInTrack = (CInTrackDepthSegment*)*it; CRect rect = GetDC()->GetScreen(pInTrack->GetPos()); rect.NormalizeRect(); if (rect.PtInRect(m_lastPoint)) { if (pSection->FindBend(pInTrack,m_pObj,pLeftWell, pWell) == NULL) { pNewBend = new CBendObj(); pNewBend->SetParent(pSection); pNewBend->m_pWellLeft = pLeftWell; pNewBend->m_pWellRight = pWell; pNewBend->m_pLayerLeft = pInTrack; pNewBend->m_LeftLayerName = pInTrack->GetLayerName(); pInTrack->m_BendRightList.push_back(pNewBend); pNewBend->m_pLayerRight = m_pObj; pNewBend->m_RightLayerName = m_pObj->GetLayerName(); m_pObj->m_BendLeftList.push_back(pNewBend); CWellSection::ReOrederBendList(m_pObj->m_BendLeftList, 1); CWellSection::ReOrederBendList(pInTrack->m_BendRightList, 2); pNewBend->InitBendControlPoints(); break; } } } } } } } if (pNewBend) { SetReUnDoAction(FALSE, IDS_STRING_ACTION_MOVE, 2); pNewBend->SetSlotType(); pNewBend->ComputeBend(); //pNewBend->SetResFormBendTopBotPoint(); //pNewBend->ComputeSlopeAndConstant(); //pNewBend->CreateBendLines(); //pNewBend->CreateBendFills(); pSection->m_BendList.AddTail(pNewBend); if (pNewBend->m_pLayerRight != NULL) {//将受影响的其它bend都重新计算一下 WELLOBJLIST::iterator it = pNewBend->m_pLayerLeft->m_BendRightList.begin(); for (; it != pNewBend->m_pLayerLeft->m_BendRightList.end(); it++) { CBendObj *pBend = (CBendObj*)(*it); if (pBend != pNewBend) { //pBend->SetResFormBendTopBotPoint(); //pBend->ComputeSlopeAndConstant(); //pBend->CreateBendLines(); //pBend->CreateBendFills(); pBend->ComputeBend(); } } it = pNewBend->m_pLayerRight->m_BendLeftList.begin(); for (; it != pNewBend->m_pLayerRight->m_BendLeftList.end(); it++) { CBendObj *pBend = (CBendObj*)(*it); if (pBend != pNewBend) { pBend->ComputeBend(); //pBend->SetResFormBendTopBotPoint(); //pBend->ComputeSlopeAndConstant(); //pBend->CreateBendLines(); //pBend->CreateBendFills(); } } } } } } void CItemAddBend::OnLButtonUp(CDC *pDC, UINT nFlags, CPoint point, int vk) { if(NULL == m_pItemWell) { return; } CWellPole * pWell = m_pItemWell->GetWellObject(); CWellSection* pSection = NULL; if (pWell != NULL) { pSection = (CWellSection*)pWell->GetParent(); } if(NULL == pSection) { return; } if (pSection->m_bResForm) { MakeBendForResform(pSection, pWell, nFlags, point); } else { MakeBendForOld(pSection, pWell, nFlags, point); } GetDoc()->Invalidate(); ReleaseCapture(); m_bLDown = FALSE; } void CItemAddBend::OnLButtonDblClk(UINT nFlags, CPoint point) { } int CItemAddBend::OnMouseMove(CDC *pDC, UINT nFlags, CPoint point) { if(IsCaptureState() && m_bLDown) { OnDraw(GetDC(),pDC); m_lastPoint = point; OnDraw(GetDC(),pDC); //OnSetCursor(/*GetView(),*/ 1, 512); } return 0; } BOOL CItemAddBend::OnSetCursor(CPoint pt, int& handle) { int nHandleSize = HANDLESIZE; double dHandleSize = GetDC()->GetRealSize(CSize(nHandleSize / 2, nHandleSize / 2)).cx; CPoint2D ptReal = GetDC()->GetReal(m_lastPoint); CRect8 rectReal = CRect8(ptReal.x0, ptReal.y0, ptReal.x0 + 1, ptReal.y0 - 1); //手动连层时设置鼠标状态 CWellPole * pWell = m_pItemWell->GetWellObject(); CWellSection* pSection = (CWellSection*)pWell->GetParent(); POSITION pos = pSection->m_WellList.GetHeadPosition(); CSectionWellObj* pWellIn = NULL; while (pos != NULL) { CSectionWellObj* pSectionWell = (CSectionWellObj*)pSection->m_WellList.GetNext(pos); if (pSectionWell->GetPos().PtInRect(ptReal) && pSectionWell != pWell) { pWellIn = pSectionWell; break; } } BOOL bExist = FALSE; if (pWellIn != NULL) { TRACKLIST tracklist; pWellIn->GetAllTrack(&tracklist); if (m_pObj->GetType() == KEP_RESULT || m_pObj->GetType() == KEP_LAYERGROUP || m_pObj->GetType() == KEP_STANDARD) { TRACKLIST::iterator pos = tracklist.begin(); for (; pos != tracklist.end(); pos++) { CTrackObj* pTrack = *pos; if ((m_pObj->GetType() == KEP_RESULT && pTrack->GetTrackType() == Track_Result) || (m_pObj->GetType() == KEP_LAYERGROUP && pTrack->GetTrackType() == Track_Stratum) || (m_pObj->GetType() == KEP_STANDARD && pTrack->GetTrackType() == Track_StandardLayer)) { WELLOBJLIST::iterator posLayer = pTrack->GetChildren().begin(); for (; posLayer != pTrack->GetChildren().end(); posLayer++) { CWellBaseObj* pLayer = (CWellBaseObj*)*posLayer; if (pLayer->GetType() == m_pObj->GetType()) { CRect rect = GetDC()->GetScreen(pLayer->GetPos()); rect.NormalizeRect(); if (pLayer->Intersects(rectReal, dHandleSize)) { bExist = TRUE; } } } if (bExist) break; } } } tracklist.clear(); } if (bExist) handle = 14; else handle = 15; return TRUE; } BOOL CItemAddBend::OnSetCursor(/*CWnd* pWnd,*/ UINT nHitTest, UINT message) { int nHandleSize= HANDLESIZE; double dHandleSize = GetDC()->GetRealSize(CSize(nHandleSize/2, nHandleSize/2)).cx; CPoint2D ptReal = GetDC()->GetReal(m_lastPoint); CRect8 rectReal = CRect8(ptReal.x0,ptReal.y0,ptReal.x0+1,ptReal.y0-1); //手动连层时设置鼠标状态 CWellPole * pWell = m_pItemWell->GetWellObject(); CWellSection* pSection = (CWellSection*)pWell->GetParent(); POSITION pos = pSection->m_WellList.GetHeadPosition(); CSectionWellObj* pWellIn = NULL; while (pos!=NULL) { CSectionWellObj* pSectionWell = (CSectionWellObj*)pSection->m_WellList.GetNext(pos); if (pSectionWell->GetPos().PtInRect(ptReal) && pSectionWell!=pWell) { pWellIn = pSectionWell; break; } } BOOL bExist = FALSE; if(pWellIn!=NULL) { TRACKLIST tracklist; pWellIn->GetAllTrack(&tracklist); if (m_pObj->GetType()==KEP_RESULT|| m_pObj->GetType()==KEP_LAYERGROUP|| m_pObj->GetType()==KEP_STANDARD) { TRACKLIST::iterator pos = tracklist.begin(); for(; pos !=tracklist.end(); pos++) { CTrackObj* pTrack = *pos; if ((m_pObj->GetType()==KEP_RESULT&&pTrack->GetTrackType()==Track_Result)|| (m_pObj->GetType()==KEP_LAYERGROUP&&pTrack->GetTrackType()==Track_Stratum)|| (m_pObj->GetType()==KEP_STANDARD&&pTrack->GetTrackType()==Track_StandardLayer)) { WELLOBJLIST::iterator posLayer = pTrack->GetChildren().begin(); for(; posLayer != pTrack->GetChildren().end(); posLayer++) { CWellBaseObj* pLayer = (CWellBaseObj*)*posLayer; if(pLayer->GetType() == m_pObj->GetType()) { CRect rect = GetDC()->GetScreen(pLayer->GetPos()); rect.NormalizeRect(); if (pLayer->Intersects(rectReal,dHandleSize)) { bExist = TRUE; } } } if(bExist) break; } } } tracklist.clear(); } if(bExist) ::SetCursor(AfxGetApp()->LoadCursor(IDC_ARROW)); else ::SetCursor(AfxGetApp()->LoadCursor(IDC_CROSS)); return TRUE; } //void CItemAddBend::ComputeBendPosition(CBendObj* pBend,double &valueLeft,double &valueRight,double &heightLeft,double &heightRight) //{ // CDrawTopEndObj* pLayerLeft = pBend->m_pLayerLeft; // CDrawTopEndObj* pLayerRight = pBend->m_pLayerRight; // if(pBend->m_pLayerLeft->GetPos().left > pBend->m_pLayerRight->GetPos().left) // { // pLayerLeft = pBend->m_pLayerRight; // pLayerRight = pBend->m_pLayerLeft; // } // //////////////////////////////////////////////////////////////////////////////左侧层有多个bend时 // if (pLayerLeft->m_BendRightList.GetCount()>1) // { // //所有层的高度和 // double TotalH = 0.0; // POSITION pos = pLayerLeft->m_BendRightList.GetHeadPosition(); // while (pos!=NULL) // { // CBendObj *pBend1 = (CBendObj *)pLayerLeft->m_BendRightList.GetNext(pos); // CDrawTopEndObj* pLayer = pBend1->m_pLayerRight; // if(pBend1->m_pLayerLeft->GetPos().left > pBend1->m_pLayerRight->GetPos().left) // pLayer = pBend1->m_pLayerLeft; // TotalH = TotalH+pLayer->GetPos().Height(); // } // pos = pLayerLeft->m_BendRightList.GetHeadPosition(); // double H = 0.0; // while(pos!=NULL) // { // CBendObj *pBend1 = (CBendObj *)pLayerLeft->m_BendRightList.GetNext(pos); // CDrawTopEndObj* pLayer = pBend1->m_pLayerRight; // if(pBend1->m_pLayerLeft->GetPos().left > pBend1->m_pLayerRight->GetPos().left) // pLayer = pBend1->m_pLayerLeft; // H = H+(pLayer->GetPos().Height()/TotalH)*pLayerLeft->GetPos().Height(); // if (pBend1==pBend) // { // valueLeft = pLayerLeft->GetPos().top-(H-(pLayer->GetPos().Height()/TotalH)*pLayerLeft->GetPos().Height())-((pLayer->GetPos().Height()/TotalH)*pLayerLeft->GetPos().Height())/2; // heightLeft = (pLayer->GetPos().Height()/TotalH)*pLayerLeft->GetPos().Height(); // //break; // } // else // { // pBend1->ReComupteControls(); // } // } // } // ////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////右侧层有多个bend时 // if (pLayerRight->m_BendLeftList.GetCount()>1) // { // double TotalH = 0.0; // POSITION pos = pLayerRight->m_BendLeftList.GetHeadPosition(); // while (pos!=NULL) // { // CBendObj *pBend1 = (CBendObj *)pLayerRight->m_BendLeftList.GetNext(pos); // CDrawTopEndObj* pLayer = pBend1->m_pLayerLeft; // if(pBend1->m_pLayerLeft->GetPos().left > pBend1->m_pLayerRight->GetPos().left) // pLayer = pBend1->m_pLayerRight; // TotalH = TotalH+pLayer->GetPos().Height(); // } // pos = pLayerRight->m_BendLeftList.GetHeadPosition(); // double H = 0.0; // while(pos!=NULL) // { // CBendObj *pBend1 = (CBendObj *)pLayerRight->m_BendLeftList.GetNext(pos); // CDrawTopEndObj* pLayer = pBend1->m_pLayerLeft; // if(pBend1->m_pLayerLeft->GetPos().left > pBend1->m_pLayerRight->GetPos().left) // pLayer = pBend1->m_pLayerRight; // H = H+(pLayer->GetPos().Height()/TotalH)*pLayerRight->GetPos().Height(); // if (pBend1==pBend) // { // valueRight = pLayerRight->GetPos().top-(H-(pLayer->GetPos().Height()/TotalH)*pLayerRight->GetPos().Height())-((pLayer->GetPos().Height()/TotalH)*pLayerRight->GetPos().Height())/2; // heightRight = (pLayer->GetPos().Height()/TotalH)*pLayerRight->GetPos().Height(); // //break; // } // else // { // pBend1->ReComupteControls(); // } // } // } //} void CItemAddBend::ReBendLeftRightList(CBendObj* pBend) { CInTrackDepthSegment* pLayerLeft = pBend->m_pLayerLeft; CInTrackDepthSegment* pLayerRight = pBend->m_pLayerRight; if(pBend->m_pLayerLeft->GetPos().left > pBend->m_pLayerRight->GetPos().left) { pLayerLeft = pBend->m_pLayerRight; pLayerRight = pBend->m_pLayerLeft; } //填充左层的右bend链表 WELLOBJLIST::iterator pos = pLayerLeft->m_BendRightList.begin(); // GetHeadPosition(); if (pLayerLeft->m_BendRightList.size() == 0) { pLayerLeft->m_BendRightList.push_back(pBend); } else { BOOL bInsert = FALSE; for ( ; pos!= pLayerLeft->m_BendRightList.end() ; pos++) { WELLOBJLIST::iterator posFlag = pos; CBendObj * p = (CBendObj *)*pos; CInTrackDepthSegment* pLayer = p->m_pLayerRight; if(p->m_pLayerLeft->GetPos().left > p->m_pLayerRight->GetPos().left) pLayer = p->m_pLayerLeft; if (pLayerRight->GetPos().top>pLayer->GetPos().top) { pLayerLeft->m_BendRightList.insert(posFlag,pBend); bInsert = TRUE; break; } } if(!bInsert) { pLayerLeft->m_BendRightList.push_back(pBend); } } //填充右层的左bend链表 pos = pLayerRight->m_BendLeftList.begin(); if (pLayerRight->m_BendLeftList.size() == 0) { pLayerRight->m_BendLeftList.push_back(pBend); } else { BOOL bInsert = FALSE; for (; pos != pLayerLeft->m_BendLeftList.end(); pos++) { WELLOBJLIST::iterator posFlag = pos; CBendObj * p = (CBendObj *)*pos; // pLayerRight->m_BendLeftList.GetNext(pos); CInTrackDepthSegment* pLayer = p->m_pLayerLeft; if(p->m_pLayerLeft->GetPos().left > p->m_pLayerRight->GetPos().left) pLayer = p->m_pLayerRight; if (pLayerLeft->GetPos().top>pLayer->GetPos().top) { pLayerRight->m_BendLeftList.insert(posFlag,pBend); bInsert = TRUE; break; } } if(!bInsert) { pLayerRight->m_BendLeftList.push_back(pBend); } } } int CItemAddBend::DeleteSelection(void) { if(this->m_WellObjSelectlist.GetCount() == 0) return 0; CItemWcsTrackIn itemtrackin(GetDoc()); CBendObj* pBendHead = (CBendObj*)m_WellObjSelectlist.GetHead(); CInTrackDepthSegment* pDrawTopEnd = NULL; POSITION pos = m_WellObjSelectlist.GetTailPosition(); while(pos != NULL) { pDrawTopEnd = (CInTrackDepthSegment*)m_WellObjSelectlist.GetPrev(pos); itemtrackin.SetDrawObj(pDrawTopEnd); itemtrackin.Select(pDrawTopEnd); } itemtrackin.DeleteSelection(); m_WellObjSelectlist.RemoveAll(); return 1; } }