EgtInterface 1.6a6 :

- sistemate funzioni su Project (New, Open, Insert, Save, SaveAs, Import, Export) e Exec.
This commit is contained in:
Dario Sassi
2015-01-28 11:58:50 +00:00
parent 1bea531b4f
commit f039e22297
8 changed files with 169 additions and 31 deletions
+1 -1
View File
@@ -31,7 +31,7 @@ bool EgtSetGridFrame( const Frame3d& frFrame) ;
bool EgtGetGridFrame( int nRefId, Frame3d& frFrame) ;
bool EgtGetGridVersZ( int nRefId, Vector3d& vtVersZ) ;
bool EgtOpenFile( const std::string& sFilePath) ;
bool EgtImportFile( const std::string& sFilePath) ;
bool EgtInsertFile( const std::string& sFilePath) ;
bool EgtSaveFile( const std::string& sFilePath, int nFlag) ;
//--------------------------- GeomDBCreate -----------------------------------
+67 -10
View File
@@ -82,14 +82,25 @@ EgtImportDxf( const string& sFilePath)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
bool bOk = true ;
// importo il file DXF
// aggiungo un gruppo pezzo
int nPartId = pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ;
// preparo l'importatore
PtrOwner<IImportDxf> pImpDxf( CreateImportDxf()) ;
VERIFY_NULL( Get( pImpDxf), "Error in CreateImportDxf", false)
bOk = bOk && ! IsNull( pImpDxf) ;
// eseguo l'importazione
return pImpDxf->Import( sFilePath, pGeomDB, nPartId) ;
bOk = bOk && pImpDxf->Import( sFilePath, pGeomDB, nPartId) ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLuaPath = sFilePath ;
ReplaceString( sLuaPath, "\\", "\\\\") ;
string sLua = "EgtImportDxf('" + sLuaPath + "')" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco il risultato
return bOk ;
}
//-----------------------------------------------------------------------------
@@ -105,15 +116,26 @@ EgtImportStl( const string& sFilePath)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
bool bOk = true ;
// importo il file STL
// aggiungo un gruppo pezzo e un gruppo layer
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()) ;
VERIFY_NULL( Get( pImpStl), "Error in CreateImportStl", false)
bOk = bOk && ! IsNull( pImpStl) ;
// eseguo l'importazione
return pImpStl->Import( sFilePath, pGeomDB, nLayerId) ;
bOk = bOk && pImpStl->Import( sFilePath, pGeomDB, nLayerId) ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLuaPath = sFilePath ;
ReplaceString( sLuaPath, "\\", "\\\\") ;
string sLua = "EgtImportStl('" + sLuaPath + "')" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco il risultato
return bOk ;
}
//-----------------------------------------------------------------------------
@@ -129,14 +151,25 @@ EgtImportCnc( const string& sFilePath)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
bool bOk = true ;
// importo il file CNC
// aggiungo un gruppo pezzo
int nPartId = pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ;
// preparo l'importatore
PtrOwner<IImportCnc> pImpCnc( CreateImportCnc()) ;
VERIFY_NULL( Get( pImpCnc), "Error in CreateImportCnc", false)
bOk = bOk && ! IsNull( pImpCnc) ;
// eseguo l'importazione
return pImpCnc->Import( sFilePath, pGeomDB, nPartId) ;
bOk = bOk && pImpCnc->Import( sFilePath, pGeomDB, nPartId) ;
// 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 ;
}
//-----------------------------------------------------------------------------
@@ -152,12 +185,24 @@ 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( CreateExportDxf()) ;
VERIFY_NULL( Get( pExpDxf), "Error in CreateExportDxf", false)
bOk = bOk && ! IsNull( pExpDxf) ;
// eseguo l'esportazione
return pExpDxf->Export( pGeomDB, nId, 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 + "')" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco il risultato
return bOk ;
}
//-----------------------------------------------------------------------------
@@ -173,10 +218,22 @@ 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( CreateExportStl()) ;
VERIFY_NULL( Get( pExpStl), "Error in CreateExportStl", false)
bOk = bOk && ! IsNull( pExpStl) ;
// eseguo l'esportazione
return pExpStl->Export( pGeomDB, nId, 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 + "')" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco il risultato
return bOk ;
}
+56 -11
View File
@@ -15,6 +15,7 @@
#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/EGnStringConverter.h"
@@ -179,10 +180,18 @@ __stdcall EgtNewFile( void)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_GEOMDB( pGseCtx, FALSE)
bool bOk = true ;
// reinizializzazione (con pulizia) del DB geometrico
pGseCtx->m_pGeomDB->Init() ;
pGseCtx->m_pGeomDB->SetDefaultMaterial( pGseCtx->m_colDef) ;
return TRUE ;
bOk = bOk && pGseCtx->m_pGeomDB->Init() ;
bOk = bOk && pGseCtx->m_pGeomDB->SetDefaultMaterial( pGseCtx->m_colDef) ;
// 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) ;
}
//-----------------------------------------------------------------------------
@@ -196,26 +205,51 @@ __stdcall EgtOpenFile( const wchar_t* wsFilePath)
bool
EgtOpenFile( const string& sFilePath)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_GEOMDB( pGseCtx, false)
bool bOk = true ;
// reinizializzazione (con pulizia) del DB geometrico
if ( ! EgtNewFile())
return false ;
bOk = bOk && pGseCtx->m_pGeomDB->Init() ;
bOk = bOk && pGseCtx->m_pGeomDB->SetDefaultMaterial( pGseCtx->m_colDef) ;
// carico il file
return GetCurrGeomDB()->Load( sFilePath) ;
bOk = bOk && GetCurrGeomDB()->Load( sFilePath) ;
// 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 ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtImportFile( const wchar_t* wsFilePath)
__stdcall EgtInsertFile( const wchar_t* wsFilePath)
{
return ( EgtImportFile( wstrztoA( wsFilePath)) ? TRUE : FALSE) ;
return ( EgtInsertFile( wstrztoA( wsFilePath)) ? TRUE : FALSE) ;
}
//-----------------------------------------------------------------------------
bool
EgtImportFile( const string& sFilePath)
EgtInsertFile( const string& sFilePath)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
// carico il file
return GetCurrGeomDB()->Load( sFilePath) ;
bool bOk = pGeomDB->Load( sFilePath) ;
// 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 ;
}
//-----------------------------------------------------------------------------
@@ -232,5 +266,16 @@ EgtSaveFile( const string& sFilePath, int nFlag)
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
// salvo il file
return pGeomDB->Save( sFilePath, nFlag) ;
bool bOk = pGeomDB->Save( sFilePath, nFlag) ;
// 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 ;
}
+9 -1
View File
@@ -80,11 +80,19 @@ __stdcall EgtLuaExecFile( const wchar_t* wsFilePath)
// emetto info
string sInfo = "Exec File = " + sFilePath ;
LOG_INFO( GetLogger(), sInfo.c_str())
// disabilito il log dei comandi
bool bPrevCmdLog = IsCmdLog() ;
EgtDisableCommandLogger() ;
// esecuzione script
bool bOk = LuaExecFile( sFilePath) ;
// ripristino lo stato originale del log dei comandi
if ( bPrevCmdLog)
EgtEnableCommandLogger() ;
// se richiesto, salvo il comando Lua
if ( IsCmdLog()) {
string sLua = "dofile('" + sFilePath + "')" +
string sLuaPath = sFilePath ;
ReplaceString( sLuaPath, "\\", "\\\\") ;
string sLua = "dofile('" + sLuaPath + "')" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
+28
View File
@@ -20,6 +20,34 @@
using namespace std ;
//----------------------------------------------------------------------------
const char*
NgeTypeToString( int nNgeType)
{
switch ( nNgeType) {
case GDB_SV_TXT : return "'T'" ;
case GDB_SV_BIN : return "'B'" ;
default :
case GDB_SV_CMPTXT : return "'CT'" ;
}
}
//----------------------------------------------------------------------------
int
StringToNgeType( const string& sNgeType)
{
string sTmp = sNgeType ;
ToUpper( sTmp) ;
if ( sTmp == "T")
return GDB_SV_TXT ;
else if ( sTmp == "B")
return GDB_SV_BIN ;
else if ( sTmp == "CT")
return GDB_SV_CMPTXT ;
// default
return GDB_SV_CMPTXT ;
}
//----------------------------------------------------------------------------
const char*
SepToString( int nSep)
+3
View File
@@ -17,6 +17,9 @@
class IGeomDB ;
//----------------------------------------------------------------------------
// Tipo del file Nge
const char* NgeTypeToString( int nNgeType) ;
int StringToNgeType( const std::string& sNgeType) ;
// Tipo punto per creazione rette e archi
const char* SepToString( int nSep) ;
int StringToSep( const std::string& sSep) ;
BIN
View File
Binary file not shown.
+5 -8
View File
@@ -15,6 +15,7 @@
#include "stdafx.h"
#include "LUA.h"
#include "API.h"
#include "AuxTools.h"
#include "/EgtDev/Include/EInAPI.h"
#include "/EgtDev/Include/EgnStringUtils.h"
#include "/EgtDev/Extern/Lua/Include/lua.hpp"
@@ -120,14 +121,14 @@ LuaOpenFile( lua_State* L)
//-------------------------------------------------------------------------------
static int
LuaImportFile( lua_State* L)
LuaInsertFile( lua_State* L)
{
// 1 parametro : path del file da importare
string sFilePath ;
LuaCheckParam( L, 1, sFilePath)
LuaClearStack( L) ;
// apro il file
bool bOk = EgtImportFile( sFilePath) ;
bool bOk = EgtInsertFile( sFilePath) ;
// restituisco il risultato
LuaSetReturn( L, bOk) ;
return 1 ;
@@ -144,11 +145,7 @@ LuaSaveFile( lua_State* L)
if ( lua_gettop( L) >= 2) {
string sFlag ;
LuaCheckParam( L, 2, sFlag) ;
ToUpper( sFlag) ;
if ( sFlag == "T")
nFlag = GDB_SV_TXT ;
else if ( sFlag == "B")
nFlag = GDB_SV_BIN ;
nFlag = StringToNgeType( sFlag) ;
}
LuaClearStack( L) ;
// salvo il file
@@ -169,7 +166,7 @@ LuaInstallGeomDB( lua_State* L)
lua_register( L, "EgtGetGridVersZ", LuaGetGridVersZ) ;
lua_register( L, "EgtNewFile", LuaNewFile) ;
lua_register( L, "EgtOpenFile", LuaOpenFile) ;
lua_register( L, "EgtImportFile", LuaImportFile) ;
lua_register( L, "EgtInsertFile", LuaInsertFile) ;
lua_register( L, "EgtSaveFile", LuaSaveFile) ;
}
catch ( ...) {