EgtExecutor 1.6h5 :

- corretta trasformazioni stringhe in stringhe Lua con '
- aggiunta gestione import BTL.
This commit is contained in:
Dario Sassi
2015-09-01 07:29:08 +00:00
parent 9811b5a249
commit fbe1fa4757
11 changed files with 113 additions and 76 deletions
+10
View File
@@ -22,6 +22,16 @@
using namespace std ;
//----------------------------------------------------------------------------
string
StringToLuaString( const string& sText)
{
string sLuaText = sText ;
ReplaceString( sLuaText, "\\", "\\\\") ;
ReplaceString( sLuaText, "'", "\\'") ;
return sLuaText ;
}
//----------------------------------------------------------------------------
const string
IdToString( int nId)
+2
View File
@@ -17,6 +17,8 @@
class IGeomDB ;
//----------------------------------------------------------------------------
// Sistemazione caratteri speciali per stringhe da scrivere in programmi Lua
std::string StringToLuaString( const std::string& sText) ;
// Id con gestione delle relative costanti
const std::string IdToString( int nId) ;
// Lista di Id completa (parametro per lua)
+21 -5
View File
@@ -36,8 +36,9 @@ using namespace std ;
static const char* EEX_SETEEXLOGGER = "SetEExLogger" ;
static const char* EEX_GETEEXVERSION = "GetEExVersion" ;
static const char* EEX_SETEEXKEY = "SetEExKey" ;
static const char* EEX_CREATEIMPORTCSF = "CreateImportCsf" ;
static const char* EEX_CREATEIMPORTBTL = "CreateImportBtl" ;
static const char* EEX_CREATEIMPORTCNC = "CreateImportCnc" ;
static const char* EEX_CREATEIMPORTCSF = "CreateImportCsf" ;
static const char* EEX_CREATEIMPORTDXF = "CreateImportDxf" ;
static const char* EEX_CREATEIMPORTSTL = "CreateImportStl" ;
static const char* EEX_CREATEEXPORTDXF = "CreateExportDxf" ;
@@ -137,15 +138,15 @@ MySetEExKey( const string& sKey)
}
//-----------------------------------------------------------------------------
IImportCsf*
MyCreateImportCsf( void)
IImportBtl*
MyCreateImportBtl( void)
{
// verifico caricamento libreria EgtExchange
if ( s_hEEx == nullptr)
return nullptr ;
// recupero funzione creazione oggetto
typedef IImportCsf* (* PF_CreateImportCsf) ( void) ;
PF_CreateImportCsf pFun = (PF_CreateImportCsf)GetProcAddress( s_hEEx, EEX_CREATEIMPORTCSF) ;
typedef IImportBtl* (* PF_CreateImportBtl) ( void) ;
PF_CreateImportBtl pFun = (PF_CreateImportBtl)GetProcAddress( s_hEEx, EEX_CREATEIMPORTBTL) ;
if ( pFun == nullptr)
return nullptr ;
return pFun() ;
@@ -166,6 +167,21 @@ MyCreateImportCnc( void)
return pFun() ;
}
//-----------------------------------------------------------------------------
IImportCsf*
MyCreateImportCsf( void)
{
// verifico caricamento libreria EgtExchange
if ( s_hEEx == nullptr)
return nullptr ;
// recupero funzione creazione oggetto
typedef IImportCsf* (* PF_CreateImportCsf) ( void) ;
PF_CreateImportCsf pFun = (PF_CreateImportCsf)GetProcAddress( s_hEEx, EEX_CREATEIMPORTCSF) ;
if ( pFun == nullptr)
return nullptr ;
return pFun() ;
}
//-----------------------------------------------------------------------------
IImportDxf*
MyCreateImportDxf( void)
+3 -1
View File
@@ -16,8 +16,9 @@
#include <string>
class ILogger ;
class IImportCsf ;
class IImportBtl ;
class IImportCnc ;
class IImportCsf ;
class IImportDxf ;
class IImportStl ;
class IExportDxf ;
@@ -31,6 +32,7 @@ bool IsLoadedExchangeDll( void) ;
void MySetEExLogger( ILogger* pLogger) ;
void MySetEExKey( const std::string& sKey) ;
const char* MyGetEExVersion( void) ;
IImportBtl* MyCreateImportBtl( void) ;
IImportCnc* MyCreateImportCnc( void) ;
IImportCsf* MyCreateImportCsf( void) ;
IImportDxf* MyCreateImportDxf( void) ;
+46 -27
View File
@@ -15,12 +15,15 @@
#include "stdafx.h"
#include "EXE.h"
#include "EXE_Macro.h"
#include "AuxTools.h"
#include "DllExchange.h"
#include "/EgtDev/Include/EXeExecutor.h"
#include "/EgtDev/Include/EXeConst.h"
#include "/EgtDev/Include/EExImportStl.h"
#include "/EgtDev/Include/EExImportDxf.h"
#include "/EgtDev/Include/EExImportCnc.h"
#include "/EgtDev/Include/EExImportCsf.h"
#include "/EgtDev/Include/EExImportBtl.h"
#include "/EgtDev/Include/EExExportStl.h"
#include "/EgtDev/Include/EExExportDxf.h"
#include "/EgtDev/Include/EGnStringUtils.h"
@@ -43,26 +46,28 @@ ExeGetFileType( const string& sFilePath)
ToUpper( sFileExt) ;
if ( sFileExt == "NGE")
return 1 ;
return FT_NGE ;
else if ( sFileExt == "NFE")
return 2 ;
return FT_NFE ;
else if ( sFileExt == "DXF")
return 11 ;
return FT_DXF ;
else if ( sFileExt == "STL")
return 12 ;
return FT_STL ;
else if ( sFileExt == "CNC")
return 13 ;
return FT_CNC ;
else if ( sFileExt == "HED" || sFileExt == "ENT" || sFileExt == "ENS")
return 14 ;
return FT_CSF ;
else if ( sFileExt == "BTL")
return FT_BTL ;
else if ( sFileExt == "TSC")
return 101 ;
return FT_TSC ;
else if ( sFileExt == "LUA")
return 102 ;
return FT_LUA ;
else {
// emetto info
string sInfo = "File type (" + sFileExt + ") not recognized" ;
LOG_INFO( GetLogger(), sInfo.c_str())
return 0 ;
return FT_NULL ;
}
}
@@ -86,9 +91,7 @@ ExeImportDxf( const string& sFilePath, double dScaleFactor)
pGseCtx->m_bModified = true ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLuaPath = sFilePath ;
ReplaceString( sLuaPath, "\\", "\\\\") ;
string sLua = "EgtImportDxf('" + sLuaPath + "'," +
string sLua = "EgtImportDxf('" + StringToLuaString( sFilePath) + "'," +
ToString( dScaleFactor) + ")" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
@@ -118,9 +121,7 @@ ExeImportStl( const string& sFilePath, double dScaleFactor)
pGseCtx->m_bModified = true ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLuaPath = sFilePath ;
ReplaceString( sLuaPath, "\\", "\\\\") ;
string sLua = "EgtImportStl('" + sLuaPath + "'," +
string sLua = "EgtImportStl('" + StringToLuaString( sFilePath) + "'," +
ToString( dScaleFactor) + ")" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
@@ -149,9 +150,7 @@ ExeImportCnc( const string& sFilePath)
pGseCtx->m_bModified = true ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLuaPath = sFilePath ;
ReplaceString( sLuaPath, "\\", "\\\\") ;
string sLua = "EgtImportCnc('" + sLuaPath + "')" +
string sLua = "EgtImportCnc('" + StringToLuaString( sFilePath) + "')" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
@@ -177,9 +176,33 @@ ExeImportCsf( const string& sFilePath)
pGseCtx->m_bModified = true ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLuaPath = sFilePath ;
ReplaceString( sLuaPath, "\\", "\\\\") ;
string sLua = "EgtImportCsf('" + sLuaPath + "')" +
string sLua = "EgtImportCsf('" + StringToLuaString( sFilePath) + "')" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco il risultato
return bOk ;
}
//-----------------------------------------------------------------------------
bool
ExeImportBtl( const string& sFilePath)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_GEOMDB( pGseCtx, false)
bool bOk = true ;
// importo il file BTL
// preparo l'importatore
PtrOwner<IImportBtl> pImpBtl( MyCreateImportBtl()) ;
bOk = bOk && ! IsNull( pImpBtl) ;
// eseguo l'importazione (direttamente nella radice)
bOk = bOk && pImpBtl->Import( sFilePath, pGseCtx->m_pGeomDB) ;
// aggiorno stato file corrente
pGseCtx->m_sFilePath = sFilePath ;
pGseCtx->m_bModified = true ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtImportBtl('" + StringToLuaString( sFilePath) + "')" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
@@ -202,10 +225,8 @@ ExeExportDxf( int nId, const string& sFilePath)
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 + "')" +
StringToLuaString( sFilePath) + "')" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
@@ -228,10 +249,8 @@ ExeExportStl( int nId, const string& sFilePath)
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 + "')" +
StringToLuaString( sFilePath) + "')" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
+5 -15
View File
@@ -214,11 +214,9 @@ ExeCreateText( int nParentId, const Point3d& ptP,
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLuaText = sText ;
ReplaceString( sLuaText, "'", "\\'") ;
string sLua = "EgtText(" + IdToString( nParentId) + ",{" +
ToString( ptP) + "},'" +
sLuaText + "'," +
StringToLuaString( sText) + "'," +
ToString( dH) + "," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
@@ -253,15 +251,11 @@ ExeCreateTextEx( int nParentId, const Point3d& ptP, double dAngRotDeg,
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLuaText = sText ;
ReplaceString( sLuaText, "'", "\\'") ;
string sLuaFont = sFont ;
ReplaceString( sLuaFont, "'", "\\'") ;
string sLua = "EgtTextEx(" + IdToString( nParentId) + ",{" +
ToString( ptP) + "}," +
ToString( dAngRotDeg) + ",'" +
sLuaText + "','" +
sLuaFont + "'," +
StringToLuaString( sText) + "','" +
StringToLuaString( sFont) + "'," +
( bItalic ? "'I'" : "'S'") + "," +
ToString( dH) + "," +
RefTypeToString( nRefType) + ")" +
@@ -298,15 +292,11 @@ ExeCreateTextAdv( int nParentId, const Point3d& ptP, double dAngRotDeg,
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLuaText = sText ;
ReplaceString( sLuaText, "'", "\\'") ;
string sLuaFont = sFont ;
ReplaceString( sLuaFont, "'", "\\'") ;
string sLua = "EgtTextAdv(" + IdToString( nParentId) + ",{" +
ToString( ptP) + "}," +
ToString( dAngRotDeg) + ",'" +
sLuaText + "','" +
sLuaFont + "'," +
StringToLuaString( sText) + "','" +
StringToLuaString( sFont) + "'," +
ToString( nW) + "," +
( bItalic ? "'I'" : "'S'") + "," +
ToString( dH) + "," +
+4 -12
View File
@@ -402,10 +402,8 @@ ExeSetName( int nId, const string& sName)
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLuaName = sName ;
ReplaceString( sLuaName, "'", "\\'") ;
string sLua = "EgtSetName(" + ToString( nId) + ",'" +
sLuaName + "')" +
StringToLuaString( sName) + "')" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
@@ -463,13 +461,9 @@ ExeSetInfo( int nId, const string& sKey, const string& sInfo)
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLuaKey = sKey ;
ReplaceString( sLuaKey, "'", "\\'") ;
string sLuaInfo = sInfo ;
ReplaceString( sLuaInfo, "'", "\\'") ;
string sLua = "EgtSetInfo(" + ToString( nId) + ",'" +
sLuaKey + "','" +
sLuaInfo + "')" +
StringToLuaString( sKey) + "','" +
StringToLuaString( sInfo) + "')" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
@@ -530,10 +524,8 @@ ExeRemoveInfo( int nId, const string& sKey)
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLuaKey = sKey ;
ReplaceString( sLuaKey, "'", "\\'") ;
string sLua = "EgtRemoveInfo(" + ToString( nId) + ",'" +
sLuaKey + "')" +
StringToLuaString( sKey) + "')" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
+4 -12
View File
@@ -281,9 +281,7 @@ ExeOpenFile( const string& sFilePath)
ExeUpdateMachMgr() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLuaPath = sFilePath ;
ReplaceString( sLuaPath, "\\", "\\\\") ;
string sLua = "EgtOpenFile('" + sLuaPath + "')" +
string sLua = "EgtOpenFile('" + StringToLuaString( sFilePath) + "')" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
@@ -324,9 +322,7 @@ ExeInsertFile( const string& sFilePath)
pGseCtx->m_bModified = true ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLuaPath = sFilePath ;
ReplaceString( sLuaPath, "\\", "\\\\") ;
string sLua = "EgtInsertFile('" + sLuaPath + "')" +
string sLua = "EgtInsertFile('" + StringToLuaString( sFilePath) + "')" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
@@ -354,9 +350,7 @@ ExeSaveFile( const string& sFilePath, int nFlag)
pGseCtx->m_bModified = false ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLuaPath = sFilePath ;
ReplaceString( sLuaPath, "\\", "\\\\") ;
string sLua = "EgtSaveFile('" + sLuaPath + "'," +
string sLua = "EgtSaveFile('" + StringToLuaString( sFilePath) + "'," +
NgeTypeToString( nFlag) + ")" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
@@ -381,9 +375,7 @@ ExeSaveObjToFile( int nId, const string& sFilePath, int nFlag)
ExeSetCurrMachGroup( nCurrMachGroup) ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLuaPath = sFilePath ;
ReplaceString( sLuaPath, "\\", "\\\\") ;
string sLua = "EgtSaveObjToFile('" + sLuaPath + "'," +
string sLua = "EgtSaveObjToFile('" + StringToLuaString( sFilePath) + "'," +
ToString( nId) + "," +
NgeTypeToString( nFlag) + ")" +
" -- Ok=" + ToString( bOk) ;
+2 -4
View File
@@ -15,6 +15,7 @@
#include "stdafx.h"
#include "EXE.h"
#include "LUA_Base.h"
#include "AuxTools.h"
#include "/EgtDev/Include/EXeExecutor.h"
#include "/EgtDev/Include/EGnStringUtils.h"
#include "/EgtDev/Include/EgtStringConverter.h"
@@ -204,10 +205,7 @@ ExeLuaExecFile( const string& sFilePath)
ExeEnableCommandLogger() ;
// se richiesto, salvo il comando Lua
if ( IsCmdLog()) {
string sLuaPath = sFilePath ;
ReplaceString( sLuaPath, "\\", "\\\\") ;
ReplaceString( sLuaPath, "'", "\\'") ;
string sLua = "dofile('" + sLuaPath + "')" +
string sLua = "dofile('" + StringToLuaString( sFilePath) + "')" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
BIN
View File
Binary file not shown.
+16
View File
@@ -85,6 +85,21 @@ LuaImportCsf( lua_State* L)
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaImportBtl( lua_State* L)
{
// 1 parametro : path del file da importare
string sFilePath ;
LuaCheckParam( L, 1, sFilePath)
LuaClearStack( L) ;
// apro il file
bool bOk = ExeImportBtl( sFilePath) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaExportDxf( lua_State* L)
@@ -128,6 +143,7 @@ LuaInstallExchange( LuaMgr& luaMgr)
bOk = bOk && luaMgr.RegisterFunction( "EgtImportStl", LuaImportStl) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtImportCnc", LuaImportCnc) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtImportCsf", LuaImportCsf) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtImportBtl", LuaImportBtl) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtExportDxf", LuaExportDxf) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtExportStl", LuaExportStl) ;
return bOk ;