EgtExecutor :

- aggiunta funzione Exe e Lua GetAllInGroup.
This commit is contained in:
Dario Sassi
2019-02-14 10:00:27 +00:00
parent 7a4f131fbe
commit 91a98e4bd9
2 changed files with 44 additions and 0 deletions
+24
View File
@@ -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)
+20
View File
@@ -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) ;