[commit] r1546 - trunk/GME/Gme

GMESRC Repository Notifications gme-commit at list.isis.vanderbilt.edu
Fri Sep 16 12:49:02 CDT 2011


Author: ksmyth
Date: Fri Sep 16 12:49:02 2011
New Revision: 1546

Log:
Panning Window refresh can be expensive with large models, do it only when necessary

Modified:
   trunk/GME/Gme/ChildFrm.cpp
   trunk/GME/Gme/ChildFrm.h
   trunk/GME/Gme/GMEPanningWindow.cpp
   trunk/GME/Gme/GMEPanningWindow.h
   trunk/GME/Gme/GMEView.cpp
   trunk/GME/Gme/GMEView.h
   trunk/GME/Gme/MainFrm.cpp

Modified: trunk/GME/Gme/ChildFrm.cpp
==============================================================================
--- trunk/GME/Gme/ChildFrm.cpp	Fri Sep 16 12:48:47 2011	(r1545)
+++ trunk/GME/Gme/ChildFrm.cpp	Fri Sep 16 12:49:02 2011	(r1546)
@@ -5,6 +5,7 @@
 #include "GMEApp.h"
 
 #include "ChildFrm.h"
+#include "MainFrm.h"
 
 #include "GMEView.h"
 
@@ -25,6 +26,7 @@
 	ON_UPDATE_COMMAND_UI(CG_ID_VIEW_MODELPROPERTIESBAR, OnUpdateControlBarMenu)
 	//{{AFX_MSG_MAP(CChildFrame)
 	ON_WM_CLOSE()
+	ON_WM_MDIACTIVATE()
 	//}}AFX_MSG_MAP
 	ON_WM_SIZE()
 END_MESSAGE_MAP()
@@ -190,3 +192,11 @@
 
 	return CMDIChildWndEx::PreTranslateMessage(pMsg);
 }
+
+void CChildFrame::OnMDIActivate(BOOL bActivate,
+		CWnd* pActivateWnd, CWnd* pDeactivateWnd)
+{
+	CMDIChildWndEx::OnMDIActivate(bActivate, pActivateWnd, pDeactivateWnd);
+	if (pActivateWnd == this)
+		((CGMEView*)GetActiveView())->DoPannWinRefresh();
+}

Modified: trunk/GME/Gme/ChildFrm.h
==============================================================================
--- trunk/GME/Gme/ChildFrm.h	Fri Sep 16 12:48:47 2011	(r1545)
+++ trunk/GME/Gme/ChildFrm.h	Fri Sep 16 12:49:02 2011	(r1546)
@@ -32,6 +32,7 @@
 	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
 	//}}AFX_VIRTUAL
 
+
 // Implementation
 public:
 	virtual ~CChildFrame();
@@ -42,6 +43,8 @@
 	void SetAppTitle(const CString& appTitle);
 	void SetSendEvent(bool sendEventParam);
 	void SetView(CView* viewParam);
+	afx_msg void OnMDIActivate(BOOL bActivate,
+		CWnd* pActivateWnd, CWnd* pDeactivateWnd);
 
 #ifdef _DEBUG
 	virtual void AssertValid() const;

Modified: trunk/GME/Gme/GMEPanningWindow.cpp
==============================================================================
--- trunk/GME/Gme/GMEPanningWindow.cpp	Fri Sep 16 12:48:47 2011	(r1545)
+++ trunk/GME/Gme/GMEPanningWindow.cpp	Fri Sep 16 12:49:02 2011	(r1546)
@@ -6,6 +6,7 @@
 #include "GMEPanningWindow.h"
 #include "GMEApp.h"
 #include "MainFrm.h"
+#include "GMEView.h"
 
 
 /////////////////////////////////////////////////////////////////////////////
@@ -132,3 +133,21 @@
 {
 	m_PanningWindowWrapper.SetViewRect(vrect.left, vrect.top, vrect.Width(), vrect.Height());
 }
+
+void CGMEPanningWindow::ShowPane(BOOL bShow, BOOL bDelay, BOOL bActivate/* = TRUE*/)
+{
+	CDockablePane::ShowPane(bShow, bDelay, bActivate);
+	if (bShow)
+	{
+		CMDIChildWnd *pChild  = CMainFrame::theInstance->MDIGetActive();
+		if (pChild) 
+		{
+			CGMEView *view = (CGMEView*)pChild->GetActiveView();
+			if (view) 
+			{
+				view->DoPannWinRefresh();
+				view->notifyPanning(view->GetDeviceScrollPosition());
+			}
+		}
+	}
+}

