# include "stdafx.h"
# include "SigmaView.h"
# include "SectionDoc.h"
# include "ItemSelect.h"
# include "ItemProportion.h"
# include "ItemEllipse.h"
# include "ItemCircle.h"
# include "ItemArc.h"
# include "ItemPointEdit.h"
# include "ItemFrame.h"
# include "ItemGrid.h"
# include "ItemNet.h"
# include "ItemText.h"
# include "ItemCurveEdit.h"
# include "ItemRectangle.h"
# include "ItemSolid.h"
# include "ItemSelectElement.h"
# include "ItemBreakCurve.h"
# include "actionmodifieditem.h"
# include "ActionModifiedMeshItem.h"
# include "ActionEmbellishItem.h"
# include "ActionAddItem.h"
# include <atlstr.h>
# include "VtkInterface.h"
# include "DrawOperator/FormatReader/GenerateImageMesh.h"
# include <string>
# include <regex>
static CItemSelectElement * GetCItemSelectElementFromView ( CSigmaView * pView )
{
if ( pView = = NULL )
return 0 ;
CItem * pItem = pView - > GetItem ( ) ;
if ( pItem = = NULL )
return 0 ;
CItemSelectElement * itemSelect = dynamic_cast < CItemSelectElement * > ( pItem ) ;
return itemSelect ;
}
CItemSelect * GetItemSelectFromView ( CSigmaView * pView )
{
if ( pView = = NULL )
return 0 ;
CItem * pItem = pView - > GetItem ( ) ;
if ( pItem = = NULL )
return 0 ;
CItemSelect * itemSelect = dynamic_cast < CItemSelect * > ( pItem ) ;
return itemSelect ;
}
CItemBreakCurve * GetCItemBreakCurveFromView ( CSigmaView * pView )
{
if ( pView = = NULL )
return 0 ;
CItem * pItem = pView - > GetItem ( ) ;
if ( pItem = = NULL )
return 0 ;
CItemBreakCurve * itemBreakCurve = dynamic_cast < CItemBreakCurve * > ( pItem ) ;
return itemBreakCurve ;
}
extern " C " __declspec ( dllexport )
int SelectGetCount ( CSigmaView * pView )
{
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return - 1 ;
return itemSelect - > GetCountSelected ( ) ;
}
extern " C " __declspec ( dllexport )
bool SelectStatusChanged ( CSigmaView * pView )
{
if ( pView = = NULL )
return false ;
CItem * pItem = pView - > GetItem ( ) ;
if ( pItem = = NULL )
return false ;
CItemSelect * itemSelect = dynamic_cast < CItemSelect * > ( pItem ) ;
if ( itemSelect = = NULL )
return false ;
return itemSelect - > IsSelectionChanged ;
}
extern " C " __declspec ( dllexport )
bool SelectIsSameType ( CSigmaView * pView )
{
if ( pView = = NULL )
return false ;
CItem * pItem = pView - > GetItem ( ) ;
if ( pItem = = NULL )
return false ;
CItemSelect * itemSelect = dynamic_cast < CItemSelect * > ( pItem ) ;
if ( itemSelect = = NULL )
return false ;
return itemSelect - > IsSameType ( ) ;
}
extern " C " __declspec ( dllexport )
bool SelectIsOnMoving ( CSigmaView * pView )
{
CItemSelect * pItem = GetItemSelectFromView ( pView ) ;
if ( pItem = = nullptr )
{
return false ;
}
return pItem - > OnMoving ( ) ;
}
extern " C " __declspec ( dllexport )
void SelectMoveElementsTo ( CSigmaView * pView , int x , int y )
{
CItemSelect * pItem = GetItemSelectFromView ( pView ) ;
if ( pItem = = nullptr )
{
return ;
}
pItem - > MoveElementsTo ( CPoint ( x , y ) ) ;
}
extern " C " __declspec ( dllexport )
void SelectTransformElements ( CSigmaView * pView , double startX , double startY , double endX , double endY )
{
CItemSelect * pItem = GetItemSelectFromView ( pView ) ;
if ( pItem = = nullptr )
{
return ;
}
pItem - > TransformElements ( CPoint ( startX , startY ) , CPoint ( endX , endY ) ) ;
}
extern " C " __declspec ( dllexport )
void SelectDrawTrackPath ( CSigmaView * pView , HDC hdcMem )
{
CItemSelect * pItem = GetItemSelectFromView ( pView ) ;
if ( pItem = = nullptr )
{
return ;
}
CDC * pDC = CDC : : FromHandle ( hdcMem ) ;
pItem - > DrawTrackPath ( pDC ) ;
}
extern " C " __declspec ( dllexport )
void SelectGetTrackerRect ( CSigmaView * pView , double & left , double & top , double & right , double & bottom )
{
CItemSelect * pItem = GetItemSelectFromView ( pView ) ;
if ( pItem = = nullptr )
{
return ;
}
CRect rect = pItem - > GetTrackerRect ( ) ;
left = rect . left ;
top = rect . top ;
right = rect . right ;
bottom = rect . bottom ;
}
BOOL Select_InsertMesh ( CSigmaView * pView , LPCTSTR meshFile , POSITION & newMeshPos )
{
CXy * pXyCurrent = pView - > m_pDoc - > GetDraw ( ) ;
CString strExt ;
CSplitPath sp ( meshFile ) ;
strExt = sp . GetExtension ( ) ;
strExt . MakeLower ( ) ;
CXy * pxy = new CXy ;
pxy - > m_bRealTimeDraw = false ;
if ( strExt = = _T ( " .dfb " ) | | strExt = = _T ( " .dft " ) )
pView - > m_pDoc - > SerializeRead ( pxy , meshFile ) ;
else if ( ! pxy - > ReadOtherWithExtension ( meshFile ) ) //<2F> <> ȡ<EFBFBD> <C8A1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ͳ<EFBFBD> <CDB2> ɹ<EFBFBD> ʱ
pxy - > ReadWithExtension ( meshFile ) ;
if ( ! pxy - > GetProjection ( ) . IsEmpty ( ) & & ! pXyCurrent - > GetProjection ( ) . IsEmpty ( ) )
pxy - > ChangeToProjection ( pXyCurrent - > GetProjection ( ) ) ;
POSITION posNew = pxy - > FindFirstElement ( DOUBLEFOX_MESH ) ;
if ( posNew = = nullptr ) {
delete pxy ;
return false ;
}
CMesh * pMeshNew = ( CMesh * ) ( pxy - > GetAt ( posNew ) ) - > value ;
CFunction2D * pGridNew = ( CFunction2D * ) pMeshNew - > GetMesh ( ) ;
long numxNew , numyNew ;
pMeshNew - > GetNumber ( numxNew , numyNew ) ;
CMesh * pMesh = new CMesh ;
pMesh - > SetMeshType ( MESH_DFG ) ;
//pMesh->m_bRealTimeDraw = pMeshOld->m_bRealTimeDraw;
CDimension2D * m_pDfg = new CDimension2D ;
m_pDfg - > Create ( numxNew , numyNew , pGridNew - > P0 [ 0 ] , pGridNew - > P0 [ 1 ] , pGridNew - > delt [ 0 ] , pGridNew - > delt [ 1 ] ) ;
m_pDfg - > SetRange ( pGridNew - > range [ 0 ] , pGridNew - > range [ 1 ] ) ;
pMesh - > SetMesh ( m_pDfg , MESH_DFG , FALSE ) ;
for ( int i = 0 ; i < numxNew ; i + + ) {
for ( int j = 0 ; j < numyNew ; j + + ) {
pMesh - > GetDfg ( ) - > SetValue ( i , j , pMeshNew - > GetValue ( i , j ) ) ;
}
}
COne * pOneMesh = pXyCurrent - > CreateOne ( pMesh , DOUBLEFOX_MESH ) ;
POSITION posMesh = pXyCurrent - > AddHeadOne ( pOneMesh ) ;
//POSITION posMesh = pXyCurrent->AddElement(pMesh, DOUBLEFOX_MESH);
CLayer * pLayer = pXyCurrent - > FindAddLayer ( " <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ;
//COne* pOneMesh = pXyCurrent->GetAt(posMesh);
pOneMesh - > SetLayer ( pLayer ) ;
pView - > m_pDoc - > SetActionItem ( new CActionAddItem ( pView - > m_pDoc , IDS_STRING_ACTION_ADD , pOneMesh ) ) ;
newMeshPos = posMesh ;
pMesh - > GetBitmap ( ) ;
pXyCurrent - > EnableMeshPackage ( pXyCurrent - > IsEnableMeshPackage ( ) , true ) ;
delete pxy ;
return true ;
}
extern " C " __declspec ( dllexport )
BOOL Select_ReplaceMesh ( CSigmaView * pView , LPCTSTR meshFile , POSITION oldMeshPos , POSITION & newMeshPos )
{
CXy * pXyCurrent = pView - > m_pDoc - > GetDraw ( ) ;
if ( oldMeshPos = = nullptr )
{
oldMeshPos = pXyCurrent - > FindFirstElement ( DOUBLEFOX_MESH ) ;
}
if ( oldMeshPos = = nullptr ) {
return Select_InsertMesh ( pView , meshFile , newMeshPos ) ;
}
CString strExt ;
CSplitPath sp ( meshFile ) ;
strExt = sp . GetExtension ( ) ;
strExt . MakeLower ( ) ;
CXy * pxy = new CXy ;
pxy - > m_bRealTimeDraw = false ;
if ( strExt = = _T ( " .dfb " ) | | strExt = = _T ( " .dft " ) )
pView - > m_pDoc - > SerializeRead ( pxy , meshFile ) ;
else if ( ! pxy - > ReadOtherWithExtension ( meshFile ) ) //<2F> <> ȡ<EFBFBD> <C8A1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ͳ<EFBFBD> <CDB2> ɹ<EFBFBD> ʱ
pxy - > ReadWithExtension ( meshFile ) ;
if ( ! pxy - > GetProjection ( ) . IsEmpty ( ) & & ! pXyCurrent - > GetProjection ( ) . IsEmpty ( ) )
pxy - > ChangeToProjection ( pXyCurrent - > GetProjection ( ) ) ;
//CPositionList select;
//pView->m_pDoc->GetDraw()->MoveInBottom(pxy, select);
POSITION posNew = pxy - > FindFirstElement ( DOUBLEFOX_MESH ) ;
if ( posNew = = nullptr ) {
delete pxy ;
return false ;
}
COne * pNewOne = pxy - > GetAt ( posNew ) ;
//pxy->RemoveAtNoClear(posNew);
COne * pOldOne = pXyCurrent - > GetAt ( oldMeshPos ) ;
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> γ <EFBFBD> <CEB3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//CActionModifiedMesh* pAction = new CActionModifiedMesh(pView->m_pDoc, IDS_STRING_PANE_COLOR_BAR);
//pAction->BackupOldItem(oldMeshPos, pOldOne);
//pNewOne->m_pParentXY = pXyCurrent;
//POSITION posInsert = pXyCurrent->InsertElementAfter(oldMeshPos, pNewOne);
//pNewOne->SetLayer(pOldOne->GetLayer());
CMesh * pMeshNew = ( CMesh * ) pNewOne - > value ;
CMesh * pMeshOld = ( CMesh * ) pOldOne - > value ;
CMesh * pMesh = new CMesh ;
pMesh - > SetMeshType ( MESH_DFG ) ;
pMesh - > m_bRealTimeDraw = pMeshOld - > m_bRealTimeDraw ;
CDimension2D * m_pDfg = new CDimension2D ;
//*(CGrid*)m_pDfg = *(CGrid*)(pMeshNew->GetDfg());
CFunction2D * pGridNew = ( CFunction2D * ) pMeshNew - > GetMesh ( ) ;
long numxNew , numyNew ;
pMeshNew - > GetNumber ( numxNew , numyNew ) ;
//pMeshNew->y
m_pDfg - > Create ( numxNew , numyNew , pGridNew - > P0 [ 0 ] , pGridNew - > P0 [ 1 ] , pGridNew - > delt [ 0 ] , pGridNew - > delt [ 1 ] ) ;
m_pDfg - > SetRange ( pGridNew - > range [ 0 ] , pGridNew - > range [ 1 ] ) ;
pMesh - > SetMesh ( m_pDfg , MESH_DFG , FALSE ) ;
for ( int i = 0 ; i < numxNew ; i + + ) {
for ( int j = 0 ; j < numyNew ; j + + ) {
pMesh - > GetDfg ( ) - > SetValue ( i , j , pMeshNew - > GetValue ( i , j ) ) ;
}
}
COne * pOne = new COne ;
pOne - > SetType ( DOUBLEFOX_MESH ) ;
pOne - > value = pMesh ;
pOne - > CloneOtherParameter ( * pOldOne ) ;
pMesh - > CloneOtherParamter ( * pMeshOld ) ;
pMesh - > GetBitmap ( ) ;
newMeshPos = pXyCurrent - > AddHeadOne ( pOne ) ;
//pMeshNew->CloneOtherParamter(*pMeshOld);
//long numx, numy;
//pMeshOld->GetNumber(numx, numy);
//long numxNew, numyNew;
//pMeshNew->GetNumber(numxNew, numyNew);
//for (int i = 0; i < numx && i < numxNew; i++) {
// for (int j = 0; j < numy && j < numyNew; j++) {
// pMeshOld->SetZ(i, j, pMeshNew->GetValue(i, j));
// }
//}
pXyCurrent - > RemoveAt ( pOldOne ) ;
pXyCurrent - > EnableMeshPackage ( pXyCurrent - > IsEnableMeshPackage ( ) , true ) ;
delete pxy ;
//<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
//pAction->BackupNewItem();
//pView->m_pDoc->SetActionItem(pAction);
return true ;
}
extern " C " __declspec ( dllexport )
BOOL Select_CreateMeshColorBar ( CSigmaView * pView , ColorPoint * colorPoints , int length , LPCTSTR barSavePath , LPCTSTR xmlSavePath ,
double minz , double maxz )
{
std : : vector < ColorPoint > vector ( colorPoints , colorPoints + length ) ;
GenerateImageMesh * pColorBar = new GenerateImageMesh ( ) ;
bool state = pColorBar - > CreateMeshColorBar ( vector , barSavePath , minz , maxz , xmlSavePath ) ;
delete pColorBar ;
return state ;
}
extern " C " __declspec ( dllexport )
BOOL Select_CreateColorBarData ( CSigmaView * pView , POSITION oldMeshPos , ColorPoint * colorPoints ,
int numColors , int & vSize , double zmin , double zmax , int colorType , int sortType )
{
COne * pOne1 = pView - > m_pDoc - > GetDraw ( ) - > GetAt ( oldMeshPos ) ;
if ( pOne1 = = 0 ) return false ;
CImageInsert * pValue = ( CImageInsert * ) pOne1 - > GetValue ( ) ;
GenerateImageMesh * pColorBar = new GenerateImageMesh ( ) ;
pColorBar - > SetImageBase ( ( CxImage ) * pValue - > m_pImage ) ;
pColorBar - > SetZminByZmax ( zmin , zmax ) ;
GenerateImageMesh : : ColorMethod colorMethod ;
GenerateImageMesh : : SortMethod sortMethod ;
switch ( colorType )
{
case 0 :
colorMethod = GenerateImageMesh : : ColorMethod : : HSV_M ;
break ;
case 1 :
colorMethod = GenerateImageMesh : : ColorMethod : : UNIFORMSAMPLING_M ;
break ;
case 2 :
colorMethod = GenerateImageMesh : : ColorMethod : : KMEANS_M ;
break ;
default :
break ;
}
switch ( sortType )
{
case 0 :
sortMethod = GenerateImageMesh : : SortMethod : : BRIGHTNESS_SORT ;
break ;
case 1 :
{
if ( colorType = = 0 | | colorType = = 1 )
sortMethod = GenerateImageMesh : : SortMethod : : HUE_SORT ;
if ( colorType = = 2 )
sortMethod = GenerateImageMesh : : SortMethod : : HUE_SORT_COLD ;
break ;
}
break ;
default :
break ;
}
std : : vector < ColorPoint > vector ;
bool state = pColorBar - > CreateColorBarData ( vector , colorMethod , sortMethod , numColors ) ;
for ( int i = 0 ; i < vector . size ( ) ; + + i ) {
colorPoints [ i ] = vector [ i ] ;
}
vSize = vector . size ( ) ;
delete pColorBar ;
return state ;
}
extern " C " __declspec ( dllexport )
BOOL Select_CreateReplaceMesh ( CSigmaView * pView , POSITION oldMeshPos , POSITION & newMeshPos ,
int colorNum , double gridZmin , double gridZmax ,
int numX , int numY , double dLocationX , double dLocationY
, double dDeltX , double dDeltY , double dMaxX , double dMaxY , ColorPoint * colorPoints , ColorPoint * colorListPoints , int colorListNum )
{
COne * pOne1 = pView - > m_pDoc - > GetDraw ( ) - > GetAt ( oldMeshPos ) ;
if ( pOne1 = = 0 )
return false ;
CImageInsert * pValue = ( CImageInsert * ) pOne1 - > GetValue ( ) ;
CLayer * lay = pOne1 - > GetLayer ( ) ;
//CString str = lay->GetName();
GenerateImageMesh * pCreateMesh = new GenerateImageMesh ( ) ;
pCreateMesh - > SetImageBase ( ( CxImage ) * pValue - > m_pImage ) ;
pCreateMesh - > SetZminByZmax ( gridZmin , gridZmax ) ;
std : : vector < ColorPoint > vector ( colorPoints , colorPoints + colorNum ) ;
std : : vector < ColorPoint > vectorColor ( colorListPoints , colorListPoints + colorListNum ) ;
//<2F> <> <EFBFBD> <EFBFBD> xy
CMesh * pMesh = pCreateMesh - > CreateImageMeshProcess ( numX , numY , dLocationX , dLocationY , dDeltX , dDeltY , dMaxX , dMaxY , vector , vectorColor ) ;
pMesh - > GetBitmap ( ) ;
CXy * pXyCurrent = pView - > m_pDoc - > GetDraw ( ) ;
COne * pOneMesh = pXyCurrent - > CreateOne ( pMesh , DOUBLEFOX_MESH ) ;
POSITION posMesh = pXyCurrent - > AddHeadOne ( pOneMesh ) ;
CLayer * pLayer = pXyCurrent - > FindAddLayer ( " <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> " ) ;
pOneMesh - > SetLayer ( pLayer ) ;
pView - > m_pDoc - > SetActionItem ( new CActionAddItem ( pView - > m_pDoc , IDS_STRING_ACTION_ADD , pOneMesh ) ) ;
newMeshPos = posMesh ;
pXyCurrent - > EnableMeshPackage ( pXyCurrent - > IsEnableMeshPackage ( ) , true ) ;
//COne * pOne = new COne;
//pOne->SetType(DOUBLEFOX_MESH);
//pOne->value = pMesh;
//newMeshPos = pXyCurrent->AddHeadOne(pOne);
//pXyCurrent->EnableMeshPackage(pXyCurrent->IsEnableMeshPackage(), true);
return true ;
}
extern " C " __declspec ( dllexport )
BOOL Select_ReselectByPosition ( CSigmaView * pView , POSITION posNew ) {
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return FALSE ;
itemSelect - > Select ( posNew , false ) ;
return TRUE ;
}
extern " C " __declspec ( dllexport )
BOOL Select_GetElementByPosition ( CSigmaView * pView , BYTE * & buffElement , int & buffLen , POSITION elementPtr , bool allContent )
{
if ( pView - > m_pDoc = = 0 )
return FALSE ;
COne * pOne = ( COne * ) ( pView - > m_pDoc - > GetDraw ( ) - > GetAt ( elementPtr ) ) ;
if ( pOne = = 0 )
return FALSE ;
if ( pOne - > GetType ( ) = = DOUBLEFOX_MESH ) {
if ( allContent ) {
return pOne - > WriteMemory ( buffElement , 0 , buffLen , 3 ) ;
}
else {
( ( CMesh * ) ( pOne - > value ) ) - > WriteElementDML ( buffElement , buffLen ) ;
}
return TRUE ;
}
else if ( pOne - > GetType ( ) = = DOUBLEFOX_TEXT ) {
( ( CText * ) ( pOne - > value ) ) - > color = pOne - > color ;
return pOne - > WriteMemory ( buffElement , 0 , buffLen , 3 ) ;
}
else if ( pOne - > GetType ( ) = = DOUBLEFOX_ELLIPSE )
{
( ( CEllipse * ) ( pOne - > value ) ) - > color = pOne - > color ;
return pOne - > WriteMemory ( buffElement , 0 , buffLen , 3 ) ;
}
else if ( pOne - > GetType ( ) = = DOUBLEFOX_CIRCLE )
{
( ( CCircle * ) ( pOne - > value ) ) - > color = pOne - > color ;
return pOne - > WriteMemory ( buffElement , 0 , buffLen , 3 ) ;
}
else if ( pOne - > GetType ( ) = = DOUBLEFOX_ARC )
{
( ( CArc * ) ( pOne - > value ) ) - > color = pOne - > color ;
return pOne - > WriteMemory ( buffElement , 0 , buffLen , 3 ) ;
}
else if ( pOne - > GetType ( ) = = DOUBLEFOX_SCALERULER )
{
( ( CScaleRuler * ) ( pOne - > value ) ) - > color = pOne - > color ;
return pOne - > WriteMemory ( buffElement , 0 , buffLen , 3 ) ;
}
else if ( pOne - > GetType ( ) = = DOUBLEFOX_PROPORTION )
{
( ( CProportion * ) ( pOne - > value ) ) - > color = pOne - > color ;
return pOne - > WriteMemory ( buffElement , 0 , buffLen , 3 ) ;
}
else if ( pOne - > GetType ( ) = = DOUBLEFOX_IMAGE )
{
( ( CImageInsert * ) ( pOne - > value ) ) - > WriteElementDML ( buffElement , buffLen ) ;
}
else if ( pOne - > GetType ( ) = = DOUBLEFOX_BLOCK )
{
if ( allContent )
{
pOne - > WriteMemory ( buffElement , 0 , buffLen , 3 ) ;
}
else {
pOne - > WriteSummaryMemory ( buffElement , 0 , buffLen , 3 ) ;
}
return true ;
}
else
{
return pOne - > WriteMemory ( buffElement , 0 , buffLen , 3 ) ;
}
return false ;
}
extern " C " __declspec ( dllexport )
BOOL Select_IsElementLocationChanged ( CSigmaView * pView )
{
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return false ;
return itemSelect - > m_isLocationChanged ;
}
extern " C " __declspec ( dllexport )
BOOL GetElementByLocation ( CSigmaView * pView , BYTE * & buffElement , int & buffLen
, int mouseX , int mouseY )
{
CPoint2D pt ;
pt . x0 = mouseX ;
pt . y0 = mouseY ;
pt = pView - > m_pDoc - > GetDC ( ) . GetReal ( pt ) ;
POSITION pos = pView - > m_pDoc - > GetSelectedItem ( pt ) ;
if ( pos = = nullptr ) {
return false ;
}
BOOL bReturn = Select_GetElementByPosition ( pView , buffElement , buffLen , pos , false ) ;
return bReturn ;
}
extern " C " __declspec ( dllexport )
BOOL SelectGetPointsZRange ( CSigmaView * pView , double & zMin , double & zMax )
{
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return false ;
return itemSelect - > GetPointsZRange ( zMin , zMax ) ;
}
extern " C " __declspec ( dllexport )
BOOL SelectSetPointsColor ( CSigmaView * pView , LPCTSTR colorItemsData , double dWidth , double dHeight )
{
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return false ;
return itemSelect - > SetPointsColor ( colorItemsData , dWidth , dHeight ) ;
}
extern " C " __declspec ( dllexport )
const BSTR GetSelectedNames ( CSigmaView * pView ) {
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return false ;
if ( itemSelect - > m_selection . IsEmpty ( ) )
return false ;
CString strData ( " " ) ;
itemSelect - > GetSelectedNames ( strData ) ;
return strData . AllocSysString ( ) ;
}
extern " C " __declspec ( dllexport )
BOOL SelectGetElement ( CSigmaView * pView , BYTE * & buffElement , int & buffLen , POSITION & elementPtr , bool allContent )
{
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return false ;
if ( itemSelect - > m_selection . IsEmpty ( ) )
return false ;
POSITION pos = itemSelect - > m_selection . GetHead ( ) ;
COne * pOne = ( COne * ) ( pView - > m_pDoc - > GetDraw ( ) - > GetAt ( pos ) ) ;
elementPtr = pos ;
BOOL bReturn = Select_GetElementByPosition ( pView , buffElement , buffLen , elementPtr , allContent ) ;
// <20> <> Ҫ<EFBFBD> ͷ<EFBFBD> free(buffElement);
return bReturn ;
}
extern " C " __declspec ( dllexport )
BOOL SelectGetElementPositions ( CSigmaView * pView , POSITION * & array , int & len ) {
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return false ;
if ( itemSelect - > m_selection . IsEmpty ( ) )
return false ;
len = itemSelect - > m_selection . GetCount ( ) ;
array = new POSITION [ len ] ;
POSITION pos , pt ;
pos = itemSelect - > m_selection . GetHeadPosition ( ) ;
int i = 0 ;
while ( pos ! = NULL )
{
pt = itemSelect - > m_selection . GetNext ( pos ) ;
array [ i + + ] = pt ;
}
//array = pPositions;
return true ;
}
extern " C " __declspec ( dllexport )
bool SelectByScreenRegion ( CSigmaView * pView , double startX , double startY , double endX , double endY , bool add , POSITION * & array , int & len ) {
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return false ;
itemSelect - > SelectInScreenRegion ( startX , startY , endX , endY , add ) ;
len = itemSelect - > m_selection . GetCount ( ) ;
if ( len < = 0 )
{
return true ;
}
array = new POSITION [ len ] ;
POSITION pos , pt ;
pos = itemSelect - > m_selection . GetHeadPosition ( ) ;
int i = 0 ;
while ( pos ! = NULL )
{
pt = itemSelect - > m_selection . GetNext ( pos ) ;
array [ i + + ] = pt ;
}
return true ;
}
// ѡ <> <D1A1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ڱ߽<DAB1> <DFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ڵ<EFBFBD> <DAB5> <EFBFBD> <EFBFBD> <EFBFBD> ͼԪ
extern " C " __declspec ( dllexport )
int SelectInCurveRange ( CSigmaView * pView ) {
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return 0 ;
return itemSelect - > SelectInCurve ( ) ;
}
// ѡ <> <D1A1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ڱ߽<DAB1> <DFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ڵ<EFBFBD> <DAB5> <EFBFBD> <EFBFBD> <EFBFBD> ͼԪ
extern " C " __declspec ( dllexport )
int SelectTypeInCurveRange ( CSigmaView * pView , int elementType ) {
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return 0 ;
return itemSelect - > SelectInCurve ( elementType ) ;
}
// ѡ <> <D1A1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͼԪ<CDBC> <D4AA> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB> <EFBFBD> ٷֱȵ<D6B1> ͼԪ
extern " C " __declspec ( dllexport )
int SelectInCurveRangeEx ( CSigmaView * pView , double factor ) {
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return 0 ;
return itemSelect - > SelectInCurveEx ( factor ) ;
}
// ѡ <> <D1A1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͼԪ<CDBC> <D4AA> <EFBFBD> <EFBFBD> һ <EFBFBD> <D2BB> <EFBFBD> ٷֱȵ<D6B1> ͼԪ
extern " C " __declspec ( dllexport )
int SelectTypeInCurveRangeEx ( CSigmaView * pView , int elementType , double factor ) {
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return 0 ;
return itemSelect - > SelectInCurveEx ( elementType , factor ) ;
}
extern " C " __declspec ( dllexport )
int Select_SamePropertyElements ( CSigmaView * pView )
{
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return 0 ;
return itemSelect - > SelectSamePropertyElements ( ) ;
}
extern " C " __declspec ( dllexport )
void Select_SetTypes ( CSigmaView * pView , int * types , int size )
{
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
{
return ;
}
itemSelect - > SetSelectTypes ( types , size ) ;
}
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ѡ <EFBFBD> <D1A1> <EFBFBD> <EFBFBD> ͼԪ
extern " C " __declspec ( dllexport )
bool Select_GetElements ( CSigmaView * pView , BYTE * & buffElement , int & buffLen )
{
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return false ;
if ( itemSelect - > m_selection . IsEmpty ( ) )
return false ;
BOOL bReturn = itemSelect - > WriteData ( pView - > m_pDoc - > GetDraw ( ) , buffElement , buffLen , 3 ) ;
// <20> <> Ҫ<EFBFBD> ͷ<EFBFBD> free(buffElement);
return bReturn ;
}
extern " C " __declspec ( dllexport )
bool Select_WriteTemplate ( CSigmaView * pView , LPCTSTR outputFile )
{
CFile fw ;
if ( ! fw . Open ( outputFile , CFile : : modeCreate | CFile : : modeWrite ) )
{
return false ;
}
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return false ;
if ( itemSelect - > m_selection . IsEmpty ( ) )
return false ;
CXy * pxy = pView - > m_pDoc - > GetDraw ( ) ;
pxy - > DFD_WriteMark ( * ( CFile * ) & fw , CUR_VERSION , 1 ) ;
pxy - > DFD_WriteLegend ( * ( CFile * ) & fw , CUR_VERSION , 1 ) ;
pxy - > DFD_Write ( * ( CFile * ) & fw , itemSelect - > m_selection ) ;
fw . Close ( ) ;
return true ;
}
/**
* <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> Ϣ
* \ return
*/
extern " C " __declspec ( dllexport )
POSITION SelectGetPolygon ( CSigmaView * pView )
{
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = nullptr )
{
return nullptr ;
}
if ( itemSelect - > m_selection . GetCount ( ) ! = 1 )
{
return nullptr ;
}
POSITION pt = itemSelect - > m_selection . GetHead ( ) ;
COne * pOne = ( COne * ) ( pView - > m_pDoc - > GetDraw ( ) - > GetAt ( pt ) ) ;
if ( pOne - > GetType ( ) = = DOUBLEFOX_CURVE )
{
CCurveEx * pCurve = ( CCurveEx * ) ( pOne - > value ) ;
if ( IsPolygon ( pCurve ) )
{
return pt ;
}
}
return nullptr ;
}
extern " C " __declspec ( dllexport )
int SelectGetElementType ( CSigmaView * pView )
{
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return 0 ;
if ( itemSelect - > m_selection . IsEmpty ( ) )
return 0 ;
if ( itemSelect - > m_selection . GetCount ( ) ! = 1 ) {
return 0 ;
}
POSITION pos = itemSelect - > m_selection . GetHead ( ) ;
COne * pOne = ( COne * ) ( pView - > m_pDoc - > GetDraw ( ) - > GetAt ( pos ) ) ;
return pOne - > GetType ( ) ;
}
extern " C " __declspec ( dllexport )
void * SelectGetMesh ( CSigmaView * pView )
{
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return 0 ;
if ( itemSelect - > m_selection . IsEmpty ( ) )
return 0 ;
if ( itemSelect - > m_selection . GetCount ( ) ! = 1 ) {
return 0 ;
}
POSITION pos = itemSelect - > m_selection . GetHead ( ) ;
COne * pOne = ( COne * ) ( pView - > m_pDoc - > GetDraw ( ) - > GetAt ( pos ) ) ;
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 ( ) ;
pKevVtkMeshData - > m_layerName = pOne - > GetLayer ( ) - > GetPathName ( ) ;
return pKevVtkMeshData ;
}
else
{
return nullptr ;
}
}
//extern "C" __declspec(dllexport)
//bool SelectSetGridData(CSigmaView* pView, BYTE* buffElement, int buffLen, POSITION elementPtr)
//{
// {
// CActionModifiedItem* m_pAction = NULL;
// CItemSelect* pSelItem = pView->m_pDoc->GetSelectItem();
// if (pSelItem)
// {
// m_pAction = new CActionModifiedItem(pView->m_pDoc, IDS_STRING_TOOLBAR_EDIT);
// m_pAction->AddCloneItem(pSelItem->m_selection);
// }
// pView->m_pDoc->SetActionItem(m_pAction);
// }
// BOOL bEdited = FALSE;
// POSITION pos;
// pos = (POSITION)elementPtr;
// COne* pOne = (COne*)(pView->m_pDoc->GetDraw()->GetAt(pos));
//
// if (pOne->GetType() == DOUBLEFOX_MESH)
// {
// CMesh* pMesh = (CMesh*)(pOne->value);
// // pMesh->m_bRealTimeDraw = false;
// // pMesh->ReadElementDML(buffElement, -1, buffLen);
// //pMesh->SetM(m_zrange.cx, m_zrange.cy);
//
// pMesh->SetM(pMesh->m_pRuler->zmin, pMesh->m_pRuler->zmax);
// pMesh->GetBitmap();
// bEdited = true;
// }
// return bEdited;
//}
/**
* @ brief <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> С <EFBFBD> <EFBFBD> λ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʽ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ <EFBFBD> <EFBFBD> <EFBFBD>
* @ param strRawName ԭ ʼ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ( <EFBFBD> <EFBFBD> " 1.23456 " <EFBFBD> <EFBFBD> " Pline1 " )
* @ param nDecimal <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> С <EFBFBD> <EFBFBD> λ <EFBFBD> <EFBFBD> ( <EFBFBD> <EFBFBD> 2 ) <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> < 0 <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> <EFBFBD> ֻ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʽ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ԭ <EFBFBD> ַ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
*/
static CString GetFormattedDecimalName ( const CString & strRawName , int nDecimal )
{
// 1. <20> <> <EFBFBD> <EFBFBD> У <EFBFBD> 飺<EFBFBD> <E9A3BA> <EFBFBD> <EFBFBD> Ϊ<EFBFBD> ջ<EFBFBD> С <EFBFBD> <D0A1> λ<EFBFBD> <CEBB> <EFBFBD> <EFBFBD> Ч<EFBFBD> <D0A7> ֱ<EFBFBD> ӷ<EFBFBD> <D3B7> <EFBFBD> ԭֵ
if ( strRawName . IsEmpty ( ) | | nDecimal < 0 )
{
return strRawName ;
}
LPTSTR pEnd = nullptr ;
// 2. <20> <> <EFBFBD> <EFBFBD> ת<EFBFBD> <D7AA> Ϊ double
double dVal = _tcstod ( strRawName , & pEnd ) ;
// 3. <20> <> <EFBFBD> <EFBFBD> <EFBFBD> Ƿ<EFBFBD> ȫ<EFBFBD> <C8AB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (ָ<> <D6B8> ָ<EFBFBD> <D6B8> ĩβ '\0')
if ( pEnd ! = nullptr & & * pEnd = = _T ( ' \0 ' ) )
{
// 4. <20> ض<EFBFBD> <D8B6> <EFBFBD> <DFBC> <EFBFBD> <EFBFBD> ˱<EFBFBD> <CBB1> <EFBFBD> -> <20> ض<EFBFBD> -> <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
// +1e-9 <20> <> ֹ 1.23 <20> <> double <20> д<EFBFBD> Ϊ 1.229999 <20> ľ<EFBFBD> <C4BE> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
double factor = pow ( 10.0 , nDecimal ) ;
dVal = trunc ( dVal * factor + 1e-9 ) / factor ;
// 5. <20> <> ʽ <EFBFBD> <CABD> <EFBFBD> <EFBFBD> <EFBFBD> ַ<EFBFBD> <D6B7> <EFBFBD>
CString strResult ;
strResult . Format ( _T ( " %.*f " ) , nDecimal , dVal ) ;
return strResult ;
}
// <20> <> <EFBFBD> Ǵ<EFBFBD> <C7B4> <EFBFBD> <EFBFBD> ֣<EFBFBD> <D6A3> <EFBFBD> <EFBFBD> <EFBFBD> ԭֵ
return strRawName ;
}
extern " C " __declspec ( dllexport )
BOOL SelectSetElement ( CSigmaView * pView , BYTE * buffElement , int buffLen , POSITION elementPtr , bool state , double zmin , double zmax )
{
if ( pView = = nullptr | | buffElement = = nullptr | | buffLen < = 0 | | elementPtr = = nullptr )
{
return FALSE ;
}
COne * pOne = ( COne * ) ( pView - > m_pDoc - > GetDraw ( ) - > GetAt ( elementPtr ) ) ;
if ( pOne = = nullptr )
{
return FALSE ;
}
// <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ر<EFBFBD> ռ <EFBFBD> ڴ棬<DAB4> <E6A3AC> <EFBFBD> ǽ<EFBFBD> <C7BD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ļ<EFBFBD> <C4BB> ˽<EFBFBD> <CBBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <E2B4A6> <EFBFBD> <EFBFBD> ֻ<EFBFBD> <D6BB> <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>
if ( pOne - > GetType ( ) = = DOUBLEFOX_MESH )
{
auto pAction = std : : make_unique < CActionModifiedMeshItem > ( pView - > m_pDoc , IDS_STRING_TOOLBAR_EDIT ) ;
pAction - > BackupOldArguments ( pOne ) ;
CMesh * pMesh = ( CMesh * ) ( pOne - > value ) ;
pMesh - > m_bRealTimeDraw = false ;
pMesh - > ReadElementDML ( buffElement , - 1 , buffLen ) ;
if ( state )
{
pMesh - > SetM ( pMesh - > m_pRuler - > zmin , pMesh - > m_pRuler - > zmax ) ;
}
else
{
//<2F> <> ɫ<EFBFBD> <C9AB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <20> <> Ҫʹ <D2AA> <CAB9> <EFBFBD> <EFBFBD> <EFBFBD> Կ<EFBFBD> <D4BF> е <EFBFBD> ֵ
pMesh - > SetM ( zmin , zmax ) ;
}
pMesh - > GetBitmap ( ) ;
pAction - > BackupNewArguments ( ) ;
pView - > m_pDoc - > SetActionItem ( pAction . release ( ) ) ;
return true ;
}
CActionModifiedItem * pAction = new CActionModifiedItem ( pView - > m_pDoc , IDS_STRING_TOOLBAR_EDIT ) ;
pAction - > BackupOldItem ( elementPtr , pOne ) ;
BOOL bEdited = FALSE ;
// TODO: <20> ж<EFBFBD> <D0B6> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ƿ<EFBFBD> <C7B7> <EFBFBD> <EFBFBD> <EFBFBD>
if ( pOne - > GetType ( ) = = DOUBLEFOX_SECTION ) {
( ( CSection * ) ( pOne - > value ) ) - > ReadElementDML ( buffElement , - 1 , buffLen ) ;
bEdited = true ;
}
else if ( pOne - > GetType ( ) = = DOUBLEFOX_MESH ) {
CMesh * pMesh = ( CMesh * ) ( pOne - > value ) ;
pMesh - > m_bRealTimeDraw = false ;
pMesh - > ReadElementDML ( buffElement , - 1 , buffLen ) ;
pMesh - > SetM ( pMesh - > m_pRuler - > zmin , pMesh - > m_pRuler - > zmax ) ;
pMesh - > GetBitmap ( ) ;
bEdited = true ;
}
else if ( pOne - > GetType ( ) = = DOUBLEFOX_TEXT ) {
pOne - > ReadMemory ( buffElement , - 1 , buffLen , 3 ) ;
CText * pText = ( CText * ) ( pOne - > value ) ;
pText - > color = pOne - > color ;
bEdited = true ;
}
else if ( pOne - > GetType ( ) = = DOUBLEFOX_ELLIPSE )
{
pOne - > ReadMemory ( buffElement , 0 , buffLen , 3 ) ;
( ( CEllipse * ) ( pOne - > value ) ) - > color = pOne - > color ;
bEdited = true ;
}
else if ( pOne - > GetType ( ) = = DOUBLEFOX_CIRCLE )
{
pOne - > ReadMemory ( buffElement , 0 , buffLen , 3 ) ;
( ( CCircle * ) ( pOne - > value ) ) - > color = pOne - > color ;
bEdited = true ;
}
else if ( pOne - > GetType ( ) = = DOUBLEFOX_ARC )
{
pOne - > ReadMemory ( buffElement , 0 , buffLen , 3 ) ;
( ( CArc * ) ( pOne - > value ) ) - > color = pOne - > color ;
TRACE ( _T ( " CArc Width: " ) , ( ( CArc * ) ( pOne - > value ) ) - > m_dCurveWidth ) ;
bEdited = true ;
}
else if ( pOne - > GetType ( ) = = DOUBLEFOX_PROPORTION )
{
pOne - > ReadMemory ( buffElement , 0 , buffLen , 3 ) ;
( ( CProportion * ) ( pOne - > value ) ) - > color = pOne - > color ;
bEdited = true ;
}
else if ( pOne - > GetType ( ) = = DOUBLEFOX_SCALERULER )
{
pOne - > ReadMemory ( buffElement , 0 , buffLen , 3 ) ;
( ( CScaleRuler * ) ( pOne - > value ) ) - > color = pOne - > color ;
bEdited = true ;
}
else if ( pOne - > GetType ( ) = = DOUBLEFOX_CURVE )
{
CHowToViewCurve * pHWCOld = pOne - > HowToViewCurve ;
if ( pHWCOld ! = NULL )
{
pHWCOld - > Empty ( ) ;
}
pOne - > ReadMemory ( buffElement , 0 , buffLen , 3 ) ;
//if (pOne->HowToViewCurve != nullptr)
//{
// pOne->HowToViewCurve->EnableDrawSourceCurve(TRUE);
// pOne->HowToViewCurve->IsSolid();
// CCurveProperties* pCurveView = new CCurveProperties();
// pCurveView->SetCurveType(PLINE_SOLID);
// pCurveView->color = pOne->color;
// pOne->HowToViewCurve->Add(pCurveView);
//}
CString strName1 = pOne - > GetName ( ) ;
bEdited = true ;
}
else if ( pOne - > GetType ( ) = = DOUBLEFOX_BLOCK )
{
pOne - > ReadSummaryMemory ( buffElement , 0 , buffLen , 3 ) ;
bEdited = true ;
}
else
{
if ( pOne - > HowToViewCurve ! = NULL )
{
pOne - > HowToViewCurve - > Empty ( ) ;
}
pOne - > ReadMemory ( buffElement , - 1 , buffLen , 3 ) ;
bEdited = true ;
}
pAction - > BackupNewItem ( ) ;
pView - > m_pDoc - > SetActionItem ( pAction ) ;
return bEdited ;
}
/**
* <EFBFBD> <EFBFBD> ѡ <EFBFBD> е Ķ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
* \ return
*/
extern " C " __declspec ( dllexport )
BOOL SelectTextsSetElement ( CSigmaView * pView , BYTE * buffElement , int buffLen )
{
if ( pView = = nullptr | | buffElement = = nullptr | | buffLen < = 0 )
{
return FALSE ;
}
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = nullptr )
{
return FALSE ;
}
BOOL bEdited = FALSE ;
//<2F> <> ȡѡ <C8A1> <D1A1> <EFBFBD> б <EFBFBD>
CPositionList & selection = itemSelect - > m_selection ;
CActionModifiedItem * pAction = new CActionModifiedItem ( pView - > m_pDoc , IDS_STRING_TOOLBAR_EDIT ) ;
pAction - > BackupOldItem ( selection ) ;
for ( POSITION pos = selection . GetHeadPosition ( ) ; pos ! = nullptr ; selection . GetNext ( pos ) )
{
POSITION pt = selection . GetAt ( pos ) ;
COne * pOne = ( COne * ) ( pView - > m_pDoc - > m_pXy - > GetAt ( pt ) ) ;
// TODO: <20> ж<EFBFBD> <D0B6> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ƿ<EFBFBD> <C7B7> <EFBFBD> <EFBFBD> <EFBFBD>
if ( pOne - > GetType ( ) = = DOUBLEFOX_TEXT )
{
CLayer * pLayer = pOne - > GetLayer ( ) ;
CString layerName = pLayer - > GetName ( ) ;
CText * pText = ( CText * ) ( pOne - > value ) ;
CString textName = pText - > GetName ( ) ;
double tX = pText - > x0 ;
double tY = pText - > y0 ;
double tz = pText - > z0 ;
//<2F> <> <EFBFBD> ォ<EFBFBD> ⼸<EFBFBD> <E2BCB8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> õ<EFBFBD> buffElement<6E> <74> <EFBFBD> 滻
// 1. <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֽ<EFBFBD> <D6BD> <EFBFBD> <EFBFBD> <EFBFBD> תΪ C++ <20> ַ<EFBFBD> <D6B7> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 㴦<EFBFBD> <E3B4A6>
std : : string xmlStr ( ( const char * ) buffElement , buffLen ) ;
// 2. ת<> <D7AA> <EFBFBD> <EFBFBD> <EFBFBD> 룺<EFBFBD> <EBA3BA> MFC <20> <> CString ת<> <D7AA> Ϊ UTF-8<> <38> <EFBFBD> <EFBFBD> ֹ<EFBFBD> <D6B9> <EFBFBD> <EFBFBD> ͼ<EFBFBD> <CDBC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֳ<EFBFBD> <D6B3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
CStringA utf8Layer = CT2CA ( layerName , CP_UTF8 ) ;
CStringA utf8Name = CT2CA ( textName , CP_UTF8 ) ;
// 3. <20> <> ʽ <EFBFBD> <CABD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ַ<EFBFBD> <D6B7> <EFBFBD>
CStringA utf8Coord ;
utf8Coord . Format ( " <Coordinate>%.8f,%.8f,%.8f</Coordinate> " , tX , tY , tz ) ;
// 4. <20> <> <EFBFBD> <EFBFBD> <EFBFBD> 滻<EFBFBD> <E6BBBB> Layer="xxx" -> Layer="[<5B> <> ǰͼ<C7B0> <CDBC> <EFBFBD> <EFBFBD> ]"
std : : regex regLayer ( R " (Layer= " [ ^ " ]* " ) " );
std : : string repLayer = std : : string ( " Layer= \" " ) + utf8Layer . GetString ( ) + " \" " ;
xmlStr = std : : regex_replace ( xmlStr , regLayer , repLayer ) ;
// 5. <20> <> <EFBFBD> <EFBFBD> <EFBFBD> 滻<EFBFBD> <E6BBBB> Value="xxx" -> Value="[<5B> <> ǰ<EFBFBD> <C7B0> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ]"
std : : regex regValue ( R " (Value= " [ ^ " ]* " ) " );
std : : string repValue = std : : string ( " Value= \" " ) + utf8Name . GetString ( ) + " \" " ;
xmlStr = std : : regex_replace ( xmlStr , regValue , repValue ) ;
// 6. <20> <> <EFBFBD> <EFBFBD> <EFBFBD> 滻<EFBFBD> <E6BBBB> <Coordinate>xxx</Coordinate> -> <Coordinate>tX,tY,tz</Coordinate>
std : : regex regCoord ( R " (<Coordinate>.*?</Coordinate>) " ) ;
xmlStr = std : : regex_replace ( xmlStr , regCoord , utf8Coord . GetString ( ) ) ;
// 7. <20> <> <EFBFBD> ĺ<DEB8> <C4BA> <EFBFBD> ר<EFBFBD> <D7A8> <EFBFBD> ڵ<EFBFBD> ǰ<EFBFBD> <C7B0> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֵ<EFBFBD> XML <20> <> <EFBFBD> <EFBFBD> ReadMemory <20> <> <EFBFBD> <EFBFBD>
// ע<> <D7A2> <EFBFBD> <EFBFBD> <EFBFBD> ﳤ<EFBFBD> ȱ<EFBFBD> <C8B1> 봫 xmlStr.length()<29> <> <EFBFBD> <EFBFBD> Ϊ<EFBFBD> 滻<EFBFBD> <E6BBBB> <EFBFBD> ݺ<EFBFBD> XML <20> <> <EFBFBD> ܳ<EFBFBD> <DCB3> ȷ<EFBFBD> <C8B7> <EFBFBD> <EFBFBD> 仯<EFBFBD> <E4BBAF>
pOne - > ReadMemory ( ( BYTE * ) xmlStr . c_str ( ) , - 1 , xmlStr . length ( ) , 3 ) ;
pText - > color = pOne - > color ;
bEdited = TRUE ;
}
}
pAction - > BackupNewItem ( ) ;
pView - > m_pDoc - > SetActionItem ( pAction ) ;
return bEdited ;
}
extern " C " __declspec ( dllexport )
BOOL SetElementVisibility ( CSigmaView * pView , POSITION elementPtr , bool visible )
{
POSITION pos = ( POSITION ) elementPtr ;
COne * pOne = ( COne * ) ( pView - > m_pDoc - > GetDraw ( ) - > GetAt ( pos ) ) ;
if ( pOne = = nullptr )
{
return FALSE ;
}
if ( visible = = TRUE )
{
pOne - > SetViewState ( VIEW_STATE ) ; // <20> <> <EFBFBD> <EFBFBD> Ϊ<EFBFBD> ɼ<EFBFBD>
}
else
{
pOne - > SetViewState ( UNVIEW_STATE ) ; // <20> <> <EFBFBD> <EFBFBD> Ϊ<EFBFBD> <CEAA> <EFBFBD> ɼ<EFBFBD>
}
return TRUE ;
}
extern " C " __declspec ( dllexport )
BOOL SelectRemoveCurveStyle ( CSigmaView * pView , POSITION elementPtr , int index )
{
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return false ;
POSITION pos ;
pos = ( POSITION ) elementPtr ;
COne * pOne = ( COne * ) ( pView - > m_pDoc - > GetDraw ( ) - > GetAt ( pos ) ) ;
if ( pOne = = NULL ) return FALSE ;
if ( pOne - > HowToViewCurve = = NULL ) return FALSE ;
CHowToViewCurve * pHW = pOne - > HowToViewCurve ;
pHW - > RemoveAt ( index ) ;
if ( pHW - > GetCount ( ) = = 0 )
{
delete pOne - > HowToViewCurve ;
pOne - > HowToViewCurve = NULL ;
}
return TRUE ;
}
extern " C " __declspec ( dllexport )
BOOL SelectRemovePointStyle ( CSigmaView * pView , POSITION elementPtr )
{
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return false ;
POSITION pos ;
pos = ( POSITION ) elementPtr ;
COne * pOne = ( COne * ) ( pView - > m_pDoc - > GetDraw ( ) - > GetAt ( pos ) ) ;
if ( pOne = = NULL ) return FALSE ;
if ( pOne - > HowToViewPoint = = NULL ) return FALSE ;
delete pOne - > HowToViewPoint ;
pOne - > HowToViewPoint = nullptr ;
return TRUE ;
}
extern " C " __declspec ( dllexport )
BOOL SelectMoveUpCurveStyle ( CSigmaView * pView , POSITION elementPtr , int nIndex ) {
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return false ;
POSITION pos ;
pos = ( POSITION ) elementPtr ;
COne * pOne = ( COne * ) ( pView - > m_pDoc - > GetDraw ( ) - > GetAt ( pos ) ) ;
if ( pOne = = NULL ) return FALSE ;
if ( pOne - > HowToViewCurve = = NULL ) return FALSE ;
CHowToViewCurve * pHW = pOne - > HowToViewCurve ;
return pHW - > MoveUp ( nIndex ) ;
}
extern " C " __declspec ( dllexport )
BOOL SelectMoveDownCurveStyle ( CSigmaView * pView , POSITION elementPtr , int nIndex ) {
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return false ;
POSITION pos ;
pos = ( POSITION ) elementPtr ;
COne * pOne = ( COne * ) ( pView - > m_pDoc - > GetDraw ( ) - > GetAt ( pos ) ) ;
if ( pOne = = NULL ) return FALSE ;
if ( pOne - > HowToViewCurve = = NULL ) return FALSE ;
CHowToViewCurve * pHW = pOne - > HowToViewCurve ;
return pHW - > MoveDown ( nIndex ) ;
}
extern " C " __declspec ( dllexport )
int RenameElement ( CSigmaView * pView , LPCTSTR oldName , LPCTSTR newName , LPCTSTR layerName )
{
CXy * pXy = pView - > m_pDoc - > m_pXy ;
if ( pXy = = NULL ) return 0 ;
CString strLayer ( layerName ) ;
bool isLayerEmpty = strLayer . IsEmpty ( ) ;
CPtrList * pl = pXy - > GetValueList ( ) ;
POSITION posCurrent = pl - > GetHeadPosition ( ) ;
COne * pOne ;
int nCount = 0 ;
while ( posCurrent )
{
pOne = pXy - > GetAt ( posCurrent ) ;
if ( pOne - > GetName ( ) = = oldName )
{
if ( ! isLayerEmpty & & strLayer ! = pOne - > GetLayer ( ) - > GetName ( ) )
{
pl - > GetNext ( posCurrent ) ;
continue ;
}
pOne - > SetName ( newName ) ;
nCount + + ;
}
pl - > GetNext ( posCurrent ) ;
}
return nCount ;
}
extern " C " __declspec ( dllexport )
int ResetCurveStyle ( CSigmaView * pView , LPCTSTR curveName , LPCTSTR layerName , int type , BYTE * buffCurve , int bufLen )
{
CXy * pXy = pView - > m_pDoc - > m_pXy ;
if ( pXy = = NULL ) return 0 ;
CString strLayer ( layerName ) ;
bool isLayerEmpty = strLayer . IsEmpty ( ) ;
CPtrList * pl = pXy - > GetValueList ( ) ;
POSITION posCurrent = pl - > GetHeadPosition ( ) ;
COne * pOne ;
int nCount = 0 ;
while ( posCurrent )
{
pOne = pXy - > GetAt ( posCurrent ) ;
if ( pOne - > GetType ( ) = = DOUBLEFOX_CURVE & & pOne - > GetName ( ) = = curveName )
{
if ( ! isLayerEmpty & & strLayer ! = pOne - > GetLayer ( ) - > GetName ( ) )
{
pl - > GetNext ( posCurrent ) ;
continue ;
}
if ( pOne - > HowToViewCurve = = NULL ) {
pOne - > HowToViewCurve = new CHowToViewCurve ( ) ;
}
CHowToViewCurve * pHWCOld = pOne - > 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 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 ;
}
pHWCOld - > SetAt ( pHWCOld - > GetCount ( ) - 1 , buffCurve , bufLen , 3 ) ;
nCount + + ;
}
pl - > GetNext ( posCurrent ) ;
}
return nCount ;
}
extern " C " __declspec ( dllexport )
BOOL SelectCreateCurveStyle ( CSigmaView * pView , POSITION elementPtr , int type , BYTE * buffCurve , int bufLen )
{
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return false ;
POSITION pos ;
pos = ( POSITION ) elementPtr ;
COne * pOne = ( COne * ) ( pView - > m_pDoc - > GetDraw ( ) - > GetAt ( pos ) ) ;
if ( pOne = = NULL ) return FALSE ;
if ( pOne - > HowToViewCurve = = NULL ) {
pOne - > HowToViewCurve = new CHowToViewCurve ( ) ;
}
CHowToViewCurve * pHWCOld = pOne - > HowToViewCurve ;
//Ϊ<> <CEAA> <EFBFBD> <EFBFBD> <EFBFBD> ε<EFBFBD> Redo/Undo
CActionEmbellishItem * pActionItem = new CActionEmbellishItem ( pView - > m_pDoc , ActionTypeLayerEmbellishCurveAdd , pOne ) ;
pActionItem - > SetOldHowToView ( pOne ) ; // <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
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 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 result = pHWCOld - > SetAt ( pHWCOld - > GetCount ( ) - 1 , buffCurve , bufLen , 3 ) ! = NULL ;
pActionItem - > SetNewHowToView ( pOne ) ;
pView - > m_pDoc - > SetActionItem ( pActionItem ) ;
return result ;
}
extern " C " __declspec ( dllexport )
BOOL SelectCreatePointStyle ( CSigmaView * pView , POSITION elementPtr , BYTE * buffPoint , int bufLen )
{
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return false ;
POSITION pos ;
pos = ( POSITION ) elementPtr ;
COne * pOne = ( COne * ) ( pView - > m_pDoc - > GetDraw ( ) - > GetAt ( pos ) ) ;
if ( pOne = = NULL ) return FALSE ;
CHowToViewPoint htp ;
BOOL bSuccess = htp . ReadMemory ( buffPoint , bufLen , 3 ) ;
if ( bSuccess = = FALSE ) {
return FALSE ;
}
CActionEmbellishItem * pActionItem = new CActionEmbellishItem ( pView - > m_pDoc , 0 , pOne ) ;
pActionItem - > SetOldHowToView ( pOne ) ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
if ( pOne - > HowToViewPoint = = NULL ) {
pOne - > HowToViewPoint = new CHowToViewPoint ( ) ;
}
* ( pOne - > HowToViewPoint ) = htp ;
pActionItem - > SetNewHowToView ( pOne ) ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
pView - > m_pDoc - > Modified ( ) ;
pView - > m_pDoc - > SetActionItem ( pActionItem ) ;
return TRUE ;
}
extern " C " __declspec ( dllexport )
BOOL SelectGetLayerNames ( CSigmaView * pView , BYTE * & buffData , int & bufLen )
{
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return false ;
CString layers ;
CPositionList * ppl = & ( itemSelect - > m_selection ) ;
if ( ppl ! = NULL & & ! ppl - > IsEmpty ( ) )
{
layers = pView - > m_pDoc - > GetSelectedElementLayer ( * ppl ) ;
bufLen = layers . GetLength ( ) ;
buffData = new BYTE [ bufLen + 1 ] ;
memcpy ( buffData , ( VOID * ) LPCTSTR ( layers ) , bufLen ) ;
}
return true ;
}
extern " C " __declspec ( dllexport )
BOOL SelectGetLayerName ( CSigmaView * pView , POSITION elementPtr , char * buffPoint , int bufLen )
{
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return false ;
POSITION pos ;
pos = ( POSITION ) elementPtr ;
COne * pOne = ( COne * ) ( pView - > m_pDoc - > GetDraw ( ) - > GetAt ( pos ) ) ;
if ( pOne = = NULL ) return FALSE ;
CLayer * pLayer = pOne - > GetLayer ( ) ;
if ( pLayer = = NULL ) return FALSE ;
CString name = pLayer - > GetName ( ) ;
strncpy ( buffPoint , name . GetBuffer ( ) , min ( bufLen , name . GetLength ( ) + 1 ) ) ;
return TRUE ;
}
extern " C " __declspec ( dllexport )
BOOL SelectSetLayerByName ( CSigmaView * pView , POSITION elementPtr , LPCTSTR layerName )
{
CXy * pxy = pView - > m_pDoc - > m_pXy ;
CLayer * pLayer = pxy - > FindLayer ( layerName ) ;
if ( pLayer = = NULL ) return FALSE ;
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL ) return FALSE ;
POSITION pos ;
pos = ( POSITION ) elementPtr ;
COne * pOne = ( COne * ) ( pView - > m_pDoc - > GetDraw ( ) - > GetAt ( pos ) ) ;
if ( pOne = = NULL ) return FALSE ;
pOne - > SetLayer ( pLayer ) ;
return TRUE ;
}
extern " C " __declspec ( dllexport )
int ItemSelectElement_GetCountSelected ( CSigmaView * pView )
{
if ( pView = = 0 )
return - 1 ;
CItemSelectElement * item = GetCItemSelectElementFromView ( pView ) ;
if ( item = = 0 )
return - 1 ;
return item - > GetCountSelected ( ) ;
}
extern " C " __declspec ( dllexport )
int Select_HightLightFirstCurve ( CSigmaView * pView , HDC hdc )
{
if ( pView = = 0 )
return - 1 ;
CItemBreakCurve * item = GetCItemBreakCurveFromView ( pView ) ;
if ( item = = 0 )
return - 1 ;
CDC * pDC = CDC : : FromHandle ( hdc ) ;
pView - > SetDrawDC ( pDC ) ;
item - > HightLightFirstCurve ( ) ;
return 1 ;
}
extern " C " __declspec ( dllexport )
BOOL SelectSetCursor ( CSigmaView * pView , int ptX , int ptY , int & handle )
{
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return - 1 ;
BOOL bSuccess = itemSelect - > OnSetCursor ( CPoint ( ptX , ptY ) , handle ) ;
return bSuccess ;
}
extern " C " __declspec ( dllexport )
BOOL SelectGetHandle ( CSigmaView * pView , int ptX , int ptY , int & handle )
{
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return - 1 ;
BOOL bSuccess = itemSelect - > GetHandle ( CPoint ( ptX , ptY ) , handle ) ;
return bSuccess ;
}
extern " C " __declspec ( dllexport )
int Select_GetKindOfSelectedElement ( CSigmaView * pView )
{
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return - 1 ;
if ( itemSelect - > m_selection . IsEmpty ( ) )
return - 1 ;
POSITION pos = itemSelect - > m_selection . GetHead ( ) ;
if ( pos = = 0 )
return - 1 ;
COne * pOne = ( COne * ) ( pView - > m_pDoc - > GetDraw ( ) - > GetAt ( pos ) ) ;
if ( pOne = = 0 )
return - 1 ;
return pOne - > GetType ( ) ;
}
extern " C " __declspec ( dllexport )
int Select_ByNames ( CSigmaView * pView , LPCTSTR data ) {
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return 0 ;
CString strData ( data ) ;
itemSelect - > SelectByNames ( strData ) ;
return 1 ;
}
extern " C " __declspec ( dllexport )
int Select_SelectAll ( CSigmaView * pView )
{
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return - 1 ;
itemSelect - > SelectAll ( ) ;
return 1 ;
}
extern " C " __declspec ( dllexport )
int Select_ClearAll ( CSigmaView * pView )
{
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return - 1 ;
itemSelect - > ClearAll ( nullptr ) ;
return 1 ;
}
extern " C " __declspec ( dllexport )
int Select_SelectAllByKind ( CSigmaView * pView , int kind )
{
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return - 1 ;
itemSelect - > SelectAll ( kind ) ;
return 1 ;
}
extern " C " __declspec ( dllexport )
int Select_ReloadTrack ( CSigmaView * pView )
{
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return - 1 ;
pView - > m_pDoc - > GetSelectionSet ( itemSelect - > m_selection ) ;
itemSelect - > ReloadTrackerPath ( ) ;
return 0 ;
}
extern " C " __declspec ( dllexport )
int Select_EnableTracker ( CSigmaView * pView , int bEnable )
{
if ( pView = = 0 )
return - 1 ;
if ( pView - > m_pDoc = = 0 )
return - 1 ;
CItemSelect * pSelect = pView - > m_pDoc - > GetSelectItem ( ) ;
if ( pSelect )
{
pSelect - > EnableTracker ( bEnable = = 1 ? true : false ) ;
}
return 1 ;
}
extern " C " __declspec ( dllexport )
int Select_SelectOneGraph ( CSigmaView * pView , POSITION pos )
{
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return - 1 ;
itemSelect - > Select ( pos , FALSE ) ;
itemSelect - > ReloadTrackerPath ( ) ;
return 1 ;
}
extern " C " __declspec ( dllexport )
void Select_CreateGroup ( CSigmaView * pView , POSITION & pos )
{
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return ;
pos = itemSelect - > GroupSelectionToBlock ( ) ;
}
extern " C " __declspec ( dllexport )
bool Select_UngroupAll ( CSigmaView * pView , int & layerCount )
{
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return false ;
return itemSelect - > UngroupAll ( layerCount ) ;
}
extern " C " __declspec ( dllexport )
bool Select_SaveSelectKml ( CSigmaView * pView , POSITION pos , LPCTSTR path )
{
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return false ;
CXy * pXyCurrent = pView - > m_pDoc - > GetDraw ( ) ;
return itemSelect - > SaveSelectKml ( pos , pXyCurrent , path ) ;
}
extern " C " __declspec ( dllexport )
bool Select_DisperseMetaEmf ( CSigmaView * pView , POSITION pos , long timestamp )
{
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return false ;
CXy * pXyCurrent = pView - > m_pDoc - > GetDraw ( ) ;
return itemSelect - > DisperseMetaEmf ( pos , pXyCurrent , timestamp ) ;
}
extern " C " __declspec ( dllexport )
int Select_PointCount ( CSigmaView * pView )
{
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = NULL )
return - 1 ;
return itemSelect - > PointCount ( ) ;
}
extern " C " __declspec ( dllexport )
void SelectChangeToLayer ( CSigmaView * pView , LPCTSTR layerName )
{
CItemSelect * itemSelect = GetItemSelectFromView ( pView ) ;
if ( itemSelect = = nullptr )
{
return ;
}
CXy * pXy = pView - > m_pDoc - > m_pXy ;
CLayer * pLayer = pXy - > FindLayer ( layerName ) ;
if ( pLayer = = nullptr )
{
return ;
}
CPositionList & selection = itemSelect - > m_selection ;
for ( POSITION pos = selection . GetHeadPosition ( ) ; pos ! = nullptr ; selection . GetNext ( pos ) )
{
POSITION pt = selection . GetAt ( pos ) ;
COne * pOne = ( COne * ) ( pXy - > GetAt ( pt ) ) ;
pOne - > SetLayer ( pLayer ) ;
}
}
extern " C " __declspec ( dllexport )
BOOL HasMeshState ( CSigmaView * pView , POSITION oldMeshPos )
{
CXy * pXyCurrent = pView - > m_pDoc - > GetDraw ( ) ;
if ( oldMeshPos = = nullptr )
{
oldMeshPos = pXyCurrent - > FindFirstElement ( DOUBLEFOX_MESH ) ;
}
if ( oldMeshPos = = nullptr ) {
return false ;
}
else
{
return true ;
}
}