diff --git a/EXE.h b/EXE.h index cb95f27..4fcd51a 100644 --- a/EXE.h +++ b/EXE.h @@ -44,3 +44,6 @@ bool ExeInsertDuplo( int nInsGrp) ; //---------------------------------------------------------------------------- bool ExeCreateMutex( const std::string& sMutexName) ; bool ExeReleaseMutex( void) ; + +//---------------------------------------------------------------------------- +bool ExeSetModified( int nCtx) ; diff --git a/EXE_GdbObjects.cpp b/EXE_GdbObjects.cpp index b347a47..eeed41a 100644 --- a/EXE_GdbObjects.cpp +++ b/EXE_GdbObjects.cpp @@ -18,6 +18,7 @@ #include "GeoTools.h" #include "AuxTools.h" #include "/EgtDev/Include/EXeExecutor.h" +#include "/EgtDev/Include/EGkMultiGeomDB.h" #include "/EgtDev/Include/EGkStringUtils3d.h" #include "/EgtDev/Include/EGkUiUnits.h" #include "/EgtDev/Include/EgtStringConverter.h" @@ -300,16 +301,39 @@ ExeCopy( int nSouId, int nRefId, int nSonBeforeAfter) ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sLua ; - if ( nSonBeforeAfter == GDB_LAST_SON) - sLua = "EgtCopy(" + ToString( nSouId) + "," + - IdToString( nRefId) + ")" + - " -- Id=" + ToString( nNewId) ; - else - sLua = "EgtCopy(" + ToString( nSouId) + "," + - IdToString( nRefId) + "," + - InsToString( nSonBeforeAfter) + ")" + - " -- Id=" + ToString( nNewId) ; + string sLua = "EgtCopy(" + ToString( nSouId) + "," + + IdToString( nRefId) + "," + + InsToString( nSonBeforeAfter) + ")" + + " -- Id=" + ToString( nNewId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco risultato + return nNewId ; +} + +//----------------------------------------------------------------------------- +int +ExeCopyEx( int nSouCtx, int nSouId, int nDestCtx, int nRefId, int nSonBeforeAfter) +{ + // recupero i due GeomDB + IGeomDB* pSouGeomDB = GetGeomDB( nSouCtx) ; + VERIFY_GEOMDB( pSouGeomDB, GDB_ID_NULL) + IGeomDB* pDstGeomDB = GetGeomDB( nDestCtx) ; + VERIFY_GEOMDB( pDstGeomDB, GDB_ID_NULL) + // risolvo l'Id di riferimento per destinazione + nRefId = AdjustId( nRefId, nDestCtx) ; + // eseguo la copia + int nNewId = Copy( pSouGeomDB, nSouId, pDstGeomDB, GDB_ID_NULL, nRefId, nSonBeforeAfter) ; + pDstGeomDB->RemoveInfo( nNewId, GDB_SI_LIST) ; + pDstGeomDB->RemoveInfo( nNewId, GDB_SI_DUPLIST) ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtCopyEx(" + ToString( nSouCtx) + "," + + ToString( nSouId) + "," + + ToString( nDestCtx) + "," + + IdToString( nRefId) + "," + + InsToString( nSonBeforeAfter) + ")" + + " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco risultato @@ -330,16 +354,39 @@ ExeCopyGlob( int nSouId, int nRefId, int nSonBeforeAfter) ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sLua ; - if ( nSonBeforeAfter == GDB_LAST_SON) - sLua = "EgtCopyGlob(" + ToString( nSouId) + "," + - IdToString( nRefId) + ")" + - " -- Id=" + ToString( nNewId) ; - else - sLua = "EgtCopyGlob(" + ToString( nSouId) + "," + - IdToString( nRefId) + "," + - InsToString( nSonBeforeAfter) + ")" + - " -- Id=" + ToString( nNewId) ; + string sLua = "EgtCopyGlob(" + ToString( nSouId) + "," + + IdToString( nRefId) + "," + + InsToString( nSonBeforeAfter) + ")" + + " -- Id=" + ToString( nNewId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco risultato + return nNewId ; +} + +//----------------------------------------------------------------------------- +int +ExeCopyGlobEx( int nSouCtx, int nSouId, int nDestCtx, int nRefId, int nSonBeforeAfter) +{ + // recupero i due GeomDB + IGeomDB* pSouGeomDB = GetGeomDB( nSouCtx) ; + VERIFY_GEOMDB( pSouGeomDB, GDB_ID_NULL) + IGeomDB* pDstGeomDB = GetGeomDB( nDestCtx) ; + VERIFY_GEOMDB( pDstGeomDB, GDB_ID_NULL) + // risolvo l'Id di riferimento per destinazione + nRefId = AdjustId( nRefId, nDestCtx) ; + // eseguo la copia + int nNewId = CopyGlob( pSouGeomDB, nSouId, pDstGeomDB, GDB_ID_NULL, nRefId, nSonBeforeAfter) ; + pDstGeomDB->RemoveInfo( nNewId, GDB_SI_LIST) ; + pDstGeomDB->RemoveInfo( nNewId, GDB_SI_DUPLIST) ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtCopyGlobEx(" + ToString( nSouCtx) + "," + + ToString( nSouId) + "," + + ToString( nDestCtx) + "," + + IdToString( nRefId) + "," + + InsToString( nSonBeforeAfter) + ")" + + " -- Id=" + ToString( nNewId) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco risultato @@ -358,16 +405,10 @@ ExeRelocate( int nSouId, int nRefId, int nSonBeforeAfter) ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sLua ; - if ( nSonBeforeAfter == GDB_LAST_SON) - sLua = "EgtRelocate(" + ToString( nSouId) + "," + - IdToString( nRefId) + ")" + - " -- Ok=" + ToString( bOk) ; - else - sLua = "EgtRelocate(" + ToString( nSouId) + "," + - IdToString( nRefId) + "," + - InsToString( nSonBeforeAfter) + ")" + - " -- Ok=" + ToString( bOk) ; + string sLua = "EgtRelocate(" + ToString( nSouId) + "," + + IdToString( nRefId) + "," + + InsToString( nSonBeforeAfter) + ")" + + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco risultato @@ -386,16 +427,10 @@ ExeRelocateGlob( int nSouId, int nRefId, int nSonBeforeAfter) ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sLua ; - if ( nSonBeforeAfter == GDB_LAST_SON) - sLua = "EgtRelocateGlob(" + ToString( nSouId) + "," + - IdToString( nRefId) + ")" + - " -- Ok=" + ToString( bOk) ; - else - sLua = "EgtRelocateGlob(" + ToString( nSouId) + "," + - IdToString( nRefId) + "," + - InsToString( nSonBeforeAfter) + ")" + - " -- Ok=" + ToString( bOk) ; + string sLua = "EgtRelocateGlob(" + ToString( nSouId) + "," + + IdToString( nRefId) + "," + + InsToString( nSonBeforeAfter) + ")" + + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco risultato diff --git a/EXE_GeomDB.cpp b/EXE_GeomDB.cpp index e3e01e6..b450064 100644 --- a/EXE_GeomDB.cpp +++ b/EXE_GeomDB.cpp @@ -226,6 +226,18 @@ ExeSetModified( void) return true ; } +//----------------------------------------------------------------------------- +bool +ExeSetModified( int nCtx) +{ + GseContext* pGseCtx = GetGseContext( nCtx) ; + VERIFY_CTX_GEOMDB( pGseCtx, false) + // se consentito, imposto il flag + if ( pGseCtx->m_bEnableModified) + pGseCtx->m_bModified = true ; + return true ; +} + //----------------------------------------------------------------------------- bool ExeResetModified( void) @@ -387,7 +399,7 @@ ExeInsertFile( const string& sFilePath) class CamStatus { public : - CamStatus( void) : m_nCurrMachGroup( GDB_ID_NULL), m_nCurrPhase( 0) { + CamStatus( void) : m_nCurrMachGroup( GDB_ID_NULL), m_nCurrPhase( 0), m_nCurrMachining( GDB_ID_NULL) { IMachMgr* pMachMgr = GetCurrMachMgr() ; if ( pMachMgr == nullptr) return ; diff --git a/GeoTools.cpp b/GeoTools.cpp index fb338f4..d6e0ad5 100644 --- a/GeoTools.cpp +++ b/GeoTools.cpp @@ -20,9 +20,9 @@ //---------------------------------------------------------------------------- int -AdjustId( int nId) +AdjustId( int nId, int nCtx) { - GseContext* pCtx = GetCurrGseContext() ; + GseContext* pCtx = ( nCtx == 0 ? GetCurrGseContext() : GetGseContext( nCtx)); VERIFY_CTX( pCtx, GDB_ID_NULL) if ( nId == GDB_ID_CURRPART) return pCtx->m_nCurrPart ; diff --git a/GeoTools.h b/GeoTools.h index 328ab0d..f64178b 100644 --- a/GeoTools.h +++ b/GeoTools.h @@ -20,7 +20,7 @@ class IGeomDB ; //---------------------------------------------------------------------------- // Sistemo Id per pezzo o layer correnti -int AdjustId( int nId) ; +int AdjustId( int nId, int nCtx = 0) ; // Vettore espresso nel riferimento desiderato partendo da vettore nel riferimento RefType Vector3d GetVectorLocal( IGeomDB* pGeomDB, const Vector3d& vtV, int nRefType, const Frame3d& frLoc) ; // Vettore espresso nel riferimento RefType partendo da vettore nel riferimento locale diff --git a/LUA_GdbObjects.cpp b/LUA_GdbObjects.cpp index ecf592f..442394f 100644 --- a/LUA_GdbObjects.cpp +++ b/LUA_GdbObjects.cpp @@ -489,6 +489,32 @@ LuaCopy( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaCopyEx( lua_State* L) +{ + // 4 o 5 parametri : nSouCtx, SouId, nDestCtx, RefId [, nSonBeforeAfter] + int nSouCtx ; + LuaCheckParam( L, 1, nSouCtx) + int nSouId ; + LuaCheckParam( L, 2, nSouId) + int nDestCtx ; + LuaCheckParam( L, 3, nDestCtx) + int nRefId ; + LuaCheckParam( L, 4, nRefId) + int nSonBeforeAfter = GDB_LAST_SON ; + LuaGetParam( L, 5, nSonBeforeAfter) ; + LuaClearStack( L) ; + // eseguo la copia + int nNewId = ExeCopyEx( nSouCtx, nSouId, nDestCtx, nRefId, nSonBeforeAfter) ; + // restituisco il risultato + if ( nNewId != GDB_ID_NULL) + LuaSetParam( L, nNewId) ; + else + LuaSetParam( L) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaCopyGlob( lua_State* L) @@ -511,6 +537,32 @@ LuaCopyGlob( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaCopyGlobEx( lua_State* L) +{ + // 4 o 5 parametri : nSouCtx, SouId, nDestCtx, RefId [, nSonBeforeAfter] + int nSouCtx ; + LuaCheckParam( L, 1, nSouCtx) + int nSouId ; + LuaCheckParam( L, 2, nSouId) + int nDestCtx ; + LuaCheckParam( L, 3, nDestCtx) + int nRefId ; + LuaCheckParam( L, 4, nRefId) + int nSonBeforeAfter = GDB_LAST_SON ; + LuaGetParam( L, 5, nSonBeforeAfter) ; + LuaClearStack( L) ; + // eseguo la copia + int nNewId = ExeCopyGlobEx( nSouCtx, nSouId, nDestCtx, nRefId, nSonBeforeAfter) ; + // restituisco il risultato + if ( nNewId != GDB_ID_NULL) + LuaSetParam( L, nNewId) ; + else + LuaSetParam( L) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaRelocate( lua_State* L) @@ -663,7 +715,9 @@ LuaInstallGdbObjects( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtGetBBoxGlob", LuaGetBBoxGlob) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetBBoxRef", LuaGetBBoxRef) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCopy", LuaCopy) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtCopyEx", LuaCopyEx) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCopyGlob", LuaCopyGlob) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtCopyGlobEx", LuaCopyGlobEx) ; bOk = bOk && luaMgr.RegisterFunction( "EgtRelocate", LuaRelocate) ; bOk = bOk && luaMgr.RegisterFunction( "EgtRelocateGlob", LuaRelocateGlob) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGroupSwap", LuaGroupSwap) ;