# include <cctype>
# include "stdafx.h"
# include "SigmaView.h"
# include "DrawBend.h"
# include "SectionDoc.h"
# include "Item.h"
# include "ItemSelect.h"
# include "ItemEraser.h"
# include "ActionDeleteLayerItem.h"
# include "ActionComboItem.h"
# include "ActionLayerDragDropItem.h"
# include "ItemPointAdd.h"
# include "ActionAddItem.h"
# include "ItemScaleEmbellish.h"
# include "./spdlog/spdlog.h"
# include "ItemSolid.h"
# include "./spdlog/sinks/rotating_file_sink.h"
# include "QTransformTracker.h"
# include "ActionListItem.h"
# include "ActionEmbellishItem.h"
# include "ActionLayerRenameItem.h"
# include "actionaddlayeritem.h"
# include "ActionChangeLayerItem.h"
# include "ActionReverseZItem.h"
# include "ItemExportFile.h"
# include "StatusDefine.h"
# include "TinyXml/tinyxml.h"
# include "DoubleComparator.h"
# include "UndoManager/UndoManager.h"
# include <optional>
# include <string_view>
# include <comutil.h>
# include <memory>
# include "vtkInterface.h"
# include "Interface.h"
# include "DrawOperator/FileUtility.h"
# include "WellPoleLib/WellPoleInitCShap.h"
# include "MultiWellSectionLib/MVSectionInitCShap.h"
# include "DrawOperator/Util.h"
# include "ObjectProxyFactory.h"
# include "DrawOperator/MapViewLayer.h"
//#include "PolygonTreeInterface.h"
//#include "InterfaceElements.h"
static bool bInitLog = false ;
static bool bInitDump = false ;
long __stdcall CrashInfocallback ( _EXCEPTION_POINTERS * pexcp ) ;
static void InitLog ( ) ;
/**
* <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ⲣ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ҫ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ij <EFBFBD> ʼ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> C # <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> C + + <EFBFBD> <EFBFBD> ̬ <EFBFBD> <EFBFBD> ʱ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> أ <EFBFBD> <EFBFBD> <EFBFBD> һ <EFBFBD> ε <EFBFBD> <EFBFBD> ö <EFBFBD> ̬ <EFBFBD> <EFBFBD> <EFBFBD> е ĺ <EFBFBD> <EFBFBD> <EFBFBD> ʱ <EFBFBD> Ż <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> أ <EFBFBD>
* <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʧ <EFBFBD> ܣ <EFBFBD> <EFBFBD> <EFBFBD> ʱ <EFBFBD> <EFBFBD> <EFBFBD> Ż ᱨ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> C # <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> һ <EFBFBD> <EFBFBD> ʼ ʱ <EFBFBD> ͵ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> һ <EFBFBD> Σ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ̬ <EFBFBD> ⲻ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
* <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĵ <EFBFBD> һ ʱ <EFBFBD> ䷢ <EFBFBD> <EFBFBD>
*
*/
extern " C " __declspec ( dllexport )
void GeoSigmaLibInit ( )
{
WellPoleLibInit_CSHAP ( ) ;
MultiWellSectionLibInit_CSHAP ( ) ;
TRACE ( " GeoSigmaLibInit \n " ) ;
}
extern " C " __declspec ( dllexport )
BOOL PointerFree ( void * p )
{
if ( p ! = nullptr )
{
free ( p ) ;
p = nullptr ;
}
return true ;
}
extern " C " __declspec ( dllexport )
BOOL PointerDelete ( void * p )
{
if ( p ! = nullptr )
{
delete p ;
p = nullptr ;
}
return true ;
}
extern " C " __declspec ( dllexport )
BOOL PointerArrayDelete ( void * p )
{
delete [ ] p ;
p = nullptr ;
return true ;
}
extern " C " __declspec ( dllexport )
BOOL TestFunSigma ( LPCTSTR strInput )
{
AfxMessageBox ( strInput ) ;
return 0 ;
}
extern " C " __declspec ( dllexport )
bool DestroyView ( CSigmaView * pView )
{
if ( pView ! = nullptr )
{
delete pView ;
pView = nullptr ;
}
//if (pSectionDoc != nullptr) {
// delete pSectionDoc;
// pSectionDoc = nullptr;
//}
return true ;
}
extern " C " __declspec ( dllexport )
CSigmaView * CreateView ( )
{
//if (!bInitDump)
//{
// //::SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER)CrashInfocallback);
// bInitDump = true;
// InitLog();
//}
CSigmaView * pView = new CSigmaView ( ) ;
return pView ;
}
// <20> Ƿ<EFBFBD> <C7B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ת<EFBFBD> ༭
extern " C " __declspec ( dllexport )
void EnableRotateEdit ( CSigmaView * pView , bool enable )
{
if ( pView = = nullptr )
{
return ;
}
pView - > SetEnableRotate ( enable ) ;
}
extern " C " __declspec ( dllexport )
CSigmaView * CreateViewByXy ( CXy * pXy )
{
CSigmaView * pView = new CSigmaView ( pXy ) ;
return pView ;
}
extern " C " __declspec ( dllexport )
void * GetDrawerXy ( CSigmaView * pView )
{
if ( pView - > m_pDoc - > m_pXy = = NULL ) return 0 ;
return pView - > m_pDoc - > m_pXy ;
}
BOOL SaveAs ( CDC * pDC , const wchar_t * lpszFilename ) ;
extern " C " __declspec ( dllexport )
void SetScreenDC ( CSigmaView * pView , HDC hdcMem )
{
CDC * pDC = CDC : : FromHandle ( hdcMem ) ;
//SaveAs(pDC, L"C:\\tmpScree.bmp");
pView - > SetScreenDC ( pDC ) ;
}
extern " C " __declspec ( dllexport )
void SetImgDC ( CSigmaView * pView , HDC hdcMem )
{
CDC * pDC = CDC : : FromHandle ( hdcMem ) ;
//SaveAs(pDC, L"C:\\tmpSet.bmp");
pView - > SetImgDc ( pDC ) ;
}
static CMesh * GetMesh ( CSigmaView * pView ) ;
extern " C " __declspec ( dllexport )
double GetKevMeshMaxScale ( CSigmaView * pView , KevVtkMeshData * pMesh )
{
double ret = - 1 ;
if ( pView = = nullptr )
{
TRACE ( " pViewΪ<EFBFBD> <EFBFBD> \n " ) ;
return ret ;
}
CSigmaDoc * pDoc = pView - > m_pDoc ;
CXyDC * pXyDC = & pDoc - > GetDC ( ) ;
CXy * pXy = pDoc - > m_pXy ;
if ( pMesh = = nullptr )
{
TRACE ( " δ<EFBFBD> ҵ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> \n " ) ;
return ret ;
}
int scaleArr [ 16 ] = { 100 , 200 , 500 , 1000 , 2000 , 5000 , 10000 , 20000 , 25000 , 50000 , 100000 , 200000 , 500000 , 1000000 , 2000000 , 5000000 } ;
double width = pMesh - > dx * ( pMesh - > numX - 1 ) ;
double height = pMesh - > dy * ( pMesh - > numY - 1 ) ;
int maxPixelNum = ( 100 * 1024 * 1024 ) / 4 ;
int length = sizeof ( scaleArr ) / sizeof ( scaleArr [ 0 ] ) ;
double scale = 1 ;
double screenWidth = 1 ;
double screenHeight = 1 ;
for ( int i = 0 ; i < length ; i + + )
{
scale = 1.0f / ( scaleArr [ i ] / 1000.0f ) ;
pXyDC - > SetScale ( scale , scale ) ;
pXy - > SetUnit ( 1 , 1 ) ;
screenWidth = pXyDC - > GetScreenWidth ( width ) ;
screenHeight = abs ( pXyDC - > GetScreenHeight ( height ) ) ;
double num = screenWidth * screenHeight ;
if ( num > maxPixelNum )
{
continue ;
}
else
{
ret = scale ;
break ;
}
}
return ret ;
}
extern " C " __declspec ( dllexport )
double GetFirstMeshMaxScale ( CSigmaView * pView )
{
double ret = - 1 ;
if ( pView = = nullptr )
{
TRACE ( " pViewΪ<EFBFBD> <EFBFBD> \n " ) ;
return ret ;
}
CSigmaDoc * pDoc = pView - > m_pDoc ;
CXyDC * pXyDC = & pDoc - > GetDC ( ) ;
CXy * pXy = pDoc - > m_pXy ;
if ( pXy - > GetCount ( ) < = 0 )
{
TRACE ( " ͼ<EFBFBD> <EFBFBD> <EFBFBD> в<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> κ<EFBFBD> Ԫ<EFBFBD> <EFBFBD> \n " ) ;
return ret ;
}
CMesh * pMesh = GetMesh ( pView ) ;
if ( pMesh = = nullptr )
{
TRACE ( " δ<EFBFBD> ҵ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> \n " ) ;
return ret ;
}
int scaleArr [ 16 ] = { 100 , 200 , 500 , 1000 , 2000 , 5000 , 10000 , 20000 , 25000 , 50000 , 100000 , 200000 , 500000 , 1000000 , 2000000 , 5000000 } ;
double width = pMesh - > Width ( ) ;
double height = pMesh - > Height ( ) ;
int maxPixelNum = ( 50 * 1024 * 1024 ) / 4 ;
int length = sizeof ( scaleArr ) / sizeof ( scaleArr [ 0 ] ) ;
double scale = 1 ;
double screenWidth = 1 ;
double screenHeight = 1 ;
for ( int i = 0 ; i < length ; i + + )
{
scale = 1.0f / ( scaleArr [ i ] / 1000.0f ) ;
pXyDC - > SetScale ( scale , scale ) ;
pXy - > SetUnit ( 1 , 1 ) ;
screenWidth = pXyDC - > GetScreenWidth ( width ) ;
screenHeight = abs ( pXyDC - > GetScreenHeight ( height ) ) ;
double num = screenWidth * screenHeight ;
if ( num > maxPixelNum )
{
continue ;
}
else
{
ret = scale ;
break ;
}
}
return ret ;
}
/**
* <EFBFBD> <EFBFBD> ȡ KEV <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֱ <EFBFBD> <EFBFBD> <EFBFBD> ͼ <EFBFBD> <EFBFBD>
*
* \ param pView
* \ return
*/
extern " C " __declspec ( dllexport )
HBITMAP GetKevMeshImage ( CSigmaView * pView , KevVtkMeshData * pMeshData )
{
if ( pView = = nullptr )
{
TRACE ( " pViewΪ<EFBFBD> <EFBFBD> \n " ) ;
return nullptr ;
}
CSigmaDoc * pDoc = pView - > m_pDoc ;
CXyDC * pXyDC = & pDoc - > GetDC ( ) ;
CXy * pXy = pDoc - > m_pXy ;
if ( pXy - > GetCount ( ) < = 0 )
{
TRACE ( " ͼ<EFBFBD> <EFBFBD> <EFBFBD> в<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> κ<EFBFBD> Ԫ<EFBFBD> <EFBFBD> \n " ) ;
return nullptr ;
}
if ( pMeshData = = nullptr )
{
TRACE ( " <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϊ<EFBFBD> <EFBFBD> \n " ) ;
return nullptr ;
}
double scale = GetKevMeshMaxScale ( pView , pMeshData ) ;
if ( scale < 0 )
{
TRACE ( " û<EFBFBD> к<EFBFBD> <EFBFBD> ʵı <EFBFBD> <EFBFBD> <EFBFBD> \n " ) ;
return nullptr ;
}
double width = pMeshData - > dx * ( pMeshData - > numX - 1 ) ;
double height = pMeshData - > dy * ( pMeshData - > numY - 1 ) ;
double left = pMeshData - > P0 [ 0 ] ;
double right = pMeshData - > P0 [ 0 ] + width ;
double bottom = pMeshData - > P0 [ 1 ] ;
double top = bottom + height ;
NBase : : CRect8 meshRect ;
meshRect . bottom = bottom ;
meshRect . top = top ;
meshRect . left = left ;
meshRect . right = right ;
pXyDC - > SetScale ( scale , scale ) ;
pXy - > SetUnit ( 1 , 1 ) ;
double screenWidth = pXyDC - > GetScreenWidth ( width ) ;
double screenHeight = abs ( pXyDC - > GetScreenHeight ( height ) ) ;
if ( screenWidth < 2 | | screenHeight < 2 )
{
return nullptr ;
}
CSize screenSize ( screenWidth , screenHeight ) ;
CDC dc ; dc . CreateCompatibleDC ( NULL ) ;
CXyDC pDC ;
pDC . Create ( & dc , false ) ;
pDC . SetAntiAlias ( true ) ;
int planes = dc . GetDeviceCaps ( PLANES ) ; // <20> <> ɫƽ <C9AB> <C6BD> <EFBFBD> <EFBFBD>
int bpp = dc . GetDeviceCaps ( BITSPIXEL ) ; // <20> <> ɫ<EFBFBD> <C9AB> <EFBFBD> <EFBFBD> ֵ
CBitmap * pBitmap , * pOldBitmap ;
pBitmap = new CBitmap ( ) ;
pBitmap - > CreateBitmap ( screenSize . cx , screenSize . cy , planes , bpp , NULL ) ;
pOldBitmap = dc . SelectObject ( pBitmap ) ;
dc . FillSolidRect ( 0 , 0 , screenSize . cx , screenSize . cy , RGB ( 255 , 255 , 255 ) ) ;
if ( pXy - > GetCount ( ) > 0 )
{
CRect rt ( 0 , 0 , screenSize . cx , screenSize . cy ) ;
pDC . Extend ( meshRect , rt , EXTEND_MODE_CENTER ) ;
pDC . SetViewRect ( rt ) ;
// FIXME: Ŀǰ<C4BF> Ľ<EFBFBD> ͼ<EFBFBD> <CDBC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݣ<EFBFBD> <DDA3> <EFBFBD> <EFBFBD> ų<EFBFBD> <C5B3> <EFBFBD> <EEA3AC> <EFBFBD> Żᳬ<C5BB> <E1B3AC> <EFBFBD> <EFBFBD> Χ <EFBFBD> <CEA7> ͼ<EFBFBD> <CDBC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݶ<EFBFBD> <DDB6> <EFBFBD> Ӱ<EFBFBD> 죬<EFBFBD> <ECA3AC> û<EFBFBD> ҵ<EFBFBD> ԭ<EFBFBD> <D4AD>
pDC . SetAntiAlias ( true ) ;
pXy - > Draw ( pDC ) ;
}
////<2F> <> <EFBFBD> <EFBFBD> Ϊ<EFBFBD> ļ<EFBFBD>
//CImage image;
//image.Attach(*pBitmap);
//CString filePath = "./FirstMeshImage.bmp";
//image.Save(filePath);
//image.Detach();
dc . SelectObject ( pOldBitmap ) ;
HBITMAP hBit = ( HBITMAP ) pBitmap - > Detach ( ) ;
delete pBitmap ;
dc . DeleteDC ( ) ;
return hBit ;
}
/**
* <EFBFBD> <EFBFBD> ȡ <EFBFBD> <EFBFBD> һ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֱ <EFBFBD> <EFBFBD> <EFBFBD> ͼ <EFBFBD> <EFBFBD>
*
* \ param pView ͼ <EFBFBD> <EFBFBD>
* \ return
*/
extern " C " __declspec ( dllexport )
HBITMAP GetFirstMeshImage ( CSigmaView * pView )
{
if ( pView = = nullptr )
{
TRACE ( " pViewΪ<EFBFBD> <EFBFBD> \n " ) ;
return nullptr ;
}
CSigmaDoc * pDoc = pView - > m_pDoc ;
CXyDC * pXyDC = & pDoc - > GetDC ( ) ;
CXy * pXy = pDoc - > m_pXy ;
if ( pXy - > GetCount ( ) < = 0 )
{
TRACE ( " ͼ<EFBFBD> <EFBFBD> <EFBFBD> в<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> κ<EFBFBD> Ԫ<EFBFBD> <EFBFBD> \n " ) ;
return nullptr ;
}
CMesh * pMesh = GetMesh ( pView ) ;
if ( pMesh = = nullptr )
{
TRACE ( " δ<EFBFBD> ҵ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> \n " ) ;
return nullptr ;
}
double scale = GetFirstMeshMaxScale ( pView ) ;
if ( scale < 0 )
{
TRACE ( " û<EFBFBD> к<EFBFBD> <EFBFBD> ʵı <EFBFBD> <EFBFBD> <EFBFBD> \n " ) ;
return nullptr ;
}
NBase : : CRect8 meshRect = pMesh - > GetRect ( ) ;
double width = meshRect . Width ( ) ;
double height = meshRect . Height ( ) ;
double left = meshRect . left ;
double right = meshRect . right ;
double top = meshRect . top ;
double bottom = meshRect . bottom ;
pXyDC - > SetScale ( scale , scale ) ;
pXy - > SetUnit ( 1 , 1 ) ;
double screenWidth = pXyDC - > GetScreenWidth ( width ) ;
double screenHeight = abs ( pXyDC - > GetScreenHeight ( height ) ) ;
if ( screenWidth < 2 | | screenHeight < 2 )
{
return nullptr ;
}
CSize screenSize ( screenWidth , screenHeight ) ;
CDC dc ; dc . CreateCompatibleDC ( NULL ) ;
CXyDC pDC ;
pDC . Create ( & dc , false ) ;
pDC . SetAntiAlias ( true ) ;
int planes = dc . GetDeviceCaps ( PLANES ) ; // <20> <> ɫƽ <C9AB> <C6BD> <EFBFBD> <EFBFBD>
int bpp = dc . GetDeviceCaps ( BITSPIXEL ) ; // <20> <> ɫ<EFBFBD> <C9AB> <EFBFBD> <EFBFBD> ֵ
CBitmap * pBitmap , * pOldBitmap ;
pBitmap = new CBitmap ( ) ;
pBitmap - > CreateBitmap ( screenSize . cx , screenSize . cy , planes , bpp , NULL ) ;
pOldBitmap = dc . SelectObject ( pBitmap ) ;
dc . FillSolidRect ( 0 , 0 , screenSize . cx , screenSize . cy , RGB ( 255 , 255 , 255 ) ) ;
if ( pXy - > GetCount ( ) > 0 )
{
CRect rt ( 0 , 0 , screenSize . cx , screenSize . cy ) ;
pDC . Extend ( meshRect , rt , EXTEND_MODE_CENTER ) ;
pDC . SetViewRect ( rt ) ;
// FIXME: Ŀǰ<C4BF> Ľ<EFBFBD> ͼ<EFBFBD> <CDBC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݣ<EFBFBD> <DDA3> <EFBFBD> <EFBFBD> ų<EFBFBD> <C5B3> <EFBFBD> <EEA3AC> <EFBFBD> Żᳬ<C5BB> <E1B3AC> <EFBFBD> <EFBFBD> Χ <EFBFBD> <CEA7> ͼ<EFBFBD> <CDBC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݶ<EFBFBD> <DDB6> <EFBFBD> Ӱ<EFBFBD> 죬<EFBFBD> <ECA3AC> û<EFBFBD> ҵ<EFBFBD> ԭ<EFBFBD> <D4AD>
pDC . SetAntiAlias ( true ) ;
pXy - > Draw ( pDC ) ;
}
////<2F> <> <EFBFBD> <EFBFBD> Ϊ<EFBFBD> ļ<EFBFBD>
//CImage image;
//image.Attach(*pBitmap);
//CString filePath = "./FirstMeshImage.bmp";
//image.Save(filePath);
//image.Detach();
dc . SelectObject ( pOldBitmap ) ;
HBITMAP hBit = ( HBITMAP ) pBitmap - > Detach ( ) ;
dc . DeleteDC ( ) ;
delete pBitmap ;
return hBit ;
}
/**
* <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ָ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Χ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͼ <EFBFBD> <EFBFBD> .
*
* @ param pView
* @ param left
* @ param top
* @ param right
* @ param bottom
* @ return
*/
extern " C " __declspec ( dllexport )
HBITMAP DrawImageBmp ( CSigmaView * pView , double left , double top , double right , double bottom )
{
CSigmaDoc * pDoc = pView - > m_pDoc ;
CXyDC * pXyDC = & pDoc - > GetDC ( ) ;
CXy * pXy = pDoc - > m_pXy ;
if ( pXy - > GetCount ( ) < = 0 )
{
return nullptr ;
}
//<2F> <> <EFBFBD> õ<EFBFBD> <C3B5> <EFBFBD> ͼ<EFBFBD> <CDBC> <EFBFBD> Ĵ<EFBFBD> С
NBase : : CRect8 rect ( 1e100 , - 1e100 , - 1e100 , 1e100 ) ;
if ( left = = right | | top = = bottom )
{
pView - > m_pDoc - > GetDrawRange ( rect ) ;
}
else
{
rect . SetRect ( left , top , right , bottom ) ;
}
double dx = rect . Width ( ) ;
double dy = rect . Height ( ) ;
if ( dx < 1e-20 | | dy < 1e-20 )
{
return nullptr ;
}
CSize sz ( pXyDC - > GetScreenWidth ( dx ) , abs ( pXyDC - > GetScreenHeight ( dy ) ) ) ;
CDC dc ; dc . CreateCompatibleDC ( NULL ) ;
CXyDC pDC ;
pDC . Create ( & dc , false ) ;
pDC . SetAntiAlias ( true ) ;
int planes = dc . GetDeviceCaps ( PLANES ) ;
int bpp = dc . GetDeviceCaps ( BITSPIXEL ) ;
CBitmap * pBitmap , * pOldBitmap ;
pBitmap = new CBitmap ( ) ;
pBitmap - > CreateBitmap ( sz . cx , sz . cy , planes , bpp , NULL ) ;
pOldBitmap = dc . SelectObject ( pBitmap ) ;
dc . FillSolidRect ( 0 , 0 , sz . cx , sz . cy , RGB ( 255 , 255 , 255 ) ) ;
if ( pXy - > GetCount ( ) > 0 )
{
CRect rt ( 0 , 0 , sz . cx , sz . cy ) ;
pDC . Extend ( rect , rt , EXTEND_MODE_CENTER ) ;
pDC . SetViewRect ( rt ) ;
// FIXME: Ŀǰ<C4BF> Ľ<EFBFBD> ͼ<EFBFBD> <CDBC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݣ<EFBFBD> <DDA3> <EFBFBD> <EFBFBD> ų<EFBFBD> <C5B3> <EFBFBD> <EEA3AC> <EFBFBD> Żᳬ<C5BB> <E1B3AC> <EFBFBD> <EFBFBD> Χ <EFBFBD> <CEA7> ͼ<EFBFBD> <CDBC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݶ<EFBFBD> <DDB6> <EFBFBD> Ӱ<EFBFBD> 죬<EFBFBD> <ECA3AC> û<EFBFBD> ҵ<EFBFBD> ԭ<EFBFBD> <D4AD>
pDC . SetAntiAlias ( true ) ;
pXy - > Draw ( pDC ) ;
}
dc . SelectObject ( pOldBitmap ) ;
HBITMAP hBit = ( HBITMAP ) pBitmap - > Detach ( ) ;
pBitmap - > DeleteObject ( ) ;
dc . DeleteDC ( ) ;
delete pBitmap ;
return hBit ;
}
extern " C " __declspec ( dllexport )
void SetViewBackcolor ( CSigmaView * pView , int r , int g , int b )
{
pView - > SetBackColor ( RGB ( r , g , b ) ) ;
}
extern " C " __declspec ( dllexport )
void GetViewBackcolor ( CSigmaView * pView , int & r , int & g , int & b )
{
COLORREF colRef = pView - > GetBackColor ( ) ;
r = GetRValue ( colRef ) ;
g = GetGValue ( colRef ) ;
b = GetBValue ( colRef ) ;
}
extern " C " __declspec ( dllexport )
void SetSymbolView ( CSigmaView * pView , BOOL isSymbolView )
{
pView - > SetSymbolView ( isSymbolView ) ;
}
extern " C " __declspec ( dllexport )
void CombinImgDC ( CSigmaView * pView , int x , int y , int width , int height , int screenX , int screenY )
{
//CImage imag;
//imag.Create(width, height, 32);
////<2F> <> CDC<44> <43> <EFBFBD> Ƶ<EFBFBD> imag
//BitBlt(imag.GetDC(), 0, 0, width, height, hdcMem, 0, 0, SRCCOPY);
//HRESULT hResult = imag.Save(_T("c:\\new.jpg"));
//imag.ReleaseDC();
pView - > CombinImg ( x , y , width , height , screenX , screenY ) ;
}
extern " C " __declspec ( dllexport )
void SetImgDCAndSize ( CSigmaView * pView , HDC hdcMem , int left , int top , int right , int bottom )
{
CDC * pDC = CDC : : FromHandle ( hdcMem ) ;
//int nHDpi = pDC->GetDeviceCaps(HORZSIZE);
//int nVDpi= pDC->GetDeviceCaps(VERTSIZE);
pView - > SetImgDc ( pDC ) ;
pView - > SetClient ( left , top , right , bottom ) ;
}
extern " C " __declspec ( dllexport )
void SetAntiAlias ( CSigmaView * pView , bool enable )
{
pView - > SetAntiAlias ( enable ) ;
}
extern " C " __declspec ( dllexport )
bool GetAntiAlias ( CSigmaView * pView )
{
return pView - > GetAntiAlias ( ) ;
}
extern " C " __declspec ( dllexport )
void SetPrinting ( CSigmaView * pView , bool isPriting )
{
pView - > SetPrinting ( isPriting ) ;
}
extern " C " __declspec ( dllexport )
bool GetIsPriting ( CSigmaView * pView )
{
return pView - > GetIsPriting ( ) ;
}
extern " C " __declspec ( dllexport )
void SetViewRect ( CSigmaView * pView , int left , int top , int right , int bottom )
{
pView - > SetClient ( left , top , right , bottom ) ;
}
extern " C " __declspec ( dllexport )
void InitializeImg ( CSigmaView * pView , HDC hdcMem , int left , int top , int right , int bottom )
{
SetImgDCAndSize ( pView , hdcMem , left , top , right , bottom ) ;
pView - > InitialView ( ) ;
}
extern " C " __declspec ( dllexport )
bool DrawImg ( CSigmaView * pView , bool symbolViewFlag )
{
return pView - > DrawImg ( symbolViewFlag ) ;
}
extern " C " __declspec ( dllexport )
bool DrawOther ( CSigmaView * pView , HDC hdcMem )
{
CDC * pDC = CDC : : FromHandle ( hdcMem ) ;
pView - > OnDrawOther ( pDC ) ;
return true ;
}
extern " C " __declspec ( dllexport )
void Sigma_UndoView ( CSigmaView * pView )
{
if ( pView - > m_pDoc = = 0 )
return ;
pView - > m_pDoc - > PopDC ( ) ;
CItemSelect * pItemSelect = pView - > m_pDoc - > GetSelectItem ( ) ;
if ( pItemSelect ! = nullptr )
{
pItemSelect - > ReloadTrackerPath ( ) ;
}
}
extern " C " __declspec ( dllexport )
int GeoSigma_GetZoomStackCount ( CSigmaView * pView )
{
if ( pView - > m_pDoc = = 0 )
return - 1 ;
return pView - > m_pDoc - > GetZoomStackCount ( ) ;
}
extern " C " __declspec ( dllexport )
void Sigma_DrawAssistant ( CSigmaView * pView , int mouseX , int mouseY , HDC hdc )
{
if ( pView = = 0 )
return ;
if ( pView - > m_pDoc = = 0 )
return ;
CDC * pDC = CDC : : FromHandle ( hdc ) ;
if ( pDC = = 0 )
return ;
NItem : : CItem * pItem = pView - > m_pDoc - > GetItem ( ) ;
if ( pItem = = 0 )
return ;
pItem - > DrawAssistant ( pDC , mouseX , mouseY ) ;
}
extern " C " __declspec ( dllexport )
void SigmaViewShowBKGrid ( CSigmaView * pView , int bShow )
{
if ( pView = = nullptr )
return ;
pView - > ShowBKGrid ( bShow = = 0 ? false : true ) ;
}
extern " C " __declspec ( dllexport )
void SetViewDC ( CSigmaView * pView , HDC hdcMem , int left , int top , int right , int bottom )
{
CDC * pDC = CDC : : FromHandle ( hdcMem ) ;
//CDC *pDC = new CDC;
//pDC->Attach(hdcMem);
pView - > SetDc ( pDC ) ;
pView - > SetClient ( left , top , right , bottom ) ;
//pDC->Detach();
//pDC->DeleteDC();
}
extern " C " __declspec ( dllexport )
CSigmaView * CreateViewWithDC ( HDC hdcMem , int left , int top , int right , int bottom )
{
//if (pSectionDoc == nullptr)
//{
// pSectionDoc = new CSectionDoc();
//}
//HDC hDC = ::GetDC(handAddress);
CSigmaView * pView = new CSigmaView ( ) ;
SetViewDC ( pView , hdcMem , left , top , right , bottom ) ;
//CDC *pDC = CDC::FromHandle(hdcMem);
//pView->SetDc(pDC);
//pView->SetClient(left, top, right, bottom);
return pView ;
}
extern " C " __declspec ( dllexport )
CSigmaView * CreateViewWithXyDC ( CXy * pXy , HDC hdcMem , int left , int top , int right , int bottom )
{
CSigmaView * pView = new CSigmaView ( pXy ) ;
SetViewDC ( pView , hdcMem , left , top , right , bottom ) ;
return pView ;
}
extern " C " __declspec ( dllexport )
HDC GetViewDC ( CSigmaView * pView )
{
if ( pView = = nullptr | | pView - > m_pDC = = nullptr )
return nullptr ;
return pView - > m_pDC - > GetSafeHdc ( ) ;
}
extern " C " __declspec ( dllexport )
void EnableRedraw ( CSigmaView * pView , bool enable )
{
pView - > m_pDoc - > EnableRedraw ( enable ) ;
}
extern " C " __declspec ( dllexport )
void SetHWND ( CSigmaView * pView , HWND hwnd )
{
pView - > SetHWND ( hwnd ) ;
}
extern " C " __declspec ( dllexport )
void Initialize ( CSigmaView * pView , HDC hdcMem , int left , int top , int right , int bottom )
{
SetViewDC ( pView , hdcMem , left , top , right , bottom ) ;
pView - > InitialView ( ) ;
}
extern " C " __declspec ( dllexport )
void GetMapRange ( CSigmaView * pView , double & left , double & top , double & right , double & bottom )
{
if ( pView - > m_pDoc - > m_pXy = = NULL )
{
return ;
}
NBase : : CRect8 rect = pView - > m_pDoc - > m_pXy - > m_range ;
left = rect . left ;
top = rect . top ;
right = rect . right ;
bottom = rect . bottom ;
}
extern " C " __declspec ( dllexport )
int GetElementCount ( CSigmaView * pView )
{
if ( pView - > m_pDoc - > m_pXy = = NULL ) return 0 ;
return pView - > m_pDoc - > m_pXy - > GetCount ( ) ;
}
extern " C " __declspec ( dllexport )
void GetScreenReal ( CSigmaView * pView , int leftS , int topS , int rightS , int bottomS ,
double & left , double & top , double & right , double & bottom )
{
CRect rcScreen ( leftS , topS , rightS , bottomS ) ;
NBase : : CRect8 rcScreenReal = pView - > m_pDoc - > m_xyDC . GetReal ( rcScreen ) ;
left = rcScreenReal . left ;
top = rcScreenReal . top ;
right = rcScreenReal . right ;
bottom = rcScreenReal . bottom ;
}
extern " C " __declspec ( dllexport )
void GetRealScreen ( CSigmaView * pView , double leftS , double topS , double rightS , double bottomS ,
int & left , int & top , int & right , int & bottom )
{
NBase : : CRect8 rcScreen ( leftS , topS , rightS , bottomS ) ;
CRect rcScreenReal = pView - > m_pDoc - > m_xyDC . GetScreen ( rcScreen ) ;
left = rcScreenReal . left ;
top = rcScreenReal . top ;
right = rcScreenReal . right ;
bottom = rcScreenReal . bottom ;
}
extern " C " __declspec ( dllexport )
double GetRealHeight ( CSigmaView * pView , int height )
{
return pView - > m_pDoc - > m_xyDC . GetRealHeight ( ( long ) height ) ; //һ <> е <EFBFBD> ʵ<EFBFBD> ʵ<EFBFBD> λ<EFBFBD> <CEBB>
}
extern " C " __declspec ( dllexport )
int GetScreenHeight ( CSigmaView * pView , double height )
{
return pView - > m_pDoc - > m_xyDC . GetScreenHeight ( height ) ; //һ <> е <EFBFBD> ʵ<EFBFBD> ʵ<EFBFBD> λ<EFBFBD> <CEBB>
}
extern " C " __declspec ( dllexport )
double GetRealWidth ( CSigmaView * pView , int width )
{
return pView - > m_pDoc - > m_xyDC . GetRealWidth ( ( long ) width ) ; //һ <> е <EFBFBD> ʵ<EFBFBD> ʵ<EFBFBD> λ<EFBFBD> <CEBB>
}
extern " C " __declspec ( dllexport )
int GetScreenWidth ( CSigmaView * pView , double width )
{
return pView - > m_pDoc - > m_xyDC . GetScreenWidth ( width ) ; //һ <> е <EFBFBD> ʵ<EFBFBD> ʵ<EFBFBD> λ<EFBFBD> <CEBB>
}
extern " C " __declspec ( dllexport )
int Sigma_WorldToScreen ( CSigmaView * pView , double wx , double wy , int * xOut , int * yOut )
{
* xOut = * yOut = 0 ;
if ( pView - > m_pDoc = = 0 )
return - 1 ;
CPoint pt = pView - > m_pDoc - > m_xyDC . GetScreen ( wx , wy ) ;
* xOut = pt . x ;
* yOut = pt . y ;
return 1 ;
}
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> :<3A> <> <EFBFBD> <EFBFBD> Ļ<EFBFBD> <C4BB> <EFBFBD> <EFBFBD> ת<EFBFBD> <D7AA> Ϊ<EFBFBD> <CEAA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
extern " C " __declspec ( dllexport )
int Sigma_ScreenToWorld ( CSigmaView * pView , int sx , int sy , double * wxOut , double * wyOut )
{
* wxOut = * wyOut = 0 ;
if ( pView - > m_pDoc = = 0 )
return - 1 ;
CPoint ptScreen ;
ptScreen . SetPoint ( sx , sy ) ;
NBase : : CPoint2D pt = pView - > m_pDoc - > m_xyDC . GetReal ( ptScreen ) ;
* wxOut = pt . x0 ;
* wyOut = pt . y0 ;
return 1 ;
}
extern " C " __declspec ( dllexport )
void GetDisplayRange ( CSigmaView * pView , double & left , double & top , double & right , double & bottom )
{
NBase : : CRect8 rect = pView - > m_pDoc - > m_pXy - > m_display ;
left = rect . left ;
top = rect . top ;
right = rect . right ;
bottom = rect . bottom ;
}
extern " C " __declspec ( dllexport )
int OffsetPix ( CSigmaView * pView , int offsetX , int offsetY )
{
double dX = pView - > m_pDoc - > m_xyDC . GetRealWidth ( ( long ) offsetX ) ;
double dY = pView - > m_pDoc - > m_xyDC . GetRealHeight ( ( long ) offsetY ) ;
pView - > m_pDoc - > m_xyDC . OffsetRect ( - dX , - dY ) ;
pView - > m_pDoc - > Modified ( ) ;
return 1 ;
}
extern " C " __declspec ( dllexport )
int SetCustomDPI ( CSigmaView * pView , double dpi )
{
pView - > m_pDoc - > m_xyDC . SetCustomDPI ( 1 , dpi ) ;
return 1 ;
}
extern " C " __declspec ( dllexport )
int GetXYScale ( CSigmaView * pView , double * xsOut , double * ysOut )
{
if ( pView = = 0 )
return - 1 ;
if ( pView - > m_pDoc = = 0 )
return - 1 ;
* xsOut = * ysOut = 0 ;
NBase : : CSize8 scale ;
pView - > m_pDoc - > GetDC ( ) . GetScale ( scale . cx , scale . cy ) ;
* xsOut = scale . cx ;
* ysOut = scale . cy ;
return 1 ;
}
extern " C " __declspec ( dllexport )
int SetXYScale ( CSigmaView * pView , double xs , double ys )
{
if ( pView = = 0 )
return - 1 ;
if ( pView - > m_pDoc = = 0 )
return - 1 ;
double xsOld = 0 ;
double ysOld = 0 ;
GetXYScale ( pView , & xsOld , & ysOld ) ;
if ( fabs ( xs - xsOld ) < 1e-8 & & fabs ( ys - ysOld ) < 1e-8 )
return 1 ;
pView - > m_pDoc - > GetDC ( ) . SetScale ( xs , ys ) ;
pView - > m_pDoc - > Modified ( ) ;
return 1 ;
}
extern " C " __declspec ( dllexport )
int GetXYUnit ( CSigmaView * pView , int * xUnitOut , int * yUnitOut )
{
if ( pView = = 0 )
return - 1 ;
if ( pView - > m_pDoc = = 0 )
return - 1 ;
* xUnitOut = * yUnitOut = 0 ;
CSize size = pView - > m_pDoc - > GetDraw ( ) - > GetUnit ( ) ;
* xUnitOut = size . cx ;
* yUnitOut = size . cy ;
return 1 ;
}
extern " C " __declspec ( dllexport )
int SetXYUnit ( CSigmaView * pView , int xUnit , int yUnit )
{
if ( pView = = 0 )
return - 1 ;
if ( pView - > m_pDoc = = 0 )
return - 1 ;
pView - > m_pDoc - > GetDraw ( ) - > SetUnit ( xUnit , yUnit ) ;
pView - > m_pDoc - > Modified ( ) ;
return 1 ;
}
extern " C " __declspec ( dllexport )
BOOL GetPointsZRange ( CSigmaView * pView , double & zMin , double & zMax )
{
return pView - > GetPointsZRange ( zMin , zMax ) ;
}
extern " C " __declspec ( dllexport )
BOOL SetPointsColor ( CSigmaView * pView , LPCTSTR colorItemsData , double dWidth , double dHeight )
{
return pView - > SetPointsColor ( colorItemsData , dWidth , dHeight ) ;
}
extern " C " __declspec ( dllexport )
void SetGridStep ( CSigmaView * pView , double stepX , double stepY )
{
if ( pView = = nullptr )
{
return ;
}
pView - > GridStepX = stepX ;
pView - > GridStepY = stepY ;
}
extern " C " __declspec ( dllexport )
void GetGridStep ( CSigmaView * pView , double & stepX , double & stepY )
{
if ( pView = = nullptr )
{
return ;
}
stepX = pView - > GridStepX ;
stepY = pView - > GridStepY ;
}
extern " C " __declspec ( dllexport )
int XyGetElementType ( CSigmaView * pView , POSITION pos )
{
if ( pView = = nullptr )
{
return - 1 ;
}
return pView - > m_pDoc - > m_pXy - > GetElementType ( pos ) ;
}
extern " C " __declspec ( dllexport )
int TestLayersLength ( CSigmaView * pView )
{
if ( pView = = NULL )
return 0 ;
if ( pView - > m_pDoc = = NULL )
return 0 ;
CString strLayers ;
CXy * pxy = pView - > m_pDoc - > m_pXy ;
if ( pxy = = NULL )
{
return 0 ;
}
CLayer * pLayerCurrent ;
strLayers = _T ( " " ) ;
POSITION pos , posLayer ;
CLayerList * pLayer ;
CClassList * pClass = pxy - > GetClassList ( ) ;
pos = pClass - > GetHeadPosition ( ) ;
while ( pos )
{
pLayer = pClass - > GetNext ( pos ) ;
posLayer = pLayer - > GetHeadPosition ( ) ;
while ( posLayer )
{
pLayerCurrent = pLayer - > GetNext ( posLayer ) ;
strLayers . AppendFormat ( " %d|%s \r \n " , pLayerCurrent - > GetState ( ) , pLayerCurrent - > GetPathName ( ) ) ;
}
}
pView - > m_pDoc - > InsertParameterPair ( CString ( " Layers " ) , strLayers ) ;
return strLayers . GetLength ( ) ;
}
extern " C " __declspec ( dllexport )
BOOL XyGetLayers ( CXy * pxy , BYTE * & destBuffer , int & destLen , BOOL withStatus )
{
if ( pxy = = NULL )
{
return 0 ;
}
CLayer * pLayerCurrent ;
CString strLayers = _T ( " " ) ;
POSITION pos , posLayer ;
CLayerList * pLayer ;
CClassList * pClass = pxy - > GetClassList ( ) ;
pos = pClass - > GetHeadPosition ( ) ;
if ( withStatus )
{
while ( pos )
{
pLayer = pClass - > GetNext ( pos ) ;
posLayer = pLayer - > GetHeadPosition ( ) ;
while ( posLayer )
{
pLayerCurrent = pLayer - > GetNext ( posLayer ) ;
strLayers . AppendFormat ( " %d|%s \r \n " , pLayerCurrent - > GetState ( ) , pLayerCurrent - > GetPathName ( ) ) ;
}
}
}
else
{
while ( pos )
{
pLayer = pClass - > GetNext ( pos ) ;
posLayer = pLayer - > GetHeadPosition ( ) ;
while ( posLayer )
{
pLayerCurrent = pLayer - > GetNext ( posLayer ) ;
strLayers . AppendFormat ( " %s \r \n " , pLayerCurrent - > GetPathName ( ) ) ;
}
}
}
destLen = strLayers . GetLength ( ) ;
CMemFile mf ( destLen ) ;
mf . Write ( strLayers , destLen ) ;
// memcpy(destBuffer, strLayers.GetBuffer(0), destLen);
destBuffer = mf . Detach ( ) ;
return TRUE ;
}
extern " C " __declspec ( dllexport )
BOOL GetLayers ( CSigmaView * pView , BYTE * & destBuffer , int & destLen , BOOL withStatus )
{
if ( pView = = NULL ) return 0 ;
if ( pView - > m_pDoc = = NULL ) return 0 ;
CString strLayers ;
CXy * pxy = pView - > m_pDoc - > m_pXy ;
if ( pxy = = NULL )
{
return 0 ;
}
CLayer * pLayerCurrent ;
strLayers = _T ( " " ) ;
POSITION pos , posLayer ;
CLayerList * pLayer ;
CClassList * pClass = pxy - > GetClassList ( ) ;
pos = pClass - > GetHeadPosition ( ) ;
if ( withStatus )
{
while ( pos )
{
pLayer = pClass - > GetNext ( pos ) ;
posLayer = pLayer - > GetHeadPosition ( ) ;
while ( posLayer )
{
CString name = pLayer - > GetPathName ( posLayer ) ;
pLayerCurrent = pLayer - > GetNext ( posLayer ) ;
strLayers . AppendFormat ( " %d|%s \r \n " , pLayerCurrent - > GetState ( ) , pLayerCurrent - > GetPathName ( ) ) ;
}
}
}
else
{
while ( pos )
{
pLayer = pClass - > GetNext ( pos ) ;
posLayer = pLayer - > GetHeadPosition ( ) ;
while ( posLayer )
{
pLayerCurrent = pLayer - > GetNext ( posLayer ) ;
strLayers . AppendFormat ( " %s \r \n " , pLayerCurrent - > GetPathName ( ) ) ;
}
}
}
destLen = strLayers . GetLength ( ) ;
CMemFile mf ( destLen ) ;
mf . Write ( strLayers , destLen ) ;
// memcpy(destBuffer, strLayers.GetBuffer(0), destLen);
destBuffer = mf . Detach ( ) ;
return TRUE ;
}
extern " C " __declspec ( dllexport )
int GetCurrentLayer ( CSigmaView * pView , BYTE * layerName )
{
CXy * pxy = pView - > m_pDoc - > m_pXy ;
CLayer * pLayer = pxy - > GetCurrentLayer ( ) ;
if ( pLayer = = NULL )
{
//layerName[0] = '\0';
return 0 ;
}
else
{
// layerName = (LPCTSTR)(pLayer->GetName());
CString strName = pLayer - > GetName ( ) ;
int nLen = strName . GetLength ( ) ;
memcpy ( layerName , strName . GetBuffer ( 0 ) , nLen ) ;
return nLen ;
}
}
extern " C " __declspec ( dllexport )
void SetCurrentLayer ( CSigmaView * pView , LPCTSTR layerName )
{
if ( pView = = NULL )
{
return ;
}
CXy * pxy = pView - > m_pDoc - > m_pXy ;
pxy - > SetCurrentLayer ( layerName ) ;
}
extern " C " __declspec ( dllexport )
void SetLayerState ( CSigmaView * pView , LPCTSTR layerName , int status )
{
if ( pView = = NULL )
{
return ;
}
CXy * pxy = pView - > m_pDoc - > m_pXy ;
if ( pxy = = NULL )
{
return ;
}
CLayer * pLayer = pxy - > FindAddLayer ( layerName ) ; //pxy<78> <79> <EFBFBD> <EFBFBD> ΪNULL<4C> <4C> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( pLayer = = NULL ) return ;
pLayer - > SetState ( status ) ;
}
extern " C " __declspec ( dllexport )
int GetLayerState ( CSigmaView * pView , LPCTSTR layerName )
{
if ( pView = = NULL )
{
return - 1 ;
}
CXy * pxy = pView - > m_pDoc - > m_pXy ;
if ( pxy = = NULL )
{
return - 1 ;
}
CLayer * pLayer = pxy - > FindAddLayer ( layerName ) ; //pxy<78> <79> <EFBFBD> <EFBFBD> ΪNULL<4C> <4C> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( pLayer = = NULL ) return - 1 ;
return pLayer - > GetState ( ) ;
}
extern " C " __declspec ( dllexport )
void FindAddLayer ( CSigmaView * pView , LPCTSTR layerName , bool doActive )
{
CXy * pxy = pView - > m_pDoc - > m_pXy ;
CLayer * pLayer = pxy - > FindLayer ( layerName ) ;
if ( pLayer ! = nullptr )
{
if ( doActive = = TRUE )
{
pxy - > SetCurrentLayer ( pLayer ) ;
}
return ;
}
CString strCurrentLayerName = pxy - > GetCurrentLayer ( ) - > GetPathName ( ) ;
pLayer = pxy - > FindAddLayer ( layerName ) ;
if ( pLayer = = NULL ) return ;
if ( doActive = = TRUE )
{
pxy - > SetCurrentLayer ( pLayer ) ;
}
pView - > m_pDoc - > SetActionItem ( new CActionLayerAddItem ( pView - > m_pDoc , pLayer , strCurrentLayerName ) ) ;
}
extern " C " __declspec ( dllexport )
void XyDeleteLayer ( CXy * pxy , const wchar_t * * layers , int count , bool bIncludeSublayer = false )
{
//pxy->RemoveLayer(layers, bIncludeSublayer);
for ( int i = 0 ; i < count ; i + + )
{
CString name ( layers [ i ] ) ;
pxy - > RemoveLayer ( name , bIncludeSublayer ) ;
}
}
/**
* ɾ <EFBFBD> <EFBFBD> ͼ Ԫ
*
* \ param pView <EFBFBD> <EFBFBD> ͼ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
* \ param layers ͼ <EFBFBD> <EFBFBD> · <EFBFBD> <EFBFBD>
* \ param length ͼ <EFBFBD> <EFBFBD> · <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
* \ param bIncludeSublayer <EFBFBD> Ƿ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ӳ <EFBFBD> һ <EFBFBD> <EFBFBD> ɾ <EFBFBD> <EFBFBD>
*/
extern " C " __declspec ( dllexport )
void DeleteLayer ( CSigmaView * pView , wchar_t * * layers , int length , bool bIncludeSublayer = FALSE )
{
CXy * pxy = pView - > m_pDoc - > m_pXy ;
NBase : : CPositionList elemList ;
CPtrList layerList ;
if ( bIncludeSublayer = = FALSE )
{
for ( int i = 0 ; i < length ; i + + )
{
CString name ;
name = layers [ i ] ;
CLayer * pLayer = pxy - > FindLayer ( name , bIncludeSublayer ) ;
if ( pLayer )
{
layerList . AddTail ( pLayer ) ;
pxy - > GetElement ( pLayer - > GetPathName ( ) , elemList , bIncludeSublayer ) ;
}
}
}
else
{
for ( int i = 0 ; i < length ; i + + )
{
CString name ;
name = layers [ i ] ;
pxy - > FindLayers ( name , layerList , bIncludeSublayer ) ; // bIncludeSublayer
}
POSITION pos = layerList . GetHeadPosition ( ) ;
while ( pos ! = nullptr )
{
CLayer * pLayer = ( CLayer * ) layerList . GetNext ( pos ) ;
pxy - > GetElement ( pLayer - > GetPathName ( ) , elemList , TRUE ) ;
}
}
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ΪʲôҪ<C3B4> <D2AA> <EFBFBD> <EFBFBD> !!!
// <20> <> <EFBFBD> <EFBFBD> 1<EFBFBD> <31> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ӳ㣬<D3B2> <E3A3AC> <EFBFBD> 洫<EFBFBD> ݽ<EFBFBD> <DDBD> <EFBFBD> <EFBFBD> <EFBFBD> ·<EFBFBD> <C2B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> п<EFBFBD> <D0BF> <EFBFBD> <EFBFBD> ظ<EFBFBD>
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ܲ<EFBFBD> <DCB2> <EFBFBD> ͨ<EFBFBD> <CDA8> <EFBFBD> ַ<EFBFBD> <D6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> أ<EFBFBD> <D8A3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ǣ<EFBFBD> <C7A3> <EFBFBD> <EFBFBD> ԣ<EFBFBD> <D4A3> <EFBFBD> <EFBFBD> Ǻ<EFBFBD> <C7BA> 鷳<EFBFBD> <E9B7B3> <EFBFBD> <EFBFBD> <EFBFBD> ÿ<EFBFBD> <C3BF> <EFBFBD> <EFBFBD> ַ<EFBFBD> <D6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ߴ <EFBFBD> <DFB4> ո <EFBFBD> <D5B8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ÿ<EFBFBD> <C3BF> Ǵ<EFBFBD> <C7B4> <EFBFBD> class <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
// <20> <> <EFBFBD> <EFBFBD> 2<EFBFBD> <32> <EFBFBD> <EFBFBD> <EFBFBD> Ӳ<EFBFBD> һ <EFBFBD> <D2BB> ɾ<EFBFBD> <C9BE> <EFBFBD> <EFBFBD> <EFBFBD> п<EFBFBD> <D0BF> ܴ<EFBFBD> <DCB4> ݽ<EFBFBD> <DDBD> <EFBFBD> <EFBFBD> <EFBFBD> ͼ<EFBFBD> <CDBC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ӳ<EFBFBD> <D3B2> Ĺ<EFBFBD> ϵ
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> أ<EFBFBD> <D8A3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ĵ<EFBFBD> <C4B4> <EFBFBD> CActionLayerDeleteItem <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ظ<EFBFBD> <D8B8> 洢<EFBFBD> <E6B4A2> Ȼ<EFBFBD> <C8BB> delete ʱ<> <CAB1> <EFBFBD> <EFBFBD> double free<65> <65> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ³<EFBFBD> <C2B3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//
CPtrList newLayerList ;
NBase : : CPositionList newElemList ;
UniquePtrList ( layerList , newLayerList ) ;
UniquePositionList ( elemList , newElemList ) ;
CSigmaDoc * pDoc = pView - > m_pDoc ;
if ( pDoc ! = NULL )
{
pDoc - > SetActionItem ( new CActionLayerDeleteItem ( pDoc , newElemList , newLayerList ) ) ;
// pDoc->Modified();
}
// ע<> ⣡<EFBFBD> <E2A3A1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ǰͼ<C7B0> 㱻ɾ<E3B1BB> <C9BE> <EFBFBD> ˣ<EFBFBD> <CBA3> <EFBFBD> Ҫ<EFBFBD> <D2AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> õ<EFBFBD> ǰͼ<C7B0> 㣬<EFBFBD> <E3A3AC> ˵<EFBFBD> <CBB5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 벻Ӧ<EBB2BB> <D3A6> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ɣ <EFBFBD> Ӧ<EFBFBD> <D3A6> <EFBFBD> <EFBFBD> CXy <20> <> <EFBFBD> <EFBFBD>
CLayer * pLayer = pxy - > GetCurrentLayer ( ) ;
if ( newLayerList . Find ( pLayer ) )
{
if ( pxy - > GetClassList ( ) - > GetLayerCount ( ) = = 0 )
{
if ( pxy - > GetClassList ( ) - > GetCount ( ) = = 0 )
pxy - > InitLayerClass ( ) ;
else
pxy - > GetClassList ( ) - > GetHead ( ) - > FindAdd ( " 0 " ) ;
}
pxy - > SetCurrentLayer ( pxy - > GetClassList ( ) - > GetHead ( ) - > GetHead ( ) ) ;
}
}
//extern "C" __declspec(dllexport)
//bool ClearAll(CSigmaView* pView, bool needUndo) {
// CXy* pxy = pView->m_pDoc->m_pXy;
//
// POSITION posClass, posLayer;
// CLayerList* pLayer;
// CClassList* pClass = pxy->GetClassList();
// posClass = pClass->GetHeadPosition();
//
// vector<CLayer*> layers;
// //wchar_t** layerNames = new wchar_t
// while (posClass)
// {
// pLayer = pClass->GetNext(posClass);
// posLayer = pLayer->GetHeadPosition();
// while (posLayer)
// {
// //CString name = pLayer->GetPathName(posLayer);
// CLayer* pLayerCurrent = pLayer->GetNext(posLayer);
// layers.push_back(pLayerCurrent);
// //CString strLayerName = pLayerCurrent->GetPathName();
// }
// }
// if (needUndo)
// { // <20> <> Ҫ<EFBFBD> <D2AA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> г <EFBFBD> <D0B3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
// int nLayerCount = layers.size();
// wchar_t** strArray = new wchar_t*[nLayerCount];
//
// // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ڴ沢<DAB4> <E6B2A2> <EFBFBD> <EFBFBD> <EFBFBD> ַ<EFBFBD> <D6B7> <EFBFBD>
// for (int i = 0; i < nLayerCount; ++i) {
// CString strLayerName = layers[i]->GetPathName();
// int len = MultiByteToWideChar(CP_ACP, 0, strLayerName, -1, NULL, 0); // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ<EFBFBD> <D6B7> <EFBFBD> <EFBFBD> <EFBFBD>
// strArray[i] = new wchar_t[len];
// MultiByteToWideChar(CP_ACP, 0, strLayerName, -1, strArray[i], len); // <20> <> <EFBFBD> <EFBFBD> ת<EFBFBD> <D7AA>
// }
// DeleteLayer(pView, strArray, nLayerCount, true);
// return true;
// }
// else {
// pxy->RemoveAllData();
// pxy->RemoveAllLayer();
// pxy->RemoveAllLegend();
// }
// return true;
//}
extern " C " __declspec ( dllexport )
void LayerRename ( CSigmaView * pView , LPCTSTR oldName , LPCTSTR newName )
{
CXy * pxy = pView - > m_pDoc - > m_pXy ;
//<2F> IJ<DEB8> <C4B2> <EFBFBD>
if ( pxy - > GetClassList ( ) - > ReplaceLayer ( oldName , newName ) > 0 )
{
pView - > m_pDoc - > SetActionItem ( new CActionLayerRenameItem ( pView - > m_pDoc
, oldName , newName ) ) ;
}
}
extern " C " __declspec ( dllexport )
bool DeleteLayerEmpty ( CSigmaView * pView )
{
CXy * pxy = pView - > m_pDoc - > m_pXy ;
CPtrList layerList ;
int rt = pxy - > ClearLayerNoneData ( & layerList ) ;
if ( layerList . GetCount ( ) > 0 )
{
// pDoc->SetModifiedFlag();
NBase : : CPositionList list ;
pView - > m_pDoc - > SetActionItem ( new CActionLayerDeleteItem ( pView - > m_pDoc , list , layerList ) ) ;
}
return rt ;
}
extern " C " __declspec ( dllexport )
BOOL XyGetLayerStyleData ( CXy * pxy , LPCTSTR layerName , BYTE * & buffCurve , int & lenCurve , BYTE * & buffPoint , int & lenPoint )
{
CLayer * pLayer = pxy - > FindAddLayer ( layerName ) ;
if ( pLayer = = NULL ) return FALSE ;
//BYTE* dataCurve;
if ( pLayer - > HowToViewCurve = = NULL )
{
lenCurve = 0 ;
}
else
{
pLayer - > HowToViewCurve - > WriteMemory ( buffCurve , lenCurve , 3 ) ;
}
if ( pLayer - > HowToViewPoint = = NULL )
{
lenPoint = 0 ;
}
else
{
pLayer - > HowToViewPoint - > WriteMemory ( buffPoint , lenPoint , 3 ) ;
}
return TRUE ;
}
extern " C " __declspec ( dllexport )
BOOL GetLayerStyleData ( CSigmaView * pView , LPCTSTR layerName , BYTE * & buffCurve , int & lenCurve , BYTE * & buffPoint , int & lenPoint )
{
CXy * pxy = pView - > m_pDoc - > m_pXy ;
CLayer * pLayer = pxy - > FindAddLayer ( layerName ) ;
if ( pLayer = = NULL ) return FALSE ;
//BYTE* dataCurve;
if ( pLayer - > HowToViewCurve = = NULL )
{
lenCurve = 0 ;
}
else
{
pLayer - > HowToViewCurve - > WriteMemory ( buffCurve , lenCurve , 3 ) ;
}
if ( pLayer - > HowToViewPoint = = NULL )
{
lenPoint = 0 ;
}
else
{
pLayer - > HowToViewPoint - > WriteMemory ( buffPoint , lenPoint , 3 ) ;
}
return TRUE ;
}
extern " C " __declspec ( dllexport )
BOOL RemoveCurveStyle ( CSigmaView * pView , LPCTSTR layerName , int index )
{
CXy * pxy = pView - > m_pDoc - > m_pXy ;
CLayer * pLayer = pxy - > FindAddLayer ( layerName ) ;
if ( pLayer = = NULL ) return FALSE ;
if ( pLayer - > HowToViewCurve = = NULL )
{
return FALSE ;
}
//Ϊ<> <CEAA> <EFBFBD> <EFBFBD> <EFBFBD> ε<EFBFBD> Redo/Undo
CActionEmbellishItem * pActionItem = new CActionEmbellishItem ( pView - > m_pDoc , ActionTypeLayerEmbellishCurveDelete , pLayer ) ;
pActionItem - > SetOldHowToView ( pLayer ) ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
CHowToViewCurve * pHW = pLayer - > HowToViewCurve ;
pHW - > RemoveAt ( index ) ;
if ( pHW - > GetCount ( ) = = 0 )
{
delete pLayer - > HowToViewCurve ;
pLayer - > HowToViewCurve = NULL ;
}
pActionItem - > SetNewHowToView ( pLayer ) ;
pView - > m_pDoc - > SetActionItem ( pActionItem ) ;
return TRUE ;
}
extern " C " __declspec ( dllexport )
BOOL RemovePointStyle ( CSigmaView * pView , LPCTSTR layerName )
{
CXy * pxy = pView - > m_pDoc - > m_pXy ;
CLayer * pLayer = pxy - > FindAddLayer ( layerName ) ;
if ( pLayer = = NULL ) return FALSE ;
if ( pLayer - > HowToViewPoint = = NULL )
{
return FALSE ;
}
//Ϊ<> <CEAA> <EFBFBD> <EFBFBD> <EFBFBD> ε<EFBFBD> Redo/Undo
CActionEmbellishItem * pActionItem = new CActionEmbellishItem ( pView - > m_pDoc , ActionTypeLayerEmbellishPointDelete , pLayer ) ;
pActionItem - > SetOldHowToView ( pLayer ) ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
delete pLayer - > HowToViewPoint ;
pLayer - > HowToViewPoint = nullptr ;
pActionItem - > SetNewHowToView ( pLayer ) ;
pView - > m_pDoc - > SetActionItem ( pActionItem ) ;
return TRUE ;
}
extern " C " __declspec ( dllexport )
BOOL XySetLayerHowtoViewPoint ( CXy * pXy , LPCTSTR layerName , BYTE * buffCurve , int bufLen , bool replace )
{
CLayer * pLayer = pXy - > FindAddLayer ( layerName ) ;
if ( pLayer = = nullptr ) return FALSE ;
if ( replace = = FALSE )
{
if ( pLayer - > HowToViewPoint ! = nullptr )
{
return TRUE ;
}
}
if ( pLayer - > HowToViewPoint = = NULL )
{
pLayer - > HowToViewPoint = new CHowToViewPoint ( ) ;
}
CHowToViewPoint htp ;
BOOL bSuccess = htp . ReadMemory ( buffCurve , bufLen , 3 ) ;
if ( bSuccess = = FALSE )
{
return FALSE ;
}
* ( pLayer - > HowToViewPoint ) = htp ;
return TRUE ;
}
extern " C " __declspec ( dllexport )
BOOL SetLayerHowtoViewPoint ( CSigmaView * pView , LPCTSTR layerName , BYTE * buffCurve , int bufLen , bool replace )
{
CXy * pxy = pView - > m_pDoc - > m_pXy ;
CLayer * pLayer = pxy - > FindAddLayer ( layerName ) ;
if ( pLayer = = NULL ) return FALSE ;
if ( pLayer - > HowToViewPoint ! = nullptr & & replace = = false )
{
return false ;
}
CHowToViewPoint htp ;
BOOL bSuccess = htp . ReadMemory ( buffCurve , bufLen , 3 ) ;
if ( bSuccess = = FALSE )
{
return FALSE ;
}
//Ϊ<> <CEAA> <EFBFBD> <EFBFBD> <EFBFBD> ε<EFBFBD> Redo/Undo
CActionEmbellishItem * pActionItem = new CActionEmbellishItem ( pView - > m_pDoc , ActionTypeLayerEmbellishPointAdd , pLayer ) ;
pActionItem - > SetOldHowToView ( pLayer ) ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( pLayer - > HowToViewPoint = = NULL )
{
pLayer - > HowToViewPoint = new CHowToViewPoint ( ) ;
}
* ( pLayer - > HowToViewPoint ) = htp ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ϲ <EFBFBD> <CFB2> <EFBFBD> <EFBFBD> ò<EFBFBD> <C3B2> <EFBFBD>
CPtrList * plist = pxy - > GetValueList ( ) ;
POSITION pos ;
COne * pOne ;
pos = plist - > GetHeadPosition ( ) ;
while ( pos )
{
pOne = ( COne * ) plist - > GetNext ( pos ) ;
if ( pOne - > GetType ( ) ! = DOUBLEFOX_BLOCK ) continue ;
CInsertBlock * pBlock = ( ( CInsertBlock * ) pOne - > value ) ;
CXy * pXyBlock = ( CXy * ) pBlock - > GetXy ( ) ;
CLayer * pLayerBlock = pXyBlock - > FindLayer ( layerName ) ;
if ( pLayerBlock ! = nullptr )
{
CHowToViewPoint * hvpBlock = NULL ;
if ( pLayer - > HowToViewPoint )
{
hvpBlock = new CHowToViewPoint ;
* hvpBlock = * ( pLayer - > HowToViewPoint ) ;
}
pLayerBlock - > SetHowToViewPoint ( hvpBlock ) ;
}
}
pActionItem - > SetNewHowToView ( pLayer ) ;
pView - > m_pDoc - > SetActionItem ( pActionItem ) ;
return TRUE ;
}
extern " C " __declspec ( dllexport )
BOOL CreateLayerPointStyle ( CSigmaView * pView , LPCTSTR layerName , BYTE * buffPoint , int bufLen )
{
return SetLayerHowtoViewPoint ( pView , layerName , buffPoint , bufLen , true ) ;
}
extern " C " __declspec ( dllexport )
bool XyCreateLayerCurveStyle ( CXy * pxy , LPCTSTR layerName , int type , BYTE * buffCurve , int bufLen )
{
CLayer * pLayer = pxy - > FindAddLayer ( layerName ) ;
if ( pLayer = = NULL ) return FALSE ;
////Ϊ<> <CEAA> <EFBFBD> <EFBFBD> <EFBFBD> ε<EFBFBD> Redo/Undo
//CActionEmbellishItem *pActionItem = new CActionEmbellishItem(pView->m_pDoc, ActionTypeLayerEmbellishCurveAdd, pLayer);
//pActionItem->SetOldHowToView(pLayer); // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( pLayer - > HowToViewCurve = = NULL )
{
pLayer - > HowToViewCurve = new CHowToViewCurve ( ) ;
}
CHowToViewCurve * pHWCOld = pLayer - > HowToViewCurve ;
pHWCOld - > Empty ( ) ;
switch ( type )
{
case CurveArrowHead :
case CurveArrowTail :
pHWCOld - > Add ( new CCurveArrow ( ) ) ;
break ;
case CurveProperties :
pHWCOld - > Add ( new CCurveProperties ( ) ) ;
break ;
case CurveLocate :
pHWCOld - > Add ( new CCurveLocate ( ) ) ;
break ;
case CurveScale :
pHWCOld - > Add ( new CCurveScale ( ) ) ;
break ;
//case CurveName:
case CurveNameHead :
case CurveNameTail :
pHWCOld - > Add ( new CCurveName ( ) ) ;
break ;
case CurveTwoMark :
pHWCOld - > Add ( new CCurveTwoMark ( ) ) ;
break ;
case CurveRgn :
pHWCOld - > Add ( new CCurveRgn ( ) ) ;
break ;
case CurveInName :
pHWCOld - > Add ( new CCurveInName ( ) ) ;
break ;
case CurveInNameAny :
pHWCOld - > Add ( new CCurveInNameAny ( ) ) ;
break ;
case CurveEffect :
pHWCOld - > Add ( new CCurveEffect ( ) ) ;
break ;
case CurveCenterName :
pHWCOld - > Add ( new CCurveCenterName ( ) ) ;
break ;
}
bool bSuccess = pHWCOld - > SetAt ( pHWCOld - > GetCount ( ) - 1 , buffCurve , bufLen , 3 ) ! = NULL ;
return bSuccess ;
}
extern " C " __declspec ( dllexport )
bool CreateLayerCurveStyle ( CSigmaView * pView , LPCTSTR layerName , int type , BYTE * buffCurve , int bufLen )
{
CXy * pxy = pView - > m_pDoc - > m_pXy ;
CLayer * pLayer = pxy - > FindAddLayer ( layerName ) ;
if ( pLayer = = NULL ) return FALSE ;
//Ϊ<> <CEAA> <EFBFBD> <EFBFBD> <EFBFBD> ε<EFBFBD> Redo/Undo
CActionEmbellishItem * pActionItem = new CActionEmbellishItem ( pView - > m_pDoc , ActionTypeLayerEmbellishCurveAdd , pLayer ) ;
pActionItem - > SetOldHowToView ( pLayer ) ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
XyCreateLayerCurveStyle ( pxy , layerName , type , buffCurve , bufLen ) ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ϲ <EFBFBD> <CFB2> <EFBFBD> <EFBFBD> ò<EFBFBD> <C3B2> <EFBFBD>
CPtrList * plist = pxy - > GetValueList ( ) ;
POSITION pos ;
COne * pOne ;
pos = plist - > GetHeadPosition ( ) ;
while ( pos )
{
pOne = ( COne * ) plist - > GetNext ( pos ) ;
if ( pOne - > GetType ( ) ! = DOUBLEFOX_BLOCK ) continue ;
CInsertBlock * pBlock = ( ( CInsertBlock * ) pOne - > value ) ;
CXy * pXyBlock = ( CXy * ) pBlock - > GetXy ( ) ;
CLayer * pLayerBlock = pXyBlock - > FindLayer ( layerName ) ;
if ( pLayerBlock ! = nullptr )
{
CHowToViewCurve * hvcBlock = nullptr ;
if ( pLayer - > HowToViewCurve )
{
hvcBlock = new CHowToViewCurve ;
* hvcBlock = * ( pLayer - > HowToViewCurve ) ;
}
pLayerBlock - > SetHowToViewCurve ( hvcBlock ) ;
}
}
pActionItem - > SetNewHowToView ( pLayer ) ;
pView - > m_pDoc - > SetActionItem ( pActionItem ) ;
return true ;
}
extern " C " __declspec ( dllexport )
bool AddLayerCurveStyle ( CSigmaView * pView , LPCTSTR layerName , int type , BYTE * buffCurve , int bufLen )
{
CXy * pxy = pView - > m_pDoc - > m_pXy ;
CLayer * pLayer = pxy - > FindAddLayer ( layerName ) ;
if ( pLayer = = NULL ) return FALSE ;
if ( pLayer - > HowToViewCurve = = NULL )
{
return CreateLayerCurveStyle ( pView , layerName , type , buffCurve , bufLen ) ;
}
//Ϊ<> <CEAA> <EFBFBD> <EFBFBD> <EFBFBD> ε<EFBFBD> Redo/Undo
CActionEmbellishItem * pActionItem = new CActionEmbellishItem ( pView - > m_pDoc , ActionTypeLayerEmbellishCurveAdd , pLayer ) ;
pActionItem - > SetOldHowToView ( pLayer ) ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
CHowToViewCurve * pHWCOld = pLayer - > HowToViewCurve ;
switch ( type )
{
case CurveArrowHead :
case CurveArrowTail :
pHWCOld - > Add ( new CCurveArrow ( type ) ) ;
break ;
case CurveProperties :
pHWCOld - > Add ( new CCurveProperties ( ) ) ;
break ;
case CurveLocate :
pHWCOld - > Add ( new CCurveLocate ( ) ) ;
break ;
case CurveScale :
pHWCOld - > Add ( new CCurveScale ( ) ) ;
break ;
case CurveNameHead :
case CurveNameTail :
pHWCOld - > Add ( new CCurveName ( ) ) ;
break ;
case CurveTwoMark :
pHWCOld - > Add ( new CCurveTwoMark ( ) ) ;
break ;
case CurveRgn :
pHWCOld - > Add ( new CCurveRgn ( ) ) ;
break ;
case CurveInName :
pHWCOld - > Add ( new CCurveInName ( ) ) ;
break ;
case CurveInNameAny :
pHWCOld - > Add ( new CCurveInNameAny ( ) ) ;
break ;
case CurveEffect :
pHWCOld - > Add ( new CCurveEffect ( ) ) ;
break ;
case CurveCenterName :
pHWCOld - > Add ( new CCurveCenterName ( ) ) ;
break ;
}
bool bSuccess = pHWCOld - > SetAt ( pHWCOld - > GetCount ( ) - 1 , buffCurve , bufLen , 3 ) ! = NULL ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ϲ <EFBFBD> <CFB2> <EFBFBD> <EFBFBD> ò<EFBFBD> <C3B2> <EFBFBD>
CPtrList * plist = pxy - > GetValueList ( ) ;
POSITION pos ;
COne * pOne ;
pos = plist - > GetHeadPosition ( ) ;
while ( pos )
{
pOne = ( COne * ) plist - > GetNext ( pos ) ;
if ( pOne - > GetType ( ) ! = DOUBLEFOX_BLOCK ) continue ;
CInsertBlock * pBlock = ( ( CInsertBlock * ) pOne - > value ) ;
CXy * pXyBlock = ( CXy * ) pBlock - > GetXy ( ) ;
CLayer * pLayerBlock = pXyBlock - > FindLayer ( layerName ) ;
if ( pLayerBlock ! = nullptr )
{
CHowToViewCurve * hvcBlock = nullptr ;
if ( pHWCOld )
{
hvcBlock = new CHowToViewCurve ;
* hvcBlock = * ( pHWCOld ) ;
}
pLayerBlock - > SetHowToViewCurve ( hvcBlock ) ;
}
}
pActionItem - > SetNewHowToView ( pLayer ) ;
pView - > m_pDoc - > SetActionItem ( pActionItem ) ;
return bSuccess ;
}
extern " C " __declspec ( dllexport )
BOOL SetLayerHowtoViewCurve ( CSigmaView * pView , LPCTSTR layerName , BYTE * buffCurve , int bufLen , int index )
{
CXy * pxy = pView - > m_pDoc - > m_pXy ;
CLayer * pLayer = pxy - > FindAddLayer ( layerName ) ;
if ( pLayer = = NULL ) return FALSE ;
CHowToViewCurve * pHWCOld = pLayer - > HowToViewCurve ;
if ( pHWCOld = = NULL )
{
return FALSE ;
}
if ( pHWCOld - > GetCount ( ) < = index )
{
return FALSE ;
}
//Ϊ<> <CEAA> <EFBFBD> <EFBFBD> <EFBFBD> ε<EFBFBD> Redo/Undo
CActionEmbellishItem * pActionItem = new CActionEmbellishItem ( pView - > m_pDoc , ActionTypeLayerEmbellishCurveAdd , pLayer ) ;
pActionItem - > SetOldHowToView ( pLayer ) ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
pHWCOld - > SetAt ( index , buffCurve , bufLen , 3 ) ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ϲ <EFBFBD> <CFB2> <EFBFBD> <EFBFBD> ò<EFBFBD> <C3B2> <EFBFBD>
CPtrList * plist = pxy - > GetValueList ( ) ;
POSITION pos ;
COne * pOne ;
pos = plist - > GetHeadPosition ( ) ;
while ( pos )
{
pOne = ( COne * ) plist - > GetNext ( pos ) ;
if ( pOne - > GetType ( ) ! = DOUBLEFOX_BLOCK ) continue ;
CInsertBlock * pBlock = ( ( CInsertBlock * ) pOne - > value ) ;
CXy * pXyBlock = ( CXy * ) pBlock - > GetXy ( ) ;
CLayer * pLayerBlock = pXyBlock - > FindLayer ( layerName ) ;
if ( pLayerBlock ! = nullptr )
{
CHowToViewCurve * hvcBlock = nullptr ;
if ( pHWCOld )
{
hvcBlock = new CHowToViewCurve ;
* hvcBlock = * ( pHWCOld ) ;
}
pLayerBlock - > SetHowToViewCurve ( hvcBlock ) ;
}
}
pActionItem - > SetNewHowToView ( pLayer ) ;
pView - > m_pDoc - > SetActionItem ( pActionItem ) ;
return TRUE ;
}
extern " C " __declspec ( dllexport )
BOOL XySetLayerHowtoViewCurve ( CXy * pxy , LPCTSTR layerName , BYTE * buffCurve , int bufLen , int index )
{
CLayer * pLayer = pxy - > FindAddLayer ( layerName ) ;
if ( pLayer = = NULL ) return FALSE ;
CHowToViewCurve * pHWCOld = pLayer - > HowToViewCurve ;
if ( pHWCOld = = NULL )
{
return FALSE ;
}
if ( pHWCOld - > GetCount ( ) < = index )
{
return FALSE ;
}
pHWCOld - > SetAt ( index , buffCurve , bufLen , 3 ) ;
return TRUE ;
}
extern " C " __declspec ( dllexport )
BOOL SetLayerMoveUpCurveStyle ( CSigmaView * pView , LPCTSTR layerName , int nIndex )
{
CXy * pxy = pView - > m_pDoc - > m_pXy ;
CLayer * pLayer = pxy - > FindAddLayer ( layerName ) ;
if ( pLayer = = NULL ) return FALSE ;
if ( pLayer - > HowToViewCurve = = NULL )
{
return FALSE ;
}
//Ϊ<> <CEAA> <EFBFBD> <EFBFBD> <EFBFBD> ε<EFBFBD> Redo/Undo
CActionEmbellishItem * pActionItem = new CActionEmbellishItem ( pView - > m_pDoc , ActionTypeLayerEmbellishCurveMoveUp , pLayer ) ;
pActionItem - > SetOldHowToView ( pLayer ) ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
CHowToViewCurve * pHW = pLayer - > HowToViewCurve ;
BOOL bSuccess = pHW - > MoveUp ( nIndex ) ;
pActionItem - > SetNewHowToView ( pLayer ) ;
pView - > m_pDoc - > SetActionItem ( pActionItem ) ;
return bSuccess ;
}
extern " C " __declspec ( dllexport )
BOOL SetLayerMoveDownCurveStyle ( CSigmaView * pView , LPCTSTR layerName , int nIndex )
{
CXy * pxy = pView - > m_pDoc - > m_pXy ;
CLayer * pLayer = pxy - > FindAddLayer ( layerName ) ;
if ( pLayer = = NULL ) return FALSE ;
if ( pLayer - > HowToViewCurve = = NULL )
{
return FALSE ;
}
//Ϊ<> <CEAA> <EFBFBD> <EFBFBD> <EFBFBD> ε<EFBFBD> Redo/Undo
CActionEmbellishItem * pActionItem = new CActionEmbellishItem ( pView - > m_pDoc , ActionTypeLayerEmbellishCurveMoveDown , pLayer ) ;
pActionItem - > SetOldHowToView ( pLayer ) ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
CHowToViewCurve * pHW = pLayer - > HowToViewCurve ;
BOOL bSuccess = pHW - > MoveDown ( nIndex ) ;
pActionItem - > SetNewHowToView ( pLayer ) ;
pView - > m_pDoc - > SetActionItem ( pActionItem ) ;
return bSuccess ;
}
extern " C " __declspec ( dllexport )
BOOL ExportImageFile ( CSigmaView * pView , LPCTSTR outputFile , int width , int height , int bpp )
{
CSize size ( width , height ) ;
CItemExportFile item ( pView - > m_pDoc ) ;
return item . Export ( outputFile , size , bpp ) ;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
extern " C " __declspec ( dllexport )
void AddWell ( LPCTSTR wellName , double locationX , double locationY )
{
//if (pSectionDoc == nullptr)
//{
// pSectionDoc = new CSectionDoc();
//}
//pSectionDoc->AddWell(wellName, locationX, locationY);
}
extern " C " __declspec ( dllexport )
void SetWellStratiUnits ( LPCTSTR wellName , int count
, LPCTSTR * stratiNames , double * tops , double * bottoms , LPCTSTR * unitNames )
{
//pSectionDoc->SetWellStratiUnits(wellName, count, stratiNames, tops, bottoms, unitNames);
}
extern " C " __declspec ( dllexport )
int DrawBend ( CSigmaView * pView , LPCTSTR leftWell , LPCTSTR leftStrati , LPCTSTR rightWell , LPCTSTR rightStrati )
{
//CPointList lstPt;
//// <20> <EFBFBD> λ<EFBFBD> <CEBB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//CRect8 leftRect = pSectionDoc->GetStratiRect(leftWell, leftStrati);
//CRect8 rightRect = pSectionDoc->GetStratiRect(rightWell, rightStrati);
//dfPoint ptLeftTop; ptLeftTop.Create(leftRect.right, leftRect.top,0);
//dfPoint ptRightTop; ptRightTop.Create(rightRect.left, rightRect.top,0);
//dfPoint ptRightBottom; ptRightBottom.Create(rightRect.left, rightRect.bottom, 0);
//dfPoint ptLeftBottom; ptLeftBottom.Create(leftRect.right, leftRect.bottom, 0);
//lstPt.AddTail(ptLeftTop);
//lstPt.AddTail(ptRightTop);
//lstPt.AddTail(ptRightBottom);
//lstPt.AddTail(ptLeftBottom);
//CEntityBend* pBend = pSectionDoc->FindBend(leftWell, leftStrati, rightWell, rightStrati);
//if (pBend == nullptr)
//{
// pBend = new CEntityBend();
// pBend->SetName(leftWell, leftStrati, rightWell, rightStrati);
// pBend->SetData(lstPt);
// pSectionDoc->AddBend(pBend);
//}
//pBend->Draw(pView->m_pDC, RGB(205, 0, 0));
//
////CDrawBend* pDrawBend = new CDrawBend();
////pDrawBend->Draw(pView->m_pDC, lstPt, RGB(255, 0, 0));
return 0 ;
}
extern " C " __declspec ( dllexport )
void SetItem ( CSigmaView * pView , int itemType )
{
pView - > SetItem ( itemType ) ;
}
extern " C " __declspec ( dllexport )
int MouseSelect ( CSigmaView * pView , int mouseX , int mouseY )
{
//pSectionDoc->SelectBend(pView->m_pDC, mouseX, mouseY);
//GSD_Select(pView->m_pDoc, mouseX, mouseY);
return 0 ;
}
extern " C " __declspec ( dllexport )
bool DrawMem ( CSigmaView * pView )
{
pView - > OnDrawMem ( ) ;
return true ;
}
extern " C " __declspec ( dllexport )
bool DrawDC ( CSigmaView * pView )
{
return pView - > OnDrawDC ( ) ;
}
extern " C " __declspec ( dllexport )
BOOL OpenDocument ( CSigmaView * pView , LPCTSTR lpszFileName , BOOL bMergeFile )
{
return pView - > OpenFile ( lpszFileName , bMergeFile ) ;
}
extern " C " __declspec ( dllexport )
BOOL OpenXy ( CSigmaView * pView , CXy * pXy , BOOL bMergeFile )
{
return pView - > OpenXy ( pXy , bMergeFile ) ;
}
extern " C " __declspec ( dllexport )
void EnableMeshPackage ( CSigmaView * pView , BOOL isEnable , BOOL force )
{
pView - > EnableMeshPackage ( isEnable , force ) ;
}
extern " C " __declspec ( dllexport )
void SetMainMeshId3D ( CSigmaView * pView , int64_t id )
{
pView - > SetMainMeshId3D ( id ) ;
}
extern " C " __declspec ( dllexport )
int64_t GetMainMeshId3D ( CSigmaView * pView )
{
return pView - > GetMainMeshId3D ( ) ;
}
extern " C " __declspec ( dllexport )
int64_t GetMainMeshIdByMesh3D ( CSigmaView * pView , void * pMesh )
{
if ( pMesh = = nullptr )
{
return - 1 ;
}
return ( ( KevVtkMeshData * ) pMesh ) - > id ;
}
extern " C " __declspec ( dllexport )
void * GetMainMeshByMeshId3D ( CSigmaView * pView , int64_t id )
{
CXy * pXy = pView - > m_pDoc - > m_pXy ;
COne * pOne = pXy - > GetOneById ( id ) ;
if ( pOne - > GetType ( ) = = DOUBLEFOX_MESH )
{
KevVtkMeshData * pKevVtkMeshData = new KevVtkMeshData ;
CMesh * pMesh = ( CMesh * ) pOne - > GetValue ( ) ;
double zmin , zmax ;
pMesh - > GetM ( zmin , zmax ) ;
pKevVtkMeshData - > m_zMin = zmin ;
pKevVtkMeshData - > m_zMax = zmax ;
double x0 , y0 ;
pMesh - > GetOrg ( x0 , y0 ) ;
pKevVtkMeshData - > x0 = x0 ;
pKevVtkMeshData - > y0 = y0 ;
double dx , dy ;
pMesh - > GetDelt ( dx , dy ) ;
pKevVtkMeshData - > dx = dx ;
pKevVtkMeshData - > dy = dy ;
CGrid * pGrid = pMesh - > GetMesh ( ) ;
long numX = pGrid - > xnum ( ) ;
long numY = pGrid - > ynum ( ) ;
pKevVtkMeshData - > numX = numX ;
pKevVtkMeshData - > numY = numY ;
CDimension3D * pdfg = pMesh - > GetDfg ( ) ;
if ( pdfg = = NULL )
return nullptr ;
pKevVtkMeshData - > num = pdfg - > num ;
pKevVtkMeshData - > P0 = pdfg - > P0 ;
pKevVtkMeshData - > delt = pdfg - > delt ;
double * pShadow = new double [ pdfg - > total ] ;
std : : memcpy ( pShadow , pdfg - > u , pdfg - > total * sizeof ( double ) ) ;
pKevVtkMeshData - > shadow_u = pShadow ;
pKevVtkMeshData - > origin_u = pdfg - > u ;
pKevVtkMeshData - > range = pdfg - > range ;
pKevVtkMeshData - > n = pdfg - > n ;
CColorBase & color = pMesh - > color ;
for ( int i = 0 ; i < color . sizeColor ( ) ; i + + )
{
CColorItem & item = color . GetColorItem ( i ) ;
KevVtkColorItem * pColorItem = new KevVtkColorItem ( ) ;
pColorItem - > z = item . z ;
pColorItem - > color [ 0 ] = item . color . rgbRed ;
pColorItem - > color [ 1 ] = item . color . rgbGreen ;
pColorItem - > color [ 2 ] = item . color . rgbBlue ;
pColorItem - > color [ 3 ] = item . color . rgbReserved ;
pColorItem - > gradient = item . m_bContinue ;
pKevVtkMeshData - > m_colorList . push_back ( pColorItem ) ;
}
pKevVtkMeshData - > id = pMesh - > GetId ( ) ;
return pKevVtkMeshData ;
}
else
{
return nullptr ;
}
}
extern " C " __declspec ( dllexport )
void GetLayerByMainMesh3D ( CSigmaView * pView , void * pMesh , wchar_t * * layer )
{
if ( pMesh = = nullptr )
{
CString strLayer ;
int len = sizeof ( wchar_t ) * ( strLayer . GetLength ( ) + 1 ) ;
* layer = new wchar_t [ len ] ;
memset ( * layer , 0 , len ) ;
wcscpy_s ( * layer , len , CT2CW ( strLayer ) ) ;
return ;
}
else
{
CString strLayer ( ( ( KevVtkMeshData * ) pMesh ) - > m_layerName . c_str ( ) ) ;
int len = sizeof ( wchar_t ) * ( strLayer . GetLength ( ) + 1 ) ;
* layer = new wchar_t [ len ] ;
memset ( * layer , 0 , len ) ;
wcscpy_s ( * layer , len , CT2CW ( strLayer ) ) ;
return ;
}
}
extern " C " __declspec ( dllexport )
void * GetMainMeshByLayer3D ( CSigmaView * pView , LPCTSTR layer )
{
CXy * pXy = pView - > m_pDoc - > GetDraw ( ) ;
if ( pXy = = nullptr )
return nullptr ;
NBase : : CPositionList elements ;
//<2F> <> ȡͼ<C8A1> <CDBC> Ԫ<EFBFBD> أ<EFBFBD> <D8A3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͼ<EFBFBD> <CDBC>
pXy - > GetElement ( layer , elements , false ) ;
POSITION p = nullptr ;
COne * pOne = nullptr ;
POSITION pos ;
pos = elements . GetHeadPosition ( ) ;
KevVtkMeshData * pKevVtkMesh = nullptr ;
while ( pos )
{
p = elements . GetNext ( pos ) ;
pOne = ( COne * ) pXy - > GetValueList ( ) - > GetAt ( p ) ;
int type = pOne - > GetType ( ) ;
switch ( type )
{
case DOUBLEFOX_MESH :
{
pKevVtkMesh = new KevVtkMeshData ;
CMesh * pMesh = ( CMesh * ) pOne - > GetValue ( ) ;
double zmin , zmax ;
pMesh - > GetM ( zmin , zmax ) ;
pKevVtkMesh - > m_zMin = zmin ;
pKevVtkMesh - > m_zMax = zmax ;
double x0 , y0 ;
pMesh - > GetOrg ( x0 , y0 ) ;
pKevVtkMesh - > x0 = x0 ;
pKevVtkMesh - > y0 = y0 ;
double dx , dy ;
pMesh - > GetDelt ( dx , dy ) ;
pKevVtkMesh - > dx = dx ;
pKevVtkMesh - > dy = dy ;
CGrid * pGrid = pMesh - > GetMesh ( ) ;
long numX = pGrid - > xnum ( ) ;
long numY = pGrid - > ynum ( ) ;
pKevVtkMesh - > numX = numX ;
pKevVtkMesh - > numY = numY ;
CDimension3D * pdfg = pMesh - > GetDfg ( ) ;
if ( pdfg = = NULL )
return nullptr ;
pKevVtkMesh - > num = pdfg - > num ;
pKevVtkMesh - > P0 = pdfg - > P0 ;
pKevVtkMesh - > delt = pdfg - > delt ;
double * pShadow = new double [ pdfg - > total ] ;
std : : memcpy ( pShadow , pdfg - > u , pdfg - > total * sizeof ( double ) ) ;
pKevVtkMesh - > shadow_u = pShadow ;
pKevVtkMesh - > origin_u = pdfg - > u ;
pKevVtkMesh - > range = pdfg - > range ;
pKevVtkMesh - > n = pdfg - > n ;
pKevVtkMesh - > m_layerName = layer ;
pKevVtkMesh - > id = pMesh - > GetId ( ) ;
CColorBase & color = pMesh - > color ;
for ( int i = 0 ; i < color . sizeColor ( ) ; i + + )
{
CColorItem & item = color . GetColorItem ( i ) ;
KevVtkColorItem * pColorItem = new KevVtkColorItem ( ) ;
pColorItem - > z = item . z ;
pColorItem - > color [ 0 ] = item . color . rgbRed ;
pColorItem - > color [ 1 ] = item . color . rgbGreen ;
pColorItem - > color [ 2 ] = item . color . rgbBlue ;
pColorItem - > color [ 3 ] = item . color . rgbReserved ;
pColorItem - > gradient = item . m_bContinue ;
pKevVtkMesh - > m_colorList . push_back ( pColorItem ) ;
}
return pKevVtkMesh ;
}
break ;
default :
break ;
}
}
return pKevVtkMesh ;
}
extern " C " __declspec ( dllexport )
void SetFaultLayer ( CSigmaView * pView , LPCTSTR faultLayer )
{
pView - > SetFaultLayer ( faultLayer ) ;
}
extern " C " __declspec ( dllexport )
void GetFaultLayer ( CSigmaView * pView , wchar_t * * faultLayer )
{
CString strFaultLayer = pView - > GetFaultLayer ( ) ;
int len = sizeof ( wchar_t ) * ( strFaultLayer . GetLength ( ) + 1 ) ;
* faultLayer = new wchar_t [ len ] ;
memset ( * faultLayer , 0 , len ) ;
wcscpy_s ( * faultLayer , len , CT2CW ( strFaultLayer ) ) ;
}
extern " C " __declspec ( dllexport )
void SetBorderLayer ( CSigmaView * pView , LPCTSTR faultLayer )
{
pView - > SetBorderLayer ( faultLayer ) ;
}
extern " C " __declspec ( dllexport )
void GetBorderLayer ( CSigmaView * pView , wchar_t * * borderLayer )
{
CString strLayer = pView - > GetBorderLayer ( ) ;
int len = sizeof ( wchar_t ) * ( strLayer . GetLength ( ) + 1 ) ;
* borderLayer = new wchar_t [ len ] ;
memset ( * borderLayer , 0 , len ) ;
wcscpy_s ( * borderLayer , len , CT2CW ( strLayer ) ) ;
}
extern " C " __declspec ( dllexport )
void SetFaultLayer3D ( CSigmaView * pView , LPCTSTR faultLayer )
{
pView - > SetFaultLayer3D ( faultLayer ) ;
}
extern " C " __declspec ( dllexport )
void GetFaultLayer3D ( CSigmaView * pView , wchar_t * * faultLayer )
{
CString strFaultLayer = pView - > GetFaultLayer3D ( ) ;
int len = sizeof ( wchar_t ) * ( strFaultLayer . GetLength ( ) + 1 ) ;
* faultLayer = new wchar_t [ len ] ;
memset ( * faultLayer , 0 , len ) ;
wcscpy_s ( * faultLayer , len , CT2CW ( strFaultLayer ) ) ;
}
extern " C " __declspec ( dllexport )
void SetBorderLayer3D ( CSigmaView * pView , LPCTSTR faultLayer )
{
pView - > SetBorderLayer3D ( faultLayer ) ;
}
extern " C " __declspec ( dllexport )
void GetBorderLayer3D ( CSigmaView * pView , wchar_t * * borderLayer )
{
CString strLayer = pView - > GetBorderLayer3D ( ) ;
int len = sizeof ( wchar_t ) * ( strLayer . GetLength ( ) + 1 ) ;
* borderLayer = new wchar_t [ len ] ;
memset ( * borderLayer , 0 , len ) ;
wcscpy_s ( * borderLayer , len , CT2CW ( strLayer ) ) ;
}
extern " C " __declspec ( dllexport )
void SetWellLayer3D ( CSigmaView * pView , LPCTSTR wellLayer )
{
pView - > SetWellLayer3D ( wellLayer ) ;
}
extern " C " __declspec ( dllexport )
void GetWellLayer3D ( CSigmaView * pView , wchar_t * * wellLayer )
{
CString strLayer = pView - > GetWellLayer3D ( ) ;
int len = sizeof ( wchar_t ) * ( strLayer . GetLength ( ) + 1 ) ;
* wellLayer = new wchar_t [ len ] ;
memset ( * wellLayer , 0 , len ) ;
wcscpy_s ( * wellLayer , len , CT2CW ( strLayer ) ) ;
}
extern " C " __declspec ( dllexport )
void SetMainMeshLayer3D ( CSigmaView * pView , LPCTSTR layer )
{
pView - > SetMainMeshLayer3D ( layer ) ;
}
extern " C " __declspec ( dllexport )
void GetMainMeshLayer3D ( CSigmaView * pView , wchar_t * * wellLayer )
{
CString strLayer = pView - > GetMainMeshLayer3D ( ) ;
int len = sizeof ( wchar_t ) * ( strLayer . GetLength ( ) + 1 ) ;
* wellLayer = new wchar_t [ len ] ;
memset ( * wellLayer , 0 , len ) ;
wcscpy_s ( * wellLayer , len , CT2CW ( strLayer ) ) ;
}
extern " C " __declspec ( dllexport )
BOOL ReloadFile ( CSigmaView * pView )
{
return pView - > ReloadFile ( ) ;
}
extern " C " __declspec ( dllexport )
BOOL NewDocument ( CSigmaView * pView , LPCTSTR lpszFileName )
{
return pView - > CreateNew ( lpszFileName ) ;
}
extern " C " __declspec ( dllexport )
BOOL SaveDocument ( CSigmaView * pView , LPCTSTR fileName )
{
if ( pView = = NULL )
return false ;
return pView - > m_pDoc - > SaveFile ( fileName ) ;
}
extern " C " __declspec ( dllexport )
BOOL SavePdfDocument ( CSigmaView * pView , LPCTSTR fileName , double leftMargin , double rightMargin ,
double topMargin , double bottomMargin , int paperSizeType , int pdfAHType , int pdfPapertDirectionType )
{
if ( pView = = NULL )
return false ;
return pView - > m_pDoc - > SaveFile ( fileName , leftMargin , rightMargin ,
topMargin , bottomMargin , paperSizeType , pdfAHType , pdfPapertDirectionType ) ;
}
extern " C " __declspec ( dllexport )
void SaveActionPosition ( CSigmaView * pView )
{
pView - > m_pDoc - > SaveActionPosition ( ) ;
}
extern " C " __declspec ( dllexport )
void SetDefaultMeshColorTemplate ( int values [ ] , double Zs [ ] , int itemsCount )
{
TTypeSet < CColorItem > * colorItems = & ( CColorBase : : GetMeshDefault ( ) ) ;
colorItems - > erase ( ) ;
CColorItem ci ;
for ( int i = 0 ; i < itemsCount ; i + + )
{
ci . SetColor ( values [ i * 3 ] , values [ i * 3 + 1 ] , values [ i * 3 + 2 ] ) ;
ci . z = Zs [ i ] ;
colorItems - > add ( ci ) ;
}
return ;
}
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĵ<EFBFBD> <C4B5> Ƿ<EFBFBD> <C7B7> <EFBFBD> <EFBFBD> <EFBFBD>
//<2F> <> <EFBFBD> <EFBFBD> ֵ:-1--<2D> <> <EFBFBD> <EFBFBD> <EFBFBD> 쳣 0--δ<> <EFBFBD> 1--<2D> <> <EFBFBD> <EFBFBD>
extern " C " __declspec ( dllexport )
int Sigma_IsDocumentModified ( CSigmaView * pView )
{
if ( pView = = NULL )
return - 1 ;
if ( pView - > m_pDoc = = NULL )
return - 1 ;
if ( pView - > m_pDoc - > IsModified ( ) )
return 1 ;
return 0 ;
}
extern " C " __declspec ( dllexport )
void Sigma_SetDocumentModified ( CSigmaView * pView , BOOL modified )
{
if ( pView = = NULL | | pView - > m_pDoc = = NULL )
return ;
pView - > m_pDoc - > Modified ( modified ) ;
}
//0--<2D> <> <EFBFBD> ¼<EFBFBD> ͷ 1--<2D> <> ֱ<EFBFBD> <D6B1> ͷ 2--<2D> <> <EFBFBD> ¼<EFBFBD> ͷ 3--ˮƽ <CBAE> <C6BD> ͷ
//4--<2D> <> ת<EFBFBD> <D7AA> ͷ 5--ˮƽ <CBAE> <C6BD> <EFBFBD> м<EFBFBD> ͷ 6--<2D> <> ֱ<EFBFBD> <D6B1> <EFBFBD> м<EFBFBD> ͷ 7--ƽ <> Ƽ <EFBFBD> ͷ
//-1 <20> <> <EFBFBD> <EFBFBD>
extern " C " __declspec ( dllexport )
int GetTrackerHandleCursorType ( CSigmaView * pView , int mouseX , int mouseY )
{
if ( pView = = NULL )
return - 1 ;
CItem * pItem = pView - > GetItem ( ) ;
if ( pItem = = NULL )
return - 1 ;
CItemSelect * itemSelect = dynamic_cast < CItemSelect * > ( pItem ) ;
if ( itemSelect = = NULL )
return - 1 ;
CPoint ptHit ( mouseX , mouseY ) ;
int nHit = itemSelect - > GetTracker ( ) . HitTest ( ptHit ) ;
return nHit ;
}
extern " C " __declspec ( dllexport )
int GeoSigma_ScaleFont ( CSigmaView * pView , int bBig )
{
if ( pView = = 0 )
return - 1 ;
if ( pView - > m_pDoc = = 0 )
return - 1 ;
bool bCtrl = : : IsKeyDown ( VK_CONTROL ) ;
CItemScaleEmbellish item ( pView - > m_pDoc ) ;
if ( bBig ! = 0 )
item . ScaleFont ( bCtrl ? 1.05 : 1.25 ) ;
else
item . ScaleFont ( bCtrl ? 0.95 : 0.8 ) ;
pView - > m_pDoc - > Modified ( ) ;
return 1 ;
}
extern " C " __declspec ( dllexport )
int GetCoordinateXY ( CSigmaView * pView , int mouseX , int mouseY , BYTE * coordinate )
{
NBase : : CPoint2D pt ;
CPoint point ( mouseX , mouseY ) ;
pt = pView - > m_pDoc - > GetDC ( ) . GetReal ( point ) ;
CString pX , pY ;
pX . Format ( _T ( " %lf " ) , pt . x0 ) ;
pY . Format ( _T ( " %lf " ) , pt . y0 ) ;
pX = " X: " + pX + " , Y: " + pY ;
int nLen = pX . GetLength ( ) ;
memcpy ( coordinate , pX . GetBuffer ( 0 ) , nLen ) ;
return nLen ;
}
/**
* <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ļ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ȡ ʵ <EFBFBD> ʾ <EFBFBD> <EFBFBD> <EFBFBD>
*
* \ param pView
* \ param x1
* \ param y1
* \ param x2
* \ param y2
*
* \ return ʵ <EFBFBD> ʾ <EFBFBD> <EFBFBD> <EFBFBD>
*/
extern " C " __declspec ( dllexport )
double GetRealDistance ( CSigmaView * pView , int x1 , int y1 , int x2 , int y2 )
{
CXyDC & xyDC = pView - > m_pDoc - > GetDC ( ) ;
double realX1 = xyDC . GetRX ( ( long ) x1 ) ;
double realY1 = xyDC . GetRY ( ( long ) y1 ) ;
double realX2 = xyDC . GetRX ( ( long ) x2 ) ;
double realY2 = xyDC . GetRY ( ( long ) y2 ) ;
double xDistance = realX2 - realX1 ;
double yDistance = realY2 - realY1 ;
return sqrt ( xDistance * xDistance + yDistance * yDistance ) ;
}
extern " C " __declspec ( dllexport )
void ClearAll ( CSigmaView * pView , bool needUndo )
{
if ( pView = = nullptr | | pView - > m_pDoc = = nullptr | | pView - > m_pDoc - > m_pXy = = nullptr )
{
TRACE ( " pView pView->m_pDoc pView->m_pDoc->m_pXy <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϊ nullptr " ) ;
return ;
}
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> /<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
pView - > m_pDoc - > GetActionManager ( ) - > ClearTarget ( ) ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ǰ Item<65> <6D> <EFBFBD> <EFBFBD> <EFBFBD> DZ<EFBFBD> <C7B1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ǰ Item<65> <6D> <EFBFBD> <EFBFBD> Ȼ<EFBFBD> <C8BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 洢<EFBFBD> <E6B4A2> ӦԪ<D3A6> <D4AA> ָ<EFBFBD> <D6B8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ݣ<EFBFBD> <DDA3> ٲ<EFBFBD> <D9B2> <EFBFBD> ʱ<EFBFBD> ͻᱨ<CDBB> <E1B1A8>
int nItemType = pView - > m_pDoc - > GetItemType ( ) ;
pView - > m_pDoc - > DeleteItem ( ) ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> C# <20> ϲ 㻹<CFB2> <E3BBB9> <EFBFBD> <EFBFBD> ԭ<EFBFBD> <D4AD> <EFBFBD> <EFBFBD> ״̬<D7B4> <CCAC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ǻ<EFBFBD> Ҫ<EFBFBD> ָ<EFBFBD> <D6B8> <EFBFBD> ȥ
pView - > SetItem ( nItemType ) ;
pView - > m_pDoc - > m_pXy - > Clear ( ) ;
}
extern " C " __declspec ( dllexport )
int Sigma_HighLightGraphItem ( CSigmaView * pView , int mouseX , int mouseY , HDC screenHDC )
{
if ( pView = = NULL )
return - 1 ;
CDC * pDC = CDC : : FromHandle ( screenHDC ) ;
return pView - > HighLightGraphItem ( mouseX , mouseY , pDC ) ;
}
extern " C " __declspec ( dllexport )
void Sigma_EndHighLightGraphItem ( CSigmaView * pView )
{
if ( pView = = NULL )
return ;
pView - > EndHighLightGraphItem ( ) ;
}
//<2F> <> <EFBFBD> <EFBFBD> ֵ:-1--<2D> <> <EFBFBD> <EFBFBD> 0--δѡ <CEB4> <D1A1> ͼԪ <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> --tipInfo<66> ַ<EFBFBD> <D6B7> <EFBFBD> <EFBFBD> ij<EFBFBD> <C4B3> <EFBFBD>
extern " C " __declspec ( dllexport )
int Sigma_GetHighLightTip ( CSigmaView * pView , wchar_t * * tipInfo )
{
if ( pView = = 0 | | tipInfo = = 0 )
return - 1 ;
* tipInfo = pView - > GetTipInfoString ( ) ;
return ( int ) wcslen ( * tipInfo ) ;
}
extern " C " __declspec ( dllexport )
POSITION GetMaxPositon ( CSigmaView * pView )
{
CXy * pXy = pView - > m_pDoc - > m_pXy ;
if ( pXy = = 0 )
{
return 0 ;
}
CPtrList * values = pXy - > GetValueList ( ) ;
POSITION pos = values - > GetHeadPosition ( ) ;
POSITION maxPos = pos ;
while ( pos )
{
values - > GetNext ( pos ) ;
if ( maxPos < pos )
{
maxPos = pos ;
}
}
return maxPos ;
}
extern " C " __declspec ( dllexport )
void SigmaLog ( LPCTSTR msg )
{
if ( bInitLog = = false )
{
bInitLog = true ;
InitLog ( ) ;
}
spdlog : : info ( msg ) ;
}
//extern "C" __declspec(dllexport)
//void EnableCrossLine(CSigmaView * pView, bool bEnable)
//{
// pView->EnableCrossLine(bEnable);
//}
//
//extern "C" __declspec(dllexport)
//bool GetCrossLineEnabledStatus(CSigmaView * pView)
//{
// return pView->GetCrossLineEnabledStatus();
//}
extern " C " __declspec ( dllexport )
int Sigma_LayerSort ( CSigmaView * pView , bool enable )
{
if ( pView = = NULL )
{
return - 1 ;
}
CXy * pXy = pView - > m_pDoc - > m_pXy ;
if ( pXy = = NULL )
{
//::AfxMessageBox("GetXY() error");
return - 1 ;
}
BOOL bEnable = enable ? TRUE : FALSE ;
if ( pXy - > IsLayerSort ( ) ! = bEnable )
{
pXy - > EnableLayerSort ( bEnable ) ;
pView - > m_pDoc - > Modified ( ) ;
}
return 1 ;
//CMainFrame* pmf = (CMainFrame*)GetMainFrame();
//CDFDrawProDoc* pDoc = (CDFDrawProDoc*)pmf->GetActiveDoc();
//if (pDoc)
//{
// pDoc->SetModifiedFlag();
// pDoc->Invalidate();
//}
}
extern " C " __declspec ( dllexport )
int Sigma_Fill ( CSigmaView * pView , int extendLength )
{
if ( pView = = NULL )
return - 1 ;
CItem * pItem = pView - > GetItem ( ) ;
if ( pItem = = NULL )
return - 1 ;
CItemSolid * itemSolid = dynamic_cast < CItemSolid * > ( pItem ) ;
itemSolid - > m_iMaxExtendLength = extendLength ;
if ( itemSolid = = NULL )
return - 1 ;
itemSolid - > DoSelectEnd ( ) ;
return 1 ;
}
extern " C " __declspec ( dllexport )
int Sigma_Fill_SetStatusOfCrossPoint ( CSigmaView * pView , int status )
{
if ( status ! = - 1 & & status ! = 0 & & status ! = 1 )
return - 1 ;
if ( pView = = NULL )
return - 1 ;
if ( pView - > m_pDoc = = nullptr )
return - 1 ;
pView - > m_pDoc - > SetStatusOfCrossPoint ( status ) ;
return 1 ;
}
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> :<3A> <> <EFBFBD> <EFBFBD> ʱѡ <CAB1> <D1A1> <EFBFBD> <EFBFBD> ͼԪ<CDBC> Ƿ<EFBFBD> <C7B7> н<EFBFBD> <D0BD> <EFBFBD>
//<2F> <> <EFBFBD> <EFBFBD> ֵ:-1<> <31> <EFBFBD> <EFBFBD> 0û<30> н<EFBFBD> <D0BD> <EFBFBD> 1<> н<EFBFBD> <D0BD> <EFBFBD>
extern " C " __declspec ( dllexport )
int Sigma_Fill_GetStatusOfCrossPoint ( CSigmaView * pView )
{
if ( pView = = NULL )
return - 1 ;
if ( pView - > m_pDoc = = nullptr )
return - 1 ;
return pView - > m_pDoc - > GetStatusOfCrossPoint ( ) ;
}
extern " C " __declspec ( dllexport )
int Sigma_Fill_Link ( CSigmaView * pView )
{
if ( pView = = NULL )
return - 1 ;
CItem * pItem = pView - > GetItem ( ) ;
if ( pItem = = NULL )
return - 1 ;
CItemSolidLink * itemSolidLink = dynamic_cast < CItemSolidLink * > ( pItem ) ;
if ( itemSolidLink = = NULL )
return - 1 ;
itemSolidLink - > DoSelectEnd ( ) ;
return 1 ;
}
extern " C " __declspec ( dllexport )
int Sigma_Fill_Auto ( CSigmaView * pView , int extendLength )
{
if ( pView = = NULL )
return - 1 ;
CItem * pItem = pView - > GetItem ( ) ;
if ( pItem = = NULL )
return - 1 ;
CItemSolidAuto * itemSolidAuto = dynamic_cast < CItemSolidAuto * > ( pItem ) ;
itemSolidAuto - > m_iMaxExtendLength = extendLength ;
if ( itemSolidAuto = = NULL )
return - 1 ;
return 1 ;
}
extern " C " __declspec ( dllexport )
int Sigma_ZPositiveNegativeSign ( CSigmaView * pView )
{
pView - > OnProcessZFlag ( ) ;
return 1 ;
}
extern " C " bool XyInsertDataBottom ( CXy * pXy , BYTE * data , int dataLen , LPCTSTR newLayer ) ;
extern " C " __declspec ( dllexport )
bool Sigma_InsertDataBottom ( CSigmaView * pView , BYTE * data , int dataLen )
{
CSigmaDoc * pDoc = pView - > m_pDoc ;
CXy * pXy = pDoc - > m_pXy ;
return XyInsertDataBottom ( pXy , data , dataLen , " " ) ;
}
static void InitLog ( )
{
try
{
//5M=1048576 * 5
//<2F> <> <EFBFBD> <EFBFBD> ѭ<EFBFBD> <D1AD> <EFBFBD> <EFBFBD> ־ <20> <> ־<EFBFBD> <D6BE> С Ϊ5M <20> <> ־<EFBFBD> ļ<EFBFBD> <C4BC> <EFBFBD> <EFBFBD> <EFBFBD> 3<EFBFBD> <33>
//spdlog<6F> İ汾1.5.0
auto fileLogger = spdlog : : rotating_logger_mt ( " logger " , " logs/sigma.txt " , 1048576 * 5 , 3 ) ;
//auto file_logger = spdlog::rotating_logger_mt("basic_logger", "logs/basic.txt", 1048, 3);
spdlog : : set_default_logger ( fileLogger ) ;
}
catch ( const spdlog : : spdlog_ex & )
{
//std::cout << "Log init failed: " << ex.what() << std::endl;
}
}
int GetEncoderClsid ( const wchar_t * format , CLSID * pClsid )
{
UINT num = 0 ;
UINT size = 0 ;
ImageCodecInfo * pImageCodecInfo = NULL ;
GetImageEncodersSize ( & num , & size ) ;
if ( size = = 0 )
return - 1 ;
pImageCodecInfo = ( ImageCodecInfo * ) ( malloc ( size ) ) ;
if ( pImageCodecInfo = = NULL )
return - 1 ;
GetImageEncoders ( num , size , pImageCodecInfo ) ;
for ( UINT j = 0 ; j < num ; + + j )
{
if ( wcscmp ( pImageCodecInfo [ j ] . MimeType , format ) = = 0 )
{
* pClsid = pImageCodecInfo [ j ] . Clsid ;
free ( pImageCodecInfo ) ;
return j ;
}
}
free ( pImageCodecInfo ) ;
return - 1 ;
}
BOOL SaveAs ( CDC * pDC , const wchar_t * lpszFilename )
{
CBitmap * pBitmap = pDC - > GetCurrentBitmap ( ) ;
BITMAP bmp ;
pBitmap - > GetBitmap ( & bmp ) ;
CRect rcClient = CRect ( 0 , 0 , bmp . bmWidth , bmp . bmHeight ) ;
CBitmap screenbitmap ;
screenbitmap . CreateCompatibleBitmap ( pDC , rcClient . Width ( ) , rcClient . Height ( ) ) ;
CDC memDC ;
memDC . CreateCompatibleDC ( pDC ) ;
CBitmap * pOldBitmap = memDC . SelectObject ( & screenbitmap ) ;
memDC . SetStretchBltMode ( HALFTONE ) ;
memDC . StretchBlt ( 0 , 0 , rcClient . Width ( ) , rcClient . Height ( ) , pDC , 0 , 0 , rcClient . Width ( ) , rcClient . Height ( ) , SRCCOPY ) ;
memDC . SelectObject ( pOldBitmap ) ;
Bitmap bitmap ( ( HBITMAP ) screenbitmap . GetSafeHandle ( ) , NULL ) ;
CLSID picClsid ;
CString sFileName ( lpszFilename ) ;
CString sExt = sFileName . Right ( 3 ) . MakeLower ( ) ;
if ( sExt = = " jpg " )
{
ULONG encoderQuality = 80 ; //ѹ<> <D1B9> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
EncoderParameters encoderParameters ;
encoderParameters . Count = 1 ;
encoderParameters . Parameter [ 0 ] . Guid = EncoderQuality ;
encoderParameters . Parameter [ 0 ] . Type = EncoderParameterValueTypeLong ;
encoderParameters . Parameter [ 0 ] . NumberOfValues = 1 ;
encoderParameters . Parameter [ 0 ] . Value = & encoderQuality ;
GetEncoderClsid ( L " image/jpeg " , & picClsid ) ;
bitmap . Save ( lpszFilename , & picClsid , & encoderParameters ) ;
}
else if ( sExt = = " png " )
{
GetEncoderClsid ( L " image/png " , & picClsid ) ;
bitmap . Save ( lpszFilename , & picClsid , NULL ) ;
}
else if ( sExt = = " bmp " )
{
GetEncoderClsid ( L " image/bmp " , & picClsid ) ;
bitmap . Save ( lpszFilename , & picClsid , NULL ) ;
}
else
{
DeleteObject ( screenbitmap ) ;
memDC . DeleteDC ( ) ;
return FALSE ;
}
DeleteObject ( screenbitmap ) ;
memDC . DeleteDC ( ) ;
return TRUE ;
}
// <20> <> <EFBFBD> <EFBFBD> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĵ<EFBFBD> û<EFBFBD> <C3BB> Ҫ<EFBFBD> <D2AA> <EFBFBD> ޱƽ <DEB1> <C6BD> <EFBFBD> <EFBFBD> <EFBFBD> <EEB2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
static bool IsApproximate ( double value1 , double value2 )
{
return fabs ( value1 - value1 ) < = 5 ;
}
/**
* <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ߶ <EFBFBD> <EFBFBD> Ͼ <EFBFBD> <EFBFBD> <EFBFBD> Ϊ ָ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ȵ ĵ <EFBFBD>
*
* \ param x1 <EFBFBD> <EFBFBD> һ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> x <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
* \ param y1 <EFBFBD> <EFBFBD> һ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> y <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
* \ param x1 <EFBFBD> ڶ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> x <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
* \ param y1 <EFBFBD> ڶ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> y <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
* \ param targetDistance Ŀ <EFBFBD> 곤 <EFBFBD> <EFBFBD>
*/
static NBase : : CPoint2D targetDistancePoint ( const NBase : : CPoint2D & point1 , const NBase : : CPoint2D & point2 , double targetDistance )
{
double x1 = point1 . x0 ;
double y1 = point1 . y0 ;
double x2 = point2 . x0 ;
double y2 = point2 . y0 ;
double halfX = ( x1 + x2 ) / 2 ;
double halfY = ( y1 + y2 ) / 2 ;
double distance = point1 . Distance ( point2 ) ;
if ( distance < targetDistance )
{
return { - 1 , - 1 } ;
}
double middleDistance = distance / 2 ;
if ( IsApproximate ( middleDistance , targetDistance ) )
{
return { halfX , halfY } ;
}
if ( middleDistance > targetDistance )
{
return targetDistancePoint ( { x1 , y1 } , { halfX , halfY } , targetDistance ) ;
}
else
{
return targetDistancePoint ( { halfX , halfY } , { x2 , y2 } , targetDistance - middleDistance ) ;
}
}
// <20> <> ȡ Mesh
static CMesh * GetMesh ( CSigmaView * pView )
{
CXy * pXy = pView - > m_pDoc - > m_pXy ;
POSITION pt = pXy - > FindFirstElement ( DOUBLEFOX_MESH ) ;
if ( pt = = nullptr )
{
return nullptr ;
}
COne * pOne = pXy - > GetAt ( pt ) ;
return ( CMesh * ) pOne - > GetValue ( ) ;
}
/**
* <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ߶ ε Ĵ <EFBFBD> ֱ <EFBFBD> ཻ <EFBFBD> <EFBFBD>
*
* \ param point1
* \ param point2
* \ param crossPoint <EFBFBD> <EFBFBD> <EFBFBD> 㣬 <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ߶ <EFBFBD> <EFBFBD> <EFBFBD>
* \ param horizontal_distance <EFBFBD> <EFBFBD> ֱ <EFBFBD> ߶ δ ӽ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> / <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ƫ <EFBFBD> Ƶ <EFBFBD> x <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
*
* \ return <EFBFBD> <EFBFBD> <EFBFBD> ش <EFBFBD> ֱ <EFBFBD> ཻ <EFBFBD> <EFBFBD> <EFBFBD> ߶ <EFBFBD>
*/
static std : : pair < NBase : : CPoint2D , NBase : : CPoint2D > PerpendicularLine (
const NBase : : CPoint2D & point1 ,
const NBase : : CPoint2D & point2 ,
const NBase : : CPoint2D & crossPoint ,
double horizontal_distance )
{
std : : pair < NBase : : CPoint2D , NBase : : CPoint2D > result ;
int distance = horizontal_distance ;
if ( point1 . x0 = = point2 . x0 ) // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ߶<EFBFBD> <DFB6> Ǵ<EFBFBD> ֱ<EFBFBD> ģ<EFBFBD> <C4A3> <EFBFBD> ôֻ<C3B4> <D6BB> Ҫˮƽ <CBAE> <C6BD> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> <DFBC> <EFBFBD>
{
result . first . x0 = crossPoint . x0 - distance ;
result . first . y0 = crossPoint . y0 ;
result . second . x0 = crossPoint . x0 + distance ;
result . second . y0 = crossPoint . y0 ;
}
else if ( point1 . y0 = = point2 . y0 ) // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ߶<EFBFBD> <DFB6> <EFBFBD> ˮƽ <CBAE> ģ<EFBFBD> <C4A3> <EFBFBD> ôֻ<C3B4> <D6BB> Ҫ<EFBFBD> <D2AA> ֱ<EFBFBD> <D6B1> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> <DFBC> <EFBFBD>
{
result . first . x0 = crossPoint . x0 ;
result . first . y0 = crossPoint . y0 - distance ;
result . second . x0 = crossPoint . x0 ;
result . second . y0 = crossPoint . y0 + distance ;
}
else // <20> <> <EFBFBD> <EFBFBD> ͨ<EFBFBD> <CDA8> б <EFBFBD> <D0B1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
{
double slope = CalcSlope ( point1 . x0 , point1 . y0 , point2 . x0 , point2 . y0 ) ;
double perpendicularSlope = - 1 / slope ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ߴ <EFBFBD> ֱʱ<D6B1> <CAB1> б <EFBFBD> ʵij˻<C4B3> Ϊ-1
result . first . x0 = crossPoint . x0 - distance ;
result . first . y0 = perpendicularSlope * ( result . first . x0 - crossPoint . x0 ) + crossPoint . y0 ; // <20> <> <EFBFBD> 㴹ֱ<E3B4B9> ཻ<EFBFBD> ߵ <EFBFBD> <DFB5> <EFBFBD> <EFBFBD> <EFBFBD>
result . second . x0 = crossPoint . x0 + distance ;
result . second . y0 = perpendicularSlope * ( result . second . x0 - crossPoint . x0 ) + crossPoint . y0 ; // <20> <> <EFBFBD> 㴹ֱ<E3B4B9> ཻ<EFBFBD> ߵ <EFBFBD> <DFB5> յ<EFBFBD>
}
return result ;
}
/**
* <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ߵ <EFBFBD> <EFBFBD> м <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Լ <EFBFBD> <EFBFBD> м <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ڵ <EFBFBD> <EFBFBD> ߶ <EFBFBD>
*
* \ param startPoint <EFBFBD> <EFBFBD> <EFBFBD> Σ <EFBFBD> <EFBFBD> ߶ <EFBFBD> <EFBFBD> <EFBFBD> ʼ λ <EFBFBD> <EFBFBD>
* \ param endPoint <EFBFBD> <EFBFBD> <EFBFBD> Σ <EFBFBD> <EFBFBD> ߶ ν <EFBFBD> <EFBFBD> <EFBFBD> λ <EFBFBD> <EFBFBD>
* \ param middlPoint <EFBFBD> <EFBFBD> <EFBFBD> Σ <EFBFBD> <EFBFBD> м <EFBFBD> <EFBFBD> <EFBFBD>
*/
static void CurveMiddlePoint ( CCurveEx * pCurve , NBase : : CPoint2D * startPoint , NBase : : CPoint2D * endPoint , NBase : : CPoint2D * middlePoint )
{
double totalDistance = 0.0 ;
std : : vector < double > distances ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ܳ<EFBFBD> <DCB3> Ⱥ<EFBFBD> ÿһ <C3BF> εij<CEB5> <C4B3> <EFBFBD>
for ( int i = 0 ; i < pCurve - > num - 1 ; i + + )
{
NBase : : CPoint2D point1 { pCurve - > x [ i ] , pCurve - > y [ i ] } ;
NBase : : CPoint2D point2 { pCurve - > x [ i + 1 ] , pCurve - > y [ i + 1 ] } ;
double distance = point1 . Distance ( point2 ) ;
totalDistance + = distance ;
distances . push_back ( distance ) ;
}
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> м<EFBFBD> <D0BC> <EFBFBD> <EFBFBD> ľ<EFBFBD> <C4BE> <EFBFBD>
double middleDistance = totalDistance / 2 ;
// <20> м<EFBFBD> <D0BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ߶<EFBFBD> ǰ<EFBFBD> <C7B0> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ߶εij<CEB5> <C4B3> <EFBFBD>
double sum = 0.0 ;
// <20> ҳ<EFBFBD> <D2B3> м<EFBFBD> <D0BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ڵ<EFBFBD> ֱ<EFBFBD> <D6B1>
size_t i = 0 ;
for ( i = 0 ; i < distances . size ( ) ; i + + )
{
if ( sum + distances [ i ] > middleDistance )
{
break ;
}
sum + = distances [ i ] ;
}
double x1 = pCurve - > x [ i ] ;
double y1 = pCurve - > y [ i ] ;
double x2 = pCurve - > x [ i + 1 ] ;
double y2 = pCurve - > y [ i + 1 ] ;
* startPoint = NBase : : CPoint2D { x1 , y1 } ;
* endPoint = NBase : : CPoint2D { x2 , y2 } ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ߵ <EFBFBD> <DFB5> <EFBFBD> <EFBFBD> ĵ<EFBFBD>
* middlePoint = targetDistancePoint ( * startPoint , * endPoint , middleDistance - sum ) ;
}
// <20> <> <EFBFBD> ߷<EFBFBD> <DFB7> <EFBFBD>
enum class CurveOrientation
{
LowToHigh , // <20> ӵ͵<D3B5> <CDB5> <EFBFBD>
HightToLow , // <20> Ӹߵ <D3B8> <DFB5> <EFBFBD>
} ;
/**
* <EFBFBD> ж ϵ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ߵ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ࡢ <EFBFBD> Ҳ ࡢ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ߶ <EFBFBD> <EFBFBD> ϣ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> IJ <EFBFBD> <EFBFBD> <EFBFBD>
*
* \ param line <EFBFBD> ߣ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> pair <EFBFBD> <EFBFBD> first <EFBFBD> <EFBFBD> second
* \ param point <EFBFBD> <EFBFBD>
* \ return > 0 <EFBFBD> <EFBFBD> <EFBFBD> ࣬ < 0 <EFBFBD> Ҳ ࣬ = 0 <EFBFBD> ߶ <EFBFBD> <EFBFBD> <EFBFBD>
*/
static int PointPositionOfLine ( const std : : pair < NBase : : CPoint2D , NBase : : CPoint2D > & line , const NBase : : CPoint2D & point )
{
double px = line . first . x0 ;
double py = line . first . y0 ;
double qx = line . second . x0 ;
double qy = line . second . y0 ;
double lx = point . x0 ;
double ly = point . y0 ;
double m = ( qx - px ) * ( ly - py ) - ( qy - py ) * ( lx - px ) ;
return m ;
}
/**
* <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ϲ <EFBFBD> <EFBFBD> ķ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 0 <EFBFBD> <EFBFBD> ʾ <EFBFBD> ӵ ͵ <EFBFBD> <EFBFBD> ߣ <EFBFBD> 1 <EFBFBD> <EFBFBD> ʾ <EFBFBD> Ӹ ߵ <EFBFBD> <EFBFBD> <EFBFBD>
*
* \ param pView
* \ param pCurve
* \ param orientation <EFBFBD> <EFBFBD> <EFBFBD> Σ <EFBFBD> <EFBFBD> ϲ 㷽 <EFBFBD> <EFBFBD>
*
* \ return
*/
static int CalcCurveOrientation ( CMesh * pMesh , CCurveEx * pCurve )
{
NBase : : CPoint2D point1 ;
NBase : : CPoint2D point2 ;
NBase : : CPoint2D crossPoint ;
double dx = 0.0 ;
double dy = 0.0 ;
pMesh - > GetDelt ( dx , dy ) ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʹ <EFBFBD> <CAB9> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ո <EFBFBD> <D5B8> <EFBFBD> <EFBFBD> ȣ <EFBFBD> <C8A3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> С <EFBFBD> ǿ<EFBFBD> <C7BF> Ըı <D4B8> <C4B1> ģ<EFBFBD> <C4A3> <EFBFBD> <EFBFBD> ﶯ̬<EFB6AF> <CCAC> ȡ<EFBFBD> <C8A1> <EFBFBD> <EFBFBD> д<EFBFBD> <D0B4> һ <EFBFBD> <D2BB> <EFBFBD> ̶<EFBFBD> ֵ<EFBFBD> <D6B5> <EFBFBD> <EFBFBD> ֹ<EFBFBD> <D6B9> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͬһ <CDAC> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
double horizontal_distance = dx * 2 ;
CurveMiddlePoint ( pCurve , & point1 , & point2 , & crossPoint ) ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֱ<EFBFBD> ཻ<EFBFBD> <E0BDBB>
std : : pair < NBase : : CPoint2D , NBase : : CPoint2D > perpendicularLine = PerpendicularLine ( point1 , point2 , crossPoint , horizontal_distance ) ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ߵ <EFBFBD> z ֵ
double z1 = pMesh - > GetValue ( perpendicularLine . first . x0 , perpendicularLine . first . y0 ) ;
double z2 = pMesh - > GetValue ( perpendicularLine . second . x0 , perpendicularLine . second . y0 ) ;
// ȡ<> <C8A1> <EFBFBD> ߵ ĵ<DFB5>
const NBase : : CPoint2D * pPoint = & point1 ;
if ( z1 < z2 )
{
pPoint = & point2 ;
}
// ͨ<> <CDA8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ж<EFBFBD> <D0B6> <EFBFBD> <EFBFBD> ߵ <EFBFBD> <DFB5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <E0BBB9> <EFBFBD> Ҳ<EFBFBD>
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> Ƕ<EFBFBD> <C7B6> <EFBFBD> <EFBFBD> <EFBFBD> һ <EFBFBD> ༴<EFBFBD> <E0BCB4>
return PointPositionOfLine ( perpendicularLine , * pPoint ) > 0 ? 1 : 0 ;
}
extern " C " __declspec ( dllexport )
int AdjustDirectionAutomatically ( CSigmaView * pView , int orientation )
{
// <20> <> ֹ<EFBFBD> <D6B9> <EFBFBD> ˴ <EFBFBD> <CBB4> <EFBFBD> 0 1 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
orientation = ( orientation = = 0 ) ? 1 : 0 ;
CSigmaDoc * pDoc = pView - > m_pDoc ;
CXy * pXy = pDoc - > m_pXy ;
CMesh * pMesh = GetMesh ( pView ) ;
if ( pMesh = = nullptr )
{
return 0 ;
}
CString layerName = pXy - > GetFaultLayer ( ) ;
CLayer * pLayer = pXy - > FindLayer ( layerName ) ;
if ( pLayer = = nullptr )
{
return 0 ;
}
NBase : : CPositionList needReversePositions ;
std : : list < CCurveEx * > needReverseCurves ;
NBase : : CPositionList posList ;
int nCount = pXy - > GetElement ( pLayer , posList , DOUBLEFOX_CURVE ) ;
if ( nCount = = 0 )
{
return 0 ;
}
CListForEach ( pos , posList )
{
POSITION pt = posList . GetAt ( pos ) ;
COne * pOne = pXy - > GetAt ( pt ) ;
CCurveEx * pCurve = ( CCurveEx * ) ( pOne - > value ) ;
if ( IsPolygon ( pCurve ) )
{
continue ;
}
if ( CalcCurveOrientation ( pMesh , pCurve ) ! = orientation )
{
needReversePositions . AddTail ( pt ) ;
needReverseCurves . push_back ( pCurve ) ;
}
}
if ( needReversePositions . GetCount ( ) = = 0 )
{
return 0 ;
}
pDoc - > SetActionItem ( new CActionCurveReversalItem ( pDoc , ID_OPERATION_CURVE_REVERSAL , needReversePositions ) ) ;
pDoc - > Modified ( ) ;
for ( CCurveEx * pCurve : needReverseCurves )
{
pCurve - > Reversal ( ) ;
}
return needReversePositions . GetCount ( ) ;
}
static POSITION GetFirstLayerPosition ( CXy * pXy , CString strLayer )
{
CLayerName layerName ( strLayer ) ;
CLayerList * pClassList = pXy - > GetClass ( layerName . GetClassName ( ) ) ;
if ( pClassList = = NULL )
{
return NULL ;
}
strLayer = layerName . GetPathName ( ) ;
strLayer . MakeLower ( ) ;
POSITION pos = pClassList - > GetHeadPosition ( ) ;
while ( pos )
{
CLayer * pLayer = pClassList - > GetAt ( pos ) ;
CString str = pLayer - > GetName ( ) ;
str . MakeLower ( ) ;
if ( str . Find ( strLayer ) = = 0 ) //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> 뵱ǰҪ<C7B0> ƶ<EFBFBD> <C6B6> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͬ,<2C> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͬʱ,<2C> <> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB> Ϊֹ
break ;
pClassList - > GetNext ( pos ) ;
}
return pos ;
}
/**
* <EFBFBD> <EFBFBD> <EFBFBD> ҵ <EFBFBD> ǰ <EFBFBD> <EFBFBD> ͬ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ǰ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͼ <EFBFBD> 㣬
*
* \ param pXy
* \ param currLayer
* \ return <EFBFBD> <EFBFBD> <EFBFBD> ڷ <EFBFBD> <EFBFBD> <EFBFBD> ǰ <EFBFBD> <EFBFBD> ͼ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ƣ <EFBFBD> ʧ <EFBFBD> ܷ <EFBFBD> <EFBFBD> ؿ <EFBFBD> <EFBFBD> ַ <EFBFBD> <EFBFBD> <EFBFBD>
*/
static CString GetPrevLayer ( CXy * pXy , CString layer )
{
CLayerName layerName ( layer ) ;
CString layerPath = layerName . GetFullPathName ( ) ;
layerPath . MakeLower ( ) ;
CLayerList * pClass = pXy - > GetClass ( layerName . GetClassName ( ) ) ;
CString parentLayer = GetParentLayerPath ( layerName . GetPathName ( ) ) ;
bool hasFind = false ;
CListForEachReverse ( pos , * pClass )
{
CLayer * pLayer = pClass - > GetAt ( pos ) ;
CString currLayerPath = CLayerName ( pLayer - > GetName ( ) ) . GetFullPathName ( ) ;
CString currParentLayerPath = GetParentLayerPath ( currLayerPath ) ;
currLayerPath . MakeLower ( ) ;
// ע<> ⣺<EFBFBD> <E2A3BA> <EFBFBD> <EFBFBD> ͳһ ʹ <D2BB> <CAB9> FullPathName <20> <> <EFBFBD> Աȣ <D4B1> <C8A3> <EFBFBD> Ϊ<EFBFBD> <CEAA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ·<EFBFBD> <C2B7> <EFBFBD> д<EFBFBD> Class <20> <> <20> <> <EFBFBD> <EFBFBD> Class <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
// <20> <> <EFBFBD> <EFBFBD> ˵<EFBFBD> <CBB5> Layer:\aa <20> <> aa <20> <> ʵ<EFBFBD> <CAB5> ͬһ ·<D2BB> <C2B7>
if ( currLayerPath . CompareNoCase ( layerPath ) = = 0 ) // <20> ҵ<EFBFBD> ͼ<EFBFBD> <CDBC>
{
hasFind = true ;
continue ;
}
if ( hasFind )
{
// <20> ҵ<EFBFBD> <D2B5> <EFBFBD> ǰ<EFBFBD> <C7B0> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB> parent <20> <> ͬ<EFBFBD> <CDAC> Ԫ<EFBFBD> <D4AA>
if ( currParentLayerPath . CompareNoCase ( currParentLayerPath ) = = 0 )
{
return currLayerPath ;
}
}
}
return " " ;
}
/**
* <EFBFBD> <EFBFBD> ȡ <EFBFBD> ƶ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
*
* \ param oldPath <EFBFBD> ƶ <EFBFBD> ǰ <EFBFBD> <EFBFBD> · <EFBFBD> <EFBFBD>
* \ param parentPath <EFBFBD> ƶ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> · <EFBFBD> <EFBFBD>
* \ return
*/
static CString GetMovedLayerPath ( const CString & oldPath , const CString & parentPath )
{
CString fileName = PathFindFileName ( oldPath ) ;
CString targetLayerName ;
targetLayerName . Format ( " %s \\ %s " , parentPath , fileName ) ;
return targetLayerName ;
}
static CString GetParentPath ( const CString & path )
{
int index = path . ReverseFind ( ' \\ ' ) ;
if ( index ! = - 1 )
{
return path . Left ( index ) ;
}
return " " ;
}
/**
* <EFBFBD> <EFBFBD> ק ͼ <EFBFBD> <EFBFBD>
* \ param pView
* \ param positioinLayer <EFBFBD> ƶ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> λ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ڵ <EFBFBD> ͼ <EFBFBD> <EFBFBD>
* \ param darggedLayer <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ק <EFBFBD> <EFBFBD> ͼ <EFBFBD> <EFBFBD>
*/
extern " C " __declspec ( dllexport )
void LayerDragged ( CSigmaView * pView , wchar_t * targetLayer , wchar_t * draggedLayer , bool beChild )
{
CXy * pXy = pView - > m_pDoc - > m_pXy ;
CString strTargetLayer ( targetLayer ) ;
CString strDraggedLayer ( draggedLayer ) ;
if ( strDraggedLayer = = strTargetLayer )
{
return ;
}
POSITION posInsert = GetFirstLayerPosition ( pXy , strTargetLayer ) ;
int count = 0 ;
CString targetParentLayer = GetParentLayerPath ( strTargetLayer ) ;
CString draggedParentLayer = GetParentLayerPath ( strDraggedLayer ) ;
CLayerLocation oldLocation ;
oldLocation . layer = strDraggedLayer ;
oldLocation . prevLayer = GetPrevLayer ( pXy , oldLocation . layer ) ;
CLayerLocation newLocation ;
if ( beChild )
{
count = pXy - > MoveLayer ( strDraggedLayer , strTargetLayer ) ;
if ( count > 0 )
{
newLocation . layer = GetMovedLayerPath ( strDraggedLayer , strTargetLayer ) ;
newLocation . prevLayer = GetPrevLayer ( pXy , newLocation . layer ) ;
}
}
else if ( targetParentLayer = = draggedParentLayer ) // ͬһ <CDAC> <D2BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> £<EFBFBD> <C2A3> Ƶ<EFBFBD> <C6B5> <EFBFBD> ͬ<EFBFBD> <CDAC> <EFBFBD> 𣬽<EFBFBD> <F0A3ACBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ˳<EFBFBD> <CBB3> <EFBFBD> <EFBFBD> ͬʱ
{
count = pXy - > MoveLayerInSameClassSeries ( strDraggedLayer , TRUE , posInsert ) ;
if ( count > 0 )
{
newLocation . layer = strDraggedLayer ;
newLocation . prevLayer = GetPrevLayer ( pXy , newLocation . layer ) ;
}
}
else
{
count = pXy - > MoveLayer ( strDraggedLayer , targetParentLayer , TRUE , posInsert ) ;
if ( count > 0 )
{
newLocation . layer = GetMovedLayerPath ( strDraggedLayer , strTargetLayer ) ;
newLocation . prevLayer = GetPrevLayer ( pXy , newLocation . layer ) ;
}
}
if ( count > 0 )
{
pView - > m_pDoc - > SetActionItem ( new CActionLayerDragDropItem ( pView - > m_pDoc , oldLocation , newLocation ) ) ;
}
}
/**
* @ brief <EFBFBD> <EFBFBD> ȡ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ִ <EFBFBD> <EFBFBD> ״ ̬ <EFBFBD> <EFBFBD>
*
* @ param pView
* @ return int ִ <EFBFBD> <EFBFBD> ״ ̬ <EFBFBD> <EFBFBD>
*/
extern " C " __declspec ( dllexport )
int GetStatusCode ( CSigmaView * pView )
{
CItem * pItem = nullptr ;
if ( pView )
{
pItem = pView - > GetItem ( ) ;
}
if ( pItem )
{
return pItem - > GetStatusCode ( ) ;
}
return STATUS_CODE_FAILED ;
}
/**
* @ brief <EFBFBD> <EFBFBD> ȡ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ִ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϣ
*
* @ param pView
* @ return const char * <EFBFBD> <EFBFBD> Ϣ <EFBFBD> ı <EFBFBD>
*/
extern " C " __declspec ( dllexport )
const char * GetStatusText ( CSigmaView * pView )
{
CItem * pItem = nullptr ;
if ( pView )
{
pItem = pView - > GetItem ( ) ;
}
if ( pItem )
{
return pItem - > GetStatusText ( ) ;
}
return nullptr ;
}
struct DeduplicateOption
{
std : : string Type ; // Ҫȥ<D2AA> ص<EFBFBD> ͼԪ
double MaxErorr = std : : numeric_limits < double > : : epsilon ( ) ; // <20> <> <EFBFBD> <EFBFBD> ;
bool CompareLayer = false ; // ֻ<> <D6BB> <EFBFBD> <EFBFBD> ͬͼ<CDAC> <CDBC> <EFBFBD> ڵ<EFBFBD> ͼԪ<CDBC> <D4AA> <EFBFBD> <EFBFBD> ȥ<EFBFBD> <C8A5>
bool CompareElementName = false ; // <20> Ա<EFBFBD> ͼԪ<CDBC> <D4AA> <EFBFBD> <EFBFBD>
bool CompareEmbellishName = false ; // <20> Ա<EFBFBD> <D4B1> <EFBFBD> <EFBFBD> η<EFBFBD> <CEB7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
} ;
static std : : optional < DeduplicateOption > LoadDeleteDupElementsOption ( const std : : string & xml )
{
DeduplicateOption option ;
TiXmlDocument xmlDoc ;
xmlDoc . Parse ( xml . c_str ( ) ) ;
TiXmlElement * root = xmlDoc . RootElement ( ) ;
if ( root = = nullptr )
{
return std : : nullopt ;
}
TiXmlElement * typeElement = root - > FirstChildElement ( " Type " ) ;
TiXmlElement * maxErrorElement = root - > FirstChildElement ( " MaxError " ) ;
TiXmlElement * compareLayerElement = root - > FirstChildElement ( " CompareLayer " ) ;
TiXmlElement * compareElementNameElement = root - > FirstChildElement ( " CompareElementName " ) ;
if ( typeElement = = nullptr
| | maxErrorElement = = nullptr
| | compareLayerElement = = nullptr
| | compareElementNameElement = = nullptr )
{
return std : : nullopt ;
}
std : : vector < std : : string > types { " Point " , " Curve " , " PointAndCurve " } ;
if ( ! Contains ( types , std : : string ( typeElement - > GetText ( ) ) ) )
{
return std : : nullopt ;
}
option . Type = typeElement - > GetText ( ) ;
try
{
option . MaxErorr = std : : stod ( maxErrorElement - > GetText ( ) ) ;
}
catch ( . . . )
{
return std : : nullopt ;
}
const char * compareLayer = compareLayerElement - > GetText ( ) ;
option . CompareLayer = ( std : : string_view ( compareLayer ) = = " true " ) ;
const char * compareElementName = compareElementNameElement - > GetText ( ) ;
option . CompareElementName = ( std : : string_view ( compareElementName ) = = " true " ) ;
return option ;
}
static bool IsPoint ( COne * pOne )
{
switch ( pOne - > GetType ( ) )
{
case DOUBLEFOX_XYZ :
case DOUBLEFOX_POINT :
case DOUBLEFOX_CROSSPOINT :
case DOUBLEFOX_TWOPOINT :
return true ;
}
return false ;
}
static bool IsCurve ( COne * pOne )
{
return pOne - > GetType ( ) = = DOUBLEFOX_CURVE ;
}
/**
* ͼ Ԫ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ࣬ Ŀ ǰ <EFBFBD> <EFBFBD> ֧ <EFBFBD> ֵ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
*/
class DupComparer
{
public :
DupComparer ( const DeduplicateOption & option )
: m_option ( option )
{
}
bool Compare ( const COne * pLeft , const COne * pRight ) const
{
COne * left = const_cast < COne * > ( pLeft ) ;
COne * right = const_cast < COne * > ( pRight ) ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> û<EFBFBD> <C3BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͬ<EFBFBD> <CDAC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ﷵ<EFBFBD> <EFB7B5> false<73> <65> <EFBFBD> <EFBFBD> <EFBFBD> Dz<EFBFBD> ϣ<EFBFBD> <CFA3> <EFBFBD> û<EFBFBD> <C3BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͬ<EFBFBD> <CDAC> <EFBFBD> <EFBFBD>
if ( left = = right )
{
return false ;
}
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ԫ<EFBFBD> <D4AA> <EFBFBD> <EFBFBD> <EFBFBD> Ͳ<EFBFBD> <CDB2> <EFBFBD> ͬ<EFBFBD> <CDAC> <EFBFBD> <EFBFBD> Ȼ<EFBFBD> <C8BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( left - > GetType ( ) ! = right - > GetType ( ) )
{
return false ;
}
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ǹ<EFBFBD> <C7B9> ĵ<EFBFBD> <C4B5> <EFBFBD> <EFBFBD> ͣ<EFBFBD> ֱ<EFBFBD> <D6B1> <EFBFBD> Թ<EFBFBD>
if ( ! MatchOptionType ( left ) )
{
return false ;
}
// <20> û<EFBFBD> <C3BB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ƿ<EFBFBD> ֻ<EFBFBD> <D6BB> ͬһ ͼ<D2BB> <CDBC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ȥ<EFBFBD> <C8A5>
if ( m_option . CompareLayer & & ( left - > GetLayer ( ) - > GetPathName ( ) ! = right - > GetLayer ( ) - > GetPathName ( ) ) )
{
return false ;
}
/*
if ( m_option . CompareEmbellishName )
{
CHowToViewPoint * leftHowToViewPoint = left - > GetHowToViewPoint ( ) ;
CHowToViewPoint * rightHowToViewPoint = right - > GetHowToViewPoint ( ) ;
if ( ! IsDupHowToViewPoint ( leftHowToViewPoint , rightHowToViewPoint ) )
{
return false ;
}
CHowToViewCurve * leftHowToViewCurve = left - > GetHowToViewCurve ( ) ;
CHowToViewCurve * rightHowToViewCurve = right - > GetHowToViewCurve ( ) ;
if ( ! IsDupHowToViewCurve ( leftHowToViewCurve , rightHowToViewCurve ) )
{
return false ;
}
}
*/
if ( m_option . CompareElementName & & ( left - > GetName ( ) ! = right - > GetName ( ) ) )
{
return false ;
}
int leftType = left - > GetType ( ) ;
if ( IsPoint ( left ) )
{
CPointNameEx * leftPoint = ( CPointNameEx * ) ( left - > GetValue ( ) ) ;
CPointNameEx * rightPoint = ( CPointNameEx * ) ( right - > GetValue ( ) ) ;
return IsDupPoint ( leftPoint , rightPoint ) ;
}
else if ( IsCurve ( left ) )
{
CCurveEx * leftCurve = ( CCurveEx * ) ( left - > GetValue ( ) ) ;
CCurveEx * rightCurve = ( CCurveEx * ) ( right - > GetValue ( ) ) ;
return IsDupCurve ( leftCurve , rightCurve ) ;
}
return false ;
}
bool MatchOptionType ( COne * left ) const
{
if ( m_option . Type = = " Point " )
{
return IsPoint ( left ) ;
}
else if ( m_option . Type = = " Curve " )
{
return IsCurve ( left ) ;
}
else if ( m_option . Type = = " PointAndCurve " )
{
return IsPoint ( left ) | | IsCurve ( left ) ;
}
return false ;
}
private :
bool IsDupPoint ( CPointNameEx * left , CPointNameEx * right ) const
{
DoubleComparator comparator ( m_option . MaxErorr ) ;
return comparator . IsEqual ( left - > x0 , right - > x0 )
& & comparator . IsEqual ( left - > y0 , right - > y0 )
& & comparator . IsEqual ( left - > z0 , right - > z0 ) ;
}
bool IsDupCurve ( CCurveEx * left , CCurveEx * right ) const
{
DoubleComparator comparator ( m_option . MaxErorr ) ;
if ( left - > num ! = right - > num )
{
return false ;
}
for ( int i = 0 ; i < left - > num ; i + + )
{
if ( ! comparator . IsEqual ( left - > x [ i ] , right - > x [ i ] ) )
{
return false ;
}
if ( ! comparator . IsEqual ( left - > y [ i ] , right - > y [ i ] ) )
{
return false ;
}
if ( ! comparator . IsEqual ( left - > z [ i ] , right - > z [ i ] ) )
{
return false ;
}
}
return true ;
}
bool IsDupHowToViewPoint ( CHowToViewPoint * left , CHowToViewPoint * right ) const
{
if ( left = = nullptr & & right = = nullptr )
{
return true ;
}
if ( left = = nullptr & & right ! = nullptr )
{
return false ;
}
if ( left ! = nullptr & & right = = nullptr )
{
return false ;
}
return left - > GetName ( ) = = right - > GetName ( ) ;
}
template < typename T >
bool IsSame ( CCurveView * left , CCurveView * right ) const
{
T * leftView = dynamic_cast < T * > ( left ) ;
T * rightView = dynamic_cast < T * > ( right ) ;
if ( leftView ! = nullptr & & rightView ! = nullptr )
{
return leftView - > MarkName = = rightView - > MarkName ;
}
return false ;
}
/// <summary>
/// <20> Ƚ<EFBFBD> <C8BD> <EFBFBD> <EFBFBD> ݶ<EFBFBD> <DDB6> <EFBFBD> ָ<EFBFBD> 뱾<EFBFBD> <EBB1BE>
/// </summary>
/// <param name="array">array</param>
/// <param name="view">view</param>
/// <returns>true/false</returns>
bool ContainsSame ( CArray < CCurveView * , CCurveView * > & array , CCurveView * view ) const
{
for ( int i = 0 ; i < array . GetSize ( ) ; i + + )
{
CCurveView * curr = array . GetAt ( i ) ;
if ( typeid ( * curr ) ! = typeid ( * view ) )
{
continue ;
}
// CCurveLocate <20> <> CCurveLoateEx <20> Ȳ<EFBFBD> <C8B2> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> û<EFBFBD> <C3BB> MarkName<6D> <65>
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> Ķ<EFBFBD> <C4B6> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ࣬<EFBFBD> Ѿ<EFBFBD> <D1BE> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( IsSame < CCurveArrow > ( curr , view )
| | IsSame < CCurveScale > ( curr , view )
| | IsSame < CCurveTwoMark > ( curr , view )
| | IsSame < CCurveRgn > ( curr , view ) )
{
return true ;
}
}
return false ;
}
bool IsSubSet ( CArray < CCurveView * , CCurveView * > & subSet , CArray < CCurveView * , CCurveView * > & set ) const
{
for ( int i = 0 ; i < subSet . GetSize ( ) ; i + + )
{
if ( ! ContainsSame ( set , subSet . GetAt ( i ) ) )
{
return false ;
}
}
return true ;
}
bool IsDupHowToViewCurve ( CHowToViewCurve * left , CHowToViewCurve * right ) const
{
CArray < CCurveView * , CCurveView * > * leftArray = left - > GetValueArray ( ) ;
CArray < CCurveView * , CCurveView * > * rightArray = right - > GetValueArray ( ) ;
if ( left = = nullptr | | right = = nullptr )
{
return left = = right ;
}
return ( leftArray - > GetSize ( ) = = rightArray - > GetSize ( ) ) & & IsSubSet ( * leftArray , * rightArray ) ;
}
DeduplicateOption m_option ;
} ;
static bool ExistDuplicateElement ( std : : vector < COne * > & vec , COne * pOne , const DupComparer & comparer )
{
return AnyOf ( vec , [ pOne , & comparer ] ( COne * pCurr )
{
return comparer . Compare ( pCurr , pOne ) ;
} ) ;
}
/**
* ɾ <EFBFBD> <EFBFBD> <EFBFBD> ظ <EFBFBD> ͼ Ԫ
* \ param pXy ͼ <EFBFBD> <EFBFBD>
* \ param filters ɾ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
* <EFBFBD> <EFBFBD> <EFBFBD> ͣ <EFBFBD> Ҫ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Щ <EFBFBD> <EFBFBD> <EFBFBD> ͵ <EFBFBD> ͼ Ԫ ȥ <EFBFBD> <EFBFBD>
* <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> : <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Χ <EFBFBD> ڲ <EFBFBD> <EFBFBD> <EFBFBD> Ϊ <EFBFBD> <EFBFBD> <EFBFBD> ظ <EFBFBD> ͼ Ԫ
* ͬ һ ͼ <EFBFBD> <EFBFBD> : <EFBFBD> Ƿ <EFBFBD> ֻ <EFBFBD> <EFBFBD> ͬ һ ͼ <EFBFBD> <EFBFBD> ͼ Ԫ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ȥ <EFBFBD> <EFBFBD>
* <EFBFBD> <EFBFBD> <EFBFBD> Σ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ҳ <EFBFBD> <EFBFBD> ͬ <EFBFBD> <EFBFBD> <EFBFBD> ж <EFBFBD> Ϊ <EFBFBD> ظ <EFBFBD> ͼ Ԫ
* <EFBFBD> Ƚ <EFBFBD> ͼ Ԫ <EFBFBD> <EFBFBD> <EFBFBD> ƣ <EFBFBD> <EFBFBD> Ƿ <EFBFBD> Ҫ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͬ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϊ <EFBFBD> <EFBFBD> <EFBFBD> ظ <EFBFBD> ͼ Ԫ
*/
extern " C " __declspec ( dllexport )
void XyDeleteDupElements ( CSigmaView * pView , const wchar_t * option )
{
assert ( pView ! = nullptr ) ;
CXy * pXy = pView - > m_pDoc - > m_pXy ;
std : : string xml = WStringToString ( option ) ;
std : : optional < DeduplicateOption > dedupOption = LoadDeleteDupElementsOption ( xml ) ;
if ( ! dedupOption )
{
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʽ <EFBFBD> <CABD> <EFBFBD> <EFBFBD> ȷ<EFBFBD> <C8B7> ʹ <EFBFBD> <CAB9> Ĭ<EFBFBD> <C4AC> ֵ
dedupOption = DeduplicateOption ( ) ;
}
std : : vector < COne * > vec ;
NBase : : CPositionList delList ;
DupComparer comparer ( dedupOption . value ( ) ) ;
CPtrList * pValueList = pXy - > GetValueList ( ) ;
for ( POSITION pos = pValueList - > GetHeadPosition ( ) ; pos ! = nullptr ; pValueList - > GetNext ( pos ) )
{
COne * pOne = ( COne * ) pValueList - > GetAt ( pos ) ;
if ( ExistDuplicateElement ( vec , pOne , comparer ) )
{
delList . AddTail ( pos ) ;
}
else
{
vec . push_back ( pOne ) ;
}
}
if ( delList . GetSize ( ) > 0 )
{
pView - > m_pDoc - > SetActionItem ( new CActionDeleteItem ( pView - > m_pDoc , IDS_STRING_ACTION_DELETE , delList ) ) ;
}
}
extern " C " __declspec ( dllexport )
void SetVtkDataNodeChecked ( CSigmaView * pView , void * nodeData , bool checked )
{
KevVtkDataNode * pData = ( KevVtkDataNode * ) nodeData ;
pData - > m_checked = checked ;
}
extern " C " __declspec ( dllexport )
void SetVtkDataNodeHide ( CSigmaView * pView , void * nodeData , bool isHide )
{
KevVtkDataNode * pData = ( KevVtkDataNode * ) nodeData ;
pData - > m_hide = isHide ;
}
extern " C " __declspec ( dllexport )
void AddVtkDataNodeChild ( CSigmaView * pView , void * pParent , void * pChild )
{
KevVtkDataNode * pp = ( KevVtkDataNode * ) pParent ;
KevVtkDataNode * pc = ( KevVtkDataNode * ) pChild ;
pp - > m_childList . push_back ( pc ) ;
}
void GetClosedDefaultList ( void * pData , std : : list < void * > & curveList )
{
if ( pData = = nullptr )
return ;
KevVtkDataNode * pKevVtkData = ( KevVtkDataNode * ) pData ;
std : : list < void * > : : iterator itCurve ;
for ( itCurve = ( pKevVtkData - > m_closedFaultCCurveList ) . begin ( ) ; itCurve ! = ( pKevVtkData - > m_closedFaultCCurveList ) . end ( ) ; + + itCurve )
{
curveList . push_back ( * itCurve ) ;
}
//<2F> <> ȡ<EFBFBD> ӽڵ<D3BD> <DAB5> պ<EFBFBD> <D5BA> <EFBFBD> <EFBFBD> <EFBFBD>
std : : list < KevVtkDataNode * > : : iterator itData ;
for ( itData = ( pKevVtkData - > m_childList ) . begin ( ) ; itData ! = ( pKevVtkData - > m_childList ) . end ( ) ; + + itData )
{
GetClosedDefaultList ( * itData , curveList ) ;
}
}
void GetWellPointList ( void * pData , std : : list < KevVtkPointData * > & wellPointList )
{
if ( pData = = nullptr )
return ;
KevVtkDataNode * pKevVtkData = ( KevVtkDataNode * ) pData ;
std : : list < KevVtkPointData * > : : iterator itCurve ;
for ( itCurve = ( pKevVtkData - > m_pointList ) . begin ( ) ; itCurve ! = ( pKevVtkData - > m_pointList ) . end ( ) ; + + itCurve )
{
wellPointList . push_back ( * itCurve ) ;
}
//<2F> <> ȡ<EFBFBD> ӽڵ<D3BD> <DAB5> պ<EFBFBD> <D5BA> <EFBFBD> <EFBFBD> <EFBFBD>
std : : list < KevVtkDataNode * > : : iterator itData ;
for ( itData = ( pKevVtkData - > m_childList ) . begin ( ) ; itData ! = ( pKevVtkData - > m_childList ) . end ( ) ; + + itData )
{
GetWellPointList ( * itData , wellPointList ) ;
}
}
void GetCloseBoundaryList ( void * pData , std : : list < void * > & curveList )
{
if ( pData = = nullptr )
return ;
KevVtkDataNode * pKevVtkData = ( KevVtkDataNode * ) pData ;
std : : list < void * > : : iterator itCurve ;
for ( itCurve = ( pKevVtkData - > m_closedBoundaryList ) . begin ( ) ; itCurve ! = ( pKevVtkData - > m_closedBoundaryList ) . end ( ) ; + + itCurve )
{
curveList . push_back ( * itCurve ) ;
}
//<2F> <> ȡ<EFBFBD> ӽڵ<D3BD> <DAB5> պ<EFBFBD> <D5BA> <EFBFBD> <EFBFBD> <EFBFBD>
std : : list < KevVtkDataNode * > : : iterator itData ;
for ( itData = ( pKevVtkData - > m_childList ) . begin ( ) ; itData ! = ( pKevVtkData - > m_childList ) . end ( ) ; + + itData )
{
GetCloseBoundaryList ( * itData , curveList ) ;
}
}
extern " C " __declspec ( dllexport )
void ProcessMeshBoundary ( CSigmaView * pView , void * pRootDataNode , void * pMainMesh )
{
KevVtkDataNode * pData = ( KevVtkDataNode * ) pRootDataNode ;
KevVtkMeshData * pMeshData = ( KevVtkMeshData * ) pMainMesh ;
//<2F> ָ<EFBFBD> ԭʼ <D4AD> <CABC> <EFBFBD> <EFBFBD>
std : : list < void * > boundaryList ;
GetCloseBoundaryList ( pRootDataNode , boundaryList ) ;
CCurveEx * pCurve = nullptr ;
if ( ! boundaryList . empty ( ) )
{
pCurve = ( CCurveEx * ) ( boundaryList . front ( ) ) ;
}
int row = pMeshData - > numX ; //ÿ<> е ĵ<D0B5> <C4B5> <EFBFBD> <EFBFBD> <EFBFBD> X<EFBFBD> <58> <EFBFBD> ϵ<EFBFBD> <CFB5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
int col = pMeshData - > numY ; //ÿ<> е ĵ<D0B5> <C4B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Y<EFBFBD> <59> <EFBFBD> ϵ<EFBFBD> <CFB5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( boundaryList . size ( ) < 1 )
{
return ;
}
//#pragma omp parallel for
for ( long j = 0 ; j < col ; j + + )
{
for ( long i = 0 ; i < row ; i + + )
{
long k = 0 ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
long pi = 0 ;
double x = 0 , y = 0 , z = 0 ;
pi = j * row + i ; //<2F> 㼯<EFBFBD> <E3BCAF> <EFBFBD> <EFBFBD>
x = pMeshData - > P0 [ 0 ] + pMeshData - > delt [ 0 ] * ( i ) ;
y = pMeshData - > P0 [ 1 ] + pMeshData - > delt [ 1 ] * ( j ) ;
z = pMeshData - > shadow_u [ pi ] ;
std : : list < void * > : : iterator itCurve ;
bool isInside = false ;
if ( pCurve )
{
if ( pCurve - > IsInside ( x , y ) )
{
isInside = true ;
}
}
if ( ! isInside )
{
pMeshData - > shadow_u [ pi ] = - 1e100 ;
}
}
}
////<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//std::list<KevVtkPointData*> tempList;
//GetWellPointList(pData, tempList);
//for (KevVtkPointData* point : tempList) {
// if (point != nullptr) {
// //ֻȡ<D6BB> <C8A1> һ <EFBFBD> <D2BB> <EFBFBD> ߽<EFBFBD> <DFBD> <EFBFBD>
// if (pCurve)
// {
// if (pCurve->IsInside(point->m_x, point->m_y))
// {
// pData->m_pointList.push_back(point);
// }
// }
// }
//}
}
extern " C " __declspec ( dllexport )
void ProcessMeshFaultArea ( CSigmaView * pView , void * pRootDataNode , void * pMainMesh )
{
KevVtkDataNode * pData = ( KevVtkDataNode * ) pRootDataNode ;
KevVtkMeshData * pMeshData = ( KevVtkMeshData * ) pMainMesh ;
std : : list < void * > faultList ;
GetClosedDefaultList ( pRootDataNode , faultList ) ;
int row = pMeshData - > numX ; //ÿ<> е ĵ<D0B5> <C4B5> <EFBFBD> <EFBFBD> <EFBFBD> X<EFBFBD> <58> <EFBFBD> ϵ<EFBFBD> <CFB5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
int col = pMeshData - > numY ; //ÿ<> е ĵ<D0B5> <C4B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Y<EFBFBD> <59> <EFBFBD> ϵ<EFBFBD> <CFB5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( faultList . size ( ) < 1 )
{
return ;
}
//#pragma omp parallel for
for ( long j = 0 ; j < col ; j + + )
{
for ( long i = 0 ; i < row ; i + + )
{
long k = 0 ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
long pi = 0 ;
double x = 0 , y = 0 , z = 0 ;
pi = j * row + i ; //<2F> 㼯<EFBFBD> <E3BCAF> <EFBFBD> <EFBFBD>
x = pMeshData - > P0 [ 0 ] + pMeshData - > delt [ 0 ] * ( i ) ;
y = pMeshData - > P0 [ 1 ] + pMeshData - > delt [ 1 ] * ( j ) ;
z = pMeshData - > shadow_u [ pi ] ;
//<2F> ߽<EFBFBD> <DFBD> <EFBFBD> <EFBFBD> ĵ㲻<C4B5> <E3B2BB> <EFBFBD> <EFBFBD>
if ( std : : fabs ( z - ( - 1e100 ) ) < 1e-6 )
{
continue ;
}
std : : list < void * > : : iterator itCurve ;
for ( itCurve = ( faultList ) . begin ( ) ; itCurve ! = ( faultList ) . end ( ) ; + + itCurve )
{
CCurveEx * pCurve = ( CCurveEx * ) ( * itCurve ) ;
if ( pCurve - > IsInside ( x , y ) )
{
pMeshData - > shadow_u [ pi ] = - 1e99 ;
break ;
}
}
}
}
}
extern " C " __declspec ( dllexport )
bool SaveMergeMesh ( CSigmaView * pView , void * pMesh , const char * filename )
{
CXy * pXy = pView - > m_pDoc - > m_pXy ;
KepVtkMeshData * pKepVtkMesh = ( KepVtkMeshData * ) pMesh ;
if ( pKepVtkMesh )
{
CMesh * mesh = new CMesh ;
CDimension3D * pdfg = new CDimension3D ;
pdfg - > CDimension2D : : Create ( pKepVtkMesh - > numX , pKepVtkMesh - > numY , pKepVtkMesh - > x0 , pKepVtkMesh - > y0 , pKepVtkMesh - > dx , pKepVtkMesh - > dy ) ;
pdfg - > range [ 0 ] = pKepVtkMesh - > range [ 0 ] ;
pdfg - > range [ 1 ] = pKepVtkMesh - > range [ 1 ] ;
pdfg - > total = pKepVtkMesh - > numX * pKepVtkMesh - > numY ;
std : : memcpy ( pdfg - > u , pKepVtkMesh - > u , pdfg - > total * sizeof ( double ) ) ;
/*for (int j = 0; j < pKepVtkMesh->numY; j++)
{
for ( int i = 0 ; i < pKepVtkMesh - > numX ; i + + )
{
m_pDfg - > SetValue ( i , j , pSurface - > m_pData [ j * pSurface - > numx + i ] ) ;
}
} */
mesh - > m_nTimes = 1 ;
mesh - > SetMesh ( pdfg , MESH_DFG , false , - DBL_MAX ) ;
/*mesh->SetMeshType(MESH_DFG);
mesh - > Attach ( pdfg , CMesh : : typeDFG ) ; */
COne * pOne = new COne ;
pOne - > SetValue ( mesh , DOUBLEFOX_MESH ) ;
pXy - > AddTailOne ( pOne ) ;
//mesh->SetM(pKepVtkMesh->m_zMin, pKepVtkMesh->m_zMax);
//mesh->GetMesh()->P0[0] = pKepVtkMesh->x0;
//mesh->GetMesh()->P0[1] = pKepVtkMesh->y0;
//mesh->GetMesh()->n = 2;
//mesh->GetMesh()->delt[0] = pKepVtkMesh->dx;
//mesh->GetMesh()->delt[1] = pKepVtkMesh->dy;
//mesh->GetMesh()->num[0] = pKepVtkMesh->numX;
//mesh->GetMesh()->num[1] = pKepVtkMesh->numY;
//mesh->GetMesh()->range[0] = pKepVtkMesh->range[0];
//mesh->GetMesh()->range[1] = pKepVtkMesh->range[1];
//if (pdfg == NULL)
// return false;
//pdfg->n = 2;
//pdfg->num[0] = pKepVtkMesh->num[0];
//pdfg->num[1] = pKepVtkMesh->num[1];
//pdfg->P0[0] = pKepVtkMesh->P0[0];
//pdfg->P0[1] = pKepVtkMesh->P0[1];
//pdfg->delt[0] = pKepVtkMesh->delt[0];
//pdfg->delt[1] = pKepVtkMesh->delt[1];
//pdfg->range[0] = pKepVtkMesh->range[0];
//pdfg->range[1] = pKepVtkMesh->range[1];
//pdfg->u = new double[pKepVtkMesh->numX * pKepVtkMesh->numY];
//std::memcpy(pdfg->u, pKepVtkMesh->u, pdfg->total * sizeof(double));
}
pView - > m_pDoc - > SaveFile ( filename ) ;
return true ;
}
extern " C " __declspec ( dllexport )
void * GetKevFirstMesh ( CSigmaView * pView )
{
CXy * pXy = pView - > m_pDoc - > m_pXy ;
NBase : : CPositionList positionList ;
// <20> <> ȡ<EFBFBD> <C8A1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <F3A3ACB0> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ɱ༭<C9B1> <E0BCAD> Ԫ<EFBFBD> <D4AA>
pXy - > GetElement ( DOUBLEFOX_MESH , positionList , true ) ;
POSITION posCurrent = positionList . GetHeadPosition ( ) ;
POSITION posFirstFind = nullptr ;
while ( posCurrent ! = NULL )
{
// <20> <> <EFBFBD> <EFBFBD> 3: ʹ <> <CAB9> GetNext <20> <> ȡ<EFBFBD> <C8A1> ǰ<EFBFBD> <C7B0> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> λ<EFBFBD> õ<EFBFBD> Ԫ<EFBFBD> أ<EFBFBD> <D8A3> <EFBFBD> <EFBFBD> õ<EFBFBD> <C3B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB> λ<EFBFBD> <CEBB>
// ע<> ⣺<EFBFBD> <E2A3BA> <EFBFBD> <EFBFBD> GetNext <20> <> <EFBFBD> ص<EFBFBD> <D8B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 洢<EFBFBD> <E6B4A2> POSITION Ԫ<> أ<EFBFBD> <D8A3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> posCurrent <20> ᱻ<EFBFBD> Զ<EFBFBD> <D4B6> <EFBFBD> <EFBFBD> <EFBFBD>
POSITION posElement = positionList . GetNext ( posCurrent ) ;
COne * tempOne = pXy - > GetAt ( posElement ) ;
CLayer * layer = tempOne - > GetLayer ( ) ;
BYTE state = layer - > GetState ( ) ;
if ( state ! = 12 )
{
posFirstFind = posElement ;
break ;
}
}
//ֱ<> <D6B1> <EFBFBD> ҵ<EFBFBD> һ <EFBFBD> <D2BB> Ԫ<EFBFBD> أ<EFBFBD> <D8A3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ҵ<EFBFBD> <D2B5> <EFBFBD> <EFBFBD> ǷDZ༭<C7B1> <E0BCAD> <EFBFBD> ɼ<EFBFBD> Ԫ<EFBFBD> <D4AA>
//POSITION posFirstFind = pXy->FindFirstElement(DOUBLEFOX_MESH);
if ( posFirstFind = = nullptr )
{
return nullptr ;
}
COne * pOne = pXy - > GetAt ( posFirstFind ) ;
CString layerStr = pOne - > GetLayerName ( ) ;
CMesh * pMesh = ( CMesh * ) pOne - > GetValue ( ) ;
KevVtkMeshData * pKevVtkMesh = nullptr ;
if ( pMesh ! = nullptr )
{
pKevVtkMesh = new KevVtkMeshData ;
pKevVtkMesh - > m_layerName = layerStr ;
double zmin , zmax ;
pMesh - > GetM ( zmin , zmax ) ;
pKevVtkMesh - > m_zMin = zmin ;
pKevVtkMesh - > m_zMax = zmax ;
double x0 , y0 ;
pMesh - > GetOrg ( x0 , y0 ) ;
pKevVtkMesh - > x0 = x0 ;
pKevVtkMesh - > y0 = y0 ;
double dx , dy ;
pMesh - > GetDelt ( dx , dy ) ;
pKevVtkMesh - > dx = dx ;
pKevVtkMesh - > dy = dy ;
CGrid * pGrid = pMesh - > GetMesh ( ) ;
long numX = pGrid - > xnum ( ) ;
long numY = pGrid - > ynum ( ) ;
pKevVtkMesh - > numX = numX ;
pKevVtkMesh - > numY = numY ;
CDimension3D * pdfg = pMesh - > GetDfg ( ) ;
if ( pdfg = = NULL )
return nullptr ;
pKevVtkMesh - > n = pdfg - > n ;
pKevVtkMesh - > num = pdfg - > num ;
pKevVtkMesh - > P0 = pdfg - > P0 ;
pKevVtkMesh - > delt = pdfg - > delt ;
pKevVtkMesh - > range = pdfg - > range ;
pKevVtkMesh - > origin_u = pdfg - > u ;
pKevVtkMesh - > shadow_u = new double [ pdfg - > total ] ;
std : : memcpy ( pKevVtkMesh - > shadow_u , pdfg - > u , pdfg - > total * sizeof ( double ) ) ;
for ( int i = 0 ; i < pMesh - > color . sizeColor ( ) ; i + + )
{
CColorItem & item = pMesh - > color . GetColorItem ( i ) ;
KevVtkColorItem * pColorItem = new KevVtkColorItem ( ) ;
pColorItem - > z = item . z ;
pColorItem - > color [ 0 ] = item . color . rgbRed ;
pColorItem - > color [ 1 ] = item . color . rgbGreen ;
pColorItem - > color [ 2 ] = item . color . rgbBlue ;
pColorItem - > color [ 3 ] = item . color . rgbReserved ;
pColorItem - > gradient = item . m_bContinue ;
pKevVtkMesh - > m_colorList . push_back ( pColorItem ) ;
}
}
return pKevVtkMesh ;
}
extern " C " __declspec ( dllexport )
void * GetFirstMesh ( CSigmaView * pView )
{
CXy * pXy = pView - > m_pDoc - > m_pXy ;
POSITION pt = pXy - > FindFirstElement ( DOUBLEFOX_MESH ) ;
if ( pt = = nullptr )
{
return nullptr ;
}
COne * pOne = pXy - > GetAt ( pt ) ;
CString layerStr = pOne - > GetLayerName ( ) ;
CMesh * pMesh = ( CMesh * ) pOne - > GetValue ( ) ;
KepVtkMeshData * pKepVtkMesh = nullptr ;
if ( pMesh ! = nullptr )
{
pKepVtkMesh = new KepVtkMeshData ;
pKepVtkMesh - > m_layerName = layerStr ;
double zmin , zmax ;
pMesh - > GetM ( zmin , zmax ) ;
pKepVtkMesh - > m_zMin = zmin ;
pKepVtkMesh - > m_zMax = zmax ;
double x0 , y0 ;
pMesh - > GetOrg ( x0 , y0 ) ;
pKepVtkMesh - > x0 = x0 ;
pKepVtkMesh - > y0 = y0 ;
double dx , dy ;
pMesh - > GetDelt ( dx , dy ) ;
pKepVtkMesh - > dx = dx ;
pKepVtkMesh - > dy = dy ;
CGrid * pGrid = pMesh - > GetMesh ( ) ;
long numX = pGrid - > xnum ( ) ;
long numY = pGrid - > ynum ( ) ;
pKepVtkMesh - > numX = numX ;
pKepVtkMesh - > numY = numY ;
CDimension3D * pdfg = pMesh - > GetDfg ( ) ;
if ( pdfg = = NULL )
return nullptr ;
pKepVtkMesh - > n = pdfg - > n ;
pKepVtkMesh - > num [ 0 ] = pdfg - > num [ 0 ] ;
pKepVtkMesh - > num [ 1 ] = pdfg - > num [ 1 ] ;
pKepVtkMesh - > P0 [ 0 ] = pdfg - > P0 [ 0 ] ;
pKepVtkMesh - > P0 [ 1 ] = pdfg - > P0 [ 1 ] ;
pKepVtkMesh - > delt [ 0 ] = pdfg - > delt [ 0 ] ;
pKepVtkMesh - > delt [ 1 ] = pdfg - > delt [ 1 ] ;
pKepVtkMesh - > range [ 0 ] = pdfg - > range [ 0 ] ;
pKepVtkMesh - > range [ 1 ] = pdfg - > range [ 1 ] ;
pKepVtkMesh - > u = new double [ pdfg - > total ] ;
std : : memcpy ( pKepVtkMesh - > u , pdfg - > u , pdfg - > total * sizeof ( double ) ) ;
for ( int i = 0 ; i < pMesh - > color . sizeColor ( ) ; i + + )
{
CColorItem & item = pMesh - > color . GetColorItem ( i ) ;
KevVtkColorItem * pColorItem = new KevVtkColorItem ( ) ;
pColorItem - > z = item . z ;
pColorItem - > color [ 0 ] = item . color . rgbRed ;
pColorItem - > color [ 1 ] = item . color . rgbGreen ;
pColorItem - > color [ 2 ] = item . color . rgbBlue ;
pColorItem - > color [ 3 ] = item . color . rgbReserved ;
pColorItem - > gradient = item . m_bContinue ;
pKepVtkMesh - > m_colorList . push_back ( pColorItem ) ;
}
}
return pKepVtkMesh ;
}
std : : vector < std : : string > split ( const std : : string & s , char delimiter )
{
std : : vector < std : : string > tokens ;
std : : stringstream ss ( s ) ;
std : : string token ;
while ( std : : getline ( ss , token , delimiter ) )
{
tokens . push_back ( token ) ;
}
return tokens ;
}
void GetLayerClosedCurveList ( CSigmaView * pView , LPCTSTR layerName , std : : list < CCurveEx * > & closedCurveList )
{
CXy * pXy = pView - > m_pDoc - > GetDraw ( ) ;
if ( pXy = = nullptr )
return ;
NBase : : CPositionList elements ;
//<2F> <> ȡͼ<C8A1> <CDBC> <EFBFBD> е <EFBFBD> <D0B5> <EFBFBD> <EFBFBD> <EFBFBD> Ԫ<EFBFBD> أ<EFBFBD> <D8A3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͼ<EFBFBD> <CDBC> , <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ɱ༭
pXy - > GetElement ( layerName , elements , false , TRUE ) ;
POSITION p = nullptr ;
COne * pOne = nullptr ;
POSITION pos ;
pos = elements . GetHeadPosition ( ) ;
while ( pos )
{
p = elements . GetNext ( pos ) ;
pOne = ( COne * ) pXy - > GetValueList ( ) - > GetAt ( p ) ;
int type = pOne - > GetType ( ) ;
switch ( type )
{
case DOUBLEFOX_CURVE :
{
CCurveEx * pCurve = ( CCurveEx * ) pOne - > GetValue ( ) ;
if ( pCurve - > IsClosed ( ) )
{
closedCurveList . push_back ( pCurve ) ;
}
}
break ;
default :
break ;
}
}
}
extern " C " __declspec ( dllexport )
void PreProcessMeshData ( CSigmaView * pView , void * pKevMeshData , const char * faultLayers , const char * boundaryLayer )
{
if ( pKevMeshData = = nullptr )
{
return ;
}
// <20> <> ȡͼ<C8A1> <CDBC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
CXy * pXy = pView - > m_pDoc - > m_pXy ;
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ϲ <EFBFBD> ͼ<EFBFBD> <CDBC> <EFBFBD> ַ<EFBFBD> <D6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ԡ<EFBFBD> <D4A1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ָ<EFBFBD>
std : : string faultStr = std : : string ( faultLayers ) ;
std : : vector < std : : string > faultVec = split ( faultStr , ' ; ' ) ;
std : : list < CCurveEx * > faultClosedCurveList ;
//<2F> <> ȡ<EFBFBD> ϲ <EFBFBD> ͼ<EFBFBD> <CDBC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> б պ<D0B1> <D5BA> <EFBFBD> <EFBFBD> <EFBFBD>
for ( int i = 0 ; i < faultVec . size ( ) ; i + + )
{
GetLayerClosedCurveList ( pView , faultVec [ i ] . c_str ( ) , faultClosedCurveList ) ;
}
//<2F> <> ȡ<EFBFBD> ߽<EFBFBD> ͼ<EFBFBD> <CDBC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> б պ<D0B1> <D5BA> <EFBFBD> <EFBFBD> <EFBFBD>
std : : list < CCurveEx * > boundaryClosedCurveList ;
GetLayerClosedCurveList ( pView , boundaryLayer , boundaryClosedCurveList ) ;
KepVtkMeshData * pMeshData = ( KepVtkMeshData * ) ( pKevMeshData ) ;
int numx = pMeshData - > numX ; //ÿ<> е ĵ<D0B5> <C4B5> <EFBFBD> <EFBFBD> <EFBFBD> X<EFBFBD> <58> <EFBFBD> ϵ<EFBFBD> <CFB5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
int numy = pMeshData - > numY ; //ÿ<> е ĵ<D0B5> <C4B5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Y<EFBFBD> <59> <EFBFBD> ϵ<EFBFBD> <CFB5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> zֵ<7A> д<EFBFBD> <D0B4> ŵ<EFBFBD>
//<2F> <> <EFBFBD> ȴ<EFBFBD> <C8B4> <EFBFBD> <EFBFBD> ߽<EFBFBD> <DFBD> <EFBFBD>
if ( boundaryClosedCurveList . size ( ) > 0 )
{
CCurveEx * pCurve = boundaryClosedCurveList . front ( ) ;
//#pragma omp parallel for
for ( long j = 0 ; j < numy ; j + + )
{
for ( long i = 0 ; i < numx ; i + + )
{
long k = 0 ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
long pi = 0 ;
double x = 0 , y = 0 , z = 0 ;
pi = j * numx + i ; //<2F> 㼯<EFBFBD> <E3BCAF> <EFBFBD> <EFBFBD>
x = pMeshData - > P0 [ 0 ] + pMeshData - > delt [ 0 ] * ( i ) ;
y = pMeshData - > P0 [ 1 ] + pMeshData - > delt [ 1 ] * ( j ) ;
z = pMeshData - > u [ pi ] ;
std : : list < void * > : : iterator itCurve ;
bool isInside = false ;
if ( pCurve - > IsInside ( x , y ) )
{
;
}
else
{
// <20> ߽<EFBFBD> <DFBD> <EFBFBD> <EFBFBD> ĵ㣬zֵ<7A> <D6B5> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> С <EFBFBD> ĸ<EFBFBD> <C4B8> <EFBFBD>
pMeshData - > u [ pi ] = - DBL_MAX ; // ԭʼ <D4AD> <CABC> <EFBFBD> ݱ<EFBFBD> Ԥ<EFBFBD> <D4A4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʹ <EFBFBD> <CAB9> Ӱ<EFBFBD> <D3B0> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
}
}
}
}
//TOD0:<3A> <> <EFBFBD> <EFBFBD> #pragma omp parallel for<6F> <72> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB> <EFBFBD> <EFBFBD> ͬ<EFBFBD> <CDAC>
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> ϲ <EFBFBD> <CFB2> <EFBFBD>
//#pragma omp parallel for
for ( long j = 0 ; j < numy ; j + + )
{
for ( long i = 0 ; i < numx ; i + + )
{
long k = 0 ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
long pi = 0 ;
double x = 0 , y = 0 , z = 0 ;
pi = j * numx + i ; //<2F> 㼯<EFBFBD> <E3BCAF> <EFBFBD> <EFBFBD>
x = pMeshData - > P0 [ 0 ] + pMeshData - > delt [ 0 ] * ( i ) ;
y = pMeshData - > P0 [ 1 ] + pMeshData - > delt [ 1 ] * ( j ) ;
z = pMeshData - > u [ pi ] ;
if ( abs ( z - ( - 1e8 ) ) < 1e-3 )
{
continue ;
}
std : : list < CCurveEx * > : : iterator itCurve ;
// x,y <20> <> <EFBFBD> κ<EFBFBD> һ <EFBFBD> <D2BB> <EFBFBD> ϲ 㷶Χ <E3B7B6> ڣ<EFBFBD> <DAA3> õ<EFBFBD> Zֵ<5A> <D6B5> Ϊ<EFBFBD> <CEAA> С <EFBFBD> <D0A1> <EFBFBD> <EFBFBD>
for ( itCurve = ( faultClosedCurveList ) . begin ( ) ; itCurve ! = ( faultClosedCurveList ) . end ( ) ; + + itCurve )
{
CCurveEx * pCurve = ( CCurveEx * ) ( * itCurve ) ;
if ( pCurve - > IsInside ( x , y ) )
{
pMeshData - > u [ pi ] = - DBL_MAX ;
break ;
}
}
}
}
}
extern " C " __declspec ( dllexport )
void * GetLayerData ( CSigmaView * pView , LPCTSTR layerName , bool bBoundaryLayer , bool bFaultLayer , bool bWellLayer )
{
KevVtkDataNode * pData = new KevVtkDataNode ( ) ;
pData - > m_layerName = layerName ;
pData - > m_bBorderLayer = bBoundaryLayer ;
pData - > m_bFaultLayer = bFaultLayer ;
pData - > m_bWellLayer = bWellLayer ;
CXy * pXy = pView - > m_pDoc - > GetDraw ( ) ;
if ( pXy = = nullptr )
return pData ;
NBase : : CPositionList elements ;
//<2F> <> ȡͼ<C8A1> <CDBC> Ԫ<EFBFBD> أ<EFBFBD> <D8A3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͼ<EFBFBD> <CDBC>
pXy - > GetElement ( layerName , elements , false ) ;
POSITION p = nullptr ;
COne * pOne = nullptr ;
POSITION pos ;
pos = elements . GetHeadPosition ( ) ;
while ( pos )
{
p = elements . GetNext ( pos ) ;
pOne = ( COne * ) pXy - > GetValueList ( ) - > GetAt ( p ) ;
int type = pOne - > GetType ( ) ;
switch ( type )
{
case DOUBLEFOX_POINT :
{
KevVtkPointData * pKevVtkPoint = new KevVtkPointData ;
CPointNameEx * pPoint = ( CPointNameEx * ) pOne - > GetValue ( ) ;
pKevVtkPoint - > m_name = pPoint - > GetName ( ) . GetString ( ) ;
pKevVtkPoint - > m_x = pPoint - > x0 ;
pKevVtkPoint - > m_y = pPoint - > y0 ;
pKevVtkPoint - > m_z = pPoint - > z0 ;
pKevVtkPoint - > m_layerName = layerName ;
pData - > m_pointList . push_back ( pKevVtkPoint ) ;
}
break ;
case DOUBLEFOX_CURVE :
{
KevVtkCurveData * pKevVtkCurve = new KevVtkCurveData ;
CCurveEx * pCurve = ( CCurveEx * ) pOne - > GetValue ( ) ;
pKevVtkCurve - > m_layerName = layerName ;
pKevVtkCurve - > m_name = pCurve - > GetName ( ) . GetString ( ) ;
pKevVtkCurve - > x = pCurve - > x ;
pKevVtkCurve - > y = pCurve - > y ;
pKevVtkCurve - > z = pCurve - > z ;
pKevVtkCurve - > l = pCurve - > l ;
pKevVtkCurve - > m_num = pCurve - > num ;
pKevVtkCurve - > m_nPoint = pCurve - > nPoint ;
pKevVtkCurve - > isClosed = pCurve - > IsClosed ( ) ;
pData - > m_curveList . push_back ( pKevVtkCurve ) ;
if ( bFaultLayer )
{
if ( pCurve - > IsClosed ( ) )
{
pData - > m_closedFaultCCurveList . push_back ( pCurve ) ;
pData - > m_closedFaultVtkCurveList . push_back ( pKevVtkCurve ) ;
}
else
{
pData - > m_singleFaultVtkCurveList . push_back ( pKevVtkCurve ) ;
}
}
if ( bBoundaryLayer )
{
if ( pCurve - > IsClosed ( ) )
{
pData - > m_closedBoundaryVtkCurveList . push_back ( pKevVtkCurve ) ;
pData - > m_closedBoundaryList . push_back ( pCurve ) ;
}
}
}
break ;
case DOUBLEFOX_MESH :
{
KevVtkMeshData * pKevVtkMesh = new KevVtkMeshData ;
CMesh * pMesh = ( CMesh * ) pOne - > GetValue ( ) ;
double zmin , zmax ;
pMesh - > GetM ( zmin , zmax ) ;
pKevVtkMesh - > m_zMin = zmin ;
pKevVtkMesh - > m_zMax = zmax ;
double x0 , y0 ;
pMesh - > GetOrg ( x0 , y0 ) ;
pKevVtkMesh - > x0 = x0 ;
pKevVtkMesh - > y0 = y0 ;
double dx , dy ;
pMesh - > GetDelt ( dx , dy ) ;
pKevVtkMesh - > dx = dx ;
pKevVtkMesh - > dy = dy ;
CGrid * pGrid = pMesh - > GetMesh ( ) ;
long numX = pGrid - > xnum ( ) ;
long numY = pGrid - > ynum ( ) ;
pKevVtkMesh - > numX = numX ;
pKevVtkMesh - > numY = numY ;
CDimension3D * pdfg = pMesh - > GetDfg ( ) ;
if ( pdfg = = NULL )
return nullptr ;
pKevVtkMesh - > num = pdfg - > num ;
pKevVtkMesh - > P0 = pdfg - > P0 ;
pKevVtkMesh - > delt = pdfg - > delt ;
double * pShadow = new double [ pdfg - > total ] ;
std : : memcpy ( pShadow , pdfg - > u , pdfg - > total * sizeof ( double ) ) ;
pKevVtkMesh - > shadow_u = pShadow ;
pKevVtkMesh - > origin_u = pdfg - > u ;
pKevVtkMesh - > range = pdfg - > range ;
pKevVtkMesh - > n = pdfg - > n ;
pKevVtkMesh - > m_layerName = layerName ;
pKevVtkMesh - > id = pMesh - > GetId ( ) ;
pData - > m_meshList . push_back ( pKevVtkMesh ) ;
CColorBase & color = pMesh - > color ;
for ( int i = 0 ; i < color . sizeColor ( ) ; i + + )
{
CColorItem & item = color . GetColorItem ( i ) ;
KevVtkColorItem * pColorItem = new KevVtkColorItem ( ) ;
pColorItem - > z = item . z ;
pColorItem - > color [ 0 ] = item . color . rgbRed ;
pColorItem - > color [ 1 ] = item . color . rgbGreen ;
pColorItem - > color [ 2 ] = item . color . rgbBlue ;
pColorItem - > color [ 3 ] = item . color . rgbReserved ;
pColorItem - > gradient = item . m_bContinue ;
pKevVtkMesh - > m_colorList . push_back ( pColorItem ) ;
}
}
break ;
case DOUBLEFOX_IMAGE :
{
KevVtkImageData * pKevVtkImage = new KevVtkImageData ;
CImageInsert * pImage = ( CImageInsert * ) pOne - > GetValue ( ) ;
pKevVtkImage - > m_x = pImage - > x0 ;
pKevVtkImage - > m_y = pImage - > y0 ;
pKevVtkImage - > m_width = pImage - > m_size . cx ;
pKevVtkImage - > m_height = pImage - > m_size . cy ;
auto now = std : : chrono : : high_resolution_clock : : now ( ) ;
auto tick = std : : chrono : : duration_cast < std : : chrono : : milliseconds > ( now . time_since_epoch ( ) ) . count ( ) ;
std : : string fileName = std : : to_string ( tick ) + " .png " ;
pData - > m_imageList . push_back ( pKevVtkImage ) ;
//pImage->SaveAs(fileName.c_str());
pKevVtkImage - > m_fileName = fileName ;
pKevVtkImage - > m_layerName = layerName ;
}
break ;
default :
break ;
}
}
return pData ;
}
extern " C " __declspec ( dllexport )
void DestroyAndInsertElement ( CSigmaView * pView , int64_t * destroyArray , int32_t destroyLength , int64_t * insertArray , int32_t insertLength )
{
if ( pView = = nullptr )
{
TRACE ( " pView <20> <> <EFBFBD> <EFBFBD> Ϊ nullptr \n " ) ;
return ;
}
if ( destroyArray = = nullptr )
{
TRACE ( " destroyArray <20> <> <EFBFBD> <EFBFBD> Ϊ nullptr \n " ) ;
return ;
}
if ( insertArray = = nullptr )
{
TRACE ( " addArray <20> <> <EFBFBD> <EFBFBD> Ϊ nullptr \n " ) ;
return ;
}
auto pComboAction = std : : make_unique < CActionComboItem > ( pView - > m_pDoc , 0 ) ;
CPositionList insertPositions ;
for ( int32_t i = 0 ; i < insertLength ; i + + )
{
POSITION pos = reinterpret_cast < POSITION > ( insertArray [ i ] ) ;
insertPositions . AddTail ( pos ) ;
}
auto pAddAction = std : : make_unique < CActionAddItem > ( pView - > m_pDoc , IDS_STRING_ACTION_ADD , insertPositions ) ;
pAddAction - > Do ( ) ;
pComboAction - > AddAction ( pAddAction . release ( ) ) ;
CPositionList destroyPositions ;
for ( int32_t i = 0 ; i < destroyLength ; i + + )
{
POSITION pos = reinterpret_cast < POSITION > ( destroyArray [ i ] ) ;
destroyPositions . AddTail ( pos ) ;
}
CXy * pXy = pView - > m_pDoc - > m_pXy ;
auto pDeleteAction = std : : make_unique < CActionDeleteItem > ( pView - > m_pDoc , IDS_STRING_ACTION_DELETE , destroyPositions ) ;
pDeleteAction - > Do ( ) ;
pComboAction - > AddAction ( pDeleteAction . release ( ) ) ;
pView - > m_pDoc - > SetActionItem ( pComboAction . release ( ) ) ;
}
extern " C " __declspec ( dllexport )
void ReverseCurveAndMeshZValue ( CSigmaView * pView )
{
ASSERT ( pView ! = nullptr ) ;
CXyElementFilter filter ;
filter . addType ( DOUBLEFOX_CURVE ) ;
filter . addType ( DOUBLEFOX_MESH ) ;
NBase : : CPositionList reversedList ;
pView - > m_pDoc - > m_pXy - > GetElement ( filter , reversedList ) ;
auto * pActionItem = new CActionReverseZItem ( pView - > m_pDoc , 0 , reversedList ) ;
pView - > m_pDoc - > SetActionItem ( pActionItem ) ;
}
/**
* <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ԥ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ļ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ŀ ¼
*
* \ param dirPath
*/
extern " C " __declspec ( dllexport )
void FileUtility_SetStartupDirectory ( const wchar_t * dirPath )
{
SetApplicationStartupDirectory ( CString ( dirPath ) ) ;
}
extern " C " __declspec ( dllexport )
void EnableSnap ( CSigmaView * pView , bool enable )
{
if ( pView = = nullptr | | pView - > m_pDoc = = nullptr )
{
TRACE ( " pView <20> <> pView->m_pDoc <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϊ nullptr \n " ) ;
return ;
}
pView - > m_pDoc - > EnableSnap ( enable ) ;
}
/**
* ɾ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ƥ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
*
* \ param settings <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʱ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> һ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> и <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ٿ <EFBFBD> <EFBFBD> <EFBFBD> ʹ <EFBFBD> <EFBFBD> json ֮ <EFBFBD> <EFBFBD>
*/
extern " C " __declspec ( dllexport )
void SetEraserSettings ( CSigmaView * pView , const LPCTSTR settings )
{
if ( pView = = nullptr )
{
return ;
}
NItem : : CItem * pItem = pView - > m_pDoc - > GetItem ( ) ;
if ( pItem = = nullptr )
{
return ;
}
CItemEraser * pItemEraser = dynamic_cast < CItemEraser * > ( pItem ) ;
if ( pItemEraser = = nullptr )
{
return ;
}
CString normal = _T ( " Normal " ) ;
CString segments = _T ( " Segments " ) ;
CString nodes = _T ( " Nodes " ) ;
if ( normal . CompareNoCase ( settings ) = = 0 )
{
pItemEraser - > SetEraserMode ( EraserMode : : Normal ) ;
}
else if ( segments . CompareNoCase ( settings ) = = 0 )
{
pItemEraser - > SetEraserMode ( EraserMode : : Segments ) ;
}
else if ( nodes . CompareNoCase ( settings ) = = 0 )
{
pItemEraser - > SetEraserMode ( EraserMode : : Nodes ) ;
}
}
extern " C " __declspec ( dllexport )
void RegisterListener ( CSigmaView * pView , Listener listener )
{
if ( pView ! = nullptr )
{
pView - > RegisterListener ( listener ) ;
}
}
template < typename T >
static std : : unique_ptr < ObjectProxy > GetObjectProxy ( CSigmaView * pView )
{
auto expected = TryGetItemCast < T > ( pView ) ;
if ( expected . has_value ( ) )
{
return GetInstace < ObjectProxyFactory > ( ) . Create ( typeid ( T ) . name ( ) , expected . value ( ) ) ;
}
else
{
TRACE ( " %s \n " , expected . error ( ) ) ;
return nullptr ;
}
}
/**
* <EFBFBD> <EFBFBD> ȡ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> д һ <EFBFBD> 㣬 <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
*
* \ param pView
* \ param itemName
* \ return
*/
static std : : unique_ptr < ObjectProxy > GetObjectProxy ( CSigmaView * pView , const CString & itemName )
{
if ( itemName = = " ItemEraser " )
{
CItem * pItem = pView - > m_pDoc - > GetItem ( ) ;
CItemEraser * pItemEraser = dynamic_cast < CItemEraser * > ( pItem ) ;
if ( pItemEraser ! = nullptr )
{
return std : : make_unique < CItemEraserProxy > ( pItemEraser ) ;
}
}
return nullptr ;
}
/**
* <EFBFBD> <EFBFBD> ȡ Item <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
*
* \ param itemName item <EFBFBD> <EFBFBD> <EFBFBD> ƣ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ҫ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ķ <EFBFBD> <EFBFBD> <EFBFBD>
* \ param property <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
* \ return <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֵ <EFBFBD> <EFBFBD> ȫ <EFBFBD> <EFBFBD> ʹ <EFBFBD> <EFBFBD> <EFBFBD> ַ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͨ <EFBFBD> ã <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ǰ item <EFBFBD> <EFBFBD> Ӧ <EFBFBD> <EFBFBD> <EFBFBD> ϣ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ؿ <EFBFBD> <EFBFBD> ַ <EFBFBD> <EFBFBD> <EFBFBD>
*/
extern " C " __declspec ( dllexport )
BSTR GetSigmaViewItemProperty ( CSigmaView * pView , const LPCTSTR itemName , const LPCTSTR property )
{
if ( pView = = nullptr | | pView - > m_pDoc = = nullptr )
{
TRACE ( " pView <20> <> pView->m_pDoc <20> <> <EFBFBD> <EFBFBD> Ϊ nullptr \n " ) ;
return nullptr ;
}
auto proxy = GetObjectProxy ( pView , itemName ) ;
if ( proxy )
{
return proxy - > GetProperty ( property ) . AllocSysString ( ) ;
}
else
{
return nullptr ;
}
}
/**
* <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Item <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
*
* \ param itemName item <EFBFBD> <EFBFBD> <EFBFBD> ƣ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ҫ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ķ <EFBFBD> <EFBFBD> <EFBFBD>
* \ param property <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
* \ return <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֵ <EFBFBD> <EFBFBD> ȫ <EFBFBD> <EFBFBD> ʹ <EFBFBD> <EFBFBD> <EFBFBD> ַ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͨ <EFBFBD> <EFBFBD>
*/
extern " C " __declspec ( dllexport )
void SetSigmaViewItemProperty ( CSigmaView * pView , const LPCTSTR itemName , const LPCTSTR property , const LPCTSTR value )
{
if ( pView = = nullptr | | pView - > m_pDoc = = nullptr )
{
TRACE ( " pView <20> <> pView->m_pDoc <20> <> <EFBFBD> <EFBFBD> Ϊ nullptr \n " ) ;
return ;
}
auto proxy = GetObjectProxy ( pView , itemName ) ;
if ( proxy )
{
proxy - > SetProperty ( property , value ) ;
}
}
//<2F> <> ȡ<EFBFBD> <C8A1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ཻ<EFBFBD> <E0BDBB> <EFBFBD> <EFBFBD>
static NBase : : CRect8 GetIntersectRect8 ( const NBase : : CRect8 & r1 , const NBase : : CRect8 & r2 )
{
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ཻ<EFBFBD> <E0BDBB> <EFBFBD> <EFBFBD>
CRect8 out ;
out . left = std : : max ( r1 . left , r2 . left ) ;
out . top = ( std : : min ) ( r1 . top , r2 . top ) ;
out . right = ( std : : min ) ( r1 . right , r2 . right ) ;
out . bottom = std : : max ( r1 . bottom , r2 . bottom ) ;
// <20> <> <EFBFBD> 齻<EFBFBD> <E9BDBB> <EFBFBD> Ƿ<EFBFBD> <C7B7> <EFBFBD> Ч
if ( out . left < = out . right & & out . top > = out . bottom )
{
return out ;
}
// <20> <EFBFBD> <DEBD> <EFBFBD>
return CRect8 ( 0 , 0 , 0 , 0 ) ;
}
static bool IsRectInside ( const NBase : : CRect8 & r1 , const NBase : : CRect8 & r2 )
{
// <20> <> <EFBFBD> <EFBFBD> r1 <20> Ƿ<EFBFBD> <C7B7> <EFBFBD> Ч<EFBFBD> <D0A7> <EFBFBD> <EFBFBD> ѡ <EFBFBD> <D1A1> <EFBFBD> <EFBFBD> ֹ r1 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ǵ<EFBFBD> <C7B4> <EFBFBD> <EFBFBD> ľ<EFBFBD> <C4BE> Σ<EFBFBD>
if ( r1 . left > r1 . right | | r1 . top < r1 . bottom )
{
return false ;
}
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ж<EFBFBD> <D0B6> <EFBFBD> (Y<> <59> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ϵ)
// r1 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ߽<EFBFBD> >= r2 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ߽<EFBFBD>
// r1 <20> <> <EFBFBD> ұ߽<D2B1> <= r2 <20> <> <EFBFBD> ұ߽<D2B1>
// r1 <20> <> <EFBFBD> ±߽<C2B1> >= r2 <20> <> <EFBFBD> ±߽<C2B1> (<28> <> Ϊ<EFBFBD> <CEAA> Y<EFBFBD> <59> <EFBFBD> <EFBFBD> <EFBFBD> ϣ<EFBFBD> <CFA3> ڲ<EFBFBD> <DAB2> ĵױ<C4B5> Ӧ<EFBFBD> ñ<EFBFBD> <C3B1> ⲿ<EFBFBD> ĵױ߸<D7B1> )
// r1 <20> <> <EFBFBD> ϱ ߽<CFB1> <= r2 <20> <> <EFBFBD> ϱ ߽<CFB1> (<28> <> Ϊ<EFBFBD> <CEAA> Y<EFBFBD> <59> <EFBFBD> <EFBFBD> <EFBFBD> ϣ<EFBFBD> <CFA3> ڲ<EFBFBD> <DAB2> Ķ<EFBFBD> <C4B6> <EFBFBD> Ӧ<EFBFBD> ñ<EFBFBD> <C3B1> ⲿ<EFBFBD> Ķ<EFBFBD> <C4B6> ߵ <EFBFBD> )
if ( r1 . left > = r2 . left & &
r1 . right < = r2 . right & &
r1 . bottom > = r2 . bottom & &
r1 . top < = r2 . top )
{
return true ;
}
return false ;
}
typedef void ( __stdcall * MapDownloadProgressCallback ) ( int done , int total ) ;
/**
* <EFBFBD> <EFBFBD> <EFBFBD> ص <EFBFBD> ͼ
*
* \ param zoom <EFBFBD> 㼶
* \ param urlStr <EFBFBD> <EFBFBD> ͼ <EFBFBD> <EFBFBD> ַ
* \ param borderLayer <EFBFBD> <EFBFBD> ͼ ָ <EFBFBD> <EFBFBD> <EFBFBD> ߽ <EFBFBD>
* \ param dirPath <EFBFBD> <EFBFBD> <EFBFBD> ص <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ص <EFBFBD> <EFBFBD> <EFBFBD> Ƭ · <EFBFBD> <EFBFBD>
* \ param strPath <EFBFBD> <EFBFBD> <EFBFBD> պ ϲ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ƭ · <EFBFBD> <EFBFBD>
* \ return MapViewLayer
*/
# include <thread>
# include <future>
# include <memory>
static std : : future < bool > g_future ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
static std : : shared_ptr < MapViewLayer > g_maplayer ; // ȫ<> ֱ<EFBFBD> <D6B1> 棬<EFBFBD> <E6A3AC> ֹ<EFBFBD> <D6B9> <EFBFBD> <EFBFBD>
extern " C " __declspec ( dllexport )
MapViewLayer * DownloadSigmaViewItemMapView ( CSigmaView * pView , int zoom , const wchar_t * urlStr , const wchar_t * borderLayer ,
const wchar_t * dirPath , const wchar_t * strPath , int type , MapDownloadProgressCallback progressCallback )
{
if ( pView = = nullptr | | pView - > m_pDoc = = nullptr )
{
TRACE ( " pView <20> <> pView->m_pDoc <20> <> <EFBFBD> <EFBFBD> Ϊ nullptr \n " ) ;
return nullptr ;
}
CString mapUrl = CString ( urlStr ) ;
CString mapImageDir = CString ( dirPath ) ;
CString imagePath = CString ( strPath ) ;
CXy * pXyCurrent = pView - > m_pDoc - > GetDraw ( ) ;
//<2F> <> ʾ <EFBFBD> <CABE> <EFBFBD> ڷ<EFBFBD> Χ
CRect8 rect1 ;
CRect r1 = pView - > GetClientRect ( ) ;
rect1 = pView - > m_pDoc - > m_xyDC . GetReal ( r1 ) ;
NBase : : CRect8 rect ( 1e100 , - 1e100 , - 1e100 , 1e100 ) ;
CString strLayer = CString ( borderLayer ) ;
if ( ! strLayer . IsEmpty ( ) )
{
CPositionList list ;
if ( pXyCurrent - > GetElement ( strLayer , list ) > 0 )
{
for ( POSITION pos = list . GetHeadPosition ( ) ; pos ! = NULL ; list . GetNext ( pos ) )
{
POSITION pt = list . GetAt ( pos ) ;
COne * pOne = pXyCurrent - > GetAt ( pt ) ;
if ( pOne - > GetType ( ) = = DOUBLEFOX_CURVE )
{
pOne - > GetRange ( rect ) ;
break ;
}
}
}
}
if ( strLayer . IsEmpty ( ) | | ( rect . left = = 1e100 ) )
{
CMesh * pMesh = GetMesh ( pView ) ;
if ( pMesh ! = nullptr )
{
rect = pMesh - > GetRect ( ) ;
}
else
{
rect = pXyCurrent - > m_range ;
}
}
rect = GetIntersectRect8 ( rect , rect1 ) ;
bool isGaodeTarget = false ;
if ( type = = 1 )
{
//gcj02
isGaodeTarget = true ;
}
g_maplayer = std : : make_shared < MapViewLayer > ( ) ;
if ( ! g_maplayer - > MapProjection ( pXyCurrent , rect , isGaodeTarget ) )
return nullptr ;
// <20> 첽ִ<ECB2BD> <D6B4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
g_future = std : : async ( std : : launch : : async , [ = ] ( ) {
return g_maplayer - > SaveTDTMapCroppedParallel (
zoom ,
mapUrl ,
mapImageDir ,
imagePath ,
12 ,
progressCallback
) ;
} ) ;
return g_maplayer . get ( ) ;
}
extern " C " __declspec ( dllexport )
bool IsSigmaViewMapView ( CSigmaView * pView , const wchar_t * borderLayer )
{
if ( pView = = nullptr | | pView - > m_pDoc = = nullptr )
{
TRACE ( " pView <20> <> pView->m_pDoc <20> <> <EFBFBD> <EFBFBD> Ϊ nullptr \n " ) ;
return false ;
}
CXy * pXyCurrent = pView - > m_pDoc - > GetDraw ( ) ;
//<2F> <> ʾ <EFBFBD> <CABE> <EFBFBD> ڷ<EFBFBD> Χ
CRect8 rect1 ;
CRect r1 = pView - > GetClientRect ( ) ;
rect1 = pView - > m_pDoc - > m_xyDC . GetReal ( r1 ) ;
NBase : : CRect8 rect ( 1e100 , - 1e100 , - 1e100 , 1e100 ) ;
CString strLayer = CString ( borderLayer ) ;
if ( ! strLayer . IsEmpty ( ) )
{
CPositionList list ;
if ( pXyCurrent - > GetElement ( strLayer , list ) > 0 )
{
for ( POSITION pos = list . GetHeadPosition ( ) ; pos ! = NULL ; list . GetNext ( pos ) )
{
POSITION pt = list . GetAt ( pos ) ;
COne * pOne = pXyCurrent - > GetAt ( pt ) ;
if ( pOne - > GetType ( ) = = DOUBLEFOX_CURVE )
{
pOne - > GetRange ( rect ) ;
break ;
}
}
}
}
if ( strLayer . IsEmpty ( ) | | ( rect . left = = 1e100 ) )
{
CMesh * pMesh = GetMesh ( pView ) ;
if ( pMesh ! = nullptr )
{
rect = pMesh - > GetRect ( ) ;
}
else
{
rect = pXyCurrent - > m_range ;
}
}
return IsRectInside ( rect , rect1 ) ;
}
/**
* <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͼ
*
* \ param borderLayer <EFBFBD> <EFBFBD> ͼ ָ <EFBFBD> <EFBFBD> <EFBFBD> ߽ <EFBFBD>
* \ param strPath <EFBFBD> <EFBFBD> <EFBFBD> պ ϲ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ƭ · <EFBFBD> <EFBFBD>
* \ return
*/
extern " C " __declspec ( dllexport )
bool AddSigmaViewItemMapImage ( CSigmaView * pView , const wchar_t * borderLayer ,
const wchar_t * strPath )
{
if ( pView = = nullptr | | pView - > m_pDoc = = nullptr )
{
TRACE ( " pView <20> <> pView->m_pDoc <20> <> <EFBFBD> <EFBFBD> Ϊ nullptr \n " ) ;
return false ;
}
CString imagePath = CString ( strPath ) ;
CXy * pXyCurrent = pView - > m_pDoc - > GetDraw ( ) ;
//<2F> <> ʾ <EFBFBD> <CABE> <EFBFBD> ڷ<EFBFBD> Χ
CRect8 rect1 ;
CRect r1 = pView - > GetClientRect ( ) ;
rect1 = pView - > m_pDoc - > m_xyDC . GetReal ( r1 ) ;
NBase : : CRect8 rect ( 1e100 , - 1e100 , - 1e100 , 1e100 ) ;
CString strLayer = CString ( borderLayer ) ;
if ( ! strLayer . IsEmpty ( ) )
{
CPositionList list ;
if ( pXyCurrent - > GetElement ( strLayer , list ) > 0 )
{
for ( POSITION pos = list . GetHeadPosition ( ) ; pos ! = NULL ; list . GetNext ( pos ) )
{
POSITION pt = list . GetAt ( pos ) ;
COne * pOne = pXyCurrent - > GetAt ( pt ) ;
if ( pOne - > GetType ( ) = = DOUBLEFOX_CURVE )
{
pOne - > GetRange ( rect ) ;
break ;
}
}
}
}
if ( strLayer . IsEmpty ( ) | | ( rect . left = = 1e100 ) )
{
CMesh * pMesh = GetMesh ( pView ) ;
if ( pMesh ! = nullptr )
{
rect = pMesh - > GetRect ( ) ;
}
else
{
rect = pXyCurrent - > m_range ;
}
}
rect = GetIntersectRect8 ( rect , rect1 ) ;
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ɺ<EFBFBD> <20> <> ͼƬ<CDBC> <C6AC> <EFBFBD> <EFBFBD>
CImageInsert * pImage = new CImageInsert ( ) ;
if ( ! pImage - > LoadImage ( imagePath ) )
{
delete pImage ;
return false ;
}
pImage - > SetRect ( rect ) ;
POSITION pos = pXyCurrent - > AddElement ( pImage , DOUBLEFOX_IMAGE ) ;
COne * pOne = pXyCurrent - > GetAt ( pos ) ;
CLayer * pLayer = pXyCurrent - > FindAddLayer ( " <EFBFBD> <EFBFBD> <EFBFBD> ǵ<EFBFBD> ͼ" ) ;
pOne - > SetLayer ( pLayer ) ;
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʾ
pXyCurrent - > MoveToBack ( pos ) ;
return true ;
}
/**
* <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͼ
*
* \ param borderLayer <EFBFBD> <EFBFBD> ͼ ָ <EFBFBD> <EFBFBD> <EFBFBD> ߽ <EFBFBD>
* \ param strPath <EFBFBD> <EFBFBD> <EFBFBD> պ ϲ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ƭ · <EFBFBD> <EFBFBD>
* \ return
*/
extern " C " __declspec ( dllexport )
void StopDownloadMaplayer ( MapViewLayer * pMap )
{
if ( pMap = = nullptr )
return ;
pMap - > StopTask ( ) ;
}