|
|
// WellPoleDoc.cpp: 实现文件
|
|
|
//
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
|
|
// WellPoleDoc
|
|
|
#include "ItemSelect.h"
|
|
|
#include "DrawOperator/XyIO.h"
|
|
|
#include "DrawOperator/FileUtility.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 "ItemSingleWell.h"
|
|
|
#include "ItemViewWellPole.h"
|
|
|
#include "WellPoleDoc.h"
|
|
|
#include "WellPoleView.h"
|
|
|
#include "SigmaStore.h"
|
|
|
|
|
|
|
|
|
CWellPoleDoc::CWellPoleDoc()
|
|
|
{
|
|
|
//m_pItemView = std::make_unique<CItemView>(this);
|
|
|
m_pItemView = nullptr;
|
|
|
m_pItemView = std::make_unique<CItemViewWellPole>(this);
|
|
|
}
|
|
|
|
|
|
|
|
|
CWellPoleDoc::~CWellPoleDoc()
|
|
|
{
|
|
|
DeleteItem();
|
|
|
}
|
|
|
|
|
|
//
|
|
|
//CItem* CWellPoleDoc::GetOtherItem(void)
|
|
|
//{
|
|
|
// return m_pOtherItem;
|
|
|
//}
|
|
|
//
|
|
|
//
|
|
|
//void CWellPoleDoc::SetOtherItem(CItem* pItem)
|
|
|
//{
|
|
|
// m_pOtherItem = pItem;
|
|
|
// CMainFrame* pmf = (CMainFrame*)GetMainFrame();
|
|
|
// if (pmf)
|
|
|
// pmf->UpdatePropertyGridContent(pItem);
|
|
|
//}
|
|
|
|
|
|
//
|
|
|
//void CWellPoleDoc::DeleteOtherItem(void)
|
|
|
//{
|
|
|
// CMainFrame* pmf = (CMainFrame*)GetMainFrame();
|
|
|
// if (pmf)
|
|
|
// pmf->SetFocus();
|
|
|
// if (GetSelectItem())
|
|
|
// GetSelectItem()->CancelSelection();
|
|
|
// if (m_pOtherItem)delete m_pOtherItem;
|
|
|
// m_pOtherItem = NULL;
|
|
|
// if (pmf)
|
|
|
// pmf->UpdatePropertyGridContent(NULL);
|
|
|
//}
|
|
|
|
|
|
//int CWellPoleDoc::GetOtherItemType(void)
|
|
|
//{
|
|
|
// if (GetOtherItem())
|
|
|
// return GetOtherItem()->GetType();
|
|
|
// return 0;
|
|
|
//}
|
|
|
//
|
|
|
//void CWellPoleDoc::InvalidateDelete(CPositionList& list)
|
|
|
//{
|
|
|
// MoveSelect = NULL;
|
|
|
// this->EnableRedraw(true);
|
|
|
// UpdateAllViews(NULL, HINT_DELETE_SELECTION, &list);
|
|
|
//}
|
|
|
//
|
|
|
//void CWellPoleDoc::Invalidate(void)
|
|
|
//{
|
|
|
// CDrawDoc::Invalidate();
|
|
|
// InvalidateEagleEye();
|
|
|
//}
|
|
|
//
|
|
|
//void CWellPoleDoc::InvalidateEagleEye(void)
|
|
|
//{
|
|
|
// CMainFrame* pmf = (CMainFrame*)GetMainFrame();
|
|
|
// if (pmf)
|
|
|
// pmf->InvalidateEagleEye();
|
|
|
//}
|
|
|
//
|
|
|
//BOOL CWellPoleDoc::SetDefaultCursor(void)
|
|
|
//{
|
|
|
// if (GetItemView().IsViewState())
|
|
|
// return CDrawDoc::SetDefaultCursor();
|
|
|
// if (GetItem())
|
|
|
// return GetItem()->OnSetCursor(NULL, HTCLIENT, 0);
|
|
|
// return FALSE;
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
// WellPoleDoc 命令
|
|
|
|
|
|
CItem* CWellPoleDoc::FindItem(int nType)
|
|
|
{
|
|
|
CItem* pit = NULL;
|
|
|
if (nType == ITEM_WELLPOLE)
|
|
|
{
|
|
|
pit = new CItemSingleWell(this);
|
|
|
return pit;
|
|
|
}
|
|
|
else
|
|
|
return CSigmaDoc::FindItem(nType);
|
|
|
}
|
|
|
|
|
|
//BOOL CWellPoleDoc::IsItemEnable(int type)
|
|
|
//{
|
|
|
// if (GetItemType() == ITEM_SCALE_OBJECT)
|
|
|
// return FALSE;
|
|
|
// if (GetOtherItem())
|
|
|
// {
|
|
|
// if (GetOtherItemType() == ITEM_FIND)
|
|
|
// return FALSE;
|
|
|
// if (type == ITEM_CURVE) return TRUE;
|
|
|
// return (type == GetOtherItemType()) ? TRUE : FALSE;
|
|
|
// }
|
|
|
// return TRUE;
|
|
|
//}
|
|
|
//
|
|
|
//void CWellPoleDoc::DeleteContents()
|
|
|
//{
|
|
|
// CDrawDoc::DeleteContents();
|
|
|
//}
|
|
|
|
|
|
int CWellPoleDoc::GetNodeWidth(void)
|
|
|
{
|
|
|
return 2;
|
|
|
}
|
|
|
|
|
|
|
|
|
//CString CWellPoleDoc::GetElementString(POSITION pSelect, CPoint2D* pPoint)
|
|
|
//{
|
|
|
// CString str, string;
|
|
|
// if (pSelect == NULL || !::AfxIsValidAddress(pSelect, sizeof(POSITION)))
|
|
|
// {
|
|
|
// if (GetSelectItem() == NULL)
|
|
|
// string.LoadString(IDS_STRING_DoubleFox);
|
|
|
// else
|
|
|
// string.LoadString(IDS_STRING_SELECT_COMMAND);
|
|
|
// return string;
|
|
|
// }
|
|
|
// return CDrawDoc::GetElementString(pSelect, pPoint);
|
|
|
//}
|
|
|
|
|
|
CItemSelect* CWellPoleDoc::GetSelectItem(void)
|
|
|
{
|
|
|
if (GetItem() == NULL) return NULL;
|
|
|
if (GetItem()->GetType() != ITEM_SELECT && !GetItem()->IsNestItem())
|
|
|
return NULL;
|
|
|
return (CItemSelect*)GetItem();
|
|
|
}
|
|
|
|
|
|
void CWellPoleDoc::RemoveAt(COne* pOne)
|
|
|
{
|
|
|
GetDraw()->RemoveAt(pOne);
|
|
|
}
|
|
|
|
|
|
CSize CWellPoleDoc::GetDocSize(void)
|
|
|
{
|
|
|
CSize sizeTotal(100, 100);
|
|
|
if (GetDraw() == NULL)return sizeTotal;
|
|
|
if (GetDraw()->GetCount() == 0)return sizeTotal;
|
|
|
|
|
|
CRect8 rect = GetDraw()->m_range;
|
|
|
double xm, ym, dx, dy;
|
|
|
dx = rect.right - rect.left;
|
|
|
dy = rect.top - rect.bottom;
|
|
|
xm = GetDC().left - rect.left;
|
|
|
ym = rect.top - GetDC().top;
|
|
|
|
|
|
int hts = GetDC().GetScreenWidth(dx);
|
|
|
int vts = GetDC().GetScreenHeight(fabs(dy));
|
|
|
vts = abs(vts);
|
|
|
|
|
|
sizeTotal.cx = hts;
|
|
|
sizeTotal.cy = vts;
|
|
|
return sizeTotal;
|
|
|
}
|
|
|
|
|
|
//CSize CWellPoleDoc::GetHandleSize(void)
|
|
|
//{
|
|
|
// return GetTracker().GetHandleSize();
|
|
|
//}
|
|
|
//
|
|
|
//CRect CWellPoleDoc::GetHandleRect(LPPOINT lpPoint)
|
|
|
//{
|
|
|
// return GetTracker().GetHandleRect(lpPoint);
|
|
|
//}
|
|
|
//
|
|
|
//void CWellPoleDoc::UpdatePropertyGridContent(CItem* pItem)
|
|
|
//{
|
|
|
// CMainFrame* pmf = (CMainFrame*)GetMainFrame();
|
|
|
// if (pmf)
|
|
|
// pmf->UpdatePropertyGridContent(pItem);
|
|
|
//}
|
|
|
|
|
|
//void CWellPoleDoc::UpdateSelection(void)
|
|
|
//{
|
|
|
// CItemSelect* pItem = GetSelectItem();
|
|
|
// if (pItem == NULL) return;
|
|
|
// BOOL bRemove = FALSE;
|
|
|
// COne* pOne;
|
|
|
// POSITION pos, pt;
|
|
|
// pt = pItem->m_selection.GetHeadPosition();
|
|
|
// while (pt)
|
|
|
// {
|
|
|
// pos = pItem->m_selection.GetNext(pt);
|
|
|
// pOne = GetDraw()->GetAt(pos);
|
|
|
// if (!pOne->GetLayer()->IsViewAndEdit())
|
|
|
// {
|
|
|
// pItem->Deselect(pos);
|
|
|
// bRemove = TRUE;
|
|
|
// }
|
|
|
// }
|
|
|
// if (bRemove) pItem->ReloadTrackerPath();
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
//void CWellPoleDoc::OnFileSaveView()
|
|
|
//{
|
|
|
// CString name;
|
|
|
// if (!GetFileName(FALSE, name, "*.kev")) return;
|
|
|
// CStdioFile fw;
|
|
|
// if (!fw.Open(name, CFile::modeCreate | CFile::modeWrite))
|
|
|
// {
|
|
|
// ::AfxMessageBox(IDS_STRING_OPEN_WRITE_ERROR);
|
|
|
// return;
|
|
|
// }
|
|
|
// BeginProgress(IDS_STRING_WriteFile);
|
|
|
// GetDraw()->DFD_WriteViewData(*(CFile*)&fw, CUR_VERSION);
|
|
|
// EndProgress();
|
|
|
// fw.Close();
|
|
|
//}
|
|
|
//
|
|
|
//void CWellPoleDoc::OnFileSaveSelected()
|
|
|
//{
|
|
|
// CItemSelect* pItem = GetSelectItem();
|
|
|
// if (pItem == NULL) return;
|
|
|
//
|
|
|
// CString name;
|
|
|
// if (!GetFileName(FALSE, name, "*.kev")) return;
|
|
|
// CStdioFile fw;
|
|
|
// if (!fw.Open(name, CFile::modeCreate | CFile::modeWrite))
|
|
|
// {
|
|
|
// ::AfxMessageBox(IDS_STRING_OPEN_WRITE_ERROR);
|
|
|
// return;
|
|
|
// }
|
|
|
// BeginProgress(IDS_STRING_WriteFile);
|
|
|
// GetDraw()->DFD_Write(*(CFile*)&fw, pItem->m_selection);
|
|
|
// EndProgress();
|
|
|
// fw.Close();
|
|
|
//}
|
|
|
//
|
|
|
//void CWellPoleDoc::OnUpdateFileSaveSelected(CCmdUI *pCmdUI)
|
|
|
//{
|
|
|
// CItemSelect* pItem = GetSelectItem();
|
|
|
// if (pItem == NULL)
|
|
|
// pCmdUI->Enable(FALSE);
|
|
|
// else if (pItem->GetSelectedCount() <= 0)
|
|
|
// pCmdUI->Enable(FALSE);
|
|
|
// else
|
|
|
// pCmdUI->Enable(TRUE);
|
|
|
//}
|
|
|
|
|
|
|
|
|
//CXy* CWellPoleDoc::GetDraw(void)
|
|
|
//{
|
|
|
// if (m_pMarkDraw)
|
|
|
// return m_pMarkDraw;
|
|
|
// return CDrawDoc::GetDraw();
|
|
|
//}
|
|
|
|
|
|
//
|
|
|
//BOOL CWellPoleDoc::OnOpenDocument(LPCTSTR lpszPathName)
|
|
|
//{
|
|
|
// //CDrawUndoManager::RegisterDoc(this);
|
|
|
// //return CDrawDoc::OnOpenDocument(lpszPathName);
|
|
|
// GetDraw()->SetXyType(CXy::XYTYPE::wellPole);
|
|
|
// return CSSDrawProDoc::OnOpenDocument(lpszPathName);
|
|
|
//}
|
|
|
//
|
|
|
//BOOL CWellPoleDoc::OnSaveDocument(LPCTSTR lpszPathName)
|
|
|
//{
|
|
|
// //SaveBackup(lpszPathName);
|
|
|
// GetDraw()->SetXyType(CXy::XYTYPE::wellPole);
|
|
|
// return CSSDrawProDoc::OnSaveDocument(lpszPathName);
|
|
|
//}
|
|
|
//
|
|
|
//
|
|
|
//BOOL CWellPoleDoc::DoSave(LPCTSTR lpszPathName, BOOL bReplace /*=TRUE*/)
|
|
|
//{
|
|
|
// return CSSDrawProDoc::DoSave(lpszPathName,bReplace);
|
|
|
//}
|
|
|
//
|
|
|
//void CWellPoleDoc::OnCloseDocument()
|
|
|
//{
|
|
|
// //if (m_hCopyDataWnd)
|
|
|
// //{
|
|
|
// // ::SendMessage(m_hCopyDataWnd, WM_CLOSE, 0, 0);
|
|
|
// // m_hCopyDataWnd = NULL;
|
|
|
// //}
|
|
|
//
|
|
|
// CSSDrawProDoc::OnCloseDocument();
|
|
|
//}
|
|
|
//
|
|
|
//BOOL CWellPoleDoc::OnNewDocument()
|
|
|
//{
|
|
|
// if (!CDrawDoc::OnNewDocument())
|
|
|
// return FALSE;
|
|
|
//
|
|
|
// int nUndoMax = ::GetPreferences().Workaround.m_nMaxUndoNum;
|
|
|
// if (nUndoMax <= 0) nUndoMax = UM_DEFAULT_STACK_CAPACITY;
|
|
|
// CDrawUndoManager::RegisterDoc(this, nUndoMax);
|
|
|
//
|
|
|
// // TODO: 在此添加重新初始化代码
|
|
|
// if (GetDraw())
|
|
|
// {
|
|
|
// SYSTEMTIME time;
|
|
|
// ::GetSystemTime(&time);
|
|
|
// GetDraw()->m_strDate.Format("%4d/%2d/%2d", time.wYear, time.wMonth, time.wDay);
|
|
|
// GetDraw()->m_strDate.Replace(" ", "0");
|
|
|
// }
|
|
|
//
|
|
|
// // (SDI 文档将重用该文档)
|
|
|
// CMainFrame* pmf = (CMainFrame*)GetMainFrame();
|
|
|
// if (pmf)
|
|
|
// {
|
|
|
// pmf->UpdatePropertyGridContent(NULL);//增加属性内容
|
|
|
// pmf->LoadLayer(GetDraw());
|
|
|
// }
|
|
|
//
|
|
|
// return TRUE;
|
|
|
//}
|
|
|
|
|
|
//void CWellPoleDoc::SetModifiedFlag(BOOL bModified /*= TRUE*/)
|
|
|
//{
|
|
|
// CSSDrawProDoc::SetModifiedFlag(bModified);
|
|
|
//}
|
|
|
//
|
|
|
//
|
|
|
//
|
|
|
//BOOL CWellPoleDoc::SaveModified()
|
|
|
//{
|
|
|
// // TODO: Add your specialized code here and/or call the base class
|
|
|
// BOOL rm = FALSE;
|
|
|
// if (IsModified())
|
|
|
// rm = ModifyTitle(FALSE);//去掉修改标志
|
|
|
//
|
|
|
// BOOL rt = CDrawDoc::SaveModified();
|
|
|
//
|
|
|
// if (!rt)
|
|
|
// ModifyTitle(TRUE); //恢复修改标志
|
|
|
// return rt;
|
|
|
//}
|
|
|
|
|
|
//void CWellPoleDoc::OnFileSave()
|
|
|
//{
|
|
|
// DoFileSave();
|
|
|
//}
|
|
|
//
|
|
|
//void CWellPoleDoc::OnFileSaveAs()
|
|
|
//{
|
|
|
// if (!DoSave(NULL, 2))
|
|
|
// TRACE(traceAppMsg, 0, "Warning: File save-as failed.\n");
|
|
|
//}
|
|
|
|
|
|
|
|
|
//void CWellPoleDoc::DocInit(void) //建立m_pItemView、m_pItemPrint的对象生成
|
|
|
//{
|
|
|
// //if (m_pDraw) delete m_pDraw; m_pDraw = NULL;
|
|
|
// //if (m_pItemPrint) delete m_pItemPrint; m_pItemPrint = NULL;
|
|
|
// //if (m_pItemView) delete m_pItemView; m_pItemView = NULL;
|
|
|
//
|
|
|
// //m_pDraw = new CXy();
|
|
|
// //m_pItemPrint = new CItemPrintEx(this);
|
|
|
// //m_pItemView = new CItemViewEx(this);
|
|
|
//}
|
|
|
|
|
|
//void CWellPoleDoc::OpenDocumentEnd(void)
|
|
|
//{
|
|
|
// AfxGetGlobalMark()->SetMark(GetDraw()->GetMark());
|
|
|
// //GetEagleEyeParameter()->m_rtEagleEyeRange = GetDraw()->GetRange();
|
|
|
//
|
|
|
// CMainFrame* pmf = (CMainFrame*)GetMainFrame();
|
|
|
// if (pmf)
|
|
|
// {
|
|
|
// pmf->LoadLayer(GetDraw());
|
|
|
// }
|
|
|
//}
|
|
|
|
|
|
//void CWellPoleDoc::DrawItem(CXyDC& dc, int nModeX, int nModeY)
|
|
|
//{
|
|
|
// if (GetItem())
|
|
|
// GetItem()->OnDraw(&dc);
|
|
|
//}
|
|
|
|
|
|
|
|
|
//void CWellPoleDoc::EnableToolSelection(void)
|
|
|
//{
|
|
|
// DeleteOtherItem();
|
|
|
// SetItem(FindItem(ITEM_SELECT));
|
|
|
// SetDefaultCursor();
|
|
|
//}
|
|
|
|
|
|
//void CWellPoleDoc::EnableDefaultTool(void)
|
|
|
//{
|
|
|
// if (ItemState.m_nDefaultToolSel == 1)
|
|
|
// EnableToolSelection();
|
|
|
// else
|
|
|
// EnableArrowTool();
|
|
|
//}
|
|
|
|
|
|
//void CWellPoleDoc::EnableArrowTool(void)
|
|
|
//{
|
|
|
// DeleteItem();
|
|
|
// DeleteOtherItem();
|
|
|
// SetDefaultCursor();
|
|
|
//}
|
|
|
|
|
|
|
|
|
//void CWellPoleDoc::InitDocGrid(CXTPPropertyGrid& grid)
|
|
|
//{
|
|
|
//CPropertyGridItemAdd ItemAdd(NULL);
|
|
|
//CItem im(this);
|
|
|
//CString strFormat = im.GetFloatFormatString();
|
|
|
//CString str;
|
|
|
//CXTPPropertyGridItem* pItem;
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
//pItem = grid.AddCategory("Object");
|
|
|
//ItemAdd.SetItem(pItem);
|
|
|
//pItem->Expand();
|
|
|
|
|
|
//pItem = ItemAdd.AddItemString(IDS_STRING_NAME, GetDraw()->m_strName, &GetDraw()->m_strName);
|
|
|
//pItem = ItemAdd.AddItemString(IDS_GI_AUTHOR, GetDraw()->m_strMaker, &GetDraw()->m_strMaker);
|
|
|
//pItem = ItemAdd.AddItemString(IDS_GI_CREATE_DATA, GetDraw()->m_strDate); pItem->SetReadOnly(TRUE);
|
|
|
|
|
|
//pItem = grid.AddCategory(IDS_STRING_SCALE);
|
|
|
//ItemAdd.SetItem(pItem);
|
|
|
//pItem->Expand();
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
//pItem = ItemAdd.AddItemCombo(IDS_STRING_UNIT, IDS_STRING_UNIT_SELECT, GetDraw()->m_unit.cx, &(GetDraw()->m_unit.cx));
|
|
|
///*pItem->SetReadOnly(TRUE);*/
|
|
|
|
|
|
//str.LoadString(IDS_STRING_SCALE);
|
|
|
//str = CString("1 : ") + str;
|
|
|
//ItemAdd.AddItemDouble(str, GetDraw()->m_dScaleFactor, strFormat, &GetDraw()->m_dScaleFactor);
|
|
|
|
|
|
//ItemAdd.AddItemCombo(IDS_INPUT_UNIT_MODE, IDS_INPUT_UNIT_MODE_LIST, m_nUnitMode, &m_nUnitMode);
|
|
|
//}
|
|
|
|
|
|
|
|
|
//BOOL CWellPoleDoc::OnGridItemChangeValue(CXTPPropertyGridItem* pItem)
|
|
|
//{
|
|
|
// BOOL bUpdate = TRUE;
|
|
|
// switch (pItem->GetID())
|
|
|
// {
|
|
|
// default:
|
|
|
// bUpdate = FALSE;
|
|
|
// break;
|
|
|
// case IDS_GI_AUTHOR:
|
|
|
// case IDS_STRING_SCALE:
|
|
|
// break;
|
|
|
// }
|
|
|
// return bUpdate;
|
|
|
//}
|
|
|
void CWellPoleDoc::SetActionItem(CActionItem* pAction, bool bDo/*=true*/)
|
|
|
{
|
|
|
m_pLastAction = pAction;
|
|
|
if (bDo) m_pLastAction->Do();
|
|
|
}
|
|
|
|
|
|
//
|
|
|
//BOOL CWellPoleDoc::Edit(POSITION pos)
|
|
|
//{
|
|
|
// if (pos == NULL) return FALSE;
|
|
|
// CWellPoleView* pView = (CWellPoleView*)GetActiveView();
|
|
|
// COne* pOne = (COne*)GetDraw()->GetAt(pos);
|
|
|
// switch (pOne->GetType())
|
|
|
// {
|
|
|
// case DOUBLEFOX_CURVE_STATION:
|
|
|
// this->SetItem(new CItemCurveStation(this));
|
|
|
// break;
|
|
|
// case DOUBLEFOX_TV:
|
|
|
// this->SetItem(new CItemCurveTV(this));
|
|
|
// break;
|
|
|
// case DOUBLEFOX_CURVE:
|
|
|
// this->SetItem(FindItem(ITEM_CURVE_EDIT));
|
|
|
// break;
|
|
|
// case DOUBLEFOX_TEXT:
|
|
|
// this->SetItem(FindItem(ITEM_TEXT));
|
|
|
// ((CItemText*)GetItem())->EditText(pOne);
|
|
|
// break;
|
|
|
// case DOUBLEFOX_STATION:
|
|
|
// {
|
|
|
// //CXy* pxy = (CXy*)(((CStation*)pOne->GetValue())->pDraw);
|
|
|
// //pView->ModifiedMark(pxy);
|
|
|
// }
|
|
|
// break;
|
|
|
// case DOUBLEFOX_BLOCK:
|
|
|
// case DOUBLEFOX_PATHFILL:
|
|
|
// case DOUBLEFOX_3D_FAULTSURFACE:
|
|
|
// {
|
|
|
// //CXyBlock* pb = (CXyBlock*)pOne->GetValue();
|
|
|
// //pView->ModifiedMark((CXy*)pb->GetXy());
|
|
|
// }
|
|
|
// break;
|
|
|
// case DOUBLEFOX_OLE:
|
|
|
// //this->SetItem(FindItem(ITEM_OLE));
|
|
|
// //GetItem()->SetPos(pos);
|
|
|
// //((CItemOle*)GetItem())->EditOle();
|
|
|
// //break;
|
|
|
// //case DOUBLEFOX_WELL:
|
|
|
// // {
|
|
|
// // this->SetItem(FindItem(ITEM_WELL));
|
|
|
// // }
|
|
|
// // break;
|
|
|
// //case DOUBLEFOX_CROSS:
|
|
|
// // {
|
|
|
// // this->SetItem(FindItem(ITEM_REGIONSELECT));
|
|
|
// // }
|
|
|
// // break;
|
|
|
// /*
|
|
|
// case DOUBLEFOX_PLATE:
|
|
|
// {
|
|
|
// this->SetItem(FindItem(ITEM_PLATEEDIT));
|
|
|
// }
|
|
|
// break;
|
|
|
// */
|
|
|
// //case DOUBLEFOX_WELLDATAGRAPH:
|
|
|
// //{
|
|
|
// // this->SetItem(FindItem(ITEM_WELLDATAGRAPH));
|
|
|
// //}
|
|
|
// //break;
|
|
|
// //case DOUBLEFOX_CHARTEX:
|
|
|
// //{
|
|
|
// // this->SetItem(FindItem(ITEM_CHARTEX_EDIT));
|
|
|
// //}
|
|
|
// //break;
|
|
|
// case DOUBLEFOX_RECTLABEL:
|
|
|
// {
|
|
|
// this->SetItem(FindItem(ITEM_LABEL_RECT_EDIT));
|
|
|
// GetItem()->SetPos(pos);
|
|
|
// }
|
|
|
// break;
|
|
|
// default:
|
|
|
// SetSelection(pos);
|
|
|
// if (GetMainFrame())
|
|
|
// GetMainFrame()->SendMessage(WM_COMMAND, ID_EDIT_TOOL_PROPERTIES);
|
|
|
// break;
|
|
|
// }
|
|
|
// if (GetItem() == NULL) return FALSE;
|
|
|
// GetItem()->SetPos(pos);
|
|
|
// UpdatePropertyGridContent(GetItem());
|
|
|
// this->Invalidate(pOne);
|
|
|
// return TRUE;
|
|
|
//}
|
|
|
|
|
|
BOOL CWellPoleDoc::GetElementRect(POSITION pos, CRect8& range)
|
|
|
{
|
|
|
if (pos == NULL) return FALSE;
|
|
|
range = GetDraw()->GetAt(pos)->GetRect();
|
|
|
return TRUE;
|
|
|
}
|
|
|
|
|
|
|
|
|
POSITION CWellPoleDoc::AddElement(COne* pOne)
|
|
|
{
|
|
|
return GetDraw()->AddTailOne(pOne);
|
|
|
}
|
|
|
|
|
|
//
|
|
|
//void CWellPoleDoc::SetSelection(CPositionList& list)
|
|
|
//{
|
|
|
// if (GetItemType() != ITEM_SELECT)
|
|
|
// this->SetItem(FindItem(ITEM_SELECT));
|
|
|
// GetSelectItem()->Select(list);
|
|
|
//}
|
|
|
//
|
|
|
//void CWellPoleDoc::SetSelection(POSITION pos)
|
|
|
//{
|
|
|
// if (pos == NULL) return;
|
|
|
// CPositionList list;
|
|
|
// list.AddHead(pos);
|
|
|
// SetSelection(list);
|
|
|
//}
|
|
|
|
|
|
|
|
|
void CWellPoleDoc::OnDraw(CXyDC& dc)
|
|
|
{
|
|
|
//TRACE(_T("CDrawDoc::OnDraw(CXyDC&),count=%ld\n"), GetDraw()->GetCount());
|
|
|
GetDraw()->Draw(dc, false);
|
|
|
}
|
|
|
|
|
|
void CWellPoleDoc::Serialize(CArchive& ar)
|
|
|
{
|
|
|
CPublicFunction& pf = *AfxGetPublicFunction();
|
|
|
if (ar.IsStoring())
|
|
|
{
|
|
|
short ver = -1;
|
|
|
|
|
|
if (m_nDocTypeID == DF_FORMAT_PCG)
|
|
|
{
|
|
|
//BeginProgress(IDS_STRING_WriteFile);
|
|
|
|
|
|
CWellPole* pWell = GetWellPole();
|
|
|
if (pWell)
|
|
|
{
|
|
|
CXy* pxy = GetDraw();
|
|
|
CXyIO xy; xy.AttachInput(pxy, false);
|
|
|
|
|
|
CRect rt = GetView()->GetClientRect();
|
|
|
pxy->m_display = GetDC().GetReal(rt);
|
|
|
pxy->m_display.NormalizeRect();
|
|
|
GetDC().GetScale(pxy->m_scaleSize.cx, pxy->m_scaleSize.cy);
|
|
|
|
|
|
pxy->PCG_WriteWellColumn(*ar.GetFile(), ver);
|
|
|
}
|
|
|
|
|
|
//EndProgress();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
CSigmaDoc::Serialize(ar);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
CSigmaDoc::Serialize(ar);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
CWellPole* CWellPoleDoc::GetWellPole()
|
|
|
{
|
|
|
CWellPole *pWell = NULL;
|
|
|
POSITION pos = GetDraw()->GetValueList()->GetHeadPosition();
|
|
|
while(pos != NULL)
|
|
|
{
|
|
|
COne* pOne = (COne*)GetDraw()->GetValueList()->GetNext(pos);
|
|
|
if (pOne->GetType() == KEP_WELL)
|
|
|
{
|
|
|
pWell = (CWellPole*)pOne->GetValue();
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return pWell;
|
|
|
}
|
|
|
|
|
|
COne* CWellPoleDoc::GetWellPoleOne()
|
|
|
{
|
|
|
CWellPole *pWell = NULL;
|
|
|
POSITION pos = GetDraw()->GetValueList()->GetHeadPosition();
|
|
|
while (pos != NULL)
|
|
|
{
|
|
|
COne* pOne = (COne*)GetDraw()->GetValueList()->GetNext(pos);
|
|
|
if (pOne->GetType() == KEP_WELL)
|
|
|
{
|
|
|
return pOne;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
|
|
|
void CWellPoleDoc::NormalEXTLogFont(GDFLOGFONTEXT& font)
|
|
|
{
|
|
|
long nH = font.m_logFont.lfHeight;
|
|
|
|
|
|
double dScaleX = 1;
|
|
|
double dScaleY = 1;
|
|
|
GetDC().GetScale(dScaleX, dScaleY);
|
|
|
GetDC().SetScale(0.1, 0.1);
|
|
|
font.m_dHeight = GetDC().GetRealHeight(nH*72.0 / GetDC().GetDC()->GetDeviceCaps(LOGPIXELSY));
|
|
|
GetDC().SetScale(dScaleX, dScaleY);
|
|
|
|
|
|
if (font.m_logFont.lfFaceName == "Times New Roman")
|
|
|
font.m_dWidth = font.m_dHeight*0.4;
|
|
|
else
|
|
|
font.m_dWidth = font.m_dHeight*0.5;
|
|
|
}
|
|
|
|
|
|
|
|
|
CWellPole* CWellPoleDoc::CreateNewWell(CREATENEWWELLSTRUCT wellStruct)
|
|
|
{
|
|
|
BOOL bReadTemplate = FALSE;
|
|
|
|
|
|
CWellPole* pWell = NULL; // = new CWellPole();
|
|
|
|
|
|
if (!wellStruct.strWellTemplateFilePath.IsEmpty())
|
|
|
{//读取模板成图
|
|
|
|
|
|
CFile file;
|
|
|
if (file.Open(wellStruct.strWellTemplateFilePath, CFile::modeRead | CFile::typeBinary))
|
|
|
{
|
|
|
if (GetDraw()->PCG_Read(file) == 1)
|
|
|
{
|
|
|
bReadTemplate = TRUE;
|
|
|
pWell = GetWellPole();
|
|
|
}
|
|
|
else
|
|
|
AfxMessageBox("读取模板文件失败");
|
|
|
|
|
|
file.Close();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
AfxMessageBox("读取模板文件失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (bReadTemplate == FALSE)
|
|
|
{//不试用模板或读取模板文件失败
|
|
|
pWell = new CWellPole();
|
|
|
pWell->SetParentXY(GetDraw());
|
|
|
|
|
|
CTrackCurve* pTrackCurve = new CTrackCurve();
|
|
|
pTrackCurve->m_strTitle = pTrackCurve->m_strTrackName = "曲线1";
|
|
|
pWell->AddTrack(pTrackCurve);
|
|
|
pTrackCurve->m_dTrackWidth = 30;
|
|
|
|
|
|
CTrackDepth* pTrackDep = new CTrackDepth();
|
|
|
pTrackDep->m_strTitle = pTrackDep->m_strTrackName = "深度";
|
|
|
pWell->AddTrack(pTrackDep);
|
|
|
|
|
|
CTrackResult *pResultTrack = new CTrackResult();
|
|
|
pResultTrack->m_strTitle = pResultTrack->m_strTrackName = "解释结果";
|
|
|
pWell->AddTrack(pResultTrack);
|
|
|
pResultTrack->m_dTrackWidth = 30;
|
|
|
|
|
|
CTrackCurve* pTrackCurve1 = new CTrackCurve();
|
|
|
pTrackCurve1->m_strTitle = pTrackCurve->m_strTrackName = "曲线2";
|
|
|
pWell->AddTrack(pTrackCurve1);
|
|
|
pTrackCurve1->m_dTrackWidth = 30;
|
|
|
|
|
|
GetDraw()->AddElement(pWell, KEP_WELL);
|
|
|
}
|
|
|
|
|
|
pWell->SetWellName(wellStruct.strWellName);
|
|
|
pWell->SetTitle(wellStruct.strWellName);
|
|
|
pWell->SetDepthProportion(wellStruct.ratio);
|
|
|
pWell->SetWellDepth(wellStruct.top, wellStruct.bottom);
|
|
|
|
|
|
pWell->CalculateSize(pWell->GetRect().TopLeft());
|
|
|
CWellPoleView* pView = (CWellPoleView*)GetView();
|
|
|
if(pView)
|
|
|
pView->ExtendViewForNewWell(pWell);
|
|
|
|
|
|
return pWell;
|
|
|
|
|
|
}
|
|
|
|
|
|
BOOL CWellPoleDoc::GetDrawRange(CRect8& rect)
|
|
|
{
|
|
|
CWellPole* pWellPole = GetWellPole();
|
|
|
if(pWellPole == NULL)
|
|
|
return CSigmaDoc::GetDrawRange(rect);
|
|
|
else
|
|
|
{
|
|
|
rect = pWellPole->GetRect();
|
|
|
rect.InflateRect(pWellPole->m_fMarginLR, pWellPole->m_fMarginTB);
|
|
|
}
|
|
|
return TRUE;
|
|
|
}
|
|
|
|
|
|
|
|
|
void CWellPoleDoc::ClearSelection(void)
|
|
|
{
|
|
|
if (GetItemType() == ITEM_SELECT || GetItemType() == ITEM_WELL)
|
|
|
GetSelectItem()->CancelSelection();
|
|
|
}
|
|
|
|
|
|
CWellPole* CWellPoleDoc::CreateNewWell( LPCTSTR wellName, double top, double bottom, double ratio, LPCTSTR wellTemplateFile)
|
|
|
{
|
|
|
if (ratio < 1)
|
|
|
ratio = 200;
|
|
|
if (bottom < top)
|
|
|
bottom = top + 100;
|
|
|
|
|
|
m_newWellStruct.strWellName = wellName;
|
|
|
m_newWellStruct.top = top;
|
|
|
m_newWellStruct.bottom = bottom;
|
|
|
m_newWellStruct.ratio = ratio;
|
|
|
m_newWellStruct.strWellTemplateFilePath = wellTemplateFile;
|
|
|
|
|
|
return CreateNewWell(m_newWellStruct);
|
|
|
}
|
|
|
|
|
|
BOOL CWellPoleDoc::OpenFile(LPCTSTR lpszFileName, BOOL bMergeFile)
|
|
|
{
|
|
|
if (!bMergeFile)
|
|
|
{
|
|
|
if (m_pXy != NULL) {
|
|
|
m_pXy->Clear();
|
|
|
}
|
|
|
// GdfCloseFile();
|
|
|
}
|
|
|
if (m_pXy == NULL)
|
|
|
m_pXy = new CXy;
|
|
|
|
|
|
m_pXy->SetXyType(CXy::XYTYPE::wellPole);
|
|
|
// 如果是恢复模式,就用备份的数据和Action替换从文件获取内容
|
|
|
if (m_recoverMode)
|
|
|
{
|
|
|
if (CSigmaStore::GetInstance().Load(this, lpszFileName))
|
|
|
{
|
|
|
return TRUE;
|
|
|
}
|
|
|
return FALSE;
|
|
|
}
|
|
|
AfxGetPublicFunction()->EnableJudgeRange(TRUE);
|
|
|
|
|
|
if (m_pXy->ReadOtherWithExtension(lpszFileName))
|
|
|
{
|
|
|
m_FileName = lpszFileName;
|
|
|
return TRUE;
|
|
|
}
|
|
|
|
|
|
CString path(lpszFileName);
|
|
|
m_TempFileName = PreprocessFile(path);
|
|
|
if (m_TempFileName.IsEmpty())
|
|
|
{
|
|
|
return FALSE;
|
|
|
}
|
|
|
std::vector<COne*> oneList = m_pXy->GetLatestReadOnes();
|
|
|
oneList.clear();
|
|
|
|
|
|
CFile file;
|
|
|
if (file.Open(m_TempFileName, CFile::modeRead))
|
|
|
{
|
|
|
m_FileName = lpszFileName;
|
|
|
// FIXME: 我们基础库暂时依赖这个来获取要保存的文件名
|
|
|
//AfxGetPublicFunction()->__CurrentSaveFilePath = lpszFileName;
|
|
|
CArchive ar(&file, CArchive::load);
|
|
|
Serialize(ar);
|
|
|
ar.Close();
|
|
|
file.Close();
|
|
|
}
|
|
|
if (m_pXy != nullptr)
|
|
|
{
|
|
|
m_pXy->EnableMeshPackage(m_bEnableMeshPackage);
|
|
|
}
|
|
|
if (!m_TempFileName.IsEmpty() && m_TempFileName != path)
|
|
|
{
|
|
|
CFile::Remove(m_TempFileName);
|
|
|
m_TempFileName = "";
|
|
|
}
|
|
|
return TRUE;
|
|
|
} |