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.

1012 lines
32 KiB
C++

1 month ago
#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();
////ˢ<><CBA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ
}
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)
{
//<2F><><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E0BEAE><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>Ҳྮһ<E0BEAE><D2BB><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6>ľ<EFBFBD><C4BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E0BEAE>λ<EFBFBD><CEBB><EFBFBD>б<D0B1><E4BBAF>
std::vector<CWellPole*> wellArr;
std::set<CWellPole*> 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))
{//<2F><><EFBFBD>ܽ<EFBFBD><DCBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD>Χ
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);
//<2F>ƶ<EFBFBD><C6B6>ĵ<EFBFBD>һ<EFBFBD>ھ<EFBFBD><DABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ľ<EFBFBD>λ<EFBFBD>÷<EFBFBD><C3B7><EFBFBD><EFBFBD><EFBFBD><E4BBAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>м<EFBFBD><D0BC>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>á<EFBFBD>
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);
}
//<2F><><EFBFBD>Ͷϲ<CDB6><CFB2>ƶ<EFBFBD><C6B6><EFBFBD>λ<EFBFBD>ú<EFBFBD><C3BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>bend
pos = pSection->m_BendList.GetHeadPosition();
while (pos)
{
CBendObj* pBend = (CBendObj*)pSection->m_BendList.GetNext(pos);
std::vector<CWellPole*>::iterator lit = std::find(wellArr.begin() + (moveId - 1), wellArr.end(), pBend->m_pWellLeft);
std::vector<CWellPole*>::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; //ֻ<>ܺ<EFBFBD><DCBA><EFBFBD><EFBFBD>ƶ<EFBFBD>
//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)
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD>
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);
}
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD><CFB6><EFBFBD><EFBFBD>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⾮Ҳ<E2BEAE><D2B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD>
//<2F>ж϶ϲ<CFB6><CFB2><EFBFBD><EFBFBD><EFBFBD>
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);
}
//ȡǰ<C8A1><C7B0><EFBFBD><EFBFBD>
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);
/////////////////////////////////////////////////////////////////////////////
//<2F><><EFBFBD>о<EFBFBD><D0BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
//<2F><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
CArray<CWellBaseObj*, CWellBaseObj*> 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]);
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
wellArr.RemoveAll();
//ȡǰ<C8A1><C7B0><EFBFBD><EFBFBD>
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)//<2F><>λ<EFBFBD>÷<EFBFBD><C3B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
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);
//// <20><>λ<EFBFBD>÷<EFBFBD><C3B7><EFBFBD><EFBFBD>仯ʱ<E4BBAF><CAB1><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>
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);
/////// <20><>λ<EFBFBD>÷<EFBFBD><C3B7><EFBFBD><EFBFBD>仯ʱ<E4BBAF><CAB1><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>
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);
//////// <20><>λ<EFBFBD>÷<EFBFBD><C3B7><EFBFBD><EFBFBD>仯ʱ<E4BBAF><CAB1><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>
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);
//////// <20><>λ<EFBFBD>÷<EFBFBD><C3B7><EFBFBD><EFBFBD>仯ʱ<E4BBAF><CAB1><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>
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);
//////<2F><>λ<EFBFBD>÷<EFBFBD><C3B7><EFBFBD><EFBFBD>仯ʱ<E4BBAF><CAB1><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>
pSection->DeleteBend(pBend);
//delete pBend;
}
}
}
//pcg<63><67><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>
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();
}
}
/// <20>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҿ<EFBFBD><D2BE><EFBFBD>λ<EFBFBD>ù<EFBFBD>ϵ
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;
}
}
}
}
//<2F>ж<EFBFBD><D0B6><EFBFBD><E9BEAE><EFBFBD><EFBFBD>
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);
}
//<2F>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>и<EFBFBD><D0B8><EFBFBD>λ
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();
}
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ
pSection->ReSetPosition();
//ˢ<><CBA2>
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);
//<2F><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
CArray<CWellBaseObj*, CWellBaseObj*> 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;ii<wellArr.GetCount();ii++)
{
pWellSection->m_WellList.AddTail(wellArr[ii]);
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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);
//ѡ<><D1A1>
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());
}
//ȡǰ<C8A1><C7B0><EFBFBD><EFBFBD>
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()) //<2F>϶<EFBFBD><CFB6><EFBFBD>
{
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
{
////////<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵķǼ<C4B7><C7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı
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);
}
////////<2F><><EFBFBD>ұ<EFBFBD><D2B1><EFBFBD><EFBFBD>ӵķǼ<C4B7><C7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı
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);
}
////////<2F><><EFBFBD><EFBFBD><EFBFBD>ӵļ<D3B5><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı
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)
{
//<2F>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>и<EFBFBD><D0B8><EFBFBD>λ
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)
{
//ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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();
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
SetScrollBarRange();
}
int CItemSectionWell::GetSubMenu()
{
int iRMenu = CItemWcsSingleWell::GetSubMenu();
if (iRMenu == 42)
iRMenu = 46; //<2F><>WellPole<6C>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD>Ϊ SectionWell<6C>˵<EFBFBD>
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;
}
}