From 11ee55fb11c64da40904f12b3c99770ca50dc453 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Thu, 7 Sep 2017 09:22:36 +0000 Subject: [PATCH] EgtExecutor 1.8i1 : - aggiunte funzioni ExeSetTempDir e ExeGetTempDir - aggiunte funzioni Exe e Lua VolZmapSetMortiserTool e VolZmapSetChiselTool - estesa funzione Lua VolZmapMillingStep. --- EXE_GdbModifyVol.cpp | 91 +++++++++++++++++++++++++++++++++++++ EXE_General.cpp | 24 +++++++++- EgtExecutor.rc | Bin 15088 -> 15088 bytes LUA_GdbModifyVol.cpp | 105 +++++++++++++++++++++++++++++++++++++------ 4 files changed, 205 insertions(+), 15 deletions(-) diff --git a/EXE_GdbModifyVol.cpp b/EXE_GdbModifyVol.cpp index f171c9f..64ec405 100644 --- a/EXE_GdbModifyVol.cpp +++ b/EXE_GdbModifyVol.cpp @@ -76,6 +76,59 @@ ExeVolZmapSetAdvTool( int nId, const string& sToolName, return bOk ; } +//---------------------------------------------------------------------------- +bool +ExeVolZmapSetMortiserTool( int nId, const string& sToolName, + double dLen, double dWidth, double dThick, double dCornR) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // recupero lo Zmap e assegno i dati dell'utensile + IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nId)) ; + bool bOk = ( pVZM != nullptr && + pVZM->SetMortiserTool( sToolName, dLen, dWidth, dThick, dCornR)) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtVolZmapSetMortiserTool(" + IdToString( nId) + "," + + sToolName + "," + + ToString( dLen) + "," + + ToString( dWidth) + "," + + ToString( dThick) + "," + + ToString( dCornR) + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco risultato + return bOk ; +} + +//---------------------------------------------------------------------------- +bool +ExeVolZmapSetChiselTool( int nId, const string& sToolName, + double dLen, double dWidth, double dThick) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // recupero lo Zmap e assegno i dati dell'utensile + IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nId)) ; + bool bOk = ( pVZM != nullptr && + pVZM->SetChiselTool( sToolName, dLen, dWidth, dThick)) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtVolZmapSetChiselTool(" + IdToString( nId) + "," + + sToolName + "," + + ToString( dLen) + "," + + ToString( dWidth) + "," + + ToString( dThick) + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco risultato + return bOk ; +} + //---------------------------------------------------------------------------- bool ExeVolZmapMillingStep( int nId, const Point3d& ptPs, const Vector3d& vtDs, @@ -110,6 +163,44 @@ ExeVolZmapMillingStep( int nId, const Point3d& ptPs, const Vector3d& vtDs, return bOk ; } +//---------------------------------------------------------------------------- +bool +ExeVolZmapMillingStep( int nId, const Point3d& ptPs, const Vector3d& vtDs, const Vector3d& vtAs, + const Point3d& ptPe, const Vector3d& vtDe, const Vector3d& vtAe, int nRefType) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // recupero il riferimento locale + Frame3d frLoc ; + bool bOk = pGeomDB->GetGlobFrame( nId, frLoc) ; + // porto in locale i punti e i vettori + Point3d ptPsL = GetPointLocal( pGeomDB, ptPs, nRefType, frLoc) ; + Vector3d vtDsL = GetVectorLocal( pGeomDB, vtDs, nRefType, frLoc) ; + Vector3d vtAsL = GetVectorLocal( pGeomDB, vtAs, nRefType, frLoc) ; + Point3d ptPeL = GetPointLocal( pGeomDB, ptPe, nRefType, frLoc) ; + Vector3d vtDeL = GetVectorLocal( pGeomDB, vtDe, nRefType, frLoc) ; + Vector3d vtAeL = GetVectorLocal( pGeomDB, vtAe, nRefType, frLoc) ; + // recupero lo Zmap e eseguo movimento di fresatura con l'utensile già associato + IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nId)) ; + bOk = bOk && ( pVZM != nullptr && pVZM->MillingStep( ptPsL, vtDsL, vtAsL, ptPeL, vtDeL, vtAeL)) ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtVolZmapMillingStep(" + IdToString( nId) + ",{" + + ToString( ptPs) + "},{" + + ToString( vtDs) + "},{" + + ToString( vtAs) + "},{" + + ToString( ptPe) + "},{" + + ToString( vtDe) + "},{" + + ToString( vtAe) + "}," + + RefTypeToString( nRefType) + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco risultato + return bOk ; +} + //---------------------------------------------------------------------------- bool ExeVolZmapGetDepth( int nId, const Point3d& ptP, const Vector3d& vtDir, int nRefType, diff --git a/EXE_General.cpp b/EXE_General.cpp index d82c979..5bba3f8 100644 --- a/EXE_General.cpp +++ b/EXE_General.cpp @@ -25,6 +25,7 @@ #include "/EgtDev/Include/EGkDllMain.h" #include "/EgtDev/Include/EGkUserObjFactory.h" #include "/EgtDev/Include/EGnStringUtils.h" +#include "/EgtDev/Include/EGnFileUtils.h" #include "/EgtDev/Include/EGnPcInfo.h" #include "/EgtDev/Include/EgtLogger.h" #include "/EgtDev/Include/EgtStringConverter.h" @@ -44,7 +45,8 @@ static int s_nKeyType = KEY_LOCK_TYPE_ANY ; static string s_sIniFile ; static pfProcEvents s_pFunProcEvents = nullptr ; static pfOutText s_pFunOutText = nullptr ; -static HWND s_hMainWnd = nullptr ; +static HWND s_hMainWnd = nullptr ; +static string s_sTempDir ; //----------------------------------------------------------------------------- bool @@ -428,6 +430,26 @@ ExeOutText( const string& sText) return false ; } +//----------------------------------------------------------------------------- +bool +ExeSetTempDir( const string& sTempDir) +{ + s_sTempDir = sTempDir ; + return true ; +} + +//----------------------------------------------------------------------------- +bool +ExeGetTempDir( string& sTempDir) +{ + // ne verifico l'esistenza + if ( ! ExistsDirectory( s_sTempDir)) + return false ; + // lo restituisco + sTempDir = s_sTempDir ; + return true ; +} + //----------------------------------------------------------------------------- bool ExeSetMainWindowHandle( HWND hMainWnd) diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 68a40f266882a20097fc0b0403fd1579d6a2887c..a5a95c8fc6585f38bd89e74fc0f3c9bd53815027 100644 GIT binary patch delta 103 zcmexR`k{2gH#SyF1|0^&&A-{4nVBoOp`YVR)EAOJ8~s&?h~?r$(o>Ndf?c&mOe^ delta 103 zcmexR`k{2gH#Sxa1|0^I&A-{4nVBoOp`YVR)EAOJ8~s&?h~?r$(o>Ndf?f?;gbf diff --git a/LUA_GdbModifyVol.cpp b/LUA_GdbModifyVol.cpp index f34965f..fcb443b 100644 --- a/LUA_GdbModifyVol.cpp +++ b/LUA_GdbModifyVol.cpp @@ -72,29 +72,104 @@ LuaVolZmapSetAdvTool( lua_State* L) //---------------------------------------------------------------------------- static int -LuaVolZmapMillingStep( lua_State* L) +LuaVolZmapSetMortiserTool( lua_State* L) { - // 5 o 6 parametri : nId, ptPs, vtDs, ptPe, vtDe [, nRefType] + // 6 parametri : Id, sToolName, dLen, dWidth, dThick, dCornR int nId ; LuaCheckParam( L, 1, nId) - Point3d ptPs ; - LuaCheckParam( L, 2, ptPs) - Vector3d vtDs ; - LuaCheckParam( L, 3, vtDs) - Point3d ptPe ; - LuaCheckParam( L, 4, ptPe) - Vector3d vtDe ; - LuaCheckParam( L, 5, vtDe) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 6, nRefType) ; + string sToolName ; + LuaCheckParam( L, 2, sToolName) + double dLen ; + LuaCheckParam( L, 3, dLen) + double dWidth ; + LuaCheckParam( L, 4, dWidth) + double dThick ; + LuaCheckParam( L, 5, dThick) + double dCornR ; + LuaCheckParam( L, 6, dCornR) LuaClearStack( L) ; - // eseguo movimento di fresatura con l'utensile già associato a Zmap - bool bOk = ExeVolZmapMillingStep( nId, ptPs, vtDs, ptPe, vtDe, nRefType) ; + // imposto mortasatrice a Zmap indicato + bool bOk = ExeVolZmapSetMortiserTool( nId, sToolName, dLen, dWidth, dThick, dCornR) ; // restituisco il risultato LuaSetParam( L, bOk) ; return 1 ; } +//---------------------------------------------------------------------------- +static int +LuaVolZmapSetChiselTool( lua_State* L) +{ + // 5 parametri : Id, sToolName, dLen, dWidth, dThick + int nId ; + LuaCheckParam( L, 1, nId) + string sToolName ; + LuaCheckParam( L, 2, sToolName) + double dLen ; + LuaCheckParam( L, 3, dLen) + double dWidth ; + LuaCheckParam( L, 4, dWidth) + double dThick ; + LuaCheckParam( L, 5, dThick) + LuaClearStack( L) ; + // imposto scalpello a Zmap indicato + bool bOk = ExeVolZmapSetChiselTool( nId, sToolName, dLen, dWidth, dThick) ; + // restituisco il risultato + LuaSetParam( L, bOk) ; + return 1 ; +} + +//---------------------------------------------------------------------------- +static int +LuaVolZmapMillingStep( lua_State* L) +{ + // 5 o 6 o 7 o 8 parametri : nId, ptPs, vtDs [, vtAs], ptPe, vtDe [, vtAe], [, nRefType] + int n = lua_gettop( L) ; + if ( n == 5 || n == 6) { + int nId ; + LuaCheckParam( L, 1, nId) + Point3d ptPs ; + LuaCheckParam( L, 2, ptPs) + Vector3d vtDs ; + LuaCheckParam( L, 3, vtDs) + Point3d ptPe ; + LuaCheckParam( L, 4, ptPe) + Vector3d vtDe ; + LuaCheckParam( L, 5, vtDe) + int nRefType = RTY_DEFAULT ; + LuaGetParam( L, 6, nRefType) ; + LuaClearStack( L) ; + // eseguo movimento di fresatura con l'utensile già associato a Zmap + bool bOk = ExeVolZmapMillingStep( nId, ptPs, vtDs, ptPe, vtDe, nRefType) ; + // restituisco il risultato + LuaSetParam( L, bOk) ; + return 1 ; + } + else { + int nId ; + LuaCheckParam( L, 1, nId) + Point3d ptPs ; + LuaCheckParam( L, 2, ptPs) + Vector3d vtDs ; + LuaCheckParam( L, 3, vtDs) + Vector3d vtAs ; + LuaCheckParam( L, 4, vtAs) + Point3d ptPe ; + LuaCheckParam( L, 5, ptPe) + Vector3d vtDe ; + LuaCheckParam( L, 6, vtDe) + Vector3d vtAe ; + LuaCheckParam( L, 7, vtAe) + int nRefType = RTY_DEFAULT ; + LuaGetParam( L, 8, nRefType) ; + LuaClearStack( L) ; + // eseguo movimento di fresatura con l'utensile già associato a Zmap + bool bOk = ExeVolZmapMillingStep( nId, ptPs, vtDs, vtAs, ptPe, vtDe, vtAe, nRefType) ; + // restituisco il risultato + LuaSetParam( L, bOk) ; + return 1 ; + } +} + //---------------------------------------------------------------------------- static int LuaVolZmapGetDepth( lua_State* L) @@ -152,6 +227,8 @@ LuaInstallGdbModifyVol( LuaMgr& luaMgr) bool bOk = ( &luaMgr != nullptr) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapSetStdTool", LuaVolZmapSetStdTool) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapSetAdvTool", LuaVolZmapSetAdvTool) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapSetMortiserTool", LuaVolZmapSetMortiserTool) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapSetChiselTool", LuaVolZmapSetChiselTool) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapMillingStep", LuaVolZmapMillingStep) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapGetDepth", LuaVolZmapGetDepth) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapAvoidBox", LuaVolZmapAvoidBox) ;