From 63d85b005ab2524746d311bbf3078cc8bbd8aca7 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 19 May 2015 20:20:12 +0000 Subject: [PATCH] EgtExecutor 1.6e6 : - aggiunta gestione import CSF - aggiunta ExeAddSubPiece. --- DllExchange.cpp | 16 ++++++++++++++++ DllExchange.h | 2 ++ EXE_Exchange.cpp | 31 +++++++++++++++++++++++++++++++ EXE_MachMgr.cpp | 10 ++++++++++ EgtExecutor.rc | Bin 11686 -> 11686 bytes LUA_Exchange.cpp | 16 ++++++++++++++++ LUA_MachMgr.cpp | 21 +++++++++++++++++++++ 7 files changed, 96 insertions(+) diff --git a/DllExchange.cpp b/DllExchange.cpp index f191239..12675e9 100644 --- a/DllExchange.cpp +++ b/DllExchange.cpp @@ -34,6 +34,7 @@ using namespace std ; static const char* EEX_SETEEXLOGGER = "SetEExLogger" ; static const char* EEX_GETEEXVERSION = "GetEExVersion" ; static const char* EEX_SETEEXKEY = "SetEExKey" ; +static const char* EEX_CREATEIMPORTCSF = "CreateImportCsf" ; static const char* EEX_CREATEIMPORTCNC = "CreateImportCnc" ; static const char* EEX_CREATEIMPORTDXF = "CreateImportDxf" ; static const char* EEX_CREATEIMPORTSTL = "CreateImportStl" ; @@ -122,6 +123,21 @@ MySetEExKey( const string& sKey) pFun( sKey) ; } +//----------------------------------------------------------------------------- +IImportCsf* +MyCreateImportCsf( void) +{ + // verifico caricamento libreria EgtExchange + if ( s_hEEx == nullptr) + return nullptr ; + // recupero funzione creazione oggetto + typedef IImportCsf* (* PF_CreateImportCsf) ( void) ; + PF_CreateImportCsf pFun = (PF_CreateImportCsf)GetProcAddress( s_hEEx, EEX_CREATEIMPORTCSF) ; + if ( pFun == nullptr) + return nullptr ; + return pFun() ; +} + //----------------------------------------------------------------------------- IImportCnc* MyCreateImportCnc( void) diff --git a/DllExchange.h b/DllExchange.h index 130f20f..e8c0fce 100644 --- a/DllExchange.h +++ b/DllExchange.h @@ -16,6 +16,7 @@ #include class ILogger ; +class IImportCsf ; class IImportCnc ; class IImportDxf ; class IImportStl ; @@ -31,6 +32,7 @@ void MySetEExLogger( ILogger* pLogger) ; void MySetEExKey( const std::string& sKey) ; const char* MyGetEExVersion( void) ; IImportCnc* MyCreateImportCnc( void) ; +IImportCsf* MyCreateImportCsf( void) ; IImportDxf* MyCreateImportDxf( void) ; IImportStl* MyCreateImportStl( void) ; IExportDxf* MyCreateExportDxf( void) ; diff --git a/EXE_Exchange.cpp b/EXE_Exchange.cpp index d3328dc..9df3dad 100644 --- a/EXE_Exchange.cpp +++ b/EXE_Exchange.cpp @@ -20,6 +20,7 @@ #include "/EgtDev/Include/EExImportStl.h" #include "/EgtDev/Include/EExImportDxf.h" #include "/EgtDev/Include/EExImportCnc.h" +#include "/EgtDev/Include/EExImportCsf.h" #include "/EgtDev/Include/EExExportStl.h" #include "/EgtDev/Include/EExExportDxf.h" #include "/EgtDev/Include/EGnStringUtils.h" @@ -51,6 +52,8 @@ ExeGetFileType( const string& sFilePath) return 12 ; else if ( sFileExt == "CNC") return 13 ; + else if ( sFileExt == "HED" || sFileExt == "ENT" || sFileExt == "ENS") + return 14 ; else if ( sFileExt == "TSC") return 101 ; else if ( sFileExt == "LUA") @@ -156,6 +159,34 @@ ExeImportCnc( const string& sFilePath) return bOk ; } +//----------------------------------------------------------------------------- +bool +ExeImportCsf( const string& sFilePath) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_GEOMDB( pGseCtx, false) + bool bOk = true ; + // importo il file CSF + // preparo l'importatore + PtrOwner pImpCsf( MyCreateImportCsf()) ; + bOk = bOk && ! IsNull( pImpCsf) ; + // eseguo l'importazione (direttamente nella radice) + bOk = bOk && pImpCsf->Import( sFilePath, pGseCtx->m_pGeomDB) ; + // aggiorno stato file corrente + pGseCtx->m_sFilePath = sFilePath ; + pGseCtx->m_bModified = true ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLuaPath = sFilePath ; + ReplaceString( sLuaPath, "\\", "\\\\") ; + string sLua = "EgtImportCsf('" + sLuaPath + "')" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco il risultato + return bOk ; +} + //----------------------------------------------------------------------------- bool ExeExportDxf( int nId, const string& sFilePath) diff --git a/EXE_MachMgr.cpp b/EXE_MachMgr.cpp index c60fc92..4d7285d 100644 --- a/EXE_MachMgr.cpp +++ b/EXE_MachMgr.cpp @@ -512,6 +512,16 @@ ExeRotatePartInRawPart( int nPartId, const Vector3d& vtAx, double dAngRotDeg) return bOk ; } +//----------------------------------------------------------------------------- +int +ExeAddSubPiece( const string& sName, const Point3d& ptPos) +{ + GseContext* pGseCtx = GetCurrGseContext() ; + VERIFY_CTX_MACHMGR( pGseCtx, false) + // inserisco il sottopezzo nella posizione indicata + return pGseCtx->m_pMachMgr->AddSubPiece( sName, ptPos) ; +} + //----------------------------------------------------------------------------- bool ExeSetAxisPos( const string& sAxis, double dVal) diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 20f84113e16bcb9bc9de84d4db3098d6313afda3..528f4e1d0aff8fbc396b2a546a74827cbf5de0ef 100644 GIT binary patch delta 79 zcmZ1$y)1geFE&QA&A-`PnSqoe*K!sx?>N)s4T4pSW|JMck~jAW*?>e(i-FY$N+HxV MD8kglDS2=M0Adgth5!Hn delta 79 zcmZ1$y)1geFE&Qg&A-`PnSqoe*K!sx?>N)s4T4pSrjs4Hk~jAW*?>e(i-FY$N+HxV MD8kglDS2=M0AR!#egFUf diff --git a/LUA_Exchange.cpp b/LUA_Exchange.cpp index e770061..56eda38 100644 --- a/LUA_Exchange.cpp +++ b/LUA_Exchange.cpp @@ -70,6 +70,21 @@ LuaImportCnc( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaImportCsf( lua_State* L) +{ + // 1 parametro : path del file da importare + string sFilePath ; + LuaCheckParam( L, 1, sFilePath) + LuaClearStack( L) ; + // apro il file + bool bOk = ExeImportCsf( sFilePath) ; + // restituisco il risultato + LuaSetReturn( L, bOk) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaExportDxf( lua_State* L) @@ -112,6 +127,7 @@ LuaInstallExchange( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtImportDxf", LuaImportDxf) ; bOk = bOk && luaMgr.RegisterFunction( "EgtImportStl", LuaImportStl) ; bOk = bOk && luaMgr.RegisterFunction( "EgtImportCnc", LuaImportCnc) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtImportCsf", LuaImportCsf) ; bOk = bOk && luaMgr.RegisterFunction( "EgtExportDxf", LuaExportDxf) ; bOk = bOk && luaMgr.RegisterFunction( "EgtExportStl", LuaExportStl) ; return bOk ; diff --git a/LUA_MachMgr.cpp b/LUA_MachMgr.cpp index 6cedfa0..7e12e59 100644 --- a/LUA_MachMgr.cpp +++ b/LUA_MachMgr.cpp @@ -506,6 +506,26 @@ LuaRotatePartInRawPart( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaAddSubPiece( lua_State* L) +{ + // 2 parametri : sName, ptPos + string sName ; + LuaCheckParam( L, 1, sName) + Point3d ptPos ; + LuaCheckParam( L, 2, ptPos) + LuaClearStack( L) ; + // metto l'asse nella nuova posizione + int nId = ExeAddSubPiece( sName, ptPos) ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) + LuaSetReturn( L, nId) ; + else + LuaSetReturn( L) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaSetAxisPos( lua_State* L) @@ -765,6 +785,7 @@ LuaInstallMachMgr( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtRemovePartFromRawPart", LuaRemovePartFromRawPart) ; bOk = bOk && luaMgr.RegisterFunction( "EgtMovePartInRawPart", LuaTranslatePartInRawPart) ; bOk = bOk && luaMgr.RegisterFunction( "EgtRotatePartInRawPart", LuaRotatePartInRawPart) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtAddSubPiece", LuaAddSubPiece) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSetAxisPos", LuaSetAxisPos) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetAxisPos", LuaGetAxisPos) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetAxisHomePos", LuaGetAxisHomePos) ;