Files
EgtExecutor/EXE_GdbObjSelection.cpp
T
Dario Sassi 106af42cc1 EgtExecutor 1.6h3 :
- rettangoli sempre disegnati CCW
- aggiunta creazione di Regioni rettangolo, stadium e disco
- correzioni a ExeSplitCurveAtSel
- aggiunta ExeProjectCurveOnPlane
- aggiunte funzioni per normale a regione piana e numero di chunk
- sostituzione di Num o Nbr con Count.
2015-08-18 07:38:26 +00:00

218 lines
6.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
ExeSelectObj( int nId)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
// seleziono l'oggetto
bool bOk = pGeomDB->SelectObj( 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)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
// 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, 0, bOnlyIfVisible) ;
// altrimenti lo seleziono direttamente
else
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)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
bool bOk = true ;
// verifico sia un gruppo
if ( pGeomDB->GetGdbType( nGroupId) == GDB_TY_GROUP) {
bOk = pGeomDB->SelectGroupObjs( nGroupId) ;
}
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() ;
}