Modified: trunk/GME/Gme/GMEPanningWindow.h
==============================================================================
--- trunk/GME/Gme/GMEPanningWindow.h	Fri Sep 16 12:48:47 2011	(r1545)
+++ trunk/GME/Gme/GMEPanningWindow.h	Fri Sep 16 12:49:02 2011	(r1546)
@@ -64,6 +64,8 @@
 public:
 	void SetBitmapDC(HWND owner, HDC bdc, HBITMAP oldBmp, CRect& ori, CRect& rect, COLORREF& bkgrnd);
 	void SetViewRect(CRect vrect);
+
+	virtual void ShowPane(BOOL bShow, BOOL bDelay, BOOL bActivate/* = TRUE*/);
 };
 
 //{{AFX_INSERT_LOCATION}}

Modified: trunk/GME/Gme/GMEView.cpp
==============================================================================
--- trunk/GME/Gme/GMEView.cpp	Fri Sep 16 12:48:47 2011	(r1545)
+++ trunk/GME/Gme/GMEView.cpp	Fri Sep 16 12:49:02 2011	(r1546)
@@ -530,7 +530,7 @@
 	m_prnpos						= NULL;
 	m_lastPrnPage					= 0;
 	m_zoomVal						= ZOOM_NO;
-	m_refreshpannwin				= false;
+	m_bEnablePannWindowRefresh = false;
 
 	initDone						= false;
 	isModelAutoRouted				= theApp.useAutoRouting;
@@ -682,6 +682,8 @@
 #define PANNING_RATIO_MIN	4 // ??
 void CGMEView::DoPannWinRefresh()
 {
+	if (!m_bEnablePannWindowRefresh)
+		return;
 //	CMainFrame* main = (CMainFrame*)AfxGetMainWnd();
 	CMainFrame* main = (CMainFrame*)theApp.m_pMainWnd;
 
@@ -993,11 +995,6 @@
 			onScreen->StretchBlt(pt.x - 5, pt.y - 5, r.Width() + 10, r.Height() + 10, offScreen, pt.x - 5, pt.y - 5, r.Width() + 10, r.Height() + 10, SRCCOPY);
 		else
 			onScreen->BitBlt(pt.x - 5, pt.y - 5, r.Width() + 10, r.Height() + 10, offScreen, pt.x - 5, pt.y - 5, SRCCOPY);
-		if (m_refreshpannwin)
-		{
-			m_refreshpannwin = false;
-			DoPannWinRefresh();
-		}
 	}
 }
 
@@ -1111,8 +1108,6 @@
 		CMainFrame::theInstance->SetPartBrowserBg(bgColor);
 		CMainFrame::theInstance->ChangePartBrowserAspect(currentAspect->index);
 	}
-	TRACE(_T("CGMEView::OnInitialUpdate DoPannWinRefresh\n"));
-	DoPannWinRefresh(); // terge - new window opened
 	SetScroll();
 	SetCenterObject(centerObj);
 	initDone = true;
@@ -1985,7 +1980,6 @@
 	if (m_isActive)
 	{
 		TRACE(_T("CGMEView::Reset GetActiveView\n"));
-		/*gmeviewA->*/m_refreshpannwin = true; 
 	}
 	CComPtr<IMgaFCO> selConn;
 	if (selectedConnection != NULL)
@@ -2209,6 +2203,7 @@
 
 	Invalidate(doInvalidate);
 	AutoRoute();
+	DoPannWinRefresh();
 
 	EndWaitCursor();
 
@@ -4295,7 +4290,7 @@
 			if (m_isActive)
 			{
 				TRACE(_T("CGMEView::ChangeAspect activeView\n"));
-				/*gmeviewA->*/m_refreshpannwin = true; 
+				DoPannWinRefresh();
 			}
 			Invalidate();
 		}
@@ -4549,7 +4544,6 @@
 		ClearConnectionSelection();
 
 		TRACE(_T("CGMEView::OnSelChangeAspectProp\n"));
-		m_refreshpannwin = true;
 		Invalidate();
 	}
 }
