//---------------------------------------------------------------------------- // EgalTech 2014-2014 //---------------------------------------------------------------------------- // File : API_GeomDB.cpp Data : 01.09.14 Versione : 1.5i1 // Contenuto : Funzioni DB geometrico per API. // // // // Modifiche : 01.09.14 DS Creazione modulo. // // //---------------------------------------------------------------------------- //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "API.h" #include "API_Macro.h" #include "/EgtDev/Include/EInAPI.h" #include "/EgtDev/Include/EGnStringUtils.h" #include "/EgtDev/Include/EGnStringConverter.h" #include "/EgtDev/Include/EgtPointerOwner.h" using namespace std ; //----------------------------------------------------------------------------- int __stdcall EgtInitGeomDB( void) { // creo e recupero un contesto libero int nGseCtx = CreateGseContext() ; if ( nGseCtx == 0) { LOG_ERROR( GetLogger(), "Error in CreateGseContext (" __FUNCTION__ ")") return 0 ; } GseContext* pGseCtx = GetGseContext( nGseCtx) ; // inizializzazioni DB geometrico PtrOwner pGeomDB( CreateGeomDB()) ; VERIFY_NULL( Get( pGeomDB), "Error in CreateGeomDB", nGseCtx) // inserisco il GeomDB nel contesto pGseCtx->m_pGeomDB = Release( pGeomDB) ; pGseCtx->m_pGeomDB->Init() ; pGseCtx->m_pGeomDB->SetDefaultMaterial( pGseCtx->m_colDef) ; // log avvio DB geometrico string sLog = "GeomDB started " + ToString( nGseCtx) ; LOG_INFO( GetLogger(), sLog.c_str()) return nGseCtx ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetDefaultMaterial( int nGseCtx, int nRed, int nGreen, int nBlue) { GseContext* pGseCtx = GetGseContext( nGseCtx) ; VERIFY_CTX_GEOMDB( pGseCtx, FALSE) // imposto il materiale di default pGseCtx->m_colDef.Set( nRed, nGreen, nBlue) ; pGseCtx->m_pGeomDB->SetDefaultMaterial( pGseCtx->m_colDef) ; return TRUE ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtNewFile( int nGseCtx) { GseContext* pGseCtx = GetGseContext( nGseCtx) ; VERIFY_CTX_GEOMDB( pGseCtx, FALSE) // reinizializzazione (con pulizia) del DB geometrico pGseCtx->m_pGeomDB->Init() ; pGseCtx->m_pGeomDB->SetDefaultMaterial( pGseCtx->m_colDef) ; return TRUE ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtOpenFile( int nGseCtx, const wchar_t* wsFilePath) { return EgtOpenFile( nGseCtx, wstrztoA( wsFilePath)) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtOpenFile( int nGseCtx, const string& sFilePath) { // reinizializzazione (con pulizia) del DB geometrico if ( ! EgtNewFile( nGseCtx)) return FALSE ; // carico il file return ( GetGeomDB( nGseCtx)->Load( sFilePath) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSaveFile( int nGseCtx, const wchar_t* wsFilePath, int nFlag) { return EgtSaveFile( nGseCtx, wstrztoA( wsFilePath), nFlag) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSaveFile( int nGseCtx, const string& sFilePath, int nFlag) { IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; VERIFY_GEOMDB( pGeomDB, FALSE) // salvo il file return ( pGeomDB->Save( sFilePath, nFlag) ? TRUE : FALSE) ; }