9186cc8a3d
- correzioni per selezione e filtri.
262 lines
8.7 KiB
C++
262 lines
8.7 KiB
C++
//----------------------------------------------------------------------------
|
|
// 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)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, false)
|
|
// deseleziono l'oggetto
|
|
bool bOk = pGeomDB->DeselectObj( nId) ;
|
|
// 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) ;
|
|
}
|
|
// 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)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, false)
|
|
// deseleziono tutto
|
|
bool bOk = pGeomDB->ClearSelection() ;
|
|
// 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) ;
|
|
}
|
|
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() ;
|
|
}
|