|
|
#include "StdAfx.h"
|
|
|
#include "ItemAddFault.h"
|
|
|
|
|
|
#include "actionmodifieditem.h"
|
|
|
#include "WellPoleLib/InTrackResult.h"
|
|
|
|
|
|
|
|
|
#include "WellPoleLib/WellBaseObj.h"
|
|
|
#include "WellPoleLib/InTrackDepthSegment.h"
|
|
|
#include "WellPoleLib/TrackObj.h"
|
|
|
#include "WellPoleLib/TrackGroup.h"
|
|
|
#include "WellPoleLib/WellPole.h"
|
|
|
#include "WellPoleLib/InclinedWellPole.h"
|
|
|
#include "WellPoleLib/InclinedTrack.h"
|
|
|
#include "WellPoleLib/TrackDepth.h"
|
|
|
#include "WellPoleLib/TrackCurve.h"
|
|
|
#include "WellPoleLib/TrackResult.h"
|
|
|
|
|
|
#include "MultiWellSectionLib/FaultObj.h"
|
|
|
#include "MultiWellSectionLib/BendObj.h"
|
|
|
#include "MultiWellSectionLib/WellSection.h"
|
|
|
|
|
|
#include "ItemFault.h"
|
|
|
|
|
|
#include "MultiWellSectionDoc.h"
|
|
|
#include "MultiWellSectionlView.h"
|
|
|
namespace NItem
|
|
|
{
|
|
|
|
|
|
CItemAddFault::CItemAddFault(CSigmaDoc* pDoc)
|
|
|
: CItemWellBase(pDoc)
|
|
|
{
|
|
|
SetType(ITEM_ADDFAULT);
|
|
|
m_pFault = NULL;
|
|
|
|
|
|
}
|
|
|
|
|
|
CItemAddFault::~CItemAddFault(void)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
void CItemAddFault::OnDraw(CXyDC* pXyDC ,CDC* pDC)
|
|
|
{
|
|
|
CPen pen(PS_DOT, 0, RGB(0, 0, 0));
|
|
|
CPen *pOldPen = (CPen *)pDC->SelectObject(&pen);
|
|
|
|
|
|
if (m_pFault)
|
|
|
{
|
|
|
if (m_pFault->m_OrgCtrlPts.size() > 1)
|
|
|
{
|
|
|
CPoint pt1, pt2;
|
|
|
pt1 = pXyDC->GetScreen(m_pFault->m_OrgCtrlPts[0]);
|
|
|
pDC->MoveTo(pt1);
|
|
|
for (int ii = 1; ii < m_pFault->m_OrgCtrlPts.size(); ii++)
|
|
|
{
|
|
|
pt2 = pXyDC->GetScreen(m_pFault->m_OrgCtrlPts[ii]);
|
|
|
pDC->LineTo(pt2);
|
|
|
|
|
|
pt1 = pt2;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
int old = pDC->SetROP2(R2_NOTXORPEN);
|
|
|
pDC->MoveTo(m_firstPoint);
|
|
|
pDC->LineTo(m_lastPoint);
|
|
|
pDC->SetROP2(old);
|
|
|
}
|
|
|
|
|
|
pDC->SelectObject(pOldPen);
|
|
|
pen.DeleteObject();
|
|
|
}
|
|
|
|
|
|
void CItemAddFault::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);
|
|
|
if (m_pFault==NULL)
|
|
|
{
|
|
|
//GetView()->SetCapture();
|
|
|
m_pFault = new CFaultObj();
|
|
|
m_pFault->SetParent(m_pItemSection->GetWellSection());
|
|
|
m_pFault->m_fLeftThrow = m_pFault->m_fRightThrow = 1.5;
|
|
|
m_pFault->SetCutFluid(FALSE);
|
|
|
dfPoint pt;
|
|
|
pt.x0 = ptReal.x0;
|
|
|
pt.y0 = ptReal.y0;
|
|
|
m_pFault->m_OrgCtrlPts.push_back(pt);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
dfPoint pt;
|
|
|
pt.x0 = ptReal.x0;
|
|
|
pt.y0 = ptReal.y0;
|
|
|
if(!(pt==m_pFault->m_OrgCtrlPts.at(m_pFault->m_OrgCtrlPts.size()-1)))
|
|
|
{
|
|
|
BOOL isXFind=TRUE,isYFind=TRUE;
|
|
|
if( m_pFault->m_OrgCtrlPts.size() > 1 )
|
|
|
{
|
|
|
//<2F>ж϶ϲ<CFB6><CFB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
if( m_pFault->m_OrgCtrlPts.at(m_pFault->m_OrgCtrlPts.size() -2).x0 >= m_pFault->m_OrgCtrlPts.at(m_pFault->m_OrgCtrlPts.size() -1).x0)
|
|
|
{
|
|
|
if( m_pFault->m_OrgCtrlPts.at(m_pFault->m_OrgCtrlPts.size() -1).x0 >= pt.x0 )
|
|
|
isXFind=TRUE;
|
|
|
else
|
|
|
isXFind=FALSE;
|
|
|
}
|
|
|
if(m_pFault->m_OrgCtrlPts.at(m_pFault->m_OrgCtrlPts.size() -2).x0 <= m_pFault->m_OrgCtrlPts.at(m_pFault->m_OrgCtrlPts.size()-1).x0)
|
|
|
{
|
|
|
if( m_pFault->m_OrgCtrlPts.at(m_pFault->m_OrgCtrlPts.size() -1).x0 <= pt.x0 )
|
|
|
isXFind=TRUE;
|
|
|
else
|
|
|
isXFind=FALSE;
|
|
|
}
|
|
|
if(m_pFault->m_OrgCtrlPts.at(m_pFault->m_OrgCtrlPts.size() -2).y0 >= m_pFault->m_OrgCtrlPts.at(m_pFault->m_OrgCtrlPts.size() -1).y0)
|
|
|
{
|
|
|
if(m_pFault->m_OrgCtrlPts.at(m_pFault->m_OrgCtrlPts.size() -1).y0>=pt.y0)
|
|
|
isYFind=TRUE;
|
|
|
else
|
|
|
isYFind=FALSE;
|
|
|
}
|
|
|
if(m_pFault->m_OrgCtrlPts.at(m_pFault->m_OrgCtrlPts.size() -2).y0 <= m_pFault->m_OrgCtrlPts.at(m_pFault->m_OrgCtrlPts.size() -1).y0)
|
|
|
{
|
|
|
if(m_pFault->m_OrgCtrlPts.at(m_pFault->m_OrgCtrlPts.size() -1).y0<=pt.y0)
|
|
|
isYFind=TRUE;
|
|
|
else
|
|
|
isYFind=FALSE;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if( isXFind && isYFind )
|
|
|
{
|
|
|
m_pFault->m_OrgCtrlPts.push_back(pt);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//AfxMessageBox("<22>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD><EFBFBD><EFBFBD>!<21><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!");
|
|
|
delete m_pFault;
|
|
|
m_pFault = NULL;
|
|
|
m_pItemSection->OnLButtonDblClk(nFlags,point);
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
void CItemAddFault::OnLButtonUp(CDC *pDC, UINT nFlags, CPoint point, int vk)
|
|
|
{
|
|
|
m_lastPoint = point;
|
|
|
|
|
|
}
|
|
|
|
|
|
void CItemAddFault::OnLButtonDblClk(UINT nFlags, CPoint point)
|
|
|
{
|
|
|
CWellSection* pSection = m_pItemSection->GetWellSection();
|
|
|
if (m_pFault!=NULL)
|
|
|
{
|
|
|
if (m_pFault->m_OrgCtrlPts.at(0)==m_pFault->m_OrgCtrlPts.at(m_pFault->m_OrgCtrlPts.size()-1))
|
|
|
{
|
|
|
delete m_pFault;
|
|
|
m_pFault = NULL;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
CPoint2D ptReal ;
|
|
|
CMultiWellSectionDoc* pDoc = (CMultiWellSectionDoc*)m_pItemSection->GetDoc();
|
|
|
CRect8 rectReal = pDoc->GetSelectedRect(ptReal);
|
|
|
int ii = 0;
|
|
|
for( ii = 0; ii< m_pFault->m_OrgCtrlPts.size();ii++)
|
|
|
{
|
|
|
rectReal = pDoc->GetSelectedRect(m_pFault->m_OrgCtrlPts[ii]);
|
|
|
if(pSection->IsInRange(rectReal))
|
|
|
break;
|
|
|
}
|
|
|
if(ii == m_pFault->m_OrgCtrlPts.size())
|
|
|
{//<2F><><EFBFBD>ƵĶϲ<C4B6><CFB2>߶<EFBFBD><DFB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>淶Χ<E6B7B6><CEA7>
|
|
|
delete m_pFault;
|
|
|
m_pFault = NULL;
|
|
|
//ReleaseCapture();
|
|
|
//pDoc->SetItem(pDoc->FindItem(ITEM_SELECT)); //<2F><><EFBFBD>ú<EFBFBD>,<2C><>CItemAddFault<6C><74>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD>
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
CString strDateTime;
|
|
|
//int nCount;
|
|
|
//nCount = pSection->m_FaultList.GetCount();
|
|
|
m_pFault->m_strName = pSection->GetNewFaultName();
|
|
|
pSection->m_FaultList.AddTail(m_pFault);
|
|
|
|
|
|
m_pFault->ComputedFaultCurvePoints(TRUE);
|
|
|
|
|
|
m_pFault->FaultReCut();
|
|
|
m_pItemSection->Select(m_pFault);
|
|
|
CItemFault* pItemFault = new CItemFault(GetDoc());
|
|
|
pItemFault->SetPos(GetPos());
|
|
|
//pItemFault->position;
|
|
|
//m_pItemSection->m_pObj = m_pFault;
|
|
|
//m_pItemSection->m_pItem = pItemFault;
|
|
|
pItemFault->SetDrawObj(m_pFault);
|
|
|
//CXTPPropertyGrid &grid = GetPropertyGrid(GetDoc()->GetMainFrame());
|
|
|
//pItemFault->InitPropertyGrid(grid);
|
|
|
pItemFault->SetItemSection(m_pItemSection);
|
|
|
|
|
|
CMultiWellSectionView* pSectionView = (CMultiWellSectionView*)GetView();
|
|
|
pSectionView->m_pWndCallBack(eWellPoleCallbackMsgDef::tInvalidateWnd, 0);
|
|
|
|
|
|
ReleaseCapture();
|
|
|
m_pItemSection->SetItem(pItemFault); //<2F><><EFBFBD>ú<EFBFBD>,<2C><>CItemAddFault<6C><74>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD>
|
|
|
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Invalidate();
|
|
|
ReleaseCapture();
|
|
|
}
|
|
|
|
|
|
int CItemAddFault::OnMouseMove(CDC *pDC, UINT nFlags, CPoint point)
|
|
|
{
|
|
|
CPoint2D lastPoint = GetDC()->GetReal(point);
|
|
|
if(IsCaptureState())
|
|
|
{
|
|
|
OnDraw(GetDC(),pDC);
|
|
|
|
|
|
m_lastPoint = point;
|
|
|
OnDraw(GetDC(),pDC);
|
|
|
|
|
|
}
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
BOOL CItemAddFault::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
|
|
|
{
|
|
|
::SetCursor(AfxGetApp()->LoadCursor(IDC_CROSS));
|
|
|
return TRUE;
|
|
|
}
|
|
|
|
|
|
BOOL CItemAddFault::OnSetCursor(CPoint pt, int& handle)
|
|
|
{
|
|
|
handle = 15;
|
|
|
return TRUE;
|
|
|
}
|
|
|
|
|
|
void CItemAddFault::OnRButtonDown(UINT nFlags, CPoint point)
|
|
|
{
|
|
|
//OnLButtonDown(NULL,nFlags, point,0);
|
|
|
m_bLDown = FALSE;
|
|
|
CItem::OnRButtonDown(nFlags, point);
|
|
|
delete m_pFault;
|
|
|
m_pFault = NULL;
|
|
|
m_pItemSection->OnLButtonDblClk(nFlags, point);
|
|
|
}
|
|
|
|
|
|
|
|
|
CWellBaseObj* CItemAddFault::GetDrawObj()
|
|
|
{
|
|
|
return m_pFault;
|
|
|
}
|
|
|
} |