EgtInterface 1.5i2 :

- estensione e razionalizzazione della interfaccia.
This commit is contained in:
Dario Sassi
2014-09-04 12:33:41 +00:00
parent 0e4a7397e8
commit 71254e1c04
12 changed files with 637 additions and 227 deletions
+28 -86
View File
@@ -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<IGeomDB> 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<IImportDxf> 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<IImportStl> 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<IExportDxf> 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<IExportStl> 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) ;
}