From 15633ec6d7e75f322a4fb7082c5b63dc77d913aa Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 14 Nov 2023 18:58:01 +0100 Subject: [PATCH] EgtExecutor : - modifiche per spostamento import/export da dll Exchange a dll Exch3dm. --- DllExch3dm.cpp | 181 ++++++++++++++++++++++++++++++++++++ DllExch3dm.h | 31 ++++++ DllExchange.cpp | 36 +------ DllExchange.h | 4 - EXE_Exchange.cpp | 5 +- EXE_General.cpp | 17 +++- EgtExecutor.vcxproj | 2 + EgtExecutor.vcxproj.filters | 6 ++ 8 files changed, 239 insertions(+), 43 deletions(-) create mode 100644 DllExch3dm.cpp create mode 100644 DllExch3dm.h diff --git a/DllExch3dm.cpp b/DllExch3dm.cpp new file mode 100644 index 0000000..f831ef2 --- /dev/null +++ b/DllExch3dm.cpp @@ -0,0 +1,181 @@ +//---------------------------------------------------------------------------- +// EgalTech 2023-2023 +//---------------------------------------------------------------------------- +// File : DllExch3dm.cpp Data : 14.11.23 Versione : 2.5k2 +// Contenuto : Funzioni di gestione della libreria opzionale EgtExch3dme. +// +// +// +// Modifiche : 14.11.23 DS Creazione modulo. +// +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "EXE.h" +#include "DllExch3dm.h" +#include "/EgtDev/Include/EE3DllMain.h" +#define NOMINMAX +#include + +using namespace std ; + +//----------------------------------------------------------------------------- +// Nome della libreria +#if defined( _WIN64) && defined( _DEBUG) + static const wchar_t* EE3_NAME = L"EgtExch3dmD64.dll" ; +#elif defined( _WIN64) + static const wchar_t* EE3_NAME = L"EgtExch3dmR64.dll" ; +#elif defined( _WIN32) && defined( _DEBUG) + static const wchar_t* EE3_NAME = L"EgtExch3dmD32.dll" ; +#else + static const wchar_t* EE3_NAME = L"EgtExch3dmR32.dll" ; +#endif +// Nome delle funzioni caricate +static const char* EE3_SETEE3LOGGER = "SetEE3Logger" ; +static const char* EE3_GETEE3VERSION = "GetEE3Version" ; +static const char* EE3_SETEE3KEY = "SetEE3Key" ; +static const char* EE3_SETEE3NETHWKEY = "SetEE3NetHwKey" ; +static const char* EE3_CREATEIMPORT3DM = "CreateImport3dm" ; +static const char* EE3_CREATEEXPORT3DM = "CreateExport3dm" ; + + +//----------------------------------------------------------------------------- +HMODULE s_hEE3 = nullptr ; + +//----------------------------------------------------------------------------- +bool +LoadExch3dmDll( ILogger* pLogger, const string& sKey, bool bNetHwKey) +{ + // verifico la chiave + if ( ! TestKeyForEE3( sKey, 0, pLogger)) { + FreeExch3dmDll() ; + return false ; + } + // se già caricata + if ( s_hEE3 != nullptr) + return true ; + // carico la libreria EgtExch3dm + s_hEE3 = LoadLibrary( EE3_NAME) ; + if ( s_hEE3 == nullptr) + return false ; + // imposto logger + MySetEE3Logger( pLogger) ; + // imposto i codici della chiave + MySetEE3Key( sKey) ; + // imposto eventuale chiave di rete + MySetEE3NetHwKey( bNetHwKey) ; + return true ; +} + +//----------------------------------------------------------------------------- +bool +FreeExch3dmDll( void) +{ + // se non è già caricata + if ( s_hEE3 == nullptr) + return true ; + // libero la libreria EgtExch3dm + FreeLibrary( s_hEE3) ; + s_hEE3 = nullptr ; + return true ; +} + +//----------------------------------------------------------------------------- +bool +IsLoadedExch3dmDll( void) +{ + return ( s_hEE3 != nullptr) ; +} + +//----------------------------------------------------------------------------- +void +MySetEE3Logger( ILogger* pLogger) +{ + // verifico caricamento libreria EgtExch3dm + if ( s_hEE3 == nullptr) + return ; + // recupero funzione che imposta il logger + typedef void (* PF_SetEE3Logger) ( ILogger* pLogger) ; + PF_SetEE3Logger pFun = (PF_SetEE3Logger)GetProcAddress( s_hEE3, EE3_SETEE3LOGGER) ; + if ( pFun == nullptr) + return ; + pFun( pLogger) ; +} + +//----------------------------------------------------------------------------- +const char* +MyGetEE3Version( void) +{ + // verifico caricamento libreria EgtExch3dm + if ( s_hEE3 == nullptr) + return "" ; + // recupero funzione che restituisce la versione della libreria + typedef const char* (* PF_GetEE3Version) ( void) ; + PF_GetEE3Version pFun = (PF_GetEE3Version)GetProcAddress( s_hEE3, EE3_GETEE3VERSION) ; + if ( pFun == nullptr) + return "" ; + return pFun() ; +} + +//----------------------------------------------------------------------------- +void +MySetEE3Key( const string& sKey) +{ + // verifico caricamento libreria EgtExch3dm + if ( s_hEE3 == nullptr) + return ; + // recupero funzione che imposta i codici di protezione + typedef void (* PF_SetEE3Key) ( const string& sKey) ; + PF_SetEE3Key pFun = (PF_SetEE3Key)GetProcAddress( s_hEE3, EE3_SETEE3KEY) ; + if ( pFun == nullptr) + return ; + pFun( sKey) ; +} + +//----------------------------------------------------------------------------- +void +MySetEE3NetHwKey( bool bNetHwKey) +{ + // verifico caricamento libreria EgtExch3dm + if ( s_hEE3 == nullptr) + return ; + // recupero funzione che imposta il flag per chiave di rete + typedef void (* PF_SetEE3NetHwKey) ( bool bNetHwKey) ; + PF_SetEE3NetHwKey pFun = (PF_SetEE3NetHwKey)GetProcAddress( s_hEE3, EE3_SETEE3NETHWKEY) ; + if ( pFun == nullptr) + return ; + pFun( bNetHwKey) ; +} + +//----------------------------------------------------------------------------- +IImport3dm* +MyCreateImport3dm( void) +{ + // verifico caricamento libreria EgtExch3dm + if ( s_hEE3 == nullptr) + return nullptr ; + // recupero funzione creazione oggetto + typedef IImport3dm* (* PF_CreateImport3dm) ( void) ; + PF_CreateImport3dm pFun = (PF_CreateImport3dm)GetProcAddress( s_hEE3, EE3_CREATEIMPORT3DM) ; + if ( pFun == nullptr) + return nullptr ; + return pFun() ; +} + +//----------------------------------------------------------------------------- +IExport3dm* +MyCreateExport3dm( void) +{ + // verifico caricamento libreria EgtExch3dm + if ( s_hEE3 == nullptr) + return nullptr ; + // recupero funzione creazione oggetto + typedef IExport3dm* (* PF_CreateExport3dm) ( void) ; + PF_CreateExport3dm pFun = (PF_CreateExport3dm)GetProcAddress( s_hEE3, EE3_CREATEEXPORT3DM) ; + if ( pFun == nullptr) + return nullptr ; + return pFun() ; +} diff --git a/DllExch3dm.h b/DllExch3dm.h new file mode 100644 index 0000000..baa8d44 --- /dev/null +++ b/DllExch3dm.h @@ -0,0 +1,31 @@ +//---------------------------------------------------------------------------- +// EgalTech 2023-2023 +//---------------------------------------------------------------------------- +// File : DllExch3dm.h Data : 14.11.23 Versione : 2.5k3 +// Contenuto : Dichiarazioni funzioni per libreria opzionale EgtExchange. +// +// +// +// Modifiche : 14.11.23 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +#include + +class ILogger ; +class IImport3dm ; +class IExport3dm ; + +//---------------------------------------------------------------------------- +bool LoadExch3dmDll( ILogger* pLogger, const std::string& sKey, bool bNetHwKey) ; +bool FreeExch3dmDll( void) ; +bool IsLoadedExch3dmDll( void) ; +void MySetEE3Logger( ILogger* pLogger) ; +void MySetEE3Key( const std::string& sKey) ; +void MySetEE3NetHwKey( bool bNetHwKey) ; +const char* MyGetEE3Version( void) ; +IImport3dm* MyCreateImport3dm( void) ; +IExport3dm* MyCreateExport3dm( void) ; diff --git a/DllExchange.cpp b/DllExchange.cpp index 9781d7d..3548d35 100644 --- a/DllExchange.cpp +++ b/DllExchange.cpp @@ -51,11 +51,9 @@ static const char* EEX_CREATEIMPORTDXF = "CreateImportDxf" ; static const char* EEX_CREATEIMPORTPNT = "CreateImportPnt" ; static const char* EEX_CREATEIMPORTSTL = "CreateImportStl" ; static const char* EEX_CREATEIMPORT3MF = "CreateImport3MF" ; -static const char* EEX_CREATEIMPORT3DM = "CreateImport3dm" ; static const char* EEX_CREATEEXPORTDXF = "CreateExportDxf" ; static const char* EEX_CREATEEXPORTSTL = "CreateExportStl" ; static const char* EEX_CREATEEXPORT3MF = "CreateExport3MF" ; -static const char* EEX_CREATEEXPORT3DM = "CreateExport3dm" ; static const char* EEX_CREATEEXPORTSVG = "CreateExportSvg" ; static const char* EEX_SETTHREEJSLIBDIR = "SetThreeJSLibDir" ; static const char* EEX_CREATEEXPORTTHREEJS = "CreateExportThreeJS" ; @@ -74,7 +72,7 @@ LoadExchangeDll( ILogger* pLogger, const string& sKey, bool bNetHwKey) FreeExchangeDll() ; return false ; } - // se gi� caricata + // se già caricata if ( s_hEEx != nullptr) return true ; // carico la libreria EgtExchange @@ -94,7 +92,7 @@ LoadExchangeDll( ILogger* pLogger, const string& sKey, bool bNetHwKey) bool FreeExchangeDll( void) { - // se non � gi� caricata + // se non è già caricata if ( s_hEEx == nullptr) return true ; // libero la libreria EgtExchange @@ -320,21 +318,6 @@ MyCreateImport3MF( void) return pFun() ; } -//----------------------------------------------------------------------------- -IImport3dm* -MyCreateImport3dm( void) -{ - // verifico caricamento libreria EgtExchange - if ( s_hEEx == nullptr) - return nullptr ; - // recupero funzione creazione oggetto - typedef IImport3dm* (* PF_CreateImport3dm) ( void) ; - PF_CreateImport3dm pFun = (PF_CreateImport3dm)GetProcAddress( s_hEEx, EEX_CREATEIMPORT3DM) ; - if ( pFun == nullptr) - return nullptr ; - return pFun() ; -} - //----------------------------------------------------------------------------- IExportDxf* MyCreateExportDxf( void) @@ -380,21 +363,6 @@ MyCreateExport3MF( void) return pFun() ; } -//----------------------------------------------------------------------------- -IExport3dm* -MyCreateExport3dm( void) -{ - // verifico caricamento libreria EgtExchange - if ( s_hEEx == nullptr) - return nullptr ; - // recupero funzione creazione oggetto - typedef IExport3dm* (* PF_CreateExport3dm) ( void) ; - PF_CreateExport3dm pFun = (PF_CreateExport3dm)GetProcAddress( s_hEEx, EEX_CREATEEXPORT3DM) ; - if ( pFun == nullptr) - return nullptr ; - return pFun() ; -} - //----------------------------------------------------------------------------- IExportSvg* MyCreateExportSvg( void) diff --git a/DllExchange.h b/DllExchange.h index 90b6d11..2c60b89 100644 --- a/DllExchange.h +++ b/DllExchange.h @@ -25,11 +25,9 @@ class IImportDxf ; class IImportPnt ; class IImportStl ; class IImport3MF ; -class IImport3dm ; class IExportDxf ; class IExportStl ; class IExport3MF ; -class IExport3dm ; class IExportThreeJS ; class IExportSvg ; class IExcExecutor ; @@ -52,11 +50,9 @@ IImportDxf* MyCreateImportDxf( void) ; IImportPnt* MyCreateImportPnt( void) ; IImportStl* MyCreateImportStl( void) ; IImport3MF* MyCreateImport3MF( void) ; -IImport3dm* MyCreateImport3dm( void) ; IExportDxf* MyCreateExportDxf( void) ; IExportStl* MyCreateExportStl( void) ; IExport3MF* MyCreateExport3MF( void) ; -IExport3dm* MyCreateExport3dm( void) ; bool MySetThreeJSLibDir( const std::string& sThreeJSLibDir) ; IExportThreeJS* MyCreateExportThreeJS( void) ; IExportSvg* MyCreateExportSvg( void) ; diff --git a/EXE_Exchange.cpp b/EXE_Exchange.cpp index 5501830..159fe29 100644 --- a/EXE_Exchange.cpp +++ b/EXE_Exchange.cpp @@ -17,6 +17,7 @@ #include "EXE_Macro.h" #include "AuxTools.h" #include "DllExchange.h" +#include "DllExch3dm.h" #include "/EgtDev/Include/EXeExecutor.h" #include "/EgtDev/Include/EXeConst.h" #include "/EgtDev/Include/EXeCmdLogOff.h" @@ -28,13 +29,13 @@ #include "/EgtDev/Include/EExImportPnt.h" #include "/EgtDev/Include/EExImportBtl.h" #include "/EgtDev/Include/EExImportBtlx.h" -#include "/EgtDev/Include/EExImport3dm.h" #include "/EgtDev/Include/EExExportDxf.h" #include "/EgtDev/Include/EExExportStl.h" #include "/EgtDev/Include/EExExport3MF.h" -#include "/EgtDev/Include/EExExport3dm.h" #include "/EgtDev/Include/EExExportSvg.h" #include "/EgtDev/Include/EExExportThreeJS.h" +#include "/EgtDev/Include/EE3Import3dm.h" +#include "/EgtDev/Include/EE3Export3dm.h" #include "/EgtDev/Include/EGnStringUtils.h" #include "/EgtDev/Include/EGnFileUtils.h" #include "/EgtDev/Include/EgtStringConverter.h" diff --git a/EXE_General.cpp b/EXE_General.cpp index e79436d..0f9846d 100644 --- a/EXE_General.cpp +++ b/EXE_General.cpp @@ -1,13 +1,14 @@ //---------------------------------------------------------------------------- -// EgalTech 2014-2015 +// EgalTech 2014-2023 //---------------------------------------------------------------------------- -// File : EXE_General.cpp Data : 01.09.14 Versione : 1.5i1 +// File : EXE_General.cpp Data : 14.11.23 Versione : 2.5k2 // Contenuto : Funzioni generali per EXE. // // // // Modifiche : 01.09.14 DS Creazione modulo. -// 28.11.19 DS Aggiunto caricamento opzionale del Nesting. +// 28.11.19 DS Aggiunto caricamento opzionale di Nesting. +// 14.11.23 DS Aggiunto caricamento opzionale di Exchange 3dm. // //---------------------------------------------------------------------------- @@ -17,6 +18,7 @@ #include "LUA_Base.h" #include "DllGraphics.h" #include "DllExchange.h" +#include "DllExch3dm.h" #include "DllMachKernel.h" #include "DllNesting.h" #include "/EgtDev/Include/EXeExecutor.h" @@ -112,6 +114,10 @@ ExeInit( int nDebug, const string& sLogFile, const string& sLogMsg) if ( LoadExchangeDll( s_pGenLog, s_sKey, s_bNetHwKey)) LOG_INFO( s_pGenLog, MyGetEExVersion()) + // carico libreria exchange 3dm opzionale + if ( LoadExch3dmDll( s_pGenLog, s_sKey, s_bNetHwKey)) + LOG_INFO( s_pGenLog, MyGetEE3Version()) + // carico libreria di lavorazione opzionale if ( LoadMachKernelDll( s_pGenLog, s_sKey, s_bNetHwKey)) LOG_INFO( s_pGenLog, MyGetEMkVersion()) @@ -168,6 +174,7 @@ ExeExit( void) // libero le librerie opzionali FreeMachKernelDll() ; FreeExchangeDll() ; + FreeExch3dmDll() ; FreeGraphicsDll() ; // cancello riferimenti a funzioni installate @@ -438,6 +445,10 @@ ExeGetVersionInfo( string& sVer, const char* szNewLine) sVer += szNewLine ; sVer += MyGetEExVersion() ; } + if ( IsLoadedExch3dmDll()) { + sVer += szNewLine ; + sVer += MyGetEE3Version() ; + } if ( IsLoadedMachKernelDll()) { sVer += szNewLine ; sVer += MyGetEMkVersion() ; diff --git a/EgtExecutor.vcxproj b/EgtExecutor.vcxproj index 909fcd9..331a50e 100644 --- a/EgtExecutor.vcxproj +++ b/EgtExecutor.vcxproj @@ -228,6 +228,7 @@ copy $(TargetPath) \EgtProg\Dll64 + @@ -248,6 +249,7 @@ copy $(TargetPath) \EgtProg\Dll64 + diff --git a/EgtExecutor.vcxproj.filters b/EgtExecutor.vcxproj.filters index 4dab7ec..aa54c36 100644 --- a/EgtExecutor.vcxproj.filters +++ b/EgtExecutor.vcxproj.filters @@ -108,6 +108,9 @@ File di intestazione + + File di intestazione + @@ -389,6 +392,9 @@ File di origine\EXE + + File di origine\Optional Dll +