diff --git a/TestEGr.rc b/TestEGr.rc
index 5f85fff..2e0e535 100644
Binary files a/TestEGr.rc and b/TestEGr.rc differ
diff --git a/TestEGr.vcxproj b/TestEGr.vcxproj
index d04e8cb..595504c 100644
--- a/TestEGr.vcxproj
+++ b/TestEGr.vcxproj
@@ -203,6 +203,7 @@
+
diff --git a/TestEGr.vcxproj.filters b/TestEGr.vcxproj.filters
index 6277e41..138b45f 100644
--- a/TestEGr.vcxproj.filters
+++ b/TestEGr.vcxproj.filters
@@ -33,6 +33,9 @@
File di risorse
+
+ File di risorse
+
diff --git a/TestEGrDlg.cpp b/TestEGrDlg.cpp
index 785512e..f538c50 100644
--- a/TestEGrDlg.cpp
+++ b/TestEGrDlg.cpp
@@ -173,15 +173,22 @@ CTestEGrDlg::OnInitDialog( void)
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)
+ // recupero i colori dello sfondo e li imposto
+ if ( m_View.GetScene() != nullptr) {
+ Color ColorTop( 186, 203, 226) ;
+ GetIniBackColor( "Scene", "BackTop", ColorTop) ;
+ Color ColorBottom( 102, 102, 102) ;
+ GetIniBackColor( "Scene", "BackBottom", ColorBottom) ;
m_View.GetScene()->SetBackground( ColorTop, ColorBottom) ;
+ }
+
+ // recupero gli attributi del rettangolo per ZoomWin e li imposto
+ if ( m_View.GetScene() != nullptr) {
+ bool bOutline = true ;
+ Color colRect( 0, 0, 0) ;
+ GetIniZoomWinAttrib( "Scene", "ZoomWin", bOutline, colRect) ;
+ m_View.GetScene()->SetWinRectAttribs( bOutline, colRect) ;
+ }
// imposto il DB geometrico
if ( m_View.GetScene() != nullptr)
@@ -223,6 +230,33 @@ CTestEGrDlg::GetIniBackColor( const char* szSection, const char* szKey, Color& c
return false ;
}
+//----------------------------------------------------------------------------
+bool
+CTestEGrDlg::GetIniZoomWinAttrib( const char* szSection, const char* szKey,
+ bool& bOutline, Color& colRect)
+{
+ string sTmp = GetPrivateProfileStringUtf8( szSection, szKey, "", AfxGetApp()->m_pszProfileName) ;
+ if ( ! sTmp.empty()) {
+ STRVECTOR vsParams ;
+ Tokenize( sTmp, ",", vsParams) ;
+ if ( vsParams.size() >= 5) {
+ FromString( vsParams[0], bOutline) ;
+ int nRed ;
+ FromString( vsParams[1], nRed) ;
+ int nGreen ;
+ FromString( vsParams[2], nGreen) ;
+ int nBlue ;
+ FromString( vsParams[3], nBlue) ;
+ int nAlpha ;
+ FromString( vsParams[4], nAlpha) ;
+ colRect.Set( nRed, nGreen, nBlue, nAlpha) ;
+ return true ;
+ }
+ }
+
+ return false ;
+}
+
//----------------------------------------------------------------------------
bool
CTestEGrDlg::GetIniWinPlace( const char* szSection, const char* szKey, WINDOWPLACEMENT& winPlace)
diff --git a/TestEGrDlg.h b/TestEGrDlg.h
index 139b8c2..74b837d 100644
--- a/TestEGrDlg.h
+++ b/TestEGrDlg.h
@@ -50,6 +50,8 @@ class CTestEGrDlg : public CDialog
private :
bool GetIniBackColor( const char* szSection, const char* szKey, Color& colBack) ;
+ bool GetIniZoomWinAttrib( const char* szSection, const char* szKey,
+ bool& bOutline, Color& colRect) ;
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.h b/TestEGrView.h
index e111797..26704db 100644
--- a/TestEGrView.h
+++ b/TestEGrView.h
@@ -42,7 +42,7 @@ class TestEgrView : public CWnd
void ShowCursorCoordinates( const Point3d& ptWin) ;
private :
- enum Status { ST_NULL = 0, ST_PAN, ST_ROT } ;
+ enum Status { ST_NULL = 0, ST_PAN, ST_ROT, ST_ZOOMWIN} ;
private :
CClientDC* m_pDC ;
diff --git a/TestEgrView.cpp b/TestEgrView.cpp
index b6e178c..4ec4acc 100644
--- a/TestEgrView.cpp
+++ b/TestEgrView.cpp
@@ -233,7 +233,11 @@ TestEgrView::View( UINT nID)
void
TestEgrView::OnMButtonDown( UINT nFlags, CPoint point)
{
- if ( nFlags & MK_CONTROL) {
+ if ( nFlags & MK_SHIFT) {
+ m_nStatus = ST_ZOOMWIN ;
+ SetCursor( AfxGetApp()->LoadCursor( IDC_ZOOMWIN)) ;
+ }
+ else if ( nFlags & MK_CONTROL) {
m_nStatus = ST_ROT ;
SetCursor( AfxGetApp()->LoadCursor( IDC_ROTATE)) ;
}
@@ -249,7 +253,19 @@ TestEgrView::OnMButtonDown( UINT nFlags, CPoint point)
void
TestEgrView::OnMButtonUp( UINT nFlags, CPoint point)
{
- if ( m_nStatus == ST_ROT || m_nStatus == ST_PAN) {
+ // eseguo ZOOMWINDOWN
+ if ( m_nStatus == ST_ZOOMWIN) {
+ // annullo i dati del rettangolo di definizione della nuova vista
+ if ( m_pScene != nullptr)
+ m_pScene->ResetWinRect() ;
+ // eseguo lo zoom
+ if ( m_pScene != nullptr)
+ m_pScene->ZoomWin( Point3d( m_PrevPoint.x, m_PrevPoint.y), Point3d( point.x, point.y)) ;
+ // aggiorno il disegno
+ RedrawWindow() ;
+ }
+ // reset dello stato se non NULL
+ if ( m_nStatus != ST_NULL) {
m_nStatus = ST_NULL ;
SetCursor( AfxGetApp()->LoadCursor( IDC_POINTER)) ;
}
@@ -261,8 +277,18 @@ TestEgrView::OnMouseMove( UINT nFlags, CPoint point)
{
// visualizzo le coordinate del puntatore
ShowCursorCoordinates( Point3d( point.x, point.y)) ;
+ // se in modalità ZOOMWINDOW
+ if ( m_nStatus == ST_ZOOMWIN && nFlags & MK_MBUTTON) {
+ SetCursor( AfxGetApp()->LoadCursor( IDC_ZOOMWIN)) ;
+ // aggiorno i dati del rettangolo di definizione della nuova vista
+ if ( m_pScene != nullptr)
+ m_pScene->SetWinRect( Point3d( m_PrevPoint.x, m_PrevPoint.y), Point3d( point.x, point.y)) ;
+ // aggiorno il disegno
+ RedrawWindow() ;
+ // il punto di riferimento deve rimanere quello originale
+ }
// se in modalità ROTATE
- if ( m_nStatus == ST_ROT && nFlags & MK_MBUTTON) {
+ else if ( m_nStatus == ST_ROT && nFlags & MK_MBUTTON) {
SetCursor( AfxGetApp()->LoadCursor( IDC_ROTATE)) ;
// eseguo la rotazione
if ( m_pScene != nullptr)
@@ -294,6 +320,10 @@ TestEgrView::OnMouseMove( UINT nFlags, CPoint point)
BOOL
TestEgrView::OnMouseWheel( UINT nFlags, short zDelta, CPoint point)
{
+ // devo essere nello stato NULL
+ if ( m_nStatus != ST_NULL)
+ return 0 ;
+
// calcolo coefficiente
double dCoeff = 1 - 0.1 * abs( zDelta) / WHEEL_DELTA ;
if ( zDelta < 0)
diff --git a/res/zoomwin.cur b/res/zoomwin.cur
new file mode 100644
index 0000000..b1be252
Binary files /dev/null and b/res/zoomwin.cur differ
diff --git a/resource.h b/resource.h
index 803b964..41bbf22 100644
Binary files a/resource.h and b/resource.h differ