From f1a45f30762da532fd2ad9eb8e161db7359dbd29 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 25 Sep 2017 07:09:45 +0000 Subject: [PATCH] EgtExecutor 1.8i3 : - migliorata selezione e deselezione di tutti gli oggetti in un pezzo o in un layer. --- EXE_GdbPartLayers.cpp | 136 +++++++++++++++++++----------------------- EgtExecutor.rc | Bin 15088 -> 15088 bytes 2 files changed, 62 insertions(+), 74 deletions(-) diff --git a/EXE_GdbPartLayers.cpp b/EXE_GdbPartLayers.cpp index c66ac3b..a884860 100644 --- a/EXE_GdbPartLayers.cpp +++ b/EXE_GdbPartLayers.cpp @@ -411,6 +411,52 @@ ExeEraseEmptyParts( void) return true ; } +//----------------------------------------------------------------------------- +static bool +MySelectGroupObjs( IGeomDB* pGeomDB, int nGrpId, int nFilter) +{ + bool bOk = true ; + // Ciclo sugli oggetti del gruppo + int nId = pGeomDB->GetFirstInGroup( nGrpId) ; + while ( nId != GDB_ID_NULL) { + // Se è gruppo seleziono i suoi componenti (ma non il gruppo) + if ( pGeomDB->GetGdbType( nId) == GDB_TY_GROUP) { + bOk = MySelectGroupObjs( pGeomDB, nId, nFilter) ; + } + // altrimenti, se selezionabile lo seleziono direttamente + else { + if ( ( pGeomDB->GetGeoType( nId) & nFilter) != 0) { + if ( ! pGeomDB->SelectObj( nId)) + bOk = false ; + } + } + // Passo al successivo + nId = pGeomDB->GetNext( nId) ; + } + return bOk ; +} + +//----------------------------------------------------------------------------- +static bool +MyDeselectGroupObjs( IGeomDB* pGeomDB, int nGrpId) +{ + bool bOk = true ; + // Ciclo sugli oggetti del gruppo + int nId = pGeomDB->GetFirstInGroup( nGrpId) ; + while ( nId != GDB_ID_NULL) { + // Se è gruppo deseleziono i suoi componenti + if ( pGeomDB->GetGdbType( nId) == GDB_TY_GROUP) { + bOk = MyDeselectGroupObjs( pGeomDB, nId) ; + } + // Eseguo deselezione (anche del gruppo per maggior sicurezza) + if ( ! pGeomDB->DeselectObj( nId)) + bOk = false ; + // Passo al successivo + nId = pGeomDB->GetNext( nId) ; + } + return bOk ; +} + //----------------------------------------------------------------------------- bool ExeSelectPartObjs( int nPartId) @@ -418,35 +464,10 @@ ExeSelectPartObjs( int nPartId) GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX_GEOMDB( pGseCtx, false) IGeomDB* pGeomDB = pGseCtx->m_pGeomDB ; - bool bOk = true ; // verifico sia veramente un pezzo - if ( ExeIsPart( nPartId)) { - // ciclo sugli oggetti del pezzo - int nId = pGeomDB->GetFirstInGroup( nPartId) ; - while ( nId != GDB_ID_NULL) { - // se è gruppo seleziono i suoi componenti - if ( pGeomDB->GetGdbType( nId) == GDB_TY_GROUP) { - // ciclo sugli oggetti del layer - int nId2 = pGeomDB->GetFirstInGroup( nId) ; - while ( nId2 != GDB_ID_NULL) { - // se selezionabile, seleziono - if ( ( pGeomDB->GetGeoType( nId2) & pGseCtx->m_nObjFilterForSelect) != 0) - pGeomDB->SelectObj( nId2) ; - // passo al successivo - nId2 = pGeomDB->GetNext( nId2) ; - } - } - // altrimenti, se selezionabile lo seleziono direttamente - else { - if ( ( pGeomDB->GetGeoType( nId) & pGseCtx->m_nObjFilterForSelect) != 0) - pGeomDB->SelectObj( nId) ; - } - // passo al successivo - nId = pGeomDB->GetNext( nId) ; - } - } - else - bOk = false ; + bool bOk = ExeIsPart( nPartId) ; + // eseguo selezione + bOk = bOk && MySelectGroupObjs( pGeomDB, nPartId, pGseCtx->m_nObjFilterForSelect) ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtSelectPartObjs(" + ToString( nPartId) + ")" + @@ -463,24 +484,10 @@ ExeDeselectPartObjs( int nPartId) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, false) - bool bOk = true ; // verifico sia veramente un pezzo - if ( ExeIsPart( nPartId)) { - // ciclo sugli oggetti del pezzo - int nId = pGeomDB->GetFirstInGroup( nPartId) ; - while ( nId != GDB_ID_NULL) { - // se è gruppo deseleziono i suoi componenti - if ( pGeomDB->GetGdbType( nId) == GDB_TY_GROUP) - pGeomDB->DeselectGroupObjs( nId) ; - // altrimenti lo deseleziono direttamente - else - pGeomDB->DeselectObj( nId) ; - // passo al successivo - nId = pGeomDB->GetNext( nId) ; - } - } - else - bOk = false ; + bool bOk = ExeIsPart( nPartId) ; + // eseguo deselezione (anche del pezzo per maggior sicurezza) + bOk = bOk && MyDeselectGroupObjs( pGeomDB, nPartId) && pGeomDB->DeselectObj( nPartId) ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtDeselectPartObjs(" + ToString( nPartId) + ")" + @@ -498,21 +505,11 @@ ExeSelectLayerObjs( int nLayerId) GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX_GEOMDB( pGseCtx, false) IGeomDB* pGeomDB = pGseCtx->m_pGeomDB ; - bool bOk = true ; - // verifico sia veramente un layer - if ( ExeIsLayer( nLayerId)) { - // ciclo sugli oggetti del layer - int nId = pGeomDB->GetFirstInGroup( nLayerId) ; - while ( nId != GDB_ID_NULL) { - // se selezionabile, seleziono - if ( ( pGeomDB->GetGeoType( nId) & pGseCtx->m_nObjFilterForSelect) != 0) - pGeomDB->SelectObj( nId) ; - // passo al successivo - nId = pGeomDB->GetNext( nId) ; - } - } - else - bOk = false ; + // verifico sia veramente un layer o almeno un gruppo di un pezzo + bool bOk = ExeIsLayer( nLayerId) || + ( ( pGeomDB->GetGdbType( nLayerId) == GDB_TY_GROUP) && ExeIsPart( pGeomDB->GetParentId( nLayerId))) ; + // eseguo selezione + bOk = bOk && MySelectGroupObjs( pGeomDB, nLayerId, pGseCtx->m_nObjFilterForSelect) ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtSelectLayerObjs(" + ToString( nLayerId) + ")" + @@ -529,20 +526,11 @@ ExeDeselectLayerObjs( int nLayerId) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, false) - bool bOk = true ; - // verifico sia veramente un layer - if ( ExeIsLayer( nLayerId)) { - // ciclo sugli oggetti del layer - int nId = pGeomDB->GetFirstInGroup( nLayerId) ; - while ( nId != GDB_ID_NULL) { - // deseleziono - pGeomDB->DeselectObj( nId) ; - // passo al successivo - nId = pGeomDB->GetNext( nId) ; - } - } - else - bOk = false ; + // verifico sia veramente un layer o almeno un gruppo di un pezzo + bool bOk = ExeIsLayer( nLayerId) || + ( ( pGeomDB->GetGdbType( nLayerId) == GDB_TY_GROUP) && ExeIsPart( pGeomDB->GetParentId( nLayerId))) ; + // eseguo deselezione (anche del layer per maggior sicurezza) + bOk = bOk && MyDeselectGroupObjs( pGeomDB, nLayerId) && pGeomDB->DeselectObj( nLayerId) ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtDeselectLayerObjs(" + ToString( nLayerId) + ")" + diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 290e7e1223a24aa48cc7d2aff8f3598ade04da79..5895e80f9b40d0f441ccaa92019de2121bfd916f 100644 GIT binary patch delta 79 zcmexR`k{2gFE&Qw&A-`PnSqoe*K!sx?>N)s4T4pS#*-bnk~jAW*?>e(i-FY$N+HxV MD8kglDNT|90Go*$jQ{`u delta 79 zcmexR`k{2gFE&P_&A-`PnSqoe*K!sx?>N)s4T4pSMw1=6k~jAW*?>e(i-FY$N+HxV MD8kglDNT|90Gd4;g#Z8m