diff --git a/GeomDBTree.cpp b/GeomDBTree.cpp
index fbc0914..a635437 100644
--- a/GeomDBTree.cpp
+++ b/GeomDBTree.cpp
@@ -26,6 +26,8 @@ using namespace std ;
//----------------------------------------------------------------------------
#ifdef _DEBUG
#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
#endif
//--------------------------- Constants --------------------------------------
@@ -68,6 +70,7 @@ CTestEGrDlg::ClearTree( void)
RevertOldIdOnTree() ;
// svuoto l'albero
+ m_Tree.SelectItem( NULL) ;
m_Tree.DeleteAllItems() ;
OutData( "") ;
@@ -217,19 +220,50 @@ CTestEGrDlg::OnTreeSelChanged( NMHDR* pNMHDR, LRESULT* pResult)
}
//----------------------------------------------------------------------------
-void
+bool
+CTestEGrDlg::SelectIdOnTree( int nId, HTREEITEM hParent)
+{
+ HTREEITEM hItem ;
+ if ( hParent == nullptr)
+ hItem = m_Tree.GetRootItem() ;
+ else
+ hItem = m_Tree.GetChildItem( hParent) ;
+ while ( hItem != nullptr) {
+ // verifico se ha l'Id cercato
+ int nData = int( m_Tree.GetItemData( hItem)) ;
+ if ( nId == nData) {
+ m_Tree.SelectItem( hItem) ;
+ return true ;
+ }
+ // se ci sono dei figli, li analizzo
+ if ( m_Tree.ItemHasChildren( hItem)) {
+ if ( SelectIdOnTree( nId, hItem))
+ return true ;
+ }
+ // passo al successivo fratello
+ hItem = m_Tree.GetNextSiblingItem( hItem) ;
+ }
+ return false ;
+}
+
+//----------------------------------------------------------------------------
+int
CTestEGrDlg::RevertOldIdOnTree( void)
{
+ // verifiche sul DB geometrico
+ if ( m_pGeomDB == nullptr)
+ return GDB_ID_NULL ;
+ // salvo il vecchio Id
+ int nOLd = m_nOldIdTree ;
+ // se non nullo...
if ( m_nOldIdTree != GDB_ID_NULL) {
- // verifiche sul DB geometrico
- if ( m_pGeomDB == nullptr)
- return ;
// ripristino il modo e lo stato precedente dell'oggetto
m_pGeomDB->RevertMode( m_nOldIdTree) ;
m_pGeomDB->RevertStatus( m_nOldIdTree) ;
// annullo oggetto da ripristinare
m_nOldIdTree = GDB_ID_NULL ;
}
+ return nOLd ;
}
//----------------------------------------------------------------------------
diff --git a/TestEGr.cpp b/TestEGr.cpp
index dfa0a84..ffd5094 100644
--- a/TestEGr.cpp
+++ b/TestEGr.cpp
@@ -89,25 +89,30 @@ CTestEGrApp::InitInstance( void)
// livello di debug
int nDebug = GetPrivateProfileInt( "General", "Debug", 0, m_pszProfileName) ;
- // inizializzazioni del logger
- Logger logger( ( nDebug > 0 ? LL_DEBUG : LL_INFO), "TestEGr") ;
- logger.AddOutputStream( new ofstream( "TestEgr.log"), true) ;
- SetEGnLogger( &logger) ;
- SetENkLogger( &logger) ;
- SetEGkLogger( &logger) ;
- SetEGrLogger( &logger) ;
+ // inizializzazioni del logger generale
+ Logger logGen( ( nDebug > 0 ? LL_DEBUG : LL_INFO), "TestEGr") ;
+ logGen.AddOutputStream( new ofstream( "TestEgr.log"), true) ;
+ SetEGnLogger( &logGen) ;
+ SetENkLogger( &logGen) ;
+ SetEGkLogger( &logGen) ;
+ SetEGrLogger( &logGen) ;
// inizio programma
- LOG_DATETIME( &logger, " Start")
+ LOG_DATETIME( &logGen, " Start")
// versione del programma
- LOG_INFO( &logger, GetExeNameVer().c_str())
+ LOG_INFO( &logGen, GetExeNameVer().c_str())
// versione delle librerie
- LOG_INFO( &logger, GetEGnVersion())
- LOG_INFO( &logger, GetENkVersion())
- LOG_INFO( &logger, GetEGkVersion())
- LOG_INFO( &logger, GetEGrVersion())
+ LOG_INFO( &logGen, GetEGnVersion())
+ LOG_INFO( &logGen, GetENkVersion())
+ LOG_INFO( &logGen, GetEGkVersion())
+ LOG_INFO( &logGen, GetEGrVersion())
+
+ // inizializzazione logger dei comandi
+ Logger logCmd( LL_INFO, "TestEGr") ;
+ logCmd.AddOutputStream( new ofstream( "TestEgr.tsc"), true) ;
+ LOG_INFO( &logCmd, ( "// " + CurrDateTime()).c_str()) ;
// gestione linea di comando
string sFileToOpen ;
@@ -117,12 +122,13 @@ CTestEGrApp::InitInstance( void)
sFileToOpen = WtoA( cmdInfo.m_strFileName) ;
// Dialog interface
- CTestEGrDlg dlg( sFileToOpen, &logger) ;
+ CTestEGrDlg dlg( sFileToOpen, &logGen, &logCmd) ;
m_pMainWnd = &dlg ;
dlg.DoModal() ;
// fine programma
- LOG_DATETIME( &logger, " End")
+ LOG_INFO( &logCmd, "// EXIT") ;
+ LOG_DATETIME( &logGen, " End")
// Exit application with FALSE
return FALSE ;
diff --git a/TestEGr.rc b/TestEGr.rc
index 9fe2272..ee9bc39 100644
Binary files a/TestEGr.rc and b/TestEGr.rc differ
diff --git a/TestEGr.vcxproj b/TestEGr.vcxproj
index 63ae67d..c5d4aaf 100644
--- a/TestEGr.vcxproj
+++ b/TestEGr.vcxproj
@@ -226,6 +226,7 @@
+
@@ -239,9 +240,10 @@
Create
+
-
+
diff --git a/TestEGr.vcxproj.filters b/TestEGr.vcxproj.filters
index 95bba3d..8e71db9 100644
--- a/TestEGr.vcxproj.filters
+++ b/TestEGr.vcxproj.filters
@@ -107,6 +107,9 @@
File di intestazione
+
+ File di intestazione
+
@@ -118,15 +121,18 @@
File di origine
-
- File di origine
-
File di origine
File di origine
+
+ File di origine
+
+
+ File di origine
+
diff --git a/TestEGrCmd.cpp b/TestEGrCmd.cpp
new file mode 100644
index 0000000..80c6345
--- /dev/null
+++ b/TestEGrCmd.cpp
@@ -0,0 +1,68 @@
+//----------------------------------------------------------------------------
+// EgalTech 2013-2014
+//----------------------------------------------------------------------------
+// File : TestEGrCmd.cpp Data : 15.03.14 Versione : 1.5c5
+// Contenuto : Metodi dell'edit per comandi utente.
+//
+//
+//
+// Modifiche : 27.02.14 DS Creazione modulo.
+//
+//
+//----------------------------------------------------------------------------
+
+//--------------------------- Include ----------------------------------------
+#include "stdafx.h"
+#include "TestEGrCmd.h"
+#include "TestEGrUtils.h"
+#include "/EgtDev/Include/EgnStringUtils.h"
+#include "/EgtDev/Include/EGnStringConverter.h"
+
+using namespace std ;
+
+//----------------------------------------------------------------------------
+#ifdef _DEBUG
+ #define new DEBUG_NEW
+ #undef THIS_FILE
+ static char THIS_FILE[] = __FILE__;
+#endif
+
+//----------------------------------------------------------------------------
+BEGIN_MESSAGE_MAP( TestEGrCmd, CEdit)
+ ON_WM_KEYDOWN()
+END_MESSAGE_MAP()
+
+
+//----------------------------------------------------------------------------
+TestEGrCmd::TestEGrCmd( void)
+{
+}
+
+//----------------------------------------------------------------------------
+TestEGrCmd::~TestEGrCmd( void)
+{
+}
+
+//----------------------------------------------------------------------------
+void
+TestEGrCmd::OnKeyDown( UINT nChar, UINT nRepCnt, UINT nFlags)
+{
+ CEdit::OnKeyDown( nChar, nRepCnt, nFlags) ;
+
+ // se e' stato premuto RETURN
+ if ( nChar == VK_RETURN) {
+ // si recupera la linea corrente
+ SetSel( -1, 0) ; // per eliminare la selezione corrente
+ int nBuf = LineLength( LineIndex()) + 1 ; // usa indice di carattere
+ wcharBuffer wBuffer( nBuf) ;
+ int nLen = GetLine( LineFromChar(), wBuffer.data(), nBuf) ; // usa indice di linea
+ wBuffer.terminate( nLen) ;
+ string sCmd = wcharBtoA( wBuffer) ;
+ TrimLeft( sCmd) ;
+ // se linea valida si esegue
+ if ( ! sCmd.empty() && sCmd.compare( 0, 2, "//") != 0) {
+ if ( ! ::LineExec( sCmd))
+ ::OutInfo( "Error executing command") ;
+ }
+ }
+}
diff --git a/TestEGrCmd.h b/TestEGrCmd.h
new file mode 100644
index 0000000..a9526ea
--- /dev/null
+++ b/TestEGrCmd.h
@@ -0,0 +1,29 @@
+//----------------------------------------------------------------------------
+// EgalTech 2013-2014
+//----------------------------------------------------------------------------
+// File : TestEGrCmd.cpp Data : 15.03.14 Versione : 1.5c5
+// Contenuto : Dichiarazioni classe dell'edit per comandi utente.
+//
+//
+//
+// Modifiche : 27.02.14 DS Creazione modulo.
+//
+//
+//----------------------------------------------------------------------------
+
+#pragma once
+
+//----------------------------------------------------------------------------
+class TestEGrCmd : public CEdit
+{
+
+ public :
+ TestEGrCmd( void) ;
+ ~TestEGrCmd( void) ;
+
+ protected :
+ afx_msg void OnKeyDown( UINT nChar, UINT nRepCnt, UINT nFlags) ;
+
+ DECLARE_MESSAGE_MAP()
+
+} ;
diff --git a/TestEGrDlg.cpp b/TestEGrDlg.cpp
index b7fce76..93e5124 100644
--- a/TestEGrDlg.cpp
+++ b/TestEGrDlg.cpp
@@ -31,7 +31,9 @@ using namespace std ;
//----------------------------------------------------------------------------
#ifdef _DEBUG
-#define new DEBUG_NEW
+ #define new DEBUG_NEW
+ #undef THIS_FILE
+ static char THIS_FILE[] = __FILE__;
#endif
@@ -78,16 +80,20 @@ END_MESSAGE_MAP()
//----------------------------------------------------------------------------
// CTestEGrDlg dialog
//----------------------------------------------------------------------------
-CTestEGrDlg::CTestEGrDlg( const std::string& sFileToOpen, ILogger* pLogger, CWnd* pParent)
+CTestEGrDlg::CTestEGrDlg( const std::string& sFileToOpen, ILogger* pLogGen, ILogger* pLogCmd, CWnd* pParent)
:CDialog( IDD_TESTEGR_DIALOG, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon( IDR_MAINFRAME) ;
// eventuale file da caricare all'avvio
m_sFileToOpen = sFileToOpen ;
- // memorizzo il puntatore al logger
- m_pLogger = pLogger ;
+ // memorizzo i puntatori ai logger generale e dei comandi
+ m_pLogGen = pLogGen ;
+ m_pLogCmd = pLogCmd ;
// inizializzazioni varie
m_pGeomDB = nullptr ;
+ m_pGdbExec = nullptr ;
+ m_pSceExec = nullptr ;
+ m_pCmdParser = nullptr ;
m_pImgList = nullptr ;
m_nOldIdTree = GDB_ID_NULL ;
}
@@ -97,6 +103,16 @@ CTestEGrDlg::~CTestEGrDlg( void)
{
// ripristino ultima entità selezionata sull'albero delle entità
RevertOldIdOnTree() ;
+ // cancello esecutori
+ if ( m_pGdbExec != nullptr)
+ delete m_pGdbExec ;
+ m_pGdbExec = nullptr ;
+ if ( m_pSceExec != nullptr)
+ delete m_pSceExec ;
+ m_pSceExec = nullptr ;
+ if ( m_pCmdParser != nullptr)
+ delete m_pCmdParser ;
+ m_pCmdParser = nullptr ;
// cancello GeomDB
if ( m_pGeomDB != nullptr)
delete m_pGeomDB ;
@@ -171,18 +187,18 @@ CTestEGrDlg::OnInitDialog( void)
if ( m_pGeomDB != nullptr)
m_pGeomDB->Init() ;
else
- LOG_ERROR( m_pLogger, "Error in CreateGeomDB")
+ LOG_ERROR( m_pLogGen, "Error in CreateGeomDB")
- // imposto il colore di default
+ // imposto il materiale di default tramite colore
if ( m_pGeomDB != nullptr) {
Color colDef( 0, 0, 0) ;
GetIniColor( "GeomDB", "DefaultColor", colDef) ;
- m_pGeomDB->SetDefaultColor( colDef) ;
+ m_pGeomDB->SetDefaultMaterial( colDef) ;
}
// creo la vista per la sciena
if ( ! m_View.Create( this, IDC_SCENE))
- LOG_ERROR( m_pLogger, "Error in CreateSceneView")
+ LOG_ERROR( m_pLogGen, "Error in CreateSceneView")
// recupero i parametri della scena
int nDriver = GetPrivateProfileInt( "OpenGL", "Driver", 2, AfxGetApp()->m_pszProfileName) ;
@@ -192,7 +208,7 @@ CTestEGrDlg::OnInitDialog( void)
// creazione della scena
if ( ! m_View.StartScene( nDriver, b2Buff, nColorBits, nDepthBits))
- LOG_ERROR( m_pLogger, "Error in StartScene")
+ LOG_ERROR( m_pLogGen, "Error in StartScene")
// recupero i colori dello sfondo e li imposto
if ( m_View.GetScene() != nullptr) {
@@ -218,13 +234,19 @@ CTestEGrDlg::OnInitDialog( void)
// log con info sulla scena
string sSceneInfo ;
m_View.GetSceneInfo( sSceneInfo) ;
- LOG_INFO( m_pLogger, sSceneInfo.c_str())
+ LOG_INFO( m_pLogGen, sSceneInfo.c_str())
// recupero il posizionamento della finestra del dialogo
WINDOWPLACEMENT winPlace ;
if ( GetIniWinPlace( "General", "WinPlace", winPlace))
SetWindowPlacement( &winPlace) ;
+ // preparo l'esecutore
+ PrepareExecutor() ;
+
+ // collego l'oggetto al control
+ m_Cmd.SubclassDlgItem( IDC_COMMAND, this) ;
+
// preparo il Tree
PrepareTree() ;
@@ -404,6 +426,7 @@ CTestEGrDlg::OnSize( UINT nType, int cx, int cy)
MoveDlgItem( IDC_VIEW_LEFT, IP_TR, cx, cy) ;
MoveDlgItem( IDC_VIEW_RIGHT, IP_TR, cx, cy) ;
MoveDlgItem( IDC_VIEW_ISO, IP_TR, cx, cy) ;
+ MoveDlgItem( IDC_COMMAND, IP_BR, cx, cy) ;
MoveDlgItem( IDC_CLOSE, IP_BR, cx, cy) ;
// spostamento e adattamento tree e associati
MoveDlgItem( IDC_TREE, IP_TL, cx, cy) ;
@@ -517,7 +540,7 @@ CTestEGrDlg::OutInfo( const string& sOut, bool bLog)
pWnd->SetWindowText( stringtoW( sOut)) ;
if ( bLog)
- LOG_INFO( m_pLogger, sOut.c_str())
+ LOG_INFO( m_pLogGen, sOut.c_str())
}
//----------------------------------------------------------------------------
@@ -529,7 +552,7 @@ CTestEGrDlg::OutData( const string& sOut, bool bLog)
pWnd->SetWindowText( stringtoW( sOut)) ;
if ( bLog)
- LOG_INFO( m_pLogger, sOut.c_str())
+ LOG_INFO( m_pLogGen, sOut.c_str())
}
//----------------------------------------------------------------------------
@@ -564,6 +587,8 @@ CTestEGrDlg::OnFileNew( void)
m_pGeomDB->Init() ;
// visualizzo con zoom all
m_View.Zoom( IDC_ZOOM_ALL) ;
+ // log dei comandi
+ LOG_INFO( m_pLogCmd, "// NEW")
}
//----------------------------------------------------------------------------
@@ -601,49 +626,6 @@ CTestEGrDlg::OnFileOpen( void)
AfxMessageBox( L"Error loading file (look at Log file)", MB_ICONSTOP|MB_OK) ;
}
-//----------------------------------------------------------------------------
-bool
-CTestEGrDlg::FileOpen( const string& sFilePath)
-{
- // verifico validità DB geometrico
- if ( m_pGeomDB == nullptr) {
- LOG_ERROR( m_pLogger, "GeomDB invalid")
- return false ;
- }
-
- // divido in nome e direttorio
- string sFileDir ;
- string sFileName ;
- SplitLast( sFilePath, "\\", sFileDir, sFileName) ;
-
- // inserisco il nome del file nel titolo della finestra
- SetWindowText( stringtoW( ( sFileName + " - EgalTech TestEGr"))) ;
- // emetto info
- string sInfo = "Open File = " + sFilePath ;
- LOG_INFO( m_pLogger, sInfo.c_str())
-
- // pulisco l'albero delle entità
- ClearTree() ;
- // pulizia e reinizializzazione del DB geometrico
- m_pGeomDB->Clear() ;
- m_pGeomDB->Init() ;
- // carico il file
- if ( ! m_pGeomDB->Load( sFilePath))
- return false ;
- // visualizzo con zoom all
- PerformanceCounter Counter ;
- Counter.Start() ;
- m_View.Zoom( IDC_ZOOM_ALL) ;
- Counter.Stop() ;
- string sOut = "First ZoomAll time = " + ToString( Counter.GetTime(), 2) + " ms" ;
- // emetto info
- ::OutInfo( sOut) ;
- // aggiorno l'albero delle entità
- LoadTree() ;
-
- return true ;
-}
-
//----------------------------------------------------------------------------
void
CTestEGrDlg::OnFileExec( void)
@@ -677,60 +659,6 @@ CTestEGrDlg::OnFileExec( void)
AfxMessageBox( L"Error executing file (look at Log file)", MB_ICONSTOP|MB_OK) ;
}
-//----------------------------------------------------------------------------
-bool
-CTestEGrDlg::FileExec( const string& sFilePath)
-{
- // creo oggetti per esecuzione
- PtrOwner pGdbExec( CreateGdbExecutor()) ;
- PtrOwner pSceExec( CreateSceExecutor()) ;
- PtrOwner pCmdParser( CreateCmdParser()) ;
-
- // controllo validità oggetti
- if ( ! IsValid( pGdbExec)) {
- LOG_ERROR( m_pLogger, "Error in CreateGdbExecutor") ;
- return false ;
- }
- if ( ! IsValid( pSceExec)) {
- LOG_ERROR( m_pLogger, "Error in CreateSceExecutor") ;
- return false ;
- }
- if ( ! IsValid( pCmdParser)) {
- LOG_ERROR( m_pLogger, "Error in CreateCmdParser") ;
- return false ;
- }
- // verifico validità DB geometrico
- if ( m_pGeomDB == nullptr) {
- LOG_ERROR( m_pLogger, "GeomDB invalid")
- return false ;
- }
-
- // divido in nome e direttorio
- string sFileDir ;
- string sFileName ;
- SplitLast( sFilePath, "\\", sFileDir, sFileName) ;
-
- // inserisco il nome del file nel titolo della finestra
- SetWindowText( stringtoW( ( sFileName + " - EgalTech TestEGr"))) ;
- // emetto info
- string sInfo = "Exec File = " + sFilePath ;
- LOG_INFO( m_pLogger, sInfo.c_str())
-
- // pulisco l'albero delle entità
- ClearTree() ;
- // esecuzione script
- pSceExec->SetScene( m_View.GetScene()) ;
- pGdbExec->SetGeomDB( m_pGeomDB) ;
- pGdbExec->AddExecutor( Get( pSceExec)) ;
- bool bOk = pCmdParser->Init( Get( pGdbExec), 0) &&
- pCmdParser->Run( sFilePath) ;
-
- // aggiorno l'albero delle entità
- LoadTree() ;
-
- return bOk ;
-}
-
//----------------------------------------------------------------------------
void
CTestEGrDlg::OnZoom( UINT nID)
@@ -761,3 +689,165 @@ CTestEGrDlg::PreTranslateMessage( MSG* pMsg)
// passo al gestore di default
return CDialog::PreTranslateMessage( pMsg) ;
}
+
+//----------------------------------------------------------------------------
+bool
+CTestEGrDlg::PrepareExecutor( void)
+{
+ // verifico validità DB geometrico
+ if ( m_pGeomDB == nullptr) {
+ LOG_ERROR( m_pLogGen, "GeomDB invalid")
+ return false ;
+ }
+
+ // eventuale distruzione oggetti per esecuzione
+ if ( m_pGdbExec != nullptr)
+ delete m_pGdbExec ;
+ m_pGdbExec = nullptr ;
+ if ( m_pSceExec != nullptr)
+ delete m_pSceExec ;
+ m_pSceExec = nullptr ;
+ if ( m_pCmdParser == nullptr)
+ delete m_pCmdParser ;
+ m_pCmdParser = nullptr ;
+
+ // creo oggetti per esecuzione e ne verifico la validità
+ m_pGdbExec = CreateGdbExecutor() ;
+ if ( m_pGdbExec == nullptr) {
+ LOG_ERROR( m_pLogGen, "Error in CreateGdbExecutor")
+ return false ;
+ }
+ m_pSceExec = CreateSceExecutor() ;
+ if ( m_pSceExec == nullptr) {
+ LOG_ERROR( m_pLogGen, "Error in CreateSceExecutor")
+ return false ;
+ }
+ m_pCmdParser = CreateCmdParser() ;
+ if ( m_pCmdParser == nullptr) {
+ LOG_ERROR( m_pLogGen, "Error in CreateCmdParser")
+ return false ;
+ }
+
+ // inizializzazioni
+ m_pSceExec->SetScene( m_View.GetScene()) ;
+ m_pGdbExec->SetGeomDB( m_pGeomDB) ;
+ m_pGdbExec->AddExecutor( m_pSceExec) ;
+ m_pCmdParser->Init( m_pGdbExec) ;
+
+ return true ;
+}
+
+//----------------------------------------------------------------------------
+bool
+CTestEGrDlg::FileOpen( const string& sFilePath)
+{
+ // verifico validità DB geometrico
+ if ( m_pGeomDB == nullptr) {
+ LOG_ERROR( m_pLogGen, "GeomDB invalid")
+ return false ;
+ }
+
+ // divido in nome e direttorio
+ string sFileDir ;
+ string sFileName ;
+ SplitLast( sFilePath, "\\", sFileDir, sFileName) ;
+
+ // inserisco il nome del file nel titolo della finestra
+ SetWindowText( stringtoW( ( sFileName + " - EgalTech TestEGr"))) ;
+ // emetto info
+ string sInfo = "Open File = " + sFilePath ;
+ LOG_INFO( m_pLogGen, sInfo.c_str())
+
+ // pulisco l'albero delle entità
+ ClearTree() ;
+ // pulizia e reinizializzazione del DB geometrico
+ m_pGeomDB->Clear() ;
+ m_pGeomDB->Init() ;
+ // carico il file
+ if ( ! m_pGeomDB->Load( sFilePath))
+ return false ;
+ // log dei comandi
+ LOG_INFO( m_pLogCmd, ( "// LOAD( " + sFilePath + ")").c_str())
+ // visualizzo con zoom all
+ PerformanceCounter Counter ;
+ Counter.Start() ;
+ m_View.Zoom( IDC_ZOOM_ALL) ;
+ Counter.Stop() ;
+ string sOut = "First ZoomAll time = " + ToString( Counter.GetTime(), 2) + " ms" ;
+ // emetto info
+ ::OutInfo( sOut) ;
+ // aggiorno l'albero delle entità
+ LoadTree() ;
+
+ return true ;
+}
+
+//----------------------------------------------------------------------------
+bool
+CTestEGrDlg::FileExec( const string& sFilePath)
+{
+ // verifico validità esecutore
+ if ( m_pCmdParser == nullptr) {
+ LOG_ERROR( m_pLogGen, "CmdParser invalid")
+ return false ;
+ }
+
+ // divido in nome e direttorio
+ string sFileDir ;
+ string sFileName ;
+ SplitLast( sFilePath, "\\", sFileDir, sFileName) ;
+
+ // inserisco il nome del file nel titolo della finestra
+ SetWindowText( stringtoW( ( sFileName + " - EgalTech TestEGr"))) ;
+ // emetto info
+ string sInfo = "Exec File = " + sFilePath ;
+ LOG_INFO( m_pLogGen, sInfo.c_str())
+
+ // pulisco l'albero delle entità
+ ClearTree() ;
+
+ // esecuzione script
+ bool bOk = m_pCmdParser->Run( sFilePath) ;
+
+ // log dei comandi
+ LOG_INFO( m_pLogCmd, ( "// RUN( " + sFilePath + ")").c_str())
+
+ // aggiorno visualizzazione
+ m_View.Redraw() ;
+ // aggiorno l'albero delle entità
+ LoadTree() ;
+
+ return bOk ;
+}
+
+//----------------------------------------------------------------------------
+bool
+CTestEGrDlg::LineExec( const string& sLine)
+{
+ // verifico validità esecutore
+ if ( m_pCmdParser == nullptr) {
+ LOG_ERROR( m_pLogGen, "CmdParser invalid")
+ return false ;
+ }
+
+ // ripristino stato oggetto selezionato
+ int nIdOld = RevertOldIdOnTree() ;
+
+ // eseguo il comando
+ bool bOk = m_pCmdParser->ExecLine( sLine) ;
+
+ // log dei comandi
+ if ( bOk)
+ LOG_INFO( m_pLogCmd, sLine.c_str())
+ else
+ LOG_INFO( m_pLogCmd, ( "// " + sLine).c_str())
+
+ // aggiorno visualizzazione
+ m_View.Redraw() ;
+ // aggiorno l'albero delle entità e tento di riselezionare oggetto
+ LoadTree() ;
+ if ( nIdOld != GDB_ID_NULL)
+ SelectIdOnTree( nIdOld) ;
+
+ return bOk ;
+}
\ No newline at end of file
diff --git a/TestEGrDlg.h b/TestEGrDlg.h
index 4a4119a..7896cc6 100644
--- a/TestEGrDlg.h
+++ b/TestEGrDlg.h
@@ -14,21 +14,27 @@
#pragma once
#include "TestEgrView.h"
+#include "TestEgrCmd.h"
#include "/EgtDev/Include/EGkColor.h"
class ILogger ;
class IGeomDB ;
+class IGdbExecutor ;
+class ISceExecutor ;
+class ICmdParser ;
class IGeoObj ;
//----------------------------------------------------------------------------
class CTestEGrDlg : public CDialog
{
public :
- CTestEGrDlg( const std::string& sFileToOpen, ILogger* pLogger = nullptr, CWnd* pParent = nullptr) ;
+ CTestEGrDlg( const std::string& sFileToOpen, ILogger* pLogGen = nullptr,
+ ILogger* pLogCmd = nullptr, CWnd* pParent = nullptr) ;
~CTestEGrDlg( void) ;
void OutInfo( const std::string& sOut, bool bLog = true) ;
bool GetSceneInfo( std::string& sInfo)
{ return m_View.GetSceneInfo( sInfo) ; }
+ bool LineExec( const std::string& sLine) ;
protected :
virtual BOOL OnInitDialog( void) ;
@@ -42,6 +48,7 @@ class CTestEGrDlg : public CDialog
afx_msg void OnFileExec( void) ;
afx_msg void OnZoom( UINT nID) ;
afx_msg void OnView( UINT nID) ;
+ afx_msg void OnCommand( void) ;
afx_msg void OnClose( void) ;
afx_msg void OnTreeSelChanged(NMHDR *pNMHDR, LRESULT *pResult) ;
@@ -58,32 +65,41 @@ class CTestEGrDlg : public CDialog
bool ReshapeDlgItem( int nID, int nFlag, int nW, int nH) ;
bool GetWindowRect( CWnd* pWnd, CRect& rect) ;
void OutData( const std::string& sOut, bool bLog = false) ;
+ // Document
+ bool PrepareExecutor( void) ;
bool FileOpen( const std::string& sFilePath) ;
bool FileExec( const std::string& sFilePath) ;
+ // GeomDBTree
bool PrepareTree( void) ;
bool ClearTree( void) ;
bool LoadTree( void) ;
bool InsertGroupOnTree( int nId, HTREEITEM hParent) ;
bool InsertGeoObjOnTree( int nId, IGeoObj* pGeoObj, HTREEITEM hParent) ;
int GetGeoObjImage( int nType) ;
- void RevertOldIdOnTree( void) ;
+ bool SelectIdOnTree( int nId, HTREEITEM hParent = nullptr) ;
+ int RevertOldIdOnTree( void) ;
void OutGroupData( int nId) ;
void OutGeoObjData( int nId) ;
private :
- IGeomDB* m_pGeomDB ;
- ILogger* m_pLogger ;
- TestEgrView m_View ;
- std::string m_sFileToOpen ;
- HICON m_hIcon ;
- CTreeCtrl m_Tree ;
- CImageList* m_pImgList ;
- int m_nOldIdTree ;
- int m_nPrevCx ;
- int m_nPrevCy ;
- int m_nLeftBarW ;
- int m_nRightBarW ;
- int m_nBottomBarH ;
+ IGeomDB* m_pGeomDB ;
+ ILogger* m_pLogGen ;
+ ILogger* m_pLogCmd ;
+ IGdbExecutor* m_pGdbExec ;
+ ISceExecutor* m_pSceExec ;
+ ICmdParser* m_pCmdParser ;
+ TestEGrView m_View ;
+ TestEGrCmd m_Cmd ;
+ std::string m_sFileToOpen ;
+ HICON m_hIcon ;
+ CTreeCtrl m_Tree ;
+ CImageList* m_pImgList ;
+ int m_nOldIdTree ;
+ int m_nPrevCx ;
+ int m_nPrevCy ;
+ int m_nLeftBarW ;
+ int m_nRightBarW ;
+ int m_nBottomBarH ;
DECLARE_MESSAGE_MAP()
} ;
diff --git a/TestEGrUtils.cpp b/TestEGrUtils.cpp
index 5928435..cbf9e1c 100644
--- a/TestEGrUtils.cpp
+++ b/TestEGrUtils.cpp
@@ -26,7 +26,7 @@ using namespace std ;
//----------------------------------------------------------------------------
void
-OutInfo( string& sOut, bool bLog)
+OutInfo( const string& sOut, bool bLog)
{
((CTestEGrDlg*)AfxGetMainWnd())->OutInfo( sOut, bLog) ;
}
@@ -37,3 +37,10 @@ GetSceneInfo( string& sInfo)
{
return ((CTestEGrDlg*)AfxGetMainWnd())->GetSceneInfo( sInfo) ;
}
+
+//----------------------------------------------------------------------------
+bool
+LineExec( const string& sLine)
+{
+ return ((CTestEGrDlg*)AfxGetMainWnd())->LineExec( sLine) ;
+}
\ No newline at end of file
diff --git a/TestEGrUtils.h b/TestEGrUtils.h
index 855f5b9..8102fac 100644
--- a/TestEGrUtils.h
+++ b/TestEGrUtils.h
@@ -16,5 +16,6 @@
#include
//----------------------------------------------------------------------------
-void OutInfo( std::string& sOut, bool bLog = true) ;
+void OutInfo( const std::string& sOut, bool bLog = true) ;
bool GetSceneInfo( std::string& sInfo) ;
+bool LineExec( const std::string& sLine) ;
diff --git a/TestEgrView.cpp b/TestEGrView.cpp
similarity index 88%
rename from TestEgrView.cpp
rename to TestEGrView.cpp
index 4ec4acc..81adebf 100644
--- a/TestEgrView.cpp
+++ b/TestEGrView.cpp
@@ -13,7 +13,7 @@
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
-#include "TestEgrView.h"
+#include "TestEGrView.h"
#include "TestEGrUtils.h"
#include "resource.h"
#include "/EgtDev/Include/EgtPerfCounter.h"
@@ -26,11 +26,13 @@ using namespace std ;
//----------------------------------------------------------------------------
#ifdef _DEBUG
-#define new DEBUG_NEW
+ #define new DEBUG_NEW
+ #undef THIS_FILE
+ static char THIS_FILE[] = __FILE__;
#endif
//----------------------------------------------------------------------------
-BEGIN_MESSAGE_MAP( TestEgrView, CWnd)
+BEGIN_MESSAGE_MAP( TestEGrView, CWnd)
ON_WM_PAINT()
ON_WM_MBUTTONDOWN()
ON_WM_MBUTTONUP()
@@ -39,7 +41,7 @@ BEGIN_MESSAGE_MAP( TestEgrView, CWnd)
END_MESSAGE_MAP()
//----------------------------------------------------------------------------
-TestEgrView::TestEgrView( void)
+TestEGrView::TestEGrView( void)
{
m_pDC = nullptr ;
m_pScene = nullptr ;
@@ -48,7 +50,7 @@ TestEgrView::TestEgrView( void)
}
//----------------------------------------------------------------------------
-TestEgrView::~TestEgrView( void)
+TestEGrView::~TestEGrView( void)
{
if ( m_pScene != nullptr)
delete m_pScene ;
@@ -60,7 +62,7 @@ TestEgrView::~TestEgrView( void)
//----------------------------------------------------------------------------
bool
-TestEgrView::Create( CWnd* pParent, int nID)
+TestEGrView::Create( CWnd* pParent, int nID)
{
if ( pParent == nullptr ||
pParent->GetDlgItem( nID) == nullptr)
@@ -73,7 +75,7 @@ TestEgrView::Create( CWnd* pParent, int nID)
pParent->GetDlgItem( nID)->GetWindowRect( rectWin) ;
pParent->ScreenToClient( rectWin) ;
- if ( CreateEx( 0, className, L"TestEgrView",
+ if ( CreateEx( 0, className, L"TestEGrView",
WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, rectWin, pParent, nID) != 0) {
SetWindowPos( &wndTop, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE) ;
SetCursor( AfxGetApp()->LoadCursor( IDC_POINTER)) ;
@@ -87,7 +89,7 @@ TestEgrView::Create( CWnd* pParent, int nID)
//----------------------------------------------------------------------------
bool
-TestEgrView::StartScene( int nDriver, bool b2Buff, int nColorBits, int nDepthBits)
+TestEGrView::StartScene( int nDriver, bool b2Buff, int nColorBits, int nDepthBits)
{
if ( m_pScene == nullptr)
return false ;
@@ -105,7 +107,7 @@ TestEgrView::StartScene( int nDriver, bool b2Buff, int nColorBits, int nDepthBit
//----------------------------------------------------------------------------
bool
-TestEgrView::GetSceneInfo( string& sInfo)
+TestEGrView::GetSceneInfo( string& sInfo)
{
if ( m_pScene == nullptr)
return false ;
@@ -119,7 +121,7 @@ TestEgrView::GetSceneInfo( string& sInfo)
//----------------------------------------------------------------------------
void
-TestEgrView::Destroy( void)
+TestEGrView::Destroy( void)
{
if ( m_pScene != nullptr)
m_pScene->Destroy() ;
@@ -128,7 +130,7 @@ TestEgrView::Destroy( void)
//----------------------------------------------------------------------------
bool
-TestEgrView::Reshape( int nX, int nY, int nW, int nH)
+TestEGrView::Reshape( int nX, int nY, int nW, int nH)
{
// se non è ancora stata creata, esco subito
if ( m_pDC == nullptr || m_pScene == nullptr)
@@ -141,7 +143,7 @@ TestEgrView::Reshape( int nX, int nY, int nW, int nH)
//----------------------------------------------------------------------------
void
-TestEgrView::OnPaint( void)
+TestEGrView::OnPaint( void)
{
if ( m_pScene == nullptr)
return ;
@@ -162,14 +164,14 @@ TestEgrView::OnPaint( void)
//----------------------------------------------------------------------------
void
-TestEgrView::Redraw( void)
+TestEGrView::Redraw( void)
{
RedrawWindow() ;
}
//----------------------------------------------------------------------------
void
-TestEgrView::Zoom( UINT nID)
+TestEGrView::Zoom( UINT nID)
{
if ( m_pScene == nullptr)
return ;
@@ -197,7 +199,7 @@ TestEgrView::Zoom( UINT nID)
//----------------------------------------------------------------------------
void
-TestEgrView::View( UINT nID)
+TestEGrView::View( UINT nID)
{
if ( m_pScene == nullptr)
return ;
@@ -231,7 +233,7 @@ TestEgrView::View( UINT nID)
//----------------------------------------------------------------------------
void
-TestEgrView::OnMButtonDown( UINT nFlags, CPoint point)
+TestEGrView::OnMButtonDown( UINT nFlags, CPoint point)
{
if ( nFlags & MK_SHIFT) {
m_nStatus = ST_ZOOMWIN ;
@@ -251,7 +253,7 @@ TestEgrView::OnMButtonDown( UINT nFlags, CPoint point)
//----------------------------------------------------------------------------
void
-TestEgrView::OnMButtonUp( UINT nFlags, CPoint point)
+TestEGrView::OnMButtonUp( UINT nFlags, CPoint point)
{
// eseguo ZOOMWINDOWN
if ( m_nStatus == ST_ZOOMWIN) {
@@ -273,7 +275,7 @@ TestEgrView::OnMButtonUp( UINT nFlags, CPoint point)
//----------------------------------------------------------------------------
void
-TestEgrView::OnMouseMove( UINT nFlags, CPoint point)
+TestEGrView::OnMouseMove( UINT nFlags, CPoint point)
{
// visualizzo le coordinate del puntatore
ShowCursorCoordinates( Point3d( point.x, point.y)) ;
@@ -318,7 +320,7 @@ TestEgrView::OnMouseMove( UINT nFlags, CPoint point)
//----------------------------------------------------------------------------
BOOL
-TestEgrView::OnMouseWheel( UINT nFlags, short zDelta, CPoint point)
+TestEGrView::OnMouseWheel( UINT nFlags, short zDelta, CPoint point)
{
// devo essere nello stato NULL
if ( m_nStatus != ST_NULL)
@@ -344,7 +346,7 @@ TestEgrView::OnMouseWheel( UINT nFlags, short zDelta, CPoint point)
//----------------------------------------------------------------------------
void
-TestEgrView::ShowCursorCoordinates( const Point3d& ptWin)
+TestEGrView::ShowCursorCoordinates( const Point3d& ptWin)
{
if ( m_pScene == nullptr)
return ;
diff --git a/TestEGrView.h b/TestEGrView.h
index 26704db..05d6a33 100644
--- a/TestEGrView.h
+++ b/TestEGrView.h
@@ -11,11 +11,11 @@ class ILogger ;
class IEGrScene ;
//----------------------------------------------------------------------------
-class TestEgrView : public CWnd
+class TestEGrView : public CWnd
{
public :
- TestEgrView( void) ;
- ~TestEgrView( void) ;
+ TestEGrView( void) ;
+ ~TestEGrView( void) ;
bool Create( CWnd* pParent, int nID) ;
bool StartScene( int nDriver, bool b2Buff, int nColorBits, int nDepthBits) ;
IEGrScene* GetScene( void)
diff --git a/resource.h b/resource.h
index 5a12648..2538e15 100644
Binary files a/resource.h and b/resource.h differ