|
From: <mbe...@us...> - 2010-08-23 15:53:39
|
Revision: 858
http://scstudio.svn.sourceforge.net/scstudio/?rev=858&view=rev
Author: mbezdeka
Date: 2010-08-23 15:53:29 +0000 (Mon, 23 Aug 2010)
Log Message:
-----------
- resnap improved
- Message jumping added
- instances can be now only straight (oblique ones will be straighten)
Modified Paths:
--------------
trunk/src/view/visio/addon/addon.cpp
trunk/src/view/visio/addon/addon.h
trunk/src/view/visio/addon/dllmodule.rc
trunk/src/view/visio/addon/document.cpp
trunk/src/view/visio/addon/document.h
trunk/src/view/visio/addon/enums.h
trunk/src/view/visio/addon/messageSnapping.cpp
trunk/src/view/visio/addon/messageSnapping.h
trunk/src/view/visio/addon/resource.h
trunk/src/view/visio/addon/scstudio.vcproj
trunk/src/view/visio/addon/shapeutils.cpp
trunk/src/view/visio/addon/shapeutils.h
trunk/src/view/visio/addon/snapGlobalDlg.cpp
trunk/src/view/visio/addon/snapGlobalDlg.h
Added Paths:
-----------
trunk/src/view/visio/addon/icon_jump_left_messages.ico
trunk/src/view/visio/addon/icon_jump_right_messages.ico
trunk/src/view/visio/addon/messageJump.cpp
trunk/src/view/visio/addon/messageJump.h
Modified: trunk/src/view/visio/addon/addon.cpp
===================================================================
--- trunk/src/view/visio/addon/addon.cpp 2010-08-23 13:16:17 UTC (rev 857)
+++ trunk/src/view/visio/addon/addon.cpp 2010-08-23 15:53:29 UTC (rev 858)
@@ -29,6 +29,7 @@
#include "resource.h"
#include "pageutils.h"
#include "messageSnapping.h"
+#include "messageJump.h"
// include command line parsing library SimpleOpt
// http://code.jellycan.com/simpleopt
@@ -71,8 +72,10 @@
m_bBeginChanged = false;
m_bEndChanged = false;
m_bCtrlDown = false;
- m_bUpDownKeyDown = false;
+ m_bArrowKeyDown = false;
m_bOnDropShape = false;
+ m_bKeyDown = false;
+ m_bAngleChanged = false;
};
VAORC CStudioAddon::About(LPVAOV2LSTRUCT pV2L)
@@ -337,6 +340,12 @@
case CDocumentMonitor::MENU_SELECT_ADD_ALL_MESSAGES:
TRACE("CStudioAddon::Run() add all messages to the current selection");
return pDocumentMonitor->OnMenuSelectAllMessages(vsoApp, SELECTION_ADD);
+ case CDocumentMonitor::MENU_MESSAGE_JUMP_LEFT:
+ TRACE("CStudioAddon::Run() jump message left");
+ return pDocumentMonitor->OnMenuMessageJump(vsoApp, true);
+ case CDocumentMonitor::MENU_MESSAGE_JUMP_RIGHT:
+ TRACE("CStudioAddon::Run() jump message right");
+ return pDocumentMonitor->OnMenuMessageJump(vsoApp, false);
case CDocumentMonitor::MENU_ENABLE_MESSAGE_ENUMERATION:
TRACE("CStudioAddon::Run() enable message enumeration");
return pDocumentMonitor->OnMenuEnableMessageEnumeration(vsoApp);
@@ -587,6 +596,10 @@
m_bEndChanged = true;
if(_tcsicmp(vsoCell->Name,_T("LocPinX")) == 0)
m_bMoving = true;
+
+ //Detect instance rotation
+ if(_tcsicmp(vsoCell->Name,_T("Angle")) == 0)
+ m_bAngleChanged = true;
}
void CStudioAddon::HandleConnectionsAdded(Visio::IVConnectsPtr vsoConnects)
@@ -634,6 +647,9 @@
void CStudioAddon::HandleKeyDown(Visio::IVKeyboardEventPtr vsoKeyboardEvent, Visio::IVApplicationPtr vsoApp)
{
+ m_bKeyDown = true;
+
+ long keyCode = vsoKeyboardEvent->KeyCode;
long oldState = m_keyButtonState;
m_keyButtonState = vsoKeyboardEvent->KeyButtonState;
@@ -644,12 +660,29 @@
}
//Keyboard re-snapping - get instances the messages are snapped to
- if((vsoKeyboardEvent->KeyCode == VK_UP || vsoKeyboardEvent->KeyCode == VK_DOWN) && m_bUpDownKeyDown == false)
+ //Message jumping
+ if(!m_bArrowKeyDown)
{
+ m_bArrowKeyDown = true;
Visio::IVSelectionPtr selection = vsoApp->ActiveWindow->Selection;
- m_bUpDownKeyDown = true;
- for(int i=1; i<=selection->Count; i++)
- snappedInstances.push_back(CMessageSnapping::getConnectedInstances(selection->Item[i]));
+ Visio::IVShapesPtr shapes = vsoApp->ActivePage->Shapes;
+
+ switch(keyCode)
+ {
+ case VK_LEFT:
+ case VK_RIGHT:
+ if(selection->Count == 1 && CMessageSnapping::isArrowKeysEnabled())
+ {
+ instances = CMessageSnapping::getConnectedInstances(selection->Item[1]);
+ break;
+ }
+ case VK_UP:
+ case VK_DOWN:
+ for(int i=1; i<=shapes->Count; i++)
+ if(get_shape_type(shapes->Item[i]) == ST_BMSC_INSTANCE || get_shape_type(shapes->Item[i]) == ST_BMSC_COREGION)
+ instances.push_back(shapes->Item[i]);
+ break;
+ }
}
if(m_keyButtonState & visKeyControl)
@@ -662,7 +695,9 @@
{
ResetState(vsoApp);
}
-
+
+ // key code
+ long keyCode = vsoKeyboardEvent->KeyCode;
// buttons state
long oldState = m_keyButtonState;
m_keyButtonState = vsoKeyboardEvent->KeyButtonState;
@@ -674,14 +709,30 @@
}
//Keyboard re-snapping - resnap disconnected messages
- if(m_bUpDownKeyDown)
+ if(m_bArrowKeyDown)
{
- for(int i=1; i<=vsoApp->ActiveWindow->Selection->Count; i++)
- CMessageSnapping::resnap(vsoApp->ActiveWindow->Selection->Item[i], snappedInstances.at(i-1));
- snappedInstances.clear();
- m_bUpDownKeyDown = false;
+ m_bArrowKeyDown = false;
+ Visio::IVSelectionPtr selection = vsoApp->ActiveWindow->Selection;
+ switch(keyCode)
+ {
+ case VK_LEFT:
+ case VK_RIGHT:
+ if(CMessageSnapping::isArrowKeysEnabled())
+ {
+ Visio::IVShapePtr shape = selection->Item[1];
+ if(!CMessageJump::jump(shape, instances, (keyCode == 0x25) ? MSJUMP_LEFT : MSJUMP_RIGHT))
+ CMessageSnapping::snap(shape, CShapeUtils::getShapeCell(shape, "PinX"), CShapeUtils::getShapeCell(shape, "PinY"), MSSNAP_PRESERVE_VERTICAL);
+ //CMessageSnapping::resnap(shape, instances, 0.1);
+ break;
+ }
+ case VK_UP:
+ case VK_DOWN:
+ for(int i=1; i<=selection->Count; i++)
+ CMessageSnapping::resnap(selection->Item[i], instances);
+ break;
+ }
+ instances.clear();
}
-
//Message snapping
m_bCtrlDown = false;
}
@@ -725,32 +776,35 @@
void CStudioAddon::HandleNonePending(Visio::IVApplicationPtr vsoApp)
{
+ Visio::IVSelectionPtr selection = vsoApp->ActiveWindow->Selection;
+
////////////////////////////////////////////////////
+ //Block instance rotation
+ if(m_bAngleChanged && (m_bBeginChanged ^ m_bEndChanged) && (get_shape_type(selection->Item[1]) == ST_BMSC_INSTANCE))
+ {
+ m_bAngleChanged = false;
+ if(m_bBeginChanged)
+ selection->Item[1]->Cells["BeginX"]->FormulaForceU = selection->Item[1]->Cells["EndX"]->Formula;
+ if(m_bEndChanged)
+ selection->Item[1]->Cells["EndX"]->FormulaForceU = selection->Item[1]->Cells["BeginX"]->Formula;
+ }
+
+ ////////////////////////////////////////////////////
//Message snapping
#define _u(x) CPageUtils::ConvertUnits(vsoApp, x, 0, visPageUnits)
- if(!m_bOnDropShape && m_bSnap && !m_bUpDownKeyDown && vsoApp->ActiveWindow->Selection->Count && CMessageSnapping::isEnabled())
+ if(!m_bOnDropShape && m_bSnap && !m_bKeyDown && (selection->Count == 1) && CMessageSnapping::isEnabled())
{
- Visio::IVSelectionPtr selection = vsoApp->ActiveWindow->Selection;
CDocumentMonitor* docMon = GetDocumentMonitor(vsoApp,vsoApp->ActiveDocument);
-
- if(selection->Count == 1)
+ Visio::IVShapePtr msgShape = selection->Item[1];
+
+ if(msgShape && m_bBeginChanged && m_bEndChanged && docMon->isMessageShape(msgShape))
{
- Visio::IVShapePtr msgShape = selection->Item[1];
- if(msgShape && m_bBeginChanged && m_bEndChanged && docMon->isMessageShape(msgShape))
- {
- //If endpoints movement would be enabled, here would be condition (m_bMoving && (m_bBeginChanged ^ m_bEndChanged))
-
- //Get relative position of the mouse from the shape Begin
- double newPosX = CShapeUtils::GetShapeCellProperty(msgShape,"PinX", visPageUnits);
- double newPosY = CShapeUtils::GetShapeCellProperty(msgShape,"PinY", visPageUnits);
- newPosX += CPageUtils::ConvertUnits(vsoApp, m_mouseRelPosX, 0, visPageUnits);
- newPosY += CPageUtils::ConvertUnits(vsoApp, m_mouseRelPosY, 0, visPageUnits);
- CMessageSnapping::snap(msgShape, newPosX, newPosY,CMessageSnapping::getSnapType()); //Do regular snapping
- }
+ //Get relative position of the mouse from the shape Begin
+ double newPosX = CShapeUtils::getShapeCell(msgShape,"PinX") + _u(m_mouseRelPosX);;
+ double newPosY = CShapeUtils::getShapeCell(msgShape,"PinY") + _u(m_mouseRelPosY);
+ CMessageSnapping::snap(msgShape, newPosX, newPosY,CMessageSnapping::getSnapType()); //Do regular snapping
}
- }
- //Set variables to false
- m_bSnap = m_bMoving = m_bBeginChanged = m_bEndChanged = false;
+ }
#undef _u
////////////////////////////////////////////////////
@@ -785,8 +839,12 @@
m_bShapeDeleted = m_bCellChanged = false;
}
+ //Set variables to false
+ m_bSnap = m_bMoving = m_bBeginChanged = m_bEndChanged = false;
//Reset OnDropShape state
m_bOnDropShape = false;
+ //Reset OnKeyDown
+ m_bKeyDown = false;
}
void CStudioAddon::HandleBeforeTextEdit(Visio::IVShapePtr shapePtr, Visio::IVApplicationPtr vsoApp)
Modified: trunk/src/view/visio/addon/addon.h
===================================================================
--- trunk/src/view/visio/addon/addon.h 2010-08-23 13:16:17 UTC (rev 857)
+++ trunk/src/view/visio/addon/addon.h 2010-08-23 15:53:29 UTC (rev 858)
@@ -135,6 +135,7 @@
long m_keyButtonState;
double m_mousePosX;
double m_mousePosY;
+ bool m_bKeyDown;
std::map<long, TAddonState> m_states;
@@ -155,11 +156,12 @@
bool m_bEndChanged;
bool m_bMoving;
bool m_bCtrlDown;
- bool m_bUpDownKeyDown;
+ bool m_bArrowKeyDown;
bool m_bOnDropShape;
+ bool m_bAngleChanged;
double m_mouseRelPosX;
double m_mouseRelPosY;
- std::vector< std::vector<Visio::IVShapePtr> > snappedInstances;
+ std::vector<Visio::IVShapePtr> instances;
};
// $Id$
Modified: trunk/src/view/visio/addon/dllmodule.rc
===================================================================
--- trunk/src/view/visio/addon/dllmodule.rc 2010-08-23 13:16:17 UTC (rev 857)
+++ trunk/src/view/visio/addon/dllmodule.rc 2010-08-23 15:53:29 UTC (rev 858)
@@ -224,17 +224,26 @@
GROUPBOX "If no nearest (numbered) message found:",IDC_STATIC,7,65,261,54,WS_GROUP
END
-IDD_SNAP_GLOBAL DIALOGEX 0, 0, 275, 118
+IDD_SNAP_GLOBAL DIALOGEX 0, 0, 275, 186
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Dialog"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
- CONTROL "Message snapping enabled",IDC_SNAP_ENABLED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,7,102,10
- GROUPBOX "Oblique message options:",IDC_STATIC,7,22,261,61
- CONTROL "straighten",IDC_STRAIGHTEN,"Button",BS_AUTORADIOBUTTON | WS_GROUP,13,37,47,10
+ CONTROL "mouse control",IDC_SNAP_ENABLED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,52,61,10
+ GROUPBOX "Oblique message options:",IDC_STATIC,7,72,261,61
+ CONTROL "straighten",IDC_STRAIGHTEN,"Button",BS_AUTORADIOBUTTON | WS_GROUP,13,87,47,10
CONTROL "preserve vertical distance between send - receive",IDC_PRESERVE_VERTICAL,
- "Button",BS_AUTORADIOBUTTON,13,51,176,10
- CONTROL "preserve slope",IDC_PRESERVE_SLOPE,"Button",BS_AUTORADIOBUTTON,13,65,63,10
+ "Button",BS_AUTORADIOBUTTON,13,101,176,10
+ CONTROL "preserve slope",IDC_PRESERVE_SLOPE,"Button",BS_AUTORADIOBUTTON,13,115,63,10
+ CONTROL "arrow-keys control",IDC_KEYS_ENABLED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,36,76,10
+ CONTROL "buttons",IDC_BUTTONS_ENABLED,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,13,20,41,10
+ GROUPBOX "Allow message snapping for:",IDC_STATIC,7,7,261,62
+ GROUPBOX "Edge instances treatment:",IDC_STATIC,7,135,261,44
+ CONTROL "preserve message type",IDC_EDGE_PRESERVE_TYPE,"Button",BS_AUTORADIOBUTTON | WS_GROUP,150,149,91,8
+ CONTROL "change the type to lost/found",IDC_EDGE_CHANGE_TYPE,
+ "Button",BS_AUTORADIOBUTTON,150,161,112,10
+ CONTROL "Alow jumping to edge instances and: ",IDC_EDGE_THREATMENT_ENABLED,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,148,132,10
END
@@ -308,8 +317,9 @@
LEFTMARGIN, 7
RIGHTMARGIN, 268
VERTGUIDE, 13
+ VERTGUIDE, 150
TOPMARGIN, 7
- BOTTOMMARGIN, 111
+ BOTTOMMARGIN, 179
END
END
#endif // APSTUDIO_INVOKED
@@ -332,6 +342,8 @@
IDI_ICON_SELECT_ADD_MESSAGES ICON "icon_select_add_messages.ico"
IDI_ICON_ENABLE_MESSAGE_ENUMERATION ICON "icon_message_enumeration.ico"
IDI_ICON_DISABLE_MESSAGE_ENUMERATION ICON "icon_message_enumeration_disable.ico"
+IDI_ICON_JUMP_LEFT ICON "icon_jump_left_messages.ico"
+IDI_ICON_JUMP_RIGHT ICON "icon_jump_right_messages.ico"
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
Modified: trunk/src/view/visio/addon/document.cpp
===================================================================
--- trunk/src/view/visio/addon/document.cpp 2010-08-23 13:16:17 UTC (rev 857)
+++ trunk/src/view/visio/addon/document.cpp 2010-08-23 15:53:29 UTC (rev 858)
@@ -31,6 +31,7 @@
#include "GlobalSettingsDlg.h"
#include "messageSnapping.h"
+#include "messageJump.h"
#include <fstream>
@@ -266,8 +267,8 @@
if(CMessageSnapping::isEnabled() && (m_vsoApp->ActiveWindow->Selection->Count == 1)) //Check whether snapping is enabled
{
- double posX = CShapeUtils::GetShapeCellProperty(vsoShape,"PinX",visPageUnits);
- double posY = CShapeUtils::GetShapeCellProperty(vsoShape,"PinY",visPageUnits);
+ double posX = CShapeUtils::getShapeCell(vsoShape,"PinX");
+ double posY = CShapeUtils::getShapeCell(vsoShape,"PinY");
if(m_addon->GetCtrlKeyDown())
posX += CPageUtils::ConvertUnits(m_vsoApp, m_addon->GetRelMousePosX(), 0, visPageUnits);
@@ -606,6 +607,30 @@
m_selAddMessagesToolbarItem->IconFileName(vslIconFile.c_str());
m_selAddMessagesToolbarItem->Visible = false;
+ m_selAddMessagesToolbarItem = m_toolbar->ToolbarItems->Add();
+ m_selAddMessagesToolbarItem->Caption = "Add All Messages To Selection";
+ m_selAddMessagesToolbarItem->AddOnName = ADDON_NAME;
+ m_selAddMessagesToolbarItem->AddOnArgs = stringize() << L"/event=" << MENU_SELECT_ADD_ALL_MESSAGES;
+ vslIconFile = vslFileName+_T(",7");
+ m_selAddMessagesToolbarItem->IconFileName(vslIconFile.c_str());
+ m_selAddMessagesToolbarItem->Visible = false;
+
+ //Message Jumping Left
+ m_msgJumpLeftToolbarItem = m_toolbar->ToolbarItems->Add();
+ m_msgJumpLeftToolbarItem->BeginGroup = true;
+ m_msgJumpLeftToolbarItem->Caption = "Jump Left";
+ m_msgJumpLeftToolbarItem->AddOnName = ADDON_NAME;
+ m_msgJumpLeftToolbarItem->AddOnArgs = stringize() << L"/event=" << MENU_MESSAGE_JUMP_LEFT;
+ vslIconFile = vslFileName+_T(",10");
+ m_msgJumpLeftToolbarItem->IconFileName(vslIconFile.c_str());
+ //Message Jumping Right
+ m_msgJumpRightToolbarItem = m_toolbar->ToolbarItems->Add();
+ m_msgJumpRightToolbarItem->Caption = "Jump Right";
+ m_msgJumpRightToolbarItem->AddOnName = ADDON_NAME;
+ m_msgJumpRightToolbarItem->AddOnArgs = stringize() << L"/event=" << MENU_MESSAGE_JUMP_RIGHT;
+ vslIconFile = vslFileName+_T(",11");
+ m_msgJumpRightToolbarItem->IconFileName(vslIconFile.c_str());
+
Visio::IVToolbarItemPtr itemFindFlow = m_toolbar->ToolbarItems->Add();
itemFindFlow->BeginGroup = true;
itemFindFlow->Caption = "Find Flow";
@@ -637,7 +662,7 @@
m_enableMessageEnumerationToolbarItem = m_toolbar->ToolbarItems->Add();
m_enableMessageEnumerationToolbarItem->BeginGroup = true;
- m_enableMessageEnumerationToolbarItem->Caption = "Message numbering";
+ m_enableMessageEnumerationToolbarItem->Caption = "Message Numbering";
m_enableMessageEnumerationToolbarItem->AddOnName = ADDON_NAME;
m_enableMessageEnumerationToolbarItem->AddOnArgs = stringize() << L"/event=" << MENU_ENABLE_MESSAGE_ENUMERATION;
m_enableMessageEnumerationToolbarItem->Visible = true;
@@ -646,7 +671,7 @@
m_enableMessageEnumerationToolbarItem->IconFileName(vslIconFile.c_str());
m_disableMessageEnumerationToolbarItem = m_toolbar->ToolbarItems->Add();
- m_disableMessageEnumerationToolbarItem->Caption = "Delete numbering";
+ m_disableMessageEnumerationToolbarItem->Caption = "Delete Numbering";
m_disableMessageEnumerationToolbarItem->AddOnName = ADDON_NAME;
m_disableMessageEnumerationToolbarItem->AddOnArgs = stringize() << L"/event=" << MENU_DISABLE_MESSAGE_ENUMERATION;
m_disableMessageEnumerationToolbarItem->Visible = true;
@@ -1100,6 +1125,23 @@
return VAORC_SUCCESS;
}
+VAORC CDocumentMonitor::OnMenuMessageJump(Visio::IVApplicationPtr vsoApp, bool left)
+{
+ Visio::IVSelectionPtr selection = vsoApp->ActiveWindow->Selection;
+
+ if(selection->Count > 1 || !selection->Count)
+ return VAORC_FAILURE;
+
+ Visio::IVShapePtr shape = selection->Item[1];
+ if(!isMessageShape(shape))
+ return VAORC_FAILURE;
+
+ if(!CMessageJump::jump(shape, CMessageSnapping::getConnectedInstances(shape), (MsgJumpDirection)left))
+ CMessageSnapping::snap(shape, CShapeUtils::getShapeCell(shape, "PinX"), CShapeUtils::getShapeCell(shape, "PinY"), MSSNAP_PRESERVE_VERTICAL);
+
+ return VAORC_SUCCESS;
+}
+
std::pair<Visio::IVShapePtr, Visio::IVShapePtr> CDocumentMonitor::getInstancesPair(Visio::IVApplicationPtr vsoApp)
{
Visio::IVSelectionPtr selection = CPageUtils::FilterSelection(vsoApp->ActiveWindow->Selection, ST_BMSC_INSTANCE);
@@ -1210,6 +1252,9 @@
VAORC CDocumentMonitor::OnMenuMessageSequence(Visio::IVApplicationPtr vsoApp, Visio::IVSelectionPtr oldSelection)
{
+ // step 0: turn off message snapping
+ bool snapStatus = CMessageSnapping::isEnabled();
+ CMessageSnapping::setEnabled(false);
// step 1: determine the boundary instances between which to draw message sequence
std::pair<Visio::IVShapePtr, Visio::IVShapePtr> boundaries = getInstancesPair(vsoApp);
if (boundaries.first == NULL)
@@ -1344,6 +1389,9 @@
}
}
+ //Turn message snapping back on
+ CMessageSnapping::setEnabled(snapStatus);
+
vsoApp->EndUndoScope(undoScope, true);
vsoApp->ActiveWindow->Selection = selection;
Modified: trunk/src/view/visio/addon/document.h
===================================================================
--- trunk/src/view/visio/addon/document.h 2010-08-23 13:16:17 UTC (rev 857)
+++ trunk/src/view/visio/addon/document.h 2010-08-23 15:53:29 UTC (rev 858)
@@ -65,7 +65,7 @@
// context menu items
MENU_ADD_INSTANCES = 102,
MENU_MESSAGE_SEQUENCE,
- MENU_SELECT_NUMBERED_GROUP,
+ MENU_SELECT_NUMBERED_GROUP,
// standard Check menu items
MENU_WINDOWS_REPORTER = 200,
MENU_IMPORT,
@@ -81,9 +81,11 @@
MENU_SELECT_ALL_MESSAGES,
MENU_SELECT_ADD_ALL_INSTANCES,
MENU_SELECT_ADD_ALL_MESSAGES,
- MENU_ENABLE_MESSAGE_ENUMERATION,
- MENU_DISABLE_MESSAGE_ENUMERATION,
- MENU_GLOBAL_SETTINGS,
+ MENU_MESSAGE_JUMP_LEFT,
+ MENU_MESSAGE_JUMP_RIGHT,
+ MENU_ENABLE_MESSAGE_ENUMERATION,
+ MENU_DISABLE_MESSAGE_ENUMERATION,
+ MENU_GLOBAL_SETTINGS,
};
VAORC OnMenuWindowsReporter(Visio::IVApplicationPtr vsoApp);
@@ -93,6 +95,7 @@
VAORC OnMenuTransform(Visio::IVApplicationPtr vsoApp, int index);
VAORC OnMenuSelectAllInstances(Visio::IVApplicationPtr vsoApp, SelectionType selType);
VAORC OnMenuSelectAllMessages(Visio::IVApplicationPtr vsoApp, SelectionType selType);
+ VAORC OnMenuMessageJump(Visio::IVApplicationPtr vsoApp, bool left);
VAORC OnMenuMessageSequence(Visio::IVApplicationPtr vsoApp, Visio::IVSelectionPtr oldSelection=NULL);
VAORC OnMenuFindFlow(Visio::IVApplicationPtr vsoApp);
VAORC OnMenuSimulationStart(Visio::IVApplicationPtr vsoApp);
@@ -231,6 +234,9 @@
//Message enumeration
Visio::IVToolbarItemPtr m_enableMessageEnumerationToolbarItem;
Visio::IVToolbarItemPtr m_disableMessageEnumerationToolbarItem;
+ //Message jumping
+ Visio::IVToolbarItemPtr m_msgJumpLeftToolbarItem;
+ Visio::IVToolbarItemPtr m_msgJumpRightToolbarItem;
/**
* Selects all instances or all messages on the active page.
Modified: trunk/src/view/visio/addon/enums.h
===================================================================
--- trunk/src/view/visio/addon/enums.h 2010-08-23 13:16:17 UTC (rev 857)
+++ trunk/src/view/visio/addon/enums.h 2010-08-23 15:53:29 UTC (rev 858)
@@ -52,4 +52,10 @@
MSSNAP_PRESERVE_SLOPE,
};
+enum MsgJumpDirection
+{
+ MSJUMP_RIGHT = 0,
+ MSJUMP_LEFT,
+};
+
// $Id$
Added: trunk/src/view/visio/addon/icon_jump_left_messages.ico
===================================================================
(Binary files differ)
Property changes on: trunk/src/view/visio/addon/icon_jump_left_messages.ico
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/src/view/visio/addon/icon_jump_right_messages.ico
===================================================================
(Binary files differ)
Property changes on: trunk/src/view/visio/addon/icon_jump_right_messages.ico
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/src/view/visio/addon/messageJump.cpp
===================================================================
--- trunk/src/view/visio/addon/messageJump.cpp (rev 0)
+++ trunk/src/view/visio/addon/messageJump.cpp 2010-08-23 15:53:29 UTC (rev 858)
@@ -0,0 +1,181 @@
+/*
+* scstudio - Sequence Chart Studio
+* http://scstudio.sourceforge.net
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License version 2.1, as published by the Free Software Foundation.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* Copyright (c) 2010 Martin Bezdeka <mbe...@se...>
+*
+* $Id$
+*/
+
+#include "stdafx.h"
+#include "dllmodule.h"
+#include "messageJump.h"
+
+#define SNAP_REG_PATH _T("Software\\Sequence Chart Studio\\MessageSnapping")
+
+bool CMessageJump::isEnabled()
+{
+ return GetRegistry<bool>(SNAP_REG_PATH, NULL, _T("EdgeTreatmentEnabled"), false);
+}
+int CMessageJump::getEdgeInstanceTreatment()
+{
+ return GetRegistry<int>(SNAP_REG_PATH, NULL, _T("EdgeTreatmentType"), 0);
+}
+
+bool CMessageJump::jump(Visio::IVShapePtr msgShape, std::vector<Visio::IVShapePtr> connectedInstances, MsgJumpDirection direction)
+{
+ if(!msgShape || !connectedInstances.size())
+ return false;
+
+ long scopeId = msgShape->Application->BeginUndoScope("Jump");
+
+ std::vector<Visio::IVShapePtr> instances = connectedInstances;
+ bool left = (CMessageSnapping::getMsgDirection(msgShape) == MSDIR_LEFT);
+
+ Visio::IVShapePtr origIntsLeft = NULL;
+ Visio::IVShapePtr origIntsRight = NULL;
+
+ switch(instances.size())
+ {
+ case 1:
+ {
+ PVEC2 intPoint = CMessageSnapping::getIntersectionWithInstance(msgShape, instances.at(0));
+ if(intPoint && (CShapeUtils::getShapeCell(msgShape, "PinX") < intPoint->x))
+ origIntsRight = instances.at(0);
+ else
+ origIntsLeft = instances.at(0);
+ delete intPoint;
+ }
+ break;
+
+ case 2:
+ origIntsLeft = instances.at(0);
+ origIntsRight = instances.at(1);
+ if(left)
+ CShapeUtils::swapShape(origIntsLeft, origIntsRight);
+ break;
+
+ default:
+ return false;
+ }
+
+ std::vector<Visio::IVShapePtr> intersIntsBegin, intersIntsEnd;
+ intersIntsBegin = CMessageSnapping::getIntersectInstances(msgShape, CShapeUtils::getShapeCell(msgShape,left ? "EndY" : "BeginY"), MSSNAP_STRAIGHTEN);
+ intersIntsEnd = CMessageSnapping::getIntersectInstances(msgShape, CShapeUtils::getShapeCell(msgShape,left ? "BeginY" : "EndY"), MSSNAP_STRAIGHTEN);
+
+#define _s(x) CShapeUtils::getShapeCell(msgShape,x)
+ Visio::IVShapePtr closestLeft = getClosestInstanceFromShape(left ? VEC2(_s("EndX"),_s("EndY")) : VEC2(_s("BeginX"),_s("BeginY")),
+ origIntsLeft, intersIntsBegin, direction);
+ Visio::IVShapePtr closestRight = getClosestInstanceFromShape(left ? VEC2(_s("BeginX"),_s("BeginY")) : VEC2(_s("EndX"),_s("EndY")),
+ origIntsRight, intersIntsEnd, direction);
+#undef _s
+
+ VEC2 msgVec;
+ CMessageSnapping::getMsgVector(msgShape, &msgVec);
+
+ if(left)
+ CShapeUtils::swapShape(closestLeft, closestRight);
+
+ //FIXME: Move to separate function
+ double PinY = CShapeUtils::getShapeCell(msgShape, "PinY");
+ if((closestLeft ^ closestRight) && origIntsLeft && origIntsRight) //NOTE: new instance is only one, previous instances were two
+ {
+ if(!isEnabled()) // If Edge treatment isn't enabled we are done
+ return true;
+
+
+ bool snapStatus = CMessageSnapping::isEnabled();
+ CMessageSnapping::setEnabled(false);
+
+ //Change message to lost/found
+ Visio::IVPagePtr page = msgShape->Application->ActivePage;
+ CDrawingVisualizer visualizer(msgShape->Application);
+ TShapeType shapeType = (TShapeType)(left ? ((direction == MSJUMP_LEFT) ? 2 : 3) : ((direction == MSJUMP_LEFT) ? 3 : 2));
+ Visio::IVShapePtr newMsg = page->Drop(visualizer.find_master((getEdgeInstanceTreatment() == 1) ? shapeType : ST_BMSC_MESSAGE),0,0);
+ newMsg->Text = msgShape->Text;
+ newMsg->Data1 = msgShape->Data1;
+ newMsg->Data2 = msgShape->Data2;
+ newMsg->Data3 = msgShape->Data3;
+ msgShape->Application->EventsEnabled = false;
+ newMsg->Cells["BeginX"]->FormulaU = stringize() << msgShape->Cells["BeginX"]->Result[""];
+ newMsg->Cells["BeginY"]->FormulaU = stringize() << msgShape->Cells["BeginY"]->Result[""];
+ newMsg->Cells["EndX"]->FormulaU = stringize() << msgShape->Cells["EndX"]->Result[""];
+ newMsg->Cells["EndY"]->FormulaU = stringize() << msgShape->Cells["EndY"]->Result[""];
+ msgShape->Application->EventsEnabled = true;
+ msgShape->Delete();
+ msgShape = newMsg;
+
+ CMessageSnapping::setEnabled(snapStatus);
+ }
+
+ CMessageSnapping::glueMsgToInstancesPair(msgShape, closestLeft, closestRight, PinY, MSSNAP_PRESERVE_VERTICAL);
+
+ if(closestLeft ^ closestRight)
+ {
+ //If message is snapped only to one instance, preserve its length
+ msgShape->Application->EventsEnabled = false;
+ if(closestLeft) //LEFT point is snapped, adjust right point
+ {
+ msgShape->Cells["EndX"]->FormulaU = stringize() << msgShape->Cells["BeginX"]->Result[""] + msgVec.x;
+ msgShape->Cells["EndY"]->FormulaU = stringize() << msgShape->Cells["BeginY"]->Result[""] + msgVec.y;
+ }
+ if(closestRight) //RIGHT point is snapped, adjust left point
+ {
+ msgShape->Cells["BeginX"]->FormulaU = stringize() << msgShape->Cells["EndX"]->Result[""] - msgVec.x;
+ msgShape->Cells["BeginY"]->FormulaU = stringize() << msgShape->Cells["EndY"]->Result[""] - msgVec.y;
+ }
+ msgShape->Application->EventsEnabled = true;
+ }
+ msgShape->Application->EndUndoScope(scopeId, true);
+
+ return true;
+}
+
+Visio::IVShapePtr CMessageJump::getClosestInstanceFromShape(VEC2 pointOnShape, Visio::IVShapePtr shape, std::vector<Visio::IVShapePtr> instances, MsgJumpDirection direction)
+{
+ if(!shape)
+ return NULL;
+
+ if(get_shape_type(shape) == ST_BMSC_COREGION)
+ shape = shape->Connects->ToSheet;
+
+ Visio::IVShapePtr closestInstance = NULL;
+ double closestDistance = 0;
+ for(std::vector<Visio::IVShapePtr>::iterator it = instances.begin(); it != instances.end(); it++)
+ {
+ if(*it == shape)
+ continue;
+
+ PVEC2 intPoint = CMessageSnapping::getIntersectionWithInstance(VEC2(pointOnShape.x-1, pointOnShape.y),
+ VEC2(pointOnShape.x, pointOnShape.y), *it);
+ if(!intPoint || !CMessageSnapping::isPointOnInstancesLine(*intPoint, *it))
+ { delete intPoint; continue; }
+
+ double xVector = pointOnShape.x - intPoint->x;
+ if((xVector * ((direction == MSJUMP_LEFT) ? 1 : -1)) < 0)
+ continue;
+
+ double distance = sqrt(pow(xVector,2) + pow((pointOnShape.y - intPoint->y),2));
+
+ if(!closestInstance || distance < closestDistance)
+ {
+ closestDistance = distance;
+ closestInstance = *it;
+ }
+ delete intPoint;
+ }
+
+ return closestInstance;
+}
+
+
+// $Id$
\ No newline at end of file
Property changes on: trunk/src/view/visio/addon/messageJump.cpp
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Added: trunk/src/view/visio/addon/messageJump.h
===================================================================
--- trunk/src/view/visio/addon/messageJump.h (rev 0)
+++ trunk/src/view/visio/addon/messageJump.h 2010-08-23 15:53:29 UTC (rev 858)
@@ -0,0 +1,41 @@
+/*
+* scstudio - Sequence Chart Studio
+* http://scstudio.sourceforge.net
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License version 2.1, as published by the Free Software Foundation.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* Copyright (c) 2010 Martin Bezdeka <mbe...@se...>
+*
+* $Id$
+*/
+
+#pragma once
+
+#include "enums.h"
+#include "shapeUtils.h"
+#include "messageSnapping.h"
+#include "visualize.h"
+
+
+class CMessageJump
+{
+public:
+ static bool isEnabled();
+ static int getEdgeInstanceTreatment();
+
+ static bool jump(Visio::IVShapePtr msgShape, std::vector<Visio::IVShapePtr> connectedInstances, MsgJumpDirection direction);
+ /*
+ *
+ */
+ static Visio::IVShapePtr getClosestInstanceFromShape(VEC2 pointOnShape, Visio::IVShapePtr shape,
+ std::vector<Visio::IVShapePtr> instances, MsgJumpDirection direction);
+};
+
+// $Id$
\ No newline at end of file
Property changes on: trunk/src/view/visio/addon/messageJump.h
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Modified: trunk/src/view/visio/addon/messageSnapping.cpp
===================================================================
--- trunk/src/view/visio/addon/messageSnapping.cpp 2010-08-23 13:16:17 UTC (rev 857)
+++ trunk/src/view/visio/addon/messageSnapping.cpp 2010-08-23 15:53:29 UTC (rev 858)
@@ -21,24 +21,31 @@
#include "messageSnapping.h"
#include "shapeUtils.h"
+#define SNAP_REG_PATH _T("Software\\Sequence Chart Studio\\MessageSnapping")
+
bool CMessageSnapping::isEnabled()
{
- return GetRegistry<bool>(_T("Software\\Sequence Chart Studio\\MessageSnapping"), NULL, _T("SnapEnabled"), 0);
+ return GetRegistry<bool>(SNAP_REG_PATH, NULL, _T("SnapEnabled"), 0);
}
+bool CMessageSnapping::isArrowKeysEnabled()
+{
+ return GetRegistry<bool>(SNAP_REG_PATH, NULL, _T("KeysEnabled"), 0);
+}
+
MsgSnapType CMessageSnapping::getSnapType()
{
- return (MsgSnapType)GetRegistry<int>(_T("Software\\Sequence Chart Studio\\MessageSnapping"), NULL, _T("SnapType"), -1);
+ return (MsgSnapType)GetRegistry<int>(SNAP_REG_PATH, NULL, _T("SnapType"), -1);
}
void CMessageSnapping::setEnabled(bool bEnable)
{
- SetRegistry<bool>(HKEY_CURRENT_USER, _T("Software\\Sequence Chart Studio\\MessageSnapping"), _T("SnapEnabled"), bEnable);
+ SetRegistry<bool>(HKEY_CURRENT_USER, SNAP_REG_PATH, _T("SnapEnabled"), bEnable);
}
void CMessageSnapping::setSnapType(MsgSnapType snapType)
{
- SetRegistry<int>(HKEY_CURRENT_USER, _T("Software\\Sequence Chart Studio\\MessageSnapping"), _T("snapType"), snapType);
+ SetRegistry<int>(HKEY_CURRENT_USER, SNAP_REG_PATH, _T("snapType"), snapType);
}
std::vector<Visio::IVShapePtr> CMessageSnapping::getIntersectInstances(Visio::IVShapePtr msgShape, double msgPosY, MsgSnapType snapType)
@@ -49,8 +56,8 @@
double InstBegY, InstEndY;
- double msgBegY = CShapeUtils::GetShapeCellProperty(msgShape,"BeginY", visPageUnits);
- double msgEndY = CShapeUtils::GetShapeCellProperty(msgShape,"EndY", visPageUnits);
+ double msgBegY = CShapeUtils::getShapeCell(msgShape,"BeginY");
+ double msgEndY = CShapeUtils::getShapeCell(msgShape,"EndY");
//Searches for instances on the page and the ones matching the criteria puts into vector
for(int i=1; i<=shapesOnPage->Count; i++)
@@ -58,8 +65,8 @@
Visio::IVShapePtr shape = shapesOnPage->Item[i];
if(get_shape_type(shape) == ST_BMSC_INSTANCE)
{
- InstBegY = CShapeUtils::GetShapeCellProperty(shape, "BeginY", visPageUnits);
- InstEndY = CShapeUtils::GetShapeCellProperty(shape, "EndY", visPageUnits);
+ InstBegY = CShapeUtils::getShapeCell(shape, "BeginY");
+ InstEndY = CShapeUtils::getShapeCell(shape, "EndY");
//If instance is upside down, swap coordinates
if((InstBegY - InstEndY) < 0)
@@ -107,7 +114,7 @@
double msgBeginY = msgShape->Cells["BeginY"]->Result[visPageUnits];
double msgEndY = msgShape->Cells["EndY"]->Result[visPageUnits];
-#define _ip(x) CShapeUtils::GetShapeCellProperty((*it),x, visPageUnits);
+#define _ip(x) CShapeUtils::getShapeCell((*it),x);
for(std::vector<Visio::IVShapePtr>::const_iterator it = instances.begin(); it != instances.end(); it++)
{
@@ -123,7 +130,7 @@
switch(snapType)
{
case MSSNAP_STRAIGHTEN:
- intPoint = CPageUtils::getIntersectionPoint(VEC2(msgSnapPointX, msgSnapPointY), VEC2(msgSnapPointX - 1, msgSnapPointY), VEC2(instEndX, instEndY), VEC2(instBeginX, instBeginY));
+ intPoint = CMessageSnapping::getIntersectionWithInstance(VEC2(msgSnapPointX - 1, msgSnapPointY), VEC2(msgSnapPointX, msgSnapPointY), *it);
break;
case MSSNAP_PRESERVE_SLOPE:
intPoint = CMessageSnapping::getIntersectionWithInstance(msgShape, (*it));
@@ -131,7 +138,7 @@
}
//Check whether point is only on instanceLine
- if(!intPoint || intPoint->y > instBeginY || intPoint->y < instEndY || !isPointOnInstancesLine(*intPoint, *it))
+ if(!intPoint || !isPointOnInstancesLine(*intPoint, *it))
continue;
mouseDistX = msgSnapPointX - intPoint->x;
@@ -194,8 +201,8 @@
yLeftPos = yRightPos = yPos; //Y-coord for snap is same for both ends of message
break;
case MSSNAP_PRESERVE_VERTICAL:
- yLeftPos = CShapeUtils::GetShapeCellProperty(msgShape,"BeginY", visPageUnits); //Y-coord for begin point of msg
- yRightPos = CShapeUtils::GetShapeCellProperty(msgShape,"EndY", visPageUnits); //Y-coord for end point of msg
+ yLeftPos = CShapeUtils::getShapeCell(msgShape,"BeginY"); //Y-coord for begin point of msg
+ yRightPos = CShapeUtils::getShapeCell(msgShape,"EndY"); //Y-coord for end point of msg
break;
case MSSNAP_PRESERVE_SLOPE:
PVEC2 p = getIntersectionWithInstance(msgShape, leftInstance);
@@ -206,62 +213,69 @@
break;
}
+ MsgSeqDirection msgDir = getMsgDirection(msgShape);
//Glue to left instance
if(leftInstance)
- glueMsgToInstance(msgShape, leftInstance, "BeginX", yLeftPos);
+ glueMsgToInstance(msgShape, leftInstance, "BeginX", yLeftPos, msgDir);
//Glue to right instance
if(rightInstance)
- glueMsgToInstance(msgShape, rightInstance, "EndX", yRightPos);
+ glueMsgToInstance(msgShape, rightInstance, "EndX", yRightPos, msgDir);
}
void CMessageSnapping::glueMsgToInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape,
const _bstr_t & msgCell, double yPos)
{
- double posX = 0.0;
+ glueMsgToInstance(msgShape, instanceShape, msgCell, yPos, getMsgDirection(msgShape));
+}
+
+void CMessageSnapping::glueMsgToInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape,
+ const _bstr_t & msgCell, double yPos, MsgSeqDirection msgDirection)
+{
+ bool posX = 0;
Visio::IVShapePtr coregion;
//If instance include coregion, check for intersection with message
coregion = getCoregionAt(instanceShape, yPos);
if(coregion)
{
instanceShape = coregion;
- if(getMsgDirection(msgShape) == MSDIR_RIGHT)
- posX = (_tcsicmp(msgCell,_T("BeginX")) == 0) ? 1.0 : 0.0;
+ if(msgDirection == MSDIR_RIGHT)
+ posX = (_tcsicmp(msgCell,_T("BeginX")) == 0) ? 1 : 0;
else
- posX = (_tcsicmp(msgCell,_T("BeginX")) == 0) ? 0.0 : 1.0;
+ posX = (_tcsicmp(msgCell,_T("BeginX")) == 0) ? 0 : 1;
+
+ if(CShapeUtils::getShapeCell(instanceShape, "BeginY") < CShapeUtils::getShapeCell(instanceShape, "EndY"))
+ posX = !posX;
}
- double InstBegY = CShapeUtils::GetShapeCellProperty(instanceShape, "BeginY", visPageUnits);
- double InstEndY = CShapeUtils::GetShapeCellProperty(instanceShape, "EndY", visPageUnits);
+ double InstBegY = CShapeUtils::getShapeCell(instanceShape, "BeginY");
+ double InstEndY = CShapeUtils::getShapeCell(instanceShape, "EndY");
double sizeOfInstance = fabs(InstBegY - InstEndY);
double msgOffset = fabs(InstBegY - yPos);
//avoid division by zero - when instances are in horizontal position
- if(sizeOfInstance == 0)
+ if(sizeOfInstance == 0 || msgOffset > sizeOfInstance)
return;
msgShape->Application->EventsEnabled = false;
- msgShape->Cells[msgCell]->GlueToPos(instanceShape,msgOffset/sizeOfInstance,posX);
+ msgShape->Cells[msgCell]->GlueToPos(instanceShape,msgOffset/sizeOfInstance,(double)posX);
msgShape->Application->EventsEnabled = true;
}
-PVEC2 CMessageSnapping::getIntersectionWithInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape)
+PVEC2 CMessageSnapping::getIntersectionWithInstance(VEC2 beginPoint, VEC2 endPoint, Visio::IVShapePtr instanceShape)
{
- if(!msgShape || !instanceShape)
+ if(!instanceShape)
return NULL;
-#define _s(x) CShapeUtils::GetShapeCellProperty(msgShape, x, visPageUnits)
-#define _i(x) CShapeUtils::GetShapeCellProperty(instanceShape, x, visPageUnits)
-
VEC2 p1,p2,p3,p4;
- p1.x = _s("EndX"); p1.y = _s("EndY");
- p2.x = _s("BeginX"); p2.y = _s("BeginY");
+ p1.x = endPoint.x; p1.y = endPoint.y;
+ p2.x = beginPoint.x; p2.y = beginPoint.y;
+#define _i(x) CShapeUtils::getShapeCell(instanceShape, x)
p3.x = _i("EndX"); p3.y = _i("EndY");
p4.x = _i("BeginX"); p4.y = _i("BeginY");
+#undef _i
-#undef _s
-#undef _i
//FIXME: if coregion is oblique, snapping isn't always correct
if(get_shape_type(instanceShape) == ST_BMSC_COREGION)
{
@@ -272,7 +286,7 @@
std::swap(p1.y,p2.y);
}
- double offsetX = CShapeUtils::GetShapeCellProperty(instanceShape, "Height", visPageUnits) / 2.0;
+ double offsetX = CShapeUtils::getShapeCell(instanceShape, "Height") / 2.0;
offsetX *= (p2.x > p4.x) ? 1 : -1;
p4.x += offsetX;
@@ -293,9 +307,23 @@
return result;
}
+PVEC2 CMessageSnapping::getIntersectionWithInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape)
+{
+ if(!msgShape)
+ return NULL;
+
+#define _s(x) CShapeUtils::getShapeCell(msgShape, x)
+ VEC2 p1, p2;
+ p1.x = _s("EndX"); p1.y = _s("EndY");
+ p2.x = _s("BeginX"); p2.y = _s("BeginY");
+#undef _s
+
+ return getIntersectionWithInstance(p2, p1, instanceShape);
+}
+
bool CMessageSnapping::isPointOnInstancesLine(VEC2 point, Visio::IVShapePtr instShape)
{
-#define _sp(x) CShapeUtils::GetShapeCellProperty(instShape, x, visPageUnits)
+#define _sp(x) CShapeUtils::getShapeCell(instShape, x)
double InstOffset = 0;
@@ -317,8 +345,8 @@
if(!resultVector)
return false;
- double msgBegY = CShapeUtils::GetShapeCellProperty(msgShape, "BeginY", visPageUnits);
- double msgEndY = CShapeUtils::GetShapeCellProperty(msgShape, "EndY", visPageUnits);
+ double msgBegY = CShapeUtils::getShapeCell(msgShape, "BeginY");
+ double msgEndY = CShapeUtils::getShapeCell(msgShape, "EndY");
resultVector->x = msgShape->Cells["EndX"]->Result[""] - msgShape->Cells["BeginX"]->Result[""];
resultVector->y = msgShape->Cells["EndY"]->Result[""] - msgShape->Cells["BeginY"]->Result[""];
@@ -329,7 +357,7 @@
void CMessageSnapping::snap(Visio::IVShapePtr msgShape, double posX, double posY, MsgSnapType snapType)
{
long scopeID = msgShape->Application->BeginUndoScope(_T("snap"));
-#define _sp(x) CShapeUtils::GetShapeCellProperty(msgShape, x, visPageUnits)
+#define _sp(x) CShapeUtils::getShapeCell(msgShape, x)
//Step 1: Check snap type
if(snapType < 0 || snapType > 2)
@@ -367,16 +395,13 @@
//Step 5: If message is left-oriented switch pointers
if(getMsgDirection(msgShape) == MSDIR_LEFT)
- {
- Visio::IVShapePtr buffer = closestInst.first;
- closestInst.first = closestInst.second;
- closestInst.second = buffer;
- }
+ CShapeUtils::swapShape(closestInst.first, closestInst.second);
//Step 6:Glue to them
glueMsgToInstancesPair(msgShape, closestInst.first, closestInst.second, posY, snapType);
- //Step 7: Do some corrections if only one of instances intersect //FIXME: Cut to functions
+ //Step 7: Do some corrections if only one of instances intersect
+ //FIXME: Cut to functions
if(closestInst.first ^ closestInst.second)
{
//Step 7.1: Straighten messages when it's snapped only to one instance (must disable events, because CellChanged would be triggered)
@@ -426,24 +451,21 @@
return instances;
}
-bool CMessageSnapping::resnap(Visio::IVShapePtr msgShape, std::vector<Visio::IVShapePtr> instances)
+bool CMessageSnapping::resnap(Visio::IVShapePtr msgShape, std::vector<Visio::IVShapePtr> instances, double precision)
{
- long scopeId = msgShape->Application->BeginUndoScope(_T("resnap"));
+ long scopeId = msgShape->Application->BeginUndoScope(_T("Re-snap"));
VEC2 beginPoint = VEC2(msgShape->Cells["BeginX"]->Result[visPageUnits], msgShape->Cells["BeginY"]->Result[visPageUnits]);
VEC2 endPoint = VEC2(msgShape->Cells["EndX"]->Result[visPageUnits], msgShape->Cells["EndY"]->Result[visPageUnits]);
- if(instances.size() > 2 || instances.size() < 1)
- return false;
-
for(std::vector<Visio::IVShapePtr>::iterator it = instances.begin(); it != instances.end(); it++)
{
PVEC2 bufferPoint = getIntersectionWithInstance(msgShape,*it);
if(bufferPoint)
{
- if(pointsEqual(*bufferPoint, beginPoint) && isPointOnInstancesLine(beginPoint, *it))
+ if(pointsEqual(*bufferPoint, beginPoint, precision) && isPointOnInstancesLine(beginPoint, *it))
glueMsgToInstance(msgShape, *it, "BeginX", beginPoint.y);
- else if(pointsEqual(*bufferPoint, endPoint) && isPointOnInstancesLine(endPoint, *it))
+ else if(pointsEqual(*bufferPoint, endPoint, precision) && isPointOnInstancesLine(endPoint, *it))
glueMsgToInstance(msgShape, *it, "EndX", endPoint.y);
}
delete bufferPoint;
@@ -453,17 +475,17 @@
return true;
}
-bool CMessageSnapping::pointsEqual(VEC2 point1, VEC2 point2)
+bool CMessageSnapping::pointsEqual(VEC2 point1, VEC2 point2, double precision)
{
- return (abs(point1.x - point2.x) < 0.00000001) && (abs(point1.y - point2.y) < 0.00000001);
+ return (abs(point1.x - point2.x) < precision) && (abs(point1.y - point2.y) < precision);
}
Visio::IVShapePtr CMessageSnapping::getCoregionAt(Visio::IVShapePtr instShape, double yPos)
{
if(get_shape_type(instShape) == ST_BMSC_COREGION)
{
- double beginY = CShapeUtils::GetShapeCellProperty(instShape, "BeginY", visPageUnits);
- double endY = CShapeUtils::GetShapeCellProperty(instShape, "EndY", visPageUnits);
+ double beginY = CShapeUtils::getShapeCell(instShape, "BeginY");
+ double endY = CShapeUtils::getShapeCell(instShape, "EndY");
if(beginY < endY)
std::swap(beginY, endY);
if( (yPos <= beginY) && (yPos >= endY) ) //check boundaries
@@ -480,8 +502,8 @@
if(get_shape_type(shape) != ST_BMSC_COREGION)
continue;
- double beginY = CShapeUtils::GetShapeCellProperty(shape, "BeginY", visPageUnits); //NOTE: in page units, begin is bigger number than end
- double endY = CShapeUtils::GetShapeCellProperty(shape, "EndY", visPageUnits);
+ double beginY = CShapeUtils::getShapeCell(shape, "BeginY"); //NOTE: in page units, begin is bigger number than end
+ double endY = CShapeUtils::getShapeCell(shape, "EndY");
if(beginY < endY)
std::swap(beginY, endY);
if( (yPos <= beginY) && (yPos >= endY) )
@@ -493,8 +515,8 @@
MsgSeqDirection CMessageSnapping::getMsgDirection(Visio::IVShapePtr msgShape)
{
- double BeginX = CShapeUtils::GetShapeCellProperty(msgShape,"BeginX", visPageUnits);
- double EndX = CShapeUtils::GetShapeCellProperty(msgShape,"EndX", visPageUnits);
+ double BeginX = CShapeUtils::getShapeCell(msgShape,"BeginX");
+ double EndX = CShapeUtils::getShapeCell(msgShape,"EndX");
return (BeginX < EndX) ? MSDIR_RIGHT : MSDIR_LEFT;
}
Modified: trunk/src/view/visio/addon/messageSnapping.h
===================================================================
--- trunk/src/view/visio/addon/messageSnapping.h 2010-08-23 13:16:17 UTC (rev 857)
+++ trunk/src/view/visio/addon/messageSnapping.h 2010-08-23 15:53:29 UTC (rev 858)
@@ -29,6 +29,8 @@
static bool isEnabled();
static void setEnabled(bool bEnable = true);
+ static bool isArrowKeysEnabled();
+
static MsgSnapType getSnapType();
static void setSnapType(MsgSnapType snapType);
/*
@@ -55,12 +57,13 @@
* @param yPos vertical position where to glue message to instance (in page units - visPageUnits)
*/
static void glueMsgToInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape, const _bstr_t & msgCell, double yPos);
+ static void glueMsgToInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape, const _bstr_t & msgCell, double yPos, MsgSeqDirection msgDirection);
/*
*
*/
+ static PVEC2 getIntersectionWithInstance(VEC2 beginPoint, VEC2 endPoint, Visio::IVShapePtr instanceShape);
static PVEC2 getIntersectionWithInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape);
-
/*
*
*/
@@ -77,13 +80,12 @@
* @param posX MouseX position for closest instances computing
* @param posY MouseY position for closest instances computing
*/
- //FIXME: Change return type to bool
static void snap(Visio::IVShapePtr msgShape, double posX, double posY, MsgSnapType snapType);
/*
* Snap message to instaces whether its enpoints are on the instance's line
*/
- static bool resnap(Visio::IVShapePtr msgShape, std::vector<Visio::IVShapePtr> instances);
+ static bool resnap(Visio::IVShapePtr msgShape, std::vector<Visio::IVShapePtr> instances, double precision = 0.0000001);
/*
* Get all instances the given message is connected to
*/
@@ -91,7 +93,7 @@
/*
*
*/
- static bool pointsEqual(VEC2 point1, VEC2 point2);
+ static bool pointsEqual(VEC2 point1, VEC2 point2, double precision = 0.0000001);
/*
* The very same function as CShapeUtils::getCoregionAt but yPos is in page units!
*/
Modified: trunk/src/view/visio/addon/resource.h
===================================================================
--- trunk/src/view/visio/addon/resource.h 2010-08-23 13:16:17 UTC (rev 857)
+++ trunk/src/view/visio/addon/resource.h 2010-08-23 15:53:29 UTC (rev 858)
@@ -47,7 +47,9 @@
#define IDD_SNAP_GLOBAL 227
#define IDC_OPTIONS_GROUP_BOX 228
#define IDC_IF_LBL1 229
+#define IDI_ICON_JUMP_LEFT 229
#define IDC_IF_LBL2 230
+#define IDI_ICON_JUMP_RIGHT 230
#define IDC_IF_LBL3 231
#define IDC_IF_SPACING_SWITCH 232
#define IDC_IF_SPACING 233
@@ -70,6 +72,7 @@
#define IDC_ADDITION 253
#define IDC_MS_LEFT_MESSAGE 254
#define IDC_CHECK_ENUMERATE_NEW 254
+#define IDC_EDGE_THREATMENT_ENABLED 254
#define IDC_MS_RIGHT_MESSAGE 255
#define IDC_STARTING_INDEX 255
#define IDC_MS_YSTART 256
@@ -100,6 +103,7 @@
#define IDC_CHECK2 271
#define IDC_ENUM_CHECK 271
#define IDC_ONLY_ON_LINE 271
+#define IDC_KEYS_ENABLED 271
#define IDC_RADIO4 273
#define IDC_USE_NUMBERING_STYLE 273
#define IDC_COMBO_NUMBERING_GLOBAL 276
@@ -113,14 +117,17 @@
#define IDC_CUSTOM1 287
#define IDC_RADIO1 288
#define IDC_STRAIGHTEN 288
+#define IDC_BUTTONS_ENABLED 289
+#define IDC_EDGE_PRESERVE_TYPE 291
+#define IDC_EDGE_CHANGE_TYPE 292
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 229
+#define _APS_NEXT_RESOURCE_VALUE 231
#define _APS_NEXT_COMMAND_VALUE 32768
-#define _APS_NEXT_CONTROL_VALUE 289
+#define _APS_NEXT_CONTROL_VALUE 294
#define _APS_NEXT_SYMED_VALUE 105
#endif
#endif
Modified: trunk/src/view/visio/addon/scstudio.vcproj
===================================================================
--- trunk/src/view/visio/addon/scstudio.vcproj 2010-08-23 13:16:17 UTC (rev 857)
+++ trunk/src/view/visio/addon/scstudio.vcproj 2010-08-23 15:53:29 UTC (rev 858)
@@ -352,6 +352,14 @@
>
</File>
<File
+ RelativePath=".\messageJump.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\messageJump.h"
+ >
+ </File>
+ <File
RelativePath=".\messagesequencedlg.cpp"
>
</File>
@@ -490,6 +498,14 @@
>
</File>
<File
+ RelativePath=".\icon_jump_left_messages.ico"
+ >
+ </File>
+ <File
+ RelativePath=".\icon_jump_right_messages.ico"
+ >
+ </File>
+ <File
RelativePath=".\icon_message_enumeration.ico"
>
</File>
Modified: trunk/src/view/visio/addon/shapeutils.cpp
===================================================================
--- trunk/src/view/visio/addon/shapeutils.cpp 2010-08-23 13:16:17 UTC (rev 857)
+++ trunk/src/view/visio/addon/shapeutils.cpp 2010-08-23 15:53:29 UTC (rev 858)
@@ -83,6 +83,13 @@
return NULL;
}
+void CShapeUtils::swapShape(Visio::IVShapePtr& shape1, Visio::IVShapePtr& shape2)
+{
+ Visio::IVShapePtr buffer = shape1;
+ shape1 = shape2;
+ shape2 = buffer;
+}
+
bool CShapeComparator::operator()(const Visio::IVShapePtr shapeOne, const Visio::IVShapePtr shapeTwo)
{
if (direction == ORDER_ASC)
Modified: trunk/src/view/visio/addon/shapeutils.h
===================================================================
--- trunk/src/view/visio/addon/shapeutils.h 2010-08-23 13:16:17 UTC (rev 857)
+++ trunk/src/view/visio/addon/shapeutils.h 2010-08-23 15:53:29 UTC (rev 858)
@@ -35,7 +35,7 @@
static double GetShapeBeginY(Visio::IVShapePtr shape) { return shape->CellsSRC[visSectionObject][visRowXForm1D][vis1DBeginY]->Result[""]; }
static double GetShapeEndY(Visio::IVShapePtr shape) { return shape->CellsSRC[visSectionObject][visRowXForm1D][vis1DEndY]->Result[""]; }
- static double GetShapeCellProperty(Visio::IVShapePtr shape, const _bstr_t & propertyName, VisUnitCodes units)
+ static double getShapeCell(Visio::IVShapePtr shape, const _bstr_t & propertyName, VisUnitCodes units = visPageUnits)
{ return shape->Cells[propertyName]->Result[units]; }
static void GlueBeginToPos(Visio::IVShapePtr what, Visio::IVShapePtr where, const MscPoint& pos);
@@ -52,6 +52,8 @@
* @return pointer to the coregion found or NULL if there is no such coregion
*/
static Visio::IVShapePtr GetCoregionAt(Visio::IVShapePtr shape, double yPos);
+
+ static void swapShape(Visio::IVShapePtr& shape1, Visio::IVShapePtr& shape2);
};
/**
Modified: trunk/src/view/visio/addon/snapGlobalDlg.cpp
===================================================================
--- trunk/src/view/visio/addon/snapGlobalDlg.cpp 2010-08-23 13:16:17 UTC (rev 857)
+++ trunk/src/view/visio/addon/snapGlobalDlg.cpp 2010-08-23 15:53:29 UTC (rev 858)
@@ -23,6 +23,12 @@
#include <htmlhelp.h>
+CSnapGlobalDlg::~CSnapGlobalDlg()
+{
+ if(IsWindow())
+ DestroyWindow();
+}
+
BOOL CSnapGlobalDlg::OnInitDialog(HWND hWndFocus, LPARAM lParam)
{
LoadRegistryData();
@@ -30,7 +36,8 @@
DoDataExchange(FALSE);
//Enable/disable controls on the dialog
- EnableControls(m_bSnapEnabled);
+ EnableSnapControls(m_bSnapEnabled);
+ EnableEdgeControls(m_bEdgeTreatmentEnabled);
return TRUE;
}
@@ -65,8 +72,13 @@
int CSnapGlobalDlg::LoadRegistryData()
{
TRACE(_T("CSnapGlobalDlg::LoadRegistryData() - Loading options from registry"));
+ //Set buttons check box to checked (for whole time)
+ m_bButtonsEnabled = true;
+ m_bKeysEnabled = GetRegistry<bool>(GetRegistryFolder(), NULL, _T("KeysEnabled"), false);
m_bSnapEnabled = GetRegistry<bool>(GetRegistryFolder(), NULL, _T("SnapEnabled"), false);
+ m_bEdgeTreatmentEnabled = GetRegistry<bool>(GetRegistryFolder(), NULL, _T("EdgeTreatmentEnabled"), false);
m_iRadioSelection = GetRegistry<int>(GetRegistryFolder(), NULL, _T("SnapType"), 0);
+ m_iEdgeRadioSelection = GetRegistry<int>(GetRegistryFolder(), NULL, _T("EdgeTreatmentType"), 0);
return 0;
}
@@ -75,23 +87,38 @@
{
TRACE(_T("CSnapGlobalDlg::LoadRegistryData() - Saving options to registry"));
SetRegistry<bool>(HKEY_CURRENT_USER, GetRegistryFolder(), _T("SnapEnabled"), m_bSnapEnabled);
+ SetRegistry<bool>(HKEY_CURRENT_USER, GetRegistryFolder(), _T("KeysEnabled"), m_bKeysEnabled);
+ SetRegistry<bool>(HKEY_CURRENT_USER, GetRegistryFolder(), _T("EdgeTreatmentEnabled"), m_bEdgeTreatmentEnabled);
SetRegistry<int>(HKEY_CURRENT_USER, GetRegistryFolder(), _T("SnapType"), m_iRadioSelection);
+ SetRegistry<int>(HKEY_CURRENT_USER, GetRegistryFolder(), _T("EdgeTreatmentType"), m_iEdgeRadioSelection);
return 0;
}
-void CSnapGlobalDlg::EnableControls(bool bEnable)
+void CSnapGlobalDlg::EnableSnapControls(bool bEnable)
{
GetDlgItem(IDC_STRAIGHTEN).EnableWindow(bEnable);
GetDlgItem(IDC_PRESERVE_VERTICAL).EnableWindow(bEnable);
GetDlgItem(IDC_PRESERVE_SLOPE).EnableWindow(bEnable);
}
+void CSnapGlobalDlg::EnableEdgeControls(bool bEnable)
+{
+ GetDlgItem(IDC_EDGE_PRESERVE_TYPE).EnableWindow(bEnable);
+ GetDlgItem(IDC_EDGE_CHANGE_TYPE).EnableWindow(bEnable);
+}
+
LRESULT CSnapGlobalDlg::OnBnClickedSnapEnabled(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
DoDataExchange(TRUE);
- EnableControls(m_bSnapEnabled);
+ EnableSnapControls(m_bSnapEnabled);
+ return 0;
+}
+LRESULT CSnapGlobalDlg::OnBnClickedEdgeEnabled(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
+{
+ DoDataExchange(TRUE);
+ EnableEdgeControls(m_bEdgeTreatmentEnabled);
return 0;
}
Modified: trunk/src/view/visio/addon/snapGlobalDlg.h
===================================================================
--- trunk/src/view/visio/addon/snapGlobalDlg.h 2010-08-23 13:16:17 UTC (rev 857)
+++ trunk/src/view/visio/addon/snapGlobalDlg.h 2010-08-23 15:53:29 UTC (rev 858)
@@ -36,32 +36,44 @@
{ //set dialog properties
m_psp.dwFlags |= PSP_HASHELP;
};
+ ~CSnapGlobalDlg();
protected:
BEGIN_MSG_MAP(CSnapGlobalDlg)
MSG_WM_INITDIALOG(OnInitDialog)
COMMAND_HANDLER(IDC_SNAP_ENABLED, BN_CLICKED, OnBnClickedSnapEnabled)
+ COMMAND_HANDLER(IDC_EDGE_THREATMENT_ENABLED, BN_CLICKED, OnBnClickedEdgeEnabled)
CHAIN_MSG_MAP(CPropertyPageImpl<CSnapGlobalDlg>)
END_MSG_MAP()
BEGIN_DDX_MAP(CSnapGlobalDlg)
+ DDX_CHECK(IDC_BUTTONS_ENABLED, m_bButtonsEnabled);
+ DDX_CHECK(IDC_KEYS_ENABLED, m_bKeysEnabled);
DDX_CHECK(IDC_SNAP_ENABLED, m_bSnapEnabled);
+ DDX_CHECK(IDC_EDGE_THREATMENT_ENABLED, m_bEdgeTreatmentEnabled);
DDX_RADIO(IDC_STRAIGHTEN, m_iRadioSelection);
+ DDX_RADIO(IDC_EDGE_PRESERVE_TYPE, m_iEdgeRadioSelection);
END_DDX_MAP()
int LoadRegistryData();
int SaveRegistryData();
//Member variables
+ bool m_bKeysEnabled;
bool m_bSnapEnabled;
+ bool m_bButtonsEnabled;
bool m_bOnlyOnLine;
+ bool m_bEdgeTreatmentEnabled;
int m_iRadioSelection;
+ int m_iEdgeRadioSelection;
Visio::IVApplicationPtr m_vsoApp;
- void EnableControls(bool bEnable = true);
+ void EnableSnapControls(bool bEnable = true);
+ void EnableEdgeControls(bool bEnable = true);
LRESULT OnBnClickedSnapEnabled(WORD, WORD, HWND, BOOL&);
+ LRESULT OnBnClickedEdgeEnabled(WORD, WORD, HWND, BOOL&);
public:
//Message handlers
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|