From 91a98e4bd94808e9a1db3054e52cb88e25831eb8 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Thu, 14 Feb 2019 10:00:27 +0000 Subject: [PATCH] EgtExecutor : - aggiunta funzione Exe e Lua GetAllInGroup. --- EXE_GdbObjects.cpp | 24 ++++++++++++++++++++++++ LUA_GdbObjects.cpp | 20 ++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/EXE_GdbObjects.cpp b/EXE_GdbObjects.cpp index e0bdfc4..a675d19 100644 --- a/EXE_GdbObjects.cpp +++ b/EXE_GdbObjects.cpp @@ -74,6 +74,30 @@ ExeGetGroupObjs( int nId) return pGeomDB->GetGroupObjs( nId) ; } +//----------------------------------------------------------------------------- +bool +ExeGetAllInGroup( int nGroupId, INTVECTOR& vIds) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // recupero il numero di oggetti nel gruppo + if ( ! pGeomDB->ExistsObj( nGroupId)) + return false ; + // preparo il riempimento del vettore + vIds.clear() ; + int nCount = pGeomDB->GetGroupObjs( nGroupId) ; + if ( nCount == 0) + return true ; + vIds.reserve( nCount) ; + // eseguo il riempimento + int nEntId = pGeomDB->GetFirstInGroup( nGroupId) ; + while ( nEntId != GDB_ID_NULL) { + vIds.emplace_back( nEntId) ; + nEntId = pGeomDB->GetNext( nEntId) ; + } + return true ; +} + //----------------------------------------------------------------------------- int ExeGetFirstInGroup( int nGroupId) diff --git a/LUA_GdbObjects.cpp b/LUA_GdbObjects.cpp index 6e15579..4dd12d9 100644 --- a/LUA_GdbObjects.cpp +++ b/LUA_GdbObjects.cpp @@ -117,6 +117,25 @@ LuaGetGroupObjs( lua_State* L) return 1 ; } +//------------------------------------------------------------------------------- +static int +LuaGetAllInGroup( lua_State* L) +{ + // 1 parametro : GroupId + int nGroupId ; + LuaCheckParam( L, 1, nGroupId) + LuaClearStack( L) ; + // determino gli oggetti nel gruppo + INTVECTOR vIds ; + bool bOk = ExeGetAllInGroup( nGroupId, vIds) ; + // restituisco il risultato + if ( bOk) + LuaSetParam( L, vIds) ; + else + LuaSetParam( L) ; + return 1 ; +} + //------------------------------------------------------------------------------- static int LuaGetFirstInGroup( lua_State* L) @@ -608,6 +627,7 @@ LuaInstallGdbObjects( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtGetGlobFrame", LuaGetGlobFrame) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetGroupGlobFrame", LuaGetGroupGlobFrame) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetGroupObjs", LuaGetGroupObjs) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtGetAllInGroup", LuaGetAllInGroup) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetFirstInGroup", LuaGetFirstInGroup) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetNext", LuaGetNext) ; bOk = bOk && luaMgr.RegisterFunction( "EgtGetLastInGroup", LuaGetLastInGroup) ;