From 88cee913085b585ea681dce2cd989ce15ba38f3b Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 15 Apr 2014 14:23:07 +0000 Subject: [PATCH] TestEgr 1.5d5 : - aggiunto stato a bottoni di Vista e di Modo di Visualizzazione. --- TestEGr.rc | Bin 22844 -> 23060 bytes TestEGrDlg.cpp | 81 ++++++++++++++++++++++++++++++++++++++++++++++- TestEGrDlg.h | 3 ++ TestEGrUtils.cpp | 10 +++++- TestEGrUtils.h | 2 ++ TestEGrView.cpp | 2 ++ resource.h | Bin 5010 -> 5102 bytes 7 files changed, 96 insertions(+), 2 deletions(-) diff --git a/TestEGr.rc b/TestEGr.rc index acc7ac1aef1bdfd377b966f97371584f6ffbd06e..7055aa8a173cb195d617eb2f02e22767ff1371fe 100644 GIT binary patch delta 590 zcmdn9iE+vn#tnKxoIwnZ3@!|w4E~cF1;i)&33=%1FgP&;GsH6lFoXhW4+bBgtT%%z z11|#?g8~$y>N+IkLxwIZVHa^6c1<=E)SoOT!m)Xaum&TV6aR?VkzrYysF9-)gARiw zg9(r{W-tSihF~_Sp1mRJM27utVh&{J+9amOXf(M{Oq2}0O5z?kgV&zRbn`s%CKg81 p&5APS%s`6KJfCs%2?Yx5&)&fXjA|I delta 184 zcmbQTg>la&#tnKxlkEhRCI<+)P0kb0n|w#e3ryz-JAvrUUxW=9!3x|&ZNL&IL=D&t z8FUyd8B8W83Rq7L5_15H-w?9{(=p;YjE0jL#YMrqC*mMuc{ck=tYTp_*}PZBoEbSetBackground( ColorTop, ColorBottom) ; } + // recupero il tipo di visualizzazione e lo imposto + if ( m_View.GetScene() != nullptr) { + int nShMode = GetPrivateProfileInt( "Scene", "ShowMode", 0, AfxGetApp()->m_pszProfileName) ; + m_View.GetScene()->SetShowMode( nShMode) ; + UpdateShowModeButtons() ; + } + + // recupero gli angoli di vista e li imposto + if ( m_View.GetScene() != nullptr) { + double dAngVdeg = 0, dAngOdeg = 0 ; + GetViewAngles( "Scene", "View", dAngVdeg, dAngOdeg) ; + m_View.GetScene()->SetCamera( dAngVdeg, dAngOdeg, 0) ; + UpdateViewButtons() ; + } + // recupero gli attributi del rettangolo per ZoomWin e li imposto if ( m_View.GetScene() != nullptr) { bool bOutline = true ; @@ -291,6 +306,24 @@ CTestEGrDlg::OnInitDialog( void) return TRUE ; // return TRUE unless you set the focus to a control } +//---------------------------------------------------------------------------- +bool +CTestEGrDlg::GetViewAngles( const char* szSection, const char* szKey, double& dAngVdeg, double& dAngOdeg) +{ + string sTmp = GetPrivateProfileStringUtf8( szSection, szKey, "", AfxGetApp()->m_pszProfileName) ; + if ( ! sTmp.empty()) { + STRVECTOR vsParams ; + Tokenize( sTmp, ",", vsParams) ; + if ( vsParams.size() >= 2) { + FromString( vsParams[0], dAngVdeg) ; + FromString( vsParams[1], dAngOdeg) ; + return true ; + } + } + + return false ; +} + //---------------------------------------------------------------------------- bool CTestEGrDlg::GetIniColor( const char* szSection, const char* szKey, Color& cCol) @@ -583,6 +616,16 @@ CTestEGrDlg::OnClose( void) if ( ! ManageModified()) return ; + // salvo il tipo di visualizzazione + int nShMode = m_View.GetScene()->GetShowMode() ; + WritePrivateProfileInt( "Scene", "ShowMode", nShMode, AfxGetApp()->m_pszProfileName) ; + + // salvo gli angoli di vista + double dAngVdeg, dAngOdeg ; + m_View.GetScene()->GetCamera( &dAngVdeg, &dAngOdeg) ; + string sOut = ToString( dAngVdeg, 1) + "," + ToString( dAngOdeg, 1) ; + WritePrivateProfileStringUtf8( "Scene", "View", sOut.c_str(), AfxGetApp()->m_pszProfileName) ; + // salvo lo stato della finestra del dialogo WINDOWPLACEMENT winPlace ; if ( GetWindowPlacement( &winPlace)) { @@ -724,6 +767,17 @@ void CTestEGrDlg::OnShowMode( UINT nID) { m_View.ShowMode( nID) ; + UpdateShowModeButtons() ; +} + +//---------------------------------------------------------------------------- +void +CTestEGrDlg::UpdateShowModeButtons( void) +{ + int nSM = m_View.GetScene()->GetShowMode() ; + (( CButton*) GetDlgItem( IDC_WIREFRAME))->SetCheck( ( nSM == SM_WIREFRAME ? BST_CHECKED : BST_UNCHECKED)) ; + (( CButton*) GetDlgItem( IDC_HIDDENLINE))->SetCheck( ( nSM == SM_HIDDENLINE ? BST_CHECKED : BST_UNCHECKED)) ; + (( CButton*) GetDlgItem( IDC_SHADING))->SetCheck( ( nSM == SM_SHADING ? BST_CHECKED : BST_UNCHECKED)) ; } //---------------------------------------------------------------------------- @@ -738,6 +792,20 @@ void CTestEGrDlg::OnView( UINT nID) { m_View.View( nID) ; + UpdateViewButtons() ; +} + +//---------------------------------------------------------------------------- +void +CTestEGrDlg::UpdateViewButtons( void) +{ + int nVw = m_View.GetScene()->GetCameraDir() ; + (( CButton*) GetDlgItem( IDC_VIEW_TOP))->SetCheck( ( nVw == CT_TOP ? BST_CHECKED : BST_UNCHECKED)) ; + (( CButton*) GetDlgItem( IDC_VIEW_FRONT))->SetCheck( ( nVw == CT_FRONT ? BST_CHECKED : BST_UNCHECKED)) ; + (( CButton*) GetDlgItem( IDC_VIEW_BACK))->SetCheck( ( nVw == CT_BACK ? BST_CHECKED : BST_UNCHECKED)) ; + (( CButton*) GetDlgItem( IDC_VIEW_LEFT))->SetCheck( ( nVw == CT_LEFT ? BST_CHECKED : BST_UNCHECKED)) ; + (( CButton*) GetDlgItem( IDC_VIEW_RIGHT))->SetCheck( ( nVw == CT_RIGHT ? BST_CHECKED : BST_UNCHECKED)) ; + (( CButton*) GetDlgItem( IDC_VIEW_ISO))->SetCheck( ( nVw == CT_ISO_SW ? BST_CHECKED : BST_UNCHECKED)) ; } //---------------------------------------------------------------------------- @@ -939,8 +1007,11 @@ CTestEGrDlg::FileSave( const string& sFilePath) string sInfo = "Save File = " + sFilePath ; LOG_INFO( m_pLogGen, sInfo.c_str()) + // recupero flag per salvatggio binario + bool bBin = ( GetPrivateProfileInt( "GeomDB", "BinarySave", 0, AfxGetApp()->m_pszProfileName) == 1) ; + // salvo il file - if ( ! m_pGeomDB->Save( sFilePath)) + if ( ! m_pGeomDB->Save( sFilePath, bBin)) return false ; // log dei comandi LOG_INFO( m_pLogCmd, ( "SAVE( " + sFilePath + ")").c_str()) @@ -985,6 +1056,10 @@ CTestEGrDlg::FileExec( const string& sFilePath) // aggiorno l'albero delle entità LoadTree() ; + // aggiorno stato bottoni + UpdateShowModeButtons() ; + UpdateViewButtons() ; + return bOk ; } @@ -1020,6 +1095,10 @@ CTestEGrDlg::LineExec( const string& sLine) ! SelectIdOnTree( nIdOld)) m_View.Redraw() ; + // aggiorno stato bottoni + UpdateShowModeButtons() ; + UpdateViewButtons() ; + return bOk ; } diff --git a/TestEGrDlg.h b/TestEGrDlg.h index fe2e491..f645634 100644 --- a/TestEGrDlg.h +++ b/TestEGrDlg.h @@ -36,6 +36,8 @@ class CTestEGrDlg : public CDialog bool GetSceneInfo( std::string& sInfo) { return m_View.GetSceneInfo( sInfo) ; } bool LineExec( const std::string& sLine) ; + void UpdateShowModeButtons( void) ; + void UpdateViewButtons( void) ; protected : virtual BOOL OnInitDialog( void) ; @@ -61,6 +63,7 @@ class CTestEGrDlg : public CDialog enum ItemReshape { IR_W = 1, IR_H, IR_WH} ; private : + bool GetViewAngles( const char* szSection, const char* szKey, double& dAngVdeg, double& dAngOdeg) ; bool GetIniColor( const char* szSection, const char* szKey, Color& cCol) ; bool GetIniZoomWinAttrib( const char* szSection, const char* szKey, bool& bOutline, Color& colRect) ; diff --git a/TestEGrUtils.cpp b/TestEGrUtils.cpp index cbf9e1c..9d9bd60 100644 --- a/TestEGrUtils.cpp +++ b/TestEGrUtils.cpp @@ -43,4 +43,12 @@ bool LineExec( const string& sLine) { return ((CTestEGrDlg*)AfxGetMainWnd())->LineExec( sLine) ; -} \ No newline at end of file +} + +//---------------------------------------------------------------------------- +void +UpdateButtons( void) +{ + ((CTestEGrDlg*)AfxGetMainWnd())->UpdateShowModeButtons() ; + ((CTestEGrDlg*)AfxGetMainWnd())->UpdateViewButtons() ; +} diff --git a/TestEGrUtils.h b/TestEGrUtils.h index 8102fac..e46f51f 100644 --- a/TestEGrUtils.h +++ b/TestEGrUtils.h @@ -19,3 +19,5 @@ void OutInfo( const std::string& sOut, bool bLog = true) ; bool GetSceneInfo( std::string& sInfo) ; bool LineExec( const std::string& sLine) ; +void UpdateButtons( void) ; + diff --git a/TestEGrView.cpp b/TestEGrView.cpp index 457a6f8..ecee3f9 100644 --- a/TestEGrView.cpp +++ b/TestEGrView.cpp @@ -319,6 +319,8 @@ TestEGrView::OnMouseMove( UINT nFlags, CPoint point) m_pScene->RotateCamera( Point3d( m_PrevPoint.x, m_PrevPoint.y), Point3d( point.x, point.y)) ; // aggiorno il disegno RedrawWindow() ; + // aggiorno i bottoni + UpdateButtons() ; // salvo il punto di riferimento m_PrevPoint = point ; } diff --git a/resource.h b/resource.h index 36f5e989d494e6c4745a2d73d26f8b8c8f9bef07..51ffd6888c4ade0b26ded82e7f4c6f8eaa4cebc2 100644 GIT binary patch delta 46 zcmbQF{!V>^p5WwdTuPG_xY!ttCI>QVGaE6OZPpZg&In|fPBvr`ot!5mGTBBr3;;Go B3>^Rf delta 24 gcmaE-K1qFpp5W##!AFdfqxdBz7YK<=o*^6t0Cy({zyJUM