diff --git a/TestEGr.cpp b/TestEGr.cpp
index d9326e4..cc7da86 100644
--- a/TestEGr.cpp
+++ b/TestEGr.cpp
@@ -92,6 +92,8 @@ CTestEGrApp::InitInstance( void)
// inizializzazioni del logger
Logger logger( ( nDebug > 0 ? LL_DEBUG : LL_INFO), "TestEGr") ;
logger.AddOutputStream( new ofstream( "TestEgr.log"), true) ;
+ SetEGkLogger( &logger) ;
+ SetEGrLogger( &logger) ;
// inizio programma
LOG_DATETIME( &logger, " Start")
diff --git a/TestEGr.rc b/TestEGr.rc
index 9d62818..bd62871 100644
Binary files a/TestEGr.rc and b/TestEGr.rc differ
diff --git a/TestEGr.vcxproj b/TestEGr.vcxproj
index 84dbfe1..d04e8cb 100644
--- a/TestEGr.vcxproj
+++ b/TestEGr.vcxproj
@@ -197,6 +197,7 @@
+
@@ -213,6 +214,7 @@
+
@@ -224,6 +226,7 @@
+
diff --git a/TestEGr.vcxproj.filters b/TestEGr.vcxproj.filters
index ddf2e83..6277e41 100644
--- a/TestEGr.vcxproj.filters
+++ b/TestEGr.vcxproj.filters
@@ -30,6 +30,9 @@
File di risorse
+
+ File di risorse
+
@@ -62,6 +65,9 @@
File di intestazione
+
+ File di intestazione
+
@@ -76,6 +82,9 @@
File di origine
+
+ File di origine
+
diff --git a/TestEGrDlg.cpp b/TestEGrDlg.cpp
index 3e5acad..f75f578 100644
--- a/TestEGrDlg.cpp
+++ b/TestEGrDlg.cpp
@@ -15,12 +15,18 @@
#include "stdafx.h"
#include "TestEGr.h"
#include "TestEGrDlg.h"
+#include "TestEGrUtils.h"
#include "resource.h"
#include "/EgtDev/Include/EgtIniFile.h"
#include "/EgtDev/Include/EgtILogger.h"
+#include "/EgtDev/Include/EgtPerfCounter.h"
+#include "/EgtDev/Include/EgtPointerOwner.h"
+#include "/EgtDev/Include/EgnCmdParser.h"
#include "/EgtDev/Include/EGkDllMain.h"
#include "/EgtDev/Include/EGkGeomDB.h"
-#include "/EgtDev/Include/EgtPerfCounter.h"
+#include "/EgtDev/Include/EGkGdbExecutor.h"
+#include "/EgtDev/Include/EGrScene.h"
+#include "/EgtDev/Include/EGrSceExecutor.h"
using namespace std ;
@@ -32,6 +38,7 @@ using namespace std ;
//----------------------------------------------------------------------------
// CAboutDlg dialog used for App About
+//----------------------------------------------------------------------------
class CAboutDlg : public CDialog
{
public :
@@ -56,6 +63,12 @@ CAboutDlg::OnInitDialog( void)
GetDlgItem( IDC_EXEVER)->SetWindowText( stringtoW( GetExeNameVer())) ;
+ string sInfo ;
+ GetSceneInfo( sInfo) ;
+ ReplaceString( sInfo, "\n", "\r\n") ;
+ sInfo += "\r\n" ;
+ GetDlgItem( IDC_EXEINFO)->SetWindowText( stringtoW( sInfo)) ;
+
return TRUE ;
}
@@ -67,16 +80,11 @@ END_MESSAGE_MAP()
// CTestEGrDlg dialog
//----------------------------------------------------------------------------
CTestEGrDlg::CTestEGrDlg( ILogger* pLogger, CWnd* pParent)
- : CDialog( IDD_TESTEGR_DIALOG, pParent)
+ :CDialog( IDD_TESTEGR_DIALOG, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon( IDR_MAINFRAME) ;
+ // memorizzo il puntatore al logger
m_pLogger = pLogger ;
- SetEGkLogger( m_pLogger) ;
- m_pGeomDB = CreateGeomDB() ;
- if ( m_pGeomDB != nullptr)
- m_pGeomDB->Init() ;
- else
- LOG_ERROR( m_pLogger, "Error in CreateGeomDB")
}
//----------------------------------------------------------------------------
@@ -94,7 +102,9 @@ BEGIN_MESSAGE_MAP( CTestEGrDlg, CDialog)
ON_WM_QUERYDRAGICON()
ON_WM_SIZE()
ON_WM_CLOSE()
+ ON_BN_CLICKED( IDC_NEW, OnFileNew)
ON_BN_CLICKED( IDC_OPEN, OnFileOpen)
+ ON_BN_CLICKED( IDC_EXEC, OnFileExec)
ON_CONTROL_RANGE( BN_CLICKED, IDC_ZOOM_ALL, IDC_ZOOM_M, OnZoom)
ON_CONTROL_RANGE( BN_CLICKED, IDC_VIEW_TOP, IDC_VIEW_ISO, OnView)
ON_BN_CLICKED( IDC_CLOSE, OnClose)
@@ -142,6 +152,13 @@ CTestEGrDlg::OnInitDialog( void)
m_nSideBarW = rectClient.right - rectView.right ;
m_nBottomBarH = rectClient.bottom - rectView.bottom ;
+ // creo il DB geometrico
+ m_pGeomDB = CreateGeomDB() ;
+ if ( m_pGeomDB != nullptr)
+ m_pGeomDB->Init() ;
+ else
+ LOG_ERROR( m_pLogger, "Error in CreateGeomDB")
+
// recupero i parametri della scena
int nDriver = GetPrivateProfileInt( "OpenGL", "Driver", 2, AfxGetApp()->m_pszProfileName) ;
bool b2Buff = ( GetPrivateProfileInt( "OpenGL", "DoubleBuffer", 1, AfxGetApp()->m_pszProfileName) == 1) ;
@@ -149,8 +166,14 @@ CTestEGrDlg::OnInitDialog( void)
int nDepthBits = GetPrivateProfileInt( "OpenGL", "DepthBits", 16, AfxGetApp()->m_pszProfileName) ;
// creazione della scena
- m_View.Create( this, IDC_SCENE) ;
- m_View.StartScene( nDriver, b2Buff, nColorBits, nDepthBits, m_pGeomDB, m_pLogger) ;
+ if ( m_View.Create( this, IDC_SCENE) &&
+ m_View.StartScene( nDriver, b2Buff, nColorBits, nDepthBits))
+ m_View.GetScene()->Init( m_pGeomDB) ;
+
+ // log con info sulla scena
+ string sSceneInfo ;
+ m_View.GetSceneInfo( sSceneInfo) ;
+ LOG_INFO( m_pLogger, sSceneInfo.c_str())
// recupero il posizionamento della finestra del dialogo
string sTmp = GetPrivateProfileStringUtf8( "General", "WinPlace", "", AfxGetApp()->m_pszProfileName) ;
@@ -238,7 +261,9 @@ CTestEGrDlg::OnSize( UINT nType, int cx, int cy)
// se cambiata dimensione
if ( nType == SIZE_RESTORED || nType == SIZE_MAXIMIZED) {
// spostamento bottoni
+ MoveDlgItem( IDC_NEW, IP_TR, cx, cy) ;
MoveDlgItem( IDC_OPEN, IP_TR, cx, cy) ;
+ MoveDlgItem( IDC_EXEC, IP_TR, cx, cy) ;
MoveDlgItem( IDC_SEPAR, IP_TR, cx, cy) ;
MoveDlgItem( IDC_ZOOM_ALL, IP_TR, cx, cy) ;
MoveDlgItem( IDC_ZOOM_P, IP_TR, cx, cy) ;
@@ -331,6 +356,18 @@ CTestEGrDlg::ReshapeDlgItem( int nID, int nFlag, int nW, int nH)
return ( pBtn->SetWindowPos( NULL, 0, 0, nWu, nHu, SWP_NOMOVE | SWP_NOZORDER) != 0) ;
}
+//----------------------------------------------------------------------------
+void
+CTestEGrDlg::OutInfo( const string& sOut, bool bLog)
+{
+ CWnd* pWnd = GetDlgItem( IDC_INFO) ;
+ if ( pWnd != nullptr)
+ pWnd->SetWindowText( stringtoW( sOut)) ;
+
+ if ( bLog)
+ LOG_INFO( m_pLogger, sOut.c_str())
+}
+
//----------------------------------------------------------------------------
void
CTestEGrDlg::OnClose( void)
@@ -352,6 +389,17 @@ CTestEGrDlg::OnClose( void)
EndDialog( IDCLOSE) ;
}
+//----------------------------------------------------------------------------
+void
+CTestEGrDlg::OnFileNew( void)
+{
+ // pulizia e reinizializzazione del DB geometrico
+ m_pGeomDB->Clear() ;
+ m_pGeomDB->Init() ;
+ // visualizzo con zoom all
+ m_View.Zoom( IDC_ZOOM_ALL) ;
+}
+
//----------------------------------------------------------------------------
void
CTestEGrDlg::OnFileOpen( void)
@@ -403,15 +451,75 @@ CTestEGrDlg::OnFileOpen( void)
m_View.Zoom( IDC_ZOOM_ALL) ;
Counter.Stop() ;
string sOut = "First ZoomAll time = " + ToString( Counter.GetTime(), 2) + " ms" ;
- // eseguo ridisegno
- Counter.Start() ;
- m_View.Redraw() ;
- Counter.Stop() ;
- sOut += " Redraw time = " + ToString( Counter.GetTime(), 2) + " ms" ;
// emetto info
- GetDlgItem( IDC_INFO)->SetWindowText( stringtoW( sOut)) ;
- LOG_INFO( m_pLogger, sOut.c_str())
+ ::OutInfo( sOut) ;
+}
+//----------------------------------------------------------------------------
+void
+CTestEGrDlg::OnFileExec( void)
+{
+ PtrOwner pGdbExec( CreateGdbExecutor()) ;
+ PtrOwner pSceExec( CreateSceExecutor()) ;
+ PtrOwner pCmdParser( CreateCmdParser()) ;
+
+ // controllo validità oggetti
+ if ( ! IsValid( pGdbExec)) {
+ AfxMessageBox( L"Error in CreateGdbExecutor", MB_ICONSTOP|MB_OK) ;
+ return ;
+ }
+ if ( ! IsValid( pSceExec)) {
+ AfxMessageBox( L"Error in CreateSceExecutor", MB_ICONSTOP|MB_OK) ;
+ return ;
+ }
+ if ( ! IsValid( pCmdParser)) {
+ AfxMessageBox( L"Error in CreateCmdParser", MB_ICONSTOP|MB_OK) ;
+ return ;
+ }
+ // verifico validità DB geometrico
+ if ( m_pGeomDB == nullptr) {
+ AfxMessageBox( L"Error in CreateGeomDB", MB_ICONSTOP|MB_OK) ;
+ return ;
+ }
+
+ // visualizzo il dialogo di scelta file
+ CFileDialog dlg( TRUE, L"*.Tsc", NULL,
+ OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST|OFN_HIDEREADONLY|OFN_NOCHANGEDIR,
+ L"Test script EgalTech (*.Tsc) |*.Tsc|", NULL, 0, FALSE) ;
+
+ // imposto il direttorio iniziale
+ wstring wsDir = stringtoW( GetPrivateProfileStringUtf8( "General", "LastTscDir", "", AfxGetApp()->m_pszProfileName)) ;
+ if ( ! wsDir.empty())
+ dlg.m_ofn.lpstrInitialDir = wsDir.c_str() ;
+
+ // lancio il dialogo di scelta file
+ if ( dlg.DoModal() != IDOK)
+ return ;
+
+ // recupero la path del file e ne salvo il direttorio
+ string sFilePath = WtoA( dlg.GetPathName()) ;
+ if ( sFilePath.empty())
+ return ;
+ string sFileDir ;
+ string sFileName ;
+ SplitLast( sFilePath, "\\", sFileDir, sFileName) ;
+ if ( ! sFileDir.empty())
+ WritePrivateProfileStringUtf8( "General", "LastTscDir", sFileDir.c_str(), AfxGetApp()->m_pszProfileName) ;
+
+ // esecuzione script
+ pGdbExec->Init( m_pGeomDB) ;
+ pSceExec->Init( m_View.GetScene()) ;
+ pGdbExec->AddExecutor( Get( pSceExec)) ;
+ if ( ! pCmdParser->Init( sFilePath, Get( pGdbExec), m_pLogger, 0)) {
+ string sOut = "Error on Parser.Init (" + sFilePath + ")" ;
+ AfxMessageBox( stringtoW( sOut), MB_ICONSTOP|MB_OK) ;
+ return ;
+ }
+ if ( ! pCmdParser->Run()) {
+ string sOut = "Error on Parser.Run (look at Log file)" ;
+ AfxMessageBox( stringtoW( sOut), MB_ICONSTOP|MB_OK) ;
+ return ;
+ }
}
//----------------------------------------------------------------------------
diff --git a/TestEGrDlg.h b/TestEGrDlg.h
index c468adc..26649ed 100644
--- a/TestEGrDlg.h
+++ b/TestEGrDlg.h
@@ -25,6 +25,9 @@ class CTestEGrDlg : public CDialog
public :
CTestEGrDlg( ILogger* pLogger = 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) ; }
protected :
virtual BOOL OnInitDialog( void) ;
@@ -33,7 +36,9 @@ class CTestEGrDlg : public CDialog
afx_msg void OnPaint( void) ;
afx_msg HCURSOR OnQueryDragIcon( void) ;
afx_msg void OnSize( UINT nType, int cx, int cy) ;
+ afx_msg void OnFileNew( void) ;
afx_msg void OnFileOpen( void) ;
+ afx_msg void OnFileExec( void) ;
afx_msg void OnZoom( UINT nID) ;
afx_msg void OnView( UINT nID) ;
afx_msg void OnClose( void) ;
@@ -47,10 +52,10 @@ class CTestEGrDlg : public CDialog
bool ReshapeDlgItem( int nID, int nFlag, int nW, int nH) ;
private :
- HICON m_hIcon ;
- TestEgrView m_View ;
- ILogger* m_pLogger ;
IGeomDB* m_pGeomDB ;
+ ILogger* m_pLogger ;
+ TestEgrView m_View ;
+ HICON m_hIcon ;
int m_nPrevCx ;
int m_nPrevCy ;
int m_nSideBarW ;
diff --git a/TestEGrUtils.cpp b/TestEGrUtils.cpp
new file mode 100644
index 0000000..5928435
--- /dev/null
+++ b/TestEGrUtils.cpp
@@ -0,0 +1,39 @@
+//----------------------------------------------------------------------------
+// EgalTech 2014-2014
+//----------------------------------------------------------------------------
+// File : TestEGrUtils.cpp Data : 17.02.14 Versione : 1.5b3
+// Contenuto : Implementazione funzioni di utilità
+//
+//
+//
+// Modifiche : 17.02.14 DS Creazione modulo.
+//
+//
+//----------------------------------------------------------------------------
+
+//--------------------------- Include ----------------------------------------
+#include "stdafx.h"
+#include "TestEGrUtils.h"
+#include "TestEGrDlg.h"
+
+using namespace std ;
+
+//----------------------------------------------------------------------------
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#endif
+
+
+//----------------------------------------------------------------------------
+void
+OutInfo( string& sOut, bool bLog)
+{
+ ((CTestEGrDlg*)AfxGetMainWnd())->OutInfo( sOut, bLog) ;
+}
+
+//----------------------------------------------------------------------------
+bool
+GetSceneInfo( string& sInfo)
+{
+ return ((CTestEGrDlg*)AfxGetMainWnd())->GetSceneInfo( sInfo) ;
+}
diff --git a/TestEGrUtils.h b/TestEGrUtils.h
new file mode 100644
index 0000000..855f5b9
--- /dev/null
+++ b/TestEGrUtils.h
@@ -0,0 +1,20 @@
+//----------------------------------------------------------------------------
+// EgalTech 2014-2014
+//----------------------------------------------------------------------------
+// File : TestEGrUtils.h Data : 17.02.14 Versione : 1.5b3
+// Contenuto : Dichiarazione funzioni di utilità.
+//
+//
+//
+// Modifiche : 17.02.14 DS Creazione modulo.
+//
+//
+//----------------------------------------------------------------------------
+
+#pragma once
+
+#include
+
+//----------------------------------------------------------------------------
+void OutInfo( std::string& sOut, bool bLog = true) ;
+bool GetSceneInfo( std::string& sInfo) ;
diff --git a/TestEGrView.h b/TestEGrView.h
index 6420f61..e111797 100644
--- a/TestEGrView.h
+++ b/TestEGrView.h
@@ -4,6 +4,7 @@
#include "/EgtDev/Include/EGkPoint3d.h"
#include
+#include
class IGeomDB ;
class ILogger ;
@@ -16,8 +17,10 @@ class TestEgrView : public CWnd
TestEgrView( void) ;
~TestEgrView( void) ;
bool Create( CWnd* pParent, int nID) ;
- bool StartScene( int nDriver, bool b2Buff, int nColorBits, int nDepthBits,
- IGeomDB* pGeomDB, ILogger* pLogger) ;
+ bool StartScene( int nDriver, bool b2Buff, int nColorBits, int nDepthBits) ;
+ IEGrScene* GetScene( void)
+ { return m_pScene ; }
+ bool GetSceneInfo( std::string& sInfo) ;
void Destroy( void) ;
bool Reshape( int nX, int nY, int nW, int nH) ;
void Redraw( void) ;
@@ -26,6 +29,8 @@ class TestEgrView : public CWnd
protected :
afx_msg void OnPaint( void) ;
+ afx_msg BOOL OnEraseBkgnd( CDC* pDC)
+ { return TRUE ; }
afx_msg void OnMButtonDown( UINT nFlags, CPoint point) ;
afx_msg void OnMButtonUp( UINT nFlags, CPoint point) ;
afx_msg void OnMouseMove( UINT nFlags, CPoint point) ;
diff --git a/TestEgrView.cpp b/TestEgrView.cpp
index f4fc116..4151d9e 100644
--- a/TestEgrView.cpp
+++ b/TestEgrView.cpp
@@ -14,12 +14,16 @@
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "TestEgrView.h"
+#include "TestEGrUtils.h"
#include "resource.h"
+#include "/EgtDev/Include/EgtPerfCounter.h"
#include "/EgtDev/Include/EgtILogger.h"
#include "/EgtDev/Include/EgnStringUtils.h"
#include "/EgtDev/Include/EgnStringConverter.h"
#include "/EgtDev/Include/EGrScene.h"
+using namespace std ;
+
//----------------------------------------------------------------------------
#ifdef _DEBUG
#define new DEBUG_NEW
@@ -83,14 +87,12 @@ TestEgrView::Create( CWnd* pParent, int nID)
//----------------------------------------------------------------------------
bool
-TestEgrView::StartScene( int nDriver, bool b2Buff, int nColorBits, int nDepthBits,
- IGeomDB* pGeomDB, ILogger* pLogger)
+TestEgrView::StartScene( int nDriver, bool b2Buff, int nColorBits, int nDepthBits)
{
if ( m_pScene == nullptr)
return false ;
// creazione della scena
- m_pScene->Init( pGeomDB, pLogger) ;
if ( ! m_pScene->CreateContext( GetSafeHdc(), nDriver, b2Buff, nColorBits, nDepthBits))
return false ;
@@ -98,9 +100,19 @@ TestEgrView::StartScene( int nDriver, bool b2Buff, int nColorBits, int nDepthBit
m_pScene->SetCamera( CT_ISO_SW) ;
m_pScene->ZoomAll() ;
- LOG_INFO( pLogger, m_pScene->GetOpenGLInfo().c_str())
- LOG_INFO( pLogger, m_pScene->GetGLSLInfo().c_str())
- LOG_INFO( pLogger, m_pScene->GetPixelFormatInfo().c_str())
+ return true ;
+}
+
+//----------------------------------------------------------------------------
+bool
+TestEgrView::GetSceneInfo( string& sInfo)
+{
+ if ( m_pScene == nullptr)
+ return false ;
+
+ sInfo = m_pScene->GetOpenGLInfo() + '\n' +
+ m_pScene->GetGLSLInfo() + '\n' +
+ m_pScene->GetPixelFormatInfo() ;
return true ;
}
@@ -134,9 +146,18 @@ TestEgrView::OnPaint( void)
if ( m_pScene == nullptr)
return ;
+ PerformanceCounter Counter ;
+
// ridisegno finestra OpenGL
+ Counter.Start() ;
m_pScene->Draw() ;
ValidateRgn( NULL) ;
+ Counter.Stop() ;
+
+ // emetto info
+ string sOut = "Redraw time = " + ToString( Counter.GetTime(), 2) + " ms" ;
+ ::OutInfo( sOut, false) ;
+
}
//----------------------------------------------------------------------------
diff --git a/res/Logo.bmp b/res/Logo.bmp
new file mode 100644
index 0000000..c827a64
Binary files /dev/null and b/res/Logo.bmp differ
diff --git a/resource.h b/resource.h
index 31cdb28..b907b91 100644
Binary files a/resource.h and b/resource.h differ