//---------------------------------------------------------------------------- // EgalTech 2014-2014 //---------------------------------------------------------------------------- // File : API_GdbObjects.cpp Data : 02.09.14 Versione : 1.5i1 // Contenuto : Funzioni iterazione di DB geometrico per API. // // // // Modifiche : 02.09.14 DS Creazione modulo. // // //---------------------------------------------------------------------------- //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "EXE.h" #include "EXE_Macro.h" #include "/EgtDev/Include/EXeExecutor.h" #include "/EgtDev/Include/EGkStringUtils3d.h" #include "/EgtDev/Include/EgtStringConverter.h" #include "/EgtDev/Include/EgtPointerOwner.h" using namespace std ; //----------------------------------------------------------------------------- bool ExeSetObjFilterForSelect( bool bZerodim, bool bCurve, bool bSurf, bool bVolume, bool bExtra) { GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX_SCENE( pGseCtx, false) // imposto il filtro pGseCtx->m_nObjFilterForSelect = 0 ; if ( bZerodim) pGseCtx->m_nObjFilterForSelect |= GEO_ZERODIM ; if ( bCurve) pGseCtx->m_nObjFilterForSelect |= GEO_CURVE ; if ( bSurf) pGseCtx->m_nObjFilterForSelect |= GEO_SURF ; if ( bVolume) pGseCtx->m_nObjFilterForSelect |= GEO_VOLUME ; if ( bExtra) pGseCtx->m_nObjFilterForSelect |= GEO_EXTRA ; bool bOk = true ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtSetObjFilterForSelect(" + string( bZerodim ? "true" : "false") + "," + string( bCurve ? "true" : "false") + "," + string( bSurf ? "true" : "false") + "," + string( bVolume ? "true" : "false") + "," + string( bExtra ? "true" : "false") + ")" + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco risultato return bOk ; } //----------------------------------------------------------------------------- bool ExeSelectObj( int nId) { GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX_GEOMDB( pGseCtx, false) IGeomDB* pGeomDB = pGseCtx->m_pGeomDB ; // se selezionabile, seleziono l'oggetto bool bOk ; if ( pGeomDB->GetGdbType( nId) == GDB_TY_GROUP) bOk = pGeomDB->SelectObj( nId) ; else if ( ( pGeomDB->GetGeoType( nId) & pGseCtx->m_nObjFilterForSelect) != 0) bOk = pGeomDB->SelectObj( nId) ; else bOk = pGeomDB->ExistsObj( nId) ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtSelectObj(" + ToString( nId) + ")" + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco risultato return bOk ; } //----------------------------------------------------------------------------- bool ExeDeselectObj( int nId) { GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX_GEOMDB( pGseCtx, false) IGeomDB* pGeomDB = GetCurrGeomDB() ; // deseleziono l'oggetto bool bOk = pGeomDB->DeselectObj( nId) ; // eventuale sistemazione ultimi selezionati if ( nId == pGseCtx->m_siSel.nLastId) pGseCtx->m_siSel.ResetLast() ; else if ( nId == pGseCtx->m_siSel.nPrevId) pGseCtx->m_siSel.ResetPrev() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtDeselectObj(" + ToString( nId) + ")" + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco risultato return bOk ; } //----------------------------------------------------------------------------- bool ExeSelectAll( bool bOnlyIfVisible) { GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX_GEOMDB( pGseCtx, false) IGeomDB* pGeomDB = pGseCtx->m_pGeomDB ; // seleziono tutto int nId1 = ExeGetFirstPart( bOnlyIfVisible) ; while ( nId1 != GDB_ID_NULL) { // ciclo sugli oggetti del pezzo int nId2 = pGeomDB->GetFirstInGroup( nId1) ; while ( nId2 != GDB_ID_NULL) { // se è gruppo seleziono i suoi componenti if ( pGeomDB->GetGdbType( nId2) == GDB_TY_GROUP) pGeomDB->SelectGroupObjs( nId2, pGseCtx->m_nObjFilterForSelect, bOnlyIfVisible) ; // altrimenti, se selezionabile lo seleziono direttamente else { if ( ( pGeomDB->GetGeoType( nId2) & pGseCtx->m_nObjFilterForSelect) != 0) pGeomDB->SelectObj( nId2, bOnlyIfVisible) ; } // passo al successivo nId2 = pGeomDB->GetNext( nId2) ; } // passo al successivo nId1 = ExeGetNextPart( nId1, bOnlyIfVisible) ; } // reset info ultimi due selezionati pGseCtx->m_siSel.Reset() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtSelectAll(" + string( bOnlyIfVisible ? "true" : "false") + ")" + " -- bOk=1" ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco risultato return true ; } //----------------------------------------------------------------------------- bool ExeDeselectAll( void) { GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX_GEOMDB( pGseCtx, false) IGeomDB* pGeomDB = GetCurrGeomDB() ; // deseleziono tutto bool bOk = pGeomDB->ClearSelection() ; // reset info ultimi due selezionati pGseCtx->m_siSel.Reset() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtDeselectAll()" " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco risultato return bOk ; } //----------------------------------------------------------------------------- bool ExeSelectGroupObjs( int nGroupId) { GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX_GEOMDB( pGseCtx, false) IGeomDB* pGeomDB = pGseCtx->m_pGeomDB ; bool bOk = true ; // verifico sia un gruppo if ( pGeomDB->GetGdbType( nGroupId) == GDB_TY_GROUP) { bOk = pGeomDB->SelectGroupObjs( nGroupId, pGseCtx->m_nObjFilterForSelect) ; // reset info ultimi due selezionati pGseCtx->m_siSel.Reset() ; } else bOk = false ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtSelectGroupObjs(" + ToString( nGroupId) + ")" + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco risultato return bOk ; } //----------------------------------------------------------------------------- bool ExeDeselectGroupObjs( int nGroupId) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, false) bool bOk = true ; // verifico sia un gruppo if ( pGeomDB->GetGdbType( nGroupId) == GDB_TY_GROUP) { bOk = pGeomDB->DeselectGroupObjs( nGroupId) ; } else bOk = false ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sLua = "EgtDeselectGroupObjs(" + ToString( nGroupId) + ")" + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco risultato return bOk ; } //----------------------------------------------------------------------------- bool ExeIsSelectedObj( int nId) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, false) // verifico se l'oggetto è selezionato return pGeomDB->IsSelectedObj( nId) ; } //----------------------------------------------------------------------------- int ExeGetSelectedObjCount( void) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, 0) // restituisco il numero di oggetti selezionati return pGeomDB->GetSelectedObjNbr() ; } //----------------------------------------------------------------------------- int ExeGetFirstSelectedObj( void) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) // recupero il primo oggetto selezionato return pGeomDB->GetFirstSelectedObj() ; } //----------------------------------------------------------------------------- int ExeGetNextSelectedObj( void) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) // recupero il successivo oggetto selezionato return pGeomDB->GetNextSelectedObj() ; } //----------------------------------------------------------------------------- int ExeGetLastSelectedObj( void) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) // recupero l'ultimo oggetto selezionato return pGeomDB->GetLastSelectedObj() ; } //----------------------------------------------------------------------------- int ExeGetPrevSelectedObj( void) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) // recupero il precedente oggetto selezionato return pGeomDB->GetPrevSelectedObj() ; } //----------------------------------------------------------------------------- bool ExeSetSelInfo( int nId, int nSub, const Point3d& ptSel) { GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX( pGseCtx, false) // imposto le informazioni ausiliarie di selezione pGseCtx->m_siSel.Set( nId, nSub, ptSel) ; return true ; } //----------------------------------------------------------------------------- bool ExeGetLastSelInfo( int& nLastId, int& nLastSub, Point3d& ptLastSel) { GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX( pGseCtx, false) // recupero le informazioni ausiliarie di selezione dell'ultima entità nLastId = pGseCtx->m_siSel.nLastId ; nLastSub = pGseCtx->m_siSel.nLastSub ; ptLastSel = pGseCtx->m_siSel.ptLastSel ; return true ; } //----------------------------------------------------------------------------- bool ExeGetPrevSelInfo( int& nPrevId, int& nPrevSub, Point3d& ptPrevSel) { GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX( pGseCtx, false) // recupero le informazioni ausiliarie di selezione dell'ultima entità nPrevId = pGseCtx->m_siSel.nPrevId ; nPrevSub = pGseCtx->m_siSel.nPrevSub ; ptPrevSel = pGseCtx->m_siSel.ptPrevSel ; return true ; }