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.

2984 lines
76 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// WellPoleView.cpp: 实现文件
//
#include "stdafx.h"
#include "../../ItemBkGrid.h"
#include "../../PublicParam.h"
#include <list>
#include <algorithm>
#include "WellPoleLib/WellBaseObj.h"
#include "WellPoleLib/InTrackDepthSegment.h"
#include "WellPoleLib/TrackObj.h"
#include "WellPoleLib/InclinedTrack.h"
#include "WellPoleLib/InTrackLith.h"
#include "WellPoleLib/InTrackSymbol.h"
#include "WellPoleLib/InTrackResult.h"
#include "WellPoleLib/InTrackTextRange.h"
#include "WellPoleLib/TrackGroup.h"
#include "WellPoleLib/WellPole.h"
#include "WellPoleLib/TrackDepth.h"
#include "WellPoleLib/TrackCurve.h"
#include "WellPoleLib/TrackSymbol.h"
#include "WellPoleLib/TrackResult.h"
#include "WellPoleLib/TrackLith.h"
#include "WellPoleLib/TrackText.h"
#include "MultiWellSectionLib/SectionWellObj.h"
#include "MultiWellSectionLib/BendObj.h"
#include "MultiWellSectionLib/FaultObj.h"
#include "MultiWellSectionLib/WellSection.h"
#include "ItemWcsTrackIn.h"
#include "ItemWcsSingleWell.h"
#include "ItemSectionWell.h"
#include "ItemAddBend.h"
#include "ItemAddFault.h"
#include "ItemBend.h"
#include "ItemFault.h"
#include "ItemWcsTrack.h"
#include "ItemWcsTrackIn.h"
#include "MultiWellSectionDoc.h"
#include "MultiWellSectionlView.h"
#include "DrawOperator/LibraryManager.h"
//定时ID号(OnTimer)
// WellPoleView
//CLIPFORMAT CMultiWellSectionView::m_clipboardDraw = (CLIPFORMAT)::RegisterClipboardFormat(_T("SSDrawerClipboard"));
//CLIPFORMAT CMultiWellSectionView::m_cfObjectDescriptor = NULL;
CMultiWellSectionView::CMultiWellSectionView()
{
Initialize();
InitSelectBmpDC();
m_bTracking = false;
}
CMultiWellSectionView::CMultiWellSectionView(CXy* pXy)
:CMultiWellSectionView()
{
InitSelectBmpDC();
m_bTracking = false;
m_pDoc->m_pXy = pXy;
}
CMultiWellSectionView::~CMultiWellSectionView()
{
DeleteSelectBmpDC();
}
void CMultiWellSectionView::Initialize()
{
if (m_pDoc)
delete m_pDoc;
m_pDoc = new CMultiWellSectionDoc();
m_pDoc->SetView(this);
m_pItemBkGrid->SetDoc(m_pDoc);
m_bFirstSize = TRUE;
m_pWndCallBack = NULL;
}
// WellPoleView 绘图
void CMultiWellSectionView::SetLastRightButtonPoint(const CPoint& point)
{
CSigmaView::SetLastRightButtonPoint(point);
m_PrevPointXY = point;
}
void CMultiWellSectionView::OnDrawAllAfter(CXyDC& dc)
{
CSigmaView::OnDrawAllAfter(dc);
}
// WellPoleView 诊断
void CMultiWellSectionView::OnSize(UINT nType, int cx, int cy)
{;
if (cx < 1 || cy < 1)
return;
//CreateSelectBmpDC(cx, cy);
if (m_bFirstSize)
{
m_bFirstSize = FALSE;
}
m_pDoc->Invalidate();
}
CMultiWellSectionDoc* CMultiWellSectionView::GetDocument() const
{
return (CMultiWellSectionDoc*)m_pDoc;
}
BOOL CMultiWellSectionView::IsViewState()
{
CMultiWellSectionDoc *pDoc = (CMultiWellSectionDoc*)m_pDoc;
if (pDoc->GetItemView()->GetType() != 0 /*|| ::IsKeyDown(GetPanKey())*/)
return TRUE;
return FALSE;
}
void CMultiWellSectionView::OnLButtonDown(int mouseX, int mouseY, HDC hdc, int vk)
{
if (IsViewState())
{
//int typeBak = pDoc->GetItemView().GetType();
//if (::IsKeyDown(GetPanKey())) pDoc->GetItemView().SetType(ID_VIEW_PAN);
CMultiWellSectionDoc *pWDoc = (CMultiWellSectionDoc *)m_pDoc;
CDC *pDC = CDC::FromHandle(hdc);
SetScreenDC(pDC);
CPoint pt;
pt.x = mouseX;
pt.y = mouseY;
int nFlags = 0;
pWDoc->GetItemView()->OnLButtonDown(pDC, 0, pt, vk);
//if (::IsKeyDown(GetPanKey())) pDoc->GetItemView().SetType(typeBak);
m_PrevPointXY.x = mouseX;
m_PrevPointXY.y = mouseY;
return;
}
CSigmaView::OnLButtonDown(mouseX, mouseY, hdc, vk);
m_PrevPointXY.x = mouseX;
m_PrevPointXY.y = mouseY;
}
void CMultiWellSectionView::OnLButtonDownOther(int mouseX, int mouseY, HDC hdc, int vk)
{
CMultiWellSectionDoc* pDoc = GetDocument();
if (pDoc->GetItem())
{
CItem* pItem = pDoc->GetItem();
pItem->m_client = m_client;
CPoint pt;
pt.x = mouseX;
pt.y = mouseY;
CItem* pOldItem = pDoc->GetItem();
CDC *pDC = NULL;
if (hdc != NULL)
{
pDC = CDC::FromHandle(hdc);
pItem->SetScreenDC(pDC);
pItem->SetBackGroundDC(m_pImgDC);
}
if (pDC == NULL)
return;
CPoint2D ptReal = pDoc->GetDC().GetReal(pt);
CRect8 rectReal = pDoc->GetSelectedRect(ptReal);
BOOL bIn = FALSE;
CPtrList* pList = pDoc->GetDraw()->GetValueList();
////对象链表
pList = pDoc->GetDraw()->GetValueList();
POSITION pos = pList->GetHeadPosition();
while (NULL != pos)
{
COne* pOne = (COne*)pList->GetAt(pos);
if (pOne->GetType() != KEP_WELLSECTION)
{
bIn = pOne->IsInRange(rectReal);
if (bIn)
{
if ((pItem->GetType() != ITEM_SELECT && !pItem->IsNestItem()) || (pItem->GetType() == KEP_WELLSECTION && pItem->IsNestItem()))
{
m_pWndCallBack(tSetItemForElement, vSetSelectItem);
}
break;
}
}
pList->GetNext(pos);
}
BOOL bInSection = FALSE;
if (!bIn)
{
pos = pList->GetHeadPosition();
while (NULL != pos)
{
COne* pOne = (COne*)pList->GetAt(pos);
if (pOne->GetType() == KEP_WELLSECTION)
{
if (pOne->IsInRange(rectReal))
{
bInSection = TRUE;
if (pItem->GetType() != ITEM_WELLSECTION)
{
CItemWellSection* pItemWellSection = new CItemWellSection(GetDocument());
pItemWellSection->SetPos(pos);
//pItemWellSection->SetDrawObj((CWellBaseObj*)pOne->GetValue());
pDoc->SetItem(pItemWellSection);
}
break;
}
}
pList->GetNext(pos);
}
if (!bInSection)
{
if (pItem->GetType() == ITEM_WELLSECTION /*&& pItem->IsInEdit()*/)
{
CItemWellSection *pItemSection = (CItemWellSection *)pItem;
BOOL bSet = TRUE;
if (pItemSection->GetItem() != NULL && pItemSection->GetItem()->GetType() == ITEM_ADDFAULT)
bSet = FALSE;
if (bSet)
pDoc->SetItem(pDoc->FindItem(ITEM_SELECT));
}
}
}
if (pDoc->GetItem() != pOldItem && pDoc->GetItem()->GetType() != ITEM_WELLSECTION)
pDoc->Invalidate();
}
//else if (pDoc->GetOtherItem())
// pDoc->GetOtherItem()->OnLButtonDown(nFlags, point);
}
int CMultiWellSectionView::OnMouseMove(HDC hMemDC, int mouseX, int mouseY, int buttonStatus)
{
if (!m_bTracking)
{
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(tme);
tme.hwndTrack = GetHWND();
tme.dwFlags = TME_LEAVE | TME_HOVER;
tme.dwHoverTime = 1;
m_bTracking = _TrackMouseEvent(&tme);
}
if (IsViewState())
{
//int typeBak = pDoc->GetItemView().GetType();
//if (::IsKeyDown(GetPanKey())) pDoc->GetItemView().SetType(ID_VIEW_PAN);
CMultiWellSectionDoc *pWDoc = (CMultiWellSectionDoc *)m_pDoc;
CDC *pDC = CDC::FromHandle(hMemDC);
SetScreenDC(pDC);
CPoint pt;
pt.x = mouseX;
pt.y = mouseY;
int nFlags = 0;
pWDoc->GetItemView()->OnMouseMove(pDC, nFlags, pt);
//if (::IsKeyDown(GetPanKey())) pDoc->GetItemView().SetType(typeBak);
return 1;
}
return CSigmaView::OnMouseMove(hMemDC, mouseX, mouseY, buttonStatus);
}
void CMultiWellSectionView::OnMouseWheelOther(UINT nFlags, short zDelta, CPoint pt)
{
CMultiWellSectionDoc* pDoc = GetDocument();
if (pDoc->GetSelectItem())
pDoc->GetSelectItem()->ReloadTrackerPath();
}
CMenu* CMultiWellSectionView::ExtendPopupMenu(CItem* pItem, CMenu* pMenu)
{
if (pMenu == NULL) return NULL;
CMultiWellSectionDoc* pDoc = GetDocument();
CMenu* pPopup = pMenu->GetSubMenu(3);
if (pItem == NULL) return pPopup;
int sub = pItem->GetSubMenu();
if (sub >= 0)
pPopup = pMenu->GetSubMenu(sub);
else if (pItem->GetType() == ITEM_SELECT &&
GetSelection()->GetCount() == 1 &&
pPopup != NULL)
{
//在缺省菜单[编辑]项之前增加扩展菜单
int index = FindMenuItem(pPopup, ID_EDIT_TOOL);
CPositionList *plist = GetSelection();
POSITION pos = plist->GetHead();
if (pos && index >= 0)
{
COne* pOne = (COne*)pDoc->GetDraw()->GetAt(pos);
CMenu* psub = NULL;
CString strTitle;
switch (pOne->GetType())
{
case DOUBLEFOX_WMF:
psub = pMenu->GetSubMenu(17);
strTitle.LoadString(IDS_STRING_META_FILE);
break;
case DOUBLEFOX_IMAGE: //图像自动矢量化
psub = pMenu->GetSubMenu(1);
strTitle.LoadString(IDS_STRING_IMAGE_TRACE);
break;
case DOUBLEFOX_NET: //根据经纬网生成直角网及边框
psub = pMenu->GetSubMenu(7);
strTitle.LoadString(IDS_STRING_CREATE_WITH_NET);
break;
case DOUBLEFOX_SCALERULER:
psub = pMenu->GetSubMenu(20);
strTitle.LoadString(IDS_STRING_DISSOLUTION_ELEMENT);
break;
case DOUBLEFOX_GRID: //根据直角网生成经纬网及边框
psub = pMenu->GetSubMenu(8);
strTitle.LoadString(IDS_STRING_CREATE_WITH_GRID);
break;
case DOUBLEFOX_OLE:
psub = pMenu->GetSubMenu(9);
strTitle.LoadString(IDS_STRING_OLE_LINK);
strTitle += _T("(&L)"); //加上快捷键
break;
case DOUBLEFOX_INSERT:
case DOUBLEFOX_DRAW:
psub = pMenu->GetSubMenu(10);
strTitle.LoadString(IDS_SELECT_ELEMENT);
strTitle += _T("(&L)"); //加上快捷键
break;
case DOUBLEFOX_MESH:
psub = pMenu->GetSubMenu(11);
strTitle.LoadString(IDS_STRING_MESH_TITLE);
break;
case DOUBLEFOX_SECTION:
psub = pMenu->GetSubMenu(15);
strTitle.LoadString(IDS_GI_SECTION);
break;
}
if (psub)
{
pPopup->InsertMenu(index, MF_BYPOSITION | MF_SEPARATOR);
pPopup->InsertMenu(index, MF_BYPOSITION | MF_POPUP, (UINT_PTR)psub->GetSafeHmenu(), strTitle);
}
}
}
else if (pItem->GetType() == ITEM_SELECT &&
GetSelection()->GetCount() == 2 &&
pPopup != NULL)
{
int index = FindMenuItem(pPopup, ID_EDIT_TOOL);
CPositionList *plist = GetSelection();
int n = plist->GetCount();
POSITION pos = plist->GetHead();
COne* pOne1 = (COne*)pDoc->GetDraw()->GetAt(pos);
plist->GetNext(pos);
COne* pOne2 = (COne*)pDoc->GetDraw()->GetAt(pos);
//if (pOne1->GetType() == DOUBLEFOX_WELL && pOne2->GetType() == DOUBLEFOX_WELL)
//{
// MENUITEMINFO item;
// item.fMask = MIIM_ID | MIIM_STRING;
// item.fType = MFT_STRING;
// item.fState = MFS_ENABLED;
// item.wID = ID_WELL_STRATUM_CONNECTION;
// item.hSubMenu = NULL;
// item.hbmpChecked = NULL;
// item.hbmpUnchecked = NULL;
// item.dwTypeData = _T("生成地层连线");
// item.cch = strlen(_T("生成地层连线"));
// item.cbSize = sizeof(item);
// pPopup->InsertMenuItem(0, &item, TRUE);
//}
}
return pPopup;
}
CPositionList* CMultiWellSectionView::GetSelection(void)
{
CMultiWellSectionDoc* pDoc = GetDocument();
if (pDoc->GetItem() == NULL) return NULL;
if (pDoc->GetItem()->GetType() != ITEM_SELECT) return NULL;
return &(((CItemSelect*)pDoc->GetItem())->m_selection);
}
int CMultiWellSectionView::FindMenuItem(CMenu* Menu, LPCTSTR MenuString)
{
ASSERT(Menu);
ASSERT(::IsMenu(Menu->GetSafeHmenu()));
int count = Menu->GetMenuItemCount();
for (int i = 0; i < count; i++)
{
CString str;
if (Menu->GetMenuString(i, str, MF_BYPOSITION) &&
(strcmp(str, MenuString) == 0))
return i;
}
return -1;
}
// FindMenuItem() will find a menu item ID from the specified
// popup menu and returns its position (0-based) in the specified
// popup menu. It returns -1 if no such menu item ID is found.
int CMultiWellSectionView::FindMenuItem(CMenu* Menu, UINT nID)
{
ASSERT(Menu);
ASSERT(::IsMenu(Menu->GetSafeHmenu()));
int count = Menu->GetMenuItemCount();
for (int i = 0; i < count; i++)
{
if (Menu->GetMenuItemID(i) == nID)
return i;
}
return -1;
}
void CMultiWellSectionView::ExtendViewForNewWell(CWellPole* pWell)
{
CRect8 rect;
GetDocument()->GetDrawRange(rect);
CRect window;
window = GetClientRect();
if (window.Width() < 100)
window.SetRect(0, 0, 640, 480);
GetDocument()->GetDC().Extend(rect, window, EXTEND_MODE_WIDTH);
GetDocument()->Invalidate();
}
void CMultiWellSectionView::OnAddWellTrack()
{
CItem *pItem = GetDocument()->GetItem();
if (NULL == pItem)
return;
CItemWcsSingleWell *pItemWell = NULL;
if (pItem->GetType() == ITEM_WELLSECTION || pItem->GetType() == ITEM_WELLFENCE)
{
CItemWellSection* pItemWellSection = (CItemWellSection*)pItem;
if (pItemWellSection->GetItem() != NULL)
{
pItemWell = (CItemSectionWell *)(pItemWellSection->GetItem());
pItemWell->AddTrack();
CWellPole* pWell = (CWellPole*)pItemWell->GetWellObject();
CWellSection* pSection = (CWellSection*)pItemWellSection->GetWellSection();
pSection->ReComputeBends(pWell);
pSection->ReSetPosition();
}
}
}
void CMultiWellSectionView::InitSelectBmpDC()
{
m_bSelectCreateDC = FALSE;
m_pSelectBmp = NULL;
m_ViewSelW = 8;
m_ViewSelH = 8;
}
void CMultiWellSectionView::CreateSelectBmpDC(int ww, int hh)
{
CDC *pDC = this->m_pImgDC; //GetDC()->GetDC(); //CWnd::GetDC();
if (pDC == NULL)
return;
m_ViewSelH = hh;
m_ViewSelW = ww;
if (m_ViewSelW < 8)
m_ViewSelW = 8;
if (m_ViewSelH < 8)
m_ViewSelH = 8;
if (m_bSelectCreateDC)
{
m_SelectDC.SelectObject(m_pSelectBmp);
m_SelectBmp.DeleteObject();
m_SelectBmp.CreateCompatibleBitmap(pDC, m_ViewSelW, m_ViewSelH);
m_pSelectBmp = m_SelectDC.SelectObject(&m_SelectBmp);
}
else
{
m_SelectDC.CreateCompatibleDC(pDC);
m_SelectBmp.CreateCompatibleBitmap(pDC, m_ViewSelW, m_ViewSelH);
m_pSelectBmp = m_SelectDC.SelectObject(&m_SelectBmp);
m_bSelectCreateDC = TRUE;
}
}
void CMultiWellSectionView::DeleteSelectBmpDC()
{
if (m_pSelectBmp)
{
m_SelectDC.SelectObject(m_pSelectBmp);
m_SelectBmp.DeleteObject();
m_SelectDC.DeleteDC();
}
}
void CMultiWellSectionView::BeginSelectBmpDC()
{
CBrush bru;
bru.CreateSolidBrush(RGB(255, 255, 255));
m_SelectDC.SetMapMode(MM_TEXT);
m_SelectDC.SetWindowOrg(0, 0);
m_SelectDC.SetViewportOrg(0, 0);
m_SelectDC.SetBrushOrg(0, 0);
m_SelectDC.FillRect(CRect(0, 0, m_ViewSelW, m_ViewSelH), &bru);
bru.DeleteObject();
//CMapWnd2D::PrepareDC(&m_SelectDC);
}
void CMultiWellSectionView::EndItemSelectBmpDC(CDC *pDC)
{
CDC* tdc = this->m_pImgDC;
if (pDC == NULL)
{
pDC = tdc; // &dc;
}
//GetMemDC()->SetMapMode(MM_TEXT);
//GetMemDC()->SetViewportOrg(0, 0);
//GetMemDC()->SetWindowOrg(0, 0);
//CRect client;
////pDC->GetClipBox(client);
//client = this->GetClientRect();
//pDC->BitBlt(client.left, client.top, client.Width(), client.Height(), GetMemDC(), 0, 0, SRCCOPY);
EndSelectBmpDC(pDC);
}
void CMultiWellSectionView::EndSelectBmpDC(CDC *pDC)
{
pDC->SetMapMode(MM_TEXT);
pDC->SetWindowOrg(0, 0);
pDC->SetViewportOrg(0, 0);
pDC->SetBrushOrg(0, 0);
m_SelectDC.SetMapMode(MM_TEXT);
m_SelectDC.SetWindowOrg(0, 0);
m_SelectDC.SetViewportOrg(0, 0);
m_SelectDC.SetBrushOrg(0, 0);
pDC->BitBlt(0, 0, m_ViewSelW, m_ViewSelH, &m_SelectDC, 0, 0, SRCAND);
}
void CMultiWellSectionView::OnEditDelete()
{
CMultiWellSectionDoc* pDoc = GetDocument();
if (pDoc->GetSelectItem())
pDoc->GetSelectItem()->DeleteSelection();
}
void CMultiWellSectionView::OnTrackLeftGroup()
{
CMultiWellSectionDoc* pDoc = GetDocument();
CItem *pItem = pDoc->GetItem();
if (NULL == pItem)
return;
CItemWcsSingleWell *pItemWell = NULL;
if (pItem->GetType() == ITEM_WELLSECTION || pItem->GetType() == ITEM_WELLFENCE)
{
CItemWellSection* pItemWellSection = (CItemWellSection*)pItem;
if (pItemWellSection->GetItem() != NULL)
pItemWell = (CItemSectionWell *)(pItemWellSection->GetItem());
}
if (pItemWell == NULL)
return;
pItemWell->TrackLeftGroup();
m_pDoc->Invalidate();
}
void CMultiWellSectionView::OnTrackRightGroup()
{
CMultiWellSectionDoc* pDoc = GetDocument();
CItem *pItem = pDoc->GetItem();
if (NULL == pItem)
return;
CItemWcsSingleWell *pItemWell = NULL;
if (pItem->GetType() == ITEM_WELLSECTION || pItem->GetType() == ITEM_WELLFENCE)
{
CItemWellSection* pItemWellSection = (CItemWellSection*)pItem;
if (pItemWellSection->GetItem() != NULL)
pItemWell = (CItemSectionWell *)(pItemWellSection->GetItem());
}
if (pItemWell == NULL)
return;
pItemWell->TrackRightGroup();
m_pDoc->Invalidate();
}
void CMultiWellSectionView::OnAddTrackAfterSelected()
{
CMultiWellSectionDoc* pDoc = GetDocument();
CItem *pItem = pDoc->GetItem();
if (NULL == pItem)
return;
CItemWcsSingleWell *pItemWell = NULL;
if (pItem->GetType() == ITEM_WELLSECTION || pItem->GetType() == ITEM_WELLFENCE)
{
CItemWellSection* pItemWellSection = (CItemWellSection*)pItem;
if (pItemWellSection->GetItem() != NULL)
pItemWell = (CItemSectionWell *)(pItemWellSection->GetItem());
if (pItemWell->AddTrackAfterSelected())
{
CWellPole* pWell = (CWellPole*)pItemWell->GetWellObject();
CWellSection* pSection = (CWellSection*)pItemWellSection->GetWellSection();
pSection->ReComputeBends(pWell);
}
}
}
void CMultiWellSectionView::OnViewTrackData()
{
CMultiWellSectionDoc* pDoc = (CMultiWellSectionDoc*)(GetDocument());
CItem *pItem = pDoc->GetItem();
if (NULL == pItem)
return;
CItemWcsSingleWell *pItemWell = NULL;
if (pItem->GetType() == ITEM_WELLSECTION || pItem->GetType() == ITEM_WELLFENCE)
{
CItemWellSection* pItemWellSection = (CItemWellSection*)pItem;
if (pItemWellSection->GetItem() != NULL)
pItemWell = (CItemSectionWell *)(pItemWellSection->GetItem());
}
if (pItemWell != NULL)
pItemWell->AddTrackInObjData();
}
void CMultiWellSectionView::OnViewExtend()
{
//CMultiWellSectionDoc* pDoc = GetDocument();
//pDoc->GetItemView().Extend(EXTEND_MODE_DEFAULT);
//pDoc->InvalidateAttachView(); //是否进行绑定更新其它视图
OnViewExtendCenter();
}
void CMultiWellSectionView::OnViewExtendCenter()
{
CMultiWellSectionDoc* pDoc = GetDocument();
pDoc->GetItemView()->Extend(EXTEND_MODE_CENTER);
}
void CMultiWellSectionView::OnViewExtendHeight()
{
CMultiWellSectionDoc* pDoc = GetDocument();
pDoc->GetItemView()->Extend(EXTEND_MODE_HEIGHT);
}
void CMultiWellSectionView::OnViewExtendWidth()
{
CMultiWellSectionDoc* pDoc = GetDocument();
pDoc->GetItemView()->Extend(EXTEND_MODE_WIDTH);
}
void CMultiWellSectionView::SetScrollBarRange(void)
{
CMultiWellSectionDoc* pDoc = GetDocument();
}
BOOL CMultiWellSectionView::MouseWheel(UINT nFlags, short zDelta, CPoint pt)
{
CMultiWellSectionDoc* pDoc = GetDocument();
CPoint offsetpt = CPoint(0, 0);
switch (nFlags)
{
case 0:
//上下移动图件
MouseWheelV(nFlags, zDelta, pt);
break;
case 1:
//左右移动图件
{
if (fabs(zDelta) > 0)
{
int pp = 0;
}
MouseWheelH(nFlags, zDelta, pt);
}
break;
}
return TRUE;
}
BOOL CMultiWellSectionView::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
{
CMultiWellSectionDoc* pDoc = GetDocument();
if (pDoc->GetDraw() == NULL || pDoc->GetDraw()->GetCount() == 0)
return TRUE;
return MouseWheel(nFlags, zDelta, pt);
return TRUE;
}
BOOL CMultiWellSectionView::MouseWheelH(UINT nFlags, short zDelta, CPoint pt)
{
CMultiWellSectionDoc* pDoc = GetDocument();
CXyDC* pdc = &pDoc->GetDC();
CRect crt;
crt = GetClientRect();
CRect8 rcScreenReal = pdc->GetReal(crt);
rcScreenReal.NormalizeRect();
CRect8 range;
pDoc->GetDrawRange(range);
double OneLine = pdc->GetRealWidth((long)zDelta); //一行的实际单位数
if (range.Width() < rcScreenReal.Width())
{//当图的范围小于屏幕范围时,(这时图的左侧或右侧,移动时不要超过屏幕的左右侧范围)
if (OneLine < 0)
{//往左滚动
if ((range.left + OneLine) < rcScreenReal.left)
{
OneLine = range.left - rcScreenReal.left;
}
if (OneLine >= 0)
return FALSE;
pdc->OffsetRect(-OneLine, 0);
}
else
{
if ((range.right + OneLine) > rcScreenReal.right)
{
OneLine = rcScreenReal.right - range.right;
}
if (OneLine <= 0)
return FALSE;
pdc->OffsetRect(-OneLine, 0);
}
}
else
{/*当图的范围大于屏幕范围时,(这时如果向右侧移动时,当图的左侧进入屏幕的左侧范围,就可以停止移动,
如果向左侧移动,图的右侧范围进入屏幕的右侧,就可以停止移动)*/
if (OneLine < 0)
{//往左滚动
if ((range.right + OneLine) < rcScreenReal.right)
{
OneLine = 0;// range.left - rcScreenReal.left;
}
if (OneLine >= 0)
return FALSE;
pdc->OffsetRect(-OneLine, 0);
}
else
{
if ((range.left + OneLine) > rcScreenReal.left)
{
OneLine = 0;// rcScreenReal.right - range.right;
}
if (OneLine <= 0)
return FALSE;
pdc->OffsetRect(-OneLine, 0);
}
}
int offset = pdc->GetScreenWidth(OneLine);
if (offset != 0)
{
//ScrollWindow(offset, 0);
m_pDoc->Invalidate();
OnMouseWheelOther(nFlags, zDelta, pt);
}
return TRUE;
}
BOOL CMultiWellSectionView::MouseWheelV(UINT nFlags, short zDelta, CPoint pt)
{
CMultiWellSectionDoc* pDoc = GetDocument();
CXyDC* pdc = &pDoc->GetDC();
CRect crt;
crt = GetClientRect();
CRect8 rcScreenReal = pdc->GetReal(crt);
rcScreenReal.NormalizeRect();
double OneLine = pdc->GetRealHeight((long)zDelta/*ol*/); //一行的实际单位数
CRect8 range;
pDoc->GetDrawRange(range);
if (range.Height() > rcScreenReal.Height())
{//图的显示范围大于屏幕
if (OneLine < 0)
{//显示井柱往上部分
if (rcScreenReal.top - OneLine >= range.top)
OneLine = rcScreenReal.top - range.top;
if (OneLine >= 0)
return FALSE;
pdc->OffsetRect(0, -OneLine);
}
else
{
if (rcScreenReal.bottom - OneLine <= range.bottom)
OneLine = rcScreenReal.bottom - range.bottom;
if (OneLine <= 0)
return FALSE;
pdc->OffsetRect(0, -OneLine);
}
}
else
{ //图形小于屏幕
if (OneLine < 0)
{//显示井柱往上部分 ,图的底部不低于屏幕的底部
if ((range.bottom + OneLine) < rcScreenReal.bottom)
OneLine = rcScreenReal.bottom - range.bottom;
if (OneLine >= 0)
return FALSE;
pdc->OffsetRect(0, -OneLine);
}
else
{//图的顶部不高于屏幕的顶部
if ((range.top + OneLine) > rcScreenReal.top)
OneLine = rcScreenReal.top - range.top;
if (OneLine <= 0)
return FALSE;
pdc->OffsetRect(0, -OneLine);
}
}
int offset = pdc->GetScreenHeight(OneLine);
if (offset != 0)
{
pDoc->Invalidate();
OnMouseWheelOther(nFlags, zDelta, pt);
}
return TRUE;
}
void CMultiWellSectionView::OnViewPan()
{
CMultiWellSectionDoc* pDoc = GetDocument();
CItemView* pItem = pDoc->GetItemView();
if (pItem == NULL)
return;
if (pItem->GetType() == ID_VIEW_PAN_WELL || pItem->GetType() == ID_VIEW_PAN)
{
pItem->SetType(0);
pDoc->SetDefaultCursor();
}
else
{
pItem->SetType(ID_VIEW_PAN);
pDoc->SetDefaultCursor();
}
}
void CMultiWellSectionView::OnViewEnlarge()
{
CMultiWellSectionDoc* pDoc = GetDocument();
CRect srect;
srect = GetClientRect();
CRect8 oldRect = pDoc->GetDC().GetReal(srect);
pDoc->GetItemView()->Enlarge();
CRect8 newRect = pDoc->GetDC().GetReal(srect);
CPoint2D deltPt;
deltPt.x0 = newRect.CenterPoint().x0 - oldRect.CenterPoint().x0;
deltPt.y0 = newRect.CenterPoint().y0 - oldRect.CenterPoint().y0;
pDoc->GetDC().OffsetRect(-deltPt.x0, -deltPt.y0);
}
void CMultiWellSectionView::OnViewReduce()
{
CMultiWellSectionDoc* pDoc = GetDocument();
CRect srect;
srect = GetClientRect();
CRect8 oldRect = pDoc->GetDC().GetReal(srect);
pDoc->GetItemView()->Reduce();
CRect8 newRect = pDoc->GetDC().GetReal(srect);
CPoint2D deltPt;
deltPt.x0 = newRect.CenterPoint().x0 - oldRect.CenterPoint().x0;
deltPt.y0 = newRect.CenterPoint().y0 - oldRect.CenterPoint().y0;
pDoc->GetDC().OffsetRect(-deltPt.x0, -deltPt.y0);
}
void CMultiWellSectionView::DrawCrossLine(CDC* pDC, CPoint point)
{
if (!m_bTracking)
return;
//CMultiWellSectionDoc* pDoc = GetDocument();
//CWellPole* pWell = pDoc->GetWellPole();
//if (pDoc->GetWellPole() != NULL)
//{
// CRect8 wRect = pWell->GetRect();
// wRect.top = wRect.top - pWell->m_dHeightTrackHead - pWell->m_dHeightWellHead;
// CRect sWRect = pDoc->GetDC().GetScreen(wRect);
// sWRect.NormalizeRect();
// if (point.y >= sWRect.bottom || point.y <= sWRect.top)
// return;
//}
//CRect rt; this->GetClientRect(rt);
//int nOldRop = pDC->SetROP2(R2_NOTXORPEN);
////pDC->MoveTo(point.x, rt.top);
////pDC->LineTo(point.x, rt.bottom);
//pDC->MoveTo(rt.left, point.y);
//pDC->LineTo(rt.right, point.y);
//pDC->SetROP2(nOldRop);
//if (GetItemToolTip() != NULL)
//{
// CPoint2D ptDown = pDoc->GetDC().GetReal(point);
// double depth = pWell->ScreenYToDepth(ptDown.y0);
// CString str;
// str.Format("%.2f", depth);
// GetItemToolTip()->CItemToolTip::SetTooltipText(str);
//}
}
void CMultiWellSectionView::OnMouseLeave()
{
m_PrevPointXY.SetPoint(-100, -100);
m_bTracking = FALSE;
}
void CMultiWellSectionView::DrawOneCrossLine(CPoint currentPoint)
{
}
BOOL CMultiWellSectionView::OnBreakLeftBend()
{
BOOL b = FALSE;
CMultiWellSectionDoc* pDoc = GetDocument();
CItem *pItem = pDoc->GetItem();
if (NULL == pItem)
return b;
CItemWcsTrackIn *pItemTrackIn = NULL;
if (pItem->GetType() == ITEM_WELLSECTION)
{
CItemWellSection* pItemSection = (CItemWellSection*)pItem;
if (NULL != pItemSection)
pItemSection->SetReUnDoAction();
if (pItemSection->GetItem() != NULL)
{
CItemWellBase* pItemWell = (CItemWellBase*)pItemSection->GetItem();
POSITION pos = pItemWell->m_WellObjSelectlist.GetHeadPosition();
while (pos != NULL)
{
CWellBaseObj* pObj = pItemWell->m_WellObjSelectlist.GetNext(pos);
CWellSection* pSection = (CWellSection*)pItemSection->GetWellSection();
POSITION posBend = pSection->m_BendList.GetHeadPosition();
while (posBend != NULL)
{
CBendObj * pBend = (CBendObj *)pSection->m_BendList.GetNext(posBend);
if (pBend->m_pLayerLeft == pObj)
{
if (pBend->m_ptArrControls[0].X < pBend->m_pLayerLeft->GetPos().left)
{
pSection->DeleteBend(pBend);
}
}
if ((pBend->m_pLayerRight != NULL && pBend->m_pLayerRight == pObj))
{
if (pBend->m_ptArrControls[0].X < pBend->m_pLayerRight->GetPos().left)
pSection->DeleteBend(pBend);
}
}
}
m_pDoc->Invalidate();
b = TRUE;
}
}
return b;
}
BOOL CMultiWellSectionView::OnBreakRightBend()
{
CMultiWellSectionDoc* pDoc = GetDocument();
CItem *pItem = pDoc->GetItem();
if (NULL == pItem)
return FALSE;
BOOL b = FALSE;
CItemWcsTrackIn *pItemTrackIn = NULL;
if (pItem->GetType() == ITEM_WELLSECTION)
{
CItemWellSection* pItemSection = (CItemWellSection*)pItem;
if (NULL != pItemSection)
pItemSection->SetReUnDoAction();
if (pItemSection->GetItem() != NULL)
{
CItemWellBase* pItemWell = (CItemWellBase*)pItemSection->GetItem();
POSITION pos = pItemWell->m_WellObjSelectlist.GetHeadPosition();
while (pos != NULL)
{
CWellBaseObj* pObj = pItemWell->m_WellObjSelectlist.GetNext(pos);
CWellSection* pSection = (CWellSection*)pItemSection->GetWellSection();
POSITION posBend = pSection->m_BendList.GetHeadPosition();
while (posBend != NULL)
{
CBendObj * pBend = (CBendObj *)pSection->m_BendList.GetNext(posBend);
if (pBend->m_pLayerLeft == pObj)
{
if (pBend->m_ptArrControls[0].X > pBend->m_pLayerLeft->GetPos().left)
{
pSection->DeleteBend(pBend);
}
}
if ((pBend->m_pLayerRight != NULL && pBend->m_pLayerRight == pObj))
{
if (pBend->m_ptArrControls[0].X > pBend->m_pLayerRight->GetPos().left)
pSection->DeleteBend(pBend);
}
}
}
m_pDoc->Invalidate();
b = TRUE;
}
}
return b;
}
BOOL CMultiWellSectionView::OnNameConnectLeft()
{
CMultiWellSectionDoc* pDoc = GetDocument();;
CItem *pItem = pDoc->GetItem();
if (NULL == pItem)
return FALSE;
BOOL b = FALSE;
if (pItem->GetType() == ITEM_WELLSECTION)
{
CItemWellSection* pItemSection = (CItemWellSection*)pItem;
if (NULL != pItemSection)
pItemSection->SetReUnDoAction();
if (pItemSection->GetItem() != NULL)
{
CItemWellBase* pItemWell = (CItemWellBase*)pItemSection->GetItem();
POSITION posSelect = pItemWell->m_WellObjSelectlist.GetHeadPosition();
while (posSelect != NULL)
{
CWellBaseObj* pObj = (CWellBaseObj*)pItemWell->m_WellObjSelectlist.GetNext(posSelect);
CTrackObj* pTrackObj = (CTrackObj*)pObj->GetParent();
if (pTrackObj->GetTrackType() == Track_Stratum || pTrackObj->GetTrackType() == Track_Result
|| pTrackObj->GetTrackType() == Track_StandardLayer || pTrackObj->GetTrackType() == Track_SandLayer)
{
CWellSection* pSection = (CWellSection*)pItemSection->GetWellSection();
POSITION posBend = pSection->m_BendList.GetHeadPosition();
std::vector<CWellBaseObj*> linkBends;
pItemSection->ConnectOnName(pObj, 1,linkBends);
if (pSection->m_bResForm)
{
for (int i = 0; i < linkBends.size(); i++)
{
CBendObj* pBend = (CBendObj*)linkBends[i];
pBend->ComputeBend();
WELLOBJLIST::iterator it = pBend->m_pLayerLeft->m_BendRightList.begin();
for (; it != pBend->m_pLayerLeft->m_BendRightList.end(); it++)//左连层中其它右侧层位受到影响
{
CBendObj *pBend1 = (CBendObj*)(*it);
if (pBend1 != pBend)
{
pBend1->ComputeBend();
}
}
}
}
}
}
b = TRUE;
m_pDoc->Invalidate();
}
}
return b;
}
BOOL CMultiWellSectionView::OnNameConnectRight()
{
CMultiWellSectionDoc* pDoc = GetDocument();
CItem *pItem = pDoc->GetItem();
if (NULL == pItem)
return FALSE;
BOOL b = FALSE;
if (pItem->GetType() == ITEM_WELLSECTION)
{
CItemWellSection* pItemSection = (CItemWellSection*)pItem;
if (NULL != pItemSection)
pItemSection->SetReUnDoAction();
if (pItemSection->GetItem() != NULL)
{
CItemWellBase* pItemWell = (CItemWellBase*)pItemSection->GetItem();
POSITION posSelect = pItemWell->m_WellObjSelectlist.GetHeadPosition();
while (posSelect != NULL)
{
CWellBaseObj* pObj = (CWellBaseObj*)pItemWell->m_WellObjSelectlist.GetNext(posSelect);
CTrackObj* pTrackObj = (CTrackObj*)pObj->GetParent();
if (pTrackObj->GetTrackType() == Track_Stratum || pTrackObj->GetTrackType() == Track_Result
|| pTrackObj->GetTrackType() == Track_StandardLayer || pTrackObj->GetTrackType() == Track_SandLayer)
{
CWellSection* pSection = (CWellSection*)pItemSection->GetWellSection();
POSITION posBend = pSection->m_BendList.GetHeadPosition();
std::vector<CWellBaseObj*> linkBends;
pItemSection->ConnectOnName(pObj, 2,linkBends);
if (pSection->m_bResForm)
{
for (int i = 0; i < linkBends.size(); i++)
{
CBendObj* pBend = (CBendObj*)linkBends[i];
pBend->ComputeBend();
WELLOBJLIST::iterator it = pBend->m_pLayerRight->m_BendLeftList.begin();
for (; it != pBend->m_pLayerRight->m_BendLeftList.end(); it++)//右连层中其它左侧层位受到影响
{
CBendObj *pBend1 = (CBendObj*)(*it);
if (pBend1 != pBend)
{
pBend1->ComputeBend();
}
}
}
}
}
}
m_pDoc->Invalidate();
b = TRUE;
}
}
return b;
}
BOOL CMultiWellSectionView::OnNameConnectAll()
{
CMultiWellSectionDoc* pDoc = GetDocument();
CItem *pItem = pDoc->GetItem();
if (NULL == pItem)
return FALSE;
BOOL b = FALSE;
if (pItem->GetType() == ITEM_WELLSECTION)
{
CItemWellSection* pItemSection = (CItemWellSection*)pItem;
if (NULL != pItemSection)
pItemSection->SetReUnDoAction();
if (pItemSection->GetItem() != NULL)
{
CItemWellBase* pItemWell = (CItemWellBase*)pItemSection->GetItem();
POSITION posSelect = pItemWell->m_WellObjSelectlist.GetHeadPosition();
while (posSelect != NULL)
{
CWellBaseObj* pObj = (CWellBaseObj*)pItemWell->m_WellObjSelectlist.GetNext(posSelect);
CTrackObj* pTrackObj = (CTrackObj*)pObj->GetParent();
if (pTrackObj->GetTrackType() == Track_Stratum || pTrackObj->GetTrackType() == Track_Result
|| pTrackObj->GetTrackType() == Track_SandLayer)
{
CWellSection* pSection = (CWellSection*)pItemSection->GetWellSection();
POSITION posBend = pSection->m_BendList.GetHeadPosition();
std::vector<CWellBaseObj*> linkBends;
pItemSection->ConnectOnName(pObj, 1,linkBends);
if (pSection->m_bResForm)
{
for (int i = 0; i < linkBends.size(); i++)
{
CBendObj* pBend = (CBendObj*)linkBends[i];
pBend->ComputeBend();
WELLOBJLIST::iterator it = pBend->m_pLayerLeft->m_BendRightList.begin();
for (; it != pBend->m_pLayerLeft->m_BendRightList.end(); it++)//左连层中其它右侧层位受到影响
{
CBendObj *pBend1 = (CBendObj*)(*it);
if (pBend1 != pBend)
{
pBend1->ComputeBend();
}
}
}
}
pItemSection->ConnectOnName(pObj, 2,linkBends);
if (pSection->m_bResForm)
{
for (int i = 0; i < linkBends.size(); i++)
{
CBendObj* pBend = (CBendObj*)linkBends[i];
pBend->ComputeBend();
WELLOBJLIST::iterator it = pBend->m_pLayerRight->m_BendLeftList.begin();
for (; it != pBend->m_pLayerRight->m_BendLeftList.end(); it++)//右连层中其它左侧层位受到影响
{
CBendObj *pBend1 = (CBendObj*)(*it);
if (pBend1 != pBend)
{
pBend1->ComputeBend();
}
}
}
}
}
}
m_pDoc->Invalidate();
b = TRUE;
}
}
return b;
}
BOOL CMultiWellSectionView::OnSetBendSmooth()
{
CMultiWellSectionDoc* pDoc = GetDocument();
CItem *pItem = pDoc->GetItem();
if (NULL == pItem)
return FALSE;
BOOL b = FALSE;
if (pItem->GetType() == ITEM_WELLSECTION)
{
CItemWellSection* pItemWellSection = (CItemWellSection*)pItem;
if (NULL != pItemWellSection)
pItemWellSection->SetReUnDoAction();
CWellSection* pSection = (CWellSection*)pItemWellSection->GetWellSection();
pSection->SetStratumSmooth(!pSection->IsStratumSmooth());
POSITION pos = pSection->m_BendList.GetHeadPosition();
while (pos != NULL)
{
CWellBaseObj* pObj = pSection->m_BendList.GetNext(pos);
if (pObj->GetType() == KEP_SECTIONBEND)
{
CBendObj* pBend = (CBendObj*)pObj;
pBend->SmoothBendLines();
//pBend->CreateBendLithoBreak();
//pBend->CreateBendFills();
b = TRUE; break;
}
}
pDoc->Invalidate();
}
return b;
}
void CMultiWellSectionView::OnAddFault()
{
CMultiWellSectionDoc* pDoc = GetDocument();
CItem *pItem = pDoc->GetItem();
if (NULL == pItem)
return;
if (pItem->GetType() == ITEM_WELLSECTION)
{
BOOL bFind = FALSE;
CItemWellSection* pItemWellSection = (CItemWellSection*)pItem;
if (pItemWellSection->GetItem() != NULL)
{
if (pItemWellSection->GetItem()->GetType() == ITEM_ADDFAULT)
{
bFind = TRUE;
}
}
if (!bFind)
{
CItemAddFault* pItemFault = new CItemAddFault(pDoc);
if (NULL != pItemWellSection)
{
pItemWellSection->SetReUnDoAction(FALSE, IDS_STRING_ACTION_MOVE,2);
}
pItemFault->SetItemSection(pItem);
pItemWellSection->SetItem(pItemFault);
pItemWellSection->SetState(TRUE);
}
}
pDoc->Invalidate();
}
void CMultiWellSectionView::OnLayerFlatten()
{
CMultiWellSectionDoc* pDoc = GetDocument();
CItem *pItem = pDoc->GetItem();
if (NULL == pItem)
return;
}
void CMultiWellSectionView::OnLayerFlatten1()
{
CMultiWellSectionDoc* pDoc = GetDocument();
CItem *pItem = pDoc->GetItem();
if (NULL == pItem)
return;
if (pItem->GetType() == ITEM_WELLSECTION)
{
CItemWellSection* pItemWellSection = (CItemWellSection*)pItem;
if (NULL != pItemWellSection)
pItemWellSection->SetReUnDoAction();
CWellSection* pSection = (CWellSection*)pItemWellSection->GetWellSection();
pSection->m_nLayerFlatten = 1;
double topValue = 0.0;
POSITION pos = pItemWellSection->m_WellObjSelectlist.GetHeadPosition();
while (pos != NULL)
{
CWellBaseObj* pObj = pItemWellSection->m_WellObjSelectlist.GetNext(pos);
if (pObj->GetType() == KEP_SECTIONBEND)
{
CBendObj* pBend = (CBendObj*)pObj;
pSection->FlatLayer(pBend, FALSE);
}
}
pSection->SetRealLevel(TRUE);
pDoc->Invalidate();
}
}
void CMultiWellSectionView::OnLayerFlatten2()
{
CMultiWellSectionDoc* pDoc = GetDocument();
CItem *pItem = pDoc->GetItem();
if (NULL == pItem)
return;
if (pItem->GetType() == ITEM_WELLSECTION)
{
CItemWellSection* pItemWellSection = (CItemWellSection*)pItem;
if (NULL != pItemWellSection)
pItemWellSection->SetReUnDoAction();
CWellSection* pSection = (CWellSection*)pItemWellSection->GetWellSection();
pSection->m_nLayerFlatten = 2;
POSITION pos = pItemWellSection->m_WellObjSelectlist.GetHeadPosition();
while (pos != NULL)
{
CWellBaseObj* pObj = pItemWellSection->m_WellObjSelectlist.GetNext(pos);
if (pObj->GetType() == KEP_SECTIONBEND)
{
CBendObj* pBend = (CBendObj*)pObj;
pSection->FlatLayer(pBend, TRUE);
}
}
pSection->SetRealLevel(TRUE);
pDoc->Invalidate();
}
}
void CMultiWellSectionView::OnLayerFlatten3()
{
CMultiWellSectionDoc* pDoc = GetDocument();
CItem *pItem = pDoc->GetItem();
if (NULL == pItem)
return;
if (pItem->GetType() == ITEM_WELLSECTION)
{
CItemWellSection* pItemWellSection = (CItemWellSection*)pItem;
if (NULL != pItemWellSection)
pItemWellSection->SetReUnDoAction();
CWellSection* pSection = (CWellSection*)pItemWellSection->GetWellSection();
pSection->m_nLayerFlatten = 3;
pSection->FlatWell(TRUE);
pSection->SetRealLevel(TRUE);
pDoc->Invalidate();
}
}
void CMultiWellSectionView::OnLayerFlatten4()
{
CMultiWellSectionDoc* pDoc = GetDocument();
CItem *pItem = pDoc->GetItem();
if (NULL == pItem)
return;
if (pItem->GetType() == ITEM_WELLSECTION)
{
CItemWellSection* pItemWellSection = (CItemWellSection*)pItem;
if (NULL != pItemWellSection)
pItemWellSection->SetReUnDoAction();
CWellSection* pSection = (CWellSection*)pItemWellSection->GetWellSection();
pSection->m_nLayerFlatten = 4;
pSection->FlatWell(FALSE);
pSection->SetRealLevel(TRUE);
pDoc->Invalidate();
}
}
void CMultiWellSectionView::OnLayerFlatten5()
{
CMultiWellSectionDoc* pDoc = GetDocument();
CItem *pItem = pDoc->GetItem();
if (NULL == pItem)
return;
if (pItem->GetType() == ITEM_WELLSECTION)
{
CItemWellSection* pItemWellSection = (CItemWellSection*)pItem;
if (NULL != pItemWellSection)
pItemWellSection->SetReUnDoAction();
CWellSection* pSection = (CWellSection*)pItemWellSection->GetWellSection();
pSection->m_nLayerFlatten = 0;
pSection->FlatRealPosition();
pSection->SetRealLevel(FALSE);
pDoc->Invalidate();
}
}
void CMultiWellSectionView::OnWellStyleComplete()
{
CMultiWellSectionDoc* pDoc = GetDocument();
CItem *pItem = pDoc->GetItem();
if (NULL == pItem)
return;
if (pItem->GetType() == ITEM_WELLSECTION || pItem->GetType() == ITEM_WELLFENCE)
{
CItemWellSection* pItemWellSection = (CItemWellSection*)pItem;
if (NULL != pItemWellSection)
pItemWellSection->SetReUnDoAction();
CWellSection* pSection = (CWellSection*)pItemWellSection->GetWellSection();
pSection->GetFeature()->SetWellStyleComplete(TRUE);
pDoc->Invalidate();
}
}
void CMultiWellSectionView::OnWellStyleDividline()
{
CMultiWellSectionDoc* pDoc = GetDocument();
CItem *pItem = pDoc->GetItem();
if (NULL == pItem)
return;
if (pItem->GetType() == ITEM_WELLSECTION || pItem->GetType() == ITEM_WELLFENCE)
{
CItemWellSection* pItemWellSection = (CItemWellSection*)pItem;
if (NULL != pItemWellSection)
pItemWellSection->SetReUnDoAction();
CWellSection* pSection = (CWellSection*)pItemWellSection->GetWellSection();
pSection->GetFeature()->SetWellStyleDividLine(TRUE);
pDoc->Invalidate();
}
}
void CMultiWellSectionView::OnWellStyleSimple()
{
CMultiWellSectionDoc* pDoc = GetDocument();
CItem *pItem = pDoc->GetItem();
if (NULL == pItem)
return;
if (pItem->GetType() == ITEM_WELLSECTION || pItem->GetType() == ITEM_WELLFENCE)
{
CItemWellSection* pItemWellSection = (CItemWellSection*)pItem;
if (NULL != pItemWellSection)
pItemWellSection->SetReUnDoAction();
CWellSection* pSection = (CWellSection*)pItemWellSection->GetWellSection();
pSection->GetFeature()->SetWellStyleSimple(TRUE);
pDoc->Invalidate();
}
}
void CMultiWellSectionView::OnBendLinkAll()
{
CMultiWellSectionDoc* pDoc = GetDocument();
CItem *pItem = pDoc->GetItem();
if (NULL == pItem)
return;
if (pItem->GetType() == ITEM_WELLSECTION)
{
CItemWellSection* pItemWellSection = (CItemWellSection*)pItem;
if (NULL != pItemWellSection)
pItemWellSection->SetReUnDoAction();
pItemWellSection->CreateLayers();
pDoc->Invalidate();
}
}
void CMultiWellSectionView::OnBendBreakAll()
{
CMultiWellSectionDoc* pDoc = GetDocument();
CItem *pItem = pDoc->GetItem();
if (NULL == pItem)
return;
if (pItem->GetType() == ITEM_WELLSECTION)
{
CItemWellSection* pItemWellSection = (CItemWellSection*)pItem;
if (NULL != pItemWellSection)
pItemWellSection->SetReUnDoAction();
pItemWellSection->BreakLayers();
pDoc->Invalidate();
}
}
void CMultiWellSectionView::OnLinkStyleOut()
{
CMultiWellSectionDoc* pDoc = GetDocument();
CItem *pItem = pDoc->GetItem();
if (NULL == pItem)
return;
if (pItem->GetType() == ITEM_WELLSECTION || pItem->GetType() == ITEM_WELLFENCE)
{
CItemWellSection* pItemWellSection = (CItemWellSection*)pItem;
if (NULL != pItemWellSection)
pItemWellSection->SetReUnDoAction();
CWellSection* pSection = (CWellSection*)pItemWellSection->GetWellSection();
pSection->GetFeature()->SetWellLinkOut(TRUE);
pSection->ComputeExTendLengthOfX();
if (pSection->m_bResForm)
{
POSITION pos = pSection->m_BendList.GetHeadPosition();
while (pos != NULL)
{
CBendObj* pBend = (CBendObj*)pSection->m_BendList.GetNext(pos);
pBend->ComputeBend();
}
}
else
{
POSITION pos = pSection->m_WellList.GetHeadPosition();
while (pos != NULL)
{
CWellPole *pWell = (CWellPole*)pSection->m_WellList.GetNext(pos);
pSection->ReComputeBends(pWell);
}
}
pDoc->Invalidate();
}
}
void CMultiWellSectionView::OnLinkStyleCurveIn()
{
CMultiWellSectionDoc* pDoc = GetDocument();
CItem *pItem = pDoc->GetItem();
if (NULL == pItem)
return;
if (pItem->GetType() == ITEM_WELLSECTION || pItem->GetType() == ITEM_WELLFENCE)
{
CItemWellSection* pItemWellSection = (CItemWellSection*)pItem;
if (NULL != pItemWellSection)
pItemWellSection->SetReUnDoAction();
CWellSection* pSection = (CWellSection*)pItemWellSection->GetWellSection();
pSection->GetFeature()->SetWellLinkCurveIn(TRUE);
pSection->ComputeExTendLengthOfX();
POSITION pos = pSection->m_WellList.GetHeadPosition();
while (pos != NULL)
{
CWellPole *pWell = (CWellPole*)pSection->m_WellList.GetNext(pos);
pSection->ReComputeBends(pWell);
}
pDoc->Invalidate();
}
}
void CMultiWellSectionView::OnLinkStyleResultBound()
{
CMultiWellSectionDoc* pDoc = GetDocument();
CItem *pItem = pDoc->GetItem();
if (NULL == pItem)
return;
if (pItem->GetType() == ITEM_WELLSECTION || pItem->GetType() == ITEM_WELLFENCE)
{
CItemWellSection* pItemWellSection = (CItemWellSection*)pItem;
if (NULL != pItemWellSection)
pItemWellSection->SetReUnDoAction();
CWellSection* pSection = (CWellSection*)pItemWellSection->GetWellSection();
pSection->GetFeature()->SetWellLinkLayerBounds(TRUE);
pSection->ComputeExTendLengthOfX();
if (pSection->m_bResForm)
{
POSITION pos = pSection->m_BendList.GetHeadPosition();
while (pos != NULL)
{
CBendObj* pBend = (CBendObj*)pSection->m_BendList.GetNext(pos);
pBend->ComputeBend();
}
}
else
{
POSITION pos = pSection->m_WellList.GetHeadPosition();
while (pos != NULL)
{
CWellPole *pWell = (CWellPole*)pSection->m_WellList.GetNext(pos);
pSection->ReComputeBends(pWell);
}
}
pDoc->Invalidate();
}
}
void CMultiWellSectionView::OnLinkStyleStratumBound()
{
CMultiWellSectionDoc* pDoc = GetDocument();
CItem *pItem = pDoc->GetItem();
if (NULL == pItem)
return;
if (pItem->GetType() == ITEM_WELLSECTION || pItem->GetType() == ITEM_WELLFENCE)
{
CItemWellSection* pItemWellSection = (CItemWellSection*)pItem;
if (NULL != pItemWellSection)
pItemWellSection->SetReUnDoAction();
CWellSection* pSection = (CWellSection*)pItemWellSection->GetWellSection();
pSection->GetFeature()->SetWellLinkStratiBounds(TRUE);
pSection->ComputeExTendLengthOfX();
if (pSection->m_bResForm)
{
POSITION pos = pSection->m_BendList.GetHeadPosition();
while (pos != NULL)
{
CBendObj* pBend = (CBendObj*)pSection->m_BendList.GetNext(pos);
pBend->ComputeBend();
}
}
else
{
POSITION pos = pSection->m_WellList.GetHeadPosition();
while (pos != NULL)
{
CWellPole *pWell = (CWellPole*)pSection->m_WellList.GetNext(pos);
pSection->ReComputeBends(pWell);
}
}
pDoc->Invalidate();
}
}
void CMultiWellSectionView::OnLinkStyleCenter()
{
CMultiWellSectionDoc* pDoc = GetDocument();
CItem *pItem = pDoc->GetItem();
if (NULL == pItem)
return;
if (pItem->GetType() == ITEM_WELLSECTION || pItem->GetType() == ITEM_WELLFENCE)
{
CItemWellSection* pItemWellSection = (CItemWellSection*)pItem;
if (NULL != pItemWellSection)
pItemWellSection->SetReUnDoAction();
CWellSection* pSection = (CWellSection*)pItemWellSection->GetWellSection();
pSection->GetFeature()->SetWellLinkCenter(TRUE);
pSection->ComputeExTendLengthOfX();
if (pSection->m_bResForm)
{
POSITION pos = pSection->m_BendList.GetHeadPosition();
while (pos != NULL)
{
CBendObj* pBend = (CBendObj*)pSection->m_BendList.GetNext(pos);
pBend->ComputeBend();
}
}
else
{
POSITION pos = pSection->m_WellList.GetHeadPosition();
while (pos != NULL)
{
CWellPole *pWell = (CWellPole*)pSection->m_WellList.GetNext(pos);
pSection->ReComputeBends(pWell);
}
}
pDoc->Invalidate();
}
}
BOOL CMultiWellSectionView::OnAddRuler()
{
CMultiWellSectionDoc* pDoc = GetDocument();
CItem *pItem = pDoc->GetItem();
if (pDoc->GetItemType() != ITEM_SCALE_RULER)
{
CXy* pXy = pDoc->GetDraw();
CPtrList* pList = pXy->GetValueList();
CWellSection* pSection = NULL;
POSITION pos = pList->GetHeadPosition();
while (pos)
{
COne* pObj = (COne*)pList->GetNext(pos);
if (pObj->GetType() == KEP_WELLSECTION)
{
pSection = (CWellSection*)pObj->GetValue();
break;
}
}
if (NULL == pSection)
{
return FALSE;
}
/////计算标尺的初始范围以及起始顶深和底深
double sDep, eDep;
double NewRight;
double NewTop, NewBottom;
double firstWellTrackStart;
double firstWellLevelDepth;
BOOL bInit = FALSE;
BOOL bPosition = FALSE;
pos = pSection->m_WellList.GetHeadPosition();
while (pos)
{
CSectionWellObj* pWell = (CSectionWellObj*)pSection->m_WellList.GetNext(pos);
if (!bInit)
{
NewBottom = pWell->GetPos().bottom;
NewTop = pWell->GetPos().top;
sDep = pWell->m_fLevel - pWell->m_dSdep;
eDep = pWell->m_fLevel - pWell->m_dEdep;
firstWellLevelDepth = pWell->m_fLevel - pWell->m_dSdep;
firstWellTrackStart = pWell->GetPos().top - pWell->m_dHeightWellHead - pWell->m_dHeightTrackHead;
bInit = TRUE;
}
else
{
//if ((pWell->GetPos().top - pWell->m_dHeightWellHead - pWell->m_dHeightTrackHead) > NewTrackStart)
//{
// NewTrackStart = pWell->GetPos().top - pWell->m_dHeightWellHead - pWell->m_dHeightTrackHead;
//}
if (pWell->GetPos().bottom < NewBottom)
{
NewBottom = pWell->GetPos().bottom;
}
if (pWell->GetPos().top > NewTop)
NewTop = pWell->GetPos().top;
if ((pWell->m_fLevel - pWell->m_dSdep) > sDep)
{
sDep = pWell->m_fLevel - pWell->m_dSdep;
}
if ((pWell->m_fLevel - pWell->m_dEdep) < eDep)
{
eDep = pWell->m_fLevel - pWell->m_dEdep;
}
}
}
NewRight = pSection->GetPos().left;
CRect8 rect;
rect.top = NewTop;
rect.bottom = NewBottom;
sDep = firstWellLevelDepth - pSection->ScreenCYToHeight(NewTop - firstWellTrackStart);// / pSection->m_fLevelScale;
eDep = firstWellLevelDepth - pSection->ScreenCYToHeight(NewBottom - firstWellTrackStart);// / pSection->m_fLevelScale;
rect.right = NewRight - 100;
rect.left = NewRight - 350;
//pAxis->SetRect(rect, true);
//pAxisObj->UpdateRect(rect, true);
CScaleRuler* pSr = new CScaleRuler();
pSr->EnableTextLeft(FALSE);
pSr->EnableAutoUpdate(FALSE);
pSr->SetRect(rect);
rect = pSr->GetRect();
pSr->EnableDirectionV(TRUE);
pSr->m_dScaleStep = 10;
pSr->m_dScaleMin = eDep;
pSr->m_dScaleMax = sDep;
pSr->m_SGradSegment = 2;
pSr->m_dTextHeight = 80;
pSr->EnableAbsoulteScale(TRUE);
pSr->m_strTitle = "海拔";
pSr->m_TitleFont.m_dHeight = 160;
pSr->m_TitleFont.m_dWidth = pSr->m_TitleFont.m_dHeight * 0.4;
pSr->EnableTitleOnTop(TRUE);
pDoc->GetDraw()->AddElement(pSr, DOUBLEFOX_SCALERULER);
CRect8 sectionRect = pSection->GetRect();
CProportion* pNewScale = new CProportion();
double widthM = pSection->ScreenCXToWidth(sectionRect.Width()); //图宽度,以米计算
pNewScale->num = 5;
pNewScale->m_dScaleLength = pSection->m_fHorzScale / 100 * 2;
pNewScale->m_dScaleHeight = 200;
pNewScale->x0 = sectionRect.CenterPoint().x0 - pNewScale->num * pNewScale->m_dScaleLength / 2;
pNewScale->y0 = sectionRect.top + 400;
pNewScale->m_size.cy = 100;
pNewScale->m_size.cx = pNewScale->m_size.cy * 0.4;
pDoc->GetDraw()->AddElement(pNewScale, DOUBLEFOX_PROPORTION);
}
else
{
//pDoc->EnableDefaultTool();
}
pDoc->Invalidate();
return TRUE;
}
BOOL CMultiWellSectionView::OnWellsMap(CString sybmlPath)
{
CMultiWellSectionDoc* pDoc = GetDocument();
CItem* pItem = pDoc->GetItem();
if (NULL == pItem)
return FALSE;
if (pItem->GetType() == ITEM_WELLSECTION)
{
CItemWellSection* pItemSection = (CItemWellSection*)pItem;
CWellSection* pSection = pItemSection->GetWellSection();
CRect8 sectionRect = pSection->GetRect();
CSize8 fontSize;
fontSize.cy = sectionRect.Height() / 20;
fontSize.cx = fontSize.cy * 0.4;
std::vector<CPointNameEx*> wellPtArr;
BOOL bFirst = TRUE;
POSITION pos = pSection->m_WellList.GetHeadPosition();
double maxx, maxy, minx, miny;
maxx = maxy = DBL_MIN;
minx = miny = DBL_MAX;
while (pos != NULL)
{
CSectionWellObj* pWell = (CSectionWellObj*)pSection->m_WellList.GetNext(pos);
CPointNameEx* pPoint = new CPointNameEx;
pPoint->x0 = pWell->m_fX;
pPoint->y0 = pWell->m_fY;
pPoint->SetName(pWell->GetWellName());
maxx = pWell->m_fX > maxx ? pWell->m_fX : maxx;
maxy = pWell->m_fY > maxy ? pWell->m_fY : maxy;
minx = pWell->m_fX < minx ? pWell->m_fX : minx;
miny = pWell->m_fY < miny ? pWell->m_fY : miny;
wellPtArr.push_back(pPoint);
if (bFirst)
{
fontSize.cy = pWell->m_font.m_dHeight * 2 / 3;
fontSize.cx = fontSize.cy * 0.4;
bFirst = FALSE;
}
}
double xlen = maxx - minx;
double ylen = maxy - miny;
double twlen = xlen > ylen ? xlen : ylen; //井范围xy向的长边。
double maxlen = sectionRect.Height() / 4; //以当前剖面范围高度的1/4与井范围矩形的长边对应。
CPoint2D minpt;
minpt.x0 = sectionRect.left - maxlen / 2; //剖面图左下角附近做为井位图左下角点。
minpt.y0 = sectionRect.bottom - maxlen / 2;
double ratio = maxlen / twlen;
CString strLibPath = sybmlPath + "\\";// ::GetPreferences().DocumentMark.GetLibraryPath();
CString markFile = strLibPath + "A2-勘探样式-中海油.kev";
CString markName = "油气层井";
bool bInitSucess = AfxGetMarkLibMgr()->InitLib(strLibPath, FALSE);
POSITION mpos = AfxGetMarkLibMgr()->Find(markFile);
CXy* pMark = NULL;
if (mpos != NULL)
{
CLibraryItem* pMItem = AfxGetMarkLibMgr()->GetAt(mpos);
if (pMItem->m_pxy == NULL)
{
pMItem->Read();
}
if (pMItem->m_pxy != NULL)
{
CMapStringToPtrNoCase* pmarks = pMItem->m_pxy->GetMark();
pMark = (CXy*)pMItem->m_pxy->FindMark(markName);
//pmarks->Lookup(makrName, (void*&)pMark);
if (pMark)
{
CXy* pNewMark = new CXy;
*pNewMark = *(pMark);
pDoc->GetDraw()->AddMark(pNewMark);
}
}
}
CItemSelect* ptItemSelect = new CItemSelect(GetDocument());
double xl, xr, yt, yb;
xl = yb = DBL_MAX;
xr = yt = -1 * DBL_MAX;
for (int i = 0; i < wellPtArr.size(); i++)
{
CPointNameEx* pPoint = wellPtArr[i];
CHowToViewPoint* pHVpt = new CHowToViewPoint;
pHVpt->m_word.cy = fontSize.cy;
pHVpt->m_word.cx = fontSize.cx;
pHVpt->frColor = RGB(10, 10, 10);
if (pMark)
{
pHVpt->m_mark.cx = fontSize.cy * 0.5;
pHVpt->m_mark.cy = fontSize.cy * 0.5;
pHVpt->MarkName = markName;
pHVpt->PositionNew(0);
pHVpt->SetAlignsH(CTextFlags::alignCenterH);
//pHVpt->pDraw =
}
pPoint->x0 = (pPoint->x0 - minx) * ratio + minpt.x0;
pPoint->y0 = (pPoint->y0 - miny) * ratio + minpt.y0;
POSITION pos = GetDocument()->GetDraw()->AddElement(pPoint, DOUBLEFOX_POINT);
COne* pOne = GetDocument()->GetDraw()->GetAt(pos);
pOne->HowToViewPoint = pHVpt;
CRect8 trect = pOne->GetRect();
if (trect.left < xl)
xl = trect.left;
if (trect.right > xr)
xr = trect.right;
if (trect.top > yt)
yt = trect.top;
if (trect.bottom < yb)
yb = trect.bottom;
ptItemSelect->m_selection.AddTail(pos);
//pOne->seth
}
if (ptItemSelect->m_selection.GetCount() > 0)
{
CRect8 rect;
rect.left = xl; rect.right = xr;
rect.top = yt; rect.bottom = yb;
CCurveEx* pCurve = new CCurveEx;
pCurve->CreateCurveFromRect(&rect);
POSITION pos1 = GetDocument()->GetDraw()->AddElement(pCurve, DOUBLEFOX_CURVE);
ptItemSelect->m_selection.AddTail(pos1);
POSITION gpos = ptItemSelect->GroupSelectionToBlock();
}
delete ptItemSelect;
return TRUE;
}
return FALSE;
}
void CMultiWellSectionView::OnBendExtendLevelLeft()
{
CMultiWellSectionDoc* pDoc = GetDocument();
CItem *pItem = pDoc->GetItem();
if (NULL == pItem)
return;
if (pItem->GetType() == ITEM_WELLSECTION)
{
CItemWellSection* pItemWellSection = (CItemWellSection*)pItem;
if (NULL != pItemWellSection)
pItemWellSection->SetReUnDoAction(FALSE, IDS_STRING_ACTION_MOVE, 2);
CWellSection* pSection = (CWellSection*)pItemWellSection->GetWellSection();
pSection->GetFeature()->SetBendExtendLeftLevel(!pSection->GetFeature()->IsBendExtendLeftLevel());
POSITION pos = pSection->m_BendList.GetHeadPosition();
while (pos)
{
CBendObj* pBend = (CBendObj*)pSection->m_BendList.GetNext(pos);
pBend->CreateBendLines();
pBend->CreateBendFills();
}
pDoc->Invalidate();
}
}
void CMultiWellSectionView::OnBendExtendTrendLeft()
{
CMultiWellSectionDoc* pDoc = GetDocument();
CItem *pItem = pDoc->GetItem();
if (NULL == pItem)
return;
if (pItem->GetType() == ITEM_WELLSECTION)
{
CItemWellSection* pItemWellSection = (CItemWellSection*)pItem;
if (NULL != pItemWellSection)
pItemWellSection->SetReUnDoAction(FALSE, IDS_STRING_ACTION_MOVE, 2);
CWellSection* pSection = (CWellSection*)pItemWellSection->GetWellSection();
pSection->GetFeature()->SetBendExtendLeftTrend(!pSection->GetFeature()->IsBendExtendLeftTrend());
POSITION pos = pSection->m_BendList.GetHeadPosition();
while (pos)
{
CBendObj* pBend = (CBendObj*)pSection->m_BendList.GetNext(pos);
pBend->CreateBendLines();
pBend->CreateBendFills();
}
pDoc->Invalidate();
}
}
void CMultiWellSectionView::OnBendExtendLevelRight()
{
CMultiWellSectionDoc* pDoc = GetDocument();
CItem *pItem = pDoc->GetItem();
if (NULL == pItem)
return;
if (pItem->GetType() == ITEM_WELLSECTION)
{
CItemWellSection* pItemWellSection = (CItemWellSection*)pItem;
if (NULL != pItemWellSection)
pItemWellSection->SetReUnDoAction(FALSE, IDS_STRING_ACTION_MOVE, 2);
CWellSection* pSection = (CWellSection*)pItemWellSection->GetWellSection();
pSection->GetFeature()->SetBendExtendRightLevel(!pSection->GetFeature()->IsBendExtendRightLevel());
POSITION pos = pSection->m_BendList.GetHeadPosition();
while (pos)
{
CBendObj* pBend = (CBendObj*)pSection->m_BendList.GetNext(pos);
pBend->CreateBendLines();
pBend->CreateBendFills();
}
pDoc->Invalidate();
}
}
void CMultiWellSectionView::OnBendExtendTrendRight()
{
CMultiWellSectionDoc* pDoc = GetDocument();
CItem *pItem = pDoc->GetItem();
if (NULL == pItem)
return;
if (pItem->GetType() == ITEM_WELLSECTION)
{
CItemWellSection* pItemWellSection = (CItemWellSection*)pItem;
if (NULL != pItemWellSection)
pItemWellSection->SetReUnDoAction(FALSE, IDS_STRING_ACTION_MOVE, 2);
CWellSection* pSection = (CWellSection*)pItemWellSection->GetWellSection();
pSection->GetFeature()->SetBendExtendRightTrend(!pSection->GetFeature()->IsBendExtendRightTrend());
POSITION pos = pSection->m_BendList.GetHeadPosition();
while (pos)
{
CBendObj* pBend = (CBendObj*)pSection->m_BendList.GetNext(pos);
pBend->CreateBendLines();
pBend->CreateBendFills();
}
pDoc->Invalidate();
}
}
BOOL CMultiWellSectionView::OnAddBendLayerPoint()
{
CMultiWellSectionDoc* pDoc = GetDocument();
CItem *pItem = pDoc->GetItem();
if (NULL == pItem)
return FALSE;
if (pItem->GetType() == ITEM_WELLSECTION)
{
CItemWellSection* pItemSection = (CItemWellSection*)pItem;
if (pItemSection->GetItem()->GetType() == ITEM_BEND)
{
CItemBend* pBendItem = (CItemBend*)pItemSection->GetItem();
pBendItem->AddBendLayerPoint();
return TRUE;
}
}
return FALSE;
}
BOOL CMultiWellSectionView::OnAddFaultPoint()
{
CMultiWellSectionDoc* pDoc = GetDocument();
CItem *pItem = pDoc->GetItem();
if (NULL == pItem)
return FALSE;
if (pItem->GetType() == ITEM_WELLSECTION)
{
CItemWellSection* pItemSection = (CItemWellSection*)pItem;
if (pItemSection->GetItem()->GetType() == ITEM_FAULT)
{
CItemFault* pFaultItem = (CItemFault*)pItemSection->GetItem();
pFaultItem->AddFaultPoint();
return TRUE;
}
}
return FALSE;
}
BOOL CMultiWellSectionView::OnDeleteLayerPoint()
{
CMultiWellSectionDoc* pDoc = GetDocument();
CItem *pItem = pDoc->GetItem();
if (NULL == pItem)
return FALSE;
if (pItem->GetType() == ITEM_WELLSECTION)
{
CItemWellSection* pItemSection = (CItemWellSection*)pItem;
if (pItemSection->GetItem()->GetType() == ITEM_BEND)
{
CItemBend* pBendItem = (CItemBend*)pItemSection->GetItem();
pBendItem->DeleteBendLayerPoint();
return TRUE;
}
}
return FALSE;
}
BOOL CMultiWellSectionView::OnDeleteFaultPoint()
{
CMultiWellSectionDoc* pDoc = GetDocument();
CItem *pItem = pDoc->GetItem();
if (NULL == pItem)
return FALSE;
if (pItem->GetType() == ITEM_WELLSECTION)
{
CItemWellSection* pItemSection = (CItemWellSection*)pItem;
if (pItemSection->GetItem()->GetType() == ITEM_FAULT)
{
CItemFault* pFaultItem = (CItemFault*)pItemSection->GetItem();
pFaultItem->DeleteFaultPoint();
return FALSE;
}
}
return FALSE;
}
void CMultiWellSectionView::SetClient(int l, int t, int r, int b)
{
CSigmaView::SetClient(l, t, r, b);
OnSize(0, r - l, b - t);
}
void CMultiWellSectionView::Scroll(int orientation, double offset)
{
CSigmaView::Scroll(orientation, offset);
}
int CMultiWellSectionView::ViewSetItemForSelectedElement(int mouseX, int mouseY)
{
int itemType = eWellPoleCallbackMsgDef::tZeroData;
CMultiWellSectionDoc* pDoc = GetDocument();
if (pDoc->GetItem())
{
CItem* pItem = pDoc->GetItem();
CPoint pt;
pt.x = mouseX;
pt.y = mouseY;
CItem* pOldItem = pDoc->GetItem();
//if (pItem->GetType() != ITEM_SELECT && pItem->GetType() != ITEM_WELLSECTION)
//{
// pDoc->GetItem()->OnLButtonDown(nFlags, point);
// return;
//}
CPoint2D ptReal = pDoc->GetDC().GetReal(pt);
CRect8 rectReal = pDoc->GetSelectedRect(ptReal);
BOOL bIn = FALSE;
CPtrList* pList = pDoc->GetDraw()->GetValueList();
////对象链表
pList = pDoc->GetDraw()->GetValueList();
POSITION pos = pList->GetHeadPosition();
while (NULL != pos)
{
COne* pOne = (COne*)pList->GetAt(pos);
if (pOne->GetType() != KEP_WELLSECTION)
{
bIn = pOne->IsInRange(rectReal);
if (bIn)
{
if ((pItem->GetType() != ITEM_SELECT && !pItem->IsNestItem()) || (pItem->GetType() == ITEM_WELLSECTION && pItem->IsNestItem()))
{//选中其它对象,切换选择工具
//pDoc->SetItem(pDoc->FindItem(ITEM_SELECT));
itemType = eWellPoleCallbackMsgDef::vSetSelectItem;
pDoc->DeleteItem();
}
break;
}
}
pList->GetNext(pos);
}
BOOL bInSection = FALSE;
if (!bIn)
{
pos = pList->GetHeadPosition();
while (NULL != pos)
{
COne* pOne = (COne*)pList->GetAt(pos);
if (pOne->GetType() == KEP_WELLSECTION)
{
if (pOne->IsInRange(rectReal))
{
bInSection = TRUE;
if (pItem->GetType() != ITEM_WELLSECTION)
{
CItemWellSection* pItemWellSection = new CItemWellSection(GetDocument());
pItemWellSection->SetPos(pos);
pItemWellSection->SetDrawObj((CWellBaseObj*)pOne->GetValue());
pDoc->SetItem(pItemWellSection);
itemType = eWellPoleCallbackMsgDef::vSetWellSectionItem;
}
break;
}
}
pList->GetNext(pos);
}
if (!bInSection)
{
if (pItem->GetType() == ITEM_WELLSECTION /*&& pItem->IsInEdit()*/)
{
CItemWellSection *pItemSection = (CItemWellSection *)pItem;
BOOL bSet = TRUE;
if (pItemSection->GetItem() != NULL && pItemSection->GetItem()->GetType() == ITEM_ADDFAULT)
bSet = FALSE;
if (bSet)
{//点中空白,切换工具
itemType = eWellPoleCallbackMsgDef::vSetSelectItem;
pDoc->DeleteItem();
}
}
}
}
return itemType;
}
return itemType;
}
BOOL CMultiWellSectionView::GetSelectWellSectionObject(int& type, int& ttype, ULONGLONG& objHandle)
{
BOOL b = FALSE;
type = -1;
ttype = -1;
objHandle = 0;
CMultiWellSectionDoc* pDoc = GetDocument();
if (pDoc->GetItem() == NULL)
return FALSE;
if (m_pDoc->GetItem()->GetType() == ITEM_WELLSECTION)
{
CItemWellSection *pSectionItem = (CItemWellSection *)m_pDoc->GetItem();
if (pSectionItem->m_pItemSelected == NULL)
{
CWellSection* pSection = pDoc->GetWellSection();
type = KEP_WELLSECTION;
ttype = KEP_WELLSECTION;
objHandle = (ULONGLONG)(pSection);
return TRUE;
}
else
{
if (pSectionItem->m_pItemSelected->GetType() == ITEM_BEND)
{
CItemBend *pItemBend = (CItemBend *)pSectionItem->m_pItemSelected;
type = KEP_SECTIONBEND;
ttype = KEP_SECTIONBEND;
CBendObj *pBend = (CBendObj*)pItemBend->GetDrawObj();
objHandle = (ULONGLONG)(pBend);
return TRUE;
}
else if(pSectionItem->m_pItemSelected->GetType() == ITEM_FAULT)
{
CItemFault *pItemFault = (CItemFault *)pSectionItem->m_pItemSelected;
type = KEP_SECTIONFAULT;
ttype = KEP_SECTIONFAULT;
CFaultObj *pFault = (CFaultObj*)pItemFault->GetDrawObj();
objHandle = (ULONGLONG)(pFault);
return TRUE;
}
else if (pSectionItem->m_pItemSelected->GetType() == ITEM_SECTIONWELL)
{
CItemSectionWell* pItemWell = (CItemSectionWell*)pSectionItem->m_pItemSelected;
if (pItemWell->m_pItemSelected == NULL)
{
CWellPole* pWell = (CWellPole*)pItemWell->GetDrawObj();
type = KEP_WELL;
ttype = KEP_WELL;
objHandle = (ULONGLONG)(pWell);
return TRUE;
}
else
{
if (pItemWell->m_pItemSelected->GetType() == ITEM_TRACK)
{
CItemWcsTrack* pItemTrack = (CItemWcsTrack*)pItemWell->m_pItemSelected;
type = KEP_TRACK;
CTrackObj* pTrack = (CTrackObj*)pItemTrack->GetDrawObj();
ttype = pTrack->GetTrackType();
objHandle = (ULONGLONG)(pItemTrack->GetDrawObj());
return TRUE;
}
else if (pItemWell->m_pItemSelected->GetType() == ITEM_ADDBEND)
{
CItemAddBend* pItemAddBend = (CItemAddBend*)pItemWell->m_pItemSelected;
CWellBaseObj* pTrack = (CWellBaseObj*)pItemAddBend->GetDrawObj();
if (pTrack == NULL)
{
return FALSE;
}
else
{
type = KEP_TRACKINDATA;
ttype = pTrack->GetType();
objHandle = (ULONGLONG)(pItemAddBend->GetDrawObj());
return TRUE;
}
}
else if (pItemWell->m_pItemSelected->GetType() == ITEM_TRACKIN)
{
CItemWcsTrackIn* pItemTrackIn = (CItemWcsTrackIn*)pItemWell->m_pItemSelected;
CWellBaseObj* pTrack = (CWellBaseObj*)pItemTrackIn->GetDrawObj();
if (pTrack == NULL)
{
return FALSE;
}
else
{
type = KEP_TRACKINDATA;
ttype = pTrack->GetType();
objHandle = (ULONGLONG)(pItemTrackIn->GetDrawObj());
return TRUE;
}
}
}
}
}
}
return b;
}
int CMultiWellSectionView::GetCurrentDrawItemType()
{
int rt = -1;
CMultiWellSectionDoc* pDoc = GetDocument();
if (pDoc->GetItem() == NULL)
return rt;
if (m_pDoc->GetItem()->GetType() == ITEM_WELLSECTION)
{
CItemWellSection *pSectionItem = (CItemWellSection *)m_pDoc->GetItem();
if (pSectionItem->m_pItemSelected == NULL)
{
rt = pSectionItem->GetType();
}
else
{
if (pSectionItem->m_pItemSelected->GetType() == ITEM_ADDFAULT)
{
rt = pSectionItem->m_pItemSelected->GetType();
}
else if (pSectionItem->m_pItemSelected->GetType() == ITEM_BEND)
{
CItemBend *pItemBend = (CItemBend *)pSectionItem->m_pItemSelected;
rt = pItemBend->GetType();
}
else if (pSectionItem->m_pItemSelected->GetType() == ITEM_FAULT)
{
CItemFault *pItemFault = (CItemFault *)pSectionItem->m_pItemSelected;
rt = pItemFault->GetType();
}
else if (pSectionItem->m_pItemSelected->GetType() == ITEM_SECTIONWELL)
{
CItemSectionWell* pItemWell = (CItemSectionWell*)pSectionItem->m_pItemSelected;
if (pItemWell->m_pItemSelected == NULL)
{
rt = pItemWell->GetType();
}
else
{
if (pItemWell->m_pItemSelected->GetType() == ITEM_TRACK)
{
CItemWcsTrack* pItemTrack = (CItemWcsTrack*)pItemWell->m_pItemSelected;
rt = pItemTrack->GetType();
return TRUE;
}
else if (pItemWell->m_pItemSelected->GetType() == ITEM_ADDBEND)
{
CItemAddBend* pItemAddBend = (CItemAddBend*)pItemWell->m_pItemSelected;
rt = pItemAddBend->GetType();
}
else if (pItemWell->m_pItemSelected->GetType() == ITEM_TRACKIN)
{
CItemWcsTrackIn* pItemTrackIn = (CItemWcsTrackIn*)pItemWell->m_pItemSelected;
rt = pItemTrackIn->GetType();
}
}
}
}
}
return rt;
}
BOOL CMultiWellSectionView::GetSelectedWell(ULONGLONG& objHandle)
{
BOOL b = FALSE;
objHandle = 0;
CMultiWellSectionDoc* pWellDoc = (CMultiWellSectionDoc*)GetDocument();
if (pWellDoc->GetItem() == NULL)
{
return FALSE;
}
if (pWellDoc->GetItem()->GetType() == ITEM_WELLSECTION)
{
CItemWellSection *pSectionItem = (CItemWellSection *)m_pDoc->GetItem();
if (pSectionItem->m_pItemSelected == NULL)
{
return FALSE;
}
else if (pSectionItem->m_pItemSelected->GetType() == ITEM_SECTIONWELL)
{
CItemSectionWell* pItemWell = (CItemSectionWell*)pSectionItem->m_pItemSelected;
CWellPole* pWell = (CWellPole*)pItemWell->GetDrawObj();
objHandle = (ULONGLONG)(pWell);
b = TRUE;
}
}
return b;
}
BOOL CMultiWellSectionView::AddTrackAfterSelectedWellObject(int trackType[], int trackNum, ULONGLONG*& pNewTrackHandle, int*& pNewTrackType, int& newTrackNum)
{
BOOL b = FALSE;
newTrackNum = 0;
CMultiWellSectionDoc* pWellDoc = (CMultiWellSectionDoc*)GetDocument();
if (pWellDoc->GetItem() == NULL)
{
return FALSE;
}
if (pWellDoc->GetItem()->GetType() == ITEM_WELLSECTION)
{
CItemWellSection *pSectionItem = (CItemWellSection *)m_pDoc->GetItem();
if (pSectionItem->m_pItemSelected == NULL)
{
return FALSE;
}
else if (pSectionItem->m_pItemSelected->GetType() == ITEM_SECTIONWELL)
{
CItemSectionWell* pItemWell = (CItemSectionWell*)pSectionItem->m_pItemSelected;
CTrackObj* pSelectTrack = NULL;
if (pItemWell->m_WellObjSelectlist.GetCount() > 0)
{
CWellBaseObj* pObjSelected = pItemWell->m_WellObjSelectlist.GetHead();
if (pObjSelected->GetType() == KEP_TRACK)
{
pSelectTrack = (CTrackObj*)pObjSelected;
}
}
TRACKLIST newTracks;
pItemWell->AddTrack(pSelectTrack, trackType, trackNum, newTracks);
newTrackNum = newTracks.size();
pNewTrackHandle = (ULONGLONG*)(new BYTE[newTrackNum * sizeof(ULONGLONG)]); //new ULONGLONG[newTrackNum]; //保证分配的指针类型与释放的一致
pNewTrackType = (int*)(new BYTE[newTrackNum * sizeof(int)]); //new int[newTrackNum];
int id = 0;
TRACKLIST::iterator it = newTracks.begin();
for (; it != newTracks.end(); ++it)
{
pNewTrackHandle[id] = ULONGLONG(*it);
pNewTrackType[id] = (*it)->GetTrackType();
id++;
}
m_pWndCallBack(eWellPoleCallbackMsgDef::tInvalidateWnd, 0);
}
b = TRUE;
}
return b;
}
BOOL CMultiWellSectionView::DeleteSelectedWellObject()
{
BOOL b = FALSE;
CMultiWellSectionDoc* pWellDoc = (CMultiWellSectionDoc*)GetDocument();
if (m_pDoc->GetItem() == NULL)
return b;
if (pWellDoc->GetItem()->GetType() == ITEM_WELLSECTION)
{
CItemWellSection *pSectionItem = (CItemWellSection *)m_pDoc->GetItem();
pSectionItem->DeleteSelection();
m_pWndCallBack(eWellPoleCallbackMsgDef::tInvalidateWnd, 0);
b = TRUE;
}
return b;
}
BOOL CMultiWellSectionView::SaveWellPoleTemplateFile(LPCTSTR filePathName)
{
BOOL b = FALSE;
CMultiWellSectionDoc* pWellDoc = (CMultiWellSectionDoc*)GetDocument();
if (pWellDoc->GetItem() == NULL)
{
return FALSE;
}
if (pWellDoc->GetItem()->GetType() == ITEM_WELLSECTION)
{
CItemWellSection *pSectionItem = (CItemWellSection *)m_pDoc->GetItem();
if (pSectionItem->m_pItemSelected == NULL)
return FALSE;
if (pSectionItem->m_pItemSelected->GetType() == ITEM_SECTIONWELL)
{
CItemSectionWell* pItemWell = (CItemSectionWell*)pSectionItem->m_pItemSelected;
CWellPole *pWellObj = pItemWell->GetWellObject();
pWellObj->SetActionTemplate(TRUE);
CStdioFile fw;
if (!fw.Open(filePathName, CFile::modeCreate | CFile::modeWrite))
{
pWellObj->SetActionTemplate(FALSE);
return FALSE;
}
b = TRUE;
AfxGetPublicFunction()->InitSaveCounter();
//AfxGetPublicFunction()->__CurrentSaveFilePath = filepathstr;
DWORD tcode = AfxGetPublicFunction()->GetCodeType();
AfxGetPublicFunction()->SetCodeType(CODE_GB2321);
//AfxGetPublicFunction()->WriteDML_Head_Version(fw);
//AfxGetPublicFunction()->WriteDML_Head_Xmlns(fw);
nsWellPoleFunc::WritePCG_Head_Version(fw);
pWellObj->WritePCG(fw, 2, 1);//pWellObj->WriteDML(fw, -1, 1);
nsWellPoleFunc::WritePCG_Tail(fw);
//AfxGetPublicFunction()->SetCodeType((DWORD)::GetPreferences().WorkaroundSave.m_nCodeMode);
AfxGetPublicFunction()->InitSaveCounter();
fw.Close();
pWellObj->SetActionTemplate(FALSE);
AfxGetPublicFunction()->SetCodeType(tcode);
}
}
return b;
}
//BOOL CMultiWellSectionView::ApplyingWellPoleTemplateFile(LPCTSTR filePathName)
//{
// BOOL b = FALSE;
// CMultiWellSectionDoc* pWellDoc = (CMultiWellSectionDoc*)GetDocument();
//
// if (pWellDoc->GetItem() == NULL)
// {
// return FALSE;
// }
//
// if (pWellDoc->GetItem()->GetType() == ITEM_WELLSECTION)
// {
// CItemWellSection *pSectionItem = (CItemWellSection *)m_pDoc->GetItem();
// if (pSectionItem->m_pItemSelected == NULL)
// return FALSE;
//
// if (pSectionItem->m_pItemSelected->GetType() == ITEM_SECTIONWELL)
// {
// CItemSectionWell* pItemWell = (CItemSectionWell*)pSectionItem->m_pItemSelected;
// CWellPole *pWellObj = pItemWell->GetWellObject();
//
// CStdioFile fr;
// if (!fr.Open(filePathName, CFile::modeRead))
// return FALSE;
//
// pItemWell->SetReUnDoAction(FALSE);
//
//
// TRACKLIST tracklist;
// tracklist.assign(pWellObj->GetTrackList().begin(), pWellObj->GetTrackList().end());
// pWellObj->GetTrackList().clear();
//
// CString strWellTitle = pWellObj->m_strTitle;
// CString strWellName = pWellObj->GetWellName();
// double fLevel = pWellObj->m_fLevel;
// double topDepth = pWellObj->m_dSdep;
// double endDepth = pWellObj->m_dEdep;
// double top = pWellObj->GetPos().top;
// double left = pWellObj->GetPos().left;
// double proportion = pWellObj->m_fProportion;
// double dOldTrackHead = pWellObj->m_dHeightTrackHead;
// double dOldWellHead = pWellObj->m_dHeightTrackHead;
//
// std::vector<CWellPole::well_interval > oldWellIntervalVec;
// oldWellIntervalVec.insert(oldWellIntervalVec.begin(), pWellObj->GetIntervalVec()->begin(), pWellObj->GetIntervalVec()->end());
//
// AfxGetPublicFunction()->SetCodeType(CODE_GB2321);
//
// if (pWellObj->ReadPCG(fr, -1) == 0)
// {
// //恢复道备份
// TRACKLIST::reverse_iterator rit = tracklist.rbegin();
// for (; rit != tracklist.rend(); rit++)
// {
// pWellObj->GetTrackList().push_front(*rit);
// }
// tracklist.clear();
//
// return FALSE;
// }
// else
// {
// pWellObj->m_strTitle = strWellTitle;
// pWellObj->SetWellName(strWellName);
// pWellObj->m_fLevel = fLevel;
// pWellObj->GetPos().left = left;
// pWellObj->GetPos().top = top;
//
// pWellObj->m_dSdep = topDepth;
// pWellObj->m_dEdep = endDepth;
//
// pWellObj->GetIntervalVec()->clear();
// pWellObj->GetIntervalVec()->insert(pWellObj->GetIntervalVec()->begin(), oldWellIntervalVec.begin(), oldWellIntervalVec.end());
//
// pWellObj->m_fProportion = proportion;
// pWellObj->ReSetWellHead();
// pWellObj->CalculateSize(pWellObj->GetPos().TopLeft());
//
// //应用井模板
// TRACKLIST::iterator it = tracklist.begin();
// for (; it != tracklist.end(); it++)
// pWellObj->GetTemplateList().push_front(*it);
// pWellObj->ApplingTemplate(TRUE, dOldTrackHead, dOldWellHead);
//
// CWellSection *pSection = pSectionItem->GetWellSection();
// CWellPole* pWell = pItemWell->GetWellObject();
// POSITION pos = pSection->m_BendList.GetHeadPosition();
// while (pos)
// {
// CBendObj* pBend = (CBendObj*)pSection->m_BendList.GetNext(pos);
// if (pBend->m_pWellLeft == pWell || pBend->m_pWellRight == pWell)
// {
// pBend->ComputeBend();
// }
// }
// //ImportDataAll(pWellObj, FALSE);
// }
// }
// }
// return b;
//}
BOOL CMultiWellSectionView::CombineLeftTrack()
{
BOOL b = FALSE;
CMultiWellSectionDoc* pWellDoc = (CMultiWellSectionDoc*)GetDocument();
if (pWellDoc->GetItem() == NULL)
{
return FALSE;
}
if (pWellDoc->GetItem()->GetType() == ITEM_WELLSECTION)
{
CItemWellSection *pSectionItem = (CItemWellSection *)m_pDoc->GetItem();
if (pSectionItem->m_pItemSelected == NULL)
return FALSE;
if (pSectionItem->m_pItemSelected->GetType() == ITEM_SECTIONWELL)
{
CItemSectionWell* pItemWell = (CItemSectionWell*)pSectionItem->m_pItemSelected;
pItemWell->TrackLeftGroup();
b = TRUE;
}
}
return b;
}
BOOL CMultiWellSectionView::CombineRightTrack()
{
BOOL b = FALSE;
CMultiWellSectionDoc* pWellDoc = (CMultiWellSectionDoc*)GetDocument();
if (pWellDoc->GetItem() == NULL)
{
return FALSE;
}
if (pWellDoc->GetItem()->GetType() == ITEM_WELLSECTION)
{
CItemWellSection *pSectionItem = (CItemWellSection *)m_pDoc->GetItem();
if (pSectionItem->m_pItemSelected == NULL)
return FALSE;
if (pSectionItem->m_pItemSelected->GetType() == ITEM_SECTIONWELL)
{
CItemSectionWell* pItemWell = (CItemSectionWell*)pSectionItem->m_pItemSelected;
pItemWell->TrackRightGroup();
b = TRUE;
}
}
return b;
}
void CMultiWellSectionView::SaveUndoRedoAction()
{
CMultiWellSectionDoc* pWellDoc = (CMultiWellSectionDoc*)GetDocument();
if (pWellDoc->GetItem() == NULL)
{
return ;
}
if (pWellDoc->GetItem()->GetType() == ITEM_WELLSECTION)
{
CItemWellSection *pSectionItem = (CItemWellSection *)m_pDoc->GetItem();
if (pSectionItem->m_pItemSelected != NULL)
{
if (pSectionItem->m_pItemSelected->GetType() == ITEM_BEND || pSectionItem->m_pItemSelected->GetType() == ITEM_FAULT)
{
pSectionItem->SetReUnDoAction(FALSE, IDS_STRING_ACTION_MOVE, 2);
}
else
pSectionItem->SetReUnDoAction();
}
else
pSectionItem->SetReUnDoAction();
}
}
BOOL CMultiWellSectionView::ApplyingTemplateFileForWell(LPCSTR filePath, ULONGLONG wellHandle)
{
BOOL b = FALSE;
CMultiWellSectionDoc* pWellDoc = (CMultiWellSectionDoc*)GetDocument();
if (pWellDoc->GetItem() == NULL)
{
return b;
}
if (pWellDoc->GetItem()->GetType() == ITEM_WELLSECTION)
{
CItemWellSection* pSectionItem = (CItemWellSection*)m_pDoc->GetItem();
b =pSectionItem->ApplyingTemplateFileForWell(filePath, wellHandle);
}
return b;
}
BOOL CMultiWellSectionView::ApplyingTemplateFileForSection(LPCSTR filePath)
{
BOOL b = FALSE;
CMultiWellSectionDoc* pWellDoc = (CMultiWellSectionDoc*)GetDocument();
if (pWellDoc->GetItem() == NULL)
{
return b;
}
if (pWellDoc->GetItem()->GetType() == ITEM_WELLSECTION)
{
CItemWellSection* pSectionItem = (CItemWellSection*)m_pDoc->GetItem();
b = pSectionItem->ApplyingTemplateFileForWell(filePath, 0);
}
return b;
}
BOOL CMultiWellSectionView::ApplyingWellTemplateForSection(ULONGLONG wellHandle)
{
BOOL b = FALSE;
CMultiWellSectionDoc* pWellDoc = (CMultiWellSectionDoc*)GetDocument();
if (pWellDoc->GetItem() == NULL)
{
return b;
}
if (pWellDoc->GetItem()->GetType() == ITEM_WELLSECTION)
{
CItemWellSection* pSectionItem = (CItemWellSection*)m_pDoc->GetItem();
b = pSectionItem->ApplyingWellTemplateForSection(wellHandle);
}
return b;
}
void CMultiWellSectionView::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();
}