diff --git a/API_GdbObjAttribs.cpp b/API_GdbObjAttribs.cpp new file mode 100644 index 0000000..4e8ef0a --- /dev/null +++ b/API_GdbObjAttribs.cpp @@ -0,0 +1,296 @@ +//---------------------------------------------------------------------------- +// EgalTech 2014-2014 +//---------------------------------------------------------------------------- +// File : API_GdbObjAttribs.cpp Data : 03.09.14 Versione : 1.5i1 +// Contenuto : Funzioni sugli attributi degli oggetti di GeomDB per API. +// +// +// +// Modifiche : 03.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 ; + + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtSetLevel( int nGseCtx, int nId, int nLevel) +{ + IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; + VERIFY_GEOMDB( pGeomDB, FALSE) + // imposto il livello + return ( pGeomDB->SetLevel( nId, nLevel) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtRevertLevel( int nGseCtx, int nId) +{ + IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; + VERIFY_GEOMDB( pGeomDB, FALSE) + // porto il livello allo stato precedente + return ( pGeomDB->RevertLevel( nId) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtGetLevel( int nGseCtx, int nId, int* pnLevel) +{ + IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; + VERIFY_GEOMDB( pGeomDB, FALSE) + // verifico il parametro + if ( pnLevel == nullptr) + return FALSE ; + // recupero il livello + return ( pGeomDB->GetLevel( nId, *pnLevel) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtGetCalcLevel( int nGseCtx, int nId, int* pnLevel) +{ + IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; + VERIFY_GEOMDB( pGeomDB, FALSE) + // verifico il parametro + if ( pnLevel == nullptr) + return FALSE ; + // recupero il modo + return ( pGeomDB->GetCalcLevel( nId, *pnLevel) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtSetMode( int nGseCtx, int nId, int nMode) +{ + IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; + VERIFY_GEOMDB( pGeomDB, FALSE) + // imposto il modo + return ( pGeomDB->SetMode( nId, nMode) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtRevertMode( int nGseCtx, int nId) +{ + IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; + VERIFY_GEOMDB( pGeomDB, FALSE) + // porto il modo allo stato precedente + return ( pGeomDB->RevertMode( nId) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtGetMode( int nGseCtx, int nId, int* pnMode) +{ + IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; + VERIFY_GEOMDB( pGeomDB, FALSE) + // verifico il parametro + if ( pnMode == nullptr) + return FALSE ; + // recupero il modo + return ( pGeomDB->GetMode( nId, *pnMode) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtGetCalcMode( int nGseCtx, int nId, int* pnMode) +{ + IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; + VERIFY_GEOMDB( pGeomDB, FALSE) + // verifico il parametro + if ( pnMode == nullptr) + return FALSE ; + // recupero il modo + return ( pGeomDB->GetCalcMode( nId, *pnMode) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtSetStatus( int nGseCtx, int nId, int nStat) +{ + IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; + VERIFY_GEOMDB( pGeomDB, FALSE) + // imposto il modo + return ( pGeomDB->SetStatus( nId, nStat) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtRevertStatus( int nGseCtx, int nId) +{ + IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; + VERIFY_GEOMDB( pGeomDB, FALSE) + // porto lo stato al valore precedente + return ( pGeomDB->RevertStatus( nId) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtGetStatus( int nGseCtx, int nId, int* pnStat) +{ + IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; + VERIFY_GEOMDB( pGeomDB, FALSE) + // verifico il parametro + if ( pnStat == nullptr) + return FALSE ; + // recupero il modo + return ( pGeomDB->GetStatus( nId, *pnStat) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtGetCalcStatus( int nGseCtx, int nId, int* pnStat) +{ + IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; + VERIFY_GEOMDB( pGeomDB, FALSE) + // verifico il parametro + if ( pnStat == nullptr) + return FALSE ; + // recupero il modo + return ( pGeomDB->GetCalcStatus( nId, *pnStat) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtSetMark( int nGseCtx, int nId) +{ + IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; + VERIFY_GEOMDB( pGeomDB, FALSE) + // imposto l'evidenziazione + return ( pGeomDB->SetMark( nId) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtResetMark( int nGseCtx, int nId) +{ + IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; + VERIFY_GEOMDB( pGeomDB, FALSE) + // imposto l'evidenziazione + return ( pGeomDB->ResetMark( nId) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtGetMark( int nGseCtx, int nId, BOOL* pbMark) +{ + IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; + VERIFY_GEOMDB( pGeomDB, FALSE) + // verifico il parametro + if ( pbMark == nullptr) + return FALSE ; + // recupero il modo + return ( pGeomDB->GetMark( nId, *pbMark) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtGetCalcMark( int nGseCtx, int nId, BOOL* pbMark) +{ + IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; + VERIFY_GEOMDB( pGeomDB, FALSE) + // verifico il parametro + if ( pbMark == nullptr) + return FALSE ; + // recupero il modo + return ( pGeomDB->GetCalcMark( nId, *pbMark) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtSetName( int nGseCtx, int nId, const wchar_t* wsName) +{ + IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; + VERIFY_GEOMDB( pGeomDB, FALSE) + // assegno il nome + return ( pGeomDB->SetName( nId, wstrztoA( wsName)) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtGetName( int nGseCtx, int nId, wchar_t*& wsName) +{ + IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; + VERIFY_GEOMDB( pGeomDB, FALSE) + // recupero il nome + string sName ; + if ( ! pGeomDB->GetName( nId, sName)) + return FALSE ; + wsName = _wcsdup( stringtoW( sName)) ; + return (( wsName == nullptr) ? FALSE : TRUE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtExistsName( int nGseCtx, int nId) +{ + IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; + VERIFY_GEOMDB( pGeomDB, FALSE) + // verifico esistenza del nome + return ( pGeomDB->ExistsName( nId) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtRemoveName( int nGseCtx, int nId) +{ + IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; + VERIFY_GEOMDB( pGeomDB, FALSE) + // rimuovo il nome + return ( pGeomDB->RemoveName( nId) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtSetInfo( int nGseCtx, int nId, const wchar_t* wsKey, const wchar_t* wsInfo) +{ + IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; + VERIFY_GEOMDB( pGeomDB, FALSE) + // assegno la info + return ( pGeomDB->SetInfo( nId, wstrztoA( wsKey), string( wstrztoA( wsInfo))) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtGetInfo( int nGseCtx, int nId, const wchar_t* wsKey, wchar_t*& wsInfo) +{ + IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; + VERIFY_GEOMDB( pGeomDB, FALSE) + // recupero la info + string sInfo ; + if ( ! pGeomDB->GetInfo( nId, wstrztoA( wsKey), sInfo)) + return FALSE ; + wsInfo = _wcsdup( stringtoW( sInfo)) ; + return (( wsInfo == nullptr) ? FALSE : TRUE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtExistsInfo( int nGseCtx, int nId, const wchar_t* wsKey) +{ + IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; + VERIFY_GEOMDB( pGeomDB, FALSE) + // verifico esistenza info + return ( pGeomDB->ExistsInfo( nId, wstrztoA( wsKey)) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtRemoveInfo( int nGseCtx, int nId, const wchar_t* wsKey) +{ + IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; + VERIFY_GEOMDB( pGeomDB, FALSE) + // rimuovo la info + return ( pGeomDB->RemoveInfo( nId, wstrztoA( wsKey)) ? TRUE : FALSE) ; +} diff --git a/API_GdbObjects.cpp b/API_GdbObjects.cpp new file mode 100644 index 0000000..780f236 --- /dev/null +++ b/API_GdbObjects.cpp @@ -0,0 +1,173 @@ +//---------------------------------------------------------------------------- +// 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 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) ; +} diff --git a/API_General.cpp b/API_General.cpp index 2e79cbe..6d0ddf4 100644 --- a/API_General.cpp +++ b/API_General.cpp @@ -94,6 +94,16 @@ __stdcall EgtSetFont( const wchar_t* sNfeFontDir, const wchar_t* sDefaultFont) return TRUE ; } +//----------------------------------------------------------------------------- +BOOL +__stdcall EgtFreeMemory( void* pMem) +{ + if ( pMem == nullptr) + return FALSE ; + free( pMem) ; + return TRUE ; +} + //----------------------------------------------------------------------------- ILogger* GetLogger( void) diff --git a/API_GeomDB.cpp b/API_GeomDB.cpp index a174f68..6ace9e7 100644 --- a/API_GeomDB.cpp +++ b/API_GeomDB.cpp @@ -14,6 +14,7 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "API.h" +#include "API_Macro.h" #include "/EgtDev/Include/EInAPI.h" #include "/EgtDev/Include/EExImportStl.h" #include "/EgtDev/Include/EExImportDxf.h" @@ -31,8 +32,7 @@ __stdcall EgtInitGeomDB( void) { // inizializzazioni DB geometrico PtrOwner pGeomDB( CreateGeomDB()) ; - if ( IsNull( pGeomDB)) - return 0 ; + VERIFY_NULL( Get( pGeomDB), "Error in CreateGeomDB", 0) // creo e recupero un contesto libero int nGseCtx = CreateGseContext() ; if ( nGseCtx == 0) @@ -53,12 +53,8 @@ __stdcall EgtInitGeomDB( void) BOOL __stdcall EgtSetDefaultMaterial( int nGseCtx, int nRed, int nGreen, int nBlue) { - // verifico GeomDB GseContext* pGseCtx = GetGseContext( nGseCtx) ; - if ( pGseCtx == nullptr || pGseCtx->m_pGeomDB == nullptr) { - LOG_ERROR( GetLogger(), "GeomDB invalid (EgtSetDefaultMaterial)") - return FALSE ; - } + VERIFY_CTX_GEOMDB( pGseCtx, FALSE) // imposto il materiale di default pGseCtx->m_colDef.Set( nRed, nGreen, nBlue) ; pGseCtx->m_pGeomDB->SetDefaultMaterial( pGseCtx->m_colDef) ; @@ -69,12 +65,8 @@ __stdcall EgtSetDefaultMaterial( int nGseCtx, int nRed, int nGreen, int nBlue) BOOL __stdcall EgtNewFile( int nGseCtx) { - // verifico GeomDB GseContext* pGseCtx = GetGseContext( nGseCtx) ; - if ( pGseCtx == nullptr || pGseCtx->m_pGeomDB == nullptr) { - LOG_ERROR( GetLogger(), "GeomDB invalid (EgtNewFile)") - return FALSE ; - } + VERIFY_CTX_GEOMDB( pGseCtx, FALSE) // reinizializzazione (con pulizia) del DB geometrico pGseCtx->m_pGeomDB->Init() ; pGseCtx->m_pGeomDB->SetDefaultMaterial( pGseCtx->m_colDef) ; @@ -89,27 +81,17 @@ __stdcall EgtOpenFile( int nGseCtx, const wchar_t* wsFilePath) if ( ! EgtNewFile( nGseCtx)) return FALSE ; // carico il file - if ( GetGseContext( nGseCtx)->m_pGeomDB->Load( LPSTR( WtoA( wsFilePath)))) - return TRUE ; - else - return FALSE ; + return ( GetGeomDB( nGseCtx)->Load( wstrztoA( wsFilePath)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSaveFile( int nGseCtx, const wchar_t* wsFilePath, int nFlag) { - // verifico GeomDB - GseContext* pGseCtx = GetGseContext( nGseCtx) ; - if ( pGseCtx == nullptr || pGseCtx->m_pGeomDB == nullptr) { - LOG_ERROR( GetLogger(), "GeomDB invalid (EgtSaveFile)") - return FALSE ; - } + IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; + VERIFY_GEOMDB( pGeomDB, FALSE) // salvo il file - if ( pGseCtx->m_pGeomDB->Save( LPSTR( WtoA( wsFilePath)), nFlag)) - return TRUE ; - else - return FALSE ; + return ( pGeomDB->Save( wstrztoA( wsFilePath), nFlag) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- @@ -118,7 +100,7 @@ __stdcall EgtGetFileType( const wchar_t* wsFilePath) { // divido in nome e direttorio string sFileDir, sFileName ; - SplitLast( LPSTR( WtoA( wsFilePath)), "\\", sFileDir, sFileName) ; + SplitLast( wstrztoA( wsFilePath), "\\", sFileDir, sFileName) ; // recupero l'estensione string sFileTitle, sFileExt ; @@ -145,99 +127,59 @@ __stdcall EgtGetFileType( const wchar_t* wsFilePath) BOOL __stdcall EgtImportDxf( int nGseCtx, const wchar_t* wsFilePath) { - // verifico GeomDB - GseContext* pGseCtx = GetGseContext( nGseCtx) ; - if ( pGseCtx == nullptr || pGseCtx->m_pGeomDB == nullptr) { - LOG_ERROR( GetLogger(), "GeomDB invalid (EgtImportDxf)") - return FALSE ; - } + IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; + VERIFY_GEOMDB( pGeomDB, FALSE) // importo il file DXF // aggiungo un gruppo pezzo - int nPartId = pGseCtx->m_pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ; + int nPartId = pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ; // preparo l'importatore PtrOwner pImpDxf( CreateImportDxf()) ; - if ( IsNull( pImpDxf)) { - LOG_ERROR( GetLogger(), "Error : CreateImportDxf") - return FALSE ; - } + VERIFY_NULL( Get( pImpDxf), "Error in CreateImportDxf", FALSE) // eseguo l'importazione - if ( pImpDxf->Import( LPSTR( WtoA( wsFilePath)), pGseCtx->m_pGeomDB, nPartId)) - return TRUE ; - else - return FALSE ; + return ( pImpDxf->Import( wstrztoA( wsFilePath), pGeomDB, nPartId) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtImportStl( int nGseCtx, const wchar_t* wsFilePath) { - // verifico GeomDB - GseContext* pGseCtx = GetGseContext( nGseCtx) ; - if ( pGseCtx == nullptr || pGseCtx->m_pGeomDB == nullptr) { - LOG_ERROR( GetLogger(), "GeomDB invalid (EgtImportStl)") - return FALSE ; - } + IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; + VERIFY_GEOMDB( pGeomDB, FALSE) // importo il file STL // aggiungo un gruppo pezzo e un gruppo layer - int nPartId = pGseCtx->m_pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ; - int nLayerId = pGseCtx->m_pGeomDB->AddGroup( GDB_ID_NULL, nPartId, Frame3d()) ; + int nPartId = pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ; + int nLayerId = pGeomDB->AddGroup( GDB_ID_NULL, nPartId, Frame3d()) ; // preparo l'importatore PtrOwner pImpStl( CreateImportStl()) ; - if ( IsNull( pImpStl)) { - LOG_ERROR( GetLogger(), "Error : CreateImportStl") - return FALSE ; - } + VERIFY_NULL( Get( pImpStl), "Error in CreateImportStl", FALSE) // eseguo l'importazione - if ( pImpStl->Import( LPSTR( WtoA( wsFilePath)), pGseCtx->m_pGeomDB, nLayerId)) - return TRUE ; - else - return FALSE ; + return ( pImpStl->Import( wstrztoA( wsFilePath), pGeomDB, nLayerId) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtExportDxf( int nGseCtx, int nId, const wchar_t* wsFilePath) { - // verifico GeomDB - GseContext* pGseCtx = GetGseContext( nGseCtx) ; - if ( pGseCtx == nullptr || pGseCtx->m_pGeomDB == nullptr) { - LOG_ERROR( GetLogger(), "GeomDB invalid (EgtExportDxf)") - return FALSE ; - } + IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; + VERIFY_GEOMDB( pGeomDB, FALSE) // esporto il file DXF // preparo l'esportatore PtrOwner pExpDxf( CreateExportDxf()) ; - if ( IsNull( pExpDxf)) { - LOG_ERROR( GetLogger(), "Error : CreateExportDxf") - return FALSE ; - } + VERIFY_NULL( Get( pExpDxf), "Error in CreateExportDxf", FALSE) // eseguo l'esportazione - if ( pExpDxf->Export( pGseCtx->m_pGeomDB, nId, LPSTR( WtoA( wsFilePath)))) - return TRUE ; - else - return FALSE ; + return ( pExpDxf->Export( pGeomDB, nId, wstrztoA( wsFilePath)) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtExportStl( int nGseCtx, int nId, const wchar_t* wsFilePath) { - // verifico GeomDB - GseContext* pGseCtx = GetGseContext( nGseCtx) ; - if ( pGseCtx == nullptr || pGseCtx->m_pGeomDB == nullptr) { - LOG_ERROR( GetLogger(), "GeomDB invalid (EgtExportStl)") - return FALSE ; - } + IGeomDB* pGeomDB = GetGeomDB( nGseCtx) ; + VERIFY_GEOMDB( pGeomDB, FALSE) // esporto il file STL // preparo l'esportatore PtrOwner pExpStl( CreateExportStl()) ; - if ( IsNull( pExpStl)) { - LOG_ERROR( GetLogger(), "Error : CreateExportStl") - return FALSE ; - } + VERIFY_NULL( Get( pExpStl), "Error in CreateExportStl", FALSE) // eseguo l'esportazione - if ( pExpStl->Export( pGseCtx->m_pGeomDB, nId, LPSTR( WtoA( wsFilePath)))) - return TRUE ; - else - return FALSE ; + return ( pExpStl->Export( pGeomDB, nId, wstrztoA( wsFilePath)) ? TRUE : FALSE) ; } diff --git a/API_Macro.h b/API_Macro.h new file mode 100644 index 0000000..512d2be --- /dev/null +++ b/API_Macro.h @@ -0,0 +1,42 @@ +//---------------------------------------------------------------------------- +// EgalTech 2014-2014 +//---------------------------------------------------------------------------- +// File : API_Macro Data : 03.09.14 Versione : 1.5i1 +// Contenuto : Macro locali per moduli API. +// +// +// +// Modifiche : 03.09.14 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + + +//----------------------------------------------------------------------------- +#define VERIFY_NULL( pO, Msg, Ret) if ( pO == nullptr) { \ + LOG_ERROR( GetLogger(), Msg " (" __FUNCTION__ ")") \ + return Ret ; \ + } + +//----------------------------------------------------------------------------- +#define VERIFY_2NULL( pO, pQ, Msg, Ret) if ( pO == nullptr || pQ == nullptr) { \ + LOG_ERROR( GetLogger(), Msg " (" __FUNCTION__ ")") \ + return Ret ; \ + } + +//----------------------------------------------------------------------------- +#define VERIFY_GEOMDB( pG, Ret) VERIFY_NULL( pG, "GeomDB invalid", Ret) + +//----------------------------------------------------------------------------- +#define VERIFY_CTX_GEOMDB( pC, Ret) VERIFY_2NULL( pC, pC->m_pGeomDB, "Context or GeomDB invalid", Ret) + +//----------------------------------------------------------------------------- +#define VERIFY_SCENE( pS, Ret) VERIFY_NULL( pS, "Scene invalid", Ret) + +//----------------------------------------------------------------------------- +#define VERIFY_CTX_SCENE( pC, Ret) VERIFY_2NULL( pC, pC->m_pScene, "Context or Scene invalid", Ret) + +//----------------------------------------------------------------------------- +#define VERIFY_TSCEXEC( pT, Ret) VERIFY_NULL( pT, "TscExecutor invalid", Ret) diff --git a/API_Scene.cpp b/API_Scene.cpp index 4cf66f0..e59cd47 100644 --- a/API_Scene.cpp +++ b/API_Scene.cpp @@ -14,6 +14,7 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "API.h" +#include "API_Macro.h" #include "/EgtDev/Include/EInAPI.h" #include "/EgtDev/Include/EgtPointerOwner.h" @@ -24,17 +25,11 @@ using namespace std ; BOOL __stdcall EgtInitScene( int nGseCtx, HWND hWnd, int nDriver, int b2Buff, int nColorBits, int nDepthBits) { - // recupero il contesto GseContext* pGseCtx = GetGseContext( nGseCtx) ; - // verifico GeomDB - if ( pGseCtx == nullptr || pGseCtx->m_pGeomDB == nullptr) { - LOG_ERROR( GetLogger(), "GeomDB invalid (EgtInitScene)") - return FALSE ; - } + VERIFY_CTX_GEOMDB( pGseCtx, FALSE) // inizializzazione scena OpenGL PtrOwner pScene( CreateEGrScene()) ; - if ( IsNull( pScene)) - return FALSE ; + VERIFY_NULL( Get( pScene), "Error in CreateEGrScene", FALSE) HDC hdc = GetDC( hWnd) ; if ( ! pScene->CreateContext( hdc, nDriver, ( b2Buff != 0), nColorBits, nDepthBits)) return FALSE ; @@ -61,17 +56,15 @@ __stdcall EgtInitScene( int nGseCtx, HWND hWnd, int nDriver, int b2Buff, int nCo //----------------------------------------------------------------------------- BOOL __stdcall EgtSetBackground( int nGseCtx, int nTopRed, int nTopGreen, int nTopBlue, - int nBottomRed, int nBottomGreen, int nBottomBlue) + int nBottomRed, int nBottomGreen, int nBottomBlue, BOOL bRedraw) { - // verifico Scena GseContext* pGseCtx = GetGseContext( nGseCtx) ; - if ( pGseCtx == nullptr || pGseCtx->m_pScene == nullptr) { - LOG_ERROR( GetLogger(), "Scene invalid (EgtSetBackground)") - return FALSE ; - } + VERIFY_CTX_SCENE( pGseCtx, FALSE) // imposto lo sfondo pGseCtx->m_pScene->SetBackground( Color( nTopRed, nTopGreen, nTopBlue), Color( nBottomRed, nBottomGreen, nBottomBlue)) ; + if ( bRedraw) + RedrawWindow( pGseCtx->m_hWnd, nullptr, nullptr, RDW_INVALIDATE) ; return TRUE ; } @@ -79,12 +72,8 @@ __stdcall EgtSetBackground( int nGseCtx, int nTopRed, int nTopGreen, int nTopBlu BOOL __stdcall EgtDraw( int nGseCtx) { - // verifico Scena GseContext* pGseCtx = GetGseContext( nGseCtx) ; - if ( pGseCtx == nullptr || pGseCtx->m_pScene == nullptr) { - LOG_ERROR( GetLogger(), "Scene invalid (EgtDraw)") - return FALSE ; - } + VERIFY_CTX_SCENE( pGseCtx, FALSE) // eseguo disegno pGseCtx->m_pScene->Draw() ; // valido la finestra disegnata @@ -97,14 +86,10 @@ __stdcall EgtDraw( int nGseCtx) BOOL __stdcall EgtResize( int nGseCtx, int nW, int nH) { - // verifico Scena - GseContext* pGseCtx = GetGseContext( nGseCtx) ; - if ( pGseCtx == nullptr || pGseCtx->m_pScene == nullptr) { - LOG_ERROR( GetLogger(), "Scene invalid (EgtResize)") - return FALSE ; - } + IEGrScene* pScene = GetScene( nGseCtx) ; + VERIFY_SCENE( pScene, FALSE) // eseguo resize - pGseCtx->m_pScene->Resize( nW, nH) ; + pScene->Resize( nW, nH) ; return TRUE ; } @@ -112,12 +97,8 @@ __stdcall EgtResize( int nGseCtx, int nW, int nH) BOOL __stdcall EgtSetShowMode( int nGseCtx, int nShowMode, BOOL bRedraw) { - // verifico Scena GseContext* pGseCtx = GetGseContext( nGseCtx) ; - if ( pGseCtx == nullptr || pGseCtx->m_pScene == nullptr) { - LOG_ERROR( GetLogger(), "Scene invalid (EgtSetShowMode)") - return FALSE ; - } + VERIFY_CTX_SCENE( pGseCtx, FALSE) // imposto il modo di visualizzazione if ( nShowMode >= SM_WIREFRAME && nShowMode <= SM_SHADING) { pGseCtx->m_pScene->SetShowMode( nShowMode) ; @@ -133,12 +114,8 @@ __stdcall EgtSetShowMode( int nGseCtx, int nShowMode, BOOL bRedraw) BOOL __stdcall EgtSetShowCurveDirection( int nGseCtx, int nShow, BOOL bRedraw) { - // verifico Scena GseContext* pGseCtx = GetGseContext( nGseCtx) ; - if ( pGseCtx == nullptr || pGseCtx->m_pScene == nullptr) { - LOG_ERROR( GetLogger(), "Scene invalid (EgtSetShowCurveDirection)") - return FALSE ; - } + VERIFY_CTX_SCENE( pGseCtx, FALSE) // imposto stato pGseCtx->m_pScene->SetShowCurveDirection( nShow != 0) ; if ( bRedraw) @@ -150,12 +127,8 @@ __stdcall EgtSetShowCurveDirection( int nGseCtx, int nShow, BOOL bRedraw) BOOL __stdcall EgtZoom( int nGseCtx, int nZoom, BOOL bRedraw) { - // verifico Scena GseContext* pGseCtx = GetGseContext( nGseCtx) ; - if ( pGseCtx == nullptr || pGseCtx->m_pScene == nullptr) { - LOG_ERROR( GetLogger(), "Scene invalid (EgtZoom)") - return FALSE ; - } + VERIFY_CTX_SCENE( pGseCtx, FALSE) const double COEFF_IN = 0.9 ; const double COEFF_OUT = 1 / COEFF_IN ; @@ -188,12 +161,8 @@ __stdcall EgtZoom( int nGseCtx, int nZoom, BOOL bRedraw) BOOL __stdcall EgtZoomOnPoint( int nGseCtx, int nWinX, int nWinY, double dCoeff, BOOL bRedraw) { - // verifico Scena GseContext* pGseCtx = GetGseContext( nGseCtx) ; - if ( pGseCtx == nullptr || pGseCtx->m_pScene == nullptr) { - LOG_ERROR( GetLogger(), "Scene invalid (EgtZoomOnPoint)") - return FALSE ; - } + VERIFY_CTX_SCENE( pGseCtx, FALSE) // eseguo zoom pGseCtx->m_pScene->ZoomOnPoint( Point3d( nWinX, nWinY), dCoeff) ; if ( bRedraw) @@ -205,12 +174,8 @@ __stdcall EgtZoomOnPoint( int nGseCtx, int nWinX, int nWinY, double dCoeff, BOOL BOOL __stdcall EgtSetWinRect( int nGseCtx, int nPrevX, int nPrevY, int nCurrX, int nCurrY, BOOL bRedraw) { - // verifico Scena GseContext* pGseCtx = GetGseContext( nGseCtx) ; - if ( pGseCtx == nullptr || pGseCtx->m_pScene == nullptr) { - LOG_ERROR( GetLogger(), "Scene invalid (EgtSetWinRect)") - return FALSE ; - } + VERIFY_CTX_SCENE( pGseCtx, FALSE) // disegno finestra per zoom pGseCtx->m_pScene->SetWinRect( Point3d( nPrevX, nPrevY), Point3d( nCurrX, nCurrY)) ; if ( bRedraw) @@ -222,12 +187,8 @@ __stdcall EgtSetWinRect( int nGseCtx, int nPrevX, int nPrevY, int nCurrX, int nC BOOL __stdcall EgtResetWinRect( int nGseCtx, BOOL bRedraw) { - // verifico Scena GseContext* pGseCtx = GetGseContext( nGseCtx) ; - if ( pGseCtx == nullptr || pGseCtx->m_pScene == nullptr) { - LOG_ERROR( GetLogger(), "Scene invalid (EgtResetWinRect)") - return FALSE ; - } + VERIFY_CTX_SCENE( pGseCtx, FALSE) // cancello finestra per zoom pGseCtx->m_pScene->ResetWinRect() ; if ( bRedraw) @@ -239,12 +200,8 @@ __stdcall EgtResetWinRect( int nGseCtx, BOOL bRedraw) BOOL __stdcall EgtZoomWin( int nGseCtx, int nPrevX, int nPrevY, int nCurrX, int nCurrY, BOOL bRedraw) { - // verifico Scena GseContext* pGseCtx = GetGseContext( nGseCtx) ; - if ( pGseCtx == nullptr || pGseCtx->m_pScene == nullptr) { - LOG_ERROR( GetLogger(), "Scene invalid (EgtZoomWin)") - return FALSE ; - } + VERIFY_CTX_SCENE( pGseCtx, FALSE) // eseguo zoom su finestra pGseCtx->m_pScene->ZoomWin( Point3d( nPrevX, nPrevY), Point3d( nCurrX, nCurrY)) ; if ( bRedraw) @@ -256,12 +213,8 @@ __stdcall EgtZoomWin( int nGseCtx, int nPrevX, int nPrevY, int nCurrX, int nCurr BOOL __stdcall EgtSetView( int nGseCtx, int nView, BOOL bRedraw) { - // verifico Scena GseContext* pGseCtx = GetGseContext( nGseCtx) ; - if ( pGseCtx == nullptr || pGseCtx->m_pScene == nullptr) { - LOG_ERROR( GetLogger(), "Scene invalid (EgtSetView)") - return FALSE ; - } + VERIFY_CTX_SCENE( pGseCtx, FALSE) // imposto vista if ( nView >= CT_TOP && nView <= CT_ISO_NW) { pGseCtx->m_pScene->SetCamera( nView) ; @@ -277,12 +230,8 @@ __stdcall EgtSetView( int nGseCtx, int nView, BOOL bRedraw) BOOL __stdcall EgtPanCamera( int nGseCtx, int nPrevX, int nPrevY, int nCurrX, int nCurrY, BOOL bRedraw) { - // verifico Scena GseContext* pGseCtx = GetGseContext( nGseCtx) ; - if ( pGseCtx == nullptr || pGseCtx->m_pScene == nullptr) { - LOG_ERROR( GetLogger(), "Scene invalid (EgtPanCamera)") - return FALSE ; - } + VERIFY_CTX_SCENE( pGseCtx, FALSE) // eseguo panoramica pGseCtx->m_pScene->PanCamera( Point3d( nPrevX, nPrevY), Point3d( nCurrX, nCurrY)) ; if ( bRedraw) @@ -294,12 +243,8 @@ __stdcall EgtPanCamera( int nGseCtx, int nPrevX, int nPrevY, int nCurrX, int nCu BOOL __stdcall EgtRotateCamera( int nGseCtx, int nPrevX, int nPrevY, int nCurrX, int nCurrY, BOOL bRedraw) { - // verifico Scena GseContext* pGseCtx = GetGseContext( nGseCtx) ; - if ( pGseCtx == nullptr || pGseCtx->m_pScene == nullptr) { - LOG_ERROR( GetLogger(), "Scene invalid (EgtRotateCamera)") - return FALSE ; - } + VERIFY_CTX_SCENE( pGseCtx, FALSE) // eseguo rotazione camera pGseCtx->m_pScene->RotateCamera( Point3d( nPrevX, nPrevY), Point3d( nCurrX, nCurrY)) ; if ( bRedraw) @@ -311,15 +256,12 @@ __stdcall EgtRotateCamera( int nGseCtx, int nPrevX, int nPrevY, int nCurrX, int BOOL __stdcall EgtGetCameraDir( int nGseCtx, int* pnDir) { - // verifico Scena - GseContext* pGseCtx = GetGseContext( nGseCtx) ; - if ( pGseCtx == nullptr || pGseCtx->m_pScene == nullptr) { - LOG_ERROR( GetLogger(), "Scene invalid (EgtGetCameraDir)") - return FALSE ; - } + IEGrScene* pScene = GetScene( nGseCtx) ; + VERIFY_SCENE( pScene, FALSE) // recupero direzione di vista - if ( pnDir != nullptr) - *pnDir = pGseCtx->m_pScene->GetCameraDir() ; + if ( pnDir == nullptr) + return FALSE ; + *pnDir = pScene->GetCameraDir() ; return TRUE ; } @@ -327,16 +269,12 @@ __stdcall EgtGetCameraDir( int nGseCtx, int* pnDir) BOOL __stdcall EgtUnProjectPoint( int nGseCtx, int nWinX, int nWinY, double ptP[3]) { - // verifico Scena - GseContext* pGseCtx = GetGseContext( nGseCtx) ; - if ( pGseCtx == nullptr || pGseCtx->m_pScene == nullptr) { - LOG_ERROR( GetLogger(), "Scene invalid (EgtUnProjectPoint)") - return FALSE ; - } + IEGrScene* pScene = GetScene( nGseCtx) ; + VERIFY_SCENE( pScene, FALSE) // eseguo l'inverso della proiezione (considero Z punto su centro) - Point3d ptView( nWinX, nWinY, pGseCtx->m_pScene->GetProjectedCenter().z) ; + Point3d ptView( nWinX, nWinY, pScene->GetProjectedCenter().z) ; Point3d ptWorld ; - if ( ! pGseCtx->m_pScene->UnProject( ptView, ptWorld)) + if ( ! pScene->UnProject( ptView, ptWorld)) return 0 ; ptP[0] = ptWorld.x ; ptP[1] = ptWorld.y ; diff --git a/API_TscExec.cpp b/API_TscExec.cpp index 557ad57..1ad99a6 100644 --- a/API_TscExec.cpp +++ b/API_TscExec.cpp @@ -14,6 +14,7 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "API.h" +#include "API_Macro.h" #include "/EgtDev/Include/EInAPI.h" #include "/EgtDev/Include/EGkGdbExecutor.h" #include "/EgtDev/Include/EExExcExecutor.h" @@ -29,13 +30,8 @@ using namespace std ; BOOL __stdcall EgtInitTscExec( int nGseCtx) { - // recupero il contesto GseContext* pGseCtx = GetGseContext( nGseCtx) ; - // verifico GeomDB - if ( pGseCtx == nullptr || pGseCtx->m_pGeomDB == nullptr) { - LOG_ERROR( GetLogger(), "GeomDB invalid (EgtInitTscExec)") - return FALSE ; - } + VERIFY_CTX_GEOMDB( pGseCtx, FALSE) // eventuale pulizia esecutore e suoi oggetti if ( pGseCtx->m_pTscExec != nullptr) { @@ -45,36 +41,24 @@ __stdcall EgtInitTscExec( int nGseCtx) // creo esecutore PtrOwner pCmdParser( CreateCmdParser()) ; - if ( IsNull( pCmdParser)) { - LOG_ERROR( GetLogger(), "Error in CreateCmdParser") - return FALSE ; - } + VERIFY_NULL( Get( pCmdParser), "Error in CreateCmdParser", FALSE) // creo oggetto per esecuzione funzioni di GeomKernel PtrOwner pGdbExec( CreateGdbExecutor()) ; - if ( IsNull( pGdbExec)) { - LOG_ERROR( GetLogger(), "Error in CreateGdbExecutor") - return FALSE ; - } + VERIFY_NULL( Get( pGdbExec), "Error in CreateGdbExecutor", FALSE) pGdbExec->SetGeomDB( pGseCtx->m_pGeomDB) ; pCmdParser->SetExecutor( Release( pGdbExec)) ; // creazione oggetto per esecuzione funzioni di Exchange PtrOwner pExcExec( CreateExcExecutor()) ; - if ( IsNull( pExcExec)) { - LOG_ERROR( GetLogger(), "Error in CreateExcExecutor") - return FALSE ; - } + VERIFY_NULL( Get( pExcExec), "Error in CreateExcExecutor", FALSE) pExcExec->SetGeomDB( pGseCtx->m_pGeomDB) ; pCmdParser->AddExecutor( Release( pExcExec)) ; // eventuale creazione oggetto per esecuzione funzioni di Scene if ( pGseCtx->m_pScene != nullptr) { PtrOwner pSceExec( CreateSceExecutor()) ; - if ( IsNull( pSceExec)) { - LOG_ERROR( GetLogger(), "Error in CreateSceExecutor") - return FALSE ; - } + VERIFY_NULL( Get( pSceExec), "Error in CreateSceExecutor", FALSE) pSceExec->SetScene( pGseCtx->m_pScene) ; pCmdParser->AddExecutor( Release( pSceExec)) ; } @@ -90,14 +74,11 @@ __stdcall EgtInitTscExec( int nGseCtx) BOOL __stdcall EgtTscFileExec( int nGseCtx, const wchar_t* wsFilePath) { - // verifico TscExecutor - GseContext* pGseCtx = GetGseContext( nGseCtx) ; - if ( pGseCtx == nullptr || pGseCtx->m_pTscExec == nullptr) { - LOG_ERROR( GetLogger(), "TscExecutor invalid (EgtFileExec)") - return FALSE ; - } + ICmdParser* pTscExec = GetTscExecutor( nGseCtx) ; + VERIFY_TSCEXEC( pTscExec, FALSE) + // converto nome file - string sFilePath = LPSTR( WtoA( wsFilePath)) ; + string sFilePath = wstrztoA( wsFilePath) ; // emetto info string sInfo = "Exec File = " + sFilePath ; LOG_INFO( GetLogger(), sInfo.c_str()) @@ -105,29 +86,18 @@ __stdcall EgtTscFileExec( int nGseCtx, const wchar_t* wsFilePath) // imposto il direttorio dello script string sFileDir, sFileName ; SplitLast( sFilePath, "\\", sFileDir, sFileName) ; - pGseCtx->m_pTscExec->SetDirReplace( "", sFileDir) ; + pTscExec->SetDirReplace( "", sFileDir) ; // esecuzione script - if ( pGseCtx->m_pTscExec->Run( sFilePath)) - return TRUE ; - else - return FALSE ; + return ( pTscExec->Run( sFilePath) ? TRUE : FALSE) ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtTscLineExec( int nGseCtx, const wchar_t* wsLine) { - // verifico TscExecutor - GseContext* pGseCtx = GetGseContext( nGseCtx) ; - if ( pGseCtx == nullptr || pGseCtx->m_pTscExec == nullptr) { - LOG_ERROR( GetLogger(), "TscExecutor invalid (EgtLineExec)") - return FALSE ; - } - + ICmdParser* pTscExec = GetTscExecutor( nGseCtx) ; + VERIFY_TSCEXEC( pTscExec, FALSE) // eseguo il comando - if ( pGseCtx->m_pTscExec->ExecLine( LPSTR( WtoA( wsLine)))) - return TRUE ; - else - return FALSE ; + return ( pTscExec->ExecLine( wstrztoA( wsLine)) ? TRUE : FALSE) ; } diff --git a/EgtInterface.rc b/EgtInterface.rc index ccb786e..e35264d 100644 Binary files a/EgtInterface.rc and b/EgtInterface.rc differ diff --git a/EgtInterface.vcxproj b/EgtInterface.vcxproj index d66d686..bd5c731 100644 --- a/EgtInterface.vcxproj +++ b/EgtInterface.vcxproj @@ -184,16 +184,18 @@ copy $(TargetPath) \EgtProg\Dll64 + + + - diff --git a/EgtInterface.vcxproj.filters b/EgtInterface.vcxproj.filters index 9949630..6b0c129 100644 --- a/EgtInterface.vcxproj.filters +++ b/EgtInterface.vcxproj.filters @@ -33,14 +33,14 @@ File di intestazione + + File di intestazione + File di origine - - File di origine - File di origine @@ -59,6 +59,12 @@ File di origine + + File di origine + + + File di origine + diff --git a/GseContext.cpp b/GseContext.cpp index 87473d6..b11e755 100644 --- a/GseContext.cpp +++ b/GseContext.cpp @@ -63,3 +63,31 @@ GetGseContext( int nInd) return nullptr ; return &(s_GseCtx[nInd-1]) ; } + +//---------------------------------------------------------------------------- +IGeomDB* +GetGeomDB( int nInd) +{ + if ( nInd < 1 || nInd > MAX_CTX || ! s_GseOn[nInd-1]) + return nullptr ; + return ( s_GseCtx[nInd-1].m_pGeomDB) ; +} + +//---------------------------------------------------------------------------- +IEGrScene* +GetScene( int nInd) +{ + if ( nInd < 1 || nInd > MAX_CTX || ! s_GseOn[nInd-1]) + return nullptr ; + return ( s_GseCtx[nInd-1].m_pScene) ; +} + +//---------------------------------------------------------------------------- +ICmdParser* +GetTscExecutor( int nInd) +{ + if ( nInd < 1 || nInd > MAX_CTX || ! s_GseOn[nInd-1]) + return nullptr ; + return ( s_GseCtx[nInd-1].m_pTscExec) ; +} + diff --git a/GseContext.h b/GseContext.h index 73cd661..6a314f3 100644 --- a/GseContext.h +++ b/GseContext.h @@ -57,3 +57,6 @@ int CreateGseContext( void) ; bool DeleteGseContext( int nInd) ; bool ClearAllGseContexts( void) ; GseContext* GetGseContext( int nInd) ; +IGeomDB* GetGeomDB( int nInd) ; +IEGrScene* GetScene( int nInd) ; +ICmdParser* GetTscExecutor( int nInd) ;