EgtInterface 1.6e2 :
- esecutore e lua scorporato in EgtExecutor.
This commit is contained in:
+7
-195
@@ -14,17 +14,9 @@
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "API.h"
|
||||
#include "API_Macro.h"
|
||||
#include "DllExchange.h"
|
||||
#include "/EgtDev/Include/EInAPI.h"
|
||||
#include "/EgtDev/Include/EExImportStl.h"
|
||||
#include "/EgtDev/Include/EExImportDxf.h"
|
||||
#include "/EgtDev/Include/EExImportCnc.h"
|
||||
#include "/EgtDev/Include/EExExportStl.h"
|
||||
#include "/EgtDev/Include/EExExportDxf.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
#include "/EgtDev/Include/EXeExecutor.h"
|
||||
#include "/EgtDev/Include/EGnStringConverter.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
@@ -32,220 +24,40 @@ using namespace std ;
|
||||
int
|
||||
__stdcall EgtGetFileType( const wchar_t* wsFilePath)
|
||||
{
|
||||
return EgtGetFileType( wstrztoA( wsFilePath)) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
EgtGetFileType( const string& sFilePath)
|
||||
{
|
||||
// divido in nome e direttorio
|
||||
string sFileDir, sFileName ;
|
||||
SplitLast( sFilePath, "\\", sFileDir, sFileName) ;
|
||||
|
||||
// recupero l'estensione
|
||||
string sFileTitle, sFileExt ;
|
||||
SplitLast( sFileName, ".", sFileTitle, sFileExt) ;
|
||||
ToUpper( sFileExt) ;
|
||||
|
||||
if ( sFileExt == "NGE")
|
||||
return 1 ;
|
||||
else if ( sFileExt == "NFE")
|
||||
return 2 ;
|
||||
else if ( sFileExt == "DXF")
|
||||
return 11 ;
|
||||
else if ( sFileExt == "STL")
|
||||
return 12 ;
|
||||
else if ( sFileExt == "CNC")
|
||||
return 13 ;
|
||||
else if ( sFileExt == "TSC")
|
||||
return 101 ;
|
||||
else if ( sFileExt == "LUA")
|
||||
return 102 ;
|
||||
else {
|
||||
// emetto info
|
||||
string sInfo = "File type (" + sFileExt + ") not recognized" ;
|
||||
LOG_INFO( GetLogger(), sInfo.c_str())
|
||||
return 0 ;
|
||||
}
|
||||
return ExeGetFileType( wstrztoA( wsFilePath)) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtImportDxf( const wchar_t* wsFilePath, double dScaleFactor)
|
||||
{
|
||||
return ( EgtImportDxf( wstrztoA( wsFilePath), dScaleFactor) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
EgtImportDxf( const string& sFilePath, double dScaleFactor)
|
||||
{
|
||||
GseContext* pGseCtx = GetCurrGseContext() ;
|
||||
VERIFY_CTX_GEOMDB( pGseCtx, false)
|
||||
bool bOk = true ;
|
||||
// importo il file DXF
|
||||
// aggiungo un gruppo pezzo
|
||||
int nPartId = pGseCtx->m_pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ;
|
||||
// preparo l'importatore
|
||||
PtrOwner<IImportDxf> pImpDxf( MyCreateImportDxf()) ;
|
||||
bOk = bOk && ! IsNull( pImpDxf) ;
|
||||
// eseguo l'importazione
|
||||
bOk = bOk && pImpDxf->Import( sFilePath, pGseCtx->m_pGeomDB, nPartId, dScaleFactor) ;
|
||||
// aggiorno stato file corrente
|
||||
pGseCtx->m_sFilePath = sFilePath ;
|
||||
pGseCtx->m_bModified = true ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLuaPath = sFilePath ;
|
||||
ReplaceString( sLuaPath, "\\", "\\\\") ;
|
||||
string sLua = "EgtImportDxf('" + sLuaPath + "'," +
|
||||
ToString( dScaleFactor) + ")" +
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco il risultato
|
||||
return bOk ;
|
||||
return ( ExeImportDxf( wstrztoA( wsFilePath), dScaleFactor) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtImportStl( const wchar_t* wsFilePath, double dScaleFactor)
|
||||
{
|
||||
return ( EgtImportStl( wstrztoA( wsFilePath), dScaleFactor) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
EgtImportStl( const string& sFilePath, double dScaleFactor)
|
||||
{
|
||||
GseContext* pGseCtx = GetCurrGseContext() ;
|
||||
VERIFY_CTX_GEOMDB( pGseCtx, false)
|
||||
bool bOk = true ;
|
||||
// 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()) ;
|
||||
// preparo l'importatore
|
||||
PtrOwner<IImportStl> pImpStl( MyCreateImportStl()) ;
|
||||
bOk = bOk && ! IsNull( pImpStl) ;
|
||||
// eseguo l'importazione
|
||||
bOk = bOk && pImpStl->Import( sFilePath, pGseCtx->m_pGeomDB, nLayerId, dScaleFactor) ;
|
||||
// aggiorno stato file corrente
|
||||
pGseCtx->m_sFilePath = sFilePath ;
|
||||
pGseCtx->m_bModified = true ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLuaPath = sFilePath ;
|
||||
ReplaceString( sLuaPath, "\\", "\\\\") ;
|
||||
string sLua = "EgtImportStl('" + sLuaPath + "'," +
|
||||
ToString( dScaleFactor) + ")" +
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco il risultato
|
||||
return bOk ;
|
||||
return ( ExeImportStl( wstrztoA( wsFilePath), dScaleFactor) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtImportCnc( const wchar_t* wsFilePath)
|
||||
{
|
||||
return ( EgtImportCnc( wstrztoA( wsFilePath)) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
EgtImportCnc( const string& sFilePath)
|
||||
{
|
||||
GseContext* pGseCtx = GetCurrGseContext() ;
|
||||
VERIFY_CTX_GEOMDB( pGseCtx, false)
|
||||
bool bOk = true ;
|
||||
// importo il file CNC
|
||||
// aggiungo un gruppo pezzo
|
||||
int nPartId = pGseCtx->m_pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ;
|
||||
// preparo l'importatore
|
||||
PtrOwner<IImportCnc> pImpCnc( MyCreateImportCnc()) ;
|
||||
bOk = bOk && ! IsNull( pImpCnc) ;
|
||||
// eseguo l'importazione
|
||||
bOk = bOk && pImpCnc->Import( sFilePath, pGseCtx->m_pGeomDB, nPartId) ;
|
||||
// aggiorno stato file corrente
|
||||
pGseCtx->m_sFilePath = sFilePath ;
|
||||
pGseCtx->m_bModified = true ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLuaPath = sFilePath ;
|
||||
ReplaceString( sLuaPath, "\\", "\\\\") ;
|
||||
string sLua = "EgtImportCnc('" + sLuaPath + "')" +
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco il risultato
|
||||
return bOk ;
|
||||
return ( ExeImportCnc( wstrztoA( wsFilePath)) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtExportDxf( int nId, const wchar_t* wsFilePath)
|
||||
{
|
||||
return ( EgtExportDxf( nId, wstrztoA( wsFilePath)) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
EgtExportDxf( int nId, const string& sFilePath)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
bool bOk = true ;
|
||||
// esporto il file DXF
|
||||
// preparo l'esportatore
|
||||
PtrOwner<IExportDxf> pExpDxf( MyCreateExportDxf()) ;
|
||||
bOk = bOk && ! IsNull( pExpDxf) ;
|
||||
// eseguo l'esportazione
|
||||
bOk = bOk && pExpDxf->Export( pGeomDB, nId, sFilePath) ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLuaPath = sFilePath ;
|
||||
ReplaceString( sLuaPath, "\\", "\\\\") ;
|
||||
string sLua = "EgtExportDxf(" + ToString( nId) + ",'" +
|
||||
sLuaPath + "')" +
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco il risultato
|
||||
return bOk ;
|
||||
return ( ExeExportDxf( nId, wstrztoA( wsFilePath)) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtExportStl( int nId, const wchar_t* wsFilePath)
|
||||
{
|
||||
return ( EgtExportStl( nId, wstrztoA( wsFilePath)) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
EgtExportStl( int nId, const string& sFilePath)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
bool bOk = true ;
|
||||
// esporto il file STL
|
||||
// preparo l'esportatore
|
||||
PtrOwner<IExportStl> pExpStl( MyCreateExportStl()) ;
|
||||
bOk = bOk && ! IsNull( pExpStl) ;
|
||||
// eseguo l'esportazione
|
||||
bOk = bOk && pExpStl->Export( pGeomDB, nId, sFilePath) ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLuaPath = sFilePath ;
|
||||
ReplaceString( sLuaPath, "\\", "\\\\") ;
|
||||
string sLua = "EgtExportStl(" + ToString( nId) + ",'" +
|
||||
sLuaPath + "')" +
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco il risultato
|
||||
return bOk ;
|
||||
return ( ExeExportStl( nId, wstrztoA( wsFilePath)) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user