From 6735c79753bfea5a5f52682c5e0719cc44dca804 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Sat, 20 Sep 2014 22:05:32 +0000 Subject: [PATCH] EgtInterface : - piccoli miglioramenti. --- API_Exchange.cpp | 136 +++++++++++++++++++++++++++++++++++ API_GdbObjects.cpp | 10 +++ API_GeomDB.cpp | 94 ------------------------ EInDllMain.cpp | 4 +- EgtInterface.vcxproj | 15 ++-- EgtInterface.vcxproj.filters | 3 + 6 files changed, 160 insertions(+), 102 deletions(-) create mode 100644 API_Exchange.cpp diff --git a/API_Exchange.cpp b/API_Exchange.cpp new file mode 100644 index 0000000..a29af58 --- /dev/null +++ b/API_Exchange.cpp @@ -0,0 +1,136 @@ +//---------------------------------------------------------------------------- +// EgalTech 2014-2014 +//---------------------------------------------------------------------------- +// File : API_Exchange.cpp Data : 20.09.14 Versione : 1.5i4 +// Contenuto : Funzioni import/export per API. +// +// +// +// Modifiche : 20.09.14 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "API.h" +#include "API_Macro.h" +#include "/EgtDev/Include/EInAPI.h" +#include "/EgtDev/Include/EExImportStl.h" +#include "/EgtDev/Include/EExImportDxf.h" +#include "/EgtDev/Include/EExImportCnc.h" +#include "/EgtDev/Include/EExExportStl.h" +#include "/EgtDev/Include/EExExportDxf.h" +#include "/EgtDev/Include/EGnStringUtils.h" +#include "/EgtDev/Include/EGnStringConverter.h" +#include "/EgtDev/Include/EgtPointerOwner.h" + +using namespace std ; + +//----------------------------------------------------------------------------- +int +__stdcall EgtGetFileType( const wchar_t* wsFilePath) +{ + // divido in nome e direttorio + string sFileDir, sFileName ; + SplitLast( wstrztoA( wsFilePath), "\\", sFileDir, sFileName) ; + + // recupero l'estensione + string sFileTitle, sFileExt ; + SplitLast( sFileName, ".", sFileTitle, sFileExt) ; + ToUpper( sFileExt) ; + + if ( sFileExt == "NGE") + return 1 ; + else if ( sFileExt == "NFE") + return 2 ; + else if ( sFileExt == "DXF") + return 11 ; + else if ( sFileExt == "STL") + return 12 ; + else if ( sFileExt == "CNC") + return 13 ; + else { + // emetto info + string sInfo = "File type (" + sFileExt + ") not recognized" ; + LOG_INFO( GetLogger(), sInfo.c_str()) + return 0 ; + } +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtImportDxf( int nGseCtx, const wchar_t* wsFilePath) +{ + IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; + VERIFY_GEOMDB( pGeomDB, FALSE) + // importo il file DXF + // aggiungo un gruppo pezzo + int nPartId = pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ; + // preparo l'importatore + PtrOwner pImpDxf( CreateImportDxf()) ; + VERIFY_NULL( Get( pImpDxf), "Error in CreateImportDxf", FALSE) + // eseguo l'importazione + return ( pImpDxf->Import( wstrztoA( wsFilePath), pGeomDB, nPartId) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtImportStl( int nGseCtx, const wchar_t* wsFilePath) +{ + IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; + VERIFY_GEOMDB( pGeomDB, FALSE) + // importo il file STL + // aggiungo un gruppo pezzo e un gruppo layer + int nPartId = pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ; + int nLayerId = pGeomDB->AddGroup( GDB_ID_NULL, nPartId, Frame3d()) ; + // preparo l'importatore + PtrOwner pImpStl( CreateImportStl()) ; + VERIFY_NULL( Get( pImpStl), "Error in CreateImportStl", FALSE) + // eseguo l'importazione + return ( pImpStl->Import( wstrztoA( wsFilePath), pGeomDB, nLayerId) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtImportCnc( int nGseCtx, const wchar_t* wsFilePath) +{ + IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; + VERIFY_GEOMDB( pGeomDB, FALSE) + // importo il file CNC + // aggiungo un gruppo pezzo + int nPartId = pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ; + // preparo l'importatore + PtrOwner pImpCnc( CreateImportCnc()) ; + VERIFY_NULL( Get( pImpCnc), "Error in CreateImportCnc", FALSE) + // eseguo l'importazione + return ( pImpCnc->Import( wstrztoA( wsFilePath), pGeomDB, nPartId) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtExportDxf( int nGseCtx, int nId, const wchar_t* wsFilePath) +{ + IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; + VERIFY_GEOMDB( pGeomDB, FALSE) + // esporto il file DXF + // preparo l'esportatore + PtrOwner pExpDxf( CreateExportDxf()) ; + VERIFY_NULL( Get( pExpDxf), "Error in CreateExportDxf", FALSE) + // eseguo l'esportazione + return ( pExpDxf->Export( pGeomDB, nId, wstrztoA( wsFilePath)) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtExportStl( int nGseCtx, int nId, const wchar_t* wsFilePath) +{ + IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; + VERIFY_GEOMDB( pGeomDB, FALSE) + // esporto il file STL + // preparo l'esportatore + PtrOwner pExpStl( CreateExportStl()) ; + VERIFY_NULL( Get( pExpStl), "Error in CreateExportStl", FALSE) + // eseguo l'esportazione + return ( pExpStl->Export( pGeomDB, nId, wstrztoA( wsFilePath)) ? TRUE : FALSE) ; +} diff --git a/API_GdbObjects.cpp b/API_GdbObjects.cpp index 780f236..2b7d750 100644 --- a/API_GdbObjects.cpp +++ b/API_GdbObjects.cpp @@ -33,6 +33,16 @@ BOOL return ( pGeomDB->ExistsObj( nId) ? TRUE : FALSE) ; } +//----------------------------------------------------------------------------- +int + __stdcall EgtGetGroupObjs( int nGseCtx, int nId) + { + IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + // recupero il primo oggetto nel gruppo + return ( pGeomDB->GetGroupObjs( nId)) ; + } + //----------------------------------------------------------------------------- int __stdcall EgtGetFirstInGroup( int nGseCtx, int nGroupId) diff --git a/API_GeomDB.cpp b/API_GeomDB.cpp index 4cbe9e1..cc9a67b 100644 --- a/API_GeomDB.cpp +++ b/API_GeomDB.cpp @@ -16,10 +16,6 @@ #include "API.h" #include "API_Macro.h" #include "/EgtDev/Include/EInAPI.h" -#include "/EgtDev/Include/EExImportStl.h" -#include "/EgtDev/Include/EExImportDxf.h" -#include "/EgtDev/Include/EExExportStl.h" -#include "/EgtDev/Include/EExExportDxf.h" #include "/EgtDev/Include/EGnStringUtils.h" #include "/EgtDev/Include/EGnStringConverter.h" #include "/EgtDev/Include/EgtPointerOwner.h" @@ -95,93 +91,3 @@ __stdcall EgtSaveFile( int nGseCtx, const wchar_t* wsFilePath, int nFlag) // salvo il file return ( pGeomDB->Save( wstrztoA( wsFilePath), nFlag) ? TRUE : FALSE) ; } - -//----------------------------------------------------------------------------- -int -__stdcall EgtGetFileType( const wchar_t* wsFilePath) -{ - // divido in nome e direttorio - string sFileDir, sFileName ; - SplitLast( wstrztoA( wsFilePath), "\\", sFileDir, sFileName) ; - - // recupero l'estensione - string sFileTitle, sFileExt ; - SplitLast( sFileName, ".", sFileTitle, sFileExt) ; - ToUpper( sFileExt) ; - - if ( sFileExt == "NGE") - return 1 ; - else if ( sFileExt == "NFE") - return 2 ; - else if ( sFileExt == "DXF") - return 11 ; - else if ( sFileExt == "STL") - return 12 ; - else { - // emetto info - string sInfo = "File type (" + sFileExt + ") not recognized" ; - LOG_INFO( GetLogger(), sInfo.c_str()) - return 0 ; - } -} - -//----------------------------------------------------------------------------- -BOOL -__stdcall EgtImportDxf( int nGseCtx, const wchar_t* wsFilePath) -{ - IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // importo il file DXF - // aggiungo un gruppo pezzo - int nPartId = pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ; - // preparo l'importatore - PtrOwner pImpDxf( CreateImportDxf()) ; - VERIFY_NULL( Get( pImpDxf), "Error in CreateImportDxf", FALSE) - // eseguo l'importazione - return ( pImpDxf->Import( wstrztoA( wsFilePath), pGeomDB, nPartId) ? TRUE : FALSE) ; -} - -//----------------------------------------------------------------------------- -BOOL -__stdcall EgtImportStl( int nGseCtx, const wchar_t* wsFilePath) -{ - IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // importo il file STL - // aggiungo un gruppo pezzo e un gruppo layer - int nPartId = pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ; - int nLayerId = pGeomDB->AddGroup( GDB_ID_NULL, nPartId, Frame3d()) ; - // preparo l'importatore - PtrOwner pImpStl( CreateImportStl()) ; - VERIFY_NULL( Get( pImpStl), "Error in CreateImportStl", FALSE) - // eseguo l'importazione - return ( pImpStl->Import( wstrztoA( wsFilePath), pGeomDB, nLayerId) ? TRUE : FALSE) ; -} - -//----------------------------------------------------------------------------- -BOOL -__stdcall EgtExportDxf( int nGseCtx, int nId, const wchar_t* wsFilePath) -{ - IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // esporto il file DXF - // preparo l'esportatore - PtrOwner pExpDxf( CreateExportDxf()) ; - VERIFY_NULL( Get( pExpDxf), "Error in CreateExportDxf", FALSE) - // eseguo l'esportazione - return ( pExpDxf->Export( pGeomDB, nId, wstrztoA( wsFilePath)) ? TRUE : FALSE) ; -} - -//----------------------------------------------------------------------------- -BOOL -__stdcall EgtExportStl( int nGseCtx, int nId, const wchar_t* wsFilePath) -{ - IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // esporto il file STL - // preparo l'esportatore - PtrOwner pExpStl( CreateExportStl()) ; - VERIFY_NULL( Get( pExpStl), "Error in CreateExportStl", FALSE) - // eseguo l'esportazione - return ( pExpStl->Export( pGeomDB, nId, wstrztoA( wsFilePath)) ? TRUE : FALSE) ; -} diff --git a/EInDllMain.cpp b/EInDllMain.cpp index 497de48..d9bb7e4 100644 --- a/EInDllMain.cpp +++ b/EInDllMain.cpp @@ -31,7 +31,7 @@ const char* EIN_STR = "EgtInterfaceR32.dll ver. " ; #endif #endif -const int STR_DIM = 40 ; +const int STR_DIM = 50 ; //----------------------------------------------------------------------------- static HINSTANCE s_hModule = NULL ; @@ -63,7 +63,7 @@ DllMain( HMODULE hModule, DWORD dwReason, LPVOID lpReserved) //----------------------------------------------------------------------------- const char* -GetEInVersion( void) +__stdcall GetEInVersion( void) { std::string sVer ; diff --git a/EgtInterface.vcxproj b/EgtInterface.vcxproj index e371f96..72f3f9e 100644 --- a/EgtInterface.vcxproj +++ b/EgtInterface.vcxproj @@ -105,7 +105,7 @@ copy $(TargetDir)$(TargetName).lib \EgtDev\Lib\ copy $(TargetPath) \EgtProg\DllD32 - _UNICODE;UNICODE;_DEB32;%(PreprocessorDefinitions) + _UNICODE;UNICODE;_DEBUG;_DEB32;%(PreprocessorDefinitions) @@ -114,11 +114,13 @@ copy $(TargetPath) \EgtProg\DllD32 Level3 Disabled WIN32;I_AM_EIN;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + false Windows true $(OutDir)$(TargetName)$(TargetExt) + true copy $(TargetDir)$(TargetName).pdb \EgtDev\Lib\ @@ -126,7 +128,7 @@ copy $(TargetDir)$(TargetName).lib \EgtDev\Lib\ copy $(TargetPath) \EgtProg\DllD64 - _UNICODE;UNICODE;_DEB64;%(PreprocessorDefinitions) + _UNICODE;UNICODE;_DEBUG;_DEB64;%(PreprocessorDefinitions) @@ -142,7 +144,7 @@ copy $(TargetPath) \EgtProg\DllD64 Windows - true + false true true $(OutDir)$(TargetName)$(TargetExt) @@ -152,7 +154,7 @@ copy $(TargetPath) \EgtProg\DllD64 copy $(TargetPath) \EgtProg\Dll32 - _UNICODE;UNICODE;NDEB32;%(PreprocessorDefinitions) + _UNICODE;UNICODE;NDEBUG;NDEB32;%(PreprocessorDefinitions) @@ -169,7 +171,7 @@ copy $(TargetPath) \EgtProg\Dll32 Windows - true + false true true $(OutDir)$(TargetName)$(TargetExt) @@ -179,7 +181,7 @@ copy $(TargetPath) \EgtProg\Dll32 copy $(TargetPath) \EgtProg\Dll64 - _UNICODE;UNICODE;NDEB64;%(PreprocessorDefinitions) + _UNICODE;UNICODE;NDEBUG;NDEB64;%(PreprocessorDefinitions) @@ -192,6 +194,7 @@ copy $(TargetPath) \EgtProg\Dll64 + diff --git a/EgtInterface.vcxproj.filters b/EgtInterface.vcxproj.filters index 6b0c129..522981e 100644 --- a/EgtInterface.vcxproj.filters +++ b/EgtInterface.vcxproj.filters @@ -65,6 +65,9 @@ File di origine + + File di origine +