From 79a8075abca1219781faee055dec5e3d3d77d3d4 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 25 Feb 2014 16:43:01 +0000 Subject: [PATCH] TestEGr 1.5b3 : - gestione dello sfondo graduato - adattamenti per modifiche a ICmdParser. --- TestEGr.cpp | 2 ++ TestEGr.rc | Bin 20120 -> 20128 bytes TestEGrDlg.cpp | 84 +++++++++++++++++++++++++++++++++++++----------- TestEGrDlg.h | 3 ++ TestEgrView.cpp | 12 +++---- resource.h | Bin 3466 -> 3376 bytes 6 files changed, 77 insertions(+), 24 deletions(-) diff --git a/TestEGr.cpp b/TestEGr.cpp index cc7da86..eb517c4 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) ; + SetEGnLogger( &logger) ; + SetENkLogger( &logger) ; SetEGkLogger( &logger) ; SetEGrLogger( &logger) ; diff --git a/TestEGr.rc b/TestEGr.rc index bd62871f6d4d5e01fdd344cd39f53fdb90160a85..5f85ffffeda6325530c9dbd35a5701e0e5834e0a 100644 GIT binary patch delta 112 zcmbO+mvO;d#tjMr%$^K+lluk4fwbRbYk@#ke}+89gpK9jJ lK*~_7ka6=pX)_S}rk*v33RGIof~)|{gUbPxw;2mb0{|VkAb|h? delta 161 zcmZ25mvP2i#tjMr(h3aP3`z_-44w=w49*Pk3{edJKQtDc#LpMox^IpGaE(`I{f=StEp97&o6%HUkNxt6rgvsX9ys0Od&~ AegFUf diff --git a/TestEGrDlg.cpp b/TestEGrDlg.cpp index f75f578..785512e 100644 --- a/TestEGrDlg.cpp +++ b/TestEGrDlg.cpp @@ -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 ; } } diff --git a/TestEGrDlg.h b/TestEGrDlg.h index 26649ed..139b8c2 100644 --- a/TestEGrDlg.h +++ b/TestEGrDlg.h @@ -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) ; diff --git a/TestEgrView.cpp b/TestEgrView.cpp index 4151d9e..b6e178c 100644 --- a/TestEgrView.cpp +++ b/TestEgrView.cpp @@ -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 ; diff --git a/resource.h b/resource.h index b907b91c9d1aa8bd58076669900facb3249d28de..803b964fb13b5d178081b17e0236cdd1e5e36202 100644 GIT binary patch delta 43 zcmeB@-XOJM8}nuXmMe_Ro(z7IH!^8Ye!#>sS&U7K)t@1hA!M>4tN!K^HZgVpDyR$* delta 55 zcmdlW)g`@Q8#AvHgC|1>gD-<4LjZ%}