[commit] r2452 - trunk/GME/Gme
GMESRC Repository Notifications
gme-commit at list.isis.vanderbilt.edu
Thu Feb 27 12:14:57 CST 2014
Author: ksmyth
Date: Thu Feb 27 12:14:57 2014
New Revision: 2452
Log:
Connection>Jump to (src|dst) and Jump along (Incoming|Outgoing) Connection: highlight the connection that was followed. This especially useful when centering the endpoint modifies the scrollbars.
Added:
trunk/GME/Gme/GMEViewOverlay.cpp
trunk/GME/Gme/GMEViewOverlay.h
Modified:
trunk/GME/Gme/GME.vcxproj
trunk/GME/Gme/GME.vcxproj.filters
trunk/GME/Gme/GMEView.cpp
trunk/GME/Gme/GMEView.h
trunk/GME/Gme/GUIObject.h
Modified: trunk/GME/Gme/GME.vcxproj
==============================================================================
--- trunk/GME/Gme/GME.vcxproj Thu Feb 27 12:14:44 2014 (r2451)
+++ trunk/GME/Gme/GME.vcxproj Thu Feb 27 12:14:57 2014 (r2452)
@@ -327,6 +327,7 @@
<ClCompile Include="GmePrintDialog.cpp" />
<ClCompile Include="GMESearch.cpp" />
<ClCompile Include="GMEView.cpp" />
+ <ClCompile Include="GMEViewOverlay.cpp" />
<ClCompile Include="GMEVistaUtil.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
@@ -495,6 +496,7 @@
<ClInclude Include="GMEStd.h" />
<ClInclude Include="GMEVersion.h" />
<ClInclude Include="GMEView.h" />
+ <ClInclude Include="GMEViewOverlay.h" />
<ClInclude Include="GraphicsUtil.h" />
<ClInclude Include="GuiMeta.h" />
<ClInclude Include="GUIObject.h" />
Modified: trunk/GME/Gme/GME.vcxproj.filters
==============================================================================
--- trunk/GME/Gme/GME.vcxproj.filters Thu Feb 27 12:14:44 2014 (r2451)
+++ trunk/GME/Gme/GME.vcxproj.filters Thu Feb 27 12:14:57 2014 (r2452)
@@ -243,6 +243,9 @@
<ClCompile Include="SVNDialogSSLServerTrust.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="GMEViewOverlay.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="AnnotatorEventSink.rgs">
@@ -620,6 +623,9 @@
<ClInclude Include="SVNDialogSSLServerTrust.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="GMEViewOverlay.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="GME.rc">
Modified: trunk/GME/Gme/GMEView.cpp
==============================================================================
--- trunk/GME/Gme/GMEView.cpp Thu Feb 27 12:14:44 2014 (r2451)
+++ trunk/GME/Gme/GMEView.cpp Thu Feb 27 12:14:57 2014 (r2452)
@@ -562,6 +562,7 @@
ON_COMMAND(ID_VIEW_HISTORYFORWKEY, OnHistoryForw)
ON_COMMAND(ID_MULTIUSER_SHOWOWNER, OnViewMultiUserShowObjectOwner)
ON_UPDATE_COMMAND_UI( ID_MULTIUSER_SHOWOWNER, OnUpdateViewMultiUserShowObjectOwner)
+ ON_WM_KILLFOCUS()
ON_COMMAND(ID_VIEW_SHOWCONNECTEDPORTSONLY, &CGMEView::OnViewShowconnectedportsonly)
ON_UPDATE_COMMAND_UI(ID_VIEW_SHOWCONNECTEDPORTSONLY, &CGMEView::OnUpdateViewShowconnectedportsonly)
@@ -1511,6 +1512,7 @@
void CGMEView::OnSize(UINT nType, int cx, int cy)
{
+ m_overlay = nullptr;
CScrollZoomView::OnSize(nType, cx, cy);
}
@@ -3058,6 +3060,7 @@
modelGrid.Clear();
FillModelGrid();
}
+ m_overlay = nullptr;
SetScroll();
CScrollZoomView::Invalidate();
}
@@ -7512,6 +7515,7 @@
//I tried logging pActivateView and pDeactiveView, but they always seemed to be "this"
//anyways, OnActivateView is called on both views, so you would know if going from
//one to another by the ACTIVATE/DEACTIVATE - Brian
+ m_overlay = nullptr;
if (bActivate && (!initDone || needsReset)) {
if( theApp.isHistoryEnabled())
@@ -8464,7 +8468,89 @@
selectedContextConnection = NULL;
}
-bool jumpToSelectedEnd( CGuiConnectionList& p_collOfConns, bool p_reverse, bool p_tryPort)
+void CGMEView::OnKillFocus(CWnd* pNewWnd)
+{
+ bool destroyOverlay = true;
+ CString name;
+ if (pNewWnd)
+ {
+ CWnd* parent = pNewWnd->GetParent();
+ CWnd* wnd = pNewWnd;
+ while (wnd)
+ {
+ if (wnd == parent)
+ {
+ destroyOverlay = false;
+ break;
+ }
+ wnd = wnd->GetParent();
+ }
+ }
+ if (destroyOverlay)
+ {
+ //overlay = nullptr;
+ }
+}
+
+void CGMEView::HighlightConnection(CGuiConnection* connection)
+{
+ m_overlay = std::unique_ptr<GMEViewOverlay>(new GMEViewOverlay());
+ CRect rect;
+ GetWindowRect(&rect);
+ if (this->GetStyle() & WS_VSCROLL)
+ {
+ rect.right -= GetSystemMetrics(SM_CXVSCROLL);
+ }
+ if (this->GetStyle() & WS_HSCROLL)
+ {
+ rect.bottom -= GetSystemMetrics(SM_CYHSCROLL);
+ }
+ rect.top++;
+ rect.left++;
+ rect.right--;
+ rect.bottom--;
+ LPCTSTR pszClassName = _T("GMEViewOverlay");
+ WNDCLASS wndcls = {0};
+ if (!::GetClassInfo(AfxGetInstanceHandle(), pszClassName, &wndcls))
+ {
+ wndcls.style = CS_VREDRAW | CS_HREDRAW;
+ wndcls.lpszClassName = pszClassName;
+ wndcls.lpfnWndProc = AfxWndProc;
+ wndcls.hInstance = AfxGetInstanceHandle();
+ VERIFY(::RegisterClass(&wndcls));
+ }
+
+ if (m_overlay->CreateEx(0 /* GMEViewOverlay::style*/, L"GMEViewOverlay", NULL, GMEViewOverlay::exstyle, rect, 0, 0, 0) == FALSE)
+ {
+ ASSERT(false);
+ return;
+ }
+
+ bool selected = connection->IsSelected();
+ connection->SetSelect(true);
+
+ m_overlay->Init1();
+ if (1) {
+ OnPrepareDC(m_overlay->m_memcdc, NULL);
+ CPoint point = m_overlay->m_memcdc->GetViewportOrg();
+ {
+ Gdiplus::Graphics gdip(*m_overlay->m_memcdc);
+ //gdip.Clear(Gdiplus::Color(0));
+ //gdip.SetTransform(
+ gdip.SetSmoothingMode(Gdiplus::SmoothingModeHighQuality);
+ gdip.SetTextRenderingHint(Gdiplus::TextRenderingHintAntiAlias);
+ connection->Draw(*m_overlay->m_memcdc, &gdip);
+ }
+ m_overlay->m_memcdc->SetViewportOrg(0, 0);
+ }
+ m_overlay->Init2();
+
+ connection->SetSelect(selected);
+
+ AfxGetApp()->OnIdle(0); // update button status immediately (ON_UPDATE_COMMAND_UI)
+}
+
+bool CGMEView::jumpToSelectedEnd( CGuiConnectionList& p_collOfConns, bool p_reverse, bool p_tryPort)
{
int hmany = p_collOfConns.GetCount();
@@ -8492,6 +8578,7 @@
CGMEDoc::theInstance->ShowObject( CComPtr<IUnknown>( a_port->mgaFco), TRUE);
else
CGMEDoc::theInstance->ShowObject( CComPtr<IUnknown>( a_neighbor->mgaFco), TRUE);
+ HighlightConnection(a_conn);
return true;
}
}
Modified: trunk/GME/Gme/GMEView.h
==============================================================================
--- trunk/GME/Gme/GMEView.h Thu Feb 27 12:14:44 2014 (r2451)
+++ trunk/GME/Gme/GMEView.h Thu Feb 27 12:14:57 2014 (r2452)
@@ -15,6 +15,7 @@
#include "GuiObject.h"
#include "AspectSyncDlg.h"
#include "ScrollZoomView.h"
+#include "GMEViewOverlay.h"
#include <list>
class CViewDriver;
@@ -26,6 +27,15 @@
{
friend class CGMEOLEModel;
friend class CGMEOLEIt;
+ friend class GMEViewOverlay;
+ std::unique_ptr<GMEViewOverlay> m_overlay;
+ void HighlightConnection(CGuiConnection* connection);
+public:
+ virtual BOOL OnScrollBy(CSize sizeScroll, BOOL bDoScroll = TRUE) {
+ m_overlay = nullptr;
+ return __super::OnScrollBy(sizeScroll, bDoScroll);
+ }
+
protected: // create from serialization only
CGMEView();
DECLARE_DYNCREATE(CGMEView)
@@ -241,6 +251,7 @@
bool FollowLine(CGuiConnection* guiConn, bool reverse, bool tryPort);
bool FollowLine(CGuiObject* guiObj, bool reverse, bool tryPort);
bool FollowLine(CGuiPort* guiPort, bool reverse, bool tryPort);
+ bool jumpToSelectedEnd( CGuiConnectionList& p_collOfConns, bool p_reverse, bool p_tryPort);
std::list<CGuiObject*> m_lstSelect;
std::list<CGuiObject*> m_lstUnselect;
void Reset(bool doInvalidate = false);
@@ -405,6 +416,7 @@
virtual void OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView);
virtual void OnActivateFrame( UINT nState, CFrameWnd* pFrameWnd );
//}}AFX_VIRTUAL
+ afx_msg void OnKillFocus(CWnd* pNewWnd);
// Implementation
public:
Added: trunk/GME/Gme/GMEViewOverlay.cpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/GME/Gme/GMEViewOverlay.cpp Thu Feb 27 12:14:57 2014 (r2452)
@@ -0,0 +1,239 @@
+// GMEViewOverlay.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "GMEViewOverlay.h"
+
+
+const UINT_PTR ID_TIMER = 1;
+
+// GMEViewOverlay
+
+IMPLEMENT_DYNAMIC(GMEViewOverlay, CWnd)
+
+GMEViewOverlay::GMEViewOverlay()
+: m_timerID(0)
+{
+}
+
+GMEViewOverlay::~GMEViewOverlay()
+{
+ if (this->m_hWnd)
+ {
+ DestroyWindow();
+ }
+}
+
+void GMEViewOverlay::OnDraw(CDC* pDC)
+{
+ Gdiplus::Graphics gdip(pDC->m_hDC);
+ gdip.SetPageUnit(Gdiplus::UnitPixel);
+
+ Gdiplus::Pen pen(Gdiplus::Color::Blue);
+ CRect rect;
+ GetWindowRect(&rect);
+ Gdiplus::Rect grect(rect.left, rect.top, rect.Width(), rect.Height());
+ VERIFY(gdip.DrawRectangle(&pen, grect) == Gdiplus::Ok);
+}
+
+int GMEViewOverlay::OnCreate(LPCREATESTRUCT lpCreateStruct)
+{
+ lpCreateStruct->dwExStyle |= GMEViewOverlay::exstyle;
+ lpCreateStruct->style |= GMEViewOverlay::style;
+ //lpCreateStruct->style |= WS_DISABLED;
+ // SystemParametersInfo(SPI_GETSELECTIONFADE, 0, &fFade, 0);
+ //CreateWindowEx(exstyle,
+ if (__super::OnCreate(lpCreateStruct) == -1)
+ return -1;
+
+ return 0;
+}
+
+template<typename int_>
+int_ RoundUpTo4(int_ val)
+{
+ int_ mask = 0;
+ mask = (~mask) ^ 3;
+ return (val + 3) & mask;
+}
+
+void GMEViewOverlay::Init1()
+{
+ DWORD exstyle = GMEViewOverlay::exstyle;
+ DWORD style = GMEViewOverlay::style;
+
+ VERIFY(ModifyStyleEx(0, exstyle));
+ VERIFY(ModifyStyle(0, style));
+ //DWORD style = GetStyle();
+ //DWORD exstyle = GetExStyle();
+
+ GdiFlush();
+
+ CRect rcWindow;
+ GetWindowRect(&rcWindow);
+ SIZE size = {rcWindow.Width(), rcWindow.Height()};
+
+ CDC screen;
+ screen.Attach(::GetDC(NULL));
+ m_memcdc = new CDC();
+ m_memcdc->CreateCompatibleDC(&screen);
+ // LPVOID bitmapdata = VirtualAlloc(0, RoundUpTo4(size.cx) * RoundUpTo4(size.cy) * 4, MEM_COMMIT, PAGE_READWRITE);
+ // m_bitmap = CreateBitmap(RoundUpTo4(size.cx), RoundUpTo4(size.cy), 1, 32, bitmapdata);
+ m_bitmap = CreateCompatibleBitmap(screen, size.cx, size.cy);
+ ASSERT(m_bitmap);
+
+ BITMAPINFO bmpInfo = {0};
+ bmpInfo.bmiHeader.biSize = sizeof(bmpInfo.bmiHeader);
+ GetDIBits(*m_memcdc, m_bitmap, 0, 0, NULL, &bmpInfo, DIB_RGB_COLORS);
+ // TODO check bmpInfo.bmiHeader.biBitCount==32
+
+ HGDIOBJ old = ::SelectObject(*m_memcdc, m_bitmap);
+ /*/ debugging: draw outline around window
+ {
+ Gdiplus::Graphics gdip(*m_memcdc);
+ gdip.SetSmoothingMode(Gdiplus::SmoothingModeHighQuality);
+ gdip.SetTextRenderingHint(Gdiplus::TextRenderingHintAntiAlias);
+ {
+ CRect rect;
+ GetWindowRect(&rect);
+ Gdiplus::Rect grect(0, 0, rect.Width()-1, rect.Height()-1);
+ Gdiplus::Pen trans(Gdiplus::Color(254, 255, 0, 0), 1);
+ VERIFY(gdip.DrawRectangle(&trans, grect) == Gdiplus::Ok);
+ }
+ }
+ // */
+}
+
+void GMEViewOverlay::Init2()
+{
+ CRect rcWindow;
+ GetWindowRect(&rcWindow);
+ SIZE size = {rcWindow.Width(), rcWindow.Height()};
+ /* debugging: FillRectangle with alpha==255 results in alpha==0
+ {
+ Gdiplus::Graphics gdip(*m_memcdc);
+ gdip.Clear(Gdiplus::Color(0));
+ gdip.SetSmoothingMode(Gdiplus::SmoothingModeHighQuality);
+ gdip.SetTextRenderingHint(Gdiplus::TextRenderingHintAntiAlias);
+ // doesnt matter gdip.SetCompositingMode( Gdiplus::CompositingModeSourceCopy );
+ {
+ CRect rect;
+ GetWindowRect(&rect);
+ Gdiplus::Rect grect(0, 0, 32, rect.Height()/2);
+ Gdiplus::SolidBrush trans(Gdiplus::Color(180, 255, 0, 0));
+ VERIFY(gdip.FillRectangle(&trans, grect) == Gdiplus::Ok);
+ }
+ {
+ CRect rect;
+ GetWindowRect(&rect);
+ Gdiplus::Rect grect(32, 0, 50, rect.Height()/2);
+ Gdiplus::SolidBrush trans(Gdiplus::Color(255, 250, 0, 0));
+ VERIFY(gdip.FillRectangle(&trans, grect) == Gdiplus::Ok);
+ }
+ } */
+
+ BITMAPINFO bmi = {0};
+ bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader);
+ bmi.bmiHeader.biBitCount = 32;
+ bmi.bmiHeader.biCompression = BI_RGB;
+ bmi.bmiHeader.biHeight = size.cy;
+ bmi.bmiHeader.biWidth = size.cx;
+ bmi.bmiHeader.biPlanes=1;
+ LPVOID bits = VirtualAlloc(0, RoundUpTo4(size.cx) * RoundUpTo4(size.cy) * 4, MEM_COMMIT, PAGE_READWRITE);
+ //auto dibits2 = GetDIBits(*m_memcdc, m_bitmap, size.cy/2+9, size.cy/2-10, bits, &bmi, DIB_RGB_COLORS);
+
+ int dibits = GetDIBits(*m_memcdc, m_bitmap, 0, size.cy, bits, &bmi, DIB_RGB_COLORS);
+ ASSERT(dibits);
+ // GDI+ sets the alpha value to 0 if the source is 255. fix it
+ // (GDI always sets alpha to 0. Fix that too)
+ for (int i = 0; i < size.cy; i++)
+ {
+ for (int j = 0; j < size.cx; j++)
+ {
+ int *argb = ((int*)bits) + size.cx * i + j;
+ if ((*argb & 0x00FFFFFF) && (*argb & 0xFF000000) == 0)
+ {
+ *argb = *argb | 0xFF000000;
+ }
+ // assert premultiplied
+ ASSERT(((*argb & 0xFF000000) >> 24) >= ((*argb & 0x00FF0000) >> 16));
+ ASSERT(((*argb & 0xFF000000) >> 24) >= ((*argb & 0x0000FF00) >> 8));
+ ASSERT(((*argb & 0xFF000000) >> 24) >= ((*argb & 0x000000FF)));
+ }
+ }
+ dibits = SetDIBits(*m_memcdc, m_bitmap, 0, size.cy, bits, &bmi, DIB_RGB_COLORS);
+ VERIFY(dibits);
+ VirtualFree(bits, 0, MEM_RELEASE);
+
+ //VERIFY(::SelectObject(*m_memcdc, m_bitmap));
+
+ ASSERT(GetSafeHwnd());
+ ::SetWindowPos(GetSafeHwnd(), HWND_TOPMOST, 0, 0, 0, 0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE);
+ POINT ptZero = {0, 0};
+ POINT ptDest = {rcWindow.left+1, rcWindow.top+1};
+ m_opacity = 0;
+ BLENDFUNCTION blend = { AC_SRC_OVER, 0, 254, AC_SRC_ALPHA};
+ CDC screen;
+ screen.Attach(::GetDC(NULL));
+ // m_memcdc RGB is premultiplied with alpha
+ VERIFY(UpdateLayeredWindow(&screen, &ptDest, &size, m_memcdc, &ptZero, 0, &blend, ULW_ALPHA));
+
+ m_timerID = SetTimer(2, 75, NULL);
+}
+
+
+BEGIN_MESSAGE_MAP(GMEViewOverlay, CWnd)
+ ON_WM_CLOSE()
+ ON_WM_CREATE()
+ ON_WM_TIMER()
+END_MESSAGE_MAP()
+
+
+
+// GMEViewOverlay message handlers
+
+void GMEViewOverlay::OnClose()
+{
+ CWnd::OnClose();
+}
+
+// Fade out, in, then out
+//[254 - i * 22 for i in range(6)] + [254 - i * 22 for i in range(6, 0, -1)] + [254 - i * 19 for i in range(13)] + [0]
+static BYTE opacities[] = { 254, 232, 210, 188, 166, 144, 122, 144, 166, 188, 210, 232, 254, 235, 216, 197, 178, 159, 140, 121, 102, 83, 64, 45, 26, 0 };
+
+void GMEViewOverlay::OnTimer(UINT_PTR nIDEvent)
+{
+ m_opacity++;
+ if (opacities[m_opacity] == 0)
+ {
+ DestroyWindow();
+ return;
+ }
+ BLENDFUNCTION blend;
+ blend.BlendOp = AC_SRC_OVER;
+ blend.BlendFlags = 0;
+ blend.SourceConstantAlpha = opacities[m_opacity];
+ blend.AlphaFormat = 0;
+ blend.AlphaFormat = AC_SRC_ALPHA;
+
+ VERIFY(UpdateLayeredWindow(NULL, NULL, NULL, NULL, NULL, 0, &blend, ULW_ALPHA));
+
+ CWnd::OnTimer(nIDEvent);
+}
+
+BOOL GMEViewOverlay::DestroyWindow()
+{
+ if (m_timerID)
+ {
+ int ret = KillTimer(m_timerID);
+ if (ret != 0)
+ {
+ auto err = GetLastError();
+ ASSERT(false);
+ }
+ }
+ VERIFY(DeleteObject(m_bitmap));
+ VERIFY(m_memcdc->DeleteDC());
+
+ return CWnd::DestroyWindow();
+}
Added: trunk/GME/Gme/GMEViewOverlay.h
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/GME/Gme/GMEViewOverlay.h Thu Feb 27 12:14:57 2014 (r2452)
@@ -0,0 +1,42 @@
+#pragma once
+
+
+// GMEViewOverlay
+
+class GMEViewOverlay : public CWnd
+{
+ DECLARE_DYNAMIC(GMEViewOverlay)
+ int m_opacity;
+ UINT_PTR m_timerID;
+ HBITMAP m_bitmap;
+public:
+ CDC* m_memcdc;
+public:
+ GMEViewOverlay();
+ virtual ~GMEViewOverlay();
+
+protected:
+ DECLARE_MESSAGE_MAP()
+public:
+ afx_msg void OnClose();
+ afx_msg void OnTimer(UINT_PTR nIDEvent);
+ virtual BOOL DestroyWindow();
+
+public:
+ afx_msg void PostNcDestroy()
+ {
+ // need to remove timer events from queue
+ // delete this;
+ }
+ afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
+ void OnDraw(CDC* pDC);
+ void Init1();
+ void Init2();
+ const static DWORD exstyle = WS_EX_LAYERED
+ | WS_EX_TRANSPARENT
+ | WS_EX_TOPMOST
+ | WS_EX_TOOLWINDOW
+ | WS_EX_NOACTIVATE;
+ ;
+ const static DWORD style = WS_POPUP | WS_VISIBLE;
+};
Modified: trunk/GME/Gme/GUIObject.h
==============================================================================
--- trunk/GME/Gme/GUIObject.h Thu Feb 27 12:14:44 2014 (r2451)
+++ trunk/GME/Gme/GUIObject.h Thu Feb 27 12:14:57 2014 (r2452)
@@ -442,6 +442,7 @@
void GrayOutEndPoints();
void ToggleHover() { hovered = !hovered; }
void SetSelect(bool sel) { selected = sel; }
+ bool IsSelected() { return selected; }
void GiveConnectionEndErroMessage(const TCHAR* mainMsg, const TCHAR* srcOrDst, const CGuiPort* otherPort) const;
void Resolve();
void ReadARPreferences();
More information about the gme-commit
mailing list