TestEGr 1.5b3 :

- gestione dello sfondo graduato
- adattamenti per modifiche a ICmdParser.
This commit is contained in:
Dario Sassi
2014-02-25 16:43:01 +00:00
parent 859537bbf4
commit 79a8075abc
6 changed files with 77 additions and 24 deletions
+2
View File
@@ -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) ;
SetEGnLogger( &logger) ;
SetENkLogger( &logger) ;
SetEGkLogger( &logger) ;
SetEGrLogger( &logger) ;
BIN
View File
Binary file not shown.
+66 -18
View File
@@ -105,7 +105,7 @@ BEGIN_MESSAGE_MAP( CTestEGrDlg, CDialog)
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_ZOOM_ALL, IDC_ZOOM_OUT, OnZoom)
ON_CONTROL_RANGE( BN_CLICKED, IDC_VIEW_TOP, IDC_VIEW_ISO, OnView)
ON_BN_CLICKED( IDC_CLOSE, OnClose)
END_MESSAGE_MAP()
@@ -159,6 +159,10 @@ CTestEGrDlg::OnInitDialog( void)
else
LOG_ERROR( m_pLogger, "Error in CreateGeomDB")
// creo la vista per la sciena
if ( ! m_View.Create( this, IDC_SCENE))
LOG_ERROR( m_pLogger, "Error in CreateSceneView")
// recupero i parametri della scena
int nDriver = GetPrivateProfileInt( "OpenGL", "Driver", 2, AfxGetApp()->m_pszProfileName) ;
bool b2Buff = ( GetPrivateProfileInt( "OpenGL", "DoubleBuffer", 1, AfxGetApp()->m_pszProfileName) == 1) ;
@@ -166,8 +170,21 @@ CTestEGrDlg::OnInitDialog( void)
int nDepthBits = GetPrivateProfileInt( "OpenGL", "DepthBits", 16, AfxGetApp()->m_pszProfileName) ;
// creazione della scena
if ( m_View.Create( this, IDC_SCENE) &&
m_View.StartScene( nDriver, b2Buff, nColorBits, nDepthBits))
if ( ! m_View.StartScene( nDriver, b2Buff, nColorBits, nDepthBits))
LOG_ERROR( m_pLogger, "Error in StartScene")
// recupero i colori dello sfondo
Color ColorTop( 186, 203, 226) ;
GetIniBackColor( "Scene", "BackTop", ColorTop) ;
Color ColorBottom( 102, 102, 102) ;
GetIniBackColor( "Scene", "BackBottom", ColorBottom) ;
// imposto lo sfondo
if ( m_View.GetScene() != nullptr)
m_View.GetScene()->SetBackground( ColorTop, ColorBottom) ;
// imposto il DB geometrico
if ( m_View.GetScene() != nullptr)
m_View.GetScene()->Init( m_pGeomDB) ;
// log con info sulla scena
@@ -176,13 +193,46 @@ CTestEGrDlg::OnInitDialog( void)
LOG_INFO( m_pLogger, sSceneInfo.c_str())
// recupero il posizionamento della finestra del dialogo
string sTmp = GetPrivateProfileStringUtf8( "General", "WinPlace", "", AfxGetApp()->m_pszProfileName) ;
WINDOWPLACEMENT winPlace ;
if ( GetIniWinPlace( "General", "WinPlace", winPlace))
SetWindowPlacement( &winPlace) ;
return TRUE ; // return TRUE unless you set the focus to a control
}
//----------------------------------------------------------------------------
bool
CTestEGrDlg::GetIniBackColor( const char* szSection, const char* szKey, Color& colBack)
{
string sTmp = GetPrivateProfileStringUtf8( szSection, szKey, "", AfxGetApp()->m_pszProfileName) ;
if ( ! sTmp.empty()) {
STRVECTOR vsParams ;
Tokenize( sTmp, ",", vsParams) ;
if ( vsParams.size() == 5) {
if ( vsParams.size() >= 3) {
int nRed ;
FromString( vsParams[0], nRed) ;
int nGreen ;
FromString( vsParams[1], nGreen) ;
int nBlue ;
FromString( vsParams[2], nBlue) ;
colBack.Set( nRed, nGreen, nBlue) ;
return true ;
}
}
return false ;
}
//----------------------------------------------------------------------------
bool
CTestEGrDlg::GetIniWinPlace( const char* szSection, const char* szKey, WINDOWPLACEMENT& winPlace)
{
string sTmp = GetPrivateProfileStringUtf8( szSection, szKey, "", AfxGetApp()->m_pszProfileName) ;
if ( ! sTmp.empty()) {
STRVECTOR vsParams ;
Tokenize( sTmp, ",", vsParams) ;
if ( vsParams.size() >= 5) {
int nVal ;
WINDOWPLACEMENT winPlace ;
winPlace.length = sizeof( WINDOWPLACEMENT) ;
winPlace.flags = 0 ;
FromString( vsParams[0], nVal) ;
@@ -195,11 +245,11 @@ CTestEGrDlg::OnInitDialog( void)
winPlace.rcNormalPosition.right = nVal ;
FromString( vsParams[4], nVal) ;
winPlace.rcNormalPosition.bottom = nVal ;
SetWindowPlacement( &winPlace) ;
return true ;
}
}
return TRUE ; // return TRUE unless you set the focus to a control
return false ;
}
//----------------------------------------------------------------------------
@@ -266,8 +316,8 @@ CTestEGrDlg::OnSize( UINT nType, int cx, int 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) ;
MoveDlgItem( IDC_ZOOM_M, IP_TR, cx, cy) ;
MoveDlgItem( IDC_ZOOM_IN, IP_TR, cx, cy) ;
MoveDlgItem( IDC_ZOOM_OUT, IP_TR, cx, cy) ;
MoveDlgItem( IDC_VIEW_TOP, IP_TR, cx, cy) ;
MoveDlgItem( IDC_VIEW_FRONT, IP_TR, cx, cy) ;
MoveDlgItem( IDC_VIEW_BACK, IP_TR, cx, cy) ;
@@ -507,17 +557,15 @@ CTestEGrDlg::OnFileExec( void)
WritePrivateProfileStringUtf8( "General", "LastTscDir", sFileDir.c_str(), AfxGetApp()->m_pszProfileName) ;
// esecuzione script
pGdbExec->Init( m_pGeomDB) ;
pSceExec->Init( m_View.GetScene()) ;
pSceExec->SetScene( m_View.GetScene()) ;
pGdbExec->SetGeomDB( m_pGeomDB) ;
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) ;
if ( ! pCmdParser->Init( Get( pGdbExec), 0)) {
AfxMessageBox( L"Error on Parser.Init", 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) ;
if ( ! pCmdParser->Run( sFilePath)) {
AfxMessageBox( L"Error on Parser.Run (look at Log file)", MB_ICONSTOP|MB_OK) ;
return ;
}
}
+3
View File
@@ -14,6 +14,7 @@
#pragma once
#include "TestEgrView.h"
#include "/EgtDev/Include/EGkColor.h"
class ILogger ;
@@ -48,6 +49,8 @@ class CTestEGrDlg : public CDialog
enum ItemReshape { IR_W = 1, IR_H, IR_WH} ;
private :
bool GetIniBackColor( const char* szSection, const char* szKey, Color& colBack) ;
bool GetIniWinPlace( const char* szSection, const char* szKey, WINDOWPLACEMENT& winPlace) ;
bool MoveDlgItem( int nID, int nPos, int cx, int cy) ;
bool ReshapeDlgItem( int nID, int nFlag, int nW, int nH) ;
+6 -6
View File
@@ -174,18 +174,18 @@ TestEgrView::Zoom( UINT nID)
if ( m_pScene == nullptr)
return ;
const double COEFF_PLUS = 0.9 ;
const double COEFF_MINUS = 1 / COEFF_PLUS ;
const double COEFF_IN = 0.9 ;
const double COEFF_OUT = 1 / COEFF_IN ;
switch ( nID) {
case IDC_ZOOM_ALL :
m_pScene->ZoomAll() ;
break ;
case IDC_ZOOM_P :
m_pScene->ZoomChange( COEFF_PLUS) ;
case IDC_ZOOM_IN :
m_pScene->ZoomChange( COEFF_IN) ;
break ;
case IDC_ZOOM_M :
m_pScene->ZoomChange( COEFF_MINUS) ;
case IDC_ZOOM_OUT :
m_pScene->ZoomChange( COEFF_OUT) ;
break ;
default :
return ;
BIN
View File
Binary file not shown.