EgtInterface 1.6e2 :
- esecutore e lua scorporato in EgtExecutor.
This commit is contained in:
+20
-301
@@ -14,12 +14,9 @@
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "API.h"
|
||||
#include "API_Macro.h"
|
||||
#include "AuxTools.h"
|
||||
#include "/EgtDev/Include/EInAPI.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EXeExecutor.h"
|
||||
#include "/EgtDev/Include/EGnStringConverter.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
@@ -27,61 +24,35 @@ using namespace std ;
|
||||
int
|
||||
__stdcall EgtInitGeomDB( void)
|
||||
{
|
||||
// creo e recupero un contesto libero
|
||||
int nGseCtx = CreateGseContext() ;
|
||||
if ( nGseCtx == 0) {
|
||||
ResetCurrGseContext() ;
|
||||
LOG_ERROR( GetLogger(), "Error in CreateGseContext (" __FUNCTION__ ")")
|
||||
return 0 ;
|
||||
}
|
||||
GseContext* pGseCtx = GetGseContext( nGseCtx) ;
|
||||
// inizializzazioni DB geometrico
|
||||
PtrOwner<IGeomDB> 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) ;
|
||||
// rendo corrente il contesto
|
||||
SetCurrGseContext( nGseCtx) ;
|
||||
// log avvio DB geometrico
|
||||
string sLog = "GeomDB started " + ToString( nGseCtx) ;
|
||||
LOG_INFO( GetLogger(), sLog.c_str())
|
||||
|
||||
return nGseCtx ;
|
||||
return ExeInitGeomDB() ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtSetCurrentContext( int nGseCtx)
|
||||
{
|
||||
return ( SetCurrGseContext( nGseCtx) ? TRUE : FALSE) ;
|
||||
return ( ExeSetCurrentContext( nGseCtx) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtResetCurrentContext( void)
|
||||
{
|
||||
return ( ResetCurrGseContext() ? TRUE : FALSE) ;
|
||||
return ( ExeResetCurrentContext() ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtGetCurrentContext( void)
|
||||
{
|
||||
return GetIndCurrGseContext() ;
|
||||
return ExeGetCurrentContext() ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtSetDefaultMaterial( const int vCol[4])
|
||||
{
|
||||
GseContext* pGseCtx = GetCurrGseContext() ;
|
||||
VERIFY_CTX_GEOMDB( pGseCtx, FALSE)
|
||||
// imposto il materiale di default
|
||||
pGseCtx->m_colDef.Set( vCol) ;
|
||||
pGseCtx->m_pGeomDB->SetDefaultMaterial( pGseCtx->m_colDef) ;
|
||||
return TRUE ;
|
||||
return ( ExeSetDefaultMaterial( vCol) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -93,27 +64,7 @@ __stdcall EgtSetGridFrame( const double ptOrig[3], const double vX[3], const dou
|
||||
if ( ! frFrame.Set( ptOrig, vX, vY, vZ))
|
||||
return FALSE ;
|
||||
// imposto il riferimento della griglia
|
||||
return ( EgtSetGridFrame( frFrame) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
EgtSetGridFrame( const Frame3d& frFrame)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// imposto il riferimento della griglia
|
||||
bool bOk = pGeomDB->SetGridFrame( frFrame) ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtSetGridFrame({{" + ToString( frFrame.Orig()) + "},{" +
|
||||
ToString( frFrame.VersX()) + "},{" +
|
||||
ToString( frFrame.VersY()) + "},{" +
|
||||
ToString( frFrame.VersZ()) + "}})" +
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
return bOk ;
|
||||
return ( ExeSetGridFrame( frFrame) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -122,7 +73,7 @@ __stdcall EgtGetGridFrame( double ptOrig[3], double vX[3], double vY[3], double
|
||||
{
|
||||
// recupero il riferimento della griglia
|
||||
Frame3d frGrid ;
|
||||
if ( EgtGetGridFrame( GDB_ID_ROOT, frGrid)) {
|
||||
if ( ExeGetGridFrame( GDB_ID_ROOT, frGrid)) {
|
||||
// assegno i valori di ritorno
|
||||
VEC_FROM_3D( ptOrig, frGrid.Orig())
|
||||
VEC_FROM_3D( vX, frGrid.VersX())
|
||||
@@ -134,62 +85,11 @@ __stdcall EgtGetGridFrame( double ptOrig[3], double vX[3], double vY[3], double
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
EgtGetGridFrame( int nRefId, Frame3d& frFrame)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero il riferimento della griglia
|
||||
frFrame = pGeomDB->GetGridFrame() ;
|
||||
// se richiesto nel riferimento globale, esco subito
|
||||
if ( nRefId == GDB_ID_ROOT)
|
||||
return true ;
|
||||
// recupero il riferimento destinazione (nRefId può essere un gruppo o una entità)
|
||||
Frame3d frDest ;
|
||||
if ( ! pGeomDB->GetGroupGlobFrame( nRefId, frDest) &&
|
||||
! pGeomDB->GetGlobFrame( nRefId, frDest))
|
||||
return false ;
|
||||
// eseguo la trasformazione
|
||||
return frFrame.ToLoc( frDest) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
EgtGetGridVersZ( int nRefId, Vector3d& vtVersZ)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero il versore Z della griglia
|
||||
vtVersZ = pGeomDB->GetGridFrame().VersZ() ;
|
||||
// se richiesto nel riferimento globale, esco subito
|
||||
if ( nRefId == GDB_ID_ROOT)
|
||||
return true ;
|
||||
// recupero il riferimento destinazione (nRefId può essere un gruppo o una entità)
|
||||
Frame3d frDest ;
|
||||
if ( ! pGeomDB->GetGroupGlobFrame( nRefId, frDest) &&
|
||||
! pGeomDB->GetGlobFrame( nRefId, frDest))
|
||||
return false ;
|
||||
// eseguo la trasformazione
|
||||
return vtVersZ.ToLoc( frDest) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtSetCurrFilePath( const wchar_t* wsFilePath)
|
||||
{
|
||||
return ( EgtSetCurrFilePath( wstrztoA( wsFilePath)) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
EgtSetCurrFilePath( const string& sFilePath)
|
||||
{
|
||||
GseContext* pGseCtx = GetCurrGseContext() ;
|
||||
VERIFY_CTX_GEOMDB( pGseCtx, false)
|
||||
// assegno la path
|
||||
pGseCtx->m_sFilePath = sFilePath ;
|
||||
return true ;
|
||||
return ( ExeSetCurrFilePath( wstrztoA( wsFilePath)) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -199,259 +99,78 @@ __stdcall EgtGetCurrFilePath( wchar_t*& wsFilePath)
|
||||
if ( &wsFilePath == nullptr)
|
||||
return false ;
|
||||
string sFilePath ;
|
||||
if ( ! EgtGetCurrFilePath( sFilePath))
|
||||
if ( ! ExeGetCurrFilePath( sFilePath))
|
||||
return FALSE ;
|
||||
wsFilePath = _wcsdup( stringtoW( sFilePath)) ;
|
||||
return (( wsFilePath == nullptr) ? FALSE : TRUE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
EgtGetCurrFilePath( string& sFilePath)
|
||||
{
|
||||
GseContext* pGseCtx = GetCurrGseContext() ;
|
||||
VERIFY_CTX_GEOMDB( pGseCtx, false)
|
||||
// restituisco la path
|
||||
sFilePath = pGseCtx->m_sFilePath ;
|
||||
return ( ! sFilePath.empty()) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtEnableModified( void)
|
||||
{
|
||||
GseContext* pGseCtx = GetCurrGseContext() ;
|
||||
VERIFY_CTX_GEOMDB( pGseCtx, FALSE)
|
||||
// abilito possibilità di alterare il flag di modifica
|
||||
pGseCtx->m_bEnableModified = true ;
|
||||
return TRUE ;
|
||||
return ( ExeEnableModified() ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtDisableModified( void)
|
||||
{
|
||||
GseContext* pGseCtx = GetCurrGseContext() ;
|
||||
VERIFY_CTX_GEOMDB( pGseCtx, FALSE)
|
||||
// disabilito possibilità di alterare il flag di modifica
|
||||
pGseCtx->m_bEnableModified = false ;
|
||||
return TRUE ;
|
||||
return ( ExeDisableModified() ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtSetModified( void)
|
||||
{
|
||||
GseContext* pGseCtx = GetCurrGseContext() ;
|
||||
VERIFY_CTX_GEOMDB( pGseCtx, FALSE)
|
||||
// se consentito, imposto il flag
|
||||
if ( pGseCtx->m_bEnableModified)
|
||||
pGseCtx->m_bModified = true ;
|
||||
return TRUE ;
|
||||
return ( ExeSetModified() ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtResetModified( void)
|
||||
{
|
||||
GseContext* pGseCtx = GetCurrGseContext() ;
|
||||
VERIFY_CTX_GEOMDB( pGseCtx, FALSE)
|
||||
// se consentito, cancello il flag
|
||||
if ( pGseCtx->m_bEnableModified)
|
||||
pGseCtx->m_bModified = false ;
|
||||
return TRUE ;
|
||||
return ( ExeResetModified() ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtGetModified( void)
|
||||
{
|
||||
GseContext* pGseCtx = GetCurrGseContext() ;
|
||||
VERIFY_CTX_GEOMDB( pGseCtx, FALSE)
|
||||
// imposto il flag
|
||||
return ( pGseCtx->m_bModified ? TRUE : FALSE) ;
|
||||
return ( ExeGetModified() ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtNewFile( void)
|
||||
{
|
||||
GseContext* pGseCtx = GetCurrGseContext() ;
|
||||
VERIFY_CTX_GEOMDB( pGseCtx, FALSE)
|
||||
bool bOk = true ;
|
||||
// reinizializzazione (con pulizia) del DB geometrico
|
||||
bOk = bOk && pGseCtx->m_pGeomDB->Init() ;
|
||||
bOk = bOk && pGseCtx->m_pGeomDB->SetDefaultMaterial( pGseCtx->m_colDef) ;
|
||||
// aggiorno stato file corrente
|
||||
pGseCtx->m_sFilePath.clear() ;
|
||||
pGseCtx->m_bModified = false ;
|
||||
// aggiornamento gestore lavorazioni
|
||||
EgtUpdateMachMgr() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtNewFile()"
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco il risultato
|
||||
return ( bOk ? TRUE : FALSE) ;
|
||||
return ( ExeNewFile() ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtOpenFile( const wchar_t* wsFilePath)
|
||||
{
|
||||
return ( EgtOpenFile( wstrztoA( wsFilePath)) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
EgtOpenFile( const string& sFilePath)
|
||||
{
|
||||
GseContext* pGseCtx = GetCurrGseContext() ;
|
||||
VERIFY_CTX_GEOMDB( pGseCtx, false)
|
||||
bool bOk = true ;
|
||||
// reinizializzazione (con pulizia) del DB geometrico
|
||||
bOk = bOk && pGseCtx->m_pGeomDB->Init() ;
|
||||
bOk = bOk && pGseCtx->m_pGeomDB->SetDefaultMaterial( pGseCtx->m_colDef) ;
|
||||
// carico il file
|
||||
bOk = bOk && pGseCtx->m_pGeomDB->Load( sFilePath) ;
|
||||
// aggiorno stato file corrente
|
||||
pGseCtx->m_sFilePath = sFilePath ;
|
||||
pGseCtx->m_bModified = false ;
|
||||
// aggiornamento gestore lavorazioni
|
||||
EgtUpdateMachMgr() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLuaPath = sFilePath ;
|
||||
ReplaceString( sLuaPath, "\\", "\\\\") ;
|
||||
string sLua = "EgtOpenFile('" + sLuaPath + "')" +
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco il risultato
|
||||
return bOk ;
|
||||
return ( ExeOpenFile( wstrztoA( wsFilePath)) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtInsertFile( const wchar_t* wsFilePath)
|
||||
{
|
||||
return ( EgtInsertFile( wstrztoA( wsFilePath)) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
EgtInsertFile( const string& sFilePath)
|
||||
{
|
||||
GseContext* pGseCtx = GetCurrGseContext() ;
|
||||
VERIFY_CTX_GEOMDB( pGseCtx, false)
|
||||
IGeomDB* pGeomDB = pGseCtx->m_pGeomDB ;
|
||||
// creo gruppo temporaneo di parcheggio
|
||||
int nGrp = pGeomDB->InsertGroup( GDB_ID_NULL, GDB_ID_ROOT, GDB_FIRST_SON, GLOB_FRM) ;
|
||||
bool bOk = ( nGrp != GDB_ID_NULL) ;
|
||||
bOk = bOk && pGeomDB->SetLevel( nGrp, GDB_LV_TEMP) ;
|
||||
// carico il file
|
||||
bOk = bOk && pGeomDB->Load( sFilePath, nGrp) ;
|
||||
// sposto i pezzi sotto la radice
|
||||
int nId = pGeomDB->GetFirstGroupInGroup( nGrp) ;
|
||||
while ( bOk && nId != GDB_ID_NULL) {
|
||||
// prossimo gruppo
|
||||
int nNextId = pGeomDB->GetNextGroup( nId) ;
|
||||
// se il gruppo corrente è un pezzo, lo sposto
|
||||
int nLevel ;
|
||||
if ( ! pGeomDB->GetLevel( nId, nLevel) || nLevel == GDB_LV_USER)
|
||||
bOk = pGeomDB->Relocate( nId, GDB_ID_ROOT, GDB_LAST_SON) ;
|
||||
// passo al prossimo
|
||||
nId = nNextId ;
|
||||
}
|
||||
// sistemo le lavorazioni
|
||||
bOk = bOk && EgtInsertMachMgr( nGrp) ;
|
||||
// cancello il gruppo temporaneo
|
||||
pGeomDB->Erase( nGrp) ;
|
||||
// aggiorno stato file corrente
|
||||
pGseCtx->m_bModified = true ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLuaPath = sFilePath ;
|
||||
ReplaceString( sLuaPath, "\\", "\\\\") ;
|
||||
string sLua = "EgtInsertFile('" + sLuaPath + "')" +
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco il risultato
|
||||
return bOk ;
|
||||
return ( ExeInsertFile( wstrztoA( wsFilePath)) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtSaveFile( const wchar_t* wsFilePath, int nFlag)
|
||||
{
|
||||
return ( EgtSaveFile( wstrztoA( wsFilePath), nFlag) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
EgtSaveFile( const string& sFilePath, int nFlag)
|
||||
{
|
||||
GseContext* pGseCtx = GetCurrGseContext() ;
|
||||
VERIFY_CTX_GEOMDB( pGseCtx, false)
|
||||
// se ero in CAM, esco
|
||||
int nCurrMachGroup = EgtGetCurrMachGroup() ;
|
||||
EgtResetCurrMachGroup() ;
|
||||
// salvo il file
|
||||
bool bOk = pGseCtx->m_pGeomDB->Save( GDB_ID_ROOT, sFilePath, nFlag) ;
|
||||
// eventuale ripristino precedente CAM
|
||||
if ( nCurrMachGroup != GDB_ID_NULL)
|
||||
EgtSetCurrMachGroup( nCurrMachGroup) ;
|
||||
// aggiorno stato file corrente
|
||||
pGseCtx->m_sFilePath = sFilePath ;
|
||||
if ( bOk)
|
||||
pGseCtx->m_bModified = false ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLuaPath = sFilePath ;
|
||||
ReplaceString( sLuaPath, "\\", "\\\\") ;
|
||||
string sLua = "EgtSaveFile('" + sLuaPath + "'," +
|
||||
NgeTypeToString( nFlag) + ")" +
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco il risultato
|
||||
return bOk ;
|
||||
return ( ExeSaveFile( wstrztoA( wsFilePath), nFlag) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtSaveObjToFile( int nId, const wchar_t* wsFilePath, int nFlag)
|
||||
{
|
||||
return ( EgtSaveObjToFile( nId, wstrztoA( wsFilePath), nFlag) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
EgtSaveObjToFile( int nId, const string& sFilePath, int nFlag)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// se ero in CAM, esco
|
||||
int nCurrMachGroup = EgtGetCurrMachGroup() ;
|
||||
EgtResetCurrMachGroup() ;
|
||||
// copio l'oggetto nel file
|
||||
bool bOk = pGeomDB->Save( nId, sFilePath, nFlag) ;
|
||||
// ripristino eventuale precedente CAM
|
||||
if ( nCurrMachGroup != GDB_ID_NULL)
|
||||
EgtSetCurrMachGroup( nCurrMachGroup) ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLuaPath = sFilePath ;
|
||||
ReplaceString( sLuaPath, "\\", "\\\\") ;
|
||||
string sLua = "EgtSaveObjToFile('" + sLuaPath + "'," +
|
||||
ToString( nId) + "," +
|
||||
NgeTypeToString( nFlag) + ")" +
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco il risultato
|
||||
return bOk ;
|
||||
return ( ExeSaveObjToFile( nId, wstrztoA( wsFilePath), nFlag) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user