[commit] r2060 - trunk/GME/Gme
GMESRC Repository Notifications
gme-commit at list.isis.vanderbilt.edu
Mon Sep 24 10:36:57 CDT 2012
Author: ksmyth
Date: Mon Sep 24 10:36:56 2012
New Revision: 2060
Log:
Add "Reverse connection direction" GMEView connection context menu item
Modified:
trunk/GME/Gme/GME.rc
trunk/GME/Gme/GMEView.cpp
trunk/GME/Gme/GMEView.h
trunk/GME/Gme/GUIObject.cpp
trunk/GME/Gme/GUIObject.h
trunk/GME/Gme/resource.h
Modified: trunk/GME/Gme/GME.rc
==============================================================================
--- trunk/GME/Gme/GME.rc Wed Sep 19 17:49:21 2012 (r2059)
+++ trunk/GME/Gme/GME.rc Mon Sep 24 10:36:56 2012 (r2060)
@@ -530,10 +530,11 @@
END
MENUITEM SEPARATOR
MENUITEM "Delete", ID_CONNCNTX_DELETE
+ MENUITEM "Reverse connection direction", ID_CONNCNTX_REVERSE
MENUITEM SEPARATOR
MENUITEM "Help", ID_CNTX_HELP
MENUITEM SEPARATOR
- MENUITEM "Jump to Source", ID_CONNCNTX_REVERSE
+ MENUITEM "Jump to Source", ID_CONNCNTX_JUMP_SRC
MENUITEM "Jump to Destination", ID_CONNCNTX_FOLLOW
MENUITEM SEPARATOR
MENUITEM "Try to apply horizontal/vertical snap along the whole connection", ID_TRYTOSNAPHORZVERTPATH
Modified: trunk/GME/Gme/GMEView.cpp
==============================================================================
--- trunk/GME/Gme/GMEView.cpp Wed Sep 19 17:49:21 2012 (r2059)
+++ trunk/GME/Gme/GMEView.cpp Mon Sep 24 10:36:56 2012 (r2060)
@@ -337,8 +337,10 @@
ON_COMMAND(ID_FILE_CLOSE, OnFileClose)
ON_COMMAND(ID_CONNCNTX_PROPERTIES, OnConncntxProperties)
ON_COMMAND(ID_CONNCNTX_DELETE, OnConncntxDelete)
+ ON_COMMAND(ID_CONNCNTX_REVERSE, OnConncntxReverse)
+ ON_UPDATE_COMMAND_UI(ID_CONNCNTX_REVERSE, OnUpdateConncntxReverse)
ON_COMMAND(ID_CONNCNTX_FOLLOW, OnConnCntxFollow)
- ON_COMMAND(ID_CONNCNTX_REVERSE, OnConnCntxRevfollow)
+ ON_COMMAND(ID_CONNCNTX_JUMP_SRC, OnConnCntxRevfollow)
ON_COMMAND(ID_PORTCNTX_FOLLOWCONNECTION, OnPortCntxFollowConnection)
ON_COMMAND(ID_PORTCNTX_REVERSECONNECTION, OnPortCntxRevfollowConnection)
ON_COMMAND(ID_CNTX_FOLLOWCONNECTION, OnCntxFollowConnection)
@@ -7734,6 +7736,121 @@
OnContextProperties(); // We now use the Launcher COM interface.
}
+static bool CanReverseConnection(CString& srcKind, CString& dstKind, IMgaMetaConnectionPtr& meta)
+{
+ for (int i = 1; i <= meta->Joints->Count; i++)
+ {
+ IMgaMetaConnJointPtr joint = meta->Joints->GetItem(i);
+ bool srcFound = false;
+ bool dstFound = false;
+ for (int j = 1; j <= joint->PointerSpecs->Count; j++)
+ {
+ IMgaMetaPointerSpecPtr spec = joint->PointerSpecs->GetItem(j);
+ _bstr_t specName = spec->Name;
+ for (int k = 1; k <= spec->Items->Count; k++)
+ {
+ IMgaMetaPointerItemPtr item = spec->Items->GetItem(k);
+ if (wcscmp(specName.GetBSTR(), L"src") == 0)
+ {
+ if (wcscmp(dstKind, item->Desc) == 0)
+ {
+ srcFound = true;
+ }
+ }
+ else if (wcscmp(specName.GetBSTR(), L"dst") == 0)
+ {
+ if (wcscmp(srcKind, item->Desc) == 0)
+ {
+ dstFound = true;
+ }
+ }
+ }
+ }
+ if (srcFound && dstFound)
+ return true;
+ }
+ return false;
+}
+
+void CGMEView::OnConncntxReverse()
+{
+ CGMEEventLogger::LogGMEEvent(_T("CGMEView::OnConncntxReverse in ")+path+name+_T("\r\n"));
+ if (isType) {
+ CGuiConnection* conn = NULL;
+ if (contextSelection)
+ conn = contextSelection->dynamic_cast_CGuiConnection();
+ else
+ {
+ ASSERT(false); // should only get here thru connection context menu
+ return;
+ }
+ MSGTRY
+ {
+ //CString srcKind = conn->srcPort ? static_cast<const TCHAR*>(conn->srcPort->metaFco->Name) : conn->src->kindName;
+ //CString dstKind = conn->dstPort ? static_cast<const TCHAR*>(conn->dstPort->metaFco->Name) : conn->dst->kindName;
+ //IMgaMetaConnectionPtr meta = conn->metaFco.p;
+ //CanReverseConnection(srcKind, dstKind, meta) ? TRUE : FALSE;
+ BeginTransaction();
+ IMgaSimpleConnectionPtr connection = conn->mgaFco.p;
+ IMgaFCOPtr src = connection->Src;
+ IMgaFCOPtr dst = connection->Dst;
+ IMgaFCOsPtr srcRefs = connection->SrcReferences;
+ IMgaFCOsPtr dstRefs = connection->DstReferences;
+
+ long oldprefs = connection->Project->Preferences;
+ try {
+ connection->Project->Preferences = connection->Project->Preferences | MGAPREF_IGNORECONNCHECKS;
+ // n.b. need to disconnect first, as self-connection is often illegal
+ connection->__SetSrc(NULL, NULL);
+ connection->__SetDst(NULL, NULL);
+ } catch (...) {
+ connection->Project->Preferences = oldprefs;
+ throw;
+ }
+ connection->__SetSrc(dstRefs, dst);
+ connection->__SetDst(srcRefs, src);
+ _bstr_t autoroutePrefKey = _bstr_t(L"autorouterPref");
+ _bstr_t autoroutePref = connection->RegistryValue[autoroutePrefKey];
+ if (autoroutePref.length())
+ {
+ wchar_t* dir = autoroutePref.GetBSTR();
+ while (*dir)
+ {
+ if (isupper(*dir))
+ {
+ *dir = tolower(*dir);
+ }
+ else if (islower(*dir))
+ {
+ *dir = toupper(*dir);
+ }
+ dir++;
+ }
+ connection->RegistryValue[autoroutePrefKey] = autoroutePref;
+ }
+ CommitTransaction();
+ } MSGCATCH(L"Could not delete connection", ;)
+ contextSelection = 0;
+ contextPort = 0;
+ }
+}
+
+void CGMEView::OnUpdateConncntxReverse(CCmdUI* pCmdUI)
+{
+ BOOL enable = FALSE;
+ if (isType && contextSelection) {
+ CGuiConnection* conn = contextSelection->dynamic_cast_CGuiConnection();
+ CString srcKind = conn->srcPort ? static_cast<const TCHAR*>(conn->srcPort->metaFco->Name) : conn->src->kindName;
+ CString dstKind = conn->dstPort ? static_cast<const TCHAR*>(conn->dstPort->metaFco->Name) : conn->dst->kindName;
+ if (conn) {
+ IMgaMetaConnectionPtr meta = conn->metaFco.p;
+ enable = CanReverseConnection(srcKind, dstKind, meta) ? TRUE : FALSE;
+ enable = TRUE;
+ }
+ }
+ pCmdUI->Enable(enable);
+}
+
void CGMEView::OnConncntxDelete()
{
CGMEEventLogger::LogGMEEvent(_T("CGMEView::OnConncntxDelete in ")+path+name+_T("\r\n"));
Modified: trunk/GME/Gme/GMEView.h
==============================================================================
--- trunk/GME/Gme/GMEView.h Wed Sep 19 17:49:21 2012 (r2059)
+++ trunk/GME/Gme/GMEView.h Mon Sep 24 10:36:56 2012 (r2060)
@@ -484,6 +484,8 @@
afx_msg void OnFileClose();
afx_msg void OnConncntxProperties();
afx_msg void OnConncntxDelete();
+ afx_msg void OnConncntxReverse();
+ afx_msg void OnUpdateConncntxReverse(CCmdUI* pCmdUI);
afx_msg void OnConnCntxFollow();
afx_msg void OnConnCntxRevfollow();
afx_msg void OnCntxClear();
Modified: trunk/GME/Gme/GUIObject.cpp
==============================================================================
--- trunk/GME/Gme/GUIObject.cpp Wed Sep 19 17:49:21 2012 (r2059)
+++ trunk/GME/Gme/GUIObject.cpp Mon Sep 24 10:36:56 2012 (r2060)
@@ -168,6 +168,8 @@
COMTHROW(fco->get_ID(&bstr));
CopyTo(bstr,id);
+ COMTHROW(fco->get_Meta(&metaFco));
+
if (!IsRealPort()) {
ReadARPreferences();
}
Modified: trunk/GME/Gme/GUIObject.h
==============================================================================
--- trunk/GME/Gme/GUIObject.h Wed Sep 19 17:49:21 2012 (r2059)
+++ trunk/GME/Gme/GUIObject.h Mon Sep 24 10:36:56 2012 (r2060)
@@ -97,6 +97,7 @@
CGuiAspect* parent;
CGuiConnectionList inConns;
CGuiConnectionList outConns;
+ CComPtr<IMgaMetaFCO> metaFco;
private:
bool autorouterPrefs[GME_AR_NUM];
@@ -218,9 +219,9 @@
CString roleName;
CString kindDisplayedName;
CString roleDisplayedName;
+ CComPtr<IMgaMetaFCO> metaFco;
protected:
- CComPtr<IMgaMetaFCO> metaFco;
int numParentAspects;
int parentAspect;
bool grayedOut;
Modified: trunk/GME/Gme/resource.h
==============================================================================
--- trunk/GME/Gme/resource.h Wed Sep 19 17:49:21 2012 (r2059)
+++ trunk/GME/Gme/resource.h Mon Sep 24 10:36:56 2012 (r2060)
@@ -405,7 +405,7 @@
#define ID_BUTTON33044 33044
#define ID_VIEW_CLEARCONSOLE 33045
#define ID_CONNCNTX_FOLLOW 33048
-#define ID_CONNCNTX_REVERSE 33050
+#define ID_CONNCNTX_JUMP_SRC 33050
#define ID_CNTX_FOLLOWCONNECTION 33051
#define ID_CNTX_REVERSECONNECTION 33053
#define ID_JUMPALONGCONN 33055
@@ -508,6 +508,7 @@
#define ID_FILE_INTERPRET48 33258
#define ID_FILE_INTERPRET49 33259
#define ID_FILE_INTERPRET_LAST ID_FILE_INTERPRET49
+#define ID_CONNCNTX_REVERSE 33270
#define IDW_TOOLBAR_MAIN 0xE820
#define IDW_TOOLBAR_WINS 0xE821
@@ -522,7 +523,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_3D_CONTROLS 1
#define _APS_NEXT_RESOURCE_VALUE 225
-#define _APS_NEXT_COMMAND_VALUE 33113
+#define _APS_NEXT_COMMAND_VALUE 33271
#define _APS_NEXT_CONTROL_VALUE 1132
#define _APS_NEXT_SYMED_VALUE 119
#endif
More information about the gme-commit
mailing list