From 0d6a829de79116121b0d95671120125af76ffd21 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 18 Oct 2016 18:37:08 +0000 Subject: [PATCH] EgtExecutor 1.6v4 : - aggiunta Exe e Lua InvertVector - aggiunte Lua EgtCreateContext e EgtDeleteContext - aggiunta Lua EgtSplitStringPlus. --- EXE_GdbModify.cpp | 29 +++++++++++++++++ EXE_GdbModifyCurve.cpp | 3 +- EXE_GeomDB.cpp | 2 +- EgtExecutor.rc | Bin 11694 -> 11694 bytes LUA_GdbModify.cpp | 16 ++++++++++ LUA_General.cpp | 55 +++++++++++++++----------------- LUA_GeomDB.cpp | 70 +++++++++++++++++++++++++++++++++++++++++ 7 files changed, 142 insertions(+), 33 deletions(-) diff --git a/EXE_GdbModify.cpp b/EXE_GdbModify.cpp index e0cb72a..4300f2d 100644 --- a/EXE_GdbModify.cpp +++ b/EXE_GdbModify.cpp @@ -98,6 +98,35 @@ ExeChangeVectorBase( int nId, const Point3d& ptB, int nRefType) return bOk ; } +//---------------------------------------------------------------------------- +bool +ExeInvertVector( const INTVECTOR& vIds) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // eseguo inversione + bool bOk = true ; + for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) { + int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; + while ( nId != GDB_ID_NULL && bOk) { + // recupero il vettore e lo inverto + IGeoVector3d* pGVect = GetGeoVector3d( pGeomDB->GetGeoObj( nId)) ; + bOk = ( pGVect != nullptr && pGVect->ChangeVector( - pGVect->GetVector())) ; + // passo alla successiva + nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; + } + } + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtInvertVector({" + IdListToString( vIds) + "})" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco risultato + return bOk ; +} + //------------------------------------------------------------------------------- bool ExeModifyText( int nId, const string& sNewText) diff --git a/EXE_GdbModifyCurve.cpp b/EXE_GdbModifyCurve.cpp index a7d4ecd..89785c5 100644 --- a/EXE_GdbModifyCurve.cpp +++ b/EXE_GdbModifyCurve.cpp @@ -53,8 +53,7 @@ ExeInvertCurve( const INTVECTOR& vIds) while ( nId != GDB_ID_NULL && bOk) { // recupero la curva e la inverto ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; - if ( pCurve != nullptr && ! pCurve->Invert()) - bOk = false ; + bOk = ( pCurve != nullptr && pCurve->Invert()) ; // passo alla successiva nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; } diff --git a/EXE_GeomDB.cpp b/EXE_GeomDB.cpp index e8851c4..9e7a2c8 100644 --- a/EXE_GeomDB.cpp +++ b/EXE_GeomDB.cpp @@ -52,7 +52,7 @@ ExeInitContext( void) } //----------------------------------------------------------------------------- -int +bool ExeDeleteContext( int nGseCtx) { // se contesto corrente, lo resetto diff --git a/EgtExecutor.rc b/EgtExecutor.rc index ae4e3842e807a9846de88cf2b0935a6eadc6e4ea..0fc7f19d66a3193b19dfe1f0f01ddca6d1b412d0 100644 GIT binary patch delta 97 zcmZ1%y)JsgA2vpl%@@V4Gflq2na5}{Ignd-a{*Tk3sCf++-0W82LxfF21;&>n->Y| cF@rU@0x76sKgP|Iq`|@mn->Y| cF@rU@0x76sKgP|Iq`|@mm_pScene == nullptr) + bOk = ExeDeleteContext( nGseCtx) ; + // restituisco il risultato + LuaSetParam( L, bOk) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaSetDefaultMaterial( lua_State* L) @@ -232,6 +298,10 @@ bool LuaInstallGeomDB( LuaMgr& luaMgr) { bool bOk = ( &luaMgr != nullptr) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtCreateContext", LuaCreateContext) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtSetContext", LuaSetContext) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtGetContext", LuaGetContext) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtDeleteContext", LuaDeleteContext) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSetDefaultMaterial", LuaSetDefaultMaterial) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSetGridFrame", LuaSetGridFrame) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetGridFrame", LuaGetGridFrame) ;