#include "stdafx.h" #include #include "WellPoleDoc.h" #include "WellPoleView.h" #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 "WellPoleLib/WellObjExtendInfo.h" #include "WellPoleLib/WellMarkNamesList.h" #include "ItemSingleWell.h" #include "WellPoleLib/Data/WellData_FaultPoints.h" #include "WellPoleLib/Data/WellData_ReservesLayer.h" #include "WellPoleLib/Data/WellData_SandSet.h" #include "CPlusCallBack.h" #include "WellObjectAttributesJson.h" #include "WellObjectAttributesXml.h" #include "DrawOperator/Encoding.h" #include "MultiWellSectionLib/SectionWellObj.h" #include "MultiWellSectionLib/BendObj.h" #include "MultiWellSectionLib/FaultObj.h" #include "MultiWellSectionLib/WellSection.h" #include "./WellSection/ItemWcsTrack.h" #include "./WellSection/ItemSectionWell.h" #include "./WellSection/ItemAddFault.h" #include "./WellSection/ItemBend.h" #include "./WellSection/ItemFault.h" #include "./WellSection/MultiWellSectionDoc.h" #include "./WellSection/MultiWellSectionlView.h" // 导出注册回调的函数 //单井柱与多井柱的共用接口 extern "C" NATIVEDLL_API void RegisterCallback(CSigmaView* pView, InvalidateWndCallback callback) { CWellPoleView *pWellView = dynamic_cast(pView); CMultiWellSectionView *pSectionView = dynamic_cast(pView); if(pWellView) pWellView->m_pWndCallBack = callback; if (pSectionView) pSectionView->m_pWndCallBack = callback; } extern "C" __declspec(dllexport) int ViewSetItemForSelectedElement(CSigmaView* pView, int x, int y) { CWellPoleView *pWellView = dynamic_cast(pView); CMultiWellSectionView *pSectionView = dynamic_cast(pView); if(pWellView) return pWellView->ViewSetItemForSelectedElement(x, y); if (pSectionView) return pSectionView->ViewSetItemForSelectedElement(x, y); return eWellPoleCallbackMsgDef::tZeroData; } extern "C" __declspec(dllexport) BOOL SelectWellPoleSetCursor(CSigmaView * pView, int ptX, int ptY, int& handle) { handle = -1; if (pView == NULL) return FALSE; CWellPoleView *pWellView = dynamic_cast(pView); CMultiWellSectionView *pSectionView = dynamic_cast(pView); BOOL bSuccess = FALSE; if (pWellView) { CItem * pItem = pView->GetItem(); if (pItem == NULL) return FALSE; if (pItem->GetType() != ITEM_WELLPOLE) return FALSE; CItemSingleWell * pItemSingleWell = (CItemSingleWell *)pItem; bSuccess = pItemSingleWell->OnSetCursor(CPoint(ptX, ptY), handle); } if (pSectionView) { CItem * pItem = pView->GetItem(); if (pItem == NULL) return FALSE; if (pItem->GetType() != ITEM_WELLSECTION) return FALSE; CItemWellSection * pItemWellSection = (CItemWellSection *)pItem; bSuccess = pItemWellSection->OnSetCursor(CPoint(ptX, ptY), handle); } return bSuccess; } extern "C" __declspec(dllexport) BOOL GetSelectWellObject(CSigmaView * pView, int& type, int& ttype, ULONGLONG& objHandle) { BOOL b = false; type = -1; ttype = -1; objHandle = 0; CWellPoleView *pWellView = dynamic_cast(pView); CMultiWellSectionView *pSectionView = dynamic_cast(pView); if (pWellView) { b = pWellView->GetSelectWellObject(type, ttype, objHandle); } if (pSectionView) { b = pSectionView->GetSelectWellSectionObject(type, ttype, objHandle); } return b; } extern "C" __declspec(dllexport) BOOL SetWellObjectAttributesXml(CSigmaView * pView, ULONGLONG objHandle, int type, int ttype, BYTE* xmlBuf, int dataLen) { BOOL b = FALSE; char* pBuf = new char[dataLen + 1]; pBuf[dataLen] = 0; memcpy(pBuf, xmlBuf, dataLen); CString str = pBuf; b = CWellObjectAttributesXml::SetWellObjectAttributes(pView,objHandle, type, ttype, str); delete[] pBuf; return b; } extern "C" __declspec(dllexport) BOOL GetWellObjectAttributesXml(ULONGLONG objHandle, int type, int ttype, BYTE*& buf, int& dataLen) { BOOL b = FALSE; buf = NULL; dataLen = 0; CString str; if (CWellObjectAttributesXml::GetWellObjectAttributes(objHandle, type, ttype, str) == FALSE) return b; b = TRUE; buf = (new BYTE[str.GetLength()]); memcpy((char*)buf, str.GetBuffer(), str.GetLength()); dataLen = str.GetLength(); return b; } extern "C" __declspec(dllexport) BOOL GetSelectedWell(CSigmaView * pView, ULONGLONG& objHandle) { BOOL b = FALSE; objHandle = 0; CWellPoleView *pWellView = dynamic_cast(pView); CMultiWellSectionView *pSectionView = dynamic_cast(pView); if(pWellView) b = pWellView->GetSelectedWell(objHandle); if (pSectionView) { b = pSectionView->GetSelectedWell(objHandle); } return b; } extern "C" __declspec(dllexport) int GetCurrentDrawItemType(CSigmaView * pView) { int rt = -1; CWellPoleView *pWellView = dynamic_cast(pView); CMultiWellSectionView *pSectionView = dynamic_cast(pView); if (pWellView) { CItem * pItem = pWellView->GetItem(); if (pItem == NULL) return rt; if (pItem->GetType() == ITEM_WELLPOLE) { CItemSingleWell * pItemWell = (CItemSingleWell*)pItem; if (pItemWell->m_pItemSelected != NULL) rt = pItemWell->m_pItemSelected->GetType(); else rt = pItemWell->GetType(); } else rt = pItem->GetType(); } if (pSectionView) { return pSectionView->GetCurrentDrawItemType(); } return rt; } extern "C" __declspec(dllexport) BOOL DeleteSelectedWellObject(CSigmaView* pView) { BOOL b = FALSE; CWellPoleView *pWellView = dynamic_cast(pView); CMultiWellSectionView *pSectionView = dynamic_cast(pView); if(pWellView) b = pWellView->DeleteSelectedWellObject(); if (pSectionView) b = pSectionView->DeleteSelectedWellObject(); return b; } extern "C" __declspec(dllexport) BOOL AddTrackAfterSelectedWellObject(CSigmaView* pView, int trackType[], int trackNum, BYTE*& newTracksHandleBuf, BYTE*& newTtypeBuf, int& newTrackNum) { ULONGLONG *pTrackHandles = NULL; int *pTrackType = NULL; BOOL b = FALSE; CWellPoleView *pWellView = dynamic_cast(pView); CMultiWellSectionView *pSectionView = dynamic_cast(pView); if (pWellView) { b = pWellView->AddTrackAfterSelectedWellObject(trackType, trackNum, pTrackHandles, pTrackType, newTrackNum); if (b && newTrackNum > 0) { newTracksHandleBuf = (BYTE*)pTrackHandles; newTtypeBuf = (BYTE*)pTrackType; } return b; } if (pSectionView) { b = pSectionView->AddTrackAfterSelectedWellObject(trackType, trackNum, pTrackHandles, pTrackType, newTrackNum); if (b && newTrackNum > 0) { newTracksHandleBuf = (BYTE*)pTrackHandles; newTtypeBuf = (BYTE*)pTrackType; } } return b; } extern "C" __declspec(dllexport) BOOL SaveWellPoleTemplateFile(CSigmaView* pView, LPCTSTR filePathName) { BOOL b = FALSE; CWellPoleView *pWellView = dynamic_cast(pView); CMultiWellSectionView *pSectionView = dynamic_cast(pView); if (pWellView) { return pWellView->SaveWellPoleTemplateFile(filePathName); } if (pSectionView) { b = pSectionView->SaveWellPoleTemplateFile(filePathName); } return b; } extern "C" __declspec(dllexport) BOOL ApplyingWellPoleTemplateFile(CSigmaView* pView, LPCTSTR filePathName) { BOOL b = FALSE; CWellPoleView *pWellView = dynamic_cast(pView); CMultiWellSectionView *pSectionView = dynamic_cast(pView); if (pWellView) { return pWellView->ApplyingWellPoleTemplateFile(filePathName); } //if (pSectionView) //{ // b = pSectionView->ApplyingWellPoleTemplateFile(filePathName); //} return b; } extern "C" __declspec(dllexport) BOOL SelectedTrackCombineLeftTrack(CSigmaView* pView) { BOOL b = FALSE; CWellPoleView *pWellView = dynamic_cast(pView); CMultiWellSectionView *pSectionView = dynamic_cast(pView); if (pWellView) return pWellView->CombineLeftTrack(); if (pSectionView) { b = pSectionView->CombineLeftTrack(); } return b; } extern "C" __declspec(dllexport) BOOL SelectedTrackCombineRightTrack(CSigmaView* pView) { BOOL b = FALSE; CWellPoleView *pWellView = dynamic_cast(pView); CMultiWellSectionView *pSectionView = dynamic_cast(pView); if (pWellView) return pWellView->CombineRightTrack(); if (pSectionView) { b = pSectionView->CombineRightTrack(); } return b; } extern "C" __declspec(dllexport) BOOL GetWellBaseObjectParent(ULONGLONG objHandle,ULONGLONG& ParentObj) { BOOL b = TRUE; ParentObj = 0; CWellBaseObj* pWellBaseObj = (CWellBaseObj*)objHandle; if (pWellBaseObj->GetParent()) { ParentObj = (LONGLONG)pWellBaseObj->GetParent(); } return b; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// extern "C" __declspec(dllexport) CWellPoleView* CreateWellPoleView() { CWellPoleView* pWellView = new CWellPoleView(); return pWellView; } extern "C" __declspec(dllexport) CWellPole* CreateNewWell(CWellPoleView* pWellView, LPCTSTR wellName,double top,double bottom,double ratio,LPCTSTR wellTemplateFile) { CWellPole* pWell = NULL; pWell = pWellView->GetDocument()->CreateNewWell(wellName, top, bottom, ratio, wellTemplateFile); return pWell; } extern "C" __declspec(dllexport) void ViewExtendCenter(CWellPoleView* pWellView) { pWellView->ViewExtendCenter(); } extern "C" __declspec(dllexport) void ViewExtendWidth(CWellPoleView* pWellView) { pWellView->ViewExtendWidth(); } extern "C" __declspec(dllexport) void InitWellPosition(CWellPoleView* pWellView,int lrEdge)//刚打开井文件时,把井移动道图中间 { pWellView->InitWellPosition(lrEdge); } extern "C" __declspec(dllexport) void SetWellPoleViewOperationKind(CWellPoleView* pWellView, int kind) { if (kind == 1) { pWellView->SetViewPan(); } else if (kind == 2) { pWellView->SetViewWindow(); } else if (kind == 3) { pWellView->SetWellPoleViewPan(); } else if (kind == 0) { pWellView->SetViewPanInvalidate(); } } extern "C" __declspec(dllexport) BOOL IsLockWellHead(CWellPoleView* pWellView) { return pWellView->m_bLockWellHead; } extern "C" __declspec(dllexport) void SetLockWellHead(CWellPoleView* pWellView,bool block) { pWellView->SetLockWellHead(block); } extern "C" __declspec(dllexport) void MouseWheelForLockWellHead(CWellPoleView* pWellView,UINT nFlags, int zDelta, int x, int y) { CPoint pt; pt.x = x; pt.y = y; if (nFlags == 0) { if (pWellView->m_bLockWellHead) //目前只用来在锁定井头时使用 { pWellView->MouseWheelVLockHead(nFlags, zDelta, pt); } } //else // pWellView->MouseWheelH(nFlags, zDelta, pt); } extern "C" __declspec(dllexport) void ScrollVForLockWellHead(CWellPoleView* pWellView, int nFlags, int scrollValue, int pageSize, int lineSize, int scrollMin,int scrollMax) { pWellView->ScrollVForLockWellHead(nFlags, scrollValue, pageSize, lineSize, scrollMin, scrollMax); } extern "C" __declspec(dllexport) void SetScrollBarVRangeForLockWellHead(CWellPoleView* pWellView, int& vrange, int & page, int &value) { pWellView->SetScrollBarVRangeForLockWellHead(vrange, page, value); } extern "C" __declspec(dllexport) void FreeByteArray(BYTE* pBuff) { if(pBuff != NULL) delete []pBuff; } extern "C" __declspec(dllexport) int GetWellTrackTypeInfo(BYTE*& typeBuff, int& typeBuffLen, BYTE*& typeStrBuf, int& typeStrLen) { int typeNum = 0; typeBuff = NULL; typeBuffLen = 0; typeStrBuf = NULL; typeStrLen = 0; std::vector trackInfos = CWellObjExtendInfoMgr::GetInstance()->GetWellTrackInfos(); if (trackInfos.size() == 0) return typeNum; typeNum = int(trackInfos.size()); int* typeArr = (int*)(new BYTE[typeNum*sizeof(int)]); CString strTypeStr; for (int ii = 0; ii < int(trackInfos.size()); ii++) { typeArr[ii] = trackInfos[ii]->m_type; strTypeStr = strTypeStr + "|" + trackInfos[ii]->m_cTypeStr; } typeBuff = (BYTE*)typeArr; typeBuffLen = sizeof(int)* int(trackInfos.size()); strTypeStr.TrimLeft("|"); typeStrBuf = (new BYTE[strTypeStr.GetLength()]); memcpy((char*)typeStrBuf, strTypeStr.GetBuffer(),strTypeStr.GetLength()); typeStrLen = strTypeStr.GetLength(); return typeNum; } extern "C" __declspec(dllexport) BOOL GetWellTrackDataJson(CWellPoleView* pWellView, ULONGLONG trackHandle, BYTE*& jsonBuf, int& dataLen) { BOOL b = FALSE; jsonBuf = NULL; dataLen = 0; CString strJson; if (pWellView->GetWellTrackDataJson(trackHandle,strJson) == FALSE) return b; jsonBuf = (new BYTE[strJson.GetLength()]); memcpy((char*)jsonBuf, strJson.GetBuffer(), strJson.GetLength()); dataLen = strJson.GetLength(); return TRUE; } extern "C" __declspec(dllexport) BOOL SetWellTrackDataJson(CWellPoleView* pWellView, ULONGLONG trackHandle, BYTE* jsonBuf, int dataLen) { char* pBuf = new char[dataLen + 1]; pBuf[dataLen] = 0; memcpy(pBuf, jsonBuf, dataLen); BOOL b = pWellView->SetWellTrackDataJson(trackHandle, pBuf); delete[] pBuf; return b; } extern "C" __declspec(dllexport) BOOL SetPictureInWellTrack(CWellPoleView* pWellView, ULONGLONG pictureObjHandle, LPCSTR filePath) { BOOL b = FALSE; b = pWellView->SetPictureInWellTrack(pictureObjHandle, filePath); return b; } extern "C" __declspec(dllexport) BOOL GetWellObjectAttributesJson(CWellPoleView* pWellView, ULONGLONG objHandle, int type, int ttype, BYTE*& jsonBuf, int& dataLen) { BOOL b = FALSE; //jsonBuf = NULL; //dataLen = 0; //CString strJson; //if (CWellObjectAttributesJson::GetWellObjectAttributesJson(objHandle, type, ttype, strJson) == FALSE) // return b; //b = TRUE; //jsonBuf = (new BYTE[strJson.GetLength()]); //memcpy((char*)jsonBuf, strJson.GetBuffer(), strJson.GetLength()); //dataLen = strJson.GetLength(); return b; } extern "C" __declspec(dllexport) BOOL SetWellObjectAttributesJson(CWellPoleView* pWellView, ULONGLONG objHandle, int type, int ttype, BYTE* jsonBuf, int dataLen) { BOOL b = FALSE; //char* pBuf = new char[dataLen + 1]; //pBuf[dataLen] = 0; //memcpy(pBuf, jsonBuf, dataLen); //CString strJson = pBuf; //b = CWellObjectAttributesJson::SetWellObjectAttributesJson(objHandle, type, ttype, strJson); //delete[] pBuf; return b; } BOOL GetWellSymbolNames(BYTE*& typeStrBuf ,int& typeStrLen, EMarkType type) { BOOL b = FALSE; typeStrBuf = NULL; typeStrLen = 0; CStringArray* pStrArr = AfxGetGlobalWellMarkNamesList()->GetWellMark(type); CString strName = AfxGetGlobalWellMarkNamesList()->GetMarkName(type); if (!strName.IsEmpty() && pStrArr != NULL) { CString str; int index = 0; int nCount = pStrArr->GetCount(); CString strTypeStr; for (int i = 0; i < nCount; i++) { str = pStrArr->GetAt(i); strTypeStr = strTypeStr + "|" + str; } strTypeStr.TrimLeft("|"); typeStrBuf = (new BYTE[strTypeStr.GetLength()]); memcpy((char*)typeStrBuf, strTypeStr.GetBuffer(), strTypeStr.GetLength()); typeStrLen = strTypeStr.GetLength(); b = TRUE; } return b; } extern "C" __declspec(dllexport) BOOL GetSymbolNamesForResult(BYTE*& typeStrBuf, int& typeStrLen) { return GetWellSymbolNames(typeStrBuf, typeStrLen, EMarkType(MarkResult1)); } BOOL GetDrawWellSymbol(EMarkType type,LPCTSTR symbolName, HDC hdcMem, int width, int height) { BOOL b = FALSE; CString strName = AfxGetGlobalWellMarkNamesList()->GetMarkName(EMarkType(type)); CString strResult = strName + symbolName; void* pDraw = AfxGetGlobalWellXy()->FindMark(strResult); if (pDraw) { CXy* pXy = (CXy*)pDraw; CDC *pDC = CDC::FromHandle(hdcMem); CXyDC xyDC; xyDC.Create(pDC); CRect rt(0, 0, width - 1, height - 1); rt.DeflateRect(3, 3); CRect8 rect(1e100, -1e100, -1e100, 1e100); if (pXy->GetCount() > 0) { pXy->GetRange(rect); pXy->m_range = rect; xyDC.Extend(rect, rt, EXTEND_MODE_CENTER); pXy->Draw(xyDC); } pDC->SelectStockObject(NULL_BRUSH); pDC->SelectStockObject(BLACK_PEN); pDC->Rectangle(0, 0, width - 1, height - 1); pDC->SelectStockObject(WHITE_PEN); pDC->Rectangle(1, 1, width - 2, height - 2); b = TRUE; } return b; } extern "C" __declspec(dllexport) BOOL GetDrawSymbolForResult(LPCTSTR symbolName, HDC hdcMem, int width, int height) { return GetDrawWellSymbol(MarkResult1, symbolName, hdcMem, width, height); } extern "C" __declspec(dllexport) BOOL GetSymbolNamesForLithology(BYTE*& typeStrBuf, int& typeStrLen) { return GetWellSymbolNames(typeStrBuf, typeStrLen, EMarkType(MarkLithoMain)); } extern "C" __declspec(dllexport) BOOL GetDrawSymbolForLithology(LPCTSTR symbolName, HDC hdcMem, int width, int height) { return GetDrawWellSymbol(MarkLithoMain, symbolName, hdcMem, width, height); } extern "C" __declspec(dllexport) BOOL GetSymbolNamesForLithologyColor(BYTE*& typeStrBuf, int& typeStrLen) { return GetWellSymbolNames(typeStrBuf, typeStrLen, EMarkType(MarkLithoColor)); } extern "C" __declspec(dllexport) BOOL GetDrawSymbolForLithologyColor(LPCTSTR symbolName, HDC hdcMem, int width, int height) { return GetDrawWellSymbol(MarkLithoColor, symbolName, hdcMem, width, height); } extern "C" __declspec(dllexport) BOOL GetSymbolNamesForLithOilGas(BYTE*& typeStrBuf, int& typeStrLen) { return GetWellSymbolNames(typeStrBuf, typeStrLen, EMarkType(MarkLithoOilGas)); } extern "C" __declspec(dllexport) BOOL GetDrawSymbolForLithOilGas(LPCTSTR symbolName, HDC hdcMem, int width, int height) { return GetDrawWellSymbol(MarkLithoOilGas, symbolName, hdcMem, width, height); } extern "C" __declspec(dllexport) BOOL GetSymbolNamesForLithContent(BYTE*& typeStrBuf, int& typeStrLen) { return GetWellSymbolNames(typeStrBuf, typeStrLen, EMarkType(MarkLithoContent)); } extern "C" __declspec(dllexport) BOOL GetDrawSymbolForLithContent(LPCTSTR symbolName, HDC hdcMem, int width, int height) { return GetDrawWellSymbol(MarkLithoContent, symbolName, hdcMem, width, height); } extern "C" __declspec(dllexport) BOOL GetSymbolNamesForLithFront(BYTE*& typeStrBuf, int& typeStrLen) { return GetWellSymbolNames(typeStrBuf, typeStrLen, EMarkType(MarkLithoFront)); } extern "C" __declspec(dllexport) BOOL GetDrawSymbolForLithFront(LPCTSTR symbolName, HDC hdcMem, int width, int height) { return GetDrawWellSymbol(MarkLithoFront, symbolName, hdcMem, width, height); } extern "C" __declspec(dllexport) BOOL GetSymbolNamesForLithConstitution(BYTE*& typeStrBuf, int& typeStrLen) { return GetWellSymbolNames(typeStrBuf, typeStrLen, EMarkType(MarkLithoConstitution)); } extern "C" __declspec(dllexport) BOOL GetDrawSymbolForLithConstitution(LPCTSTR symbolName, HDC hdcMem, int width, int height) { return GetDrawWellSymbol(MarkLithoConstitution, symbolName, hdcMem, width, height); } extern "C" __declspec(dllexport) BOOL GetNormalSymbolNames(BYTE*& typeStrBuf, int& typeStrLen) { return GetWellSymbolNames(typeStrBuf, typeStrLen, EMarkType(MarkNormal)); } extern "C" __declspec(dllexport) BOOL GetDrawNormalSymbol(LPCTSTR symbolName, HDC hdcMem, int width, int height) { return GetDrawWellSymbol(MarkNormal, symbolName, hdcMem, width, height); } extern "C" __declspec(dllexport) BOOL GetCurveFillSymbolNames(BYTE*& typeStrBuf, int& typeStrLen) { return GetWellSymbolNames(typeStrBuf, typeStrLen, EMarkType(MarkFill)); } extern "C" __declspec(dllexport) BOOL GetDrawCurveFillSymbol(LPCTSTR symbolName, HDC hdcMem, int width, int height) { return GetDrawWellSymbol(MarkFill, symbolName, hdcMem, width, height); } extern "C" __declspec(dllexport) BOOL GetCurvePointSymbolNames(BYTE*& typeStrBuf, int& typeStrLen) { return GetWellSymbolNames(typeStrBuf, typeStrLen, EMarkType(MarkChart)); } extern "C" __declspec(dllexport) BOOL GetDrawCurvePointSymbol(LPCTSTR symbolName, HDC hdcMem, int width, int height) { return GetDrawWellSymbol(MarkChart, symbolName, hdcMem, width, height); } extern "C" __declspec(dllexport) BOOL GetStratumLithNames(BYTE*& typeStrBuf, int& typeStrLen) { return GetWellSymbolNames(typeStrBuf, typeStrLen, EMarkType(MarkStratumLitho)); } extern "C" __declspec(dllexport) BOOL GetDrawStratumLith(LPCTSTR symbolName, HDC hdcMem, int width, int height) { return GetDrawWellSymbol(MarkStratumLitho, symbolName, hdcMem, width, height); } extern "C" __declspec(dllexport) BOOL GetStratumBendStyleNames(BYTE*& typeStrBuf, int& typeStrLen) { return GetWellSymbolNames(typeStrBuf, typeStrLen, EMarkType(MarkBreakStratum)); } extern "C" __declspec(dllexport) BOOL GetDrawSymbolBendStyle(LPCTSTR symbolName, HDC hdcMem, int width, int height) { return GetDrawWellSymbol(MarkBreakStratum, symbolName, hdcMem, width, height); } extern "C" __declspec(dllexport) BOOL GetWellAllCurveNames(CWellPoleView* pWellView, ULONGLONG wellHandle, BYTE*& typeStrBuf, int& typeStrLen) { CStringArray strArr; BOOL b = pWellView->GetWellAllCurveNames(wellHandle, strArr); typeStrBuf = NULL; typeStrLen = 0; CString strType,str; for (int i = 0; i < strArr.GetSize(); i++) { str = strArr.GetAt(i); strType = strType + "|" + str; } strType.TrimLeft("|"); typeStrBuf = (new BYTE[strType.GetLength()]); memcpy((char*)typeStrBuf, strType.GetBuffer(), strType.GetLength()); typeStrLen = strType.GetLength(); return b; } extern "C" __declspec(dllexport) BOOL GetWellAllDiscreteNames(CWellPoleView* pWellView, ULONGLONG wellHandle, BYTE*& typeStrBuf, int& typeStrLen) { CStringArray strArr; BOOL b = pWellView->GetWellAllDiscreteNames(wellHandle, strArr); typeStrBuf = NULL; typeStrLen = 0; CString strType, str; for (int i = 0; i < strArr.GetSize(); i++) { str = strArr.GetAt(i); strType = strType + "|" + str; } strType.TrimLeft("|"); typeStrBuf = (new BYTE[strType.GetLength()]); memcpy((char*)typeStrBuf, strType.GetBuffer(), strType.GetLength()); typeStrLen = strType.GetLength(); return b; } extern "C" __declspec(dllexport) BOOL GetWellFrameLineNames(BYTE*& typeStrBuf, int& typeStrLen) { BOOL b = FALSE; typeStrBuf = NULL; typeStrLen = 0; CString strLines; CString strName; strName.Format("%s\\", LIB_FRAME_TYPE);//曲线线型 if (AfxGetGlobalWellXy() == NULL) //平面分析需要跳过它,防止死机 return b; CLayer* pLayer = NULL; CString name; CPtrList pLayerList; int index = -1; CString strTotal; b = TRUE; AfxGetGlobalWellXy()->GetLayer(pLayerList, strName); POSITION pos = pLayerList.GetTailPosition(); while (pos != NULL) { pLayer = (CLayer*)pLayerList.GetPrev(pos); name = pLayer->GetName(); index = name.Find(strName); if (index > -1) { name = name.Right(name.GetLength() - index - strName.GetLength()); if (!name.IsEmpty()) { strTotal = strTotal + "|" + name; } } } strTotal.TrimLeft("|"); typeStrBuf = (new BYTE[strTotal.GetLength()]); memcpy((char*)typeStrBuf, strTotal.GetBuffer(), strTotal.GetLength()); typeStrLen = strTotal.GetLength(); return b; } extern "C" __declspec(dllexport) BOOL GetWellCurveLineNames(BYTE*& typeStrBuf, int& typeStrLen) { BOOL b = FALSE; typeStrBuf = NULL; typeStrLen = 0; CString strName; strName.Format("%s\\", LIB_CURVE_TYPE);//曲线线型 if (AfxGetGlobalWellXy() == NULL) //平面分析需要跳过它,防止死机 return b; b = TRUE; CLayer* pLayer = NULL; CString name; CPtrList pLayerList; int index = -1; CString strTotal; AfxGetGlobalWellXy()->GetLayer(pLayerList, strName); POSITION pos = pLayerList.GetTailPosition(); while (pos != NULL) { pLayer = (CLayer*)pLayerList.GetPrev(pos); name = pLayer->GetName(); index = name.Find(strName); if (index > -1) { name = name.Right(name.GetLength() - index - strName.GetLength()); if (!name.IsEmpty()) { strTotal = strTotal + "|" + name; } } } strTotal.TrimLeft("|"); typeStrBuf = (new BYTE[strTotal.GetLength()]); memcpy((char*)typeStrBuf, strTotal.GetBuffer(), strTotal.GetLength()); typeStrLen = strTotal.GetLength(); return b; } BOOL GetDrawWellLine(CString strName, CString strType, HDC hdcMem, int width, int height) { CString name; BOOL b = FALSE; CLayer* pLayer = NULL; CPtrList pLayerList; AfxGetGlobalWellXy()->GetLayer(pLayerList, strType); POSITION pos = pLayerList.GetTailPosition(); while (pos != NULL) { pLayer = (CLayer*)pLayerList.GetPrev(pos); name = pLayer->GetName(); if (strName == name) { b = TRUE; break; } } if (b) { CDC *pDC = CDC::FromHandle(hdcMem); CXyDC xyDC; xyDC.Create(pDC); CRect rt(0, 0, width - 1, height - 1); rt.DeflateRect(3, 3); CPoint p1, p2; p1.x = rt.left + 10; p1.y = rt.CenterPoint().y; p2.x = rt.right - 10; p2.y = p1.y; CPoint2D pt1, pt2; pt1 = xyDC.GetReal(p1); pt2 = xyDC.GetReal(p2); CCurveEx curve; curve.Create(2); curve.x[0] = pt1.x0; curve.x[1] = pt2.x0; curve.y[0] = pt1.y0; curve.y[1] = pt2.y0; curve.GetLocation(); //曲线修饰 if (pLayer->HowToViewCurve != NULL) { CHowToViewCurve* pHTVC = new CHowToViewCurve(); *pHTVC = *(pLayer->HowToViewCurve); xyDC.Draw(curve, pHTVC); } else xyDC.Draw(curve); pDC->SelectStockObject(NULL_BRUSH); pDC->SelectStockObject(BLACK_PEN); pDC->Rectangle(0, 0, width - 1, height - 1); pDC->SelectStockObject(WHITE_PEN); pDC->Rectangle(1, 1, width - 2, height - 2); } return b; } extern "C" __declspec(dllexport) BOOL GetDrawWellCurveLine(LPCTSTR lineName,HDC hdcMem, int width, int height) { BOOL b = FALSE; CString strName,name,strType; strName.Format("%s\\%s", LIB_CURVE_TYPE,lineName);//曲线线型 if (AfxGetGlobalWellXy() == NULL) //平面分析需要跳过它,防止死机 return b; strType.Format("%s\\", LIB_CURVE_TYPE);//曲线线型 b = GetDrawWellLine(strName, strType, hdcMem, width, height); return b; } extern "C" __declspec(dllexport) BOOL GetDrawWellFrameLine(LPCTSTR lineName, HDC hdcMem, int width, int height) { BOOL b = FALSE; CString strName, name, strType; strName.Format("%s\\%s", LIB_FRAME_TYPE, lineName);//曲线线型 if (AfxGetGlobalWellXy() == NULL) //平面分析需要跳过它,防止死机 return b; strType.Format("%s\\", LIB_FRAME_TYPE);//曲线线型 b = GetDrawWellLine(strName,strType, hdcMem, width, height); return b; } extern "C" __declspec(dllexport) BOOL GetWellTracks(CWellPoleView* pWellView, ULONGLONG wellHandle, BYTE*& tracksHandleBuf, BYTE*& ttypeBuf, int& trackNum, BYTE*& dataRef, int& dataRefLen, BYTE*& refTable, int& refTableLen, BYTE*& refCol, int& refColLen) { BOOL b = FALSE; dataRefLen = 0; refTableLen = 0; refColLen = 0; try { CWellBaseObj* pWellBase = (CWellBaseObj*)wellHandle; CWellPole* pWell = dynamic_cast(pWellBase); TRACKLIST trackList; pWell->GetTypeTrackList(&trackList, Track_Normal); trackNum = trackList.size(); CTrackObj* pTrack; CTrackCurve* pTrackCurve; CTrackDiscrete* pTrackDiscrete; tracksHandleBuf = new BYTE[trackNum * sizeof(ULONGLONG)]; ULONGLONG *pHandle = (ULONGLONG*)tracksHandleBuf; ttypeBuf = new BYTE[trackNum * sizeof(int)]; int *pType = (int*)ttypeBuf; //std::vector strDatas, strRefTabls, strRefCols; CString strDataRef ,strRefTable,strRefCol; TRACKLIST::iterator it = trackList.begin(); int ii = 0; for (; it != trackList.end(); it++) { pTrack = (*it); pHandle[ii] = (ULONGLONG)pTrack; pType[ii] = pTrack->GetTrackType(); // strDatas.push_back(pTrack->m_strDataRef); if (pTrack->GetTrackType() == Track_Curve) { pTrackCurve = (CTrackCurve*)pTrack; strDataRef = strDataRef + "|" + pTrackCurve->m_strDataRef; } else if (pTrack->GetTrackType() == Track_Discrete) { pTrackDiscrete = (CTrackDiscrete*)pTrack; strDataRef = strDataRef + "|" + pTrackDiscrete->m_strDataRef; } else strDataRef = strDataRef + "| "; // strRefTabls.push_back(pTrack->m_dataSourceID); // strRefCols.push_back(pTrack->m_dataColID); strRefTable = strRefTable + "|" + pTrack->m_dataSourceID; strRefCol = strRefCol + "|" + pTrack->m_dataColID; ii++; } strDataRef = strDataRef.Right(strDataRef.GetLength() - 1); //strDataRef.TrimLeft("|"); dataRef = (new BYTE[strDataRef.GetLength()]); memcpy((char*)dataRef, strDataRef.GetBuffer(), strDataRef.GetLength()); dataRefLen = strDataRef.GetLength(); //strRefTable.TrimLeft("|"); strRefTable = strRefTable.Right(strRefTable.GetLength() - 1); refTable = new BYTE[strRefTable.GetLength()]; memcpy((char*)refTable, strRefTable.GetBuffer(), strRefTable.GetLength()); refTableLen = strRefTable.GetLength(); //strRefCol.TrimLeft("|"); strRefCol = strRefCol.Right(strRefCol.GetLength() - 1); refCol = new BYTE[strRefCol.GetLength()]; memcpy((char*)refCol, strRefCol.GetBuffer(), strRefCol.GetLength()); refColLen = strRefCol.GetLength(); b = TRUE; } catch (std::exception e) { return FALSE; } return b; } extern "C" __declspec(dllexport) BOOL GetPerforationLayerType(BYTE*& typeStrBuf, int& typeStrLen) //获得射孔数据的层位类型 { BOOL b = FALSE; CStringArray strArr; GetPerforationLayerType(strArr); CString strTypes; for (int ii = 0; ii < strArr.GetSize(); ii++) { strTypes = strTypes + "|" + strArr[ii]; } strTypes.TrimLeft("|"); typeStrBuf = (new BYTE[strTypes.GetLength()]); //dataRef[strDataRef.GetLength()] = 0; memcpy((char*)typeStrBuf, strTypes.GetBuffer(), strTypes.GetLength()); typeStrLen = strTypes.GetLength(); b = TRUE; return b; } extern "C" __declspec(dllexport) BOOL GetWellTrajectoryDatasJson(ULONGLONG wellHandle, BYTE*& typeStrBuf, int& typeStrLen) { BOOL b = FALSE; typeStrBuf = NULL; typeStrLen = 0; try { CWellBaseObj* pWellBase = (CWellBaseObj*)wellHandle; CWellPole* pWell = dynamic_cast(pWellBase); CString strJson; pWell->GetTrajectoryDatasJson(strJson); typeStrBuf = (new BYTE[strJson.GetLength()]); memcpy((char*)typeStrBuf, strJson.GetBuffer(), strJson.GetLength()); typeStrLen = strJson.GetLength(); b = TRUE; } catch (std::exception e) { return FALSE; } return b; } extern "C" __declspec(dllexport) BOOL SetWellTrajectoryDatasJson(ULONGLONG wellHandle, BYTE* strBuf, int typeStrLen) { BOOL b = FALSE; try { CWellBaseObj* pWellBase = (CWellBaseObj*)wellHandle; CWellPole* pWell = dynamic_cast(pWellBase); char* pBuf = new char[typeStrLen + 1]; pBuf[typeStrLen] = 0; memcpy(pBuf, strBuf, typeStrLen); CString str = pBuf; b = pWell->SetTrajectoryDatasJson(str); delete[] pBuf; } catch (std::exception e) { return FALSE; } return b; } extern "C" __declspec(dllexport) BOOL SetWellStratificationJson(ULONGLONG wellHandle, BYTE* strBuf, int typeStrLen) //井分层数据级别 { BOOL b = FALSE; try { CWellBaseObj* pWellBase = (CWellBaseObj*)wellHandle; CWellPole* pWell = dynamic_cast(pWellBase); char* pBuf = new char[typeStrLen + 1]; pBuf[typeStrLen] = 0; memcpy(pBuf, strBuf, typeStrLen); CString str = pBuf; b = pWell->SetWellStratification(str); delete[] pBuf; } catch (std::exception e) { return FALSE; } return b; } extern "C" __declspec(dllexport) BOOL SetStratumDivisionJson(ULONGLONG wellHandle, BYTE* strBuf, int typeStrLen) //井地层分层数据级别 { BOOL b = FALSE; try { CWellBaseObj* pWellBase = (CWellBaseObj*)wellHandle; CWellPole* pWell = dynamic_cast(pWellBase); char* pBuf = new char[typeStrLen + 1]; pBuf[typeStrLen] = 0; memcpy(pBuf, strBuf, typeStrLen); CString str = pBuf; b = pWell->SetStratumDivision(str); delete[] pBuf; } catch (std::exception e) { return FALSE; } return b; } extern "C" __declspec(dllexport) BOOL SetWellSandSetsJson(ULONGLONG wellHandle, BYTE* strBuf, int typeStrLen , BOOL bRefreshTracks) { BOOL b = FALSE; try { CWellBaseObj* pWellBase = (CWellBaseObj*)wellHandle; CWellPole* pWell = dynamic_cast(pWellBase); char* pBuf = new char[typeStrLen + 1]; pBuf[typeStrLen] = 0; memcpy(pBuf, strBuf, typeStrLen); CString str = pBuf; b = pWell->SetWellSandSets(str , bRefreshTracks); delete[] pBuf; } catch (std::exception e) { return FALSE; } return b; } extern "C" __declspec(dllexport) BOOL TrackReadWellTableData(ULONGLONG trackHandle) //读取井管理数据 { BOOL b = FALSE; try { CWellBaseObj* pWellBase = (CWellBaseObj*)trackHandle; if (pWellBase->GetType() != KEP_TRACK) return FALSE; CTrackObj* pTrack = dynamic_cast(pWellBase); if (pTrack == NULL) return b; pTrack->ReadWellTableData(); b = TRUE; } catch (std::exception e) { return FALSE; } return b; } extern "C" __declspec(dllexport) BOOL TrackIsWellTableDataSource(ULONGLONG trackHandle) //是否井管理数据 { BOOL b = FALSE; try { CWellBaseObj* pWellBase = (CWellBaseObj*)trackHandle; if (pWellBase->GetType() != KEP_TRACK) return FALSE; CTrackObj* pTrack = dynamic_cast(pWellBase); if (pTrack == NULL) return b; b = pTrack->IsWellTableDataSource(); } catch (std::exception e) { return FALSE; } return b; } extern "C" __declspec(dllexport) BOOL TrackGetDataSourceID(ULONGLONG trackHandle, BYTE*& sourceStrBuf, int& sourceStrLen, BYTE*& colStrBuf, int& colStrLen) { sourceStrLen = colStrLen = 0; sourceStrBuf = colStrBuf = NULL; BOOL b = FALSE; try { CWellBaseObj* pWellBase = (CWellBaseObj*)trackHandle; if (pWellBase->GetType() != KEP_TRACK) return FALSE; CTrackObj* pTrack = dynamic_cast(pWellBase); if (pTrack == NULL) return b; CString strSource, strCol; pTrack->GetTrackDataSourceID(strSource,strCol); if (!strSource.IsEmpty()) { sourceStrBuf = (new BYTE[strSource.GetLength()]); memcpy((char*)sourceStrBuf, strSource.GetBuffer(), strSource.GetLength()); sourceStrLen = strSource.GetLength(); } if (!strCol.IsEmpty()) { colStrBuf = (new BYTE[strCol.GetLength()]); memcpy((char*)colStrBuf, strCol.GetBuffer(), strCol.GetLength()); colStrLen = strCol.GetLength(); } b = TRUE; } catch (std::exception e) { return FALSE; } return b; } extern "C" __declspec(dllexport) BOOL TrackSetDataRefID(ULONGLONG trackHandle, BYTE* sourceStrBuf, int sourceStrLen, BYTE* colStrBuf, int colStrLen) { BOOL b = FALSE; try { CWellBaseObj* pWellBase = (CWellBaseObj*)trackHandle; if (pWellBase->GetType() != KEP_TRACK) return FALSE; CTrackObj* pTrack = dynamic_cast(pWellBase); if (pTrack == NULL) return b; CString strSource, strCol; if (sourceStrLen > 0) { char* pBuf = new char[sourceStrLen + 1]; pBuf[sourceStrLen] = 0; memcpy(pBuf, sourceStrBuf, sourceStrLen); strSource = pBuf; delete[]pBuf; } if (colStrLen > 0) { char* pBuf = new char[colStrLen + 1]; pBuf[colStrLen] = 0; memcpy(pBuf, colStrBuf, colStrLen); strCol = pBuf; delete[]pBuf; } pTrack->SetDataRefID(strSource, strCol); b = TRUE; } catch (std::exception e) { return FALSE; } return b; } extern "C" __declspec(dllexport) BOOL SetWellFaultDatasJson(ULONGLONG wellHandle, BYTE* strBuf, int typeStrLen, BOOL bRefreshTracks) { BOOL b = FALSE; try { CWellBaseObj* pWellBase = (CWellBaseObj*)wellHandle; CWellPole* pWell = dynamic_cast(pWellBase); char* pBuf = new char[typeStrLen + 1]; pBuf[typeStrLen] = 0; memcpy(pBuf, strBuf, typeStrLen); CString str = pBuf; b = pWell->SetFaultPoints(str , bRefreshTracks ); delete[] pBuf; } catch (std::exception e) { return FALSE; } return b; } extern "C" __declspec(dllexport) BOOL SetWellReservesLayersJson(ULONGLONG wellHandle, BYTE* strBuf, int typeStrLen, BOOL bRefreshTracks) { BOOL b = FALSE; try { CWellBaseObj* pWellBase = (CWellBaseObj*)wellHandle; CWellPole* pWell = dynamic_cast(pWellBase); char* pBuf = new char[typeStrLen + 1]; pBuf[typeStrLen] = 0; memcpy(pBuf, strBuf, typeStrLen); CString str = pBuf; b = pWell->SetWellReservesLayers(str , bRefreshTracks); delete[] pBuf; } catch (std::exception e) { return FALSE; } return b; } extern "C" __declspec(dllexport) BOOL SetWellUndoRedoAction(CWellPoleView* pWellView) { if (pWellView == NULL) return FALSE; CItem * pItem = pWellView->GetItem(); if (pItem == NULL) return FALSE; if (pItem->GetType() != ITEM_WELLPOLE) return FALSE; CItemSingleWell * pItemSingleWell = (CItemSingleWell *)pItem; pItemSingleWell->SetReUnDoAction(); return TRUE; } extern "C" __declspec(dllexport) BOOL GetWellStratificationClasses(ULONGLONG wellHandle, BYTE*& typeStrBuf, int& typeStrLen) //井分层数据 { BOOL b = FALSE; typeStrBuf = NULL; typeStrLen = 0; try { CWellBaseObj* pWellBase = (CWellBaseObj*)wellHandle; CWellPole* pWell = dynamic_cast(pWellBase); if (pWell) { //layerClassShowNames["0"] = "一级分层"; //layerClassShowNames["1"] = "二级分层"; //layerClassShowNames["2"] = "三级分层"; //layerClassShowNames["3"] = "四级分层"; //layerClassShowNames["4"] = "五级分层"; int count = pWell->m_WellStratiTree.GetClassNames().size(); if (count > 0) { CString strTotal; for (int ii = 0; ii < count; ii++) { strTotal = strTotal + "|" + pWell->m_WellStratiTree.GetClassNames()[ii]; } strTotal.TrimLeft("|"); typeStrLen = strTotal.GetLength(); typeStrBuf = new BYTE[typeStrLen]; memcpy(typeStrBuf, strTotal.GetBuffer(), strTotal.GetLength()); } b = true; } } catch (std::exception e) { return FALSE; } return b; } extern "C" __declspec(dllexport) BOOL GetWellStratumClasses(ULONGLONG wellHandle, BYTE*& typeStrBuf, int& typeStrLen) //界、系、统、组、段分层数据 { BOOL b = FALSE; typeStrBuf = NULL; typeStrLen = 0; try { CWellBaseObj* pWellBase = (CWellBaseObj*)wellHandle; CWellPole* pWell = dynamic_cast(pWellBase); if (pWell) { int count = pWell->m_StratumDivisionTree.GetClassNames().size(); std::set classes; classes.insert("界"); classes.insert("系"); classes.insert("统"); classes.insert("组"); classes.insert("段"); if (count > 0) { CString strTotal; for (int ii = 0; ii < count; ii++) { CString str = pWell->m_StratumDivisionTree.GetClassNames()[ii]; std::set::iterator it = classes.find(str); if (it == classes.end()) continue; strTotal = strTotal + "|" + str; } strTotal.TrimLeft("|"); typeStrLen = strTotal.GetLength(); typeStrBuf = new BYTE[typeStrLen]; memcpy(typeStrBuf, strTotal.GetBuffer(), strTotal.GetLength()); } b = true; } } catch (std::exception e) { return FALSE; } return b; } extern "C" __declspec(dllexport) BOOL SetAddFaultPoint(CWellPoleView* pWellView) { if (pWellView == NULL) return FALSE; BOOL b = FALSE; CItem * pItem = pWellView->GetItem(); if (pItem == NULL) return FALSE; if (pItem->GetType() != ITEM_WELLPOLE) return FALSE; CItemSingleWell * pItemSingleWell = (CItemSingleWell *)pItem; pItemSingleWell->SetAddFaultPoint(); b = TRUE; return b; } extern "C" __declspec(dllexport) BOOL IsAddFaultPoint(CWellPoleView* pWellView) { if (pWellView == NULL) return FALSE; BOOL b = FALSE; CItem * pItem = pWellView->GetItem(); if (pItem == NULL) return FALSE; if (pItem->GetType() != ITEM_WELLPOLE) return FALSE; CItemSingleWell * pItemSingleWell = (CItemSingleWell *)pItem; return pItemSingleWell->IsAddFaultPoint(); } extern "C" __declspec(dllexport) BOOL GetWellTableDatasJson(ULONGLONG wellHandle, BYTE* strTableId, int TableIdStrLen, BYTE*& buf, int& dataLen) { BOOL b = FALSE; buf = NULL; dataLen = 0; try { char* pBuf = new char[TableIdStrLen + 1]; pBuf[TableIdStrLen] = 0; memcpy(pBuf, strTableId, TableIdStrLen); CString strTableId = pBuf; CWellBaseObj* pWellBase = (CWellBaseObj*)wellHandle; CWellPole* pWell = dynamic_cast(pWellBase); CString jsonStr; if (strTableId == CWellData_FaultPoints::s_tableID) pWell->GetFaultPoints(jsonStr); else if (strTableId == CWellData_ReservesLayer::s_tableID) pWell->GetWellReservesLayers(jsonStr); else if (strTableId == CWellData_SandSet::s_tableID) pWell->GetWellSandSets(jsonStr); if (jsonStr.GetLength() > 0) { buf = (new BYTE[jsonStr.GetLength()]); memcpy((char*)buf, jsonStr.GetBuffer(), jsonStr.GetLength()); dataLen = jsonStr.GetLength(); b = TRUE; } delete[]pBuf; } catch (std::exception e) { return FALSE; } return b; } extern "C" __declspec(dllexport) BOOL GetFaciesNames(BYTE*& typeStrBuf, int& typeStrLen) { BOOL b = FALSE; typeStrBuf = NULL; typeStrLen = 0; CStringArray strArr; //AfxGetGlobalWellFaciesLib()->GetFaciesNames(strArr); AfxGetGlobalInterpretBrushLib()->GetFaciesNames(strArr); if (strArr.GetSize() > 0 ) { CString str; int index = 0; int nCount = strArr.GetSize(); CString strTypeStr; for (int i = 0; i < nCount; i++) { str = strArr.GetAt(i); strTypeStr = strTypeStr + "|" + str; } strTypeStr.TrimLeft("|"); typeStrBuf = (new BYTE[strTypeStr.GetLength()]); memcpy((char*)typeStrBuf, strTypeStr.GetBuffer(), strTypeStr.GetLength()); typeStrLen = strTypeStr.GetLength(); b = TRUE; } return b; } extern "C" __declspec(dllexport) BOOL GetFaciesColor(BYTE* nameBuf, int nameStrLen, DWORD& color) { bool b = TRUE; char* pBuf = new char[nameStrLen + 1]; pBuf[nameStrLen] = 0; memcpy(pBuf, nameBuf, nameStrLen); CString str = pBuf; char*pstr = UTF8_To_GB2312(str.GetBuffer()); str.ReleaseBuffer(); str = pstr; delete[]pstr; //color = AfxGetGlobalWellFaciesLib()->GetColor(str); color = RGB(255, 255, 255); AfxGetGlobalInterpretBrushLib()->GetColor(BrushFacies, str, color); delete[] pBuf; return b; } extern "C" __declspec(dllexport) BOOL RefreshAllInTrackObjsForOneWellTable(ULONGLONG wellHandle, BYTE* strTableId, int TableIdStrLen) { BOOL b = FALSE; try { char* pBuf = new char[TableIdStrLen + 1]; pBuf[TableIdStrLen] = 0; memcpy(pBuf, strTableId, TableIdStrLen); CString strTableId = pBuf; CWellBaseObj* pWellBase = (CWellBaseObj*)wellHandle; CWellPole* pWell = dynamic_cast(pWellBase); TRACKLIST trackList; pWell->GetAllTrack(&trackList); TRACKLIST::iterator it = trackList.begin(); for (; it != trackList.end(); it++) { CTrackObj* pTrack = (*it); if (pTrack->m_dataSourceID == strTableId) { pTrack->SetDataRefID(pTrack->m_dataSourceID, pTrack->m_dataColID); } } delete[]pBuf; b = TRUE; } catch (std::exception e) { return FALSE; } return b; } extern "C" __declspec(dllexport) BOOL WellTempateGetTracksType(LPCTSTR lpszFileName , BYTE*& ttypeBuf, int& trackNum, BYTE*& refCol, int& refColLen)//用来获取井模板中的道信息,不新建文档视图 { BOOL b = FALSE; trackNum = 0; ttypeBuf = NULL; refColLen = 0; if (CWellPoleDoc::c_xy) delete CWellPoleDoc::c_xy; CWellPoleDoc::c_xy = new CXy(); CWellPoleDoc::c_xy->SetXyType(CXy::XYTYPE::wellPole); if (CWellPoleDoc::c_xy->PCG_Read3(lpszFileName) == 0) return FALSE; POSITION pos = CWellPoleDoc::c_xy->GetValueList()->GetHeadPosition(); while (pos != NULL) { COne* pOne = (COne*)CWellPoleDoc::c_xy->GetValueList()->GetNext(pos); if (pOne->GetType() == KEP_WELL) { CWellPoleDoc::c_well = (CWellPole*)pOne->GetValue(); break; } } if (CWellPoleDoc::c_well == NULL) return FALSE; BYTE* tracksHandleBuf = NULL; BYTE* dataRef = NULL; int dataRefLen = 0; BYTE* refTable = NULL; int refTableLen = 0; refCol = NULL; refColLen = 0; if (GetWellTracks(NULL, ULONGLONG(CWellPoleDoc::c_well), tracksHandleBuf, ttypeBuf, trackNum, dataRef, dataRefLen, refTable,refTableLen, refCol, refColLen)) { b = TRUE; if (tracksHandleBuf != NULL) delete[] tracksHandleBuf; if (dataRef != NULL) delete[] dataRef; if (refTable != NULL) delete[]refTable; } delete CWellPoleDoc::c_xy; CWellPoleDoc::c_xy = NULL; CWellPoleDoc::c_well = NULL; return b; } extern "C" __declspec(dllexport) BOOL MovingSelectedTrackInWell(CSigmaView* pView) { CWellPoleView* pWellView = dynamic_cast(pView); CMultiWellSectionView* pSectionView = dynamic_cast(pView); BOOL b = FALSE; if (pWellView) { CItem* pItem = pWellView->GetItem(); if (pItem == NULL) return FALSE; if (pItem->GetType() != ITEM_WELLPOLE) return FALSE; CItemSingleWell* pItemWell = (CItemSingleWell*)pItem; if (pItemWell->m_WellObjSelectlist.GetCount() != 1) return FALSE; CWellBaseObj* pObjSelected = pItemWell->m_WellObjSelectlist.GetHead(); if (pItemWell->selectMode == CItemSelect::move && pObjSelected->GetType() == KEP_TRACK) { b = TRUE; } } if (pSectionView) { CItem* pItem = pSectionView->GetItem(); if (pItem == NULL) return FALSE; if (pItem->GetType() != ITEM_WELLSECTION) return FALSE; CItemWellSection* pItemSection = (CItemWellSection*)pItem; if (pItemSection->m_pItemSelected == NULL) return FALSE; if (pItemSection->m_pItemSelected->GetType() == ITEM_SECTIONWELL) { CItemWcsSingleWell* pItemWell = (CItemWcsSingleWell*)pItemSection->m_pItemSelected; if (pItemWell->m_WellObjSelectlist.GetCount() != 1) return FALSE; CWellBaseObj* pObjSelected = pItemWell->m_WellObjSelectlist.GetHead(); if (pItemWell->selectMode == CItemSelect::move && pObjSelected->GetType() == KEP_TRACK) { b = TRUE; } } } return b; } extern "C" __declspec(dllexport) BOOL SetSelectedTrackInWellMovePicture(CSigmaView* pView, HDC hdcMem) {//拖动道时,绘制被移动道及所经过道头区域 BOOL b = FALSE; CWellPoleView* pWellView = dynamic_cast(pView); CMultiWellSectionView* pSectionView = dynamic_cast(pView); if (pWellView) { CItem* pItem = pWellView->GetItem(); if (pItem == NULL) return FALSE; if (pItem->GetType() != ITEM_WELLPOLE) return FALSE; CItemSingleWell* pItemWell = (CItemSingleWell*)pItem; if (pItemWell->m_WellObjSelectlist.GetCount() != 1) return FALSE; CWellBaseObj* pObjSelected = pItemWell->m_WellObjSelectlist.GetHead(); if (pItemWell->selectMode == CItemSelect::move && pObjSelected->GetType() == KEP_TRACK) { CDC* pDC = CDC::FromHandle(hdcMem); pItemWell->DrawMovedTrackPicture(pDC); b = TRUE; } } if (pSectionView) { CItem* pItem = pSectionView->GetItem(); if (pItem == NULL) return FALSE; if (pItem->GetType() != ITEM_WELLSECTION) return FALSE; CItemWellSection* pItemSection = (CItemWellSection*)pItem; if (pItemSection->m_pItemSelected == NULL) return FALSE; if (pItemSection->m_pItemSelected->GetType() == ITEM_SECTIONWELL) { CItemWcsSingleWell* pItemWell = (CItemWcsSingleWell*)pItemSection->m_pItemSelected; if (pItemWell->m_WellObjSelectlist.GetCount() != 1) return FALSE; CWellBaseObj* pObjSelected = pItemWell->m_WellObjSelectlist.GetHead(); if (pItemWell->selectMode == CItemSelect::move && pObjSelected->GetType() == KEP_TRACK) { CDC* pDC = CDC::FromHandle(hdcMem); pItemWell->DrawMovedTrackPicture(pDC); b = TRUE; } } } return b; } extern "C" __declspec(dllexport) BOOL GetSelectedWellObjectScreenRange(CSigmaView* pView, ULONGLONG wellHandle, int& left,int &top, int& right, int& bottom) { BOOL b = FALSE; left = top = right = bottom = 0; CWellPoleView* pWellView = dynamic_cast(pView); CMultiWellSectionView* pSectionView = dynamic_cast(pView); if (pWellView) { CWellBaseObj* pBaseObj = (CWellBaseObj*)wellHandle; CRect8 orect = pBaseObj->GetRect(); CWellPoleDoc* pWellDoc = pWellView->GetDocument(); if (pWellDoc) { CRect rect = pWellDoc->GetDC().GetScreen(orect); left = rect.left; top = rect.top; right = rect.right; bottom = rect.bottom; } b = TRUE; } if (pSectionView) { CWellBaseObj* pBaseObj = (CWellBaseObj*)wellHandle; CRect8 orect = pBaseObj->GetRect(); CMultiWellSectionDoc* pDoc = pSectionView->GetDocument(); if (pDoc) { CRect rect = pDoc->GetDC().GetScreen(orect); left = rect.left; top = rect.top; right = rect.right; bottom = rect.bottom; } b = TRUE; } return b; } extern "C" __declspec(dllexport) BOOL WellPoleGetToolTipInfo(CWellPoleView* pView, int X, int Y, BYTE*& strInfo, int& dataLen) { BOOL b = FALSE; strInfo = NULL; dataLen = 0; CWellPoleDoc* pWellDoc = pView->GetDocument(); CWellPole* pWell = pWellDoc->GetWellPole(); if (pWell) { //CRect trect(X, Y, X+1, Y-1); CPoint2D pt = pWellDoc->GetDC().GetReal(X*1.0, Y*1.0); //CRect8 ptRect = pWellDoc->GetDC().GetReal(trect); CRect8 rect = pWell->GetRect(); if (rect.PtInRect(pt)) { if (pt.y0 < pWell->GetTrackStartTop()) { CString str,str1,str2,strTotal; double depth; if (pWell->GetDepthInWell(pt.y0, depth) > -1) { str.Format("深度:%.2f", depth); } TRACKLIST trackList; pWell->GetAllTrack(&trackList, Track_Curve); TRACKLIST::iterator it = trackList.begin(); double value; int valueid; for (; it != trackList.end(); it++) { CTrackCurve* pTrackObj = (CTrackCurve * )(*it); if (pTrackObj->GetRect().PtInRect(pt) == FALSE) continue; if (pTrackObj->GetCurveValue(depth, value, valueid)) { str1.Format("%s:%.2f", pTrackObj->m_dataObj.m_curve_name, value); } str2 = str2 + "\r\n" +str1; } str2.TrimLeft("\r\n"); if (!str.IsEmpty()) strTotal = str + "\r\n"; if (!str2.IsEmpty()) strTotal = strTotal + str2; strInfo = (new BYTE[strTotal.GetLength()]); memcpy((char*)strInfo, strTotal.GetBuffer(), strTotal.GetLength()); dataLen = strTotal.GetLength(); b = TRUE; } } } return b; }