@@ -7048,12 +7042,10 @@
 	if (m_isActive)
 	{
 		TRACE(_T("CGMEView::OnActivateFrame\n"));
-		/*gmeviewA->*/m_refreshpannwin = true; 
 	}
 	CScrollZoomView::OnActivateFrame(nState, pFrameWnd);
 }
 
-
 void CGMEView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView)
 {
 	CString s = bActivate ? _T("ACTIVATE "):_T("DEACTIVATE ");
@@ -7082,7 +7074,7 @@
 			CMainFrame::theInstance->SetPartBrowserBg(bgColor);
 			CMainFrame::theInstance->ChangePartBrowserAspect(currentAspect->index);
 		}
-		DoPannWinRefresh();
+		needsReset = false;
 	}
 	else if(tmpConnectMode) {
 		tmpConnectMode = false;
@@ -7105,7 +7097,6 @@
 		}
 	}
 	TRACE(_T("CGMEView::OnActivateView final false\n"));
-	m_refreshpannwin = false;
 	if (bActivate)
 		theApp.UpdateMainTitle();
 	CScrollZoomView::OnActivateView(bActivate, pActivateView, pDeactiveView);

Modified: trunk/GME/Gme/GMEView.h
==============================================================================
--- trunk/GME/Gme/GMEView.h	Fri Sep 16 12:48:47 2011	(r1545)
+++ trunk/GME/Gme/GMEView.h	Fri Sep 16 12:49:02 2011	(r1546)
@@ -54,9 +54,6 @@
 	void DoPannWinRefresh();
 
 public:
-	bool m_refreshpannwin;
-
-public:
 	void PrepareAspectPrn(CPrintInfo* pInfo);
 	bool ChangePrnAspect(CString aspect);
 	void SaveCurrAsp() { m_prevcurrasp = currentAspect; }
@@ -97,6 +94,7 @@
 	CGuiObject*				objectInDecoratorOperation;
 	CGuiAnnotator*			annotatorInDecoratorOperation;
 public:
+	bool m_bEnablePannWindowRefresh;
 	struct ContextClickState {
 		UINT		nFlags;
 		CPoint		lpoint;

Modified: trunk/GME/Gme/MainFrm.cpp
==============================================================================
--- trunk/GME/Gme/MainFrm.cpp	Fri Sep 16 12:48:47 2011	(r1545)
+++ trunk/GME/Gme/MainFrm.cpp	Fri Sep 16 12:49:02 2011	(r1546)
@@ -13,6 +13,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include "ChildFrm.h"
+#include "GMEView.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
@@ -662,15 +663,31 @@
 		CDocument *pDocument = CGMEDoc::theInstance;
 		ASSERT( pDocument );
 
+		// KMS: WM_MDIACTIVATE is sent 3 times for tabs after the first: once for the new CChildFrame, once for the old,
+		// and again for the new. Disable panning window refresh, since it can be expensive.
+		CGMEView* oldGmeview = CGMEView::GetActiveView();
+		if (oldGmeview)
+			oldGmeview->m_bEnablePannWindowRefresh = false;
 		CFrameWnd *pFrame = docTemplate->CreateNewFrame(pDocument, NULL);
 		if(pFrame == NULL) {
 			AfxMessageBox(_T("Failed to create window"),MB_OK | MB_ICONSTOP);
 			return;
 		}
 		docTemplate->InitialUpdateFrame(pFrame,pDocument);
-		m_wndClientArea.UpdateMDITabbedGroups(TRUE);  // The framework by default calls this via OnUpdateFrameTitle 
+		HWND hwndActive = (HWND) m_wndClientArea.SendMessage(WM_MDIGETACTIVE);
+
+		m_wndClientArea.UpdateMDITabbedGroups(FALSE);  // The framework by default calls this via OnUpdateFrameTitle 
 		                                              // (overloaded in our implementation without calling the base class intentionally)
 
+		CGMEView* newGmeview = CGMEView::GetActiveView();
+
+		if (oldGmeview)
+		{
+			oldGmeview->m_bEnablePannWindowRefresh = true;
+		}
+		newGmeview->m_bEnablePannWindowRefresh = true;
+		newGmeview->DoPannWinRefresh();
+
 #if defined(ACTIVEXGMEVIEW)
 		CMainFrame* pMainFrame = (CMainFrame*)theApp.m_pMainWnd;
 		// Get the active MDI child window.


More information about the gme-commit mailing list