Files
EgtInterface/API_GdbObjects.cpp
T
Dario Sassi 6735c79753 EgtInterface :
- piccoli miglioramenti.
2014-09-20 22:05:32 +00:00

184 lines
6.1 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2014-2014
//----------------------------------------------------------------------------
// File : API_GdbIterate.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 "API.h"
#include "API_Macro.h"
#include "/EgtDev/Include/EInAPI.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EGnStringConverter.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
using namespace std ;
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtExistsObj( int nGseCtx, int nId)
{
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero il primo oggetto nel gruppo
return ( pGeomDB->ExistsObj( nId) ? TRUE : FALSE) ;
}
//-----------------------------------------------------------------------------
int
__stdcall EgtGetGroupObjs( int nGseCtx, int nId)
{
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero il primo oggetto nel gruppo
return ( pGeomDB->GetGroupObjs( nId)) ;
}
//-----------------------------------------------------------------------------
int
__stdcall EgtGetFirstInGroup( int nGseCtx, int nGroupId)
{
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero il primo oggetto nel gruppo
return pGeomDB->GetFirstInGroup( nGroupId) ;
}
//-----------------------------------------------------------------------------
int
__stdcall EgtGetNext( int nGseCtx, int nId)
{
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero il prossimo oggetto nello stesso gruppo
return pGeomDB->GetNext( nId) ;
}
//-----------------------------------------------------------------------------
int
__stdcall EgtGetLastInGroup( int nGseCtx, int nGroupId)
{
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero l'ultimo oggetto nel gruppo
return pGeomDB->GetLastInGroup( nGroupId) ;
}
//-----------------------------------------------------------------------------
int
__stdcall EgtGetPrev( int nGseCtx, int nId)
{
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero il precedente oggetto nello stesso gruppo
return pGeomDB->GetPrev( nId) ;
}
//-----------------------------------------------------------------------------
int
__stdcall EgtGetType( int nGseCtx, int nId)
{
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
VERIFY_GEOMDB( pGeomDB, GDB_TY_NONE)
// recupero il tipo GDB
int nType = pGeomDB->GetGdbType( nId) ;
if ( nType == GDB_TY_GEO) {
// recupero il tipo Geo
const IGeoObj* pGeoObj = pGeomDB->GetGeoObj( nId) ;
if ( pGeoObj == nullptr)
return GDB_TY_NONE ;
else
return pGeoObj->GetType() ;
}
else if ( nType == GDB_TY_GROUP)
return GDB_TY_GROUP ;
else
return GDB_TY_NONE ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtGetTitle( int nGseCtx, int nId, wchar_t*& wsTitle)
{
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
VERIFY_GEOMDB( pGeomDB, FALSE)
// recupero l'oggetto geometrico
const IGeoObj* pGeoObj = pGeomDB->GetGeoObj( nId) ;
if ( pGeoObj == nullptr)
return FALSE ;
// recupero la stringa del titolo
wsTitle = _wcsdup( stringtoW( pGeoObj->GetTitle())) ;
return (( wsTitle == nullptr) ? FALSE : TRUE) ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtGroupDump( int nGseCtx, int nId, wchar_t*& wsDump)
{
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
VERIFY_GEOMDB( pGeomDB, FALSE)
// preparo l'intestazione
string sDump = "Group " + ToString( nId) + "\r\n" ;
// preparo gli attributi
pGeomDB->DumpAttributes( nId, sDump, "\r\n") ;
// numero di nodi (figli)
int nNodes = pGeomDB->GetGroupObjs( nId) ;
sDump += "Nodes : " + ToString( nNodes) + "\r\n" ;
// riferimento in globale
Frame3d frGlob ;
if ( pGeomDB->GetGroupGlobFrame( nId, frGlob)) {
sDump += "GlobFrame :\r\n" ;
sDump += " O(" + ToString( frGlob.Orig()) + ")\r\n" ;
sDump += " X(" + ToString( frGlob.VersX()) + ")\r\n" ;
sDump += " Y(" + ToString( frGlob.VersY()) + ")\r\n" ;
sDump += " Z(" + ToString( frGlob.VersZ()) + ")\r\n" ;
}
// ingombro in globale
BBox3d b3Glob ;
if ( pGeomDB->GetGlobalBBox( nId, b3Glob)) {
sDump += "GlobBBox :\r\n" ;
Point3d ptMin, ptMax ;
if ( b3Glob.GetMinMax( ptMin, ptMax)) {
sDump += " m(" + ToString( ptMin) + ")\r\n" ;
sDump += " M(" + ToString( ptMax) + ")\r\n" ;
}
else {
sDump += " Empty\r\n" ;
}
}
// alloco buffer di ritorno ed eseguo copia
wsDump = _wcsdup( stringtoW( sDump)) ;
return (( wsDump == nullptr) ? FALSE : TRUE) ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtGeoObjDump( int nGseCtx, int nId, wchar_t*& wsDump)
{
IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ;
VERIFY_GEOMDB( pGeomDB, FALSE)
// recupero l'oggetto geometrico
const IGeoObj* pGeoObj = pGeomDB->GetGeoObj( nId) ;
if ( pGeoObj == nullptr)
return FALSE ;
// preparo l'intestazione
string sDump = pGeoObj->GetTitle() + " " + ToString( nId) + "\r\n" ;
// preparo gli attributi
pGeomDB->DumpAttributes( nId, sDump, "\r\n") ;
// recupero i dati geometrici
if ( ! pGeoObj->Dump( sDump, "\r\n"))
return FALSE ;
// alloco buffer di ritorno ed eseguo copia
wsDump = _wcsdup( stringtoW( sDump)) ;
return (( wsDump == nullptr) ? FALSE : TRUE) ;
}