|
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 di...
[truncated message content] |
|
From: <mbe...@us...> - 2010-08-23 22:25:25
|
Revision: 859
http://scstudio.svn.sourceforge.net/scstudio/?rev=859&view=rev
Author: mbezdeka
Date: 2010-08-23 22:25:18 +0000 (Mon, 23 Aug 2010)
Log Message:
-----------
- resnap improved
- bugs fixed
Modified Paths:
--------------
trunk/src/view/visio/addon/addon.cpp
trunk/src/view/visio/addon/document.cpp
trunk/src/view/visio/addon/messageJump.cpp
trunk/src/view/visio/addon/messageJump.h
trunk/src/view/visio/addon/messageSnapping.cpp
trunk/src/view/visio/addon/messageSnapping.h
Modified: trunk/src/view/visio/addon/addon.cpp
===================================================================
--- trunk/src/view/visio/addon/addon.cpp 2010-08-23 15:53:29 UTC (rev 858)
+++ trunk/src/view/visio/addon/addon.cpp 2010-08-23 22:25:18 UTC (rev 859)
@@ -665,22 +665,13 @@
{
m_bArrowKeyDown = true;
Visio::IVSelectionPtr selection = vsoApp->ActiveWindow->Selection;
- 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;
}
}
@@ -713,22 +704,24 @@
{
m_bArrowKeyDown = false;
Visio::IVSelectionPtr selection = vsoApp->ActiveWindow->Selection;
+ Visio::IVShapesPtr shapes = vsoApp->ActivePage->Shapes;
+ Visio::IVShapePtr shape = selection->Item[1];
switch(keyCode)
{
case VK_LEFT:
case VK_RIGHT:
- if(CMessageSnapping::isArrowKeysEnabled())
+ if(CMessageSnapping::isArrowKeysEnabled() && GetDocumentMonitor(vsoApp, vsoApp->ActiveDocument)->isMessageShape(shape))
{
- 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);
+ if(CMessageJump::getMsgNeedsResnap(shape))
+ CMessageSnapping::resnap(shape, shapes, 0.0001);
break;
}
case VK_UP:
case VK_DOWN:
for(int i=1; i<=selection->Count; i++)
- CMessageSnapping::resnap(selection->Item[i], instances);
+ CMessageSnapping::resnap(selection->Item[i], shapes);
break;
}
instances.clear();
@@ -783,10 +776,13 @@
if(m_bAngleChanged && (m_bBeginChanged ^ m_bEndChanged) && (get_shape_type(selection->Item[1]) == ST_BMSC_INSTANCE))
{
m_bAngleChanged = false;
+ Visio::IVShapePtr shape = selection->Item[1];
if(m_bBeginChanged)
- selection->Item[1]->Cells["BeginX"]->FormulaForceU = selection->Item[1]->Cells["EndX"]->Formula;
+ shape->Cells["BeginX"]->FormulaForceU = shape->Cells["EndX"]->Formula;
if(m_bEndChanged)
- selection->Item[1]->Cells["EndX"]->FormulaForceU = selection->Item[1]->Cells["BeginX"]->Formula;
+ shape->Cells["EndX"]->FormulaForceU = shape->Cells["BeginX"]->Formula;
+ if(CShapeUtils::getShapeCell(shape,"BeginY") < CShapeUtils::getShapeCell(shape,"EndY"))
+ shape->Cells["BeginY"]->FormulaForceU = stringize() << 2 * shape->Cells["EndY"]->Result[""] - shape->Cells["BeginY"]->Result[""];
}
////////////////////////////////////////////////////
Modified: trunk/src/view/visio/addon/document.cpp
===================================================================
--- trunk/src/view/visio/addon/document.cpp 2010-08-23 15:53:29 UTC (rev 858)
+++ trunk/src/view/visio/addon/document.cpp 2010-08-23 22:25:18 UTC (rev 859)
@@ -263,8 +263,7 @@
case ST_BMSC_MESSAGE_LOST:
case ST_BMSC_MESSAGE_FOUND:
if(vsoShape->Text.length() == 0)
- vsoShape->Text = _T("NAME");
-
+ vsoShape->Text = _T("NAME");
if(CMessageSnapping::isEnabled() && (m_vsoApp->ActiveWindow->Selection->Count == 1)) //Check whether snapping is enabled
{
double posX = CShapeUtils::getShapeCell(vsoShape,"PinX");
@@ -1138,6 +1137,8 @@
if(!CMessageJump::jump(shape, CMessageSnapping::getConnectedInstances(shape), (MsgJumpDirection)left))
CMessageSnapping::snap(shape, CShapeUtils::getShapeCell(shape, "PinX"), CShapeUtils::getShapeCell(shape, "PinY"), MSSNAP_PRESERVE_VERTICAL);
+ if(CMessageJump::getMsgNeedsResnap(shape))
+ CMessageSnapping::resnap(shape, vsoApp->ActivePage->Shapes, 0.0001);
return VAORC_SUCCESS;
}
Modified: trunk/src/view/visio/addon/messageJump.cpp
===================================================================
--- trunk/src/view/visio/addon/messageJump.cpp 2010-08-23 15:53:29 UTC (rev 858)
+++ trunk/src/view/visio/addon/messageJump.cpp 2010-08-23 22:25:18 UTC (rev 859)
@@ -68,6 +68,10 @@
return false;
}
+ //Erase information about re-snaping
+ if(origIntsLeft && origIntsRight && getMsgNeedsResnap(msgShape))
+ setMsgNeedsResnap(msgShape, 0);
+
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);
@@ -106,14 +110,18 @@
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[""];
+ newMsg->Cells["BeginX"]->Formula = msgShape->Cells["BeginX"]->ResultStr[visMillimeters];
+ newMsg->Cells["BeginY"]->Formula = msgShape->Cells["BeginY"]->ResultStr[visMillimeters];
+ newMsg->Cells["EndX"]->Formula = msgShape->Cells["EndX"]->ResultStr[visMillimeters];
+ newMsg->Cells["EndY"]->Formula = msgShape->Cells["EndY"]->ResultStr[visMillimeters];
msgShape->Application->EventsEnabled = true;
msgShape->Delete();
msgShape = newMsg;
+ if(getEdgeInstanceTreatment() == 0)
+ setMsgNeedsResnap(msgShape, true);
+
+
CMessageSnapping::setEnabled(snapStatus);
}
@@ -125,13 +133,13 @@
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;
+ msgShape->Cells["EndX"]->Formula = stringize() << msgShape->Cells["BeginX"]->Result[visMillimeters] + msgVec.x << " mm";
+ msgShape->Cells["EndY"]->Formula = stringize() << msgShape->Cells["BeginY"]->Result[visMillimeters] + msgVec.y << " mm";
}
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->Cells["BeginX"]->Formula = stringize() << msgShape->Cells["EndX"]->Result[visMillimeters] - msgVec.x << " mm";
+ msgShape->Cells["BeginY"]->Formula = stringize() << msgShape->Cells["EndY"]->Result[visMillimeters] - msgVec.y << " mm";
}
msgShape->Application->EventsEnabled = true;
}
@@ -177,5 +185,27 @@
return closestInstance;
}
+bool CMessageJump::getMsgNeedsResnap(Visio::IVShapePtr msgShape)
+{
+ if(!msgShape->GetCellExists(_T("User.Resnap"),0))
+ return false;
+ if(msgShape->Cells["User.Resnap"]->ResultInt[visNone][visTruncate] != 1)
+ return false;
+ return true;
+}
+
+void CMessageJump::setMsgNeedsResnap(Visio::IVShapePtr msgShape, bool bTrueIfNeeds)
+{
+ bool bCellExists = (msgShape->GetCellExists(_T("User.Resnap"),0) == -1);
+
+ if(bTrueIfNeeds && !bCellExists)
+ {
+ msgShape->AddNamedRow(visSectionUser, _T("Resnap"), 0);
+ msgShape->Cells["User.Resnap"]->FormulaU = _T("1");
+ }
+ else if(!bTrueIfNeeds && bCellExists)
+ msgShape->DeleteRow(visSectionUser,msgShape->CellsRowIndex["User.Resnap"]);
+}
+
// $Id$
\ No newline at end of file
Modified: trunk/src/view/visio/addon/messageJump.h
===================================================================
--- trunk/src/view/visio/addon/messageJump.h 2010-08-23 15:53:29 UTC (rev 858)
+++ trunk/src/view/visio/addon/messageJump.h 2010-08-23 22:25:18 UTC (rev 859)
@@ -36,6 +36,9 @@
*/
static Visio::IVShapePtr getClosestInstanceFromShape(VEC2 pointOnShape, Visio::IVShapePtr shape,
std::vector<Visio::IVShapePtr> instances, MsgJumpDirection direction);
+
+ static bool getMsgNeedsResnap(Visio::IVShapePtr msgShape);
+ static void setMsgNeedsResnap(Visio::IVShapePtr msgShape, bool bTrueIfNeeds);
};
// $Id$
\ No newline at end of file
Modified: trunk/src/view/visio/addon/messageSnapping.cpp
===================================================================
--- trunk/src/view/visio/addon/messageSnapping.cpp 2010-08-23 15:53:29 UTC (rev 858)
+++ trunk/src/view/visio/addon/messageSnapping.cpp 2010-08-23 22:25:18 UTC (rev 859)
@@ -223,18 +223,18 @@
}
void CMessageSnapping::glueMsgToInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape,
- const _bstr_t & msgCell, double yPos)
+ const _bstr_t & msgCell, double yPos, VisUnitCodes units)
{
- glueMsgToInstance(msgShape, instanceShape, msgCell, yPos, getMsgDirection(msgShape));
+ glueMsgToInstance(msgShape, instanceShape, msgCell, yPos, getMsgDirection(msgShape), units);
}
void CMessageSnapping::glueMsgToInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape,
- const _bstr_t & msgCell, double yPos, MsgSeqDirection msgDirection)
+ const _bstr_t & msgCell, double yPos, MsgSeqDirection msgDirection, VisUnitCodes units)
{
bool posX = 0;
Visio::IVShapePtr coregion;
//If instance include coregion, check for intersection with message
- coregion = getCoregionAt(instanceShape, yPos);
+ coregion = getCoregionAt(instanceShape, yPos, units);
if(coregion)
{
instanceShape = coregion;
@@ -243,12 +243,12 @@
else
posX = (_tcsicmp(msgCell,_T("BeginX")) == 0) ? 0 : 1;
- if(CShapeUtils::getShapeCell(instanceShape, "BeginY") < CShapeUtils::getShapeCell(instanceShape, "EndY"))
+ if(CShapeUtils::getShapeCell(instanceShape, "BeginY", units) < CShapeUtils::getShapeCell(instanceShape, "EndY", units))
posX = !posX;
}
- double InstBegY = CShapeUtils::getShapeCell(instanceShape, "BeginY");
- double InstEndY = CShapeUtils::getShapeCell(instanceShape, "EndY");
+ double InstBegY = CShapeUtils::getShapeCell(instanceShape, "BeginY", units);
+ double InstEndY = CShapeUtils::getShapeCell(instanceShape, "EndY", units);
double sizeOfInstance = fabs(InstBegY - InstEndY);
double msgOffset = fabs(InstBegY - yPos);
@@ -262,7 +262,7 @@
msgShape->Application->EventsEnabled = true;
}
-PVEC2 CMessageSnapping::getIntersectionWithInstance(VEC2 beginPoint, VEC2 endPoint, Visio::IVShapePtr instanceShape)
+PVEC2 CMessageSnapping::getIntersectionWithInstance(VEC2 beginPoint, VEC2 endPoint, Visio::IVShapePtr instanceShape, VisUnitCodes units)
{
if(!instanceShape)
return NULL;
@@ -271,7 +271,7 @@
p1.x = endPoint.x; p1.y = endPoint.y;
p2.x = beginPoint.x; p2.y = beginPoint.y;
-#define _i(x) CShapeUtils::getShapeCell(instanceShape, x)
+#define _i(x) CShapeUtils::getShapeCell(instanceShape, x, units)
p3.x = _i("EndX"); p3.y = _i("EndY");
p4.x = _i("BeginX"); p4.y = _i("BeginY");
#undef _i
@@ -286,7 +286,7 @@
std::swap(p1.y,p2.y);
}
- double offsetX = CShapeUtils::getShapeCell(instanceShape, "Height") / 2.0;
+ double offsetX = CShapeUtils::getShapeCell(instanceShape, "Height", units) / 2.0;
offsetX *= (p2.x > p4.x) ? 1 : -1;
p4.x += offsetX;
@@ -307,23 +307,23 @@
return result;
}
-PVEC2 CMessageSnapping::getIntersectionWithInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape)
+PVEC2 CMessageSnapping::getIntersectionWithInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape, VisUnitCodes units)
{
if(!msgShape)
return NULL;
-#define _s(x) CShapeUtils::getShapeCell(msgShape, x)
+#define _s(x) CShapeUtils::getShapeCell(msgShape, x, units)
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);
+ return getIntersectionWithInstance(p2, p1, instanceShape, units);
}
-bool CMessageSnapping::isPointOnInstancesLine(VEC2 point, Visio::IVShapePtr instShape)
+bool CMessageSnapping::isPointOnInstancesLine(VEC2 point, Visio::IVShapePtr instShape, VisUnitCodes units)
{
-#define _sp(x) CShapeUtils::getShapeCell(instShape, x)
+#define _sp(x) CShapeUtils::getShapeCell(instShape, x, units)
double InstOffset = 0;
@@ -340,7 +340,7 @@
#undef _sp
}
-bool CMessageSnapping::getMsgVector(Visio::IVShapePtr msgShape, PVEC2 resultVector)
+bool CMessageSnapping::getMsgVector(Visio::IVShapePtr msgShape, PVEC2 resultVector, VisUnitCodes units)
{
if(!resultVector)
return false;
@@ -348,8 +348,8 @@
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[""];
+ resultVector->x = msgShape->Cells["EndX"]->Result[units] - msgShape->Cells["BeginX"]->Result[units];
+ resultVector->y = msgShape->Cells["EndY"]->Result[units] - msgShape->Cells["BeginY"]->Result[units];
return true;
}
@@ -367,7 +367,7 @@
}
VEC2 msgVec;
- if(!getMsgVector(msgShape, &msgVec))
+ if(!getMsgVector(msgShape, &msgVec, (VisUnitCodes) 0))
return;
//Step 2: If message is only horizontal we can take as Y coord PinY and don't have to calculate oblique
@@ -451,22 +451,26 @@
return instances;
}
-bool CMessageSnapping::resnap(Visio::IVShapePtr msgShape, std::vector<Visio::IVShapePtr> instances, double precision)
+bool CMessageSnapping::resnap(Visio::IVShapePtr msgShape, Visio::IVShapesPtr shapes, double precision)
{
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]);
+ VEC2 beginPoint = VEC2(msgShape->Cells["BeginX"]->Result[""], msgShape->Cells["BeginY"]->Result[""]);
+ VEC2 endPoint = VEC2(msgShape->Cells["EndX"]->Result[""], msgShape->Cells["EndY"]->Result[""]);
- for(std::vector<Visio::IVShapePtr>::iterator it = instances.begin(); it != instances.end(); it++)
+ for(int i=1; i<=shapes->Count; i++)
{
- PVEC2 bufferPoint = getIntersectionWithInstance(msgShape,*it);
+ Visio::IVShapePtr it = shapes->Item[i];
+ if(!(get_shape_type(it) == ST_BMSC_INSTANCE || get_shape_type(it) == ST_BMSC_COREGION))
+ continue;
+
+ PVEC2 bufferPoint = getIntersectionWithInstance(msgShape,it, (VisUnitCodes)0);
if(bufferPoint)
{
- if(pointsEqual(*bufferPoint, beginPoint, precision) && isPointOnInstancesLine(beginPoint, *it))
- glueMsgToInstance(msgShape, *it, "BeginX", beginPoint.y);
- else if(pointsEqual(*bufferPoint, endPoint, precision) && isPointOnInstancesLine(endPoint, *it))
- glueMsgToInstance(msgShape, *it, "EndX", endPoint.y);
+ if(pointsEqual(*bufferPoint, beginPoint, precision) && isPointOnInstancesLine(beginPoint, it, (VisUnitCodes)0))
+ glueMsgToInstance(msgShape, it, "BeginX", beginPoint.y, (VisUnitCodes)0);
+ else if(pointsEqual(*bufferPoint, endPoint, precision) && isPointOnInstancesLine(endPoint, it, (VisUnitCodes)0))
+ glueMsgToInstance(msgShape, it, "EndX", endPoint.y, (VisUnitCodes)0);
}
delete bufferPoint;
}
@@ -480,12 +484,12 @@
return (abs(point1.x - point2.x) < precision) && (abs(point1.y - point2.y) < precision);
}
-Visio::IVShapePtr CMessageSnapping::getCoregionAt(Visio::IVShapePtr instShape, double yPos)
+Visio::IVShapePtr CMessageSnapping::getCoregionAt(Visio::IVShapePtr instShape, double yPos, VisUnitCodes units)
{
if(get_shape_type(instShape) == ST_BMSC_COREGION)
{
- double beginY = CShapeUtils::getShapeCell(instShape, "BeginY");
- double endY = CShapeUtils::getShapeCell(instShape, "EndY");
+ double beginY = CShapeUtils::getShapeCell(instShape, "BeginY", units);
+ double endY = CShapeUtils::getShapeCell(instShape, "EndY", units);
if(beginY < endY)
std::swap(beginY, endY);
if( (yPos <= beginY) && (yPos >= endY) ) //check boundaries
@@ -502,8 +506,8 @@
if(get_shape_type(shape) != ST_BMSC_COREGION)
continue;
- double beginY = CShapeUtils::getShapeCell(shape, "BeginY"); //NOTE: in page units, begin is bigger number than end
- double endY = CShapeUtils::getShapeCell(shape, "EndY");
+ double beginY = CShapeUtils::getShapeCell(shape, "BeginY", units);
+ double endY = CShapeUtils::getShapeCell(shape, "EndY", units);
if(beginY < endY)
std::swap(beginY, endY);
if( (yPos <= beginY) && (yPos >= endY) )
Modified: trunk/src/view/visio/addon/messageSnapping.h
===================================================================
--- trunk/src/view/visio/addon/messageSnapping.h 2010-08-23 15:53:29 UTC (rev 858)
+++ trunk/src/view/visio/addon/messageSnapping.h 2010-08-23 22:25:18 UTC (rev 859)
@@ -56,23 +56,25 @@
* @param msgCell message cell which should be glued (e.g. BeginX, EndY)
* @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 void glueMsgToInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape, const _bstr_t & msgCell, double yPos,
+ VisUnitCodes units = visPageUnits);
+ static void glueMsgToInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape, const _bstr_t & msgCell, double yPos,
+ MsgSeqDirection msgDirection, VisUnitCodes units = visPageUnits);
/*
*
*/
- static PVEC2 getIntersectionWithInstance(VEC2 beginPoint, VEC2 endPoint, Visio::IVShapePtr instanceShape);
- static PVEC2 getIntersectionWithInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape);
+ static PVEC2 getIntersectionWithInstance(VEC2 beginPoint, VEC2 endPoint, Visio::IVShapePtr instanceShape, VisUnitCodes units = visPageUnits);
+ static PVEC2 getIntersectionWithInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape, VisUnitCodes units = visPageUnits);
/*
*
*/
- static bool isPointOnInstancesLine(VEC2 point, Visio::IVShapePtr instShape);
+ static bool isPointOnInstancesLine(VEC2 point, Visio::IVShapePtr instShape, VisUnitCodes units = visPageUnits);
/*
* Get Directional vector of given message shape
*/
- static bool getMsgVector(Visio::IVShapePtr msgShape, PVEC2 resultVector);
+ static bool getMsgVector(Visio::IVShapePtr msgShape, PVEC2 resultVector, VisUnitCodes units = visMillimeters);
/*
* automatically snaps current message to nearest instances
@@ -85,7 +87,7 @@
/*
* Snap message to instaces whether its enpoints are on the instance's line
*/
- static bool resnap(Visio::IVShapePtr msgShape, std::vector<Visio::IVShapePtr> instances, double precision = 0.0000001);
+ static bool resnap(Visio::IVShapePtr msgShape, Visio::IVShapesPtr shapes, double precision = 0.0000001);
/*
* Get all instances the given message is connected to
*/
@@ -97,7 +99,7 @@
/*
* The very same function as CShapeUtils::getCoregionAt but yPos is in page units!
*/
- static Visio::IVShapePtr getCoregionAt(Visio::IVShapePtr instShape, double yPos);
+ static Visio::IVShapePtr getCoregionAt(Visio::IVShapePtr instShape, double yPos, VisUnitCodes units = visPageUnits);
/*
* Returns the direction of given message
*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mbe...@us...> - 2010-08-25 10:46:59
|
Revision: 860
http://scstudio.svn.sourceforge.net/scstudio/?rev=860&view=rev
Author: mbezdeka
Date: 2010-08-25 10:46:51 +0000 (Wed, 25 Aug 2010)
Log Message:
-----------
- added full functionality of preventing instance from rotation
- VEC2 strcture changed to MscPoint (Message snapping)
- added global dialog Protection
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/extract.cpp
trunk/src/view/visio/addon/extract.h
trunk/src/view/visio/addon/globalSettingsDlg.cpp
trunk/src/view/visio/addon/globalSettingsDlg.h
trunk/src/view/visio/addon/messageJump.cpp
trunk/src/view/visio/addon/messageSnapping.cpp
trunk/src/view/visio/addon/messageSnapping.h
trunk/src/view/visio/addon/pageutils.cpp
trunk/src/view/visio/addon/pageutils.h
trunk/src/view/visio/addon/resource.h
trunk/src/view/visio/addon/scstudio.vcproj
Added Paths:
-----------
trunk/src/view/visio/addon/protectionGlobalDlg.cpp
trunk/src/view/visio/addon/protectionGlobalDlg.h
Modified: trunk/src/view/visio/addon/addon.cpp
===================================================================
--- trunk/src/view/visio/addon/addon.cpp 2010-08-23 22:25:18 UTC (rev 859)
+++ trunk/src/view/visio/addon/addon.cpp 2010-08-25 10:46:51 UTC (rev 860)
@@ -528,6 +528,10 @@
HandleNonePending(pSourceObj);
break;
+ case visEvtApp+visEvtIdle:
+ HandleVisioIsIdle(pSourceObj);
+ break;
+
case visEvtMod+visEvtText:
HandleTextChanged(pSubjectObj,pSourceObj);
break;
@@ -574,8 +578,7 @@
}
}
- if((_tcsicmp(vsoCell->Name,_T("PinX")) == 0 || _tcsicmp(vsoCell->Name,_T("PinY")) == 0) &&
- (GetDocumentMonitor(vsoCell->Application,vsoCell->Application->ActiveDocument)->isMessageShape(vsoCell->Shape)))
+ if((_tcsicmp(vsoCell->Name,_T("PinX")) == 0 || _tcsicmp(vsoCell->Name,_T("PinY")) == 0) && isMessageShape(vsoCell->Shape))
{
//Message enumeration
if(_tcsicmp(vsoCell->Shape->Data1,_T("1")) == 0)
@@ -710,7 +713,7 @@
{
case VK_LEFT:
case VK_RIGHT:
- if(CMessageSnapping::isArrowKeysEnabled() && GetDocumentMonitor(vsoApp, vsoApp->ActiveDocument)->isMessageShape(shape))
+ if(CMessageSnapping::isArrowKeysEnabled() && isMessageShape(shape))
{
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);
@@ -749,16 +752,18 @@
void CStudioAddon::HandleWinSelChange(Visio::IVApplicationPtr vsoApp)
{
- //Message snapping
- if(vsoApp->ActiveWindow->Selection->Count == 1)
+ Visio::IVSelectionPtr selection = vsoApp->ActiveWindow->Selection;
+
+ if(selection->Count == 1)
{
- Visio::IVShapePtr shape = vsoApp->ActiveWindow->Selection->Item[1];
+ //Message snapping
+ Visio::IVShapePtr shape = selection->Item[1];
m_mouseRelPosX = m_mousePosX - shape->Cells["PinX"]->Result[""];
m_mouseRelPosY = m_mousePosY - shape->Cells["PinY"]->Result[""];
}
m_oldSelections[vsoApp] = m_curSelections[vsoApp];
- m_curSelections[vsoApp] = vsoApp->ActiveWindow->Selection;
+ m_curSelections[vsoApp] = selection;
if (GetState(vsoApp) == STATE_MESSAGE_SEQUENCE_WAITING_FOR_SEL_CHANGE)
{
@@ -773,27 +778,25 @@
////////////////////////////////////////////////////
//Block instance rotation
- if(m_bAngleChanged && (m_bBeginChanged ^ m_bEndChanged) && (get_shape_type(selection->Item[1]) == ST_BMSC_INSTANCE))
+ //Note: this code must be also in VisioIsIdle, otherwise Undo action won't trigger
+ if((selection->Count == 1) && (m_bBeginChanged || m_bEndChanged) && get_shape_type(selection->Item[1]) == ST_BMSC_INSTANCE)
{
- m_bAngleChanged = false;
Visio::IVShapePtr shape = selection->Item[1];
- if(m_bBeginChanged)
- shape->Cells["BeginX"]->FormulaForceU = shape->Cells["EndX"]->Formula;
- if(m_bEndChanged)
- shape->Cells["EndX"]->FormulaForceU = shape->Cells["BeginX"]->Formula;
- if(CShapeUtils::getShapeCell(shape,"BeginY") < CShapeUtils::getShapeCell(shape,"EndY"))
- shape->Cells["BeginY"]->FormulaForceU = stringize() << 2 * shape->Cells["EndY"]->Result[""] - shape->Cells["BeginY"]->Result[""];
+ if((CShapeUtils::getShapeCell(shape, "BeginX") != CShapeUtils::getShapeCell(shape, "EndX")) ||
+ (CShapeUtils::getShapeCell(shape, "BeginY") < CShapeUtils::getShapeCell(shape, "EndY")))
+ {
+ if(GetRegistry<bool>(_T("Software\\Sequence Chart Studio\\Protection"), NULL, _T("PreventInstanceRotation"), 0))
+ vsoApp->Undo();
+ }
}
-
////////////////////////////////////////////////////
//Message snapping
#define _u(x) CPageUtils::ConvertUnits(vsoApp, x, 0, visPageUnits)
if(!m_bOnDropShape && m_bSnap && !m_bKeyDown && (selection->Count == 1) && CMessageSnapping::isEnabled())
{
- CDocumentMonitor* docMon = GetDocumentMonitor(vsoApp,vsoApp->ActiveDocument);
Visio::IVShapePtr msgShape = selection->Item[1];
- if(msgShape && m_bBeginChanged && m_bEndChanged && docMon->isMessageShape(msgShape))
+ if(msgShape && m_bBeginChanged && m_bEndChanged && isMessageShape(msgShape))
{
//Get relative position of the mouse from the shape Begin
double newPosX = CShapeUtils::getShapeCell(msgShape,"PinX") + _u(m_mouseRelPosX);;
@@ -822,7 +825,7 @@
for(int i=1; i<=vsoApp->ActivePage->Shapes->Count; i++)
{
Visio::IVShapePtr shape = vsoApp->ActivePage->Shapes->Item[i];
- if(docMon->isMessageShape(shape) && _tcsicmp(shape->Data1,_T("1")) == 0)
+ if(isMessageShape(shape) && _tcsicmp(shape->Data1,_T("1")) == 0)
{
bNumberedMsg = true;
break;
@@ -836,16 +839,31 @@
}
//Set variables to false
- m_bSnap = m_bMoving = m_bBeginChanged = m_bEndChanged = false;
+ m_bSnap = m_bMoving = m_bBeginChanged = m_bEndChanged = m_bAngleChanged = false;
//Reset OnDropShape state
m_bOnDropShape = false;
//Reset OnKeyDown
m_bKeyDown = false;
}
+void CStudioAddon::HandleVisioIsIdle(Visio::IVApplicationPtr vsoApp)
+{
+ if((vsoApp->ActiveWindow->Selection->Count == 1) &&
+ (m_bBeginChanged || m_bEndChanged) && get_shape_type(vsoApp->ActiveWindow->Selection->Item[1]) == ST_BMSC_INSTANCE)
+ {
+ Visio::IVShapePtr shape = vsoApp->ActiveWindow->Selection->Item[1];
+ if((CShapeUtils::getShapeCell(shape, "BeginX") != CShapeUtils::getShapeCell(shape, "EndX")) ||
+ (CShapeUtils::getShapeCell(shape, "BeginY") < CShapeUtils::getShapeCell(shape, "EndY")))
+ {
+ vsoApp->Undo();
+ m_bBeginChanged = m_bEndChanged = false;
+ }
+ }
+}
+
void CStudioAddon::HandleBeforeTextEdit(Visio::IVShapePtr shapePtr, Visio::IVApplicationPtr vsoApp)
{
- if(GetDocumentMonitor(vsoApp,vsoApp->ActiveDocument)->isMessageShape(shapePtr) && _tcsicmp(shapePtr->Data1,_T("1")) == 0)
+ if(isMessageShape(shapePtr) && _tcsicmp(shapePtr->Data1,_T("1")) == 0)
{
GetDocumentMonitor(vsoApp,vsoApp->ActiveDocument)->ToogleNumeration(false);
shapePtr->Text = shapePtr->Data2;
@@ -866,7 +884,7 @@
void CStudioAddon::HandleBeforeShapeDeleted(Visio::IVShapePtr shapePtr, Visio::IVApplicationPtr vsoApp)
{
- if(GetDocumentMonitor(vsoApp,vsoApp->ActiveDocument)->isMessageShape(shapePtr) && _tcsicmp(shapePtr->Data1,_T("1")) == 0)
+ if(isMessageShape(shapePtr) && _tcsicmp(shapePtr->Data1,_T("1")) == 0)
{
m_enumerationGroups.insert(shapePtr->Data3);
m_bShapeDeleted = true;
@@ -956,7 +974,9 @@
vsoApp->EventList->AddAdvise(visEvtDel+visEvtShape, varSink, _T(""), _T("ShapeDeleted"));
vsoApp->EventList->AddAdvise(visEvtCodeWinSelChange, varSink, _T(""), _T("SelectionChanges"));
+ vsoApp->EventList->AddAdvise(visEvtApp+visEvtIdle, varSink, _T(""), _T("VisioIsIdle"));
+
// Create a monitor class to keep track of this document and the Events
// being monitored for this document.
pDocumentMonitor = new CDocumentMonitor(this, vsoApp, vsoDocument);
Modified: trunk/src/view/visio/addon/addon.h
===================================================================
--- trunk/src/view/visio/addon/addon.h 2010-08-23 22:25:18 UTC (rev 859)
+++ trunk/src/view/visio/addon/addon.h 2010-08-25 10:46:51 UTC (rev 860)
@@ -63,6 +63,7 @@
void HandleBeforeShapeDeleted(Visio::IVShapePtr shapePtr, Visio::IVApplicationPtr vsoApp);
void HandleTextChanged(Visio::IVShapePtr shapePtr,Visio::IVDocumentPtr vsoDocument);
void HandleNonePending(Visio::IVApplicationPtr vsoApp);
+ void HandleVisioIsIdle(Visio::IVApplicationPtr vsoApp);
void RegisterPersistentEvents(Visio::IVDocumentPtr vsoDocument);
CDocumentMonitor *GetDocumentMonitor(Visio::IVApplicationPtr vsoApp, Visio::IVDocumentPtr vsoDocument);
Modified: trunk/src/view/visio/addon/dllmodule.rc
===================================================================
--- trunk/src/view/visio/addon/dllmodule.rc 2010-08-23 22:25:18 UTC (rev 859)
+++ trunk/src/view/visio/addon/dllmodule.rc 2010-08-25 10:46:51 UTC (rev 860)
@@ -246,7 +246,16 @@
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,148,132,10
END
+IDD_PROTECTION_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 "Do not allow to rotate instances",IDC_DONT_ROTATE_CHECK,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,7,118,10
+END
+
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
@@ -321,6 +330,14 @@
TOPMARGIN, 7
BOTTOMMARGIN, 179
END
+
+ IDD_PROTECTION_GLOBAL, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 268
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 179
+ END
END
#endif // APSTUDIO_INVOKED
Modified: trunk/src/view/visio/addon/document.cpp
===================================================================
--- trunk/src/view/visio/addon/document.cpp 2010-08-23 22:25:18 UTC (rev 859)
+++ trunk/src/view/visio/addon/document.cpp 2010-08-25 10:46:51 UTC (rev 860)
@@ -1735,18 +1735,6 @@
}
}
-bool CDocumentMonitor::isMessageShape(Visio::IVShapePtr shape)
-{
- switch(get_shape_type(shape))
- {
- case ST_BMSC_MESSAGE:
- case ST_BMSC_MESSAGE_FOUND:
- case ST_BMSC_MESSAGE_LOST:
- return true;
- }
- return false;
-}
-
VAORC CDocumentMonitor::OnMenuGlobalSettings(Visio::IVApplicationPtr vsoApp)
{
CGlobalSettingsDlg sheet(vsoApp, _T("Settings"));
Modified: trunk/src/view/visio/addon/document.h
===================================================================
--- trunk/src/view/visio/addon/document.h 2010-08-23 22:25:18 UTC (rev 859)
+++ trunk/src/view/visio/addon/document.h 2010-08-25 10:46:51 UTC (rev 860)
@@ -315,11 +315,6 @@
Visio::IVShapePtr DrawMessage(Visio::IVMasterPtr msgMaster, Visio::IVMasterPtr orderingMaster, Visio::IVShapePtr from, Visio::IVShapePtr to, double yCoord, const TCHAR* caption, MsgSeqCoregionTreatment coregionTreatment, Visio::IVShapePtr prevMsg);
public:
- /*
- * Returns whether shape is message (ordinary, lost, found)
- * @param shape a shape to check
- */
- bool isMessageShape(Visio::IVShapePtr shape);
/**
* Recompute positions in order left - right, top - down a draws the numbers into text field
* @param shapesOnPage pointer to all shapes on a page
Modified: trunk/src/view/visio/addon/extract.cpp
===================================================================
--- trunk/src/view/visio/addon/extract.cpp 2010-08-23 22:25:18 UTC (rev 859)
+++ trunk/src/view/visio/addon/extract.cpp 2010-08-25 10:46:51 UTC (rev 860)
@@ -207,6 +207,18 @@
return 0; // default value
}
+bool isMessageShape(Visio::IVShapePtr shape)
+{
+ switch(get_shape_type(shape))
+ {
+ case ST_BMSC_MESSAGE:
+ case ST_BMSC_MESSAGE_FOUND:
+ case ST_BMSC_MESSAGE_LOST:
+ return true;
+ }
+ return false;
+}
+
TDrawingType get_drawing_type(Visio::IVPagePtr vsoPage)
{
Visio::IVShapesPtr vsoShapes = vsoPage->Shapes;
Modified: trunk/src/view/visio/addon/extract.h
===================================================================
--- trunk/src/view/visio/addon/extract.h 2010-08-23 22:25:18 UTC (rev 859)
+++ trunk/src/view/visio/addon/extract.h 2010-08-25 10:46:51 UTC (rev 860)
@@ -65,6 +65,9 @@
//! determine type of the drawing on the given page
TDrawingType get_drawing_type(Visio::IVPagePtr vsoPage);
+//! determine if shape is message(ordinary, lost, found)
+bool isMessageShape(Visio::IVShapePtr shape);
+
MscPoint GetLineBegin(Visio::IVShapePtr shape);
MscPoint GetLineEnd(Visio::IVShapePtr shape);
MscPoint GetPinPos(Visio::IVShapePtr shape);
Modified: trunk/src/view/visio/addon/globalSettingsDlg.cpp
===================================================================
--- trunk/src/view/visio/addon/globalSettingsDlg.cpp 2010-08-23 22:25:18 UTC (rev 859)
+++ trunk/src/view/visio/addon/globalSettingsDlg.cpp 2010-08-25 10:46:51 UTC (rev 860)
@@ -31,10 +31,12 @@
//Property pages contructors
page1 = boost::shared_ptr<CNumberingGlobalDlg>(new CNumberingGlobalDlg(vsoApp));
page2 = boost::shared_ptr<CSnapGlobalDlg>(new CSnapGlobalDlg(vsoApp));
+ page3 = boost::shared_ptr<CProtectionGlobalDlg>(new CProtectionGlobalDlg(vsoApp));
//Adding pages
page1->SetTitle(_T("Numbering")); AddPage(*page1);
page2->SetTitle(_T("Snap && Glue")); AddPage(*page2);
+ page3->SetTitle(_T("Protection")); AddPage(*page3);
}
CGlobalSettingsDlg::~CGlobalSettingsDlg()
Modified: trunk/src/view/visio/addon/globalSettingsDlg.h
===================================================================
--- trunk/src/view/visio/addon/globalSettingsDlg.h 2010-08-23 22:25:18 UTC (rev 859)
+++ trunk/src/view/visio/addon/globalSettingsDlg.h 2010-08-25 10:46:51 UTC (rev 860)
@@ -25,6 +25,7 @@
//dialogs for tabs
#include "numberingGlobalDlg.h"
#include "snapGlobalDlg.h"
+#include "protectionGlobalDlg.h"
class CGlobalSettingsDlg : public CPropertySheetImpl<CGlobalSettingsDlg>
{
@@ -46,8 +47,9 @@
bool m_bCentered;
//Pages of property sheet
- boost::shared_ptr<CNumberingGlobalDlg> page1;
- boost::shared_ptr<CSnapGlobalDlg> page2;
+ boost::shared_ptr<CNumberingGlobalDlg> page1;
+ boost::shared_ptr<CSnapGlobalDlg> page2;
+ boost::shared_ptr<CProtectionGlobalDlg> page3;
Visio::IVApplicationPtr m_vsoApp;
};
Modified: trunk/src/view/visio/addon/messageJump.cpp
===================================================================
--- trunk/src/view/visio/addon/messageJump.cpp 2010-08-23 22:25:18 UTC (rev 859)
+++ trunk/src/view/visio/addon/messageJump.cpp 2010-08-25 10:46:51 UTC (rev 860)
@@ -48,8 +48,8 @@
{
case 1:
{
- PVEC2 intPoint = CMessageSnapping::getIntersectionWithInstance(msgShape, instances.at(0));
- if(intPoint && (CShapeUtils::getShapeCell(msgShape, "PinX") < intPoint->x))
+ MscPoint* intPoint = CMessageSnapping::getIntersectionWithInstance(msgShape, instances.at(0));
+ if(intPoint && (CShapeUtils::getShapeCell(msgShape, "PinX") < intPoint->get_x()))
origIntsRight = instances.at(0);
else
origIntsLeft = instances.at(0);
@@ -110,10 +110,10 @@
newMsg->Data2 = msgShape->Data2;
newMsg->Data3 = msgShape->Data3;
msgShape->Application->EventsEnabled = false;
- newMsg->Cells["BeginX"]->Formula = msgShape->Cells["BeginX"]->ResultStr[visMillimeters];
- newMsg->Cells["BeginY"]->Formula = msgShape->Cells["BeginY"]->ResultStr[visMillimeters];
- newMsg->Cells["EndX"]->Formula = msgShape->Cells["EndX"]->ResultStr[visMillimeters];
- newMsg->Cells["EndY"]->Formula = msgShape->Cells["EndY"]->ResultStr[visMillimeters];
+ //FIXME: Put into try catch block
+ for(int i=0; i<4; i++)
+ newMsg->GetCellsSRC(visSectionObject, visRowXForm1D, i)->Formula =
+ msgShape->GetCellsSRC(visSectionObject, visRowXForm1D, i)->ResultStr[visMillimeters];
msgShape->Application->EventsEnabled = true;
msgShape->Delete();
msgShape = newMsg;
@@ -163,16 +163,16 @@
if(*it == shape)
continue;
- PVEC2 intPoint = CMessageSnapping::getIntersectionWithInstance(VEC2(pointOnShape.x-1, pointOnShape.y),
- VEC2(pointOnShape.x, pointOnShape.y), *it);
+ MscPoint* intPoint = CMessageSnapping::getIntersectionWithInstance(MscPoint(pointOnShape.x-1, pointOnShape.y),
+ MscPoint(pointOnShape.x, pointOnShape.y), *it);
if(!intPoint || !CMessageSnapping::isPointOnInstancesLine(*intPoint, *it))
{ delete intPoint; continue; }
- double xVector = pointOnShape.x - intPoint->x;
+ double xVector = pointOnShape.x - intPoint->get_x();
if((xVector * ((direction == MSJUMP_LEFT) ? 1 : -1)) < 0)
continue;
- double distance = sqrt(pow(xVector,2) + pow((pointOnShape.y - intPoint->y),2));
+ double distance = sqrt(pow(xVector,2) + pow((pointOnShape.y - intPoint->get_y()),2));
if(!closestInstance || distance < closestDistance)
{
Modified: trunk/src/view/visio/addon/messageSnapping.cpp
===================================================================
--- trunk/src/view/visio/addon/messageSnapping.cpp 2010-08-23 22:25:18 UTC (rev 859)
+++ trunk/src/view/visio/addon/messageSnapping.cpp 2010-08-25 10:46:51 UTC (rev 860)
@@ -86,7 +86,7 @@
}
else if(snapType == MSSNAP_PRESERVE_SLOPE)
{
- PVEC2 result = getIntersectionWithInstance(msgShape, shape);
+ MscPoint* result = getIntersectionWithInstance(msgShape, shape);
if(result)
instShapes.push_back(shape);
@@ -126,11 +126,11 @@
std::swap(instBeginX,instEndX);
}
//Get intersection point with instance
- PVEC2 intPoint = NULL;
+ MscPoint* intPoint = NULL;
switch(snapType)
{
case MSSNAP_STRAIGHTEN:
- intPoint = CMessageSnapping::getIntersectionWithInstance(VEC2(msgSnapPointX - 1, msgSnapPointY), VEC2(msgSnapPointX, msgSnapPointY), *it);
+ intPoint = CMessageSnapping::getIntersectionWithInstance(MscPoint(msgSnapPointX - 1, msgSnapPointY), MscPoint(msgSnapPointX, msgSnapPointY), *it);
break;
case MSSNAP_PRESERVE_SLOPE:
intPoint = CMessageSnapping::getIntersectionWithInstance(msgShape, (*it));
@@ -141,8 +141,8 @@
if(!intPoint || !isPointOnInstancesLine(*intPoint, *it))
continue;
- mouseDistX = msgSnapPointX - intPoint->x;
- distance = sqrt(pow((msgSnapPointX - intPoint->x),2) + pow((msgSnapPointY - intPoint->y),2));
+ mouseDistX = msgSnapPointX - intPoint->get_x();
+ distance = sqrt(pow((msgSnapPointX - intPoint->get_x()),2) + pow((msgSnapPointY - intPoint->get_y()),2));
delete intPoint;
@@ -205,11 +205,11 @@
yRightPos = CShapeUtils::getShapeCell(msgShape,"EndY"); //Y-coord for end point of msg
break;
case MSSNAP_PRESERVE_SLOPE:
- PVEC2 p = getIntersectionWithInstance(msgShape, leftInstance);
- if(p) yLeftPos = p->y; delete p;
+ MscPoint* p = getIntersectionWithInstance(msgShape, leftInstance);
+ if(p) yLeftPos = p->get_y(); delete p;
p = getIntersectionWithInstance(msgShape, rightInstance);
- if(p) yRightPos = p->y; delete p;
+ if(p) yRightPos = p->get_y(); delete p;
break;
}
@@ -262,66 +262,65 @@
msgShape->Application->EventsEnabled = true;
}
-PVEC2 CMessageSnapping::getIntersectionWithInstance(VEC2 beginPoint, VEC2 endPoint, Visio::IVShapePtr instanceShape, VisUnitCodes units)
+MscPoint* CMessageSnapping::getIntersectionWithInstance(const MscPoint& beginPoint,const MscPoint& endPoint, Visio::IVShapePtr instanceShape, VisUnitCodes units)
{
if(!instanceShape)
return NULL;
- VEC2 p1,p2,p3,p4;
- p1.x = endPoint.x; p1.y = endPoint.y;
- p2.x = beginPoint.x; p2.y = beginPoint.y;
+ MscPoint p1,p2,p3,p4;
+ p1 = endPoint;
+ p2 = beginPoint;
#define _i(x) CShapeUtils::getShapeCell(instanceShape, x, units)
- p3.x = _i("EndX"); p3.y = _i("EndY");
- p4.x = _i("BeginX"); p4.y = _i("BeginY");
+ p3 = MscPoint(_i("EndX"), _i("EndY"));
+ p4 = MscPoint(_i("BeginX"), _i("BeginY"));
#undef _i
//FIXME: if coregion is oblique, snapping isn't always correct
if(get_shape_type(instanceShape) == ST_BMSC_COREGION)
{
//if msg is left, flip x-coord
- if(p1.x < p2.x)
- {
- std::swap(p1.x,p2.x);
- std::swap(p1.y,p2.y);
- }
+ if(p1.get_x() < p2.get_x())
+ std::swap(p1,p2);
double offsetX = CShapeUtils::getShapeCell(instanceShape, "Height", units) / 2.0;
- offsetX *= (p2.x > p4.x) ? 1 : -1;
+ offsetX *= (p2.get_x() > p4.get_x()) ? 1 : -1;
- p4.x += offsetX;
- p3.x += offsetX;
+ p4.set_x(p4.get_x() + offsetX);
+ p3.set_x(p3.get_x() + offsetX);
}
- PVEC2 result = CPageUtils::getIntersectionPoint(p1, p2, p3, p4);
+ MscPoint* result = CPageUtils::getIntersectionPoint(p1, p2, p3, p4);
if(!result)
return NULL;
//Swap y coord if instance is upside down
- if(p4.y < p3.y)
- std::swap(p4.y,p3.y);
+ if(p4.get_y() < p3.get_y())
+ std::swap(p4, p3);
//Check if it's outside of instance
- if(result->y > p4.y || result->y < p3.y)
+ if(result->get_y() > p4.get_y() || result->get_y() < p3.get_y())
+ {
+ delete result;
return NULL;
+ }
return result;
}
-PVEC2 CMessageSnapping::getIntersectionWithInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape, VisUnitCodes units)
+MscPoint* CMessageSnapping::getIntersectionWithInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape, VisUnitCodes units)
{
if(!msgShape)
return NULL;
#define _s(x) CShapeUtils::getShapeCell(msgShape, x, units)
- VEC2 p1, p2;
- p1.x = _s("EndX"); p1.y = _s("EndY");
- p2.x = _s("BeginX"); p2.y = _s("BeginY");
+ MscPoint p1(_s("EndX"), _s("EndY"));
+ MscPoint p2(_s("BeginX"), _s("BeginY"));
#undef _s
return getIntersectionWithInstance(p2, p1, instanceShape, units);
}
-bool CMessageSnapping::isPointOnInstancesLine(VEC2 point, Visio::IVShapePtr instShape, VisUnitCodes units)
+bool CMessageSnapping::isPointOnInstancesLine(const MscPoint& point, Visio::IVShapePtr instShape, VisUnitCodes units)
{
#define _sp(x) CShapeUtils::getShapeCell(instShape, x, units)
@@ -332,7 +331,7 @@
InstOffset = _sp("Controls.mscHeadWidth.X"); //NOTE: get width of instances rectangles
double sizeOfInstance = _sp("Width");
- double msgOffset = sqrt( pow(point.x - _sp("BeginX"),2) + pow(point.y - _sp("BeginY"),2) );
+ double msgOffset = sqrt( pow(point.get_x() - _sp("BeginX"),2) + pow(point.get_y() - _sp("BeginY"),2) );
//Glue to position, if message is on "rectangles" on the instance it won't be glued
return !((msgOffset < InstOffset) || (msgOffset > (sizeOfInstance - InstOffset)));
@@ -455,8 +454,8 @@
{
long scopeId = msgShape->Application->BeginUndoScope(_T("Re-snap"));
- VEC2 beginPoint = VEC2(msgShape->Cells["BeginX"]->Result[""], msgShape->Cells["BeginY"]->Result[""]);
- VEC2 endPoint = VEC2(msgShape->Cells["EndX"]->Result[""], msgShape->Cells["EndY"]->Result[""]);
+ MscPoint beginPoint(msgShape->Cells["BeginX"]->Result[""], msgShape->Cells["BeginY"]->Result[""]);
+ MscPoint endPoint(msgShape->Cells["EndX"]->Result[""], msgShape->Cells["EndY"]->Result[""]);
for(int i=1; i<=shapes->Count; i++)
{
@@ -464,13 +463,13 @@
if(!(get_shape_type(it) == ST_BMSC_INSTANCE || get_shape_type(it) == ST_BMSC_COREGION))
continue;
- PVEC2 bufferPoint = getIntersectionWithInstance(msgShape,it, (VisUnitCodes)0);
+ MscPoint* bufferPoint = getIntersectionWithInstance(msgShape,it, (VisUnitCodes)0);
if(bufferPoint)
{
if(pointsEqual(*bufferPoint, beginPoint, precision) && isPointOnInstancesLine(beginPoint, it, (VisUnitCodes)0))
- glueMsgToInstance(msgShape, it, "BeginX", beginPoint.y, (VisUnitCodes)0);
+ glueMsgToInstance(msgShape, it, "BeginX", beginPoint.get_y(), (VisUnitCodes)0);
else if(pointsEqual(*bufferPoint, endPoint, precision) && isPointOnInstancesLine(endPoint, it, (VisUnitCodes)0))
- glueMsgToInstance(msgShape, it, "EndX", endPoint.y, (VisUnitCodes)0);
+ glueMsgToInstance(msgShape, it, "EndX", endPoint.get_y(), (VisUnitCodes)0);
}
delete bufferPoint;
}
@@ -479,9 +478,9 @@
return true;
}
-bool CMessageSnapping::pointsEqual(VEC2 point1, VEC2 point2, double precision)
+bool CMessageSnapping::pointsEqual(const MscPoint& point1, const MscPoint& point2, double precision)
{
- return (abs(point1.x - point2.x) < precision) && (abs(point1.y - point2.y) < precision);
+ return (abs(point1.get_x() - point2.get_x()) < precision) && (abs(point1.get_y() - point2.get_y()) < precision);
}
Visio::IVShapePtr CMessageSnapping::getCoregionAt(Visio::IVShapePtr instShape, double yPos, VisUnitCodes units)
Modified: trunk/src/view/visio/addon/messageSnapping.h
===================================================================
--- trunk/src/view/visio/addon/messageSnapping.h 2010-08-23 22:25:18 UTC (rev 859)
+++ trunk/src/view/visio/addon/messageSnapping.h 2010-08-25 10:46:51 UTC (rev 860)
@@ -60,17 +60,15 @@
VisUnitCodes units = visPageUnits);
static void glueMsgToInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape, const _bstr_t & msgCell, double yPos,
MsgSeqDirection msgDirection, VisUnitCodes units = visPageUnits);
-
/*
*
*/
- static PVEC2 getIntersectionWithInstance(VEC2 beginPoint, VEC2 endPoint, Visio::IVShapePtr instanceShape, VisUnitCodes units = visPageUnits);
- static PVEC2 getIntersectionWithInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape, VisUnitCodes units = visPageUnits);
+ static MscPoint* getIntersectionWithInstance(const MscPoint& beginPoint,const MscPoint& endPoint, Visio::IVShapePtr instanceShape, VisUnitCodes units = visPageUnits);
+ static MscPoint* getIntersectionWithInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape, VisUnitCodes units = visPageUnits);
/*
*
*/
- static bool isPointOnInstancesLine(VEC2 point, Visio::IVShapePtr instShape, VisUnitCodes units = visPageUnits);
-
+ static bool isPointOnInstancesLine(const MscPoint& point, Visio::IVShapePtr instShape, VisUnitCodes units = visPageUnits);
/*
* Get Directional vector of given message shape
*/
@@ -83,7 +81,6 @@
* @param posY MouseY position for closest instances computing
*/
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
*/
@@ -95,9 +92,9 @@
/*
*
*/
- static bool pointsEqual(VEC2 point1, VEC2 point2, double precision = 0.0000001);
+ static bool pointsEqual(const MscPoint& point1, const MscPoint& point2, double precision = 0.0000001);
/*
- * The very same function as CShapeUtils::getCoregionAt but yPos is in page units!
+ *
*/
static Visio::IVShapePtr getCoregionAt(Visio::IVShapePtr instShape, double yPos, VisUnitCodes units = visPageUnits);
/*
Modified: trunk/src/view/visio/addon/pageutils.cpp
===================================================================
--- trunk/src/view/visio/addon/pageutils.cpp 2010-08-23 22:25:18 UTC (rev 859)
+++ trunk/src/view/visio/addon/pageutils.cpp 2010-08-25 10:46:51 UTC (rev 860)
@@ -132,10 +132,10 @@
return newSel;
}
-PVEC2 CPageUtils::getIntersectionPoint(VEC2 p1, VEC2 p2, VEC2 p3, VEC2 p4)
+MscPoint* CPageUtils::getIntersectionPoint(const MscPoint& p1, const MscPoint& p2, const MscPoint& p3, const MscPoint& p4)
{
- double x1 = p1.x, x2 = p2.x, x3 = p3.x, x4 = p4.x;
- double y1 = p1.y, y2 = p2.y, y3 = p3.y, y4 = p4.y;
+ double x1 = p1.get_x(), x2 = p2.get_x(), x3 = p3.get_x(), x4 = p4.get_x();
+ double y1 = p1.get_y(), y2 = p2.get_y(), y3 = p3.get_y(), y4 = p4.get_y();
double d = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);
if(d == 0)
@@ -146,7 +146,7 @@
double x = ( pre * (x3 - x4) - (x1 - x2) * post ) / d;
double y = ( pre * (y3 - y4) - (y1 - y2) * post ) / d;
- return new VEC2(x,y);
+ return new MscPoint(x,y);
}
// $Id$
Modified: trunk/src/view/visio/addon/pageutils.h
===================================================================
--- trunk/src/view/visio/addon/pageutils.h 2010-08-23 22:25:18 UTC (rev 859)
+++ trunk/src/view/visio/addon/pageutils.h 2010-08-25 10:46:51 UTC (rev 860)
@@ -101,7 +101,7 @@
* @param p3 endpoint of the second line
* @param p4 beginpoint of the second line
*/
- static PVEC2 getIntersectionPoint(VEC2 p1, VEC2 p2, VEC2 p3, VEC2 p4);
+ static MscPoint* getIntersectionPoint(const MscPoint& p1, const MscPoint& p2, const MscPoint& p3, const MscPoint& p4);
};
// $Id$
Added: trunk/src/view/visio/addon/protectionGlobalDlg.cpp
===================================================================
--- trunk/src/view/visio/addon/protectionGlobalDlg.cpp (rev 0)
+++ trunk/src/view/visio/addon/protectionGlobalDlg.cpp 2010-08-25 10:46:51 UTC (rev 860)
@@ -0,0 +1,71 @@
+/*
+ * 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 "protectionGlobalDlg.h"
+#include "errors.h"
+#include "data/msc.h"
+
+#include <htmlhelp.h>
+
+CProtectionGlobalDlg::~CProtectionGlobalDlg(...
[truncated message content] |
|
From: <mbe...@us...> - 2010-08-26 00:30:38
|
Revision: 861
http://scstudio.svn.sourceforge.net/scstudio/?rev=861&view=rev
Author: mbezdeka
Date: 2010-08-26 00:30:31 +0000 (Thu, 26 Aug 2010)
Log Message:
-----------
- snap global dialog changed
- Flip message direction added
- bugs fixed
Modified Paths:
--------------
trunk/src/view/visio/addon/addon.cpp
trunk/src/view/visio/addon/addon.h
trunk/src/view/visio/addon/document.cpp
trunk/src/view/visio/addon/document.h
trunk/src/view/visio/addon/messageJump.cpp
trunk/src/view/visio/addon/messageJump.h
trunk/src/view/visio/addon/messageSnapping.cpp
trunk/src/view/visio/addon/messageSnapping.h
trunk/src/view/visio/addon/snapGlobalDlg.cpp
trunk/src/view/visio/addon/snapGlobalDlg.h
Modified: trunk/src/view/visio/addon/addon.cpp
===================================================================
--- trunk/src/view/visio/addon/addon.cpp 2010-08-25 10:46:51 UTC (rev 860)
+++ trunk/src/view/visio/addon/addon.cpp 2010-08-26 00:30:31 UTC (rev 861)
@@ -75,7 +75,9 @@
m_bArrowKeyDown = false;
m_bOnDropShape = false;
m_bKeyDown = false;
- m_bAngleChanged = false;
+ m_bShapeChanged = false;
+
+ m_iJumpType = 0;
};
VAORC CStudioAddon::About(LPVAOV2LSTRUCT pV2L)
@@ -296,6 +298,9 @@
case CDocumentMonitor::MENU_SELECT_NUMBERED_GROUP: //104
TRACE("CStudioAddon::Run() menu item 'context menu - select numbering group'");
return pDocumentMonitor->OnMenuSelectNumberedGroup(vsoApp);
+ case CDocumentMonitor::MENU_FLIP_MESSAGE_DIRECTION: //105
+ TRACE("CStudioAddon::Run() menu item 'context menu - Flip message direction'");
+ return pDocumentMonitor->OnMenuFlipMessageDirection(vsoApp);
// 2xx events
case CDocumentMonitor::MENU_WINDOWS_REPORTER:
@@ -578,18 +583,22 @@
}
}
- if((_tcsicmp(vsoCell->Name,_T("PinX")) == 0 || _tcsicmp(vsoCell->Name,_T("PinY")) == 0) && isMessageShape(vsoCell->Shape))
+ if((_tcsicmp(vsoCell->Name,_T("PinX")) == 0 || _tcsicmp(vsoCell->Name,_T("PinY")) == 0))
{
- //Message enumeration
- if(_tcsicmp(vsoCell->Shape->Data1,_T("1")) == 0)
+ if(isMessageShape(vsoCell->Shape))
{
- //add to set
- m_enumerationGroups.insert(vsoCell->Shape->Data3);
- m_bCellChanged = true;
+ //Message enumeration
+ if(_tcsicmp(vsoCell->Shape->Data1,_T("1")) == 0)
+ {
+ //add to set
+ m_enumerationGroups.insert(vsoCell->Shape->Data3);
+ m_bCellChanged = true;
+ }
+ //Message snapping
+ if(!m_bSnap)
+ m_bSnap = true;
}
- //Message snapping
- if(!m_bSnap)
- m_bSnap = true;
+ m_bShapeChanged = true;
}
//HACK: cell changed so update mouse position (because when changing end points, MouseMove event won't trigger)
@@ -599,10 +608,6 @@
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)
@@ -662,21 +667,18 @@
GetDocumentMonitor(vsoApp, vsoApp->ActiveDocument)->ToggleToolbarItems(true);
}
- //Keyboard re-snapping - get instances the messages are snapped to
- //Message jumping
- if(!m_bArrowKeyDown)
+ //KeyDown handling
+ Visio::IVSelectionPtr selection = vsoApp->ActiveWindow->Selection;
+ switch(keyCode)
{
- m_bArrowKeyDown = true;
- Visio::IVSelectionPtr selection = vsoApp->ActiveWindow->Selection;
-
- switch(keyCode)
+ case VK_LEFT:
+ case VK_RIGHT:
+ if(selection->Count == 1 && CMessageSnapping::isArrowKeysEnabled())
{
- case VK_LEFT:
- case VK_RIGHT:
- if(selection->Count == 1 && CMessageSnapping::isArrowKeysEnabled())
- instances = CMessageSnapping::getConnectedInstances(selection->Item[1]);
- break;
+ instances = CMessageSnapping::getConnectedInstances(selection->Item[1]);
+ m_iJumpType = (keyCode == 0x25) ? 1 : 2;
}
+ break;
}
if(m_keyButtonState & visKeyControl)
@@ -702,33 +704,22 @@
GetDocumentMonitor(vsoApp, vsoApp->ActiveDocument)->ToggleToolbarItems(false);
}
- //Keyboard re-snapping - resnap disconnected messages
- if(m_bArrowKeyDown)
+ //KeyUp handling
+ Visio::IVSelectionPtr selection = vsoApp->ActiveWindow->Selection;
+ Visio::IVShapesPtr shapes = vsoApp->ActivePage->Shapes;
+ switch(keyCode)
{
- m_bArrowKeyDown = false;
- Visio::IVSelectionPtr selection = vsoApp->ActiveWindow->Selection;
- Visio::IVShapesPtr shapes = vsoApp->ActivePage->Shapes;
- Visio::IVShapePtr shape = selection->Item[1];
- switch(keyCode)
- {
- case VK_LEFT:
- case VK_RIGHT:
- if(CMessageSnapping::isArrowKeysEnabled() && isMessageShape(shape))
- {
- 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);
- if(CMessageJump::getMsgNeedsResnap(shape))
- CMessageSnapping::resnap(shape, shapes, 0.0001);
- break;
- }
- case VK_UP:
- case VK_DOWN:
- for(int i=1; i<=selection->Count; i++)
- CMessageSnapping::resnap(selection->Item[i], shapes);
- break;
- }
- instances.clear();
+ case VK_LEFT:
+ case VK_RIGHT:
+ if(selection->Count == 1 && CMessageSnapping::isArrowKeysEnabled()) //NOTE: Skip re-snapping if jumping is procceeding
+ break;
+ case VK_UP:
+ case VK_DOWN:
+ for(int i=1; i<=selection->Count; i++)
+ CMessageSnapping::resnap(selection->Item[i], shapes);
+ break;
}
+
//Message snapping
m_bCtrlDown = false;
}
@@ -775,19 +766,18 @@
void CStudioAddon::HandleNonePending(Visio::IVApplicationPtr vsoApp)
{
Visio::IVSelectionPtr selection = vsoApp->ActiveWindow->Selection;
-
////////////////////////////////////////////////////
- //Block instance rotation
- //Note: this code must be also in VisioIsIdle, otherwise Undo action won't trigger
- if((selection->Count == 1) && (m_bBeginChanged || m_bEndChanged) && get_shape_type(selection->Item[1]) == ST_BMSC_INSTANCE)
+ //Message jumping
+ if(m_iJumpType && selection->Count == 1 && CMessageSnapping::isArrowKeysEnabled() && isMessageShape(selection->Item[1]))
{
+ Visio::IVShapesPtr shapes = vsoApp->ActivePage->Shapes;
Visio::IVShapePtr shape = selection->Item[1];
- if((CShapeUtils::getShapeCell(shape, "BeginX") != CShapeUtils::getShapeCell(shape, "EndX")) ||
- (CShapeUtils::getShapeCell(shape, "BeginY") < CShapeUtils::getShapeCell(shape, "EndY")))
- {
- if(GetRegistry<bool>(_T("Software\\Sequence Chart Studio\\Protection"), NULL, _T("PreventInstanceRotation"), 0))
- vsoApp->Undo();
- }
+ if(!CMessageJump::jump(shape, instances, (m_iJumpType == 1) ? MSJUMP_LEFT : MSJUMP_RIGHT))
+ CMessageSnapping::snap(shape, CShapeUtils::getShapeCell(shape, "PinX"), CShapeUtils::getShapeCell(shape, "PinY"), MSSNAP_PRESERVE_VERTICAL);
+ if(CMessageJump::getMsgNeedsResnap(shape))
+ CMessageSnapping::resnap(shape, shapes, 0.0001);
+ instances.clear();
+ m_iJumpType = 0;
}
////////////////////////////////////////////////////
//Message snapping
@@ -839,7 +829,7 @@
}
//Set variables to false
- m_bSnap = m_bMoving = m_bBeginChanged = m_bEndChanged = m_bAngleChanged = false;
+ m_bSnap = m_bMoving = m_bBeginChanged = m_bEndChanged = false;
//Reset OnDropShape state
m_bOnDropShape = false;
//Reset OnKeyDown
@@ -848,16 +838,29 @@
void CStudioAddon::HandleVisioIsIdle(Visio::IVApplicationPtr vsoApp)
{
- if((vsoApp->ActiveWindow->Selection->Count == 1) &&
- (m_bBeginChanged || m_bEndChanged) && get_shape_type(vsoApp->ActiveWindow->Selection->Item[1]) == ST_BMSC_INSTANCE)
+ ////////////////////////////////////////////////////
+ //Block instance rotation
+ if(m_bShapeChanged)
{
- Visio::IVShapePtr shape = vsoApp->ActiveWindow->Selection->Item[1];
- if((CShapeUtils::getShapeCell(shape, "BeginX") != CShapeUtils::getShapeCell(shape, "EndX")) ||
- (CShapeUtils::getShapeCell(shape, "BeginY") < CShapeUtils::getShapeCell(shape, "EndY")))
+ if(vsoApp->ActiveWindow->Selection->Count > 0)
{
- vsoApp->Undo();
- m_bBeginChanged = m_bEndChanged = false;
+ for(int i=1;i<=vsoApp->ActiveWindow->Selection->Count; i++)
+ if(get_shape_type(vsoApp->ActiveWindow->Selection->Item[i]) == ST_BMSC_INSTANCE)
+ {
+ Visio::IVShapePtr shape = vsoApp->ActiveWindow->Selection->Item[i];
+ if((CShapeUtils::getShapeCell(shape, "BeginX") != CShapeUtils::getShapeCell(shape, "EndX")) ||
+ (CShapeUtils::getShapeCell(shape, "BeginY") < CShapeUtils::getShapeCell(shape, "EndY")))
+ {
+ if(GetRegistry<bool>(_T("Software\\Sequence Chart Studio\\Protection"), NULL, _T("PreventInstanceRotation"), 0))
+ {
+ vsoApp->Undo();
+ MessageBeep(0);
+ }
+ break;
+ }
+ }
}
+ m_bShapeChanged = false;
}
}
Modified: trunk/src/view/visio/addon/addon.h
===================================================================
--- trunk/src/view/visio/addon/addon.h 2010-08-25 10:46:51 UTC (rev 860)
+++ trunk/src/view/visio/addon/addon.h 2010-08-26 00:30:31 UTC (rev 861)
@@ -159,10 +159,13 @@
bool m_bCtrlDown;
bool m_bArrowKeyDown;
bool m_bOnDropShape;
- bool m_bAngleChanged;
+ bool m_bShapeChanged;
double m_mouseRelPosX;
double m_mouseRelPosY;
std::vector<Visio::IVShapePtr> instances;
+
+ //Message jumping
+ int m_iJumpType;
};
// $Id$
Modified: trunk/src/view/visio/addon/document.cpp
===================================================================
--- trunk/src/view/visio/addon/document.cpp 2010-08-25 10:46:51 UTC (rev 860)
+++ trunk/src/view/visio/addon/document.cpp 2010-08-26 00:30:31 UTC (rev 861)
@@ -263,7 +263,13 @@
case ST_BMSC_MESSAGE_LOST:
case ST_BMSC_MESSAGE_FOUND:
if(vsoShape->Text.length() == 0)
- vsoShape->Text = _T("NAME");
+ vsoShape->Text = _T("NAME");
+ //Message flip
+ vsoShape->AddNamedRow(visSectionAction,_T("flipDirection"),visTagDefault);
+ vsoShape->Cells["Actions.flipDirection.Action"]->FormulaU = _T("=RUNADDONWARGS(\"Sequence Chart Studio\",\"/event=105\")");
+ vsoShape->Cells["Actions.flipDirection.Menu"]->FormulaU = _T("=\"Flip message direction\"");
+ vsoShape->Cells["Actions.flipDirection.BeginGroup"]->FormulaU = _T("=TRUE");
+ //Message snapping
if(CMessageSnapping::isEnabled() && (m_vsoApp->ActiveWindow->Selection->Count == 1)) //Check whether snapping is enabled
{
double posX = CShapeUtils::getShapeCell(vsoShape,"PinX");
@@ -275,6 +281,7 @@
CMessageSnapping::snap(vsoShape, posX, posY, CMessageSnapping::getSnapType());
m_vsoApp->EventsEnabled = true;
}
+ //Message numbering
autoEnumerate(vsoShape);
break;
@@ -1177,6 +1184,36 @@
}
}
+VAORC CDocumentMonitor::OnMenuFlipMessageDirection(Visio::IVApplicationPtr vsoApp)
+{
+ Visio::IVSelectionPtr selection = vsoApp->ActiveWindow->Selection;
+ std::vector<_bstr_t> formulas;
+
+ vsoApp->EventsEnabled = false;
+ for(int i = 1; i <= selection->Count; i++)
+ {
+ Visio::IVShapePtr shape = selection->Item[i];
+ if(!isMessageShape(shape))
+ continue;
+ for(int i = 0; i < 4; i++)
+ formulas.push_back(shape->GetCellsSRC(visSectionObject, visRowXForm1D, i)->FormulaU);
+ try {
+ for(int i = 0; i < 2; i++)
+ {
+ shape->GetCellsSRC(visSectionObject, visRowXForm1D, i)->FormulaU = formulas.at(i+2);
+ shape->GetCellsSRC(visSectionObject, visRowXForm1D, i+2)->FormulaU = formulas.at(i);
+ }
+ }
+ catch(_com_error err){
+ MessageBox(GetActiveWindow(), L"Exception occurred", L"", MB_OK);
+ }
+ formulas.clear();
+ }
+ vsoApp->EventsEnabled = true;
+
+ return VAORC_SUCCESS;
+}
+
std::vector<Visio::IVShapePtr> CDocumentMonitor::getInstancesInBetween(Visio::IVShapePtr boundaryOne, Visio::IVShapePtr boundaryTwo, double yCoord)
{
std::vector<Visio::IVShapePtr> qualified;
Modified: trunk/src/view/visio/addon/document.h
===================================================================
--- trunk/src/view/visio/addon/document.h 2010-08-25 10:46:51 UTC (rev 860)
+++ trunk/src/view/visio/addon/document.h 2010-08-26 00:30:31 UTC (rev 861)
@@ -66,6 +66,7 @@
MENU_ADD_INSTANCES = 102,
MENU_MESSAGE_SEQUENCE,
MENU_SELECT_NUMBERED_GROUP,
+ MENU_FLIP_MESSAGE_DIRECTION,
// standard Check menu items
MENU_WINDOWS_REPORTER = 200,
MENU_IMPORT,
@@ -105,6 +106,7 @@
VAORC OnMenuDisableMessageEnumeration(Visio::IVApplicationPtr vsoApp);
VAORC OnMenuSelectNumberedGroup(Visio::IVApplicationPtr vsoApp);
VAORC OnMenuGlobalSettings(Visio::IVApplicationPtr vsoApp);
+ VAORC OnMenuFlipMessageDirection(Visio::IVApplicationPtr vsoApp);
void ShowReportView();
void OnHideReportView();
Modified: trunk/src/view/visio/addon/messageJump.cpp
===================================================================
--- trunk/src/view/visio/addon/messageJump.cpp 2010-08-25 10:46:51 UTC (rev 860)
+++ trunk/src/view/visio/addon/messageJump.cpp 2010-08-26 00:30:31 UTC (rev 861)
@@ -36,8 +36,6 @@
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);
@@ -68,6 +66,8 @@
return false;
}
+ long scopeId = msgShape->Application->BeginUndoScope("Jump");
+
//Erase information about re-snaping
if(origIntsLeft && origIntsRight && getMsgNeedsResnap(msgShape))
setMsgNeedsResnap(msgShape, 0);
@@ -77,52 +77,32 @@
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")),
+ Visio::IVShapePtr closestLeft = getClosestInstanceFromShape(left ? MscPoint(_s("EndX"),_s("EndY")) : MscPoint(_s("BeginX"),_s("BeginY")),
origIntsLeft, intersIntsBegin, direction);
- Visio::IVShapePtr closestRight = getClosestInstanceFromShape(left ? VEC2(_s("BeginX"),_s("BeginY")) : VEC2(_s("EndX"),_s("EndY")),
+ Visio::IVShapePtr closestRight = getClosestInstanceFromShape(left ? MscPoint(_s("BeginX"),_s("BeginY")) : MscPoint(_s("EndX"),_s("EndY")),
origIntsRight, intersIntsEnd, direction);
#undef _s
- VEC2 msgVec;
+ MscPoint 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
+ {
+ msgShape->Application->EndUndoScope(scopeId, true);
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;
- //FIXME: Put into try catch block
- for(int i=0; i<4; i++)
- newMsg->GetCellsSRC(visSectionObject, visRowXForm1D, i)->Formula =
- msgShape->GetCellsSRC(visSectionObject, visRowXForm1D, i)->ResultStr[visMillimeters];
- msgShape->Application->EventsEnabled = true;
- msgShape->Delete();
- msgShape = newMsg;
+ changeMsgType(msgShape, (getEdgeInstanceTreatment() == 1) ? shapeType : ST_BMSC_MESSAGE);
if(getEdgeInstanceTreatment() == 0)
setMsgNeedsResnap(msgShape, true);
-
-
- CMessageSnapping::setEnabled(snapStatus);
}
CMessageSnapping::glueMsgToInstancesPair(msgShape, closestLeft, closestRight, PinY, MSSNAP_PRESERVE_VERTICAL);
@@ -133,13 +113,13 @@
msgShape->Application->EventsEnabled = false;
if(closestLeft) //LEFT point is snapped, adjust right point
{
- msgShape->Cells["EndX"]->Formula = stringize() << msgShape->Cells["BeginX"]->Result[visMillimeters] + msgVec.x << " mm";
- msgShape->Cells["EndY"]->Formula = stringize() << msgShape->Cells["BeginY"]->Result[visMillimeters] + msgVec.y << " mm";
+ msgShape->Cells["EndX"]->Formula = stringize() << msgShape->Cells["BeginX"]->Result[visMillimeters] + msgVec.get_x() << " mm";
+ msgShape->Cells["EndY"]->Formula = stringize() << msgShape->Cells["BeginY"]->Result[visMillimeters] + msgVec.get_y() << " mm";
}
if(closestRight) //RIGHT point is snapped, adjust left point
{
- msgShape->Cells["BeginX"]->Formula = stringize() << msgShape->Cells["EndX"]->Result[visMillimeters] - msgVec.x << " mm";
- msgShape->Cells["BeginY"]->Formula = stringize() << msgShape->Cells["EndY"]->Result[visMillimeters] - msgVec.y << " mm";
+ msgShape->Cells["BeginX"]->Formula = stringize() << msgShape->Cells["EndX"]->Result[visMillimeters] - msgVec.get_x() << " mm";
+ msgShape->Cells["BeginY"]->Formula = stringize() << msgShape->Cells["EndY"]->Result[visMillimeters] - msgVec.get_y() << " mm";
}
msgShape->Application->EventsEnabled = true;
}
@@ -148,7 +128,7 @@
return true;
}
-Visio::IVShapePtr CMessageJump::getClosestInstanceFromShape(VEC2 pointOnShape, Visio::IVShapePtr shape, std::vector<Visio::IVShapePtr> instances, MsgJumpDirection direction)
+Visio::IVShapePtr CMessageJump::getClosestInstanceFromShape(const MscPoint& pointOnShape, Visio::IVShapePtr shape, std::vector<Visio::IVShapePtr> instances, MsgJumpDirection direction)
{
if(!shape)
return NULL;
@@ -163,16 +143,16 @@
if(*it == shape)
continue;
- MscPoint* intPoint = CMessageSnapping::getIntersectionWithInstance(MscPoint(pointOnShape.x-1, pointOnShape.y),
- MscPoint(pointOnShape.x, pointOnShape.y), *it);
+ MscPoint* intPoint = CMessageSnapping::getIntersectionWithInstance(MscPoint(pointOnShape.get_x()-1, pointOnShape.get_y()),
+ MscPoint(pointOnShape.get_x(), pointOnShape.get_y()), *it);
if(!intPoint || !CMessageSnapping::isPointOnInstancesLine(*intPoint, *it))
{ delete intPoint; continue; }
- double xVector = pointOnShape.x - intPoint->get_x();
+ double xVector = pointOnShape.get_x() - intPoint->get_x();
if((xVector * ((direction == MSJUMP_LEFT) ? 1 : -1)) < 0)
continue;
- double distance = sqrt(pow(xVector,2) + pow((pointOnShape.y - intPoint->get_y()),2));
+ double distance = sqrt(pow(xVector,2) + pow((pointOnShape.get_y() - intPoint->get_y()),2));
if(!closestInstance || distance < closestDistance)
{
@@ -208,4 +188,39 @@
msgShape->DeleteRow(visSectionUser,msgShape->CellsRowIndex["User.Resnap"]);
}
+bool CMessageJump::changeMsgType(Visio::IVShapePtr& msgShape, TShapeType shapeType)
+{
+ Visio::IVPagePtr page = msgShape->Application->ActivePage;
+
+ //Disable snapping
+ bool snapStatus = CMessageSnapping::isEnabled();
+ CMessageSnapping::setEnabled(false);
+ //Change message to lost/found
+ CDrawingVisualizer visualizer(msgShape->Application);
+ Visio::IVShapePtr newMsg = page->Drop(visualizer.find_master(shapeType),0,0);
+ //Copy message internal data
+ newMsg->Text = msgShape->Text;
+ newMsg->Data1 = msgShape->Data1;
+ newMsg->Data2 = msgShape->Data2;
+ newMsg->Data3 = msgShape->Data3;
+ //Copy message position
+ msgShape->Application->EventsEnabled = false;
+ try {
+ for(int i=0; i<4; i++)
+ newMsg->GetCellsSRC(visSectionObject, visRowXForm1D, i)->Formula =
+ msgShape->GetCellsSRC(visSectionObject, visRowXForm1D, i)->ResultStr[visMillimeters];
+ }
+ catch (_com_error err) {
+ MessageBox(GetActiveWindow(), _T("changeMsgType: exception occurred."), L"", MB_OK);
+ }
+ msgShape->Application->EventsEnabled = true;
+
+ msgShape->Delete();
+ msgShape = newMsg;
+
+ //Enable snapping back
+ CMessageSnapping::setEnabled(snapStatus);
+ return true;
+}
+
// $Id$
\ No newline at end of file
Modified: trunk/src/view/visio/addon/messageJump.h
===================================================================
--- trunk/src/view/visio/addon/messageJump.h 2010-08-25 10:46:51 UTC (rev 860)
+++ trunk/src/view/visio/addon/messageJump.h 2010-08-26 00:30:31 UTC (rev 861)
@@ -34,11 +34,20 @@
/*
*
*/
- static Visio::IVShapePtr getClosestInstanceFromShape(VEC2 pointOnShape, Visio::IVShapePtr shape,
+ static Visio::IVShapePtr getClosestInstanceFromShape(const MscPoint& pointOnShape, Visio::IVShapePtr shape,
std::vector<Visio::IVShapePtr> instances, MsgJumpDirection direction);
-
+ /*
+ *
+ */
static bool getMsgNeedsResnap(Visio::IVShapePtr msgShape);
+ /*
+ *
+ */
static void setMsgNeedsResnap(Visio::IVShapePtr msgShape, bool bTrueIfNeeds);
+ /*
+ *
+ */
+ static bool changeMsgType(Visio::IVShapePtr& msgShape, TShapeType shapeType);
};
// $Id$
\ No newline at end of file
Modified: trunk/src/view/visio/addon/messageSnapping.cpp
===================================================================
--- trunk/src/view/visio/addon/messageSnapping.cpp 2010-08-25 10:46:51 UTC (rev 860)
+++ trunk/src/view/visio/addon/messageSnapping.cpp 2010-08-26 00:30:31 UTC (rev 861)
@@ -339,17 +339,14 @@
#undef _sp
}
-bool CMessageSnapping::getMsgVector(Visio::IVShapePtr msgShape, PVEC2 resultVector, VisUnitCodes units)
+bool CMessageSnapping::getMsgVector(Visio::IVShapePtr msgShape, MscPoint* resultVector, VisUnitCodes units)
{
if(!resultVector)
return false;
- double msgBegY = CShapeUtils::getShapeCell(msgShape, "BeginY");
- double msgEndY = CShapeUtils::getShapeCell(msgShape, "EndY");
+ resultVector->set_x(msgShape->Cells["EndX"]->Result[units] - msgShape->Cells["BeginX"]->Result[units]);
+ resultVector->set_y(msgShape->Cells["EndY"]->Result[units] - msgShape->Cells["BeginY"]->Result[units]);
- resultVector->x = msgShape->Cells["EndX"]->Result[units] - msgShape->Cells["BeginX"]->Result[units];
- resultVector->y = msgShape->Cells["EndY"]->Result[units] - msgShape->Cells["BeginY"]->Result[units];
-
return true;
}
@@ -365,7 +362,7 @@
return;
}
- VEC2 msgVec;
+ MscPoint msgVec;
if(!getMsgVector(msgShape, &msgVec, (VisUnitCodes) 0))
return;
@@ -418,14 +415,14 @@
msgShape->Application->EventsEnabled = false;
if(closestInst.first) //LEFT point is snapped, adjust right point
{
- msgShape->Cells["EndX"]->FormulaU = stringize() << msgShape->Cells["BeginX"]->Result[""] + msgVec.x;
- if(snapType != MSSNAP_STRAIGHTEN) msgShape->Cells["EndY"]->FormulaU = stringize() << msgShape->Cells["BeginY"]->Result[""] + msgVec.y;
+ msgShape->Cells["EndX"]->FormulaU = stringize() << msgShape->Cells["BeginX"]->Result[""] + msgVec.get_x();
+ if(snapType != MSSNAP_STRAIGHTEN) msgShape->Cells["EndY"]->FormulaU = stringize() << msgShape->Cells["BeginY"]->Result[""] + msgVec.get_y();
}
if(closestInst.second) //RIGHT point is snapped, adjust left point
{
- msgShape->Cells["BeginX"]->FormulaU = stringize() << msgShape->Cells["EndX"]->Result[""] - msgVec.x;
- if(snapType != MSSNAP_STRAIGHTEN) msgShape->Cells["BeginY"]->FormulaU = stringize() << msgShape->Cells["EndY"]->Result[""] - msgVec.y;
+ msgShape->Cells["BeginX"]->FormulaU = stringize() << msgShape->Cells["EndX"]->Result[""] - msgVec.get_x();
+ if(snapType != MSSNAP_STRAIGHTEN) msgShape->Cells["BeginY"]->FormulaU = stringize() << msgShape->Cells["EndY"]->Result[""] - msgVec.get_y();
}
msgShape->Application->EventsEnabled = true;
}
Modified: trunk/src/view/visio/addon/messageSnapping.h
===================================================================
--- trunk/src/view/visio/addon/messageSnapping.h 2010-08-25 10:46:51 UTC (rev 860)
+++ trunk/src/view/visio/addon/messageSnapping.h 2010-08-26 00:30:31 UTC (rev 861)
@@ -72,7 +72,7 @@
/*
* Get Directional vector of given message shape
*/
- static bool getMsgVector(Visio::IVShapePtr msgShape, PVEC2 resultVector, VisUnitCodes units = visMillimeters);
+ static bool getMsgVector(Visio::IVShapePtr msgShape, MscPoint* resultVector, VisUnitCodes units = visMillimeters);
/*
* automatically snaps current message to nearest instances
Modified: trunk/src/view/visio/addon/snapGlobalDlg.cpp
===================================================================
--- trunk/src/view/visio/addon/snapGlobalDlg.cpp 2010-08-25 10:46:51 UTC (rev 860)
+++ trunk/src/view/visio/addon/snapGlobalDlg.cpp 2010-08-26 00:30:31 UTC (rev 861)
@@ -36,8 +36,7 @@
DoDataExchange(FALSE);
//Enable/disable controls on the dialog
- EnableSnapControls(m_bSnapEnabled);
- EnableEdgeControls(m_bEdgeTreatmentEnabled);
+ EnableControls(m_bEdgeTreatmentEnabled);
return TRUE;
}
@@ -95,30 +94,16 @@
return 0;
}
-void CSnapGlobalDlg::EnableSnapControls(bool bEnable)
+void CSnapGlobalDlg::EnableControls(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);
- EnableSnapControls(m_bSnapEnabled);
- return 0;
-}
-
LRESULT CSnapGlobalDlg::OnBnClickedEdgeEnabled(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
DoDataExchange(TRUE);
- EnableEdgeControls(m_bEdgeTreatmentEnabled);
+ EnableControls(m_bEdgeTreatmentEnabled);
return 0;
}
Modified: trunk/src/view/visio/addon/snapGlobalDlg.h
===================================================================
--- trunk/src/view/visio/addon/snapGlobalDlg.h 2010-08-25 10:46:51 UTC (rev 860)
+++ trunk/src/view/visio/addon/snapGlobalDlg.h 2010-08-26 00:30:31 UTC (rev 861)
@@ -41,7 +41,6 @@
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()
@@ -70,9 +69,7 @@
Visio::IVApplicationPtr m_vsoApp;
- void EnableSnapControls(bool bEnable = true);
- void EnableEdgeControls(bool bEnable = true);
- LRESULT OnBnClickedSnapEnabled(WORD, WORD, HWND, BOOL&);
+ void EnableControls(bool bEnable = true);
LRESULT OnBnClickedEdgeEnabled(WORD, WORD, HWND, BOOL&);
public:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mbe...@us...> - 2010-08-26 22:25:12
|
Revision: 862
http://scstudio.svn.sourceforge.net/scstudio/?rev=862&view=rev
Author: mbezdeka
Date: 2010-08-26 22:25:05 +0000 (Thu, 26 Aug 2010)
Log Message:
-----------
- Flip message direction added
- message snapping improved
- resnap now won't snap lost/found message at theirs circle endpoint
- bugs fixed
Modified Paths:
--------------
trunk/src/view/visio/addon/addon.cpp
trunk/src/view/visio/addon/document.cpp
trunk/src/view/visio/addon/enumerateUtils.cpp
trunk/src/view/visio/addon/messageJump.cpp
trunk/src/view/visio/addon/messageSnapping.cpp
trunk/src/view/visio/addon/messageSnapping.h
Modified: trunk/src/view/visio/addon/addon.cpp
===================================================================
--- trunk/src/view/visio/addon/addon.cpp 2010-08-26 00:30:31 UTC (rev 861)
+++ trunk/src/view/visio/addon/addon.cpp 2010-08-26 22:25:05 UTC (rev 862)
@@ -583,6 +583,7 @@
}
}
+ //FIXME: Change to (vsoCell->Column == visXFormPinX)
if((_tcsicmp(vsoCell->Name,_T("PinX")) == 0 || _tcsicmp(vsoCell->Name,_T("PinY")) == 0))
{
if(isMessageShape(vsoCell->Shape))
@@ -602,6 +603,7 @@
}
//HACK: cell changed so update mouse position (because when changing end points, MouseMove event won't trigger)
+
if((_tcsicmp(vsoCell->Name,_T("BeginX")) == 0) || (_tcsicmp(vsoCell->Name,_T("BeginY")) == 0))
m_bBeginChanged = true;
if((_tcsicmp(vsoCell->Name,_T("EndX")) == 0) || (_tcsicmp(vsoCell->Name,_T("EndY")) == 0))
@@ -786,12 +788,18 @@
{
Visio::IVShapePtr msgShape = selection->Item[1];
- if(msgShape && m_bBeginChanged && m_bEndChanged && isMessageShape(msgShape))
+ if(msgShape && isMessageShape(msgShape))
{
- //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
+ if(m_bBeginChanged && m_bEndChanged) //NOTE: Trigger when moving with whole message
+ {
+ //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
+ }
+ else if(m_bBeginChanged ^ m_bEndChanged) //NOTE: Trigger when pulling endpoints
+ CMessageSnapping::snapEndPointToClosestInstance(msgShape, m_bBeginChanged ? "BeginX" : "EndX",
+ CMessageSnapping::getMsgDirection(msgShape));
}
}
#undef _u
Modified: trunk/src/view/visio/addon/document.cpp
===================================================================
--- trunk/src/view/visio/addon/document.cpp 2010-08-26 00:30:31 UTC (rev 861)
+++ trunk/src/view/visio/addon/document.cpp 2010-08-26 22:25:05 UTC (rev 862)
@@ -268,7 +268,6 @@
vsoShape->AddNamedRow(visSectionAction,_T("flipDirection"),visTagDefault);
vsoShape->Cells["Actions.flipDirection.Action"]->FormulaU = _T("=RUNADDONWARGS(\"Sequence Chart Studio\",\"/event=105\")");
vsoShape->Cells["Actions.flipDirection.Menu"]->FormulaU = _T("=\"Flip message direction\"");
- vsoShape->Cells["Actions.flipDirection.BeginGroup"]->FormulaU = _T("=TRUE");
//Message snapping
if(CMessageSnapping::isEnabled() && (m_vsoApp->ActiveWindow->Selection->Count == 1)) //Check whether snapping is enabled
{
@@ -1188,13 +1187,18 @@
{
Visio::IVSelectionPtr selection = vsoApp->ActiveWindow->Selection;
std::vector<_bstr_t> formulas;
-
+
vsoApp->EventsEnabled = false;
for(int i = 1; i <= selection->Count; i++)
{
Visio::IVShapePtr shape = selection->Item[i];
if(!isMessageShape(shape))
continue;
+ //TODO: Flip lost and found messages
+ //TShapeType shapeType = get_shape_type(shape);
+ //if(shapeType == ST_BMSC_MESSAGE_FOUND || shapeType == ST_BMSC_MESSAGE_LOST)
+ // CMessageJump::changeMsgType(shape, (TShapeType)((shapeType == 3) ? 2 : 3));
+
for(int i = 0; i < 4; i++)
formulas.push_back(shape->GetCellsSRC(visSectionObject, visRowXForm1D, i)->FormulaU);
try {
@@ -1208,6 +1212,9 @@
MessageBox(GetActiveWindow(), L"Exception occurred", L"", MB_OK);
}
formulas.clear();
+ //NOTE: changeMsgType cause disconnecting message, so we must resnap it
+ //if(shapeType == ST_BMSC_MESSAGE_FOUND || shapeType == ST_BMSC_MESSAGE_LOST)
+ // CMessageSnapping::resnap(shape, vsoApp->ActivePage->Shapes, 0.0001);
}
vsoApp->EventsEnabled = true;
Modified: trunk/src/view/visio/addon/enumerateUtils.cpp
===================================================================
--- trunk/src/view/visio/addon/enumerateUtils.cpp 2010-08-26 00:30:31 UTC (rev 861)
+++ trunk/src/view/visio/addon/enumerateUtils.cpp 2010-08-26 22:25:05 UTC (rev 862)
@@ -1,242 +1,242 @@
/*
- * 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$
- */
+* 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 "enumerateUtils.h"
std::wstring CEnumerateUtils::int2Romans(int index)
{
- if(index < 0 || index > 3999)
- {
- MessageBox(GetActiveWindow(),
- _T("Index too big! Use another type of enumeration. Roman index can be from 0-3999."),
- _T("Error"),MB_OK | MB_ICONERROR);
- return _T("?");
- }
+ if(index < 0 || index > 3999)
+ {
+ MessageBox(GetActiveWindow(),
+ _T("Index too big! Use another type of enumeration. Roman index can be from 0-3999."),
+ _T("Error"),MB_OK | MB_ICONERROR);
+ return _T("?");
+ }
- if(index == 0)
- return _T("N");
+ if(index == 0)
+ return _T("N");
- int numeral[] = {1000, 900, 500, 400, 100,90, 50, 40, 10, 9, 5, 4, 1};
- std::wstring romans[] = {L"M", L"CM", L"D", L"CD", L"C", L"XC", L"L", L"XL", L"X", L"IX", L"V", L"IV", L"I" };
- std::wstring result;
+ int numeral[] = {1000, 900, 500, 400, 100,90, 50, 40, 10, 9, 5, 4, 1};
+ std::wstring romans[] = {L"M", L"CM", L"D", L"CD", L"C", L"XC", L"L", L"XL", L"X", L"IX", L"V", L"IV", L"I" };
+ std::wstring result;
- for(int i=0; i < 13; i++)
- while(index >=numeral[i])
- {
- index -= numeral[i];
- result += romans[i];
- }
-
- return result;
+ for(int i=0; i < 13; i++)
+ while(index >=numeral[i])
+ {
+ index -= numeral[i];
+ result += romans[i];
+ }
+
+ return result;
}
std::wstring CEnumerateUtils::int2Char(int index, bool capitals)
{
- index--;
+ index--;
- if(index < 0)
- {
- MessageBox(GetActiveWindow(),
- _T("Index less than one! Char index can be from 1-inf."),
- _T("Error"),MB_OK | MB_ICONERROR);
- return _T("?");
- }
+ if(index < 0)
+ {
+ MessageBox(GetActiveWindow(),
+ _T("Index less than one! Char index can be from 1-inf."),
+ _T("Error"),MB_OK | MB_ICONERROR);
+ return _T("?");
+ }
- std::wstring result;
-
- if(index == 0)
- return (capitals ? _T("A") : _T("a"));
+ std::wstring result;
- bool bLast = true;
+ if(index == 0)
+ return (capitals ? _T("A") : _T("a"));
- while(index > 0)
- {
- if(bLast)
- {
- result.insert(0,(capitals ? (stringize() << (char)((index % 26)+65)) : (stringize() << (char)((index % 26)+97))));
- index = index / 26;
+ bool bLast = true;
- if(index/27 == 0)
- bLast = false;
- }
- else
- {
- result.insert(0,(capitals ? (stringize() << (char)((index % 27)+64)) : (stringize() << (char)((index % 27)+96))));
- index = index / 27;
- }
- }
+ while(index > 0)
+ {
+ if(bLast)
+ {
+ result.insert(0,(capitals ? (stringize() << (char)((index % 26)+65)) : (stringize() << (char)((index % 26)+97))));
+ index = index / 26;
- return result;
+ if(index/27 == 0)
+ bLast = false;
+ }
+ else
+ {
+ result.insert(0,(capitals ? (stringize() << (char)((index % 27)+64)) : (stringize() << (char)((index % 27)+96))));
+ index = index / 27;
+ }
+ }
+
+ return result;
}
bool CEnumerateUtils::messageCompare(Visio::IVShapePtr p1, Visio::IVShapePtr p2)
{
- double beginP1Y = p1->Cells["BeginY"]->ResultIU;
- double beginP2Y = p2->Cells["BeginY"]->ResultIU;
+ double beginP1Y = p1->Cells["BeginY"]->ResultIU;
+ double beginP2Y = p2->Cells["BeginY"]->ResultIU;
- if(beginP1Y - beginP2Y != 0.0)
- return beginP1Y > beginP2Y;
- else
- {
- double beginP1X = p1->Cells["BeginX"]->ResultIU;
- double beginP2X = p2->Cells["BeginX"]->ResultIU;
+ if(beginP1Y - beginP2Y != 0.0)
+ return beginP1Y > beginP2Y;
+ else
+ {
+ double beginP1X = p1->Cells["BeginX"]->ResultIU;
+ double beginP2X = p2->Cells["BeginX"]->ResultIU;
- if(beginP1X - beginP2X != 0.0)
- return beginP1X < beginP2X;
- else
- {
- double endP1X = p1->Cells["EndX"]->ResultIU;
- double endP2X = p2->Cells["EndX"]->ResultIU;
+ if(beginP1X - beginP2X != 0.0)
+ return beginP1X < beginP2X;
+ else
+ {
+ double endP1X = p1->Cells["EndX"]->ResultIU;
+ double endP2X = p2->Cells["EndX"]->ResultIU;
- return endP1X < endP2X;
- }
- }
+ return endP1X < endP2X;
+ }
+ }
}
bool CEnumerateUtils::loadGroupSettings(Visio::IVApplicationPtr vsoApp, _bstr_t groupID, int& startIndex, int& numberingType, std::wstring& addition)
{
- Visio::IVShapePtr page = vsoApp->ActivePage->PageSheet;
- if(!page->SectionExists[visSectionUser][0])
- return false;
+ Visio::IVShapePtr page = vsoApp->ActivePage->PageSheet;
+ if(!page->SectionExists[visSectionUser][0])
+ return false;
- _bstr_t userGroupID = stringize() << _T("User.") << groupID;
- Visio::IVCellPtr groupCell = page->GetCells(userGroupID);
- if(!groupCell)
- return false;
-
- std::wstringstream ss(std::wstringstream::in | std::stringstream::out);
- ss << groupCell->ResultStr[visNone];
- ss >> startIndex >> numberingType >> addition;
+ _bstr_t userGroupID = stringize() << _T("User.") << groupID;
+ Visio::IVCellPtr groupCell = page->GetCells(userGroupID);
+ if(!groupCell)
+ return false;
- //Get spaces in addition back
- for(size_t i=0; i<addition.size(); i++)
- if(addition[i] == '$')
- addition[i] = ' ';
+ std::wstringstream ss(std::wstringstream::in | std::stringstream::out);
+ ss << groupCell->ResultStr[visNone];
+ ss >> startIndex >> numberingType >> addition;
- addition = addition + _T(" ");
+ //Get spaces in addition back
+ for(size_t i=0; i<addition.size(); i++)
+ if(addition[i] == '$')
+ addition[i] = ' ';
- return true;
+ addition = addition + _T(" ");
+
+ return true;
}
bool CEnumerateUtils::saveGroupSettings(Visio::IVApplicationPtr vsoApp, _bstr_t groupID, int startIndex, int numberingType, BSTR addition)
{
- Visio::IVShapePtr page = vsoApp->ActivePage->PageSheet;
+ Visio::IVShapePtr page = vsoApp->ActivePage->PageSheet;
- if(!page->SectionExists[visSectionUser][0])
- page->AddSection(visSectionUser);
+ if(!page->SectionExists[visSectionUser][0])
+ page->AddSection(visSectionUser);
- _bstr_t userGroupID = stringize() << _T("User.") << groupID;
+ _bstr_t userGroupID = stringize() << _T("User.") << groupID;
- if(page->GetCellExists(userGroupID,0) != -1)
- page->AddNamedRow(visSectionUser, groupID, visTagDefault);
-
- Visio::IVCellPtr groupCell = page->GetCells(userGroupID);
-
- if(!groupCell)
- return false;
+ if(page->GetCellExists(userGroupID,0) != -1)
+ page->AddNamedRow(visSectionUser, groupID, visTagDefault);
- std::wstring additionTemp = addition;
+ Visio::IVCellPtr groupCell = page->GetCells(userGroupID);
- for(size_t i=0; i<additionTemp.size(); i++)
- if(additionTemp[i] == 32)
- additionTemp[i] = '$';
+ if(!groupCell)
+ return false;
- groupCell->FormulaU = stringize() << _T("=\"") << startIndex << _T(" ")
- << numberingType << _T(" ")
- << additionTemp << _T("\"");
- return true;
+ std::wstring additionTemp = addition;
+
+ for(size_t i=0; i<additionTemp.size(); i++)
+ if(additionTemp[i] == 32)
+ additionTemp[i] = '$';
+
+ groupCell->FormulaU = stringize() << _T("=\"") << startIndex << _T(" ")
+ << numberingType << _T(" ")
+ << additionTemp << _T("\"");
+ return true;
}
void CEnumerateUtils::selectGroup(Visio::IVApplicationPtr vsoApp, _bstr_t groupID)
{
- Visio::IVPagePtr page = vsoApp->ActivePage;
- Visio::IVSelectionPtr selection = page->CreateSelection(Visio::visSelTypeEmpty, Visio::visSelModeSkipSuper);
+ Visio::IVPagePtr page = vsoApp->ActivePage;
+ Visio::IVSelectionPtr selection = page->CreateSelection(Visio::visSelTypeEmpty, Visio::visSelModeSkipSuper);
- for(int i=1; i<=page->Shapes->Count; i++)
- {
- Visio::IVShapePtr shape = page->Shapes->Item[i];
- if(_tcsicmp(shape->Data1,_T("1")) == 0 && _tcsicmp(shape->Data3,groupID) == 0)
- selection->Select(shape,visSelect);
- }
+ for(int i=1; i<=page->Shapes->Count; i++)
+ {
+ Visio::IVShapePtr shape = page->Shapes->Item[i];
+ if(_tcsicmp(shape->Data1,_T("1")) == 0 && _tcsicmp(shape->Data3,groupID) == 0)
+ selection->Select(shape,visSelect);
+ }
- vsoApp->ActiveWindow->Selection = selection;
+ vsoApp->ActiveWindow->Selection = selection;
}
Visio::IVShapePtr CEnumerateUtils::getClosestMessage(Visio::IVApplicationPtr vsoApp, const Visio::IVShapePtr shapePtr, bool onlyNumbered)
{
- Visio::IVShapesPtr shapes = vsoApp->ActivePage->Shapes;
- std::map<double, Visio::IVShapePtr> messages;
+ Visio::IVShapesPtr shapes = vsoApp->ActivePage->Shapes;
+ std::map<double, Visio::IVShapePtr> messages;
- double x = shapePtr->Cells["PinX"]->ResultIU;
- double y = shapePtr->Cells["PinY"]->ResultIU;
+ double x = shapePtr->Cells["PinX"]->ResultIU;
+ double y = shapePtr->Cells["PinY"]->ResultIU;
- for(int i=1; i<=shapes->Count; i++)
- {
- Visio::IVShapePtr shape = shapes->Item[i];
+ for(int i=1; i<=shapes->Count; i++)
+ {
+ Visio::IVShapePtr shape = shapes->Item[i];
- if(shape == shapePtr)
- continue;
+ if(shape == shapePtr)
+ continue;
- if(_tcsicmp(shape->Data1,_T("1")) == 0 || !onlyNumbered)
- {
- double tempX = shape->Cells["PinX"]->ResultIU;
- double tempY = shape->Cells["PinY"]->ResultIU;
+ if(_tcsicmp(shape->Data1,_T("1")) == 0 || !onlyNumbered)
+ {
+ double tempX = shape->Cells["PinX"]->ResultIU;
+ double tempY = shape->Cells["PinY"]->ResultIU;
- double distance = sqrt(pow(x-tempX,2) + pow(y-tempY,2));
+ double distance = sqrt(pow(x-tempX,2) + pow(y-tempY,2));
- messages.insert(std::pair<double, Visio::IVShapePtr>(distance, shape));
- }
- }
- if (!messages.size())
- return NULL;
+ messages.insert(std::pair<double, Visio::IVShapePtr>(distance, shape));
+ }
+ }
+ if (!messages.size())
+ return NULL;
- return messages.begin()->second;
+ return messages.begin()->second;
}
int CEnumerateUtils::getGroupCount(Visio::IVApplicationPtr vsoApp)
{
- Visio::IVShapePtr pagesheet = vsoApp->ActivePage->PageSheet;
+ Visio::IVShapePtr pagesheet = vsoApp->ActivePage->PageSheet;
- if(!pagesheet->GetCellExists(_T("User.EnumCount"),0))
- {
- pagesheet->AddNamedRow(visSectionUser,_T("EnumCount"),visTagDefault);
- pagesheet->Cells["User.EnumCount"]->FormulaU = _T("0");
- return 0;
- }
+ if(!pagesheet->GetCellExists(_T("User.EnumCount"),0))
+ {
+ pagesheet->AddNamedRow(visSectionUser,_T("EnumCount"),visTagDefault);
+ pagesheet->Cells["User.EnumCount"]->FormulaU = _T("0");
+ return 0;
+ }
- return pagesheet->Cells["User.EnumCount"]->ResultInt[visNone][visTruncate];
+ return pagesheet->Cells["User.EnumCount"]->ResultInt[visNone][visTruncate];
}
void CEnumerateUtils::setGroupCount(Visio::IVApplicationPtr vsoApp, int count)
{
- Visio::IVShapePtr pagesheet = vsoApp->ActivePage->PageSheet;
+ Visio::IVShapePtr pagesheet = vsoApp->ActivePage->PageSheet;
- if(!pagesheet->GetCellExists(_T("User.EnumCount"),0) && count != 0)
- {
- pagesheet->AddNamedRow(visSectionUser,_T("EnumCount"),visTagDefault);
- }
- else if(count == 0)
- {
- pagesheet->DeleteRow(visSectionUser,pagesheet->CellsRowIndex["User.EnumCount"]);
- return;
- }
+ if(!pagesheet->GetCellExists(_T("User.EnumCount"),0) && count != 0)
+ {
+ pagesheet->AddNamedRow(visSectionUser,_T("EnumCount"),visTagDefault);
+ }
+ else if(count == 0)
+ {
+ pagesheet->DeleteRow(visSectionUser,pagesheet->CellsRowIndex["User.EnumCount"]);
+ return;
+ }
- pagesheet->Cells["User.EnumCount"]->FormulaU = stringize() << count;
+ pagesheet->Cells["User.EnumCount"]->FormulaU = stringize() << count;
}
int CEnumerateUtils::getAutoEnumGroup(Visio::IVApplicationPtr vsoApp)
@@ -247,7 +247,7 @@
{
return pagesheet->Cells["User.AutoEnumGroupID"]->ResultInt[visNone][visTruncate];
}
-
+
return -1;
}
@@ -260,64 +260,63 @@
VAORC CEnumerateUtils::enableEnumeration(Visio::IVShapePtr shape, _bstr_t groupID, std::set<_bstr_t>& formerGroups)
{
- if(_tcsicmp(shape->Data1,_T("")) == 0)
- {
- shape->Data1 = _T("1");
- shape->Data2 = shape->Text;
- shape->Data3 = groupID;
- shape->AddNamedRow(visSectionAction,_T("enumeration"),visTagDefault);
- shape->Cells["Actions.enumeration.Action"]->FormulaU = _T("=RUNADDONWARGS(\"Sequence Chart Studio\",\"/event=104\")");
- shape->Cells["Actions.enumeration.Menu"]->FormulaU = _T("=\"Select numbering group\"");
- shape->Cells["Actions.enumeration.BeginGroup"]->FormulaU = _T("=TRUE");
- }
- else if(_tcsicmp(shape->Data1,_T("1")) == 0)
- {
- formerGroups.insert(shape->Data3);
- shape->Data3 = groupID;
- }
- else
- {
- if(MessageBox(GetActiveWindow(),
- _T("Data fields (Format -> Special...) are not empty! Message enumeration use Data1, Data2 and Data3 for storing enumeration information. One or more shapes can't be numbered! Do you want to clear data fields (invalid shape lose its caption)?"),
- _T("Error"),MB_YESNO | MB_ICONWARNING))
- {
- shape->Data1 = _T("1");
- shape->Data2 = _T("");
- shape->Data3 = _T("");
- }
- else
- return VAORC_FAILURE;
- }
+ if(_tcsicmp(shape->Data1,_T("")) == 0)
+ {
+ shape->Data1 = _T("1");
+ shape->Data2 = shape->Text;
+ shape->Data3 = groupID;
+ shape->AddNamedRow(visSectionAction,_T("enumeration"),visTagDefault);
+ shape->Cells["Actions.enumeration.Action"]->FormulaU = _T("=RUNADDONWARGS(\"Sequence Chart Studio\",\"/event=104\")");
+ shape->Cells["Actions.enumeration.Menu"]->FormulaU = _T("=\"Select numbering group\"");
+ }
+ else if(_tcsicmp(shape->Data1,_T("1")) == 0)
+ {
+ formerGroups.insert(shape->Data3);
+ shape->Data3 = groupID;
+ }
+ else
+ {
+ if(MessageBox(GetActiveWindow(),
+ _T("Data fields (Format -> Special...) are not empty! Message enumeration use Data1, Data2 and Data3 for storing enumeration information. One or more shapes can't be numbered! Do you want to clear data fields (invalid shape lose its caption)?"),
+ _T("Error"),MB_YESNO | MB_ICONWARNING))
+ {
+ shape->Data1 = _T("1");
+ shape->Data2 = _T("");
+ shape->Data3 = _T("");
+ }
+ else
+ return VAORC_FAILURE;
+ }
- return VAORC_SUCCESS;
+ return VAORC_SUCCESS;
}
VAORC CEnumerateUtils::disableEnumeration(Visio::IVShapePtr shape)
{
- if(_tcsicmp(shape->Data1,_T("1")) == 0) //if the enumeration was enabled
- {
- shape->Text = shape->Data2;
- shape->Data1 = _T(""); //Clean the data fields
- shape->Data2 = _T("");
- shape->Data3 = _T("");
- shape->DeleteRow(visSectionAction,shape->GetCells(_T("Actions.enumeration"))->Row);
- }
- else if(_tcsicmp(shape->Data1,_T("")) != 0)
- {
- if(MessageBox(GetActiveWindow(),
- _T("Data1 field has wrong format. Message enumeration was corrupted! Do you want to delete data fields?"),
- _T("Error"),MB_YESNO | MB_ICONWARNING) == IDYES)
- {
- shape->Data1 = _T(""); //Clean the data fields
- shape->Data2 = _T("");
- shape->Data3 = _T("");
- }
- else
- return VAORC_FAILURE;
- }
+ if(_tcsicmp(shape->Data1,_T("1")) == 0) //if the enumeration was enabled
+ {
+ shape->Text = shape->Data2;
+ shape->Data1 = _T(""); //Clean the data fields
+ shape->Data2 = _T("");
+ shape->Data3 = _T("");
+ shape->DeleteRow(visSectionAction,shape->GetCells(_T("Actions.enumeration"))->Row);
+ }
+ else if(_tcsicmp(shape->Data1,_T("")) != 0)
+ {
+ if(MessageBox(GetActiveWindow(),
+ _T("Data1 field has wrong format. Message enumeration was corrupted! Do you want to delete data fields?"),
+ _T("Error"),MB_YESNO | MB_ICONWARNING) == IDYES)
+ {
+ shape->Data1 = _T(""); //Clean the data fields
+ shape->Data2 = _T("");
+ shape->Data3 = _T("");
+ }
+ else
+ return VAORC_FAILURE;
+ }
- return VAORC_SUCCESS;
+ return VAORC_SUCCESS;
}
void CEnumerateUtils::eraseEnumInfo(Visio::IVApplicationPtr vsoApp)
@@ -325,16 +324,16 @@
Visio::IVShapePtr page = vsoApp->ActivePage->PageSheet;
for(int i=1; i<=getGroupCount(vsoApp); i++)
- {
- _bstr_t userGroupID = stringize() << _T("User.Enum") << i;
- if(page->GetCellExists(userGroupID,0) != -1)
- continue;
- page->DeleteRow(visSectionUser,page->GetCells(userGroupID)->Row);
- }
- //erase AutoNumbering information if exists
- eraseAutoEnumGroup(page->Application);
- //restore IDs
- setGroupCount(page->Application,0);
+ {
+ _bstr_t userGroupID = stringize() << _T("User.Enum") << i;
+ if(page->GetCellExists(userGroupID,0) != -1)
+ continue;
+ page->DeleteRow(visSectionUser,page->GetCells(userGroupID)->Row);
+ }
+ //erase AutoNumbering information if exists
+ eraseAutoEnumGroup(page->Application);
+ //restore IDs
+ setGroupCount(page->Application,0);
}
void CEnumerateUtils::fillComboWithTypes(WTL::CComboBox& combo)
Modified: trunk/src/view/visio/addon/messageJump.cpp
===================================================================
--- trunk/src/view/visio/addon/messageJump.cpp 2010-08-26 00:30:31 UTC (rev 861)
+++ trunk/src/view/visio/addon/messageJump.cpp 2010-08-26 22:25:05 UTC (rev 862)
@@ -37,7 +37,7 @@
return false;
std::vector<Visio::IVShapePtr> instances = connectedInstances;
- bool left = (CMessageSnapping::getMsgDirection(msgShape) == MSDIR_LEFT);
+ bool left = (CMessageSnapping::getMsgDirection(msgShape) == MSJUMP_LEFT);
Visio::IVShapePtr origIntsLeft = NULL;
Visio::IVShapePtr origIntsRight = NULL;
@@ -105,7 +105,7 @@
setMsgNeedsResnap(msgShape, true);
}
- CMessageSnapping::glueMsgToInstancesPair(msgShape, closestLeft, closestRight, PinY, MSSNAP_PRESERVE_VERTICAL);
+ CMessageSnapping::glueMsgToInstancesPair(msgShape, closestLeft, closestRight, PinY, MSSNAP_PRESERVE_VERTICAL, false);
if(closestLeft ^ closestRight)
{
Modified: trunk/src/view/visio/addon/messageSnapping.cpp
===================================================================
--- trunk/src/view/visio/addon/messageSnapping.cpp 2010-08-26 00:30:31 UTC (rev 861)
+++ trunk/src/view/visio/addon/messageSnapping.cpp 2010-08-26 22:25:05 UTC (rev 862)
@@ -19,6 +19,7 @@
#include "stdafx.h"
#include "dllmodule.h"
#include "messageSnapping.h"
+#include "messageJump.h"
#include "shapeUtils.h"
#define SNAP_REG_PATH _T("Software\\Sequence Chart Studio\\MessageSnapping")
@@ -186,7 +187,7 @@
}
void CMessageSnapping::glueMsgToInstancesPair(Visio::IVShapePtr msgShape, Visio::IVShapePtr leftInstance, Visio::IVShapePtr rightInstance,
- double yPos, MsgSnapType snapType)
+ double yPos, MsgSnapType snapType, bool dontGlueIfConnected)
{
//if there are no instances, return
if(!leftInstance && !rightInstance)
@@ -213,24 +214,34 @@
break;
}
- MsgSeqDirection msgDir = getMsgDirection(msgShape);
+ MsgJumpDirection msgDir = getMsgDirection(msgShape);
//Glue to left instance
if(leftInstance)
- glueMsgToInstance(msgShape, leftInstance, "BeginX", yLeftPos, msgDir);
+ glueMsgToInstance(msgShape, leftInstance, "BeginX", yLeftPos, msgDir, dontGlueIfConnected);
//Glue to right instance
if(rightInstance)
- glueMsgToInstance(msgShape, rightInstance, "EndX", yRightPos, msgDir);
+ glueMsgToInstance(msgShape, rightInstance, "EndX", yRightPos, msgDir, dontGlueIfConnected);
}
void CMessageSnapping::glueMsgToInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape,
const _bstr_t & msgCell, double yPos, VisUnitCodes units)
{
- glueMsgToInstance(msgShape, instanceShape, msgCell, yPos, getMsgDirection(msgShape), units);
+ glueMsgToInstance(msgShape, instanceShape, msgCell, yPos, getMsgDirection(msgShape), true, units);
}
void CMessageSnapping::glueMsgToInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape,
- const _bstr_t & msgCell, double yPos, MsgSeqDirection msgDirection, VisUnitCodes units)
+ const _bstr_t & msgCell, double yPos, MsgJumpDirection msgDirection, bool dontGlueIfConnected, VisUnitCodes units)
{
+ //NOTE: If user snap message by himself (using red rectangle), we are done
+ if(dontGlueIfConnected)
+ if(msgShape->GetCells((_tcsicmp(msgCell,_T("BeginX")) == 0) ? "BegTrigger" : "EndTrigger")->ResultInt[visNone][visTruncate] == 2)
+ return;
+
+ //NOTE: Return if endpoint is found or lost message
+ TShapeType shapeType = get_shape_type(msgShape);
+ if( (shapeType == 2 && _tcsicmp(msgCell,_T("EndX")) == 0) || (shapeType == 3 && _tcsicmp(msgCell,_T("BeginX")) == 0) )
+ return;
+
bool posX = 0;
Visio::IVShapePtr coregion;
//If instance include coregion, check for intersection with message
@@ -238,7 +249,7 @@
if(coregion)
{
instanceShape = coregion;
- if(msgDirection == MSDIR_RIGHT)
+ if(msgDirection == MSJUMP_RIGHT)
posX = (_tcsicmp(msgCell,_T("BeginX")) == 0) ? 1 : 0;
else
posX = (_tcsicmp(msgCell,_T("BeginX")) == 0) ? 0 : 1;
@@ -390,7 +401,7 @@
closestInst = getClosestInstancePair(msgShape, posX, posY, instShapes, snapType);
//Step 5: If message is left-oriented switch pointers
- if(getMsgDirection(msgShape) == MSDIR_LEFT)
+ if(getMsgDirection(msgShape) == MSJUMP_LEFT)
CShapeUtils::swapShape(closestInst.first, closestInst.second);
//Step 6:Glue to them
@@ -513,11 +524,35 @@
return NULL;
}
-MsgSeqDirection CMessageSnapping::getMsgDirection(Visio::IVShapePtr msgShape)
+MsgJumpDirection CMessageSnapping::getMsgDirection(Visio::IVShapePtr msgShape)
{
double BeginX = CShapeUtils::getShapeCell(msgShape,"BeginX");
double EndX = CShapeUtils::getShapeCell(msgShape,"EndX");
- return (BeginX < EndX) ? MSDIR_RIGHT : MSDIR_LEFT;
+ return (BeginX < EndX) ? MSJUMP_RIGHT : MSJUMP_LEFT;
}
+
+void CMessageSnapping::snapEndPointToClosestInstance(Visio::IVShapePtr msgShape, _bstr_t endPointX, MsgJumpDirection direction)
+{
+ if(!msgShape)
+ return;
+ //NOTE: If user snap message by himself (using red rectangle), we are done
+ if(msgShape->GetCells((_tcsicmp(endPointX,_T("BeginX")) == 0) ? "BegTrigger" : "EndTrigger")->ResultInt[visNone][visTruncate] == 2)
+ return;
+ //NOTE: Return if message is not connected to any instance
+ if(msgShape->GetCells("BegTrigger")->ResultIU == 1 && msgShape->GetCells("EndTrigger")->ResultIU == 1)
+ return;
+
+ MscPoint endPoint(CShapeUtils::getShapeCell(msgShape,endPointX),
+ CShapeUtils::getShapeCell(msgShape,(_tcsicmp(endPointX,_T("BeginX")) == 0) ? "BeginY" : "EndY"));
+
+ MsgJumpDirection closestInstDir = (_tcsicmp(endPointX,_T("BeginX")) == 0) ? MSJUMP_LEFT : MSJUMP_RIGHT;
+ if(direction == MSJUMP_LEFT)
+ closestInstDir = (MsgJumpDirection)!closestInstDir;
+
+ std::vector<Visio::IVShapePtr> inst = CMessageSnapping::getIntersectInstances(msgShape, endPoint.get_y(), MSSNAP_STRAIGHTEN);
+ Visio::IVShapePtr instance = CMessageJump::getClosestInstanceFromShape(endPoint, msgShape, inst, closestInstDir);
+
+ CMessageSnapping::glueMsgToInstance(msgShape, instance, endPointX, endPoint.get_y());
+}
// $Id$
\ No newline at end of file
Modified: trunk/src/view/visio/addon/messageSnapping.h
===================================================================
--- trunk/src/view/visio/addon/messageSnapping.h 2010-08-26 00:30:31 UTC (rev 861)
+++ trunk/src/view/visio/addon/messageSnapping.h 2010-08-26 22:25:05 UTC (rev 862)
@@ -50,7 +50,7 @@
* @param onlyOnInstanceLine if true avoid connection message on instace's "rectangles" on the top and the bottom
*/
static void glueMsgToInstancesPair(Visio::IVShapePtr msgShape, Visio::IVShapePtr leftInstance, Visio::IVShapePtr rightInstance,
- double yPos, MsgSnapType snapType);
+ double yPos, MsgSnapType snapType, bool dontGlueIfConnected = true);
/*
* Glue given message to instance, but only to "line" of instance, rectangles at the bottom and top are ignored
* @param msgCell message cell which should be glued (e.g. BeginX, EndY)
@@ -59,7 +59,7 @@
...
[truncated message content] |
|
From: <mbe...@us...> - 2010-09-07 22:14:57
|
Revision: 884
http://scstudio.svn.sourceforge.net/scstudio/?rev=884&view=rev
Author: mbezdeka
Date: 2010-09-07 22:14:50 +0000 (Tue, 07 Sep 2010)
Log Message:
-----------
Message snapping
- copy message with ctrl key pressed is possible
- snapping to oblique instances with coregions is now working properly
Flip message
- flip lost/found message change message to found/lost
Message jumping
- messages won't unplug on the edge instances
Modified Paths:
--------------
trunk/src/view/visio/addon/addon.cpp
trunk/src/view/visio/addon/addon.h
trunk/src/view/visio/addon/document.cpp
trunk/src/view/visio/addon/enums.h
trunk/src/view/visio/addon/messageJump.cpp
trunk/src/view/visio/addon/messageSnapping.cpp
trunk/src/view/visio/addon/messageSnapping.h
trunk/src/view/visio/addon/pageutils.h
trunk/src/view/visio/addon/shapeutils.cpp
trunk/src/view/visio/addon/shapeutils.h
Modified: trunk/src/view/visio/addon/addon.cpp
===================================================================
--- trunk/src/view/visio/addon/addon.cpp 2010-09-07 21:31:10 UTC (rev 883)
+++ trunk/src/view/visio/addon/addon.cpp 2010-09-07 22:14:50 UTC (rev 884)
@@ -677,7 +677,13 @@
case VK_RIGHT:
if(selection->Count == 1 && CMessageSnapping::isArrowKeysEnabled())
{
- instances = CMessageSnapping::getConnectedInstances(selection->Item[1]);
+ Visio::IVShapePtr shape = selection->Item[1];
+ //If message isn't connected to both endpoints(not for LOST/FOUND), snap unplugged end to nearest instance
+ MsgConnectedEndpoints conn = CShapeUtils::getConnectedEndpoints(shape);
+ if(conn != MSCE_BOTH && conn != MSCE_NONE)
+ CMessageSnapping::snapEndPointToClosestInstance(shape, (conn == MSCE_BEGIN) ? "EndX" : "BeginX", CMessageSnapping::getMsgDirection(shape));
+ //Get connected instances
+ instances = CMessageSnapping::getConnectedInstances(shape);
m_iJumpType = (keyCode == 0x25) ? 1 : 2;
}
break;
@@ -721,7 +727,6 @@
CMessageSnapping::resnap(selection->Item[i], shapes);
break;
}
-
//Message snapping
m_bCtrlDown = false;
}
@@ -774,12 +779,27 @@
{
Visio::IVShapesPtr shapes = vsoApp->ActivePage->Shapes;
Visio::IVShapePtr shape = selection->Item[1];
+
+ long scopeId = vsoApp->BeginUndoScope("Jump");
+ if(!instances.size()) //If message is not connected, snap it first
+ {
+ CMessageSnapping::snap(shape, CShapeUtils::getShapeCell(shape, "PinX"), CShapeUtils::getShapeCell(shape, "PinY"), MSSNAP_PRESERVE_VERTICAL);
+ instances = CMessageSnapping::getConnectedInstances(shape);
+ }
if(!CMessageJump::jump(shape, instances, (m_iJumpType == 1) ? MSJUMP_LEFT : MSJUMP_RIGHT))
- CMessageSnapping::snap(shape, CShapeUtils::getShapeCell(shape, "PinX"), CShapeUtils::getShapeCell(shape, "PinY"), MSSNAP_PRESERVE_VERTICAL);
+ {
+ MscPoint msgVec;
+ CMessageSnapping::getMsgVector(shape, &msgVec);
+ CMessageSnapping::resnap(shape, shapes, 0.1);
+ MsgConnectedEndpoints conn = CShapeUtils::getConnectedEndpoints(shape);
+ if(conn != MSCE_BOTH && conn != MSCE_NONE)
+ CMessageSnapping::setMsgLength(shape, msgVec, (conn == MSCE_BEGIN) ? vis1DBeginX : vis1DEndX);
+ }
if(CMessageJump::getMsgNeedsResnap(shape))
CMessageSnapping::resnap(shape, shapes, 0.0001);
instances.clear();
m_iJumpType = 0;
+ vsoApp->EndUndoScope(scopeId, true);
}
////////////////////////////////////////////////////
//Message snapping
Modified: trunk/src/view/visio/addon/addon.h
===================================================================
--- trunk/src/view/visio/addon/addon.h 2010-09-07 21:31:10 UTC (rev 883)
+++ trunk/src/view/visio/addon/addon.h 2010-09-07 22:14:50 UTC (rev 884)
@@ -165,7 +165,7 @@
std::vector<Visio::IVShapePtr> instances;
//Message jumping
- int m_iJumpType;
+ int m_iJumpType;
};
// $Id$
Modified: trunk/src/view/visio/addon/document.cpp
===================================================================
--- trunk/src/view/visio/addon/document.cpp 2010-09-07 21:31:10 UTC (rev 883)
+++ trunk/src/view/visio/addon/document.cpp 2010-09-07 22:14:50 UTC (rev 884)
@@ -279,9 +279,7 @@
if(m_addon->GetCtrlKeyDown())
posX += CPageUtils::ConvertUnits(m_vsoApp, m_addon->GetRelMousePosX(), 0, visPageUnits);
- m_vsoApp->EventsEnabled = false;
CMessageSnapping::snap(vsoShape, posX, posY, CMessageSnapping::getSnapType());
- m_vsoApp->EventsEnabled = true;
}
//Message numbering
autoEnumerate(vsoShape);
@@ -1144,10 +1142,25 @@
if(!isMessageShape(shape))
return VAORC_FAILURE;
- if(!CMessageJump::jump(shape, CMessageSnapping::getConnectedInstances(shape), (MsgJumpDirection)left))
+ long scopeId = vsoApp->BeginUndoScope("Jump");
+ std::vector<Visio::IVShapePtr> instances = CMessageSnapping::getConnectedInstances(shape);
+ MsgConnectedEndpoints conn = CShapeUtils::getConnectedEndpoints(shape);
+ if(!instances.size())
+ {
CMessageSnapping::snap(shape, CShapeUtils::getShapeCell(shape, "PinX"), CShapeUtils::getShapeCell(shape, "PinY"), MSSNAP_PRESERVE_VERTICAL);
+ instances = CMessageSnapping::getConnectedInstances(shape);
+ }
+ else if(conn != MSCE_BOTH) //If message isn't connected to both endpoints(not for LOST/FOUND), snap unplugged end to nearest instance
+ {
+ CMessageSnapping::snapEndPointToClosestInstance(shape, (conn == MSCE_BEGIN) ? "EndX" : "BeginX", CMessageSnapping::getMsgDirection(shape));
+ instances = CMessageSnapping::getConnectedInstances(shape);
+ }
+
+ CMessageJump::jump(shape, instances, (MsgJumpDirection)left);
+
if(CMessageJump::getMsgNeedsResnap(shape))
CMessageSnapping::resnap(shape, vsoApp->ActivePage->Shapes, 0.0001);
+ vsoApp->EndUndoScope(scopeId, true);
return VAORC_SUCCESS;
}
@@ -1191,17 +1204,14 @@
Visio::IVSelectionPtr selection = vsoApp->ActiveWindow->Selection;
std::vector<_bstr_t> formulas;
+ long scopeId = vsoApp->BeginUndoScope("Flip direction");
+
vsoApp->EventsEnabled = false;
for(int i = 1; i <= selection->Count; i++)
{
Visio::IVShapePtr shape = selection->Item[i];
if(!isMessageShape(shape))
continue;
- //TODO: Flip lost and found messages
- //TShapeType shapeType = get_shape_type(shape);
- //if(shapeType == ST_BMSC_MESSAGE_FOUND || shapeType == ST_BMSC_MESSAGE_LOST)
- // CMessageJump::changeMsgType(shape, (TShapeType)((shapeType == 3) ? 2 : 3));
-
for(int i = 0; i < 4; i++)
formulas.push_back(shape->GetCellsSRC(visSectionObject, visRowXForm1D, i)->FormulaU);
try {
@@ -1215,12 +1225,18 @@
MessageBox(GetActiveWindow(), L"Exception occurred", L"", MB_OK);
}
formulas.clear();
- //NOTE: changeMsgType cause disconnecting message, so we must resnap it
- //if(shapeType == ST_BMSC_MESSAGE_FOUND || shapeType == ST_BMSC_MESSAGE_LOST)
- // CMessageSnapping::resnap(shape, vsoApp->ActivePage->Shapes, 0.0001);
+ //Flip lost and found messages
+ TShapeType shapeType = get_shape_type(shape);
+ if(shapeType == ST_BMSC_MESSAGE_FOUND || shapeType == ST_BMSC_MESSAGE_LOST)
+ {
+ CMessageJump::changeMsgType(shape, (TShapeType)((shapeType == 3) ? 2 : 3));
+ CMessageSnapping::resnap(shape, vsoApp->ActivePage->Shapes, 0.0001);
+ }
}
vsoApp->EventsEnabled = true;
+ vsoApp->EndUndoScope(scopeId, true);
+
return VAORC_SUCCESS;
}
Modified: trunk/src/view/visio/addon/enums.h
===================================================================
--- trunk/src/view/visio/addon/enums.h 2010-09-07 21:31:10 UTC (rev 883)
+++ trunk/src/view/visio/addon/enums.h 2010-09-07 22:14:50 UTC (rev 884)
@@ -58,4 +58,12 @@
MSJUMP_LEFT,
};
+enum MsgConnectedEndpoints
+{
+ MSCE_NONE = 0,
+ MSCE_BEGIN,
+ MSCE_END,
+ MSCE_BOTH,
+};
+
// $Id$
Modified: trunk/src/view/visio/addon/messageJump.cpp
===================================================================
--- trunk/src/view/visio/addon/messageJump.cpp 2010-09-07 21:31:10 UTC (rev 883)
+++ trunk/src/view/visio/addon/messageJump.cpp 2010-09-07 22:14:50 UTC (rev 884)
@@ -66,8 +66,6 @@
return false;
}
- long scopeId = msgShape->Application->BeginUndoScope("Jump");
-
//Erase information about re-snaping
if(origIntsLeft && origIntsRight && getMsgNeedsResnap(msgShape))
setMsgNeedsResnap(msgShape, 0);
@@ -77,10 +75,9 @@
intersIntsEnd = CMessageSnapping::getIntersectInstances(msgShape, CShapeUtils::getShapeCell(msgShape,left ? "BeginY" : "EndY"), MSSNAP_STRAIGHTEN);
#define _s(x) CShapeUtils::getShapeCell(msgShape,x)
- Visio::IVShapePtr closestLeft = getClosestInstanceFromShape(left ? MscPoint(_s("EndX"),_s("EndY")) : MscPoint(_s("BeginX"),_s("BeginY")),
- origIntsLeft, intersIntsBegin, direction);
- Visio::IVShapePtr closestRight = getClosestInstanceFromShape(left ? MscPoint(_s("BeginX"),_s("BeginY")) : MscPoint(_s("EndX"),_s("EndY")),
- origIntsRight, intersIntsEnd, direction);
+ MscPoint begin(_s("BeginX"),_s("BeginY")), end(_s("EndX"),_s("EndY"));
+ Visio::IVShapePtr closestLeft = getClosestInstanceFromShape(left ? end : begin, origIntsLeft, intersIntsBegin, direction);
+ Visio::IVShapePtr closestRight = getClosestInstanceFromShape(left ? begin : end, origIntsRight, intersIntsEnd, direction);
#undef _s
MscPoint msgVec;
@@ -89,14 +86,12 @@
if(left)
CShapeUtils::swapShape(closestLeft, closestRight);
+ //Edge treatment
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
- {
- msgShape->Application->EndUndoScope(scopeId, true);
- return true;
- }
+ if(!isEnabled()) // If Edge treatment isn't enabled we are done and Message won't be snapped to any new instance
+ return false;
TShapeType shapeType = (TShapeType)(left ? ((direction == MSJUMP_LEFT) ? 2 : 3) : ((direction == MSJUMP_LEFT) ? 3 : 2));
changeMsgType(msgShape, (getEdgeInstanceTreatment() == 1) ? shapeType : ST_BMSC_MESSAGE);
@@ -105,25 +100,19 @@
setMsgNeedsResnap(msgShape, true);
}
+ //Glue messages to instances
CMessageSnapping::glueMsgToInstancesPair(msgShape, closestLeft, closestRight, PinY, MSSNAP_PRESERVE_VERTICAL, false);
-
+ //Preserve its length (If message is snapped only to one instance, preserve its length)
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"]->Formula = stringize() << msgShape->Cells["BeginX"]->Result[visMillimeters] + msgVec.get_x() << " mm";
- msgShape->Cells["EndY"]->Formula = stringize() << msgShape->Cells["BeginY"]->Result[visMillimeters] + msgVec.get_y() << " mm";
- }
+ CMessageSnapping::setMsgLength(msgShape, msgVec, vis1DBeginX);
if(closestRight) //RIGHT point is snapped, adjust left point
- {
- msgShape->Cells["BeginX"]->Formula = stringize() << msgShape->Cells["EndX"]->Result[visMillimeters] - msgVec.get_x() << " mm";
- msgShape->Cells["BeginY"]->Formula = stringize() << msgShape->Cells["EndY"]->Result[visMillimeters] - msgVec.get_y() << " mm";
- }
- msgShape->Application->EventsEnabled = true;
+ CMessageSnapping::setMsgLength(msgShape, msgVec, vis1DEndX);
}
- msgShape->Application->EndUndoScope(scopeId, true);
+
+ if(!closestLeft && !closestRight)
+ return false;
return true;
}
@@ -179,47 +168,25 @@
{
bool bCellExists = (msgShape->GetCellExists(_T("User.Resnap"),0) == -1);
- if(bTrueIfNeeds && !bCellExists)
- {
- msgShape->AddNamedRow(visSectionUser, _T("Resnap"), 0);
- msgShape->Cells["User.Resnap"]->FormulaU = _T("1");
- }
- else if(!bTrueIfNeeds && bCellExists)
- msgShape->DeleteRow(visSectionUser,msgShape->CellsRowIndex["User.Resnap"]);
+ if(bTrueIfNeeds && !bCellExists)
+ {
+ msgShape->AddNamedRow(visSectionUser, _T("Resnap"), 0);
+ msgShape->Cells["User.Resnap"]->FormulaU = _T("1");
+ }
+ else if(!bTrueIfNeeds && bCellExists)
+ msgShape->DeleteRow(visSectionUser,msgShape->CellsRowIndex["User.Resnap"]);
}
bool CMessageJump::changeMsgType(Visio::IVShapePtr& msgShape, TShapeType shapeType)
{
- Visio::IVPagePtr page = msgShape->Application->ActivePage;
+ if(!msgShape || !isMessageShape(msgShape))
+ return false;
- //Disable snapping
- bool snapStatus = CMessageSnapping::isEnabled();
- CMessageSnapping::setEnabled(false);
- //Change message to lost/found
- CDrawingVisualizer visualizer(msgShape->Application);
- Visio::IVShapePtr newMsg = page->Drop(visualizer.find_master(shapeType),0,0);
- //Copy message internal data
- newMsg->Text = msgShape->Text;
- newMsg->Data1 = msgShape->Data1;
- newMsg->Data2 = msgShape->Data2;
- newMsg->Data3 = msgShape->Data3;
- //Copy message position
- msgShape->Application->EventsEnabled = false;
- try {
- for(int i=0; i<4; i++)
- newMsg->GetCellsSRC(visSectionObject, visRowXForm1D, i)->Formula =
- msgShape->GetCellsSRC(visSectionObject, visRowXForm1D, i)->ResultStr[visMillimeters];
- }
- catch (_com_error err) {
- MessageBox(GetActiveWindow(), _T("changeMsgType: exception occurred."), L"", MB_OK);
- }
- msgShape->Application->EventsEnabled = true;
-
+ Visio::IVShapePtr newShape = CShapeUtils::duplicateShape(msgShape, shapeType);
+
msgShape->Delete();
- msgShape = newMsg;
+ msgShape = newShape;
- //Enable snapping back
- CMessageSnapping::setEnabled(snapStatus);
return true;
}
Modified: trunk/src/view/visio/addon/messageSnapping.cpp
===================================================================
--- trunk/src/view/visio/addon/messageSnapping.cpp 2010-09-07 21:31:10 UTC (rev 883)
+++ trunk/src/view/visio/addon/messageSnapping.cpp 2010-09-07 22:14:50 UTC (rev 884)
@@ -232,14 +232,18 @@
void CMessageSnapping::glueMsgToInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape,
const _bstr_t & msgCell, double yPos, MsgJumpDirection msgDirection, bool dontGlueIfConnected, VisUnitCodes units)
{
+ if(!msgShape || !instanceShape)
+ return;
+
+ bool isBegin = _tcsicmp(msgCell,_T("BeginX")) == 0;
//NOTE: If user snap message by himself (using red rectangle), we are done
if(dontGlueIfConnected)
- if(msgShape->GetCells((_tcsicmp(msgCell,_T("BeginX")) == 0) ? "BegTrigger" : "EndTrigger")->ResultInt[visNone][visTruncate] == 2)
+ if(msgShape->GetCells(isBegin ? "BegTrigger" : "EndTrigger")->ResultInt[visNone][visTruncate] == 2)
return;
//NOTE: Return if endpoint is found or lost message
TShapeType shapeType = get_shape_type(msgShape);
- if( (shapeType == 2 && _tcsicmp(msgCell,_T("EndX")) == 0) || (shapeType == 3 && _tcsicmp(msgCell,_T("BeginX")) == 0) )
+ if( (shapeType == 2 && _tcsicmp(msgCell,_T("EndX")) == 0) || (shapeType == 3 && isBegin) )
return;
bool posX = 0;
@@ -249,13 +253,30 @@
if(coregion)
{
instanceShape = coregion;
- if(msgDirection == MSJUMP_RIGHT)
- posX = (_tcsicmp(msgCell,_T("BeginX")) == 0) ? 1 : 0;
- else
- posX = (_tcsicmp(msgCell,_T("BeginX")) == 0) ? 0 : 1;
+ posX = (msgDirection == MSJUMP_RIGHT) ? (isBegin ? 1 : 0) : (isBegin ? 0 : 1);
- if(CShapeUtils::getShapeCell(instanceShape, "BeginY", units) < CShapeUtils::getShapeCell(instanceShape, "EndY", units))
+ MscPoint corBegin(CShapeUtils::getShapeCell(instanceShape, "BeginX", units), CShapeUtils::getShapeCell(instanceShape, "BeginY", units));
+ MscPoint corEnd(CShapeUtils::getShapeCell(instanceShape, "EndX", units), CShapeUtils::getShapeCell(instanceShape, "EndY", units));
+
+ //Get intersection with coregion
+ MscPoint corNormalVec = corBegin - corEnd;
+ corNormalVec = MscPoint(-corNormalVec.get_y(), corNormalVec.get_x());
+ double normalize = sqrt(pow(corNormalVec.get_x(), 2) + pow(corNormalVec.get_y(), 2));
+ //FIXME: Change to coregion height
+ double corHeight = CShapeUtils::getCoregionHeight(instanceShape, units);
+ corNormalVec = MscPoint(corNormalVec.get_x() / normalize * corHeight, corNormalVec.get_y() / normalize * corHeight);
+
+ int coef = -1;
+ if((msgDirection == MSJUMP_LEFT && isBegin) || (msgDirection == MSJUMP_RIGHT && !isBegin))
+ coef = 1;
+
+ if(corBegin.get_y() < corEnd.get_y())
+ {
posX = !posX;
+ coef *= -1;
+ }
+
+ yPos -= corNormalVec.get_y()*coef;
}
double InstBegY = CShapeUtils::getShapeCell(instanceShape, "BeginY", units);
@@ -297,8 +318,25 @@
double offsetX = CShapeUtils::getShapeCell(instanceShape, "Height", units) / 2.0;
offsetX *= (p2.get_x() > p4.get_x()) ? 1 : -1;
- p4.set_x(p4.get_x() + offsetX);
- p3.set_x(p3.get_x() + offsetX);
+ if(p3.get_x() != p4.get_x())
+ {
+ MscPoint corNormalVec = p4 - p3;
+ corNormalVec = MscPoint(-corNormalVec.get_y(), corNormalVec.get_x());
+ double normalize = sqrt(pow(corNormalVec.get_x(), 2) + pow(corNormalVec.get_y(), 2));
+ double corHeight = CShapeUtils::getCoregionHeight(instanceShape, units);
+ corNormalVec = MscPoint(corNormalVec.get_x() / normalize * offsetX, corNormalVec.get_y() / normalize * offsetX);
+
+ p4.set_x(p4.get_x() + corNormalVec.get_x());
+ p4.set_y(p4.get_y() + corNormalVec.get_y());
+
+ p3.set_x(p3.get_x() + corNormalVec.get_x());
+ p3.set_y(p3.get_y() + corNormalVec.get_y());
+ }
+ else
+ {
+ p4.set_x(p4.get_x() + offsetX);
+ p3.set_x(p3.get_x() + offsetX);
+ }
}
MscPoint* result = CPageUtils::getIntersectionPoint(p1, p2, p3, p4);
@@ -460,6 +498,9 @@
bool CMessageSnapping::resnap(Visio::IVShapePtr msgShape, Visio::IVShapesPtr shapes, double precision)
{
+ if(!msgShape || !shapes)
+ return false;
+
long scopeId = msgShape->Application->BeginUndoScope(_T("Re-snap"));
MscPoint beginPoint(msgShape->Cells["BeginX"]->Result[""], msgShape->Cells["BeginY"]->Result[""]);
@@ -533,15 +574,15 @@
return (BeginX < EndX) ? MSJUMP_RIGHT : MSJUMP_LEFT;
}
-void CMessageSnapping::snapEndPointToClosestInstance(Visio::IVShapePtr msgShape, _bstr_t endPointX, MsgJumpDirection direction)
+Visio::IVShapePtr CMessageSnapping::snapEndPointToClosestInstance(Visio::IVShapePtr msgShape, _bstr_t endPointX, MsgJumpDirection direction)
{
if(!msgShape)
- return;
+ return NULL;
bool isBegin = _tcsicmp(endPointX,_T("BeginX")) == 0;
//NOTE: If user snap message by himself (using red rectangle), we are done
if(msgShape->GetCells(isBegin ? "BegTrigger" : "EndTrigger")->ResultInt[visNone][visTruncate] == 2)
- return;
+ return NULL;
MscPoint endPoint(CShapeUtils::getShapeCell(msgShape,endPointX),
CShapeUtils::getShapeCell(msgShape,isBegin ? "BeginY" : "EndY"));
@@ -554,5 +595,33 @@
Visio::IVShapePtr instance = CMessageJump::getClosestInstanceFromShape(endPoint, msgShape, inst, closestInstDir);
CMessageSnapping::glueMsgToInstance(msgShape, instance, endPointX, endPoint.get_y());
+
+ return instance;
}
+
+void CMessageSnapping::setMsgLength(Visio::IVShapePtr msgShape, MscPoint msgVector, VisCellIndices fixedColumnX)
+{
+ if(!msgShape || !isMessageShape(msgShape))
+ return;
+
+ msgShape->Application->EventsEnabled = false;
+
+ int sign = (fixedColumnX == vis1DBeginX) ? 1 : -1;
+
+ try {
+ msgShape->GetCellsSRC(visSectionObject,visRowXForm1D, fixedColumnX+(2*sign))->Formula =
+ stringize() << msgShape->GetCellsSRC(visSectionObject,
+ visRowXForm1D,
+ fixedColumnX)->Result[visMillimeters] + sign * msgVector.get_x() << " mm";
+
+ msgShape->GetCellsSRC(visSectionObject,visRowXForm1D, (fixedColumnX + 1)+(2*sign))->Formula =
+ stringize() << msgShape->GetCellsSRC(visSectionObject,
+ visRowXForm1D,
+ fixedColumnX+1)->Result[visMillimeters] + sign * msgVector.get_y() << " mm";
+ }
+ catch(_com_error err) {
+ MessageBox(GetActiveWindow(), L"setMsgLength: exception occurred", L"Error", MB_OK);
+ }
+ msgShape->Application->EventsEnabled = true;
+}
// $Id$
\ No newline at end of file
Modified: trunk/src/view/visio/addon/messageSnapping.h
===================================================================
--- trunk/src/view/visio/addon/messageSnapping.h 2010-09-07 21:31:10 UTC (rev 883)
+++ trunk/src/view/visio/addon/messageSnapping.h 2010-09-07 22:14:50 UTC (rev 884)
@@ -53,7 +53,7 @@
double yPos, MsgSnapType snapType, bool dontGlueIfConnected = true);
/*
* Glue given message to instance, but only to "line" of instance, rectangles at the bottom and top are ignored
- * @param msgCell message cell which should be glued (e.g. BeginX, EndY)
+ * @param msgCell message cell which should be glued (e.g. BeginX, EndX)
* @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,
@@ -104,8 +104,13 @@
/*
*
*/
- static void snapEndPointToClosestInstance(Visio::IVShapePtr msgShape, _bstr_t endPointX, MsgJumpDirection direction);
-
+ static Visio::IVShapePtr snapEndPointToClosestInstance(Visio::IVShapePtr msgShape, _bstr_t endPointX, MsgJumpDirection direction);
+ /*
+ * Set length of message given by direction and length of msgVector
+ * @param msgVector Vector must be in milimeters!!!
+ * @param fixedColumnX Fixed column (vis1DBeginX, vis1DEndX) stays fixed and other side of message will be prolonged
+ */
+ static void setMsgLength(Visio::IVShapePtr msgShape, MscPoint msgVector, VisCellIndices fixedColumnX);
};
// $Id$
\ No newline at end of file
Modified: trunk/src/view/visio/addon/pageutils.h
===================================================================
--- trunk/src/view/visio/addon/pageutils.h 2010-09-07 21:31:10 UTC (rev 883)
+++ trunk/src/view/visio/addon/pageutils.h 2010-09-07 22:14:50 UTC (rev 884)
@@ -20,15 +20,6 @@
#include "stdafx.h"
#include "extract.h"
-typedef struct _Vec2
-{
- _Vec2() {};
- _Vec2(double _x, double _y): x(_x), y(_y) {};
- double x;
- double y;
-
-} VEC2, *PVEC2;
-
/**
* A utility class for functionality on a Visio Page.
*/
Modified: trunk/src/view/visio/addon/shapeutils.cpp
===================================================================
--- trunk/src/view/visio/addon/shapeutils.cpp 2010-09-07 21:31:10 UTC (rev 883)
+++ trunk/src/view/visio/addon/shapeutils.cpp 2010-09-07 22:14:50 UTC (rev 884)
@@ -16,6 +16,8 @@
* $Id$
*/
#include "shapeutils.h"
+#include "messageSnapping.h"
+#include "visualize.h"
void CShapeUtils::GlueBeginToPos(Visio::IVShapePtr what, Visio::IVShapePtr where, const MscPoint& pos)
{
@@ -90,6 +92,62 @@
shape2 = buffer;
}
+MsgConnectedEndpoints CShapeUtils::getConnectedEndpoints(Visio::IVShapePtr shape)
+{
+ bool begSnapped = shape->GetCells("BegTrigger")->ResultInt[visNone][visTruncate] == 2;
+ bool endSnapped = shape->GetCells("EndTrigger")->ResultInt[visNone][visTruncate] == 2;
+
+ if(begSnapped && endSnapped)
+ return MSCE_BOTH;
+ if(begSnapped)
+ return MSCE_BEGIN;
+ if(endSnapped)
+ return MSCE_END;
+
+ return MSCE_NONE;
+}
+
+Visio::IVShapePtr CShapeUtils::duplicateShape(Visio::IVShapePtr origShape, TShapeType newShapeType)
+{
+ if(!origShape)
+ return NULL;
+
+ Visio::IVPagePtr page = origShape->Application->ActivePage;
+
+ bool snapStatus = CMessageSnapping::isEnabled();
+ CMessageSnapping::setEnabled(false);
+ //Change message to lost/found
+ CDrawingVisualizer visualizer(origShape->Application);
+ origShape->Application->EventsEnabled = true;
+ Visio::IVShapePtr newShape = page->Drop(visualizer.find_master(newShapeType),0,0);
+ origShape->Application->EventsEnabled = false;
+ //Copy message internal data (for message numbering)
+ newShape->Text = origShape->Text;
+ newShape->Data1 = origShape->Data1;
+ newShape->Data2 = origShape->Data2;
+ newShape->Data3 = origShape->Data3;
+ //Copy message position
+ try {
+ for(int i=0; i<4; i++)
+ newShape->GetCellsSRC(visSectionObject, visRowXForm1D, i)->Formula =
+ origShape->GetCellsSRC(visSectionObject, visRowXForm1D, i)->ResultStr[visMillimeters];
+ }
+ catch (_com_error err) {
+ MessageBox(GetActiveWindow(), _T("changeMsgType: exception occurred."), L"", MB_OK);
+ }
+ origShape->Application->EventsEnabled = true;
+
+ //Enable snapping back
+ CMessageSnapping::setEnabled(snapStatus);
+
+ return newShape;
+}
+
+double CShapeUtils::getCoregionHeight(Visio::IVShapePtr coregion, VisUnitCodes units)
+{
+ return CShapeUtils::getShapeCell(coregion, "Height", units) / 2.0;
+}
+
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-09-07 21:31:10 UTC (rev 883)
+++ trunk/src/view/visio/addon/shapeutils.h 2010-09-07 22:14:50 UTC (rev 884)
@@ -54,6 +54,12 @@
static Visio::IVShapePtr GetCoregionAt(Visio::IVShapePtr shape, double yPos);
static void swapShape(Visio::IVShapePtr& shape1, Visio::IVShapePtr& shape2);
+
+ static MsgConnectedEndpoints getConnectedEndpoints(Visio::IVShapePtr shape);
+
+ static Visio::IVShapePtr duplicateShape(Visio::IVShapePtr shape, TShapeType newShapeType);
+
+ static double getCoregionHeight(Visio::IVShapePtr coregion, VisUnitCodes units = visPageUnits);
};
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mbe...@us...> - 2010-09-08 22:49:16
|
Revision: 896
http://scstudio.svn.sourceforge.net/scstudio/?rev=896&view=rev
Author: mbezdeka
Date: 2010-09-08 22:49:10 +0000 (Wed, 08 Sep 2010)
Log Message:
-----------
Message snapping
- repair snapping to oblique coregions
Modified Paths:
--------------
trunk/src/view/visio/addon/addon.cpp
trunk/src/view/visio/addon/messageSnapping.cpp
trunk/src/view/visio/addon/messageSnapping.h
trunk/src/view/visio/addon/pageutils.cpp
trunk/src/view/visio/addon/pageutils.h
trunk/src/view/visio/addon/shapeutils.cpp
trunk/src/view/visio/addon/shapeutils.h
Modified: trunk/src/view/visio/addon/addon.cpp
===================================================================
--- trunk/src/view/visio/addon/addon.cpp 2010-09-08 14:33:01 UTC (rev 895)
+++ trunk/src/view/visio/addon/addon.cpp 2010-09-08 22:49:10 UTC (rev 896)
@@ -724,7 +724,7 @@
case VK_UP:
case VK_DOWN:
for(int i=1; i<=selection->Count; i++)
- CMessageSnapping::resnap(selection->Item[i], shapes);
+ CMessageSnapping::resnap(selection->Item[i], shapes, 0.0001);
break;
}
//Message snapping
Modified: trunk/src/view/visio/addon/messageSnapping.cpp
===================================================================
--- trunk/src/view/visio/addon/messageSnapping.cpp 2010-09-08 14:33:01 UTC (rev 895)
+++ trunk/src/view/visio/addon/messageSnapping.cpp 2010-09-08 22:49:10 UTC (rev 896)
@@ -90,7 +90,6 @@
MscPoint* result = getIntersectionWithInstance(msgShape, shape);
if(result)
instShapes.push_back(shape);
-
delete result;
}
else
@@ -166,7 +165,6 @@
else
return std::pair<Visio::IVShapePtr, Visio::IVShapePtr>(NULL,NULL); //NOTE: Ordinary snap will handle position change
}
-
#undef _ip
//restrict snapping for FOUND and LOST messages
@@ -247,44 +245,30 @@
return;
bool posX = 0;
- Visio::IVShapePtr coregion;
- //If instance include coregion, check for intersection with message
- coregion = getCoregionAt(instanceShape, yPos, units);
+ MscPoint InstBeg(CShapeUtils::getShapeCell(instanceShape, "BeginX", units), CShapeUtils::getShapeCell(instanceShape, "BeginY", units));
+ MscPoint InstEnd(CShapeUtils::getShapeCell(instanceShape, "EndX", units), CShapeUtils::getShapeCell(instanceShape, "EndY", units));
+
+ //If instance include coregion, adjust glue point
+ Visio::IVShapePtr coregion = getCoregionAt(instanceShape, yPos, units);
if(coregion)
{
instanceShape = coregion;
+ double corBegY = CShapeUtils::getShapeCell(instanceShape, "BeginY", units);
+ double corEndY = CShapeUtils::getShapeCell(instanceShape, "EndY", units);
posX = (msgDirection == MSJUMP_RIGHT) ? (isBegin ? 1 : 0) : (isBegin ? 0 : 1);
+ double corSide = (InstBeg.get_y() < InstEnd.get_y()) ? !posX : posX;
+ MscPoint* normalVec = CPageUtils::getNormalVec(InstBeg-InstEnd, CShapeUtils::getCoregionHeight(instanceShape, units) * (corSide ? 1 : -1));
+ InstBeg.set_y(corBegY + normalVec->get_y());
+ InstEnd.set_y(corEndY + normalVec->get_y());
+ delete normalVec;
- MscPoint corBegin(CShapeUtils::getShapeCell(instanceShape, "BeginX", units), CShapeUtils::getShapeCell(instanceShape, "BeginY", units));
- MscPoint corEnd(CShapeUtils::getShapeCell(instanceShape, "EndX", units), CShapeUtils::getShapeCell(instanceShape, "EndY", units));
-
- //Get intersection with coregion
- MscPoint corNormalVec = corBegin - corEnd;
- corNormalVec = MscPoint(-corNormalVec.get_y(), corNormalVec.get_x());
- double normalize = sqrt(pow(corNormalVec.get_x(), 2) + pow(corNormalVec.get_y(), 2));
- //FIXME: Change to coregion height
- double corHeight = CShapeUtils::getCoregionHeight(instanceShape, units);
- corNormalVec = MscPoint(corNormalVec.get_x() / normalize * corHeight, corNormalVec.get_y() / normalize * corHeight);
-
- int coef = -1;
- if((msgDirection == MSJUMP_LEFT && isBegin) || (msgDirection == MSJUMP_RIGHT && !isBegin))
- coef = 1;
-
- if(corBegin.get_y() < corEnd.get_y())
- {
+ if(corBegY < corEndY)
posX = !posX;
- coef *= -1;
- }
-
- yPos -= corNormalVec.get_y()*coef;
}
- double InstBegY = CShapeUtils::getShapeCell(instanceShape, "BeginY", units);
- double InstEndY = CShapeUtils::getShapeCell(instanceShape, "EndY", units);
+ double sizeOfInstance = fabs(InstBeg.get_y() - InstEnd.get_y());
+ double msgOffset = fabs(InstBeg.get_y() - yPos);
- double sizeOfInstance = fabs(InstBegY - InstEndY);
- double msgOffset = fabs(InstBegY - yPos);
-
//avoid division by zero - when instances are in horizontal position
if(sizeOfInstance == 0 || msgOffset > sizeOfInstance)
return;
@@ -299,50 +283,26 @@
if(!instanceShape)
return NULL;
+ MscPoint* result = NULL;
MscPoint p1,p2,p3,p4;
+
p1 = endPoint;
p2 = beginPoint;
-
#define _i(x) CShapeUtils::getShapeCell(instanceShape, x, units)
p3 = MscPoint(_i("EndX"), _i("EndY"));
p4 = MscPoint(_i("BeginX"), _i("BeginY"));
#undef _i
-
- //FIXME: if coregion is oblique, snapping isn't always correct
- if(get_shape_type(instanceShape) == ST_BMSC_COREGION)
+
+ std::vector<Visio::IVShapePtr> cor = CShapeUtils::getConnectedShapes(instanceShape, ST_BMSC_COREGION);
+ for(u_int i=0; i<cor.size(); i++)
{
- //if msg is left, flip x-coord
- if(p1.get_x() < p2.get_x())
- std::swap(p1,p2);
-
- double offsetX = CShapeUtils::getShapeCell(instanceShape, "Height", units) / 2.0;
- offsetX *= (p2.get_x() > p4.get_x()) ? 1 : -1;
-
- if(p3.get_x() != p4.get_x())
- {
- MscPoint corNormalVec = p4 - p3;
- corNormalVec = MscPoint(-corNormalVec.get_y(), corNormalVec.get_x());
- double normalize = sqrt(pow(corNormalVec.get_x(), 2) + pow(corNormalVec.get_y(), 2));
- double corHeight = CShapeUtils::getCoregionHeight(instanceShape, units);
- corNormalVec = MscPoint(corNormalVec.get_x() / normalize * offsetX, corNormalVec.get_y() / normalize * offsetX);
-
- p4.set_x(p4.get_x() + corNormalVec.get_x());
- p4.set_y(p4.get_y() + corNormalVec.get_y());
-
- p3.set_x(p3.get_x() + corNormalVec.get_x());
- p3.set_y(p3.get_y() + corNormalVec.get_y());
- }
- else
- {
- p4.set_x(p4.get_x() + offsetX);
- p3.set_x(p3.get_x() + offsetX);
- }
+ if(!(result = getIntersectionWithCoregion(beginPoint, endPoint, cor.at(i), units)))
+ continue;
+ return result;
}
- MscPoint* result = CPageUtils::getIntersectionPoint(p1, p2, p3, p4);
- if(!result)
+ if(!(result = CPageUtils::getIntersectionPoint(p1, p2, p3, p4)))
return NULL;
-
//Swap y coord if instance is upside down
if(p4.get_y() < p3.get_y())
std::swap(p4, p3);
@@ -371,6 +331,9 @@
bool CMessageSnapping::isPointOnInstancesLine(const MscPoint& point, Visio::IVShapePtr instShape, VisUnitCodes units)
{
+ if(!instShape)
+ return false;
+
#define _sp(x) CShapeUtils::getShapeCell(instShape, x, units)
double InstOffset = 0;
@@ -490,8 +453,10 @@
for(int i=1; i<=conns->Count; i++)
{
Visio::IVConnectPtr conItem = conns->Item[i];
- Visio::IVCellPtr instCell = conItem->ToCell;
- instances.push_back(instCell->Shape);
+ Visio::IVShapePtr shape = conItem->ToCell->Shape;
+ if(get_shape_type(shape) == ST_BMSC_COREGION)
+ shape = shape->Connects->ToSheet; //NOTE: If we are connected to coregion, we treat it as we are connected to instance
+ instances.push_back(shape);
}
return instances;
}
@@ -510,7 +475,7 @@
{
Visio::IVShapePtr it = shapes->Item[i];
TShapeType shapeType = get_shape_type(it);
- if(!(shapeType == ST_BMSC_INSTANCE || shapeType == ST_BMSC_COREGION))
+ if(shapeType != ST_BMSC_INSTANCE)
continue;
MscPoint* bufferPoint = getIntersectionWithInstance(msgShape,it, (VisUnitCodes)0);
@@ -624,4 +589,50 @@
}
msgShape->Application->EventsEnabled = true;
}
+
+MscPoint* CMessageSnapping::getIntersectionWithCoregion(MscPoint beginPoint, MscPoint endPoint,
+ Visio::IVShapePtr coregionShape, VisUnitCodes units)
+{
+ if(!coregionShape || get_shape_type(coregionShape) != ST_BMSC_COREGION)
+ return NULL;
+
+ double offsetX = CShapeUtils::getCoregionHeight(coregionShape, units);
+
+#define _i(x) CShapeUtils::getShapeCell(coregionShape, x, units)
+ MscPoint corBeginPoint(_i("BeginX"), _i("BeginY"));
+ MscPoint corEndPoint(_i("EndX"), _i("EndY"));
+#undef _i
+
+ if(corBeginPoint.get_y() < corEndPoint.get_y())
+ std::swap(corBeginPoint, corEndPoint); //NOTE: No coregion can't be upside down
+ //STEP 1: Get relative message position to coregion (left or right side)
+ //FIXME: Doesn't corespond with mouse position on snapping - do it better
+ if(beginPoint.get_x() > endPoint.get_x())
+ std::swap(beginPoint, endPoint); //NOTE: Every message is treated as right-headed
+ MscPoint* point = NULL;
+ if(!(point = CPageUtils::getIntersectionPoint(endPoint, beginPoint, corEndPoint, corBeginPoint)))
+ return NULL;
+ offsetX *= (point->get_x() < endPoint.get_x()) ? 1 : -1; //FIXME: Deciding whether message should be on the right or on the left isn't accurate
+ delete point;
+
+ //STEP 2: Move coregion points at distance of coregion height
+ MscPoint corNormalVec = corBeginPoint - corEndPoint;
+ corNormalVec = MscPoint(corNormalVec.get_y(), -corNormalVec.get_x());
+ double normalize = sqrt(pow(corNormalVec.get_x(), 2) + pow(corNormalVec.get_y(), 2));
+ corNormalVec = MscPoint(corNormalVec.get_x() / normalize * offsetX, corNormalVec.get_y() / normalize * offsetX);
+
+ //STEP 3: Compute intersection
+ corBeginPoint = corBeginPoint + corNormalVec;
+ corEndPoint = corEndPoint + corNormalVec;
+
+ MscPoint * resultPoint = NULL;
+ if(!(resultPoint = CPageUtils::getIntersectionPoint(endPoint, beginPoint, corEndPoint, corBeginPoint)))
+ return NULL;
+ //STEP 4: Check boundaries
+ if((point->get_y() < corBeginPoint.get_y()) && (point->get_y() > corEndPoint.get_y()))
+ return resultPoint;
+
+ delete resultPoint;
+ return NULL;
+}
// $Id$
\ No newline at end of file
Modified: trunk/src/view/visio/addon/messageSnapping.h
===================================================================
--- trunk/src/view/visio/addon/messageSnapping.h 2010-09-08 14:33:01 UTC (rev 895)
+++ trunk/src/view/visio/addon/messageSnapping.h 2010-09-08 22:49:10 UTC (rev 896)
@@ -63,8 +63,9 @@
/*
*
*/
- static MscPoint* getIntersectionWithInstance(const MscPoint& beginPoint,const MscPoint& endPoint, Visio::IVShapePtr instanceShape, VisUnitCodes units = visPageUnits);
static MscPoint* getIntersectionWithInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape, VisUnitCodes units = visPageUnits);
+ static MscPoint* getIntersectionWithInstance(const MscPoint& beginPoint,const MscPoint& endPoint,
+ Visio::IVShapePtr instanceShape, VisUnitCodes units = visPageUnits);
/*
*
*/
@@ -111,6 +112,11 @@
* @param fixedColumnX Fixed column (vis1DBeginX, vis1DEndX) stays fixed and other side of message will be prolonged
*/
static void setMsgLength(Visio::IVShapePtr msgShape, MscPoint msgVector, VisCellIndices fixedColumnX);
+ /*
+ *
+ */
+ static MscPoint* getIntersectionWithCoregion( MscPoint beginPoint, MscPoint endPoint,
+ Visio::IVShapePtr coregionShape, VisUnitCodes units = visPageUnits);
};
// $Id$
\ No newline at end of file
Modified: trunk/src/view/visio/addon/pageutils.cpp
===================================================================
--- trunk/src/view/visio/addon/pageutils.cpp 2010-09-08 14:33:01 UTC (rev 895)
+++ trunk/src/view/visio/addon/pageutils.cpp 2010-09-08 22:49:10 UTC (rev 896)
@@ -149,4 +149,15 @@
return new MscPoint(x,y);
}
+MscPoint* CPageUtils::getNormalVec(const MscPoint &origVector, double newVectorSize)
+{
+ //Create normal vector
+ MscPoint normalVec(origVector.get_y(), -origVector.get_x());
+ //Normalize
+ double normalize = sqrt(pow(normalVec.get_x(), 2) + pow(normalVec.get_y(), 2));
+ normalVec = MscPoint(normalVec.get_x() / normalize * newVectorSize, normalVec.get_y() / normalize * newVectorSize);
+
+ return new MscPoint(normalVec);
+}
+
// $Id$
Modified: trunk/src/view/visio/addon/pageutils.h
===================================================================
--- trunk/src/view/visio/addon/pageutils.h 2010-09-08 14:33:01 UTC (rev 895)
+++ trunk/src/view/visio/addon/pageutils.h 2010-09-08 22:49:10 UTC (rev 896)
@@ -93,6 +93,8 @@
* @param p4 beginpoint of the second line
*/
static MscPoint* getIntersectionPoint(const MscPoint& p1, const MscPoint& p2, const MscPoint& p3, const MscPoint& p4);
+
+ static MscPoint* getNormalVec(const MscPoint& origVector, double newVectorSize);
};
// $Id$
Modified: trunk/src/view/visio/addon/shapeutils.cpp
===================================================================
--- trunk/src/view/visio/addon/shapeutils.cpp 2010-09-08 14:33:01 UTC (rev 895)
+++ trunk/src/view/visio/addon/shapeutils.cpp 2010-09-08 22:49:10 UTC (rev 896)
@@ -148,6 +148,21 @@
return CShapeUtils::getShapeCell(coregion, "Height", units) / 2.0;
}
+std::vector<Visio::IVShapePtr> CShapeUtils::getConnectedShapes(Visio::IVShapePtr shape, TShapeType connectedShapeType)
+{
+ std::vector<Visio::IVShapePtr> shapes;
+ Visio::IVConnectsPtr connects = shape->FromConnects;
+
+ for (int i=1; i<=connects->Count; i++)
+ {
+ Visio::IVShapePtr connShape = connects->Item[i]->FromSheet;
+ if (get_shape_type(connShape) != connectedShapeType)
+ continue;
+ shapes.push_back(connShape);
+ }
+ return shapes;
+}
+
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-09-08 14:33:01 UTC (rev 895)
+++ trunk/src/view/visio/addon/shapeutils.h 2010-09-08 22:49:10 UTC (rev 896)
@@ -60,6 +60,12 @@
static Visio::IVShapePtr duplicateShape(Visio::IVShapePtr shape, TShapeType newShapeType);
static double getCoregionHeight(Visio::IVShapePtr coregion, VisUnitCodes units = visPageUnits);
+ /*
+ * Get shapes connected to another shape
+ * @param shape shape the other shapes are connected to
+ * @param connectedShapeType filter for connected shapes (e.g. coregions, messages, etc.)
+ */
+ static std::vector<Visio::IVShapePtr> getConnectedShapes(Visio::IVShapePtr shape, TShapeType connectedShapeType);
};
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mbe...@us...> - 2010-09-10 10:14:13
|
Revision: 908
http://scstudio.svn.sourceforge.net/scstudio/?rev=908&view=rev
Author: mbezdeka
Date: 2010-09-10 10:14:06 +0000 (Fri, 10 Sep 2010)
Log Message:
-----------
Message Jump
- jumping as copy is now possible by pressing ctrl or shift with button
Modified Paths:
--------------
trunk/src/view/visio/addon/addon.cpp
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/messageJump.cpp
trunk/src/view/visio/addon/messageJump.h
trunk/src/view/visio/addon/resource.h
trunk/src/view/visio/addon/scstudio.vcproj
trunk/src/view/visio/addon/shapeutils.cpp
Added Paths:
-----------
trunk/src/view/visio/addon/icon_jump_left_messages_copy.ico
trunk/src/view/visio/addon/icon_jump_right_messages_copy.ico
Modified: trunk/src/view/visio/addon/addon.cpp
===================================================================
--- trunk/src/view/visio/addon/addon.cpp 2010-09-10 07:13:39 UTC (rev 907)
+++ trunk/src/view/visio/addon/addon.cpp 2010-09-10 10:14:06 UTC (rev 908)
@@ -347,10 +347,16 @@
return pDocumentMonitor->OnMenuSelectAllMessages(vsoApp, SELECTION_ADD);
case CDocumentMonitor::MENU_MESSAGE_JUMP_LEFT:
TRACE("CStudioAddon::Run() jump message left");
- return pDocumentMonitor->OnMenuMessageJump(vsoApp, true);
+ return pDocumentMonitor->OnMenuMessageJump(vsoApp, true, false);
case CDocumentMonitor::MENU_MESSAGE_JUMP_RIGHT:
TRACE("CStudioAddon::Run() jump message right");
- return pDocumentMonitor->OnMenuMessageJump(vsoApp, false);
+ return pDocumentMonitor->OnMenuMessageJump(vsoApp, false, false);
+ case CDocumentMonitor::MENU_MESSAGE_JUMP_LEFT_COPY:
+ TRACE("CStudioAddon::Run() jump message left as copy");
+ return pDocumentMonitor->OnMenuMessageJump(vsoApp, true, true);
+ case CDocumentMonitor::MENU_MESSAGE_JUMP_RIGHT_COPY:
+ TRACE("CStudioAddon::Run() jump message right as copy");
+ return pDocumentMonitor->OnMenuMessageJump(vsoApp, false, true);
case CDocumentMonitor::MENU_ENABLE_MESSAGE_ENUMERATION:
TRACE("CStudioAddon::Run() enable message enumeration");
return pDocumentMonitor->OnMenuEnableMessageEnumeration(vsoApp);
@@ -786,7 +792,7 @@
CMessageSnapping::snap(shape, CShapeUtils::getShapeCell(shape, "PinX"), CShapeUtils::getShapeCell(shape, "PinY"), MSSNAP_PRESERVE_VERTICAL);
instances = CMessageSnapping::getConnectedInstances(shape);
}
- if(!CMessageJump::jump(shape, instances, (m_iJumpType == 1) ? MSJUMP_LEFT : MSJUMP_RIGHT))
+ if(!CMessageJump::jump(shape, instances, (m_iJumpType == 1) ? MSJUMP_LEFT : MSJUMP_RIGHT, false))
{
MscPoint msgVec;
CMessageSnapping::getMsgVector(shape, &msgVec);
Modified: trunk/src/view/visio/addon/dllmodule.rc
===================================================================
--- trunk/src/view/visio/addon/dllmodule.rc 2010-09-10 07:13:39 UTC (rev 907)
+++ trunk/src/view/visio/addon/dllmodule.rc 2010-09-10 10:14:06 UTC (rev 908)
@@ -361,6 +361,8 @@
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"
+IDI_ICON_JUMP_LEFT_COPY ICON "icon_jump_left_messages_copy.ico"
+IDI_ICON_JUMP_RIGHT_COPY ICON "icon_jump_right_messages_copy.ico"
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
Modified: trunk/src/view/visio/addon/document.cpp
===================================================================
--- trunk/src/view/visio/addon/document.cpp 2010-09-10 07:13:39 UTC (rev 907)
+++ trunk/src/view/visio/addon/document.cpp 2010-09-10 10:14:06 UTC (rev 908)
@@ -637,6 +637,24 @@
vslIconFile = vslFileName+_T(",11");
m_msgJumpRightToolbarItem->IconFileName(vslIconFile.c_str());
+ //Message Jumping Left Copy
+ m_msgJumpLeftCopyToolbarItem = m_toolbar->ToolbarItems->Add();
+ m_msgJumpLeftCopyToolbarItem->BeginGroup = true;
+ m_msgJumpLeftCopyToolbarItem->Caption = "Jump Left As Copy";
+ m_msgJumpLeftCopyToolbarItem->AddOnName = ADDON_NAME;
+ m_msgJumpLeftCopyToolbarItem->AddOnArgs = stringize() << L"/event=" << MENU_MESSAGE_JUMP_LEFT_COPY;
+ m_msgJumpLeftCopyToolbarItem->Visible = false;
+ vslIconFile = vslFileName+_T(",12");
+ m_msgJumpLeftCopyToolbarItem->IconFileName(vslIconFile.c_str());
+ //Message Jumping Right Copy
+ m_msgJumpRightCopyToolbarItem = m_toolbar->ToolbarItems->Add();
+ m_msgJumpRightCopyToolbarItem->Caption = "Jump Right As Copy";
+ m_msgJumpRightCopyToolbarItem->AddOnName = ADDON_NAME;
+ m_msgJumpRightCopyToolbarItem->AddOnArgs = stringize() << L"/event=" << MENU_MESSAGE_JUMP_RIGHT_COPY;
+ m_msgJumpRightCopyToolbarItem->Visible = false;
+ vslIconFile = vslFileName+_T(",13");
+ m_msgJumpRightCopyToolbarItem->IconFileName(vslIconFile.c_str());
+
Visio::IVToolbarItemPtr itemFindFlow = m_toolbar->ToolbarItems->Add();
itemFindFlow->BeginGroup = true;
itemFindFlow->Caption = "Find Flow";
@@ -702,6 +720,11 @@
m_selMessagesToolbarItem->Visible = !modifiersPressed;
m_selAddInstancesToolbarItem->Visible = modifiersPressed;
m_selAddMessagesToolbarItem->Visible = modifiersPressed;
+ //Message jumping
+ m_msgJumpLeftToolbarItem->Visible = !modifiersPressed;
+ m_msgJumpRightToolbarItem->Visible = !modifiersPressed;
+ m_msgJumpLeftCopyToolbarItem->Visible = modifiersPressed;
+ m_msgJumpRightCopyToolbarItem->Visible = modifiersPressed;
m_vsoDocument->CustomToolbars->UpdateUI();
}
@@ -1131,7 +1154,7 @@
return VAORC_SUCCESS;
}
-VAORC CDocumentMonitor::OnMenuMessageJump(Visio::IVApplicationPtr vsoApp, bool left)
+VAORC CDocumentMonitor::OnMenuMessageJump(Visio::IVApplicationPtr vsoApp, bool left, bool asCopy)
{
Visio::IVSelectionPtr selection = vsoApp->ActiveWindow->Selection;
@@ -1156,7 +1179,7 @@
instances = CMessageSnapping::getConnectedInstances(shape);
}
- CMessageJump::jump(shape, instances, (MsgJumpDirection)left);
+ CMessageJump::jump(shape, instances, (MsgJumpDirection)left, asCopy);
if(CMessageJump::getMsgNeedsResnap(shape))
CMessageSnapping::resnap(shape, vsoApp->ActivePage->Shapes, 0.0001);
Modified: trunk/src/view/visio/addon/document.h
===================================================================
--- trunk/src/view/visio/addon/document.h 2010-09-10 07:13:39 UTC (rev 907)
+++ trunk/src/view/visio/addon/document.h 2010-09-10 10:14:06 UTC (rev 908)
@@ -84,6 +84,8 @@
MENU_SELECT_ADD_ALL_MESSAGES,
MENU_MESSAGE_JUMP_LEFT,
MENU_MESSAGE_JUMP_RIGHT,
+ MENU_MESSAGE_JUMP_LEFT_COPY,
+ MENU_MESSAGE_JUMP_RIGHT_COPY,
MENU_ENABLE_MESSAGE_ENUMERATION,
MENU_DISABLE_MESSAGE_ENUMERATION,
MENU_GLOBAL_SETTINGS,
@@ -96,7 +98,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 OnMenuMessageJump(Visio::IVApplicationPtr vsoApp, bool left, bool asCopy);
VAORC OnMenuMessageSequence(Visio::IVApplicationPtr vsoApp, Visio::IVSelectionPtr oldSelection=NULL);
VAORC OnMenuFindFlow(Visio::IVApplicationPtr vsoApp);
VAORC OnMenuSimulationStart(Visio::IVApplicationPtr vsoApp);
@@ -239,6 +241,8 @@
//Message jumping
Visio::IVToolbarItemPtr m_msgJumpLeftToolbarItem;
Visio::IVToolbarItemPtr m_msgJumpRightToolbarItem;
+ Visio::IVToolbarItemPtr m_msgJumpLeftCopyToolbarItem;
+ Visio::IVToolbarItemPtr m_msgJumpRightCopyToolbarItem;
/**
* Selects all instances or all messages on the active page.
Added: trunk/src/view/visio/addon/icon_jump_left_messages_copy.ico
===================================================================
(Binary files differ)
Property changes on: trunk/src/view/visio/addon/icon_jump_left_messages_copy.ico
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/src/view/visio/addon/icon_jump_right_messages_copy.ico
===================================================================
(Binary files differ)
Property changes on: trunk/src/view/visio/addon/icon_jump_right_messages_copy.ico
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/src/view/visio/addon/messageJump.cpp
===================================================================
--- trunk/src/view/visio/addon/messageJump.cpp 2010-09-10 07:13:39 UTC (rev 907)
+++ trunk/src/view/visio/addon/messageJump.cpp 2010-09-10 10:14:06 UTC (rev 908)
@@ -31,7 +31,7 @@
return GetRegistry<int>(SNAP_REG_PATH, NULL, _T("EdgeTreatmentType"), 0);
}
-bool CMessageJump::jump(Visio::IVShapePtr msgShape, std::vector<Visio::IVShapePtr> connectedInstances, MsgJumpDirection direction)
+bool CMessageJump::jump(Visio::IVShapePtr msgShape, std::vector<Visio::IVShapePtr> connectedInstances, MsgJumpDirection direction, bool asCopy)
{
if(!msgShape || !connectedInstances.size())
return false;
@@ -66,6 +66,10 @@
return false;
}
+ //Duplicate message
+ if(asCopy)
+ msgShape = CShapeUtils::duplicateShape(msgShape, get_shape_type(msgShape));
+
//Erase information about re-snaping
if(origIntsLeft && origIntsRight && getMsgNeedsResnap(msgShape))
setMsgNeedsResnap(msgShape, 0);
@@ -184,8 +188,10 @@
Visio::IVShapePtr newShape = CShapeUtils::duplicateShape(msgShape, shapeType);
+ msgShape->Application->EventsEnabled = false;
msgShape->Delete();
msgShape = newShape;
+ msgShape->Application->EventsEnabled = true;
return true;
}
Modified: trunk/src/view/visio/addon/messageJump.h
===================================================================
--- trunk/src/view/visio/addon/messageJump.h 2010-09-10 07:13:39 UTC (rev 907)
+++ trunk/src/view/visio/addon/messageJump.h 2010-09-10 10:14:06 UTC (rev 908)
@@ -30,7 +30,7 @@
static bool isEnabled();
static int getEdgeInstanceTreatment();
- static bool jump(Visio::IVShapePtr msgShape, std::vector<Visio::IVShapePtr> connectedInstances, MsgJumpDirection direction);
+ static bool jump(Visio::IVShapePtr msgShape, std::vector<Visio::IVShapePtr> connectedInstances, MsgJumpDirection direction, bool asCopy);
/*
*
*/
Modified: trunk/src/view/visio/addon/resource.h
===================================================================
--- trunk/src/view/visio/addon/resource.h 2010-09-10 07:13:39 UTC (rev 907)
+++ trunk/src/view/visio/addon/resource.h 2010-09-10 10:14:06 UTC (rev 908)
@@ -54,6 +54,9 @@
#define IDC_IF_SPACING_SWITCH 232
#define IDD_PROTECTION_GLOBAL 232
#define IDC_IF_SPACING 233
+#define IDI_ICON_JUMP_LEFT_COPY 233
+#define IDI_ICON2 234
+#define IDI_ICON_JUMP_RIGHT_COPY 234
#define IDC_IF_MARGIN_LEFT 236
#define IDC_IF_MARGIN_RIGHT 237
#define IDC_IF_LBL4 239
@@ -127,7 +130,7 @@
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 233
+#define _APS_NEXT_RESOURCE_VALUE 235
#define _APS_NEXT_COMMAND_VALUE 32768
#define _APS_NEXT_CONTROL_VALUE 294
#define _APS_NEXT_SYMED_VALUE 105
Modified: trunk/src/view/visio/addon/scstudio.vcproj
===================================================================
--- trunk/src/view/visio/addon/scstudio.vcproj 2010-09-10 07:13:39 UTC (rev 907)
+++ trunk/src/view/visio/addon/scstudio.vcproj 2010-09-10 10:14:06 UTC (rev 908)
@@ -510,10 +510,18 @@
>
</File>
<File
+ RelativePath=".\icon_jump_left_messages_copy.ico"
+ >
+ </File>
+ <File
RelativePath=".\icon_jump_right_messages.ico"
>
</File>
<File
+ RelativePath=".\icon_jump_right_messages_copy.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-09-10 07:13:39 UTC (rev 907)
+++ trunk/src/view/visio/addon/shapeutils.cpp 2010-09-10 10:14:06 UTC (rev 908)
@@ -116,18 +116,36 @@
bool snapStatus = CMessageSnapping::isEnabled();
CMessageSnapping::setEnabled(false);
- //Change message to lost/found
+ //Create new shapge
CDrawingVisualizer visualizer(origShape->Application);
+ origShape->Application->EventsEnabled = false;
+ Visio::IVShapePtr newShape = page->Drop(visualizer.find_master(newShapeType),0,0);
origShape->Application->EventsEnabled = true;
- Visio::IVShapePtr newShape = page->Drop(visualizer.find_master(newShapeType),0,0);
- origShape->Application->EventsEnabled = false;
- //Copy message internal data (for message numbering)
+ //Copy shape internal data (for message numbering)
newShape->Text = origShape->Text;
newShape->Data1 = origShape->Data1;
newShape->Data2 = origShape->Data2;
newShape->Data3 = origShape->Data3;
+ try {
+ //Copy shape section
+ if(isMessageShape(newShape))
+ {
+ //Message flip
+ if(!newShape->GetCellExists(_T("Actions.flipDirection"),0))
+ {
+ newShape->AddNamedRow(visSectionAction,_T("flipDirection"),visTagDefault);
+ newShape->Cells["Actions.flipDirection.Action"]->FormulaU = _T("=RUNADDONWARGS(\"Sequence Chart Studio\",\"/event=105\")");
+ newShape->Cells["Actions.flipDirection.Menu"]->FormulaU = _T("=\"Flip message direction\"");
+ }
+ //Message numbering
+ if(!newShape->GetCellExists(_T("Actions.enumeration"),0) && _tcsicmp(newShape->Data1, _T("1")) == 0)
+ {
+ newShape->AddNamedRow(visSectionAction,_T("enumeration"),visTagDefault);
+ newShape->Cells["Actions.enumeration.Action"]->FormulaU = _T("=RUNADDONWARGS(\"Sequence Chart Studio\",\"/event=104\")");
+ newShape->Cells["Actions.enumeration.Menu"]->FormulaU = _T("=\"Select numbering group\"");
+ }
+ }
//Copy message position
- try {
for(int i=0; i<4; i++)
newShape->GetCellsSRC(visSectionObject, visRowXForm1D, i)->Formula =
origShape->GetCellsSRC(visSectionObject, visRowXForm1D, i)->ResultStr[visMillimeters];
@@ -136,7 +154,6 @@
MessageBox(GetActiveWindow(), _T("changeMsgType: exception occurred."), L"", MB_OK);
}
origShape->Application->EventsEnabled = true;
-
//Enable snapping back
CMessageSnapping::setEnabled(snapStatus);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mbe...@us...> - 2010-09-10 23:18:01
|
Revision: 912
http://scstudio.svn.sourceforge.net/scstudio/?rev=912&view=rev
Author: mbezdeka
Date: 2010-09-10 23:17:55 +0000 (Fri, 10 Sep 2010)
Log Message:
-----------
Message jump
- repaired wrong change of message type at edge treatment
Modified Paths:
--------------
trunk/src/view/visio/addon/addon.cpp
trunk/src/view/visio/addon/messageJump.cpp
trunk/src/view/visio/addon/messageJump.h
trunk/src/view/visio/addon/messageSnapping.cpp
Modified: trunk/src/view/visio/addon/addon.cpp
===================================================================
--- trunk/src/view/visio/addon/addon.cpp 2010-09-10 14:40:57 UTC (rev 911)
+++ trunk/src/view/visio/addon/addon.cpp 2010-09-10 23:17:55 UTC (rev 912)
@@ -730,7 +730,7 @@
case VK_UP:
case VK_DOWN:
for(int i=1; i<=selection->Count; i++)
- CMessageSnapping::resnap(selection->Item[i], shapes, 0.0001);
+ CMessageSnapping::resnap(selection->Item[i], shapes, 0.001);
break;
}
//Message snapping
Modified: trunk/src/view/visio/addon/messageJump.cpp
===================================================================
--- trunk/src/view/visio/addon/messageJump.cpp 2010-09-10 14:40:57 UTC (rev 911)
+++ trunk/src/view/visio/addon/messageJump.cpp 2010-09-10 23:17:55 UTC (rev 912)
@@ -66,14 +66,10 @@
return false;
}
- //Duplicate message
+ //Duplicate message (creates a new instance of shape)
if(asCopy)
msgShape = CShapeUtils::duplicateShape(msgShape, get_shape_type(msgShape));
- //Erase information about re-snaping
- if(origIntsLeft && origIntsRight && getMsgNeedsResnap(msgShape))
- setMsgNeedsResnap(msgShape, 0);
-
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);
@@ -97,11 +93,8 @@
if(!isEnabled()) // If Edge treatment isn't enabled we are done and Message won't be snapped to any new instance
return false;
- TShapeType shapeType = (TShapeType)(left ? ((direction == MSJUMP_LEFT) ? 2 : 3) : ((direction == MSJUMP_LEFT) ? 3 : 2));
+ TShapeType shapeType = closestLeft ? ST_BMSC_MESSAGE_LOST : ST_BMSC_MESSAGE_FOUND;
changeMsgType(msgShape, (getEdgeInstanceTreatment() == 1) ? shapeType : ST_BMSC_MESSAGE);
-
- if(getEdgeInstanceTreatment() == 0)
- setMsgNeedsResnap(msgShape, true);
}
//Glue messages to instances
Modified: trunk/src/view/visio/addon/messageJump.h
===================================================================
--- trunk/src/view/visio/addon/messageJump.h 2010-09-10 14:40:57 UTC (rev 911)
+++ trunk/src/view/visio/addon/messageJump.h 2010-09-10 23:17:55 UTC (rev 912)
@@ -32,20 +32,20 @@
static bool jump(Visio::IVShapePtr msgShape, std::vector<Visio::IVShapePtr> connectedInstances, MsgJumpDirection direction, bool asCopy);
/*
- *
+ * Finds closest instance from shape in horiyontal direction
*/
static Visio::IVShapePtr getClosestInstanceFromShape(const MscPoint& pointOnShape, Visio::IVShapePtr shape,
std::vector<Visio::IVShapePtr> instances, MsgJumpDirection direction);
/*
- *
+ * !Obsolete - will be deleted
*/
static bool getMsgNeedsResnap(Visio::IVShapePtr msgShape);
- /*
- *
+ /*
+ * !Obsolete - will be deleted
*/
static void setMsgNeedsResnap(Visio::IVShapePtr msgShape, bool bTrueIfNeeds);
/*
- *
+ * Changes shape's type
*/
static bool changeMsgType(Visio::IVShapePtr& msgShape, TShapeType shapeType);
};
Modified: trunk/src/view/visio/addon/messageSnapping.cpp
===================================================================
--- trunk/src/view/visio/addon/messageSnapping.cpp 2010-09-10 14:40:57 UTC (rev 911)
+++ trunk/src/view/visio/addon/messageSnapping.cpp 2010-09-10 23:17:55 UTC (rev 912)
@@ -249,7 +249,7 @@
MscPoint InstEnd(CShapeUtils::getShapeCell(instanceShape, "EndX", units), CShapeUtils::getShapeCell(instanceShape, "EndY", units));
//If instance include coregion, adjust glue point
- Visio::IVShapePtr coregion = getCoregionAt(instanceShape, yPos, units);
+ Visio::IVShapePtr coregion = getCoregionAt(instanceShape, yPos, units); //FIXME: coregion could not be sometimes recognized when it's oblique!!
if(coregion)
{
instanceShape = coregion;
@@ -257,10 +257,10 @@
double corEndY = CShapeUtils::getShapeCell(instanceShape, "EndY", units);
posX = (msgDirection == MSJUMP_RIGHT) ? (isBegin ? 1 : 0) : (isBegin ? 0 : 1);
double corSide = (InstBeg.get_y() < InstEnd.get_y()) ? !posX : posX;
- MscPoint* normalVec = CPageUtils::getNormalVec(InstBeg-InstEnd, CShapeUtils::getCoregionHeight(instanceShape, units) * (corSide ? 1 : -1));
+ boost::shared_ptr<MscPoint> normalVec =
+ boost::shared_ptr<MscPoint>(CPageUtils::getNormalVec(InstBeg-InstEnd, CShapeUtils::getCoregionHeight(instanceShape, units) * (corSide ? 1 : -1)));
InstBeg.set_y(corBegY + normalVec->get_y());
InstEnd.set_y(corEndY + normalVec->get_y());
- delete normalVec;
if(corBegY < corEndY)
posX = !posX;
@@ -500,17 +500,8 @@
Visio::IVShapePtr CMessageSnapping::getCoregionAt(Visio::IVShapePtr instShape, double yPos, VisUnitCodes units)
{
- if(get_shape_type(instShape) == ST_BMSC_COREGION)
- {
- double beginY = CShapeUtils::getShapeCell(instShape, "BeginY", units);
- double endY = CShapeUtils::getShapeCell(instShape, "EndY", units);
- if(beginY < endY)
- std::swap(beginY, endY);
- if( (yPos <= beginY) && (yPos >= endY) ) //check boundaries
- return instShape;
-
+ if(get_shape_type(instShape) != ST_BMSC_INSTANCE)
return NULL;
- }
Visio::IVConnectsPtr conns = instShape->FromConnects;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mbe...@us...> - 2010-09-13 13:19:41
|
Revision: 916
http://scstudio.svn.sourceforge.net/scstudio/?rev=916&view=rev
Author: mbezdeka
Date: 2010-09-13 13:19:34 +0000 (Mon, 13 Sep 2010)
Log Message:
-----------
- bugs fixed
Modified Paths:
--------------
trunk/src/view/visio/addon/addon.cpp
trunk/src/view/visio/addon/document.cpp
trunk/src/view/visio/addon/enums.h
trunk/src/view/visio/addon/messageJump.cpp
trunk/src/view/visio/addon/messageJump.h
trunk/src/view/visio/addon/messageSnapping.cpp
trunk/src/view/visio/addon/messageSnapping.h
trunk/src/view/visio/addon/numberingGlobalDlg.cpp
trunk/src/view/visio/addon/shapeutils.cpp
trunk/src/view/visio/addon/snapGlobalDlg.cpp
Modified: trunk/src/view/visio/addon/addon.cpp
===================================================================
--- trunk/src/view/visio/addon/addon.cpp 2010-09-13 12:24:46 UTC (rev 915)
+++ trunk/src/view/visio/addon/addon.cpp 2010-09-13 13:19:34 UTC (rev 916)
@@ -589,7 +589,6 @@
}
}
- //FIXME: Change to (vsoCell->Column == visXFormPinX)
if((_tcsicmp(vsoCell->Name,_T("PinX")) == 0 || _tcsicmp(vsoCell->Name,_T("PinY")) == 0))
{
if(isMessageShape(vsoCell->Shape))
@@ -685,9 +684,9 @@
{
Visio::IVShapePtr shape = selection->Item[1];
//If message isn't connected to both endpoints(not for LOST/FOUND), snap unplugged end to nearest instance
- MsgConnectedEndpoints conn = CShapeUtils::getConnectedEndpoints(shape);
- if(conn != MSCE_BOTH && conn != MSCE_NONE)
- CMessageSnapping::snapEndPointToClosestInstance(shape, (conn == MSCE_BEGIN) ? "EndX" : "BeginX", CMessageSnapping::getMsgDirection(shape));
+ /* MsgConnectedEndpoints conn = CShapeUtils::getConnectedEndpoints(shape);
+ if(conn != MSCE_BOTH && conn != MSCE_NONE && get_shape_type(shape) == ST_BMSC_MESSAGE)
+ CMessageSnapping::snapEndPointToClosestInstance(shape, (conn == MSCE_BEGIN) ? "EndX" : "BeginX", CMessageSnapping::getMsgDirection(shape));*/
//Get connected instances
instances = CMessageSnapping::getConnectedInstances(shape);
m_iJumpType = (keyCode == 0x25) ? 1 : 2;
@@ -803,8 +802,8 @@
}
if(CMessageJump::getMsgNeedsResnap(shape))
CMessageSnapping::resnap(shape, shapes, 0.0001);
- instances.clear();
m_iJumpType = 0;
+ instances.clear();
vsoApp->EndUndoScope(scopeId, true);
}
////////////////////////////////////////////////////
Modified: trunk/src/view/visio/addon/document.cpp
===================================================================
--- trunk/src/view/visio/addon/document.cpp 2010-09-13 12:24:46 UTC (rev 915)
+++ trunk/src/view/visio/addon/document.cpp 2010-09-13 13:19:34 UTC (rev 916)
@@ -1173,14 +1173,14 @@
CMessageSnapping::snap(shape, CShapeUtils::getShapeCell(shape, "PinX"), CShapeUtils::getShapeCell(shape, "PinY"), MSSNAP_PRESERVE_VERTICAL);
instances = CMessageSnapping::getConnectedInstances(shape);
}
- else if(conn != MSCE_BOTH) //If message isn't connected to both endpoints(not for LOST/FOUND), snap unplugged end to nearest instance
- {
- CMessageSnapping::snapEndPointToClosestInstance(shape, (conn == MSCE_BEGIN) ? "EndX" : "BeginX", CMessageSnapping::getMsgDirection(shape));
- instances = CMessageSnapping::getConnectedInstances(shape);
- }
-
- CMessageJump::jump(shape, instances, (MsgJumpDirection)left, asCopy);
-
+ //else if(conn != MSCE_BOTH) //If message isn't connected to both endpoints(not for LOST/FOUND), snap unplugged end to nearest instance
+ //{
+ // CMessageSnapping::snapEndPointToClosestInstance(shape, (conn == MSCE_BEGIN) ? "EndX" : "BeginX", CMessageSnapping::getMsgDirection(shape));
+ // instances = CMessageSnapping::getConnectedInstances(shape);
+ //}
+ if(!CMessageJump::jump(shape, instances, (MsgJumpDirection)left, asCopy) && CShapeUtils::getConnectedEndpoints(shape) == MSCE_NONE)
+ CMessageSnapping::resnap(shape, vsoApp->ActivePage->Shapes, 0.001);
+
if(CMessageJump::getMsgNeedsResnap(shape))
CMessageSnapping::resnap(shape, vsoApp->ActivePage->Shapes, 0.0001);
vsoApp->EndUndoScope(scopeId, true);
Modified: trunk/src/view/visio/addon/enums.h
===================================================================
--- trunk/src/view/visio/addon/enums.h 2010-09-13 12:24:46 UTC (rev 915)
+++ trunk/src/view/visio/addon/enums.h 2010-09-13 13:19:34 UTC (rev 916)
@@ -64,6 +64,7 @@
MSCE_BEGIN,
MSCE_END,
MSCE_BOTH,
+ MSCE_UNKNOWN,
};
// $Id$
Modified: trunk/src/view/visio/addon/messageJump.cpp
===================================================================
--- trunk/src/view/visio/addon/messageJump.cpp 2010-09-13 12:24:46 UTC (rev 915)
+++ trunk/src/view/visio/addon/messageJump.cpp 2010-09-13 13:19:34 UTC (rev 916)
@@ -31,7 +31,7 @@
return GetRegistry<int>(SNAP_REG_PATH, NULL, _T("EdgeTreatmentType"), 0);
}
-bool CMessageJump::jump(Visio::IVShapePtr msgShape, std::vector<Visio::IVShapePtr> connectedInstances, MsgJumpDirection direction, bool asCopy)
+bool CMessageJump::jump(Visio::IVShapePtr& msgShape, std::vector<Visio::IVShapePtr> connectedInstances, MsgJumpDirection direction, bool asCopy)
{
if(!msgShape || !connectedInstances.size())
return false;
@@ -66,10 +66,19 @@
return false;
}
+ //UNDONE: Copy message when jumping isn't implemented yet
//Duplicate message (creates a new instance of shape)
- if(asCopy)
+ /*if(asCopy)
+ {
+ msgShape->Application->EventsEnabled = false;
msgShape = CShapeUtils::duplicateShape(msgShape, get_shape_type(msgShape));
+ msgShape->Application->EventsEnabled = true;
+ */
+ //Erase information about re-snaping
+ if(origIntsLeft && origIntsRight && getMsgNeedsResnap(msgShape))
+ setMsgNeedsResnap(msgShape, 0);
+
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);
@@ -82,7 +91,6 @@
MscPoint msgVec;
CMessageSnapping::getMsgVector(msgShape, &msgVec);
-
if(left)
CShapeUtils::swapShape(closestLeft, closestRight);
@@ -95,20 +103,21 @@
TShapeType shapeType = closestLeft ? ST_BMSC_MESSAGE_LOST : ST_BMSC_MESSAGE_FOUND;
changeMsgType(msgShape, (getEdgeInstanceTreatment() == 1) ? shapeType : ST_BMSC_MESSAGE);
+ if(getEdgeInstanceTreatment() == 0)
+ setMsgNeedsResnap(msgShape, true);
}
//Glue messages to instances
CMessageSnapping::glueMsgToInstancesPair(msgShape, closestLeft, closestRight, PinY, MSSNAP_PRESERVE_VERTICAL, false);
+
//Preserve its length (If message is snapped only to one instance, preserve its length)
- if(closestLeft ^ closestRight)
- {
- if(closestLeft) //LEFT point is snapped, adjust right point
- CMessageSnapping::setMsgLength(msgShape, msgVec, vis1DBeginX);
- if(closestRight) //RIGHT point is snapped, adjust left point
- CMessageSnapping::setMsgLength(msgShape, msgVec, vis1DEndX);
- }
-
- if(!closestLeft && !closestRight)
+ MsgConnectedEndpoints conn = CShapeUtils::getConnectedEndpoints(msgShape);
+
+ if(conn == MSCE_BEGIN) //LEFT point is snapped, adjust right point
+ CMessageSnapping::setMsgLength(msgShape, msgVec, vis1DBeginX);
+ else if(conn == MSCE_END) //RIGHT point is snapped, adjust left point
+ CMessageSnapping::setMsgLength(msgShape, msgVec, vis1DEndX);
+ else if(conn == MSCE_NONE)
return false;
return true;
@@ -129,10 +138,12 @@
if(*it == shape)
continue;
- MscPoint* intPoint = CMessageSnapping::getIntersectionWithInstance(MscPoint(pointOnShape.get_x()-1, pointOnShape.get_y()),
- MscPoint(pointOnShape.get_x(), pointOnShape.get_y()), *it);
+ boost::shared_ptr<MscPoint> intPoint (CMessageSnapping::getIntersectionWithInstance(MscPoint(pointOnShape.get_x()-1, pointOnShape.get_y()),
+ MscPoint(pointOnShape.get_x(), pointOnShape.get_y()), *it));
if(!intPoint || !CMessageSnapping::isPointOnInstancesLine(*intPoint, *it))
- { delete intPoint; continue; }
+ continue;
+ if(CMessageSnapping::pointsEqual(*intPoint, pointOnShape, 0.001))
+ return *it;
double xVector = pointOnShape.get_x() - intPoint->get_x();
if((xVector * ((direction == MSJUMP_LEFT) ? 1 : -1)) < 0)
@@ -140,14 +151,12 @@
double distance = sqrt(pow(xVector,2) + pow((pointOnShape.get_y() - intPoint->get_y()),2));
- if(!closestInstance || distance < closestDistance)
+ if(!closestInstance || distance <= closestDistance)
{
closestDistance = distance;
closestInstance = *it;
}
- delete intPoint;
}
-
return closestInstance;
}
@@ -179,9 +188,8 @@
if(!msgShape || !isMessageShape(msgShape))
return false;
+ msgShape->Application->EventsEnabled = false;
Visio::IVShapePtr newShape = CShapeUtils::duplicateShape(msgShape, shapeType);
-
- msgShape->Application->EventsEnabled = false;
msgShape->Delete();
msgShape = newShape;
msgShape->Application->EventsEnabled = true;
Modified: trunk/src/view/visio/addon/messageJump.h
===================================================================
--- trunk/src/view/visio/addon/messageJump.h 2010-09-13 12:24:46 UTC (rev 915)
+++ trunk/src/view/visio/addon/messageJump.h 2010-09-13 13:19:34 UTC (rev 916)
@@ -30,18 +30,18 @@
static bool isEnabled();
static int getEdgeInstanceTreatment();
- static bool jump(Visio::IVShapePtr msgShape, std::vector<Visio::IVShapePtr> connectedInstances, MsgJumpDirection direction, bool asCopy);
+ static bool jump(Visio::IVShapePtr& msgShape, std::vector<Visio::IVShapePtr> connectedInstances, MsgJumpDirection direction, bool asCopy);
/*
* Finds closest instance from shape in horiyontal direction
*/
static Visio::IVShapePtr getClosestInstanceFromShape(const MscPoint& pointOnShape, Visio::IVShapePtr shape,
std::vector<Visio::IVShapePtr> instances, MsgJumpDirection direction);
/*
- * !Obsolete - will be deleted
+ *
*/
static bool getMsgNeedsResnap(Visio::IVShapePtr msgShape);
/*
- * !Obsolete - will be deleted
+ *
*/
static void setMsgNeedsResnap(Visio::IVShapePtr msgShape, bool bTrueIfNeeds);
/*
Modified: trunk/src/view/visio/addon/messageSnapping.cpp
===================================================================
--- trunk/src/view/visio/addon/messageSnapping.cpp 2010-09-13 12:24:46 UTC (rev 915)
+++ trunk/src/view/visio/addon/messageSnapping.cpp 2010-09-13 13:19:34 UTC (rev 916)
@@ -184,12 +184,12 @@
return std::pair<Visio::IVShapePtr, Visio::IVShapePtr>(leftClosestInstance,rightClosestInstance);
}
-void CMessageSnapping::glueMsgToInstancesPair(Visio::IVShapePtr msgShape, Visio::IVShapePtr leftInstance, Visio::IVShapePtr rightInstance,
+bool CMessageSnapping::glueMsgToInstancesPair(Visio::IVShapePtr msgShape, Visio::IVShapePtr leftInstance, Visio::IVShapePtr rightInstance,
double yPos, MsgSnapType snapType, bool dontGlueIfConnected)
{
//if there are no instances, return
if(!leftInstance && !rightInstance)
- return;
+ return false;
double yLeftPos, yRightPos;
@@ -213,36 +213,35 @@
}
MsgJumpDirection msgDir = getMsgDirection(msgShape);
- //Glue to left instance
- if(leftInstance)
- glueMsgToInstance(msgShape, leftInstance, "BeginX", yLeftPos, msgDir, dontGlueIfConnected);
- //Glue to right instance
- if(rightInstance)
- glueMsgToInstance(msgShape, rightInstance, "EndX", yRightPos, msgDir, dontGlueIfConnected);
+ //Glue to left instance or to right instance (at least one endpoint must be snapped to return true)
+ glueMsgToInstance(msgShape, leftInstance, "BeginX", yLeftPos, msgDir, dontGlueIfConnected);
+ glueMsgToInstance(msgShape, rightInstance, "EndX", yRightPos, msgDir, dontGlueIfConnected);
+
+ return true;
}
-void CMessageSnapping::glueMsgToInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape,
+bool CMessageSnapping::glueMsgToInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape,
const _bstr_t & msgCell, double yPos, VisUnitCodes units)
{
- glueMsgToInstance(msgShape, instanceShape, msgCell, yPos, getMsgDirection(msgShape), true, units);
+ return glueMsgToInstance(msgShape, instanceShape, msgCell, yPos, getMsgDirection(msgShape), true, units);
}
-void CMessageSnapping::glueMsgToInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape,
+bool CMessageSnapping::glueMsgToInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape,
const _bstr_t & msgCell, double yPos, MsgJumpDirection msgDirection, bool dontGlueIfConnected, VisUnitCodes units)
{
if(!msgShape || !instanceShape)
- return;
+ return false;
bool isBegin = _tcsicmp(msgCell,_T("BeginX")) == 0;
//NOTE: If user snap message by himself (using red rectangle), we are done
if(dontGlueIfConnected)
if(msgShape->GetCells(isBegin ? "BegTrigger" : "EndTrigger")->ResultInt[visNone][visTruncate] == 2)
- return;
+ return false;
//NOTE: Return if endpoint is found or lost message
TShapeType shapeType = get_shape_type(msgShape);
if( (shapeType == 2 && _tcsicmp(msgCell,_T("EndX")) == 0) || (shapeType == 3 && isBegin) )
- return;
+ return false;
bool posX = 0;
MscPoint InstBeg(CShapeUtils::getShapeCell(instanceShape, "BeginX", units), CShapeUtils::getShapeCell(instanceShape, "BeginY", units));
@@ -257,8 +256,7 @@
double corEndY = CShapeUtils::getShapeCell(instanceShape, "EndY", units);
posX = (msgDirection == MSJUMP_RIGHT) ? (isBegin ? 1 : 0) : (isBegin ? 0 : 1);
double corSide = (InstBeg.get_y() < InstEnd.get_y()) ? !posX : posX;
- boost::shared_ptr<MscPoint> normalVec =
- boost::shared_ptr<MscPoint>(CPageUtils::getNormalVec(InstBeg-InstEnd, CShapeUtils::getCoregionHeight(instanceShape, units) * (corSide ? 1 : -1)));
+ boost::shared_ptr<MscPoint> normalVec (CPageUtils::getNormalVec(InstBeg-InstEnd, CShapeUtils::getCoregionHeight(instanceShape, units) * (corSide ? 1 : -1)));
InstBeg.set_y(corBegY + normalVec->get_y());
InstEnd.set_y(corEndY + normalVec->get_y());
@@ -266,16 +264,42 @@
posX = !posX;
}
+ //NOTE: IMPLEMENT
+ //std::vector<Visio::IVShapePtr> coregs = CShapeUtils::getConnectedShapes(instanceShape, ST_BMSC_COREGION);
+ //for(u_int i = 0; i < coregs.size(); i++)
+ //{
+ // double corBegY = CShapeUtils::getShapeCell(coregs.at(i), "BeginY", units);
+ // double corEndY = CShapeUtils::getShapeCell(coregs.at(i), "EndY", units);
+ // posX = (msgDirection == MSJUMP_RIGHT) ? (isBegin ? 1 : 0) : (isBegin ? 0 : 1);
+ // double corSide = (InstBeg.get_y() < InstEnd.get_y()) ? !posX : posX;
+ // boost::shared_ptr<MscPoint> normalVec (CPageUtils::getNormalVec(InstBeg-InstEnd, CShapeUtils::getCoregionHeight(coregs.at(i), units) * (corSide ? 1 : -1)));
+ // corBegY += normalVec->get_y();
+ // corEndY += normalVec->get_y();
+
+ // if(yPos <= corBegY && yPos >= corEndY)
+ // {
+ // instanceShape = coregs.at(i);
+ // InstBeg.set_y(corBegY);
+ // InstEnd.set_y(corEndY);
+
+ // if(corBegY < corEndY)
+ // posX = !posX;
+ // break;
+ // }
+ // }
+
double sizeOfInstance = fabs(InstBeg.get_y() - InstEnd.get_y());
double msgOffset = fabs(InstBeg.get_y() - yPos);
//avoid division by zero - when instances are in horizontal position
if(sizeOfInstance == 0 || msgOffset > sizeOfInstance)
- return;
+ return false;
msgShape->Application->EventsEnabled = false;
msgShape->Cells[msgCell]->GlueToPos(instanceShape,msgOffset/sizeOfInstance,(double)posX);
msgShape->Application->EventsEnabled = true;
+
+ return true;
}
MscPoint* CMessageSnapping::getIntersectionWithInstance(const MscPoint& beginPoint,const MscPoint& endPoint, Visio::IVShapePtr instanceShape, VisUnitCodes units)
@@ -353,17 +377,24 @@
bool CMessageSnapping::getMsgVector(Visio::IVShapePtr msgShape, MscPoint* resultVector, VisUnitCodes units)
{
- if(!resultVector)
+ if(!msgShape || !resultVector || !isMessageShape(msgShape))
return false;
+ try {
resultVector->set_x(msgShape->Cells["EndX"]->Result[units] - msgShape->Cells["BeginX"]->Result[units]);
resultVector->set_y(msgShape->Cells["EndY"]->Result[units] - msgShape->Cells["BeginY"]->Result[units]);
+ } catch(_com_error err) {
+ MessageBox(GetActiveWindow(), L"getMsgVector:: exception occurred", L"", MB_ICONERROR);
+ }
return true;
}
void CMessageSnapping::snap(Visio::IVShapePtr msgShape, double posX, double posY, MsgSnapType snapType)
{
+ if(!msgShape)
+ return;
+
long scopeID = msgShape->Application->BeginUndoScope(_T("snap"));
#define _sp(x) CShapeUtils::getShapeCell(msgShape, x)
@@ -448,6 +479,8 @@
std::vector<Visio::IVShapePtr> CMessageSnapping::getConnectedInstances(Visio::IVShapePtr msgShape)
{
std::vector<Visio::IVShapePtr> instances;
+ if(!msgShape)
+ return instances;
Visio::IVConnectsPtr conns = msgShape->Connects;
for(int i=1; i<=conns->Count; i++)
@@ -463,7 +496,7 @@
bool CMessageSnapping::resnap(Visio::IVShapePtr msgShape, Visio::IVShapesPtr shapes, double precision)
{
- if(!msgShape || !shapes)
+ if(!msgShape || !shapes || !isMessageShape(msgShape))
return false;
long scopeId = msgShape->Application->BeginUndoScope(_T("Re-snap"));
@@ -563,7 +596,6 @@
msgShape->Application->EventsEnabled = false;
int sign = (fixedColumnX == vis1DBeginX) ? 1 : -1;
-
try {
msgShape->GetCellsSRC(visSectionObject,visRowXForm1D, fixedColumnX+(2*sign))->Formula =
stringize() << msgShape->GetCellsSRC(visSectionObject,
Modified: trunk/src/view/visio/addon/messageSnapping.h
===================================================================
--- trunk/src/view/visio/addon/messageSnapping.h 2010-09-13 12:24:46 UTC (rev 915)
+++ trunk/src/view/visio/addon/messageSnapping.h 2010-09-13 13:19:34 UTC (rev 916)
@@ -49,16 +49,16 @@
* designed only for horizontal messages (diagonal messages will be snapped according their PinX point and reformed to horizontal messages)
* @param onlyOnInstanceLine if true avoid connection message on instace's "rectangles" on the top and the bottom
*/
- static void glueMsgToInstancesPair(Visio::IVShapePtr msgShape, Visio::IVShapePtr leftInstance, Visio::IVShapePtr rightInstance,
+ static bool glueMsgToInstancesPair(Visio::IVShapePtr msgShape, Visio::IVShapePtr leftInstance, Visio::IVShapePtr rightInstance,
double yPos, MsgSnapType snapType, bool dontGlueIfConnected = true);
/*
* Glue given message to instance, but only to "line" of instance, rectangles at the bottom and top are ignored
* @param msgCell message cell which should be glued (e.g. BeginX, EndX)
* @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 bool glueMsgToInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape, const _bstr_t & msgCell, double yPos,
VisUnitCodes units = visPageUnits);
- static void glueMsgToInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape, const _bstr_t & msgCell, double yPos,
+ static bool glueMsgToInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape, const _bstr_t & msgCell, double yPos,
MsgJumpDirection msgDirection, bool dontGlueIfConnected = true, VisUnitCodes units = visPageUnits);
/*
*
Modified: trunk/src/view/visio/addon/numberingGlobalDlg.cpp
===================================================================
--- trunk/src/view/visio/addon/numberingGlobalDlg.cpp 2010-09-13 12:24:46 UTC (rev 915)
+++ trunk/src/view/visio/addon/numberingGlobalDlg.cpp 2010-09-13 13:19:34 UTC (rev 916)
@@ -137,24 +137,10 @@
void CNumberingGlobalDlg::OnHelp()
{
- //FIXME: Doesn't work in VIsio 2007
std::basic_string<TCHAR> path = GetVisioModulePath();
path += _T("\\help\\frontend\\message-numbering.html");
- ShellExecute(NULL, L"open", path.c_str() , NULL, NULL, SW_SHOWNORMAL);
- return;
-
-
- path += _T("scstudio.chm::/frontend/message-numbering.html");
-
- try
- {
- m_vsoApp->InvokeHelp(path.c_str(), HH_DISPLAY_TOPIC, 1);
- }
- catch (_com_error &err)
- {
- std::wstring text = stringize() << _T("Cannot display help due to internal error: ") << err.ErrorMessage();
- MessageBox(text.c_str());
- }
+ MessageBox(path.c_str());
+ ShellExecuteW(NULL, L"open", path.c_str() , NULL, NULL, SW_SHOWNORMAL);
}
void CNumberingGlobalDlg::EnableAllControls(bool bEnable)
Modified: trunk/src/view/visio/addon/shapeutils.cpp
===================================================================
--- trunk/src/view/visio/addon/shapeutils.cpp 2010-09-13 12:24:46 UTC (rev 915)
+++ trunk/src/view/visio/addon/shapeutils.cpp 2010-09-13 13:19:34 UTC (rev 916)
@@ -94,6 +94,9 @@
MsgConnectedEndpoints CShapeUtils::getConnectedEndpoints(Visio::IVShapePtr shape)
{
+ if(!shape || !isMessageShape(shape))
+ MSCE_UNKNOWN;
+
bool begSnapped = shape->GetCells("BegTrigger")->ResultInt[visNone][visTruncate] == 2;
bool endSnapped = shape->GetCells("EndTrigger")->ResultInt[visNone][visTruncate] == 2;
@@ -118,9 +121,7 @@
CMessageSnapping::setEnabled(false);
//Create new shapge
CDrawingVisualizer visualizer(origShape->Application);
- origShape->Application->EventsEnabled = false;
Visio::IVShapePtr newShape = page->Drop(visualizer.find_master(newShapeType),0,0);
- origShape->Application->EventsEnabled = true;
//Copy shape internal data (for message numbering)
newShape->Text = origShape->Text;
newShape->Data1 = origShape->Data1;
@@ -153,7 +154,6 @@
catch (_com_error err) {
MessageBox(GetActiveWindow(), _T("changeMsgType: exception occurred."), L"", MB_OK);
}
- origShape->Application->EventsEnabled = true;
//Enable snapping back
CMessageSnapping::setEnabled(snapStatus);
@@ -167,6 +167,7 @@
std::vector<Visio::IVShapePtr> CShapeUtils::getConnectedShapes(Visio::IVShapePtr shape, TShapeType connectedShapeType)
{
+ //FIXME: Each coregion is twice in vector
std::vector<Visio::IVShapePtr> shapes;
Visio::IVConnectsPtr connects = shape->FromConnects;
Modified: trunk/src/view/visio/addon/snapGlobalDlg.cpp
===================================================================
--- trunk/src/view/visio/addon/snapGlobalDlg.cpp 2010-09-13 12:24:46 UTC (rev 915)
+++ trunk/src/view/visio/addon/snapGlobalDlg.cpp 2010-09-13 13:19:34 UTC (rev 916)
@@ -57,19 +57,6 @@
std::basic_string<TCHAR> path = GetVisioModulePath();
path += _T("\\help\\frontend\\message-snapping.html");
ShellExecute(NULL, L"open", path.c_str() , NULL, NULL, SW_SHOWNORMAL);
-
- return;
- path += _T("scstudio.chm::/frontend/message-snapping.html");
-
- try
- {
- m_vsoApp->InvokeHelp(path.c_str(), HH_DISPLAY_TOPIC, 1);
- }
- catch (_com_error &err)
- {
- std::wstring text = stringize() << _T("Cannot display help due to internal error: ") << err.Description();
- MessageBox(text.c_str());
- }
}
int CSnapGlobalDlg::LoadRegistryData()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <got...@us...> - 2010-09-15 21:59:04
|
Revision: 933
http://scstudio.svn.sourceforge.net/scstudio/?rev=933&view=rev
Author: gotthardp
Date: 2010-09-15 21:58:58 +0000 (Wed, 15 Sep 2010)
Log Message:
-----------
Implemented membership PrerequisiteCheck in Microsoft Visio.
Modified Paths:
--------------
trunk/src/view/visio/addon/document.cpp
trunk/src/view/visio/addon/document.h
trunk/src/view/visio/addon/document_check.cpp
Modified: trunk/src/view/visio/addon/document.cpp
===================================================================
--- trunk/src/view/visio/addon/document.cpp 2010-09-15 20:31:55 UTC (rev 932)
+++ trunk/src/view/visio/addon/document.cpp 2010-09-15 21:58:58 UTC (rev 933)
@@ -955,6 +955,33 @@
return VAORC_SUCCESS;
}
+int CDocumentMonitor::check_membership_preconditions(MscPtr& msc)
+{
+ // initialize a list of user defined priorities
+ // items listed in the same order as m_checkers
+ RequiredCheckersList priorities;
+ priorities.insert(priorities.begin(), m_checkers.size(), PrerequisiteCheck::PP_DISREGARDED);
+
+ // examine membership preconditions
+ Searcher::PreconditionList preconditions = m_membership->get_preconditions(msc);
+ // walk through all installed checkers
+ for(Searcher::PreconditionList::const_iterator ppos = preconditions.begin();
+ ppos != preconditions.end(); ppos++)
+ {
+ CheckerPtrList::const_iterator checker = find_checker(ppos->property_name);
+ if(checker != m_checkers.end())
+ {
+ size_t icheck = checker - m_checkers.begin();
+
+ if(ppos->priority < priorities[icheck])
+ priorities[icheck] = ppos->priority;
+ }
+ }
+
+ // execute the check
+ return run_checks(msc, priorities);
+}
+
VAORC CDocumentMonitor::OnMenuFindFlow(Visio::IVApplicationPtr vsoApp)
{
CFindDlg dlg(vsoApp);
@@ -969,12 +996,32 @@
// obtain MSC to search for (needle)
MscPtr msc_needle = needle_extractor.extract_msc(dlg.m_page1);
+ // execute the check
+ int needle_status = check_membership_preconditions(msc_needle);
+ // check the status
+ if(needle_status < 0)
+ {
+ m_reportView->Print(RS_ERROR, stringize()
+ << "Search failed. Preconditions of " << msc_needle->get_label() << " violated.");
+ return VAORC_FAILURE;
+ }
+
MscPtr msc_haystack;
// obtain MSC to search in (haystack)
if (dlg.m_page2 != dlg.m_page1)
{
CDrawingExtractor haystack_extractor(m_reportView);
msc_haystack = haystack_extractor.extract_msc(dlg.m_page2);
+
+ // execute the check
+ int haystack_status = check_membership_preconditions(msc_haystack);
+ // check the status
+ if(haystack_status < 0)
+ {
+ m_reportView->Print(RS_ERROR, stringize()
+ << "Search failed. Preconditions of " << msc_haystack->get_label() << " violated.");
+ return VAORC_FAILURE;
+ }
}
else
msc_haystack = msc_needle;
@@ -982,7 +1029,19 @@
if (msc_haystack == NULL || msc_needle == NULL)
return VAORC_FAILURE;
- MscPtr result = m_membership->find(msc_haystack, msc_needle);
+ MscPtr result;
+
+ try
+ {
+ result = m_membership->find(msc_haystack, msc_needle);
+ }
+ catch(std::exception &exc)
+ {
+ m_reportView->Print(RS_ERROR, stringize()
+ << "Search failed. Internal error: " << exc.what());
+ return VAORC_FAILURE;
+ }
+
if (result != NULL)
{
m_reportView->Print(RS_NOTICE, stringize()
Modified: trunk/src/view/visio/addon/document.h
===================================================================
--- trunk/src/view/visio/addon/document.h 2010-09-15 20:31:55 UTC (rev 932)
+++ trunk/src/view/visio/addon/document.h 2010-09-15 21:58:58 UTC (rev 933)
@@ -211,6 +211,7 @@
size_t m_annotatedRows;
#endif // EXCEL_FOUND
+ int check_membership_preconditions(MscPtr& msc);
SearcherPtr m_membership;
SimulatorPtr m_simulator;
Modified: trunk/src/view/visio/addon/document_check.cpp
===================================================================
--- trunk/src/view/visio/addon/document_check.cpp 2010-09-15 20:31:55 UTC (rev 932)
+++ trunk/src/view/visio/addon/document_check.cpp 2010-09-15 21:58:58 UTC (rev 933)
@@ -149,8 +149,6 @@
int CDocumentMonitor::run_checks(MscPtr& msc, const RequiredCheckersList& priorities)
{
- Visio::IVPagePtr vsoPage = m_vsoApp->GetActivePage();
-
CheckExecutionStatusList status;
// initialize status for each checker
status.insert(status.begin(), m_checkers.size(), CheckExecutionStatus());
@@ -316,7 +314,7 @@
{
if(!all_preconditions)
{
- m_reportView->Print(RS_WARNING, stringize() << vsoPage->Name << ": "
+ m_reportView->Print(RS_WARNING, stringize() << msc->get_label() << ": "
<< msc_checker->get_property_name()
<< " skipped. Required prerequisites not satisfied.", msc_checker->get_help_filename());
@@ -338,9 +336,13 @@
}
catch(std::exception &exc)
{
- m_reportView->Print(RS_ERROR, stringize() << vsoPage->Name << ": "
+ m_reportView->Print(RS_ERROR, stringize() << msc->get_label() << ": "
<< msc_checker->get_property_name()
- << " internal error: " << exc.what());
+ << " skipped. Internal error: " << exc.what());
+
+ if(boost::get(max_priority_map, *cpos) == PrerequisiteCheck::PP_REQUIRED)
+ error_count++;
+ continue;
}
}
@@ -350,7 +352,7 @@
{
if(!all_preconditions)
{
- m_reportView->Print(RS_WARNING, stringize() << vsoPage->Name << ": "
+ m_reportView->Print(RS_WARNING, stringize() << msc->get_label() << ": "
<< msc_checker->get_property_name()
<< " skipped. Required prerequisites not satisfied.", msc_checker->get_help_filename());
@@ -372,9 +374,13 @@
}
catch(std::exception &exc)
{
- m_reportView->Print(RS_ERROR, stringize() << vsoPage->Name << ": "
+ m_reportView->Print(RS_ERROR, stringize() << msc->get_label() << ": "
<< msc_checker->get_property_name()
- << " internal error: " << exc.what());
+ << " skipped. Internal error: " << exc.what());
+
+ if(boost::get(max_priority_map, *cpos) == PrerequisiteCheck::PP_REQUIRED)
+ error_count++;
+ continue;
}
}
@@ -395,7 +401,7 @@
// - required dependencies of required tests
if(boost::get(max_priority_map, *cpos) == PrerequisiteCheck::PP_REQUIRED)
{
- m_reportView->Print(RS_ERROR, stringize() << vsoPage->Name << ": "
+ m_reportView->Print(RS_ERROR, stringize() << msc->get_label() << ": "
<< msc_checker->get_property_name()
<< " violated.", result, msc_checker->get_help_filename());
error_count++;
@@ -405,7 +411,7 @@
if(boost::get(max_priority_map, *cpos) == PrerequisiteCheck::PP_RECOMMENDED
&& output_level >= OL_WARNING)
{
- m_reportView->Print(RS_WARNING, stringize() << vsoPage->Name << ": "
+ m_reportView->Print(RS_WARNING, stringize() << msc->get_label() << ": "
<< msc_checker->get_property_name()
<< " violated.", result, msc_checker->get_help_filename());
}
@@ -421,7 +427,7 @@
if(boost::get(max_priority_map, *cpos) == PrerequisiteCheck::PP_REQUIRED
&& output_level >= OL_NOTIFY)
{
- m_reportView->Print(RS_NOTICE, stringize() << vsoPage->Name << ": "
+ m_reportView->Print(RS_NOTICE, stringize() << msc->get_label() << ": "
<< msc_checker->get_property_name()
<< " satisfied.", msc_checker->get_help_filename());
}
@@ -430,13 +436,13 @@
msc_checker->cleanup_attributes();
}
- if(executed_count > 0)
- if(error_count > 0)
- return -1; // failed
+ if(error_count > 0)
+ return -1; // failed
+ else
+ if(executed_count > 0)
+ return 1; // correct
else
- return 1; // correct
- else
- return 0; // nothing executed
+ return 0; // nothing executed
}
// $Id$
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mbe...@us...> - 2010-09-16 20:15:37
|
Revision: 947
http://scstudio.svn.sourceforge.net/scstudio/?rev=947&view=rev
Author: mbezdeka
Date: 2010-09-16 20:15:31 +0000 (Thu, 16 Sep 2010)
Log Message:
-----------
- bug fixed
- function comments repaired for doxy
Modified Paths:
--------------
trunk/src/view/visio/addon/enums.h
trunk/src/view/visio/addon/numberingGlobalDlg.cpp
trunk/src/view/visio/addon/shapeutils.cpp
trunk/src/view/visio/addon/shapeutils.h
Modified: trunk/src/view/visio/addon/enums.h
===================================================================
--- trunk/src/view/visio/addon/enums.h 2010-09-16 19:33:25 UTC (rev 946)
+++ trunk/src/view/visio/addon/enums.h 2010-09-16 20:15:31 UTC (rev 947)
@@ -58,6 +58,12 @@
MSJUMP_LEFT,
};
+enum MsgDirection
+{
+ MSG_RIGHT = 0,
+ MSG_LEFT,
+};
+
enum MsgConnectedEndpoints
{
MSCE_NONE = 0,
Modified: trunk/src/view/visio/addon/numberingGlobalDlg.cpp
===================================================================
--- trunk/src/view/visio/addon/numberingGlobalDlg.cpp 2010-09-16 19:33:25 UTC (rev 946)
+++ trunk/src/view/visio/addon/numberingGlobalDlg.cpp 2010-09-16 20:15:31 UTC (rev 947)
@@ -139,7 +139,6 @@
{
std::basic_string<TCHAR> path = GetVisioModulePath();
path += _T("\\help\\frontend\\message-numbering.html");
- MessageBox(path.c_str());
ShellExecuteW(NULL, L"open", path.c_str() , NULL, NULL, SW_SHOWNORMAL);
}
Modified: trunk/src/view/visio/addon/shapeutils.cpp
===================================================================
--- trunk/src/view/visio/addon/shapeutils.cpp 2010-09-16 19:33:25 UTC (rev 946)
+++ trunk/src/view/visio/addon/shapeutils.cpp 2010-09-16 20:15:31 UTC (rev 947)
@@ -167,7 +167,6 @@
std::vector<Visio::IVShapePtr> CShapeUtils::getConnectedShapes(Visio::IVShapePtr shape, TShapeType connectedShapeType)
{
- //FIXME: Each coregion is twice in vector
std::vector<Visio::IVShapePtr> shapes;
Visio::IVConnectsPtr connects = shape->FromConnects;
@@ -176,11 +175,20 @@
Visio::IVShapePtr connShape = connects->Item[i]->FromSheet;
if (get_shape_type(connShape) != connectedShapeType)
continue;
- shapes.push_back(connShape);
+ if(std::find(shapes.begin(), shapes.end(), connShape) == shapes.end())
+ shapes.push_back(connShape);
}
return shapes;
}
+MsgDirection CShapeUtils::getMsgDirection(Visio::IVShapePtr msgShape)
+{
+ double BeginX = CShapeUtils::getShapeCell(msgShape,"BeginX");
+ double EndX = CShapeUtils::getShapeCell(msgShape,"EndX");
+
+ return (BeginX < EndX) ? MSG_RIGHT : MSG_LEFT;
+}
+
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-09-16 19:33:25 UTC (rev 946)
+++ trunk/src/view/visio/addon/shapeutils.h 2010-09-16 20:15:31 UTC (rev 947)
@@ -60,12 +60,16 @@
static Visio::IVShapePtr duplicateShape(Visio::IVShapePtr shape, TShapeType newShapeType);
static double getCoregionHeight(Visio::IVShapePtr coregion, VisUnitCodes units = visPageUnits);
- /*
+ /**
* Get shapes connected to another shape
* @param shape shape the other shapes are connected to
* @param connectedShapeType filter for connected shapes (e.g. coregions, messages, etc.)
*/
static std::vector<Visio::IVShapePtr> getConnectedShapes(Visio::IVShapePtr shape, TShapeType connectedShapeType);
+ /**
+ * Returns the direction of given message
+ */
+ static MsgDirection getMsgDirection(Visio::IVShapePtr msgShape);
};
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mbe...@us...> - 2010-09-16 21:15:07
|
Revision: 949
http://scstudio.svn.sourceforge.net/scstudio/?rev=949&view=rev
Author: mbezdeka
Date: 2010-09-16 21:15:00 +0000 (Thu, 16 Sep 2010)
Log Message:
-----------
Message snapping
- repaired and improved snapping to oblique coregions
Modified Paths:
--------------
trunk/src/view/visio/addon/addon.cpp
trunk/src/view/visio/addon/document.cpp
trunk/src/view/visio/addon/enumerateUtils.h
trunk/src/view/visio/addon/messageJump.cpp
trunk/src/view/visio/addon/messageJump.h
trunk/src/view/visio/addon/messageSnapping.cpp
trunk/src/view/visio/addon/messageSnapping.h
trunk/src/view/visio/addon/pageutils.cpp
trunk/src/view/visio/addon/pageutils.h
Modified: trunk/src/view/visio/addon/addon.cpp
===================================================================
--- trunk/src/view/visio/addon/addon.cpp 2010-09-16 21:14:32 UTC (rev 948)
+++ trunk/src/view/visio/addon/addon.cpp 2010-09-16 21:15:00 UTC (rev 949)
@@ -686,7 +686,7 @@
//If message isn't connected to both endpoints(not for LOST/FOUND), snap unplugged end to nearest instance
/* MsgConnectedEndpoints conn = CShapeUtils::getConnectedEndpoints(shape);
if(conn != MSCE_BOTH && conn != MSCE_NONE && get_shape_type(shape) == ST_BMSC_MESSAGE)
- CMessageSnapping::snapEndPointToClosestInstance(shape, (conn == MSCE_BEGIN) ? "EndX" : "BeginX", CMessageSnapping::getMsgDirection(shape));*/
+ CMessageSnapping::snapEndPointToClosestInstance(shape, (conn == MSCE_BEGIN) ? "EndX" : "BeginX", getMsgDirection::getMsgDirection(shape));*/
//Get connected instances
instances = CMessageSnapping::getConnectedInstances(shape);
m_iJumpType = (keyCode == 0x25) ? 1 : 2;
@@ -824,7 +824,7 @@
}
else if(m_bBeginChanged ^ m_bEndChanged) //NOTE: Trigger when pulling endpoints
CMessageSnapping::snapEndPointToClosestInstance(msgShape, m_bBeginChanged ? "BeginX" : "EndX",
- CMessageSnapping::getMsgDirection(msgShape));
+ CShapeUtils::getMsgDirection(msgShape));
}
}
#undef _u
Modified: trunk/src/view/visio/addon/document.cpp
===================================================================
--- trunk/src/view/visio/addon/document.cpp 2010-09-16 21:14:32 UTC (rev 948)
+++ trunk/src/view/visio/addon/document.cpp 2010-09-16 21:15:00 UTC (rev 949)
@@ -1240,7 +1240,7 @@
}
//else if(conn != MSCE_BOTH) //If message isn't connected to both endpoints(not for LOST/FOUND), snap unplugged end to nearest instance
//{
- // CMessageSnapping::snapEndPointToClosestInstance(shape, (conn == MSCE_BEGIN) ? "EndX" : "BeginX", CMessageSnapping::getMsgDirection(shape));
+ // CMessageSnapping::snapEndPointToClosestInstance(shape, (conn == MSCE_BEGIN) ? "EndX" : "BeginX", CShapeUtils::getMsgDirection(shape));
// instances = CMessageSnapping::getConnectedInstances(shape);
//}
if(!CMessageJump::jump(shape, instances, (MsgJumpDirection)left, asCopy) && CShapeUtils::getConnectedEndpoints(shape) == MSCE_NONE)
Modified: trunk/src/view/visio/addon/enumerateUtils.h
===================================================================
--- trunk/src/view/visio/addon/enumerateUtils.h 2010-09-16 21:14:32 UTC (rev 948)
+++ trunk/src/view/visio/addon/enumerateUtils.h 2010-09-16 21:15:00 UTC (rev 949)
@@ -24,18 +24,18 @@
class CEnumerateUtils
{
public:
- /*
- * Add comment
+ /**
+ *
*/
static std::wstring int2Romans(int index);
- /*
+ /**
* Convers integer to char: a-z,aa-az,ba-bz,...,aaa-aaz,..etc.
* @param index integer to convert to char
* @param capitals if true, creates capitals Chars as: A-Z, AA-AZ
* @return string representing index
*/
static std::wstring int2Char(int index, bool capitals);
- /*
+ /**
* Compare function for drawNumbers, decides order of message shape according to their position
* @param p1 pointer to first message shape to compare
* @param p2 pointer to second message shape to compare
Modified: trunk/src/view/visio/addon/messageJump.cpp
===================================================================
--- trunk/src/view/visio/addon/messageJump.cpp 2010-09-16 21:14:32 UTC (rev 948)
+++ trunk/src/view/visio/addon/messageJump.cpp 2010-09-16 21:15:00 UTC (rev 949)
@@ -37,7 +37,7 @@
return false;
std::vector<Visio::IVShapePtr> instances = connectedInstances;
- bool left = (CMessageSnapping::getMsgDirection(msgShape) == MSJUMP_LEFT);
+ bool left = (CShapeUtils::getMsgDirection(msgShape) == MSG_LEFT);
Visio::IVShapePtr origIntsLeft = NULL;
Visio::IVShapePtr origIntsRight = NULL;
Modified: trunk/src/view/visio/addon/messageJump.h
===================================================================
--- trunk/src/view/visio/addon/messageJump.h 2010-09-16 21:14:32 UTC (rev 948)
+++ trunk/src/view/visio/addon/messageJump.h 2010-09-16 21:15:00 UTC (rev 949)
@@ -31,20 +31,20 @@
static int getEdgeInstanceTreatment();
static bool jump(Visio::IVShapePtr& msgShape, std::vector<Visio::IVShapePtr> connectedInstances, MsgJumpDirection direction, bool asCopy);
- /*
- * Finds closest instance from shape in horiyontal direction
+ /**
+ * Finds closest instance from shape in horizontal direction
*/
static Visio::IVShapePtr getClosestInstanceFromShape(const MscPoint& pointOnShape, Visio::IVShapePtr shape,
std::vector<Visio::IVShapePtr> instances, MsgJumpDirection direction);
- /*
+ /**
*
*/
static bool getMsgNeedsResnap(Visio::IVShapePtr msgShape);
- /*
+ /**
*
*/
static void setMsgNeedsResnap(Visio::IVShapePtr msgShape, bool bTrueIfNeeds);
- /*
+ /**
* Changes shape's type
*/
static bool changeMsgType(Visio::IVShapePtr& msgShape, TShapeType shapeType);
Modified: trunk/src/view/visio/addon/messageSnapping.cpp
===================================================================
--- trunk/src/view/visio/addon/messageSnapping.cpp 2010-09-16 21:14:32 UTC (rev 948)
+++ trunk/src/view/visio/addon/messageSnapping.cpp 2010-09-16 21:15:00 UTC (rev 949)
@@ -212,7 +212,7 @@
break;
}
- MsgJumpDirection msgDir = getMsgDirection(msgShape);
+ MsgDirection msgDir = CShapeUtils::getMsgDirection(msgShape);
//Glue to left instance or to right instance (at least one endpoint must be snapped to return true)
glueMsgToInstance(msgShape, leftInstance, "BeginX", yLeftPos, msgDir, dontGlueIfConnected);
glueMsgToInstance(msgShape, rightInstance, "EndX", yRightPos, msgDir, dontGlueIfConnected);
@@ -223,11 +223,11 @@
bool CMessageSnapping::glueMsgToInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape,
const _bstr_t & msgCell, double yPos, VisUnitCodes units)
{
- return glueMsgToInstance(msgShape, instanceShape, msgCell, yPos, getMsgDirection(msgShape), true, units);
+ return glueMsgToInstance(msgShape, instanceShape, msgCell, yPos, CShapeUtils::getMsgDirection(msgShape), true, units);
}
bool CMessageSnapping::glueMsgToInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape,
- const _bstr_t & msgCell, double yPos, MsgJumpDirection msgDirection, bool dontGlueIfConnected, VisUnitCodes units)
+ const _bstr_t & msgCell, double yPos, MsgDirection msgDirection, bool dontGlueIfConnected, VisUnitCodes units)
{
if(!msgShape || !instanceShape)
return false;
@@ -243,60 +243,24 @@
if( (shapeType == 2 && _tcsicmp(msgCell,_T("EndX")) == 0) || (shapeType == 3 && isBegin) )
return false;
- bool posX = 0;
- MscPoint InstBeg(CShapeUtils::getShapeCell(instanceShape, "BeginX", units), CShapeUtils::getShapeCell(instanceShape, "BeginY", units));
- MscPoint InstEnd(CShapeUtils::getShapeCell(instanceShape, "EndX", units), CShapeUtils::getShapeCell(instanceShape, "EndY", units));
+ bool xPos = 0;
+ MscPoint instBeg(CShapeUtils::getShapeCell(instanceShape, "BeginX", units), CShapeUtils::getShapeCell(instanceShape, "BeginY", units));
+ MscPoint instEnd(CShapeUtils::getShapeCell(instanceShape, "EndX", units), CShapeUtils::getShapeCell(instanceShape, "EndY", units));
//If instance include coregion, adjust glue point
- Visio::IVShapePtr coregion = getCoregionAt(instanceShape, yPos, units); //FIXME: coregion could not be sometimes recognized when it's oblique!!
- if(coregion)
- {
- instanceShape = coregion;
- double corBegY = CShapeUtils::getShapeCell(instanceShape, "BeginY", units);
- double corEndY = CShapeUtils::getShapeCell(instanceShape, "EndY", units);
- posX = (msgDirection == MSJUMP_RIGHT) ? (isBegin ? 1 : 0) : (isBegin ? 0 : 1);
- double corSide = (InstBeg.get_y() < InstEnd.get_y()) ? !posX : posX;
- boost::shared_ptr<MscPoint> normalVec (CPageUtils::getNormalVec(InstBeg-InstEnd, CShapeUtils::getCoregionHeight(instanceShape, units) * (corSide ? 1 : -1)));
- InstBeg.set_y(corBegY + normalVec->get_y());
- InstEnd.set_y(corEndY + normalVec->get_y());
+ MsgDirection posToCoregion = (msgDirection == MSG_RIGHT) ? (isBegin ? MSG_RIGHT : MSG_LEFT) : (isBegin ? MSG_LEFT : MSG_RIGHT);
+ if(!coregionTreatment(instanceShape, instBeg, instEnd, posToCoregion, xPos, yPos, units))
+ return false;
- if(corBegY < corEndY)
- posX = !posX;
- }
+ double sizeOfInstance = fabs(instBeg.get_y() - instEnd.get_y());
+ double msgOffset = fabs(instBeg.get_y() - yPos);
- //NOTE: IMPLEMENT
- //std::vector<Visio::IVShapePtr> coregs = CShapeUtils::getConnectedShapes(instanceShape, ST_BMSC_COREGION);
- //for(u_int i = 0; i < coregs.size(); i++)
- //{
- // double corBegY = CShapeUtils::getShapeCell(coregs.at(i), "BeginY", units);
- // double corEndY = CShapeUtils::getShapeCell(coregs.at(i), "EndY", units);
- // posX = (msgDirection == MSJUMP_RIGHT) ? (isBegin ? 1 : 0) : (isBegin ? 0 : 1);
- // double corSide = (InstBeg.get_y() < InstEnd.get_y()) ? !posX : posX;
- // boost::shared_ptr<MscPoint> normalVec (CPageUtils::getNormalVec(InstBeg-InstEnd, CShapeUtils::getCoregionHeight(coregs.at(i), units) * (corSide ? 1 : -1)));
- // corBegY += normalVec->get_y();
- // corEndY += normalVec->get_y();
-
- // if(yPos <= corBegY && yPos >= corEndY)
- // {
- // instanceShape = coregs.at(i);
- // InstBeg.set_y(corBegY);
- // InstEnd.set_y(corEndY);
-
- // if(corBegY < corEndY)
- // posX = !posX;
- // break;
- // }
- // }
-
- double sizeOfInstance = fabs(InstBeg.get_y() - InstEnd.get_y());
- double msgOffset = fabs(InstBeg.get_y() - yPos);
-
//avoid division by zero - when instances are in horizontal position
if(sizeOfInstance == 0 || msgOffset > sizeOfInstance)
return false;
msgShape->Application->EventsEnabled = false;
- msgShape->Cells[msgCell]->GlueToPos(instanceShape,msgOffset/sizeOfInstance,(double)posX);
+ msgShape->Cells[msgCell]->GlueToPos(instanceShape, msgOffset/sizeOfInstance, (double)xPos);
msgShape->Application->EventsEnabled = true;
return true;
@@ -433,7 +397,7 @@
closestInst = getClosestInstancePair(msgShape, posX, posY, instShapes, snapType);
//Step 5: If message is left-oriented switch pointers
- if(getMsgDirection(msgShape) == MSJUMP_LEFT)
+ if(CShapeUtils::getMsgDirection(msgShape) == MSG_LEFT)
CShapeUtils::swapShape(closestInst.first, closestInst.second);
//Step 6:Glue to them
@@ -555,16 +519,8 @@
return NULL;
}
-MsgJumpDirection CMessageSnapping::getMsgDirection(Visio::IVShapePtr msgShape)
+Visio::IVShapePtr CMessageSnapping::snapEndPointToClosestInstance(Visio::IVShapePtr msgShape, _bstr_t endPointX, MsgDirection direction)
{
- double BeginX = CShapeUtils::getShapeCell(msgShape,"BeginX");
- double EndX = CShapeUtils::getShapeCell(msgShape,"EndX");
-
- return (BeginX < EndX) ? MSJUMP_RIGHT : MSJUMP_LEFT;
-}
-
-Visio::IVShapePtr CMessageSnapping::snapEndPointToClosestInstance(Visio::IVShapePtr msgShape, _bstr_t endPointX, MsgJumpDirection direction)
-{
if(!msgShape)
return NULL;
@@ -577,7 +533,7 @@
CShapeUtils::getShapeCell(msgShape,isBegin ? "BeginY" : "EndY"));
MsgJumpDirection closestInstDir = isBegin ? MSJUMP_LEFT : MSJUMP_RIGHT;
- if(direction == MSJUMP_LEFT)
+ if(direction == MSG_LEFT)
closestInstDir = (MsgJumpDirection)!closestInstDir;
std::vector<Visio::IVShapePtr> inst = CMessageSnapping::getIntersectInstances(msgShape, endPoint.get_y(), MSSNAP_STRAIGHTEN);
@@ -639,17 +595,14 @@
delete point;
//STEP 2: Move coregion points at distance of coregion height
- MscPoint corNormalVec = corBeginPoint - corEndPoint;
- corNormalVec = MscPoint(corNormalVec.get_y(), -corNormalVec.get_x());
- double normalize = sqrt(pow(corNormalVec.get_x(), 2) + pow(corNormalVec.get_y(), 2));
- corNormalVec = MscPoint(corNormalVec.get_x() / normalize * offsetX, corNormalVec.get_y() / normalize * offsetX);
+ MscPoint corNormalVec = CPageUtils::getNormalVec(corBeginPoint - corEndPoint, offsetX);
//STEP 3: Compute intersection
- MscPoint _corBeginPoint = corBeginPoint + corNormalVec;
- MscPoint _corEndPoint = corEndPoint + corNormalVec;
-
+ corBeginPoint = corBeginPoint + corNormalVec;
+ corEndPoint = corEndPoint + corNormalVec;
+
MscPoint * resultPoint = NULL;
- if(!(resultPoint = CPageUtils::getIntersectionPoint(endPoint, beginPoint, _corEndPoint, _corBeginPoint)))
+ if(!(resultPoint = CPageUtils::getIntersectionPoint(endPoint, beginPoint, corEndPoint, corBeginPoint)))
return NULL;
//STEP 4: Check boundaries
if((point->get_y() < corBeginPoint.get_y()) && (point->get_y() > corEndPoint.get_y()))
@@ -658,4 +611,54 @@
delete resultPoint;
return NULL;
}
+
+bool CMessageSnapping::coregionTreatment(Visio::IVShapePtr& instanceShape, MscPoint& instBegin, MscPoint& instEnd,
+ MsgDirection posToCoregion, bool &xPos, const double &yPos, VisUnitCodes units)
+{
+ if(!instanceShape || get_shape_type(instanceShape) != ST_BMSC_INSTANCE)
+ return false;
+
+ //Get all coregions the instance contains
+ std::vector<Visio::IVShapePtr> coregs = CShapeUtils::getConnectedShapes(instanceShape, ST_BMSC_COREGION);
+ if(!coregs.size())
+ return true;
+
+ bool inDeadZone = false;
+ bool upside = false;
+ for(u_int i = 0; i < coregs.size(); i++)
+ {
+ MscPoint corBeg(CShapeUtils::getShapeCell(coregs.at(i), "BeginX", units), CShapeUtils::getShapeCell(coregs.at(i), "BeginY", units));
+ MscPoint corEnd(CShapeUtils::getShapeCell(coregs.at(i), "EndX", units), CShapeUtils::getShapeCell(coregs.at(i), "EndY", units));
+
+ int corSide = (posToCoregion == MSG_LEFT) ? -1 : 1;
+ double corHeight = CShapeUtils::getCoregionHeight(coregs.at(i), units) * corSide;
+
+ if(corBeg.get_y() < corEnd.get_y())
+ {
+ upside = true;
+ xPos = !xPos;
+ std::swap(corBeg, corEnd); //NOTE: Coregion is never upside down
+ }
+
+ MscPoint normalVec = CPageUtils::getNormalVec(corBeg-corEnd, corHeight);
+ MscPoint _corBeg = corBeg + normalVec;
+ MscPoint _corEnd = corEnd + normalVec;
+
+ if(yPos <= _corBeg.get_y() && yPos >= _corEnd.get_y())
+ {
+ instanceShape = coregs.at(i);
+ instBegin = upside ? _corEnd : _corBeg;
+ instEnd = upside? _corBeg : _corEnd;
+ if(corSide == 1) xPos = !xPos;
+ return true;
+ }
+
+ //Check the coregion dead zone (applies only to oblique coregions)
+ bool side = (posToCoregion == MSG_RIGHT);
+ if(corBeg.get_x() > corEnd.get_x()) side = !side; //NOTE: Coregion is titled to the right
+ if(side ? (yPos < _corEnd.get_y() && yPos > corEnd.get_y()) : (yPos < corBeg.get_y() && yPos > _corBeg.get_y()))
+ inDeadZone = true;
+ }
+ return !inDeadZone;
+}
// $Id$
\ No newline at end of file
Modified: trunk/src/view/visio/addon/messageSnapping.h
===================================================================
--- trunk/src/view/visio/addon/messageSnapping.h 2010-09-16 21:14:32 UTC (rev 948)
+++ trunk/src/view/visio/addon/messageSnapping.h 2010-09-16 21:15:00 UTC (rev 949)
@@ -23,6 +23,8 @@
#include "extract.h"
#include "pageutils.h"
+typedef boost::shared_ptr<MscPoint> MscPointPtr;
+
class CMessageSnapping
{
public:
@@ -33,17 +35,17 @@
static MsgSnapType getSnapType();
static void setSnapType(MsgSnapType snapType);
- /*
+ /**
* Get All instances that intersect current msg, 3 types of intersecting - STRAIGHTEN, PRESERVE VERTICAL, PREVERSE SLOPE
* returns vector of pointers to instances, if zero, there are no intersecting instances
*/
static std::vector<Visio::IVShapePtr> getIntersectInstances(Visio::IVShapePtr msgShape, double msgPosY, MsgSnapType snapType);
- /*
+ /**
* returns two closest instances for given message (first of the pair is instance on the left from the message, second is ono the right)
*/
static std::pair<Visio::IVShapePtr, Visio::IVShapePtr> getClosestInstancePair(Visio::IVShapePtr msgShape, double msgSnapPointX, double msgSnapPointY,
const std::vector<Visio::IVShapePtr>& instances, MsgSnapType snapType);
- /*
+ /**
* Glue given message on the given instances
* If leftInstance or rightInstance is NULL, message will be connected only to not null one
* designed only for horizontal messages (diagonal messages will be snapped according their PinX point and reformed to horizontal messages)
@@ -51,7 +53,7 @@
*/
static bool glueMsgToInstancesPair(Visio::IVShapePtr msgShape, Visio::IVShapePtr leftInstance, Visio::IVShapePtr rightInstance,
double yPos, MsgSnapType snapType, bool dontGlueIfConnected = true);
- /*
+ /**
* Glue given message to instance, but only to "line" of instance, rectangles at the bottom and top are ignored
* @param msgCell message cell which should be glued (e.g. BeginX, EndX)
* @param yPos vertical position where to glue message to instance (in page units - visPageUnits)
@@ -59,64 +61,71 @@
static bool glueMsgToInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape, const _bstr_t & msgCell, double yPos,
VisUnitCodes units = visPageUnits);
static bool glueMsgToInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape, const _bstr_t & msgCell, double yPos,
- MsgJumpDirection msgDirection, bool dontGlueIfConnected = true, VisUnitCodes units = visPageUnits);
- /*
+ MsgDirection msgDirection, bool dontGlueIfConnected = true, VisUnitCodes units = visPageUnits);
+ /**
*
*/
static MscPoint* getIntersectionWithInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape, VisUnitCodes units = visPageUnits);
static MscPoint* getIntersectionWithInstance(const MscPoint& beginPoint,const MscPoint& endPoint,
Visio::IVShapePtr instanceShape, VisUnitCodes units = visPageUnits);
- /*
+ /**
*
*/
static bool isPointOnInstancesLine(const MscPoint& point, Visio::IVShapePtr instShape, VisUnitCodes units = visPageUnits);
- /*
+ /**
* Get Directional vector of given message shape
*/
static bool getMsgVector(Visio::IVShapePtr msgShape, MscPoint* resultVector, VisUnitCodes units = visMillimeters);
- /*
+ /**
* automatically snaps current message to nearest instances
* @param msgShape a shape to snap
* @param posX MouseX position for closest instances computing
* @param posY MouseY position for closest instances computing
*/
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, Visio::IVShapesPtr shapes, double precision = 0.0000001);
- /*
+ /**
* Get all instances the given message is connected to
*/
static std::vector<Visio::IVShapePtr> getConnectedInstances(Visio::IVShapePtr msgShape);
- /*
+ /**
*
*/
static bool pointsEqual(const MscPoint& point1, const MscPoint& point2, double precision = 0.0000001);
- /*
+ /**
*
*/
static Visio::IVShapePtr getCoregionAt(Visio::IVShapePtr instShape, double yPos, VisUnitCodes units = visPageUnits);
- /*
- * Returns the direction of given message
- */
- static MsgJumpDirection getMsgDirection(Visio::IVShapePtr msgShape);
- /*
+ /**
*
*/
- static Visio::IVShapePtr snapEndPointToClosestInstance(Visio::IVShapePtr msgShape, _bstr_t endPointX, MsgJumpDirection direction);
- /*
+ static Visio::IVShapePtr snapEndPointToClosestInstance(Visio::IVShapePtr msgShape, _bstr_t endPointX, MsgDirection direction);
+ /**
* Set length of message given by direction and length of msgVector
* @param msgVector Vector must be in milimeters!!!
* @param fixedColumnX Fixed column (vis1DBeginX, vis1DEndX) stays fixed and other side of message will be prolonged
*/
static void setMsgLength(Visio::IVShapePtr msgShape, MscPoint msgVector, VisCellIndices fixedColumnX);
- /*
+ /**
*
*/
static MscPoint* getIntersectionWithCoregion( MscPoint beginPoint, MscPoint endPoint,
Visio::IVShapePtr coregionShape, VisUnitCodes units = visPageUnits);
+
+private:
+ /**
+ * Function used to determine, whether message should be connected to coregion at given yPos,
+ * because oblique coregions have some "dead zones", where message can't be glued
+ * @param instanceShape instance shape, which can contains coregion(s)
+ * @param xPos sets xPos on the coregion to snap to (zero (left side) or one (right side))
+ * @param yPos gets yPos where messsage should be snapped
+ */
+ static bool coregionTreatment(Visio::IVShapePtr& instanceShape, MscPoint& instBegin, MscPoint& instEnd,
+ MsgDirection posToCoregion, bool& xPos, const double& yPos, VisUnitCodes units = visPageUnits);
};
// $Id$
\ No newline at end of file
Modified: trunk/src/view/visio/addon/pageutils.cpp
===================================================================
--- trunk/src/view/visio/addon/pageutils.cpp 2010-09-16 21:14:32 UTC (rev 948)
+++ trunk/src/view/visio/addon/pageutils.cpp 2010-09-16 21:15:00 UTC (rev 949)
@@ -149,7 +149,7 @@
return new MscPoint(x,y);
}
-MscPoint* CPageUtils::getNormalVec(const MscPoint &origVector, double newVectorSize)
+MscPoint CPageUtils::getNormalVec(const MscPoint &origVector, double newVectorSize)
{
//Create normal vector
MscPoint normalVec(origVector.get_y(), -origVector.get_x());
@@ -157,7 +157,7 @@
double normalize = sqrt(pow(normalVec.get_x(), 2) + pow(normalVec.get_y(), 2));
normalVec = MscPoint(normalVec.get_x() / normalize * newVectorSize, normalVec.get_y() / normalize * newVectorSize);
- return new MscPoint(normalVec);
+ return MscPoint(normalVec);
}
// $Id$
Modified: trunk/src/view/visio/addon/pageutils.h
===================================================================
--- trunk/src/view/visio/addon/pageutils.h 2010-09-16 21:14:32 UTC (rev 948)
+++ trunk/src/view/visio/addon/pageutils.h 2010-09-16 21:15:00 UTC (rev 949)
@@ -69,9 +69,9 @@
* @param vsoPage the page which to get height of
* @param units units in which to retrieve the result; use VisUnitCodes constants or 0 for Visio's internal units;
* the default are units of the given page
- * @return height of the page in units \a units
+ * @return height of the page in units
*/
- static double GetPageHeight(Visio::IVPagePtr vsoPage, int units=visPageUnits);
+ static double GetPageHeight(Visio::IVPagePtr vsoPage, int units = visPageUnits);
static const LPCTSTR VisioUnitToString(short unitCode);
@@ -84,7 +84,6 @@
*/
static Visio::IVSelectionPtr FilterSelection(Visio::IVSelectionPtr selection, TShapeType shapeType);
-
/**
* Returns intersection point between two vectors represented by 4 points
* @param p1 endpoint of the first line
@@ -94,7 +93,7 @@
*/
static MscPoint* getIntersectionPoint(const MscPoint& p1, const MscPoint& p2, const MscPoint& p3, const MscPoint& p4);
- static MscPoint* getNormalVec(const MscPoint& origVector, double newVectorSize);
+ static MscPoint getNormalVec(const MscPoint& origVector, double newVectorSize);
};
// $Id$
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mbe...@us...> - 2010-09-16 21:53:09
|
Revision: 952
http://scstudio.svn.sourceforge.net/scstudio/?rev=952&view=rev
Author: mbezdeka
Date: 2010-09-16 21:53:03 +0000 (Thu, 16 Sep 2010)
Log Message:
-----------
- bug fixed
Modified Paths:
--------------
trunk/src/view/visio/addon/messageJump.cpp
trunk/src/view/visio/addon/messageSnapping.cpp
trunk/src/view/visio/addon/messageSnapping.h
Modified: trunk/src/view/visio/addon/messageJump.cpp
===================================================================
--- trunk/src/view/visio/addon/messageJump.cpp 2010-09-16 21:48:09 UTC (rev 951)
+++ trunk/src/view/visio/addon/messageJump.cpp 2010-09-16 21:53:03 UTC (rev 952)
@@ -103,22 +103,27 @@
TShapeType shapeType = closestLeft ? ST_BMSC_MESSAGE_LOST : ST_BMSC_MESSAGE_FOUND;
changeMsgType(msgShape, (getEdgeInstanceTreatment() == 1) ? shapeType : ST_BMSC_MESSAGE);
- if(getEdgeInstanceTreatment() == 0)
- setMsgNeedsResnap(msgShape, true);
}
//Glue messages to instances
- CMessageSnapping::glueMsgToInstancesPair(msgShape, closestLeft, closestRight, PinY, MSSNAP_PRESERVE_VERTICAL, false);
+ MsgConnectedEndpoints conn = CMessageSnapping::glueMsgToInstancesPair(msgShape, closestLeft, closestRight, PinY, MSSNAP_PRESERVE_VERTICAL, false);
//Preserve its length (If message is snapped only to one instance, preserve its length)
- MsgConnectedEndpoints conn = CShapeUtils::getConnectedEndpoints(msgShape);
-
- if(conn == MSCE_BEGIN) //LEFT point is snapped, adjust right point
- CMessageSnapping::setMsgLength(msgShape, msgVec, vis1DBeginX);
- else if(conn == MSCE_END) //RIGHT point is snapped, adjust left point
- CMessageSnapping::setMsgLength(msgShape, msgVec, vis1DEndX);
- else if(conn == MSCE_NONE)
+ switch(conn)
+ {
+ case MSCE_BEGIN: //LEFT point is snapped, adjust right point
+ case MSCE_END: //RIGHT point is snapped, adjust left point
+ if(origIntsLeft && origIntsRight)
+ changeMsgType(msgShape, get_shape_type(msgShape));
+ CMessageSnapping::setMsgLength(msgShape, msgVec, (conn == MSCE_BEGIN) ? vis1DBeginX : vis1DEndX);
+ if(origIntsLeft && origIntsRight)
+ CMessageSnapping::resnap(msgShape, msgShape->Application->ActivePage->Shapes, 0.0001);
+ if(getMsgNeedsResnap(msgShape) == 0)
+ setMsgNeedsResnap(msgShape, true);
+ break;
+ case MSCE_NONE:
return false;
+ }
return true;
}
Modified: trunk/src/view/visio/addon/messageSnapping.cpp
===================================================================
--- trunk/src/view/visio/addon/messageSnapping.cpp 2010-09-16 21:48:09 UTC (rev 951)
+++ trunk/src/view/visio/addon/messageSnapping.cpp 2010-09-16 21:53:03 UTC (rev 952)
@@ -184,12 +184,13 @@
return std::pair<Visio::IVShapePtr, Visio::IVShapePtr>(leftClosestInstance,rightClosestInstance);
}
-bool CMessageSnapping::glueMsgToInstancesPair(Visio::IVShapePtr msgShape, Visio::IVShapePtr leftInstance, Visio::IVShapePtr rightInstance,
+MsgConnectedEndpoints CMessageSnapping::glueMsgToInstancesPair(Visio::IVShapePtr msgShape, Visio::IVShapePtr leftInstance, Visio::IVShapePtr rightInstance,
double yPos, MsgSnapType snapType, bool dontGlueIfConnected)
{
+ int result = 0;
//if there are no instances, return
if(!leftInstance && !rightInstance)
- return false;
+ return (MsgConnectedEndpoints)result;
double yLeftPos, yRightPos;
@@ -214,10 +215,12 @@
MsgDirection msgDir = CShapeUtils::getMsgDirection(msgShape);
//Glue to left instance or to right instance (at least one endpoint must be snapped to return true)
- glueMsgToInstance(msgShape, leftInstance, "BeginX", yLeftPos, msgDir, dontGlueIfConnected);
- glueMsgToInstance(msgShape, rightInstance, "EndX", yRightPos, msgDir, dontGlueIfConnected);
+ if(glueMsgToInstance(msgShape, leftInstance, "BeginX", yLeftPos, msgDir, dontGlueIfConnected))
+ result++;
+ if(glueMsgToInstance(msgShape, rightInstance, "EndX", yRightPos, msgDir, dontGlueIfConnected))
+ result = (!result) ? 2 : 3;
- return true;
+ return (MsgConnectedEndpoints)result;
}
bool CMessageSnapping::glueMsgToInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape,
Modified: trunk/src/view/visio/addon/messageSnapping.h
===================================================================
--- trunk/src/view/visio/addon/messageSnapping.h 2010-09-16 21:48:09 UTC (rev 951)
+++ trunk/src/view/visio/addon/messageSnapping.h 2010-09-16 21:53:03 UTC (rev 952)
@@ -51,7 +51,7 @@
* designed only for horizontal messages (diagonal messages will be snapped according their PinX point and reformed to horizontal messages)
* @param onlyOnInstanceLine if true avoid connection message on instace's "rectangles" on the top and the bottom
*/
- static bool glueMsgToInstancesPair(Visio::IVShapePtr msgShape, Visio::IVShapePtr leftInstance, Visio::IVShapePtr rightInstance,
+ static MsgConnectedEndpoints glueMsgToInstancesPair(Visio::IVShapePtr msgShape, Visio::IVShapePtr leftInstance, Visio::IVShapePtr rightInstance,
double yPos, MsgSnapType snapType, bool dontGlueIfConnected = true);
/**
* Glue given message to instance, but only to "line" of instance, rectangles at the bottom and top are ignored
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <xp...@us...> - 2010-09-18 12:52:55
|
Revision: 971
http://scstudio.svn.sourceforge.net/scstudio/?rev=971&view=rev
Author: xpekarc
Date: 2010-09-18 12:52:48 +0000 (Sat, 18 Sep 2010)
Log Message:
-----------
adding dialogs for beautify settings
Modified Paths:
--------------
trunk/src/view/visio/addon/addon.cpp
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/resource.h
trunk/src/view/visio/addon/scstudio.vcproj
Added Paths:
-----------
trunk/src/view/visio/addon/beautifySettingsDlg.cpp
trunk/src/view/visio/addon/beautifySettingsDlg.h
trunk/src/view/visio/addon/distanceSettingDlg.cpp
trunk/src/view/visio/addon/distanceSettingDlg.h
trunk/src/view/visio/addon/distances_beautify.bmp
trunk/src/view/visio/addon/instanceSettingDlg.cpp
trunk/src/view/visio/addon/instanceSettingDlg.h
Modified: trunk/src/view/visio/addon/addon.cpp
===================================================================
--- trunk/src/view/visio/addon/addon.cpp 2010-09-18 12:50:39 UTC (rev 970)
+++ trunk/src/view/visio/addon/addon.cpp 2010-09-18 12:52:48 UTC (rev 971)
@@ -366,6 +366,9 @@
case CDocumentMonitor::MENU_GLOBAL_SETTINGS:
TRACE("CStudioAddon::Run() global settings");
return pDocumentMonitor->OnMenuGlobalSettings(vsoApp);
+ case CDocumentMonitor::MENU_BEAUTIFY_SETTINGS:
+ TRACE("CStudioAddon::Run() beautify settings");
+ return pDocumentMonitor->OnMenuBeautifySettings(vsoApp);
default:
TRACE("CStudioAddon::Run() unexpected event id=" << iEvent);
Added: trunk/src/view/visio/addon/beautifySettingsDlg.cpp
===================================================================
--- trunk/src/view/visio/addon/beautifySettingsDlg.cpp (rev 0)
+++ trunk/src/view/visio/addon/beautifySettingsDlg.cpp 2010-09-18 12:52:48 UTC (rev 971)
@@ -0,0 +1,54 @@
+/*
+ * 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 Zuzana Pekarcikova <z.p...@gm...>
+ *
+ * $Id: $
+ */
+
+#include "stdafx.h"
+#include "dllmodule.h"
+#include "beautifySettingsDlg.h"
+
+CBeautifySettingsDlg::CBeautifySettingsDlg(Visio::IVApplicationPtr vsoApp, ATL::_U_STRINGorID title,UINT uStartPage, HWND hWndParent):
+CPropertySheetImpl<CBeautifySettingsDlg>(title,uStartPage,hWndParent)
+{
+ m_bCentered = false;
+
+ //Disable APPLY button and CONTEXT HELP button
+ m_psh.dwFlags |= PSH_NOAPPLYNOW | PSH_NOCONTEXTHELP;
+
+ //Property pages contructors
+ page1 = boost::shared_ptr<CInstanceSettingDlg>(new CInstanceSettingDlg(vsoApp));
+ page2 = boost::shared_ptr<CDistanceSettingDlg>(new CDistanceSettingDlg(vsoApp));
+
+ //Adding pages
+ page1->SetTitle(_T("Instances")); AddPage(*page1);
+ page2->SetTitle(_T("Distances")); AddPage(*page2);
+}
+
+CBeautifySettingsDlg::~CBeautifySettingsDlg()
+{
+}
+
+void CBeautifySettingsDlg::OnShowWindow(BOOL bShowing, int nReason)
+{
+ if(bShowing && !m_bCentered)
+ {
+ m_bCentered = true;
+ CenterWindow(m_psh.hwndParent);
+ }
+}
+
+// $Id:
+
Added: trunk/src/view/visio/addon/beautifySettingsDlg.h
===================================================================
--- trunk/src/view/visio/addon/beautifySettingsDlg.h (rev 0)
+++ trunk/src/view/visio/addon/beautifySettingsDlg.h 2010-09-18 12:52:48 UTC (rev 971)
@@ -0,0 +1,55 @@
+/*
+ * 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 Zuzana Pekarcikova <z.p...@gm...>
+ *
+ * $Id: $
+ */
+
+#pragma once
+
+#include <atldlgs.h>
+#include <atlctrls.h>
+#include <atlddx.h>
+
+//dialogs for tabs
+#include "instanceSettingDlg.h"
+#include "distanceSettingDlg.h"
+
+class CBeautifySettingsDlg : public CPropertySheetImpl<CBeautifySettingsDlg>
+{
+public:
+ CBeautifySettingsDlg(Visio::IVApplicationPtr vsoApp, ATL::_U_STRINGorID title = (LPCTSTR) NULL,
+ UINT uStartPage = 0, HWND hWndParent = NULL);
+
+ ~CBeautifySettingsDlg();
+
+ BEGIN_MSG_MAP(CBeautifySettingsDlg)
+ MSG_WM_SHOWWINDOW(OnShowWindow)
+ CHAIN_MSG_MAP(CPropertySheetImpl<CBeautifySettingsDlg>)
+ END_MSG_MAP()
+
+ //Message handlers
+ void OnShowWindow(BOOL bShowing, int nReason);
+
+protected:
+ bool m_bCentered;
+
+ //Pages of property sheet
+ boost::shared_ptr<CInstanceSettingDlg> page1;
+ boost::shared_ptr<CDistanceSettingDlg> page2;
+
+ Visio::IVApplicationPtr m_vsoApp;
+};
+
+// $Id:
\ No newline at end of file
Added: trunk/src/view/visio/addon/distanceSettingDlg.cpp
===================================================================
--- trunk/src/view/visio/addon/distanceSettingDlg.cpp (rev 0)
+++ trunk/src/view/visio/addon/distanceSettingDlg.cpp 2010-09-18 12:52:48 UTC (rev 971)
@@ -0,0 +1,72 @@
+/*
+ * 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 Zuzana Pekarcikova <z.p...@gm...>
+ *
+ * $Id: $
+ */
+
+#include "stdafx.h"
+#include "dllmodule.h"
+#include "distanceSettingDlg.h"
+#include "errors.h"
+
+#include <htmlhelp.h>
+
+BOOL CDistanceSettingDlg::OnInitDialog(HWND hWndFocus, LPARAM lParam)
+{
+ CenterWindow(GetParent());
+
+ LoadRegistryData();
+ //Move values in variables into controls
+ DoDataExchange(FALSE);
+
+ return TRUE;
+}
+
+void CDistanceSettingDlg::OnHelp()
+{
+}
+
+int CDistanceSettingDlg::OnApply()
+{
+ //Move values in controls to variables
+ if(!DoDataExchange(TRUE))
+ return PSNRET_INVALID;
+
+ SaveRegistryData();
+
+ return 0;
+}
+
+int CDistanceSettingDlg::LoadRegistryData()
+{
+ m_bottom_distance_value = GetRegistry<float>(GetRegistryFolder(), NULL, _T("MinInstanceBottomDistance"), 5.0);
+ m_head_distance_value = GetRegistry<float>(GetRegistryFolder(), NULL, _T("InstanceHeadDistance"), 5.0);
+ m_successor_value = GetRegistry<float>(GetRegistryFolder(), NULL, _T("SuccessorDistance"), 5.0);
+ m_uncompeleted_msg_value = GetRegistry<float>(GetRegistryFolder(), NULL, _T("IncompleteMessageLength"), 20.0);
+ m_send_receive_value = GetRegistry<float>(GetRegistryFolder(), NULL, _T("SendReceiveDistance"), 0.0);
+
+ return 0;
+}
+
+int CDistanceSettingDlg::SaveRegistryData()
+{
+ SetRegistry<>(HKEY_CURRENT_USER, GetRegistryFolder(), _T("MinInstanceBottomDistance"), (float)m_bottom_distance_value);
+ SetRegistry<>(HKEY_CURRENT_USER, GetRegistryFolder(), _T("InstanceHeadDistance"), (float)m_head_distance_value);
+ SetRegistry<>(HKEY_CURRENT_USER, GetRegistryFolder(), _T("SuccessorDistance"), (float)m_successor_value);
+ SetRegistry<>(HKEY_CURRENT_USER, GetRegistryFolder(), _T("IncompleteMessageLength"), (float)m_uncompeleted_msg_value);
+ SetRegistry<>(HKEY_CURRENT_USER, GetRegistryFolder(), _T("SendReceiveDistance"), (float)m_send_receive_value);
+
+ return 0;
+}
Added: trunk/src/view/visio/addon/distanceSettingDlg.h
===================================================================
--- trunk/src/view/visio/addon/distanceSettingDlg.h (rev 0)
+++ trunk/src/view/visio/addon/distanceSettingDlg.h 2010-09-18 12:52:48 UTC (rev 971)
@@ -0,0 +1,79 @@
+/*
+ * 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 Zuzana Pekarcikova <z.p...@gm...>
+ *
+ * $Id: $
+ */
+
+#pragma once
+
+#include <atldlgs.h>
+#include <atlddx.h>
+#include <atlctrls.h>
+#include <atlcrack.h>
+#include <atlmisc.h>
+
+//#include "data/msc.h"
+
+#include <boost/shared_ptr.hpp>
+
+class CDistanceSettingDlg: public CPropertyPageImpl<CDistanceSettingDlg>,
+ public CWinDataExchange<CDistanceSettingDlg>
+{
+public:
+ enum { IDD = IDD_DISTANCES_BEAUTIFY };
+
+ float m_bottom_distance_value;
+ float m_head_distance_value;
+ float m_successor_value;
+ float m_uncompeleted_msg_value;
+ float m_send_receive_value;
+
+ CDistanceSettingDlg(Visio::IVApplicationPtr vsoApp):m_vsoApp(vsoApp)
+ { //set dialog properties
+ m_psp.dwFlags |= PSP_HASHELP;
+ };
+ //Registry folder
+ const wchar_t* GetRegistryFolder() { return SCSTUDIO_REGISTRY_ROOT _T("\\Beautify"); }
+
+ //Message handlers
+ BOOL OnInitDialog(HWND hWndFocus, LPARAM lParam);
+
+ //Property page notification handlers (override method)
+ void OnHelp();
+ int OnApply();
+
+protected:
+ Visio::IVApplicationPtr m_vsoApp;
+
+ BEGIN_DDX_MAP(CDistanceSettingDlg)
+ DDX_FLOAT(IDC_BOTTOM_DISTANCE_VALUE, m_bottom_distance_value)
+ DDX_FLOAT(IDC_HEAD_DISTANCE_VALUE, m_head_distance_value)
+ DDX_FLOAT(IDC_SUCCESSOR_VALUE, m_successor_value)
+ DDX_FLOAT(IDC_UNCOMPLETED_MSG_VALUE, m_uncompeleted_msg_value)
+ DDX_FLOAT(IDC_SEND_RECEIVE_VALUE, m_send_receive_value)
+
+ END_DDX_MAP()
+
+ BEGIN_MSG_MAP(CDistanceSettingDlg)
+ MSG_WM_INITDIALOG(OnInitDialog)
+ CHAIN_MSG_MAP(CPropertyPageImpl<CDistanceSettingDlg>)
+ END_MSG_MAP()
+
+ int LoadRegistryData();
+ int SaveRegistryData();
+};
+
+
+// $Id: $
\ No newline at end of file
Added: trunk/src/view/visio/addon/distances_beautify.bmp
===================================================================
(Binary files differ)
Property changes on: trunk/src/view/visio/addon/distances_beautify.bmp
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/src/view/visio/addon/dllmodule.rc
===================================================================
--- trunk/src/view/visio/addon/dllmodule.rc 2010-09-18 12:50:39 UTC (rev 970)
+++ trunk/src/view/visio/addon/dllmodule.rc 2010-09-18 12:52:48 UTC (rev 971)
@@ -255,7 +255,56 @@
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,7,118,10
END
+IDD_INSTANCES_BEAUTIFY DIALOGEX 0, 0, 336, 194
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Instances"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ GROUPBOX "Length",IDC_LENGHT,7,7,162,87
+ CONTROL "minimal concerning events and coregions",IDC_MIN_LENGTH_RDO,
+ "Button",BS_AUTORADIOBUTTON | WS_GROUP,22,23,146,10
+ CONTROL "do not change the lenght",IDC_ORIGINAL_LENGTH_RDO,
+ "Button",BS_AUTORADIOBUTTON,22,40,97,10
+ CONTROL "constant",IDC_CONST_LENGTH_RDO,"Button",BS_AUTORADIOBUTTON,22,57,44,10
+ EDITTEXT IDC_CONSTANT_VALUE,89,53,40,14,ES_AUTOHSCROLL
+ CONTROL "align bottom",IDC_ALIGN_BOTTOM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,74,55,10
+ GROUPBOX "Spacing",IDC_STATIC,7,101,162,86
+ GROUPBOX "Width of Head and Foot",IDC_STATIC,176,7,153,87
+ CONTROL "minimal concerning all heads/foots",IDC_MIN_HEAD_RDO,
+ "Button",BS_AUTORADIOBUTTON | WS_GROUP,191,23,125,10
+ CONTROL "maximal concerning all heads/foots",IDC_MAX_HEAD_RDO,
+ "Button",BS_AUTORADIOBUTTON,191,40,127,10
+ CONTROL "do not change the width",IDC_ORIGINAL_HEAD_RDO,"Button",BS_AUTORADIOBUTTON,191,57,94,10
+ CONTROL "constant",IDC_CONST_HEAD_RDO,"Button",BS_AUTORADIOBUTTON,191,74,44,10
+ EDITTEXT IDC_CONST_HEAD_VALUE,257,70,40,14,ES_AUTOHSCROLL
+ CONTROL "allow permutation",IDC_ALLOW_PERMUTATION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,115,73,10
+ CONTROL "do not change the spacing",IDC_ORIGINAL_SPACING_RDO,
+ "Button",BS_AUTORADIOBUTTON,22,132,101,10
+ CONTROL "spacing",IDC_CONST_SPACING_RDO,"Button",BS_AUTORADIOBUTTON,22,149,40,10
+ CONTROL "total width",IDC_TOTAL_WIDTH_RDO,"Button",BS_AUTORADIOBUTTON,22,166,50,10
+ EDITTEXT IDC_CONST_SPACING_VALUE,89,145,40,14,ES_AUTOHSCROLL
+ EDITTEXT IDC_TOTAL_WIDTH_VALUE,89,162,40,14,ES_AUTOHSCROLL
+ LTEXT "mm",IDC_STATIC,134,59,12,8
+ LTEXT "mm",IDC_STATIC,134,151,12,8
+ LTEXT "mm",IDC_STATIC,134,168,12,8
+ LTEXT "mm",IDC_STATIC,303,76,12,8
+END
+IDD_DISTANCES_BEAUTIFY DIALOGEX 0, 0, 316, 186
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Distances"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ CONTROL 237,IDC_STATIC,"Static",SS_BITMAP,49,26,260,153
+ EDITTEXT IDC_UNCOMPLETED_MSG_VALUE,261,18,40,14,ES_AUTOHSCROLL
+ EDITTEXT IDC_SEND_RECEIVE_VALUE,261,123,40,14,ES_AUTOHSCROLL
+ EDITTEXT IDC_BOTTOM_DISTANCE_VALUE,261,151,40,14,ES_AUTOHSCROLL
+ EDITTEXT IDC_HEAD_DISTANCE_VALUE,117,48,40,14,ES_AUTOHSCROLL
+ EDITTEXT IDC_SUCCESSOR_VALUE,6,94,40,14,ES_AUTOHSCROLL
+ LTEXT "Distances in millimetres.",IDC_STATIC,12,10,76,8
+END
+
+
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
@@ -338,6 +387,35 @@
TOPMARGIN, 7
BOTTOMMARGIN, 179
END
+
+ IDD_INSTANCES_BEAUTIFY, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 329
+ VERTGUIDE, 22
+ VERTGUIDE, 89
+ VERTGUIDE, 134
+ VERTGUIDE, 191
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 187
+ HORZGUIDE, 33
+ HORZGUIDE, 50
+ HORZGUIDE, 67
+ HORZGUIDE, 84
+ HORZGUIDE, 94
+ HORZGUIDE, 125
+ HORZGUIDE, 142
+ HORZGUIDE, 159
+ HORZGUIDE, 176
+ END
+
+ IDD_DISTANCES_BEAUTIFY, DIALOG
+ BEGIN
+ RIGHTMARGIN, 309
+ VERTGUIDE, 261
+ TOPMARGIN, 2
+ BOTTOMMARGIN, 179
+ END
END
#endif // APSTUDIO_INVOKED
@@ -454,6 +532,13 @@
/////////////////////////////////////////////////////////////////////////////
//
+// Bitmap
+//
+
+IDB_DISTANCES_BEAUTIFY BITMAP "distances_beautify.bmp"
+
+/////////////////////////////////////////////////////////////////////////////
+//
// String Table
//
Modified: trunk/src/view/visio/addon/document.cpp
===================================================================
--- trunk/src/view/visio/addon/document.cpp 2010-09-18 12:50:39 UTC (rev 970)
+++ trunk/src/view/visio/addon/document.cpp 2010-09-18 12:52:48 UTC (rev 971)
@@ -29,6 +29,7 @@
#include "messagesequencedlg.h"
#include "enumerationDlg.h"
#include "GlobalSettingsDlg.h"
+#include "beautifySettingsDlg.h"
#include "messageSnapping.h"
#include "messageJump.h"
@@ -527,6 +528,12 @@
globalSettings->BeginGroup = true;
globalSettings->AddOnArgs = stringize() << L"/event=" << MENU_GLOBAL_SETTINGS;
+ Visio::IVMenuItemPtr beautifySettings = itemDrawing->MenuItems->Add();
+ beautifySettings->Caption = "&Beautify settings...";
+ beautifySettings->AddOnName = ADDON_NAME;
+ beautifySettings->BeginGroup = true;
+ beautifySettings->AddOnArgs = stringize() << L"/event=" << MENU_BEAUTIFY_SETTINGS;
+
// step 2: create accelerators
// note: the accelerators must be created in this custom menu set
// note: the accelerators are bound with menu items via CmdNum property
@@ -1902,6 +1909,14 @@
return VAORC_SUCCESS;
}
+VAORC CDocumentMonitor::OnMenuBeautifySettings(Visio::IVApplicationPtr vsoApp)
+{
+ CBeautifySettingsDlg sheet(vsoApp, _T("Beautify Settings"));
+ sheet.DoModal();
+
+ return VAORC_SUCCESS;
+}
+
void CDocumentMonitor::ShowReportView()
{
if(m_reportVisible)
Modified: trunk/src/view/visio/addon/document.h
===================================================================
--- trunk/src/view/visio/addon/document.h 2010-09-18 12:50:39 UTC (rev 970)
+++ trunk/src/view/visio/addon/document.h 2010-09-18 12:52:48 UTC (rev 971)
@@ -89,6 +89,7 @@
MENU_ENABLE_MESSAGE_ENUMERATION,
MENU_DISABLE_MESSAGE_ENUMERATION,
MENU_GLOBAL_SETTINGS,
+ MENU_BEAUTIFY_SETTINGS,
};
VAORC OnMenuWindowsReporter(Visio::IVApplicationPtr vsoApp);
@@ -108,6 +109,7 @@
VAORC OnMenuDisableMessageEnumeration(Visio::IVApplicationPtr vsoApp);
VAORC OnMenuSelectNumberedGroup(Visio::IVApplicationPtr vsoApp);
VAORC OnMenuGlobalSettings(Visio::IVApplicationPtr vsoApp);
+ VAORC OnMenuBeautifySettings(Visio::IVApplicationPtr vsoApp);
VAORC OnMenuFlipMessageDirection(Visio::IVApplicationPtr vsoApp);
void ShowReportView();
Added: trunk/src/view/visio/addon/instanceSettingDlg.cpp
===================================================================
--- trunk/src/view/visio/addon/instanceSettingDlg.cpp (rev 0)
+++ trunk/src/view/visio/addon/instanceSettingDlg.cpp 2010-09-18 12:52:48 UTC (rev 971)
@@ -0,0 +1,225 @@
+/*
+ * 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 Zuzana Pekarcikova <z.p...@gm...>
+ *
+ * $Id: $
+ */
+
+#include "stdafx.h"
+#include "dllmodule.h"
+#include "instanceSettingDlg.h"
+#include "errors.h"
+
+#include <htmlhelp.h>
+
+
+BOOL CInstanceSettingDlg::OnInitDialog(HWND hWndFocus, LPARAM lParam)
+{
+ CenterWindow(GetParent());
+
+ LoadRegistryData();
+ //Move values in variables into controls
+ DoDataExchange(FALSE);
+
+ UpdateControls();
+
+ return TRUE;
+}
+
+void CInstanceSettingDlg::OnHelp()
+{
+}
+
+int CInstanceSettingDlg::OnApply()
+{
+ //Move values in controls to variables
+ if(!DoDataExchange(TRUE))
+ return PSNRET_INVALID;
+
+ SaveRegistryData();
+
+ return 0;
+}
+
+int CInstanceSettingDlg::LoadRegistryData()
+{
+ TRACE("CInstanceSettingDlg::LoadRegistryData() - Loading options from registry");
+ m_const_length_value = GetRegistry<float>(GetRegistryFolder(), NULL, _T("ConstLenghtValue"), 30.0);
+ m_bAlignBottom = GetRegistry<DWORD>(GetRegistryFolder(), NULL, _T("AlignBottom"), 1);
+ m_use_const_length = GetRegistry<DWORD>(GetRegistryFolder(), NULL, _T("ConstLength"), 0);
+ m_use_original_length = GetRegistry<DWORD>(GetRegistryFolder(), NULL, _T("OriginalLength"), 0);
+
+ m_use_min_head = GetRegistry<DWORD>(GetRegistryFolder(), NULL, _T("MinHead"), 1);
+ m_use_max_head = GetRegistry<DWORD>(GetRegistryFolder(), NULL, _T("MaxHead"), 0);
+ m_use_const_head = GetRegistry<DWORD>(GetRegistryFolder(), NULL, _T("ConstHead"), 0);
+ m_const_head_value = GetRegistry<float>(GetRegistryFolder(), NULL, _T("ConstHeadValue"), 10.0);
+
+ m_use_const_spacing = GetRegistry<DWORD>(GetRegistryFolder(), NULL, _T("ConstSpacing"), 1);
+ m_use_total_width = GetRegistry<DWORD>(GetRegistryFolder(), NULL, _T("TotalWidth"), 0);
+ m_const_spacing_value = GetRegistry<float>(GetRegistryFolder(), NULL, _T("ConstSpacingValue"), 30.0);
+ m_total_width_value = GetRegistry<float>(GetRegistryFolder(), NULL, _T("TotalWidthValue"), 50.0);
+ m_allowPermutation = GetRegistry<DWORD>(GetRegistryFolder(), NULL, _T("AllowPermutation"), 1);
+
+ return 0;
+}
+
+int CInstanceSettingDlg::SaveRegistryData()
+{
+ TRACE("CInstanceSettingDlg::SaveRegistryData() - Saving options to registry");
+
+ SetRegistry<>(HKEY_CURRENT_USER, GetRegistryFolder(), _T("ConstLenghtValue"), (float)m_const_length_value);
+ SetRegistry<>(HKEY_CURRENT_USER, GetRegistryFolder(), _T("ConstLength"), (DWORD)m_use_const_length);
+ SetRegistry<>(HKEY_CURRENT_USER, GetRegistryFolder(), _T("AlignBottom"), (DWORD)m_bAlignBottom);
+ SetRegistry<>(HKEY_CURRENT_USER, GetRegistryFolder(), _T("OriginalLength"), (DWORD)m_use_original_length);
+
+ SetRegistry<>(HKEY_CURRENT_USER, GetRegistryFolder(), _T("MinHead"), (DWORD)m_use_min_head);
+ SetRegistry<>(HKEY_CURRENT_USER, GetRegistryFolder(), _T("MaxHead"), (DWORD)m_use_max_head);
+ SetRegistry<>(HKEY_CURRENT_USER, GetRegistryFolder(), _T("ConstHead"), (DWORD)m_use_const_head);
+ SetRegistry<>(HKEY_CURRENT_USER, GetRegistryFolder(), _T("ConstHeadValue"), (float)m_const_head_value);
+
+ SetRegistry<>(HKEY_CURRENT_USER, GetRegistryFolder(), _T("ConstSpacing"), (DWORD)m_use_const_spacing);
+ SetRegistry<>(HKEY_CURRENT_USER, GetRegistryFolder(), _T("TotalWidth"), (DWORD)m_use_total_width);
+ SetRegistry<>(HKEY_CURRENT_USER, GetRegistryFolder(), _T("ConstSpacingValue"), (float)m_const_spacing_value);
+ SetRegistry<>(HKEY_CURRENT_USER, GetRegistryFolder(), _T("TotalWidthValue"), (float)m_total_width_value);
+ SetRegistry<>(HKEY_CURRENT_USER, GetRegistryFolder(), _T("AllowPermutation"), (DWORD)m_allowPermutation);
+
+
+ return 0;
+}
+
+
+// Length of instances settings
+
+LRESULT CInstanceSettingDlg::OnMinLengthRdo(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
+{
+ m_use_const_length = 0;
+ m_use_original_length = 0;
+ UpdateControls();
+ return 0;
+}
+
+LRESULT CInstanceSettingDlg::OnConstLengthRdo(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
+{
+ m_use_const_length = 1;
+ m_use_original_length = 0;
+ m_constLengthValue.SetFocus();
+ UpdateControls();
+ return 0;
+}
+
+LRESULT CInstanceSettingDlg::OnOriginalLengthRdo(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
+{
+ m_use_const_length = 0;
+ m_use_original_length = 1;
+ UpdateControls();
+ return 0;
+}
+
+// Head and Foot settings
+
+LRESULT CInstanceSettingDlg::OnMinHeadRdo(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
+{
+ m_use_min_head = 1;
+ m_use_max_head = 0;
+ m_use_const_head = 0;
+ UpdateControls();
+ return 0;
+}
+
+LRESULT CInstanceSettingDlg::OnMaxHeadRdo(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
+{
+ m_use_min_head = 0;
+ m_use_max_head = 1;
+ m_use_const_head = 0;
+ UpdateControls();
+ return 0;
+}
+
+LRESULT CInstanceSettingDlg::OnOriginalHeadRdo(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
+{
+ m_use_min_head = 0;
+ m_use_max_head = 0;
+ m_use_const_head = 0;
+ UpdateControls();
+ return 0;
+}
+
+LRESULT CInstanceSettingDlg::OnConstHeadRdo(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
+{
+ m_use_min_head = 0;
+ m_use_max_head = 0;
+ m_use_const_head = 1;
+ UpdateControls();
+ return 0;
+}
+
+// Spacing settings
+
+LRESULT CInstanceSettingDlg::OnConstSpacingRdo(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
+{
+ m_use_const_spacing = 1;
+ m_use_total_width = 0;
+ UpdateControls();
+ return 0;
+}
+
+LRESULT CInstanceSettingDlg::OnTotalWidthRdo(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
+{
+ m_use_const_spacing = 0;
+ m_use_total_width = 1;
+ UpdateControls();
+ return 0;
+}
+
+LRESULT CInstanceSettingDlg::OnOriginalSpacingRdo(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
+{
+ m_use_const_spacing = 0;
+ m_use_total_width = 0;
+ UpdateControls();
+ return 0;
+}
+
+LRESULT CInstanceSettingDlg::OnAllowPermutation(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
+{
+ DoDataExchange(TRUE);
+ if(!m_use_const_spacing && !m_use_total_width)
+ m_use_const_spacing = 1;
+ UpdateControls();
+ return 0;
+}
+
+
+
+void CInstanceSettingDlg::UpdateControls()
+{
+ m_minLengthRdo.SetCheck((!m_use_const_length && !m_use_original_length) ? BST_CHECKED : BST_UNCHECKED);
+ m_constLengthRdo.SetCheck((m_use_const_length && !m_use_original_length) ? BST_CHECKED : BST_UNCHECKED);
+ m_originalLengthRdo.SetCheck((!m_use_const_length && m_use_original_length) ? BST_CHECKED : BST_UNCHECKED);
+ m_constLengthValue.EnableWindow(m_use_const_length);
+
+ m_minHeadRdo.SetCheck(m_use_min_head ? BST_CHECKED : BST_UNCHECKED);
+ m_maxHeadRdo.SetCheck(m_use_max_head ? BST_CHECKED : BST_UNCHECKED);
+ m_constHeadRdo.SetCheck(m_use_const_head ? BST_CHECKED : BST_UNCHECKED);
+ m_originalHeadRdo.SetCheck((!m_use_min_head && !m_use_max_head && !m_use_const_head) ? BST_CHECKED : BST_UNCHECKED);
+ m_constHeadValue.EnableWindow(m_use_const_head);
+
+ m_constSpacingRdo.SetCheck(m_use_const_spacing ? BST_CHECKED : BST_UNCHECKED);
+ m_totalWidthRdo.SetCheck(m_use_total_width ? BST_CHECKED : BST_UNCHECKED);
+ m_originalSpacingRdo.SetCheck((!m_use_const_spacing && !m_use_total_width) ? BST_CHECKED : BST_UNCHECKED);
+
+ m_originalSpacingRdo.EnableWindow(!m_allowPermutation);
+ m_constSpacingValue.EnableWindow(m_use_const_spacing);
+ m_totalWidthValue.EnableWindow(m_use_total_width);
+}
+
Added: trunk/src/view/visio/addon/instanceSettingDlg.h
===================================================================
--- trunk/src/view/visio/addon/instanceSettingDlg.h (rev 0)
+++ trunk/src/view/visio/addon/instanceSettingDlg.h 2010-09-18 12:52:48 UTC (rev 971)
@@ -0,0 +1,164 @@
+/*
+ * 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 Zuzana Pekarcikova <z.p...@gm...>
+ *
+ * $Id: $
+ */
+
+#pragma once
+
+#include <atldlgs.h>
+#include <atlddx.h>
+#include <atlctrls.h>
+#include <atlcrack.h>
+#include <atlmisc.h>
+
+#include "data/msc.h"
+
+#include <boost/shared_ptr.hpp>
+
+class CInstanceSettingDlg: public CPropertyPageImpl<CInstanceSettingDlg>,
+ public CWinDataExchange<CInstanceSettingDlg>
+{
+public:
+ enum { IDD = IDD_INSTANCES_BEAUTIFY };
+
+ long m_use_const_length;
+ long m_use_original_length;
+
+ long m_use_min_head;
+ long m_use_max_head;
+ long m_use_const_head;
+
+ long m_use_const_spacing;
+ long m_use_total_width;
+ bool m_allowPermutation;
+
+ float m_const_length_value;
+ float m_const_head_value;
+ float m_const_spacing_value;
+ float m_total_width_value;
+ bool m_bAlignBottom;
+
+ CInstanceSettingDlg(Visio::IVApplicationPtr vsoApp):m_vsoApp(vsoApp)
+ { //set dialog properties
+ m_psp.dwFlags |= PSP_HASHELP;
+ };
+
+ //Registry folder
+ const wchar_t* GetRegistryFolder() { return SCSTUDIO_REGISTRY_ROOT _T("\\Beautify"); }
+
+ //Message handlers
+ BOOL OnInitDialog(HWND hWndFocus, LPARAM lParam);
+
+ //Property page notification handlers (override method)
+ void OnHelp();
+ int OnApply();
+
+
+protected:
+ Visio::IVApplicationPtr m_vsoApp;
+
+ BEGIN_DDX_MAP(CInstanceSettingDlg)
+ DDX_FLOAT(IDC_CONSTANT_VALUE, m_const_length_value)
+ DDX_FLOAT(IDC_CONST_HEAD_VALUE, m_const_head_value)
+ DDX_FLOAT(IDC_CONST_SPACING_VALUE, m_const_spacing_value)
+ DDX_FLOAT(IDC_TOTAL_WIDTH_VALUE, m_total_width_value)
+
+ DDX_CHECK(IDC_ALIGN_BOTTOM,m_bAlignBottom)
+ DDX_CONTROL_HANDLE(IDC_MIN_LENGTH_RDO, m_minLengthRdo)
+ DDX_CONTROL_HANDLE(IDC_ORIGINAL_LENGTH_RDO, m_originalLengthRdo)
+ DDX_CONTROL_HANDLE(IDC_CONST_LENGTH_RDO, m_constLengthRdo)
+
+ DDX_CONTROL_HANDLE(IDC_MIN_HEAD_RDO, m_minHeadRdo)
+ DDX_CONTROL_HANDLE(IDC_MAX_HEAD_RDO, m_maxHeadRdo)
+ DDX_CONTROL_HANDLE(IDC_ORIGINAL_HEAD_RDO, m_originalHeadRdo)
+ DDX_CONTROL_HANDLE(IDC_CONST_HEAD_RDO, m_constHeadRdo)
+
+ DDX_CONTROL_HANDLE(IDC_CONSTANT_VALUE, m_constLengthValue)
+ DDX_CONTROL_HANDLE(IDC_CONST_HEAD_VALUE, m_constHeadValue)
+
+ DDX_CONTROL_HANDLE(IDC_CONST_SPACING_RDO, m_constSpacingRdo)
+ DDX_CONTROL_HANDLE(IDC_TOTAL_WIDTH_RDO, m_totalWidthRdo)
+ DDX_CONTROL_HANDLE(IDC_ORIGINAL_SPACING_RDO, m_originalSpacingRdo)
+ DDX_CHECK(IDC_ALLOW_PERMUTATION,m_allowPermutation)
+
+
+ DDX_CONTROL_HANDLE(IDC_CONST_SPACING_VALUE, m_constSpacingValue)
+ DDX_CONTROL_HANDLE(IDC_TOTAL_WIDTH_VALUE, m_totalWidthValue)
+
+ END_DDX_MAP()
+
+ BEGIN_MSG_MAP(CInstanceSettingDlg)
+ MSG_WM_INITDIALOG(OnInitDialog)
+ CHAIN_MSG_MAP(CPropertyPageImpl<CInstanceSettingDlg>)
+ COMMAND_ID_HANDLER(IDC_MIN_LENGTH_RDO, OnMinLengthRdo)
+ COMMAND_ID_HANDLER(IDC_CONST_LENGTH_RDO, OnConstLengthRdo)
+ COMMAND_ID_HANDLER(IDC_ORIGINAL_LENGTH_RDO, OnOriginalLengthRdo)
+
+ COMMAND_ID_HANDLER(IDC_MIN_HEAD_RDO, OnMinHeadRdo)
+ COMMAND_ID_HANDLER(IDC_MAX_HEAD_RDO, OnMaxHeadRdo)
+ COMMAND_ID_HANDLER(IDC_ORIGINAL_...
[truncated message content] |
|
From: <mbe...@us...> - 2010-09-18 17:43:32
|
Revision: 973
http://scstudio.svn.sourceforge.net/scstudio/?rev=973&view=rev
Author: mbezdeka
Date: 2010-09-18 17:43:26 +0000 (Sat, 18 Sep 2010)
Log Message:
-----------
- bug fixed (preserve message type in Message jump doesn't work)
- comments added
Modified Paths:
--------------
trunk/src/view/visio/addon/messageJump.cpp
trunk/src/view/visio/addon/messageJump.h
Modified: trunk/src/view/visio/addon/messageJump.cpp
===================================================================
--- trunk/src/view/visio/addon/messageJump.cpp 2010-09-18 15:34:26 UTC (rev 972)
+++ trunk/src/view/visio/addon/messageJump.cpp 2010-09-18 17:43:26 UTC (rev 973)
@@ -19,6 +19,7 @@
#include "stdafx.h"
#include "dllmodule.h"
#include "messageJump.h"
+#include "messageSnapping.h"
#define SNAP_REG_PATH _T("Software\\Sequence Chart Studio\\MessageSnapping")
@@ -101,7 +102,6 @@
{
if(!isEnabled()) // If Edge treatment isn't enabled we are done and Message won't be snapped to any new instance
return false;
-
changeMsgType(msgShape, (getEdgeInstanceTreatment() == 1) ? shapeType : ST_BMSC_MESSAGE);
}
@@ -114,10 +114,11 @@
case MSCE_BEGIN: //LEFT point is snapped, adjust right point
case MSCE_END: //RIGHT point is snapped, adjust left point
if(origIntsLeft && origIntsRight)
- changeMsgType(msgShape, shapeType);
+ changeMsgType(msgShape, (getEdgeInstanceTreatment() == 1) ? shapeType : ST_BMSC_MESSAGE);
CMessageSnapping::setMsgLength(msgShape, msgVec, (conn == MSCE_BEGIN) ? vis1DBeginX : vis1DEndX);
if(origIntsLeft && origIntsRight)
CMessageSnapping::resnap(msgShape, msgShape->Application->ActivePage->Shapes, 0.0001);
+
if(getMsgNeedsResnap(msgShape) == 0)
setMsgNeedsResnap(msgShape, true);
break;
Modified: trunk/src/view/visio/addon/messageJump.h
===================================================================
--- trunk/src/view/visio/addon/messageJump.h 2010-09-18 15:34:26 UTC (rev 972)
+++ trunk/src/view/visio/addon/messageJump.h 2010-09-18 17:43:26 UTC (rev 973)
@@ -20,16 +20,22 @@
#include "enums.h"
#include "shapeUtils.h"
-#include "messageSnapping.h"
#include "visualize.h"
-
+//! Class enables messages to jump between instances (coregions)
class CMessageJump
{
public:
static bool isEnabled();
static int getEdgeInstanceTreatment();
-
+ /**
+ * Jumps with given message to the left or to the right
+ * @param msgShape a message which we wnat to jump with
+ * @param connectedInstances instances the message is currently connected to
+ * @param direction jump direction (MSJUMP_LEFT, MSJUMP_RIGHT)
+ * @param asCopy creates message duplicate and then jump with duplicate
+ * @return Returns true if jump succeeded, false otherwise
+ */
static bool jump(Visio::IVShapePtr& msgShape, std::vector<Visio::IVShapePtr> connectedInstances, MsgJumpDirection direction, bool asCopy);
/**
* Finds closest instance from shape in horizontal direction
@@ -45,7 +51,10 @@
*/
static void setMsgNeedsResnap(Visio::IVShapePtr msgShape, bool bTrueIfNeeds);
/**
- * Changes shape's type
+ * Changes message's type and deletes previous one
+ * @param msgShape a message which type we want to change
+ * @param shapeType type of a new message (ST_BMSC_MESSAGE, ST_BMSC_MESSAGE_FOUND, ST_BMSC_MESSAGE_LOST)
+ * @return Returns true if change succeeded, false otherwise
*/
static bool changeMsgType(Visio::IVShapePtr& msgShape, TShapeType shapeType);
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ob...@us...> - 2010-09-20 14:50:39
|
Revision: 979
http://scstudio.svn.sourceforge.net/scstudio/?rev=979&view=rev
Author: obouda
Date: 2010-09-20 14:50:33 +0000 (Mon, 20 Sep 2010)
Log Message:
-----------
Fixed help paths from Visio Addon
Modified Paths:
--------------
trunk/src/view/visio/addon/numberingGlobalDlg.cpp
trunk/src/view/visio/addon/snapGlobalDlg.cpp
Modified: trunk/src/view/visio/addon/numberingGlobalDlg.cpp
===================================================================
--- trunk/src/view/visio/addon/numberingGlobalDlg.cpp 2010-09-20 14:41:01 UTC (rev 978)
+++ trunk/src/view/visio/addon/numberingGlobalDlg.cpp 2010-09-20 14:50:33 UTC (rev 979)
@@ -138,7 +138,7 @@
void CNumberingGlobalDlg::OnHelp()
{
std::basic_string<TCHAR> path = GetVisioModulePath();
- path += _T("\\help\\frontend\\message-numbering.html");
+ path += _T("\\help\\frontend\\message_numbering.html");
ShellExecuteW(NULL, L"open", path.c_str() , NULL, NULL, SW_SHOWNORMAL);
}
Modified: trunk/src/view/visio/addon/snapGlobalDlg.cpp
===================================================================
--- trunk/src/view/visio/addon/snapGlobalDlg.cpp 2010-09-20 14:41:01 UTC (rev 978)
+++ trunk/src/view/visio/addon/snapGlobalDlg.cpp 2010-09-20 14:50:33 UTC (rev 979)
@@ -55,7 +55,7 @@
void CSnapGlobalDlg::OnHelp()
{
std::basic_string<TCHAR> path = GetVisioModulePath();
- path += _T("\\help\\frontend\\message-snapping.html");
+ path += _T("\\help\\frontend\\settings.html");
ShellExecute(NULL, L"open", path.c_str() , NULL, NULL, SW_SHOWNORMAL);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ob...@us...> - 2010-11-16 23:22:20
|
Revision: 1000
http://scstudio.svn.sourceforge.net/scstudio/?rev=1000&view=rev
Author: obouda
Date: 2010-11-16 23:22:14 +0000 (Tue, 16 Nov 2010)
Log Message:
-----------
Cleaned up the code changes made in revision 999
Revision Links:
--------------
http://scstudio.svn.sourceforge.net/scstudio/?rev=999&view=rev
Modified Paths:
--------------
trunk/src/view/visio/addon/shapeutils.cpp
trunk/src/view/visio/addon/visualize.cpp
Modified: trunk/src/view/visio/addon/shapeutils.cpp
===================================================================
--- trunk/src/view/visio/addon/shapeutils.cpp 2010-11-16 22:40:55 UTC (rev 999)
+++ trunk/src/view/visio/addon/shapeutils.cpp 2010-11-16 23:22:14 UTC (rev 1000)
@@ -53,10 +53,18 @@
void CShapeUtils::MarkShape(Visio::IVShapePtr shape)
{
- // line color = red
- shape->CellsSRC[visSectionObject][visRowLine][visLineColor]->ResultIU = 2;
- // text color = red
- shape->CellsSRC[visSectionCharacter][visRowCharacter][visCharacterColor]->ResultIU = 2;
+ if (shape->Type == Visio::visTypeGroup)
+ {
+ for(long i = 1; i <= shape->Shapes->Count; i++)
+ {
+ MarkShape(shape->Shapes->Item[i]);
+ }
+ } else {
+ // line color = red
+ shape->CellsSRC[visSectionObject][visRowLine][visLineColor]->ResultIU = 2;
+ // text color = red
+ shape->CellsSRC[visSectionCharacter][visRowCharacter][visCharacterColor]->ResultIU = 2;
+ }
}
void CShapeUtils::UnmarkShape(Visio::IVShapePtr shape)
Modified: trunk/src/view/visio/addon/visualize.cpp
===================================================================
--- trunk/src/view/visio/addon/visualize.cpp 2010-11-16 22:40:55 UTC (rev 999)
+++ trunk/src/view/visio/addon/visualize.cpp 2010-11-16 23:22:14 UTC (rev 1000)
@@ -272,11 +272,8 @@
if (what->Type == Visio::visTypeGroup)
{
for(long i = 1; i <= what->Shapes->Count; i++)
- {
- // line color = red
- what->Shapes->Item[i]->CellsSRC[visSectionObject][visRowLine][visLineColor]->ResultIU = 2;
- // text color = red
- what->Shapes->Item[i]->CellsSRC[visSectionCharacter][visRowCharacter][visCharacterColor]->ResultIU = 2;
+ {
+ MarkShape(what->Shapes->Item[i]);
}
} else {
// line color = red
@@ -758,12 +755,8 @@
std::wstringstream mcnt_stream;
mcnt_stream << "# of visites: " << mcnt;
Comment* refNodeComment = new Comment(mcnt_stream.str());
- //Coordinate pos_x = shape->Cells["PinX"]->Result[""];
- //Coordinate pos_y = shape->Cells["PinY"]->Result[""];
- //MscPoint commentPos(pos_x, pos_y);
MscPoint commentPos(GetPinPos(shape));
refNodeComment->set_position(commentPos);
- //refNodeComment->set_width(7);
Visio::IVShapePtr commentShape = DropComment<Comment>(vsoPage, refNodeComment);
CShapeUtils::GlueBeginToShape(commentShape, shape);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <xr...@us...> - 2010-11-18 07:34:26
|
Revision: 1001
http://scstudio.svn.sourceforge.net/scstudio/?rev=1001&view=rev
Author: xrehak
Date: 2010-11-18 07:34:20 +0000 (Thu, 18 Nov 2010)
Log Message:
-----------
Finishing of revision 1000.
- (visites->visits)
- removed duplicites of CShapeUtils::?? from visualize.cpp
- UnmarkedShape for Group shapes
Revision Links:
--------------
http://scstudio.svn.sourceforge.net/scstudio/?rev=1000&view=rev
Modified Paths:
--------------
trunk/src/view/visio/addon/shapeutils.cpp
trunk/src/view/visio/addon/visualize.cpp
trunk/src/view/visio/addon/visualize.h
Modified: trunk/src/view/visio/addon/shapeutils.cpp
===================================================================
--- trunk/src/view/visio/addon/shapeutils.cpp 2010-11-16 23:22:14 UTC (rev 1000)
+++ trunk/src/view/visio/addon/shapeutils.cpp 2010-11-18 07:34:20 UTC (rev 1001)
@@ -69,10 +69,18 @@
void CShapeUtils::UnmarkShape(Visio::IVShapePtr shape)
{
- // line color = red
- shape->CellsSRC[visSectionObject][visRowLine][visLineColor]->ResultIU = 0;
- // text color = red
- shape->CellsSRC[visSectionCharacter][visRowCharacter][visCharacterColor]->ResultIU = 0;
+ if (shape->Type == Visio::visTypeGroup)
+ {
+ for(long i = 1; i <= shape->Shapes->Count; i++)
+ {
+ UnmarkShape(shape->Shapes->Item[i]);
+ }
+ } else {
+ // line color = black
+ shape->CellsSRC[visSectionObject][visRowLine][visLineColor]->ResultIU = 0;
+ // text color = black
+ shape->CellsSRC[visSectionCharacter][visRowCharacter][visCharacterColor]->ResultIU = 0;
+ }
}
Visio::IVShapePtr CShapeUtils::GetCoregionAt(Visio::IVShapePtr shape, double yPos)
Modified: trunk/src/view/visio/addon/visualize.cpp
===================================================================
--- trunk/src/view/visio/addon/visualize.cpp 2010-11-16 23:22:14 UTC (rev 1000)
+++ trunk/src/view/visio/addon/visualize.cpp 2010-11-18 07:34:20 UTC (rev 1001)
@@ -266,58 +266,58 @@
}
}
-// FIXME: duplicate of CShapeUtils::MarkShape - remove from here
-void MarkShape(Visio::IVShapePtr what)
-{
- if (what->Type == Visio::visTypeGroup)
- {
- for(long i = 1; i <= what->Shapes->Count; i++)
- {
- MarkShape(what->Shapes->Item[i]);
- }
- } else {
- // line color = red
- what->CellsSRC[visSectionObject][visRowLine][visLineColor]->ResultIU = 2;
- // text color = red
- what->CellsSRC[visSectionCharacter][visRowCharacter][visCharacterColor]->ResultIU = 2;
- }
-}
+// duplicate of CShapeUtils::MarkShape - removed from here
+//void MarkShape(Visio::IVShapePtr what)
+//{
+// if (what->Type == Visio::visTypeGroup)
+// {
+// for(long i = 1; i <= what->Shapes->Count; i++)
+// {
+// MarkShape(what->Shapes->Item[i]);
+// }
+// } else {
+// // line color = red
+// what->CellsSRC[visSectionObject][visRowLine][visLineColor]->ResultIU = 2;
+// // text color = red
+// what->CellsSRC[visSectionCharacter][visRowCharacter][visCharacterColor]->ResultIU = 2;
+// }
+//}
-// FIXME: duplicate of CShapeUtils::GlueBeginToPos - remove from here
-void GlueBeginToPos(Visio::IVShapePtr what, Visio::IVShapePtr where, const MscPoint& pos)
-{
- double height = where->CellsSRC[visSectionObject][visRowXFormOut][visXFormHeight]->Result[visMillimeters];
- double width = where->CellsSRC[visSectionObject][visRowXFormOut][visXFormWidth]->Result[visMillimeters];
+// duplicate of CShapeUtils::GlueBeginToPos - removed from here
+//void GlueBeginToPos(Visio::IVShapePtr what, Visio::IVShapePtr where, const MscPoint& pos)
+//{
+// double height = where->CellsSRC[visSectionObject][visRowXFormOut][visXFormHeight]->Result[visMillimeters];
+// double width = where->CellsSRC[visSectionObject][visRowXFormOut][visXFormWidth]->Result[visMillimeters];
+//
+// Visio::IVCellPtr cell = what->CellsSRC[visSectionObject][visRowXForm1D][vis1DBeginX];
+// // glue coordinates represent decimal fractions of the shape's width and height
+// // note: instances in Visio are rotated by 90', height is the 'x' coordinate
+// cell->GlueToPos(where, pos.get_y()/max(1.0,width), pos.get_x()/max(1.0,height));
+//}
- Visio::IVCellPtr cell = what->CellsSRC[visSectionObject][visRowXForm1D][vis1DBeginX];
- // glue coordinates represent decimal fractions of the shape's width and height
- // note: instances in Visio are rotated by 90', height is the 'x' coordinate
- cell->GlueToPos(where, pos.get_y()/max(1.0,width), pos.get_x()/max(1.0,height));
-}
+// duplicate of CShapeUtils::GlueBeginToShape - removed from here
+//void GlueBeginToShape(Visio::IVShapePtr what, Visio::IVShapePtr where)
+//{
+// double height = where->CellsSRC[visSectionObject][visRowXFormOut][visXFormHeight]->Result[visMillimeters];
+// double width = where->CellsSRC[visSectionObject][visRowXFormOut][visXFormWidth]->Result[visMillimeters];
+//
+// Visio::IVCellPtr from_cell = what->CellsSRC[visSectionObject][visRowXForm1D][vis1DBeginX];
+// Visio::IVCellPtr to_cell = where->CellsSRC[visSectionObject][visRowXFormOut][visXFormPinX];
+//
+// from_cell->GlueTo(to_cell);
+//}
-// FIXME: duplicate of CShapeUtils::GlueBeginToShape - remove from here
-void GlueBeginToShape(Visio::IVShapePtr what, Visio::IVShapePtr where)
-{
- double height = where->CellsSRC[visSectionObject][visRowXFormOut][visXFormHeight]->Result[visMillimeters];
- double width = where->CellsSRC[visSectionObject][visRowXFormOut][visXFormWidth]->Result[visMillimeters];
+// duplicate of CShapeUtils::GlueEndToPos - removed from here
+//void GlueEndToPos(Visio::IVShapePtr what, Visio::IVShapePtr where, const MscPoint& pos)
+//{
+// double height = where->CellsSRC[visSectionObject][visRowXFormOut][visXFormHeight]->Result[visMillimeters];
+// double width = where->CellsSRC[visSectionObject][visRowXFormOut][visXFormWidth]->Result[visMillimeters];
+//
+// Visio::IVCellPtr cell = what->CellsSRC[visSectionObject][visRowXForm1D][vis1DEndX];
+// // note: instances in Visio are rotated by 90', height is the 'x' coordinate
+// cell->GlueToPos(where, pos.get_y()/max(1.0,width), pos.get_x()/max(1.0,height));
+//}
- Visio::IVCellPtr from_cell = what->CellsSRC[visSectionObject][visRowXForm1D][vis1DBeginX];
- Visio::IVCellPtr to_cell = where->CellsSRC[visSectionObject][visRowXFormOut][visXFormPinX];
-
- from_cell->GlueTo(to_cell);
-}
-
-// FIXME: duplicate of CShapeUtils::GlueEndToPos - remove from here
-void GlueEndToPos(Visio::IVShapePtr what, Visio::IVShapePtr where, const MscPoint& pos)
-{
- double height = where->CellsSRC[visSectionObject][visRowXFormOut][visXFormHeight]->Result[visMillimeters];
- double width = where->CellsSRC[visSectionObject][visRowXFormOut][visXFormWidth]->Result[visMillimeters];
-
- Visio::IVCellPtr cell = what->CellsSRC[visSectionObject][visRowXForm1D][vis1DEndX];
- // note: instances in Visio are rotated by 90', height is the 'x' coordinate
- cell->GlueToPos(where, pos.get_y()/max(1.0,width), pos.get_x()/max(1.0,height));
-}
-
Visio::IVShapePtr CDrawingVisualizer::drop_message(Visio::IVPagePtr vsoPage, MessagePtrMap& messages,
MscMessagePtr message, Visio::IVMasterPtr master)
{
@@ -327,7 +327,7 @@
msg = vsoPage->Drop(master, 0, 0);
if(message->get_marked())
- MarkShape(msg);
+ CShapeUtils::MarkShape(msg);
msg->Text = message->get_label().c_str();
messages[message] = msg;
@@ -344,9 +344,9 @@
Visio::IVShapePtr msg = drop_message(vsoPage, messages, complete_message, find_master(ST_BMSC_MESSAGE));
if(complete_message->get_send_event() == event)
- GlueBeginToPos(msg, parent, event->get_position());
+ CShapeUtils::GlueBeginToPos(msg, parent, event->get_position());
else if(complete_message->get_receive_event() == event)
- GlueEndToPos(msg, parent, event->get_position());
+ CShapeUtils::GlueEndToPos(msg, parent, event->get_position());
}
IncompleteMessagePtr incomplete_message = event->get_incomplete_message();
@@ -355,13 +355,13 @@
if(incomplete_message->is_lost())
{
Visio::IVShapePtr msg = drop_message(vsoPage, messages, incomplete_message, find_master(ST_BMSC_MESSAGE_LOST));
- GlueBeginToPos(msg, parent, event->get_position());
+ CShapeUtils::GlueBeginToPos(msg, parent, event->get_position());
SetLineEnd(msg, GetLineBegin(msg)+incomplete_message->get_dot_position());
}
else if(incomplete_message->is_found())
{
Visio::IVShapePtr msg = drop_message(vsoPage, messages, incomplete_message, find_master(ST_BMSC_MESSAGE_FOUND));
- GlueEndToPos(msg, parent, event->get_position());
+ CShapeUtils::GlueEndToPos(msg, parent, event->get_position());
SetLineBegin(msg, GetLineEnd(msg)+incomplete_message->get_dot_position());
}
}
@@ -386,7 +386,7 @@
{
Visio::IVShapePtr comment = DropComment(vsoPage, *cpos);
- GlueBeginToPos(comment, parent, event->get_position());
+ CShapeUtils::GlueBeginToPos(comment, parent, event->get_position());
SetLineEnd(comment, (*cpos)->get_position());
}
}
@@ -402,8 +402,8 @@
else
connector = vsoPage->Drop(find_master(ST_BMSC_ORDER_LINE), 0, 0);
- GlueBeginToPos(connector, parent, pred_event->get_position());
- GlueEndToPos(connector, parent, succ_event->get_position());
+ CShapeUtils::GlueBeginToPos(connector, parent, pred_event->get_position());
+ CShapeUtils::GlueEndToPos(connector, parent, succ_event->get_position());
// events are on the same side
if(fcmp(pred_event->get_position().get_x(), succ_event->get_position().get_x()) == 0)
@@ -431,7 +431,7 @@
SetControlPos(result, _T("Width"), time_relation->get_width());
if(time_relation->get_marked())
- MarkShape(result);
+ CShapeUtils::MarkShape(result);
result->Text = time_relation->get_label().c_str();
@@ -460,9 +460,9 @@
}
if((*rpos)->get_event_a() == event)
- GlueBeginToPos(dimension, parent, event->get_position());
+ CShapeUtils::GlueBeginToPos(dimension, parent, event->get_position());
else if((*rpos)->get_event_b() == event)
- GlueEndToPos(dimension, parent, event->get_position());
+ CShapeUtils::GlueEndToPos(dimension, parent, event->get_position());
}
}
@@ -484,7 +484,7 @@
text->CellsSRC[visSectionObject][visRowXFormOut][visXFormWidth]->Result[visMillimeters] = (*cpos)->get_width();
if((*cpos)->get_marked())
- MarkShape(text);
+ CShapeUtils::MarkShape(text);
}
BMscPtr bmsc = boost::dynamic_pointer_cast<BMsc>(msc);
@@ -507,7 +507,7 @@
Visio::IVShapePtr inst =
vsoPage->Drop(find_master(ST_BMSC_INSTANCE, (*ipos)->get_visual_style()), 0, 0);
if((*ipos)->get_marked())
- MarkShape(inst);
+ CShapeUtils::MarkShape(inst);
inst->Text = (*ipos)->get_label().c_str();
SetControlPos(inst, _T("mscHeadWidth"), (*ipos)->get_width()/2.0);
@@ -548,10 +548,10 @@
{
Visio::IVShapePtr coregion = vsoPage->Drop(find_master(ST_BMSC_COREGION), 0, 0);
if(coregion_area->get_marked())
- MarkShape(coregion);
+ CShapeUtils::MarkShape(coregion);
- GlueBeginToPos(coregion, inst, MscPoint(0,coregion_area->get_begin_height()));
- GlueEndToPos(coregion, inst, MscPoint(0,coregion_area->get_end_height()));
+ CShapeUtils::GlueBeginToPos(coregion, inst, MscPoint(0,coregion_area->get_begin_height()));
+ CShapeUtils::GlueEndToPos(coregion, inst, MscPoint(0,coregion_area->get_end_height()));
// events to be processed; this is to avoid recursion
std::list<CoregionEventPtr> event_stack;
@@ -577,7 +577,7 @@
Visio::IVShapePtr connector = connect_events(vsoPage, coregion, *epos, successor);
if((*spos)->get_marked())
- MarkShape(connector);
+ CShapeUtils::MarkShape(connector);
// add successors of this event to the stack
// note: std::list<>::push_back doesn't invalidate iterators
@@ -636,7 +636,7 @@
}
if(node->get_marked())
- MarkShape(shape);
+ CShapeUtils::MarkShape(shape);
nodes[node] = shape;
@@ -723,7 +723,7 @@
Visio::IVShapePtr connector = vsoPage->Drop(find_master(ST_HMSC_ARROW), 0, 0);
if((*spos)->get_marked())
- MarkShape(connector);
+ CShapeUtils::MarkShape(connector);
Visio::IVCellPtr from_cell = connector->CellsSRC[visSectionObject][visRowXForm1D][vis1DBeginX];
from_cell->GlueToPos(shape, 0.5, 0.0);
@@ -753,7 +753,7 @@
int mcnt = reference_node->get_attribute("membership_counter", 0);
if (mcnt > 0) {
std::wstringstream mcnt_stream;
- mcnt_stream << "# of visites: " << mcnt;
+ mcnt_stream << "# of visits: " << mcnt;
Comment* refNodeComment = new Comment(mcnt_stream.str());
MscPoint commentPos(GetPinPos(shape));
refNodeComment->set_position(commentPos);
@@ -761,7 +761,7 @@
Visio::IVShapePtr commentShape = DropComment<Comment>(vsoPage, refNodeComment);
CShapeUtils::GlueBeginToShape(commentShape, shape);
SetLineEnd(commentShape, commentPos + MscPoint(20, -10));
- MarkShape(commentShape);
+ CShapeUtils::MarkShape(commentShape);
}
}
}
@@ -771,7 +771,7 @@
{
Visio::IVShapePtr comment = DropComment(vsoPage, *cpos);
- GlueBeginToShape(comment, shape);
+ CShapeUtils::GlueBeginToShape(comment, shape);
SetLineEnd(comment, (*cpos)->get_position());
}
}
Modified: trunk/src/view/visio/addon/visualize.h
===================================================================
--- trunk/src/view/visio/addon/visualize.h 2010-11-16 23:22:14 UTC (rev 1000)
+++ trunk/src/view/visio/addon/visualize.h 2010-11-18 07:34:20 UTC (rev 1001)
@@ -83,7 +83,7 @@
result->CellsSRC[visSectionObject][visRowXFormOut][visXFormHeight]->Result[visMillimeters] = comment->get_width();
if(comment->get_marked())
- MarkShape(result);
+ CShapeUtils::MarkShape(result);
return result;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mbe...@us...> - 2010-11-28 09:58:10
|
Revision: 1003
http://scstudio.svn.sourceforge.net/scstudio/?rev=1003&view=rev
Author: mbezdeka
Date: 2010-11-28 09:58:04 +0000 (Sun, 28 Nov 2010)
Log Message:
-----------
MarkShape(): Added default parameter for choosing a color.
Modified Paths:
--------------
trunk/src/view/visio/addon/enums.h
trunk/src/view/visio/addon/shapeutils.cpp
trunk/src/view/visio/addon/shapeutils.h
Modified: trunk/src/view/visio/addon/enums.h
===================================================================
--- trunk/src/view/visio/addon/enums.h 2010-11-27 12:25:17 UTC (rev 1002)
+++ trunk/src/view/visio/addon/enums.h 2010-11-28 09:58:04 UTC (rev 1003)
@@ -73,4 +73,15 @@
MSCE_UNKNOWN,
};
+enum ShapeColor
+{
+ SC_BLACK = 0,
+ SC_WHITE,
+ SC_RED,
+ SC_GREEN,
+ SC_BLUE,
+ SC_YELLOW,
+ SC_PINK,
+};
+
// $Id$
Modified: trunk/src/view/visio/addon/shapeutils.cpp
===================================================================
--- trunk/src/view/visio/addon/shapeutils.cpp 2010-11-27 12:25:17 UTC (rev 1002)
+++ trunk/src/view/visio/addon/shapeutils.cpp 2010-11-28 09:58:04 UTC (rev 1003)
@@ -51,7 +51,7 @@
cell->GlueToPos(where, pos.get_y()/max(1.0,width), pos.get_x()/max(1.0,height));
}
-void CShapeUtils::MarkShape(Visio::IVShapePtr shape)
+void CShapeUtils::MarkShape(Visio::IVShapePtr shape, ShapeColor color)
{
if (shape->Type == Visio::visTypeGroup)
{
@@ -60,27 +60,16 @@
MarkShape(shape->Shapes->Item[i]);
}
} else {
- // line color = red
- shape->CellsSRC[visSectionObject][visRowLine][visLineColor]->ResultIU = 2;
- // text color = red
- shape->CellsSRC[visSectionCharacter][visRowCharacter][visCharacterColor]->ResultIU = 2;
+ // line color from ShapeColor enum
+ shape->CellsSRC[visSectionObject][visRowLine][visLineColor]->ResultIU = color;
+ // text color from ShapeColor enum
+ shape->CellsSRC[visSectionCharacter][visRowCharacter][visCharacterColor]->ResultIU = color;
}
}
void CShapeUtils::UnmarkShape(Visio::IVShapePtr shape)
{
- if (shape->Type == Visio::visTypeGroup)
- {
- for(long i = 1; i <= shape->Shapes->Count; i++)
- {
- UnmarkShape(shape->Shapes->Item[i]);
- }
- } else {
- // line color = black
- shape->CellsSRC[visSectionObject][visRowLine][visLineColor]->ResultIU = 0;
- // text color = black
- shape->CellsSRC[visSectionCharacter][visRowCharacter][visCharacterColor]->ResultIU = 0;
- }
+ MarkShape(shape, SC_BLACK);
}
Visio::IVShapePtr CShapeUtils::GetCoregionAt(Visio::IVShapePtr shape, double yPos)
Modified: trunk/src/view/visio/addon/shapeutils.h
===================================================================
--- trunk/src/view/visio/addon/shapeutils.h 2010-11-27 12:25:17 UTC (rev 1002)
+++ trunk/src/view/visio/addon/shapeutils.h 2010-11-28 09:58:04 UTC (rev 1003)
@@ -42,7 +42,13 @@
static void GlueBeginToShape(Visio::IVShapePtr what, Visio::IVShapePtr where);
static void GlueEndToPos(Visio::IVShapePtr what, Visio::IVShapePtr where, const MscPoint& pos);
- static void MarkShape(Visio::IVShapePtr shape);
+ /**
+ * Marking, unmarking shapes
+ *
+ * @param shape the shape to be marked
+ * @param color the color the shape will be marked with (color enums can be found in enums.h)
+ */
+ static void MarkShape(Visio::IVShapePtr shape, ShapeColor color = SC_RED);
static void UnmarkShape(Visio::IVShapePtr shape);
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mbe...@us...> - 2010-12-12 11:05:45
|
Revision: 1012
http://scstudio.svn.sourceforge.net/scstudio/?rev=1012&view=rev
Author: mbezdeka
Date: 2010-12-12 11:05:38 +0000 (Sun, 12 Dec 2010)
Log Message:
-----------
- Find dialog: check-boxes behavior improved
Modified Paths:
--------------
trunk/src/view/visio/addon/finddlg.cpp
trunk/src/view/visio/addon/finddlg.h
Modified: trunk/src/view/visio/addon/finddlg.cpp
===================================================================
--- trunk/src/view/visio/addon/finddlg.cpp 2010-12-09 18:10:21 UTC (rev 1011)
+++ trunk/src/view/visio/addon/finddlg.cpp 2010-12-12 11:05:38 UTC (rev 1012)
@@ -44,12 +44,9 @@
m_pages1 = GetTreeSelection(m_drawing1);
std::vector<Visio::IVPagePtr> m_pages2 = GetTreeSelection(m_drawing2);
if(m_pages2.size() != 1)
- {
- MessageBox(L"You must choose one item in drawing tree!");
- return 0;
- }
-
- m_page2 = m_pages2.at(0);
+ m_page2 == NULL;
+ else
+ m_page2 = m_pages2.at(0);
if (m_pages1.empty() || m_page2 == NULL)
{
@@ -113,8 +110,113 @@
//Get sibling parent
parent = tree.GetNextSiblingItem(parent);
}
-
return vsoPages;
}
+LRESULT CFindDlg::OnNMClickDrawing1(int, LPNMHDR pNMHDR, BOOL&)
+{
+ return OnTreeViewClicked(m_drawing1);
+}
+
+LRESULT CFindDlg::OnNMClickDrawing2(int, LPNMHDR pNMHDR, BOOL&)
+{
+ return OnTreeViewClicked(m_drawing2);
+}
+
+LRESULT CFindDlg::OnTreeViewClicked(CTreeViewCtrl& tree)
+{
+ //Get cursor position
+ POINT pt;
+ GetCursorPos(&pt);
+ tree.ScreenToClient(&pt);
+ //Check where is the cursor position to drawing
+ UINT flags = 0;
+ HTREEITEM hItem = tree.HitTest(pt, &flags);
+ if(!hItem)
+ return 0;
+
+ return OnTreeViewItemClicked(tree, hItem, flags);
+}
+
+LRESULT CFindDlg::OnTreeViewItemClicked(CTreeViewCtrl& tree, HTREEITEM item, UINT unFlags)
+{
+ bool multiSelect = (tree == m_drawing1);
+
+ if(unFlags & TVHT_ONITEMSTATEICON) // cursor is on the check-box
+ return processCheckBoxes(tree, item, multiSelect, true);
+ else if(unFlags & TVHT_ONITEMLABEL) // cursor is on the label item
+ return processCheckBoxes(tree, item, multiSelect);
+
+ return 0;
+}
+
+void CFindDlg::setCheckBoxes(CTreeViewCtrl& tree, BOOL bCheck)
+{
+ HTREEITEM parent = tree.GetRootItem();
+ HTREEITEM child = NULL;
+
+ //Observe whole tree and set all nodes check-boxes to bCheck
+ while(parent)
+ {
+ tree.SetCheckState(parent, bCheck);
+ child = tree.GetChildItem(parent);
+ //Observe all children
+ while(child)
+ {
+ tree.SetCheckState(child, bCheck);
+ child = tree.GetNextSiblingItem(child); //Get sibling child
+ }
+ parent = tree.GetNextSiblingItem(parent); //Get sibling parent
+ }
+}
+
+LRESULT CFindDlg::processCheckBoxes(CTreeViewCtrl& tree, HTREEITEM item, bool multiSelect, bool reverted)
+{
+ BOOL newCheckState = !tree.GetCheckState(item);
+ //Get parent item
+ HTREEITEM parent = tree.GetParentItem(item);
+
+ if(!multiSelect)
+ {
+ setCheckBoxes(tree, 0); //Reset all check-boxes
+ if(reverted) tree.SetCheckState(item, !newCheckState);
+ }
+
+ //Check/uncheck current item
+ if(!reverted) //NOTE: If we click on check-box, it's automatically checked/unchecked
+ tree.SetCheckState(item, newCheckState);
+
+ if(parent) //'item' is a child item -> Check if there is another checked/uncheckd sibling item
+ {
+ HTREEITEM sibling = tree.GetChildItem(parent); //Get first sibling item
+ if(newCheckState)
+ tree.SetCheckState(parent, 1);
+
+ while(sibling)
+ {
+ if((tree.GetCheckState(sibling) != newCheckState) && (sibling != item))
+ break;
+ sibling = tree.GetNextSiblingItem(sibling);
+ }
+ if(!sibling) // If sibling is NULL, then every sibling items have the same check-box status
+ tree.SetCheckState(parent, newCheckState);
+ }
+ else //'item' is a parent item -> check or uncheck all child items
+ {
+ HTREEITEM childItem = tree.GetChildItem(item);
+
+ while(childItem)
+ {
+ tree.SetCheckState(childItem, newCheckState);
+ childItem = tree.GetNextSiblingItem(childItem);
+ //If multiselect is off and parent item has more
+ //than one child we don't know which child should be checked -> check only first childItem
+ if(childItem && !multiSelect && newCheckState)
+ break; //Jump out from cycle
+ }
+ }
+
+ return 0;
+}
+
// $Id$
Modified: trunk/src/view/visio/addon/finddlg.h
===================================================================
--- trunk/src/view/visio/addon/finddlg.h 2010-12-09 18:10:21 UTC (rev 1011)
+++ trunk/src/view/visio/addon/finddlg.h 2010-12-12 11:05:38 UTC (rev 1012)
@@ -46,13 +46,10 @@
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_ID_HANDLER(IDOK, OnCloseCmd)
COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd)
+ NOTIFY_HANDLER(IDC_DRAWING1, NM_CLICK, OnNMClickDrawing1)
+ NOTIFY_HANDLER(IDC_DRAWING2, NM_CLICK, OnNMClickDrawing2)
END_MSG_MAP()
-// Handler prototypes:
-// LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
-// LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
-// LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
-
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnCloseCmd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
@@ -61,6 +58,14 @@
private:
Visio::IVApplicationPtr m_vsoApp;
+
+public:
+ LRESULT OnNMClickDrawing1(int /*idCtrl*/, LPNMHDR pNMHDR, BOOL& /*bHandled*/);
+ LRESULT OnNMClickDrawing2(int /*idCtrl*/, LPNMHDR pNMHDR, BOOL& /*bHandled*/);
+ LRESULT OnTreeViewClicked(CTreeViewCtrl& tree);
+ LRESULT OnTreeViewItemClicked(CTreeViewCtrl& tree, HTREEITEM item, UINT unFlags);
+ LRESULT processCheckBoxes(CTreeViewCtrl& tree, HTREEITEM item, bool multiSelect, bool reverted = false);
+ void setCheckBoxes(CTreeViewCtrl& tree, BOOL bCheck);
};
-// $Id$
+// $Id$
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <xp...@us...> - 2011-01-04 07:22:44
|
Revision: 1020
http://scstudio.svn.sourceforge.net/scstudio/?rev=1020&view=rev
Author: xpekarc
Date: 2011-01-04 07:22:38 +0000 (Tue, 04 Jan 2011)
Log Message:
-----------
adding the sources for setting parameter of import
Added Paths:
-----------
trunk/src/view/visio/addon/ImportDistancesBmp.bmp
trunk/src/view/visio/addon/importSettingsDlg.cpp
trunk/src/view/visio/addon/importSettingsDlg.h
Added: trunk/src/view/visio/addon/ImportDistancesBmp.bmp
===================================================================
(Binary files differ)
Property changes on: trunk/src/view/visio/addon/ImportDistancesBmp.bmp
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/src/view/visio/addon/importSettingsDlg.cpp
===================================================================
--- trunk/src/view/visio/addon/importSettingsDlg.cpp (rev 0)
+++ trunk/src/view/visio/addon/importSettingsDlg.cpp 2011-01-04 07:22:38 UTC (rev 1020)
@@ -0,0 +1,160 @@
+/*
+ * 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 Zuzana Pekarcikova <z.p...@gm...>
+ *
+ * $Id: $
+ */
+
+#include "stdafx.h"
+#include "dllmodule.h"
+#include "importSettingsDlg.h"
+#include "errors.h"
+#include "document.h"
+#include "pageutils.h"
+
+
+
+
+
+LRESULT CImportSettingsDlg::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+ CenterWindow(GetParent());
+
+ LoadRegistryData();
+ //Move values in variables into controls
+ DoDataExchange(FALSE);
+
+ return bHandled = false;
+}
+
+LRESULT CImportSettingsDlg::OnCloseCmd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
+{
+ BOOL dataExchanged = FALSE;
+ if(wID == IDOK)
+ {
+ dataExchanged = DoDataExchange(true);
+ if (dataExchanged)
+ SaveRegistryData();
+ else
+ return PSNRET_INVALID;
+ }
+
+ EndDialog((wID == IDOK && dataExchanged));
+ return 0;
+}
+
+int CImportSettingsDlg::LoadRegistryData()
+{
+ TRACE("CBeautifySettingDlg::LoadRegistryData() - Loading options from registry");
+
+ Visio::IVPagePtr page = m_vsoApp->ActivePage;
+#define _u(x) CPageUtils::ConvertUnits(page, x, 0, visPageUnits)
+
+ m_incomplete_msg_value_imp = GetRegistry<float>(GetRegistryFolder(), NULL, _T("IncompleteMsgValueImport"), 20);
+ m_head_dist_value_imp = GetRegistry<float>(GetRegistryFolder(), NULL, _T("HeadDistValueImport"), 5);
+ m_begin_cor_dist_value_imp = GetRegistry<float>(GetRegistryFolder(), NULL, _T("BeginCorDistValueImport"), 5);
+ m_end_cor_dist_value_imp = GetRegistry<float>(GetRegistryFolder(), NULL, _T("EndCorDistValueImport"), 5);
+ m_slope_value_imp = GetRegistry<float>(GetRegistryFolder(), NULL, _T("SlopeValueImport"), 0);
+ m_successor_dist_value_imp = GetRegistry<float>(GetRegistryFolder(), NULL, _T("SuccDistValueImport"), 5);
+ m_foot_dist_value_imp = GetRegistry<float>(GetRegistryFolder(), NULL, _T("FootDistValueImport"), 5);
+ m_head_width_value_imp = GetRegistry<float>(GetRegistryFolder(), NULL, _T("HeadValueImport"), 10);
+ m_cor_width_value_imp = GetRegistry<float>(GetRegistryFolder(), NULL, _T("CoregionValueImport"), 10);
+ m_space_value_imp = GetRegistry<float>(GetRegistryFolder(), NULL, _T("SpaceValueImport"), 30);
+#undef _u
+
+ return 0;
+}
+
+void CImportSettingsDlg::UpdateControls()
+{
+}
+
+int CImportSettingsDlg::SaveRegistryData()
+{
+ TRACE("CBeautifySettingDlg::SaveRegistryData() - Saving options to registry");
+
+ Visio::IVPagePtr page = m_vsoApp->ActivePage;
+#define _u(x) CPageUtils::ConvertUnits(page, x, 0, visPageUnits)
+ SetRegistry<>(HKEY_CURRENT_USER, GetRegistryFolder(), _T("HeadValueImport"), (float)m_head_width_value_imp);
+ SetRegistry<>(HKEY_CURRENT_USER, GetRegistryFolder(), _T("CoregionValueImport"), (float)m_cor_width_value_imp);
+ SetRegistry<>(HKEY_CURRENT_USER, GetRegistryFolder(), _T("SpaceValueImport"), (float)m_space_value_imp);
+ SetRegistry<>(HKEY_CURRENT_USER, GetRegistryFolder(), _T("HeadDistValueImport"), (float)m_head_dist_value_imp);
+ SetRegistry<>(HKEY_CURRENT_USER, GetRegistryFolder(), _T("BeginCorDistValueImport"), (float)m_begin_cor_dist_value_imp);
+ SetRegistry<>(HKEY_CURRENT_USER, GetRegistryFolder(), _T("EndCorDistValueImport"), (float)m_end_cor_dist_value_imp);
+ SetRegistry<>(HKEY_CURRENT_USER, GetRegistryFolder(), _T("SlopeValueImport"), (float)m_slope_value_imp);
+ SetRegistry<>(HKEY_CURRENT_USER, GetRegistryFolder(), _T("SuccDistValueImport"), (float)m_successor_dist_value_imp);
+ SetRegistry<>(HKEY_CURRENT_USER, GetRegistryFolder(), _T("FootDistValueImport"), (float)m_foot_dist_value_imp);
+ SetRegistry<>(HKEY_CURRENT_USER, GetRegistryFolder(), _T("IncompleteMsgValueImport"), (float)m_incomplete_msg_value_imp);
+#undef _u
+
+ return 0;
+}
+
+void CImportSettingsDlg::OnDataValidateError(UINT nCtrlID, BOOL bSave, _XData& data)
+{
+ CString sMsg = "";
+
+ switch (nCtrlID) {
+ case IDC_HEAD_WIDTH_VALUE_IMP :
+ case IDC_COR_WIDTH_VALUE_IMP :
+ sMsg.Format(_T("The size of width must be between %d mm and %d mm."),
+ (int)data.floatData.nMin, (int)data.floatData.nMax);
+ break;
+
+ case IDC_HEAD_DIST_VALUE_IMP :
+ sMsg.Format(_T("The distance between the instance begin and the first element must be between %d mm and %d mm."),
+ (int)data.floatData.nMin, (int)data.floatData.nMax );
+ break;
+ case IDC_SLOPE_VALUE_IMP :
+ sMsg.Format(_T("The distance between messages ends must be between %d mm and %d mm."),
+ (int)data.floatData.nMin, (int)data.floatData.nMax );
+ break;
+ case IDC_FOOT_DIST_VALUE_IMP :
+ sMsg.Format(_T("The distance between the last element and the instance end must be between %d mm and %d mm."),
+ (int)data.floatData.nMin, (int)data.floatData.nMax );
+ break;
+ case IDC_SPACE_VALUE_IMP :
+ sMsg.Format(_T("The distance between the instance begin and the first element must be between %d mm and %d mm."),
+ (int)data.floatData.nMin, (int)data.floatData.nMax );
+ break;
+
+ case IDC_BEGIN_COR_DIST_VALUE_IMP :
+ case IDC_END_COR_DIST_VALUE_IMP:
+ sMsg.Format(_T("The distance between the coregion edges and events must be between %d mm and %d mm."),
+ (int)data.floatData.nMin, (int)data.floatData.nMax );
+ break;
+
+ case IDC_SUCCESSOR_DIST_VALUE_IMP:
+ sMsg.Format(_T("The distance between two elements on instance must be between %d mm and %d mm."),
+ (int)data.floatData.nMin, (int)data.floatData.nMax );
+ break;
+
+
+ case IDC_INCOMPLETE_MSG_VALUE_IMP:
+ sMsg.Format(_T("The length of incomplete message must be between %d mm and %d mm."),
+ (int)data.floatData.nMin, (int)data.floatData.nMax );
+ break;
+
+ default:
+ sMsg = "Unknown error";
+ TRACE("CImportSettingsDlg::OnDataValidateError() does not have a validation error message for a control");
+ }
+
+ MessageBox(sMsg, _T("Setting Import Error"), MB_ICONEXCLAMATION);
+}
+
+
+
+
+// $Id:
Added: trunk/src/view/visio/addon/importSettingsDlg.h
===================================================================
--- trunk/src/view/visio/addon/importSettingsDlg.h (rev 0)
+++ trunk/src/view/visio/addon/importSettingsDlg.h 2011-01-04 07:22:38 UTC (rev 1020)
@@ -0,0 +1,114 @@
+/*
+ * 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 Zuzana Pekarcikova <z.p...@gm...>
+ *
+ * $Id: $
+ */
+
+#pragma once
+
+#include <atldlgs.h>
+#include <atlddx.h>
+#include <atlctrls.h>
+#include <atlcrack.h>
+#include <atlmisc.h>
+
+#include "data/msc.h"
+
+
+
+class CImportSettingsDlg
+ : public ATL::CDialogImpl<CImportSettingsDlg>, public CWinDataExchange<CImportSettingsDlg>
+{
+public:
+ enum { IDD = IDD_IMPORT_SETTINGS };
+
+ CImportSettingsDlg(Visio::IVApplicationPtr vsoApp):m_vsoApp(vsoApp) {}
+
+ ~CImportSettingsDlg(){}
+
+ //Registry folder
+ const wchar_t* GetRegistryFolder() { return SCSTUDIO_REGISTRY_ROOT _T("\\Beautify"); }
+
+ float m_head_width_value_imp;
+ float m_cor_width_value_imp;
+ float m_space_value_imp;
+ float m_head_dist_value_imp;
+ float m_begin_cor_dist_value_imp;
+ float m_end_cor_dist_value_imp;
+ float m_slope_value_imp;
+ float m_successor_dist_value_imp;
+ float m_foot_dist_value_imp;
+ float m_incomplete_msg_value_imp;
+
+private:
+ Visio::IVApplicationPtr m_vsoApp;
+
+BEGIN_DDX_MAP(CImportSettingDlg)
+
+ DDX_CONTROL_HANDLE(IDC_HEAD_WIDTH_VALUE_IMP, m_headWidthValueImp)
+ DDX_CONTROL_HANDLE(IDC_COR_WIDTH_VALUE_IMP, m_corWidthValueImp)
+ DDX_CONTROL_HANDLE(IDC_SPACE_VALUE_IMP, m_spaceValueImp)
+ DDX_CONTROL_HANDLE(IDC_HEAD_DIST_VALUE_IMP, m_headDistValueImp)
+ DDX_CONTROL_HANDLE(IDC_BEGIN_COR_DIST_VALUE_IMP, m_beginCorDistValueImp)
+ DDX_CONTROL_HANDLE(IDC_END_COR_DIST_VALUE_IMP, m_endCorDistValueImp)
+ DDX_CONTROL_HANDLE(IDC_SLOPE_VALUE_IMP, m_slopeValueImp)
+ DDX_CONTROL_HANDLE(IDC_SUCCESSOR_DIST_VALUE_IMP, m_successorDistValueImp)
+ DDX_CONTROL_HANDLE(IDC_FOOT_DIST_VALUE_IMP, m_footDistValueImp)
+ DDX_CONTROL_HANDLE(IDC_INCOMPLETE_MSG_VALUE_IMP, m_incompleteMsgValueImp)
+
+
+ DDX_FLOAT_RANGE(IDC_HEAD_WIDTH_VALUE_IMP, m_head_width_value_imp, 0, 500)
+ DDX_FLOAT_RANGE(IDC_COR_WIDTH_VALUE_IMP, m_cor_width_value_imp, 1, 500)
+ DDX_FLOAT_RANGE(IDC_SPACE_VALUE_IMP, m_space_value_imp, 1, 500)
+ DDX_FLOAT_RANGE(IDC_HEAD_DIST_VALUE_IMP, m_head_dist_value_imp, 3, 500)
+ DDX_FLOAT_RANGE(IDC_BEGIN_COR_DIST_VALUE_IMP, m_begin_cor_dist_value_imp, 1, 500)
+ DDX_FLOAT_RANGE(IDC_END_COR_DIST_VALUE_IMP, m_end_cor_dist_value_imp, 1, 500)
+ DDX_FLOAT_RANGE(IDC_SLOPE_VALUE_IMP, m_slope_value_imp, 0, 500)
+ DDX_FLOAT_RANGE(IDC_SUCCESSOR_DIST_VALUE_IMP, m_successor_dist_value_imp, 1, 500)
+ DDX_FLOAT_RANGE(IDC_FOOT_DIST_VALUE_IMP, m_foot_dist_value_imp, 3, 100000)
+ DDX_FLOAT_RANGE(IDC_INCOMPLETE_MSG_VALUE_IMP, m_incomplete_msg_value_imp, 1, 500)
+END_DDX_MAP()
+
+BEGIN_MSG_MAP(CImportSettingDlg)
+ MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
+
+ COMMAND_ID_HANDLER(IDOK, OnCloseCmd)
+ COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd)
+END_MSG_MAP()
+
+ void OnDataValidateError (UINT nCtrlID, BOOL bSave, _XData& data);
+
+ LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+ LRESULT OnCloseCmd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
+
+ int LoadRegistryData();
+ int SaveRegistryData();
+
+ void UpdateControls();
+
+ CEdit m_headWidthValueImp;
+ CEdit m_corWidthValueImp;
+ CEdit m_spaceValueImp;
+ CEdit m_headDistValueImp;
+ CEdit m_beginCorDistValueImp;
+ CEdit m_endCorDistValueImp;
+ CEdit m_slopeValueImp;
+ CEdit m_successorDistValueImp;
+ CEdit m_footDistValueImp;
+ CEdit m_incompleteMsgValueImp;
+};
+
+
+// $Id:
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mbe...@us...> - 2011-02-15 17:34:58
|
Revision: 1040
http://scstudio.svn.sourceforge.net/scstudio/?rev=1040&view=rev
Author: mbezdeka
Date: 2011-02-15 17:34:51 +0000 (Tue, 15 Feb 2011)
Log Message:
-----------
Menu reconfiguration started...
Modified Paths:
--------------
trunk/src/view/visio/addon/dllmodule.rc
trunk/src/view/visio/addon/document.cpp
trunk/src/view/visio/addon/instancesfielddlg.cpp
trunk/src/view/visio/addon/instancesfielddlg.h
trunk/src/view/visio/addon/resource.h
trunk/src/view/visio/addon/scstudio.vcproj
Added Paths:
-----------
trunk/src/view/visio/addon/icon_message_select_group.ico
Modified: trunk/src/view/visio/addon/dllmodule.rc
===================================================================
--- trunk/src/view/visio/addon/dllmodule.rc 2011-02-15 17:15:11 UTC (rev 1039)
+++ trunk/src/view/visio/addon/dllmodule.rc 2011-02-15 17:34:51 UTC (rev 1040)
@@ -165,35 +165,33 @@
CONTROL "Diff",IDC_DIFF,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,253,56,24,10
END
-IDD_INSTANCES_FIELD_OPTIONS DIALOGEX 0, 0, 210, 127
+IDD_INSTANCES_FIELD_OPTIONS DIALOGEX 0, 0, 215, 115
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Add Instances Options"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
- DEFPUSHBUTTON "OK",IDOK,155,5,50,14
- PUSHBUTTON "Cancel",IDCANCEL,155,25,50,14
+ DEFPUSHBUTTON "OK",IDOK,158,5,52,14
+ PUSHBUTTON "Cancel",IDCANCEL,158,25,52,14
LTEXT "Number of instances:",IDC_STATIC,5,5,70,12,SS_CENTERIMAGE
EDITTEXT IDC_IF_INSTANCES_CNT,80,5,43,14,ES_AUTOHSCROLL
- GROUPBOX "",IDC_OPTIONS_GROUP_BOX,5,73,200,50
- LTEXT " Options ",IDC_OPTIONS_SWITCH_LBL,19,73,30,8
+ GROUPBOX "",IDC_OPTIONS_GROUP_BOX,5,70,205,40
LTEXT "Instance length:",IDC_STATIC,5,23,70,12,SS_CENTERIMAGE
EDITTEXT IDC_IF_INSTANCE_LENGTH,80,23,43,14,ES_AUTOHSCROLL
LTEXT "Start position:",IDC_STATIC,5,40,50,12,SS_CENTERIMAGE
EDITTEXT IDC_IF_START_POS_X,80,40,43,14,ES_AUTOHSCROLL
- EDITTEXT IDC_IF_START_POS_Y,80,54,43,14,ES_AUTOHSCROLL
- PUSHBUTTON "+",IDC_OPTIONS_SWITCH_BTN,5,73,10,10
- CONTROL "Total width:",IDC_TOTAL_WIDTH_RDO,"Button",BS_AUTORADIOBUTTON,10,89,54,10
- CONTROL "Spacing:",IDC_SPACING_RDO,"Button",BS_AUTORADIOBUTTON,10,104,43,10
- EDITTEXT IDC_IF_TOTAL_WIDTH,63,88,40,14,ES_AUTOHSCROLL
- EDITTEXT IDC_IF_SPACING,63,103,40,14,ES_AUTOHSCROLL
- PUSHBUTTON "Default values",IDC_DEFAULT_BTN,140,88,58,14
+ EDITTEXT IDC_IF_START_POS_Y,80,55,43,14,ES_AUTOHSCROLL
+ CONTROL "Total width:",IDC_TOTAL_WIDTH_RDO,"Button",BS_AUTORADIOBUTTON,10,79,54,10
+ CONTROL "Spacing:",IDC_SPACING_RDO,"Button",BS_AUTORADIOBUTTON,10,94,43,10
+ EDITTEXT IDC_IF_TOTAL_WIDTH,80,78,43,14,ES_AUTOHSCROLL
+ EDITTEXT IDC_IF_SPACING,80,93,43,14,ES_AUTOHSCROLL
+ PUSHBUTTON "Default values",IDC_DEFAULT_BTN,158,47,52,14
LTEXT "x:",IDC_STATIC,64,40,9,12,SS_CENTERIMAGE
- LTEXT "y:",IDC_STATIC,64,54,9,12,SS_CENTERIMAGE
+ LTEXT "y:",IDC_STATIC,64,55,9,12,SS_CENTERIMAGE
LTEXT "<units>",IDC_IF_UNITS0,127,24,27,8
LTEXT "<units>",IDC_IF_UNITS1,127,41,27,8
- LTEXT "<units>",IDC_IF_UNITS2,127,55,27,8
- LTEXT "<units>",IDC_IF_UNITS3,107,90,27,8
- LTEXT "<units>",IDC_IF_UNITS4,107,104,27,8
+ LTEXT "<units>",IDC_IF_UNITS2,127,56,27,8
+ LTEXT "<units>",IDC_IF_UNITS3,128,81,27,8
+ LTEXT "<units>",IDC_IF_UNITS4,127,95,27,8
END
IDD_ENUMERATION_OPTIONS DIALOGEX 0, 0, 236, 63
@@ -320,7 +318,7 @@
IDD_INSTANCES_FIELD_OPTIONS, DIALOG
BEGIN
LEFTMARGIN, 5
- RIGHTMARGIN, 205
+ RIGHTMARGIN, 210
VERTGUIDE, 10
VERTGUIDE, 19
VERTGUIDE, 48
@@ -328,7 +326,7 @@
VERTGUIDE, 123
VERTGUIDE, 130
TOPMARGIN, 5
- BOTTOMMARGIN, 122
+ BOTTOMMARGIN, 110
HORZGUIDE, 54
END
@@ -400,6 +398,7 @@
IDI_ICON_JUMP_RIGHT ICON "icon_jump_right_messages.ico"
IDI_ICON_JUMP_LEFT_COPY ICON "icon_jump_left_messages_copy.ico"
IDI_ICON_JUMP_RIGHT_COPY ICON "icon_jump_right_messages_copy.ico"
+IDI_ICON_SELECT_GROUP ICON "icon_message_select_group.ico"
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
Modified: trunk/src/view/visio/addon/document.cpp
===================================================================
--- trunk/src/view/visio/addon/document.cpp 2011-02-15 17:15:11 UTC (rev 1039)
+++ trunk/src/view/visio/addon/document.cpp 2011-02-15 17:34:51 UTC (rev 1040)
@@ -377,7 +377,7 @@
Visio::IVMenuSetPtr menuSet = vsoMenus->MenuSets->ItemAtID[Visio::visUIObjSetDrawing];
Visio::IVMenuPtr menu = menuSet->Menus->AddAt(5);
- menu->Caption = "&Check";
+ menu->Caption = "&SCStudio";
// many functions are not working in OLE window: repaint, import, error display
// disable verification functions when opened from OLE window
menu->Enabled = !m_vsoDocument->InPlace;
@@ -385,12 +385,7 @@
std::basic_string<TCHAR> vslFileName = GetVisioModuleFileName();
std::basic_string<TCHAR> vslIconFile;
- Visio::IVMenuItemPtr itemWindows = menu->MenuItems->Add();
- itemWindows->Caption = "&Windows";
- itemWindows->BeginGroup = true;
- itemWindows->CmdNum = Visio::visCmdHierarchical;
-
- m_reportMenuItem = itemWindows->MenuItems->Add();
+ m_reportMenuItem = menu->MenuItems->Add();
m_reportMenuItem->Caption = "Verification &Report";
m_reportMenuItem->AddOnName = ADDON_NAME;
m_reportMenuItem->AddOnArgs = stringize() << L"/event=" << MENU_WINDOWS_REPORTER;
@@ -455,6 +450,8 @@
itemRepaint->AddOnArgs = stringize() << L"/event=" << MENU_REPAINT;
itemRepaint->BeginGroup = true;
+ //Add pointers for accelerators
+ short beautify = -1;
for(TransformerPtrList::const_iterator tpos = m_transformers.begin();
tpos != m_transformers.end(); tpos++)
{
@@ -464,6 +461,9 @@
// note: event numbers 300-399 are reserved for transformers
menuItem3x->AddOnArgs =
stringize() << L"/event=" << 300+(tpos-m_transformers.begin());
+ //Make asociation with accelerator (Do it for every item you wnat shortcut to)
+ if(!strcmp(menuItem3x->Caption,"Beautify"))
+ beautify = menuItem3x->CmdNum;
}
Visio::IVMenuItemPtr itemEnableEnumerating = itemMessageEnumerating->MenuItems->Add();
@@ -480,6 +480,14 @@
vslIconFile = vslFileName+_T(",9");
itemDisableEnumerating->IconFileName(vslIconFile.c_str());
+ Visio::IVMenuItemPtr itemSelectNumberingGroup = itemMessageEnumerating->MenuItems->Add();
+ itemSelectNumberingGroup->Caption = "&Select numbering group";
+ itemSelectNumberingGroup->AddOnName = ADDON_NAME;
+ itemSelectNumberingGroup->AddOnArgs = stringize() << L"/event=" << MENU_SELECT_NUMBERED_GROUP;
+ //TODO: Add icon
+ //vslIconFile = vslFileName+_T(",9");
+ //itemDisableEnumerating->IconFileName(vslIconFile.c_str());
+
Visio::IVMenuItemPtr itemFindFlow = menu->MenuItems->Add();
itemFindFlow->Caption = "&Find Flow...";
itemFindFlow->AddOnName = ADDON_NAME;
@@ -550,42 +558,63 @@
// note: the accelerators must be created in this custom menu set
// note: the accelerators are bound with menu items via CmdNum property
Visio::IVAccelTablePtr accelTable = vsoMenus->AccelTables->ItemAtID[Visio::visUIObjSetDrawing];
-
+ //Select Instances
Visio::IVAccelItemPtr accelItemSelectInstances = accelTable->AccelItems->Add();
accelItemSelectInstances->CmdNum = itemSelectInstances->CmdNum;
accelItemSelectInstances->Key = 'I';
accelItemSelectInstances->Control = true;
accelItemSelectInstances->Alt = true;
-
+ //Select Messages
Visio::IVAccelItemPtr accelItemSelectMessages = accelTable->AccelItems->Add();
accelItemSelectMessages->CmdNum = itemSelectMessages->CmdNum;
accelItemSelectMessages->Key = 'M';
accelItemSelectMessages->Control = true;
accelItemSelectMessages->Alt = true;
-
+ //Add Instances
Visio::IVAccelItemPtr accelItemAddInstances = accelTable->AccelItems->Add();
accelItemAddInstances->CmdNum = itemAddInstances->CmdNum;
accelItemAddInstances->Key = 'F';
accelItemAddInstances->Control = true;
accelItemAddInstances->Alt = true;
-
+ //Message Sequence
Visio::IVAccelItemPtr accelItemMessageSequence = accelTable->AccelItems->Add();
accelItemMessageSequence->CmdNum = itemMessageSequence->CmdNum;
accelItemMessageSequence->Key = 'S';
accelItemMessageSequence->Control = true;
accelItemMessageSequence->Alt = true;
-
+ //Enable message numbering
accelItemMessageEnumeration = accelTable->AccelItems->Add();
accelItemMessageEnumeration->CmdNum = itemEnableEnumerating->CmdNum;
accelItemMessageEnumeration->Key = 'E';
accelItemMessageEnumeration->Control = true;
accelItemMessageEnumeration->Alt = true;
-
+ //Disable message numbering
accelItemMessageEnumerationDisable = accelTable->AccelItems->Add();
accelItemMessageEnumerationDisable->CmdNum = itemDisableEnumerating->CmdNum;
accelItemMessageEnumerationDisable->Key = 'D';
accelItemMessageEnumerationDisable->Control = true;
accelItemMessageEnumerationDisable->Alt = true;
+ //Select numbering group
+ Visio::IVAccelItemPtr accelItemSelectNumberingGroup = accelTable->AccelItems->Add();
+ accelItemSelectNumberingGroup->CmdNum = itemSelectNumberingGroup->CmdNum;
+ accelItemSelectNumberingGroup->Key = 'N';
+ accelItemSelectNumberingGroup->Control = true;
+ accelItemSelectNumberingGroup->Alt = true;
+ //Verify
+ Visio::IVAccelItemPtr accelItemVerify = accelTable->AccelItems->Add();
+ accelItemVerify->CmdNum = itemVerify->CmdNum;
+ accelItemVerify->Key = 'V';
+ accelItemVerify->Control = true;
+ accelItemVerify->Alt = true;
+ //Transforms shortcuts
+ if(beautify >= 0)
+ {
+ Visio::IVAccelItemPtr accelItemBeutify = accelTable->AccelItems->Add();
+ accelItemBeutify->CmdNum = beautify;
+ accelItemBeutify->Key = 'B';
+ accelItemBeutify->Control = true;
+ accelItemBeutify->Alt = true;
+ }
m_vsoDocument->SetCustomMenus(vsoMenus);
}
@@ -725,6 +754,15 @@
vslIconFile = vslFileName+_T(",9");
m_disableMessageEnumerationToolbarItem->IconFileName(vslIconFile.c_str());
+ Visio::IVToolbarItemPtr selectNumberingGroup = m_toolbar->ToolbarItems->Add();
+ selectNumberingGroup->Caption = "Select Numbering Group";
+ selectNumberingGroup->AddOnName = ADDON_NAME;
+ selectNumberingGroup->AddOnArgs = stringize() << L"/event=" << MENU_SELECT_NUMBERED_GROUP;
+ selectNumberingGroup->Visible = true;
+ selectNumberingGroup->Enabled = true;
+ vslIconFile = vslFileName+_T(",14");
+ selectNumberingGroup->IconFileName(vslIconFile.c_str());
+
Visio::IVToolbarItemPtr itemVerify = m_toolbar->ToolbarItems->Add();
itemVerify->Caption = "Verify";
itemVerify->AddOnName = ADDON_NAME;
@@ -1836,8 +1874,12 @@
VAORC CDocumentMonitor::OnMenuSelectNumberedGroup(Visio::IVApplicationPtr vsoApp)
{
- CEnumerateUtils::selectGroup(vsoApp,vsoApp->ActiveWindow->Selection->Item[1]->Data3);
+ Visio::IVSelectionPtr selection = vsoApp->ActiveWindow->Selection;
+ if(selection->Count == 0 || !strcmp(selection->Item[1]->Data3,""))
+ return VAORC_FAILURE;
+ CEnumerateUtils::selectGroup(vsoApp,selection->Item[1]->Data3);
+
return VAORC_SUCCESS;
}
Added: trunk/src/view/visio/addon/icon_message_select_group.ico
===================================================================
(Binary files differ)
Property changes on: trunk/src/view/visio/addon/icon_message_select_group.ico
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/src/view/visio/addon/instancesfielddlg.cpp
===================================================================
--- trunk/src/view/visio/addon/instancesfielddlg.cpp 2011-02-15 17:15:11 UTC (rev 1039)
+++ trunk/src/view/visio/addon/instancesfielddlg.cpp 2011-02-15 17:34:51 UTC (rev 1040)
@@ -65,7 +65,6 @@
}
DoDataExchange(false);
- SetOptionsVisibility(m_optionsVisible);
UpdateSpacingControls();
// units
@@ -95,13 +94,6 @@
return 0;
}
-LRESULT CInstancesFieldDlg::OnOptionsSwitch(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
-{
- m_optionsVisible = !m_optionsVisible;
- SetOptionsVisibility(m_optionsVisible);
- return 0;
-}
-
void CInstancesFieldDlg::UpdateSpacingControls()
{
m_totalWidthRdo.SetCheck(m_use_const_spacing ? BST_UNCHECKED : BST_CHECKED);
@@ -146,44 +138,6 @@
return 0;
}
-
-void CInstancesFieldDlg::SetOptionsVisibility(bool visible)
-{
- m_optionsSwitchBtn.SetWindowText((visible ? _T("-") : _T("+")));
-
- CWindow window = m_optionsGroupBox.GetParent();
- RECT windowRect;
- window.GetWindowRect(&windowRect);
- windowRect.bottom = windowRect.top + (visible ? 225 : 165);
- window.SetWindowPos(0, &windowRect, SWP_SHOWWINDOW | SWP_NOZORDER | SWP_DRAWFRAME);
-
- RECT groupRect;
- m_optionsGroupBox.GetWindowRect(&groupRect);
- m_optionsGroupBox.ScreenToClient(&groupRect);
- // relative to the dialog window
- groupRect.top = 120;
- groupRect.bottom = groupRect.top + (visible ? 76 : 8);
- groupRect.left = 8;
- groupRect.right = 308;
- m_optionsGroupBox.SetWindowPos(0, &groupRect, SWP_SHOWWINDOW | SWP_NOZORDER | SWP_DRAWFRAME);
-
- m_totalWidthRdo.ShowWindow(visible);
- m_spacingRdo.ShowWindow(visible);
- m_totalWidthEdit.ShowWindow(visible);
- m_spacingEdit.ShowWindow(visible);
- m_defaultValuesBtn.ShowWindow(visible);
-
- if (visible) {
- if (m_use_const_spacing) {
- m_spacingRdo.SetFocus();
- } else {
- m_totalWidthRdo.SetFocus();
- }
- } else {
- m_instancesCntEdit.SetFocus();
- }
-}
-
int CInstancesFieldDlg::LoadRegistryData()
{
TRACE("CInstancesFieldDlg::LoadRegistryData() loading options from registry");
@@ -198,7 +152,6 @@
m_use_const_spacing = GetRegistry<bool> (GetRegistryFolder(), NULL, _T("SpacingSwitch"), DEFAULT_IF_SPACING_SWITCH);
m_total_width = _u(GetRegistry<double>(GetRegistryFolder(), NULL, _T("TotalWidth"), DEFAULT_IF_TOTAL_WIDTH));
m_spacing = _u(GetRegistry<double>(GetRegistryFolder(), NULL, _T("Spacing"), DEFAULT_IF_SPACING));
- m_optionsVisible = GetRegistry<bool> (GetRegistryFolder(), NULL, _T("OptionsVisible"), DEFAULT_IF_OPTIONS_VISIBLE);
#undef _u
return 0;
@@ -218,7 +171,6 @@
SetRegistry<bool> (HKEY_CURRENT_USER, GetRegistryFolder(), _T("SpacingSwitch"), m_use_const_spacing);
SetRegistry<double>(HKEY_CURRENT_USER, GetRegistryFolder(), _T("TotalWidth"), _u(m_total_width));
SetRegistry<double>(HKEY_CURRENT_USER, GetRegistryFolder(), _T("Spacing"), _u(m_spacing));
- SetRegistry<bool> (HKEY_CURRENT_USER, GetRegistryFolder(), _T("OptionsVisible"), m_optionsVisible);
#undef _u
return 0;
Modified: trunk/src/view/visio/addon/instancesfielddlg.h
===================================================================
--- trunk/src/view/visio/addon/instancesfielddlg.h 2011-02-15 17:15:11 UTC (rev 1039)
+++ trunk/src/view/visio/addon/instancesfielddlg.h 2011-02-15 17:34:51 UTC (rev 1040)
@@ -65,7 +65,6 @@
DDX_CONTROL_HANDLE(IDC_IF_INSTANCES_CNT, m_instancesCntEdit)
DDX_CONTROL_HANDLE(IDC_OPTIONS_GROUP_BOX, m_optionsGroupBox)
- DDX_CONTROL_HANDLE(IDC_OPTIONS_SWITCH_BTN, m_optionsSwitchBtn)
DDX_CONTROL_HANDLE(IDC_TOTAL_WIDTH_RDO, m_totalWidthRdo)
DDX_CONTROL_HANDLE(IDC_SPACING_RDO, m_spacingRdo)
DDX_CONTROL_HANDLE(IDC_DEFAULT_BTN, m_defaultValuesBtn)
@@ -82,7 +81,6 @@
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
COMMAND_ID_HANDLER(IDOK, OnCloseCmd)
COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd)
- COMMAND_ID_HANDLER(IDC_OPTIONS_SWITCH_BTN, OnOptionsSwitch)
// FIXME: would like to make the label switch the options as well, but the following does not work:
//COMMAND_ID_HANDLER(IDC_OPTIONS_SWITCH_LBL, OnOptionsSwitch)
COMMAND_ID_HANDLER(IDC_TOTAL_WIDTH_RDO, OnTotalWidthRdo)
@@ -99,7 +97,6 @@
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnCloseCmd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
- LRESULT OnOptionsSwitch(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnTotalWidthRdo(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnSpacingRdo(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnDefaultCmd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
@@ -107,12 +104,9 @@
int LoadRegistryData();
int SaveRegistryData();
- void SetOptionsVisibility(bool visible);
void UpdateSpacingControls();
CStatic m_optionsGroupBox;
- bool m_optionsVisible;
- CButton m_optionsSwitchBtn;
CButton m_totalWidthRdo;
CButton m_spacingRdo;
CButton m_defaultValuesBtn;
@@ -132,7 +126,6 @@
static const int DEFAULT_IF_SPACING_SWITCH = true;
static const double DEFAULT_IF_TOTAL_WIDTH = 7.8740157480314960; // 200 mm
static const double DEFAULT_IF_SPACING = 1.1811023622047244094; // 30 mm
-static const bool DEFAULT_IF_OPTIONS_VISIBLE = false;
static const double IF_BORDER = 0.0787401574803149; // 2 mm border for the default command
// $Id$
Modified: trunk/src/view/visio/addon/resource.h
===================================================================
--- trunk/src/view/visio/addon/resource.h 2011-02-15 17:15:11 UTC (rev 1039)
+++ trunk/src/view/visio/addon/resource.h 2011-02-15 17:34:51 UTC (rev 1040)
@@ -94,6 +94,8 @@
#define IDB_IMPORT_DISTANCES_BMP 255
#define IDC_MS_YSTART 256
#define IDC_MS_START_POS_Y 256
+#define IDI_ICON1 256
+#define IDI_ICON_SELECT_GROUP 256
#define IDC_MS_VERTICAL_SPACE 257
#define IDC_MS_DIR_RIGHT_LEFT 258
#define IDC_MS_VERTICAL_SPACE2 259
@@ -178,7 +180,7 @@
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 256
+#define _APS_NEXT_RESOURCE_VALUE 257
#define _APS_NEXT_COMMAND_VALUE 32768
#define _APS_NEXT_CONTROL_VALUE 341
#define _APS_NEXT_SYMED_VALUE 105
Modified: trunk/src/view/visio/addon/scstudio.vcproj
===================================================================
--- trunk/src/view/visio/addon/scstudio.vcproj 2011-02-15 17:15:11 UTC (rev 1039)
+++ trunk/src/view/visio/addon/scstudio.vcproj 2011-02-15 17:34:51 UTC (rev 1040)
@@ -602,6 +602,10 @@
>
</File>
<File
+ RelativePath=".\icon_message_select_group.ico"
+ >
+ </File>
+ <File
RelativePath=".\icon_select_add_instances.ico"
>
</File>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mbe...@us...> - 2011-03-18 00:43:31
|
Revision: 1065
http://scstudio.svn.sourceforge.net/scstudio/?rev=1065&view=rev
Author: mbezdeka
Date: 2011-03-18 00:43:24 +0000 (Fri, 18 Mar 2011)
Log Message:
-----------
Menu reconfiguration:
- new buttons for beutify, tighten time, flip msg direction, add instances, message sequence, select numbering group
- Fixed bug #3198234 - Shortcut changed to Ctrl-Atl-C
- Shortcuts for beautify, select numbering group
Modified Paths:
--------------
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/resource.h
trunk/src/view/visio/addon/scstudio.vcproj
Added Paths:
-----------
trunk/src/view/visio/addon/icon_add_instances.ico
trunk/src/view/visio/addon/icon_beautify.ico
trunk/src/view/visio/addon/icon_message_sequence.ico
trunk/src/view/visio/addon/icon_reverse_message.ico
trunk/src/view/visio/addon/icon_tighten_time.ico
Modified: trunk/src/view/visio/addon/dllmodule.rc
===================================================================
--- trunk/src/view/visio/addon/dllmodule.rc 2011-03-17 13:42:42 UTC (rev 1064)
+++ trunk/src/view/visio/addon/dllmodule.rc 2011-03-18 00:43:24 UTC (rev 1065)
@@ -399,6 +399,11 @@
IDI_ICON_JUMP_LEFT_COPY ICON "icon_jump_left_messages_copy.ico"
IDI_ICON_JUMP_RIGHT_COPY ICON "icon_jump_right_messages_copy.ico"
IDI_ICON_SELECT_GROUP ICON "icon_message_select_group.ico"
+IDI_ICON_BEAUTIFY ICON "icon_beautify.ico"
+IDI_ICON_MESSAGE_SEQUENCE ICON "icon_message_sequence.ico"
+IDI_ICON_REVERSE_MESSAGE ICON "icon_reverse_message.ico"
+IDI_ICON_TIGHTEN_TIME ICON "icon_tighten_time.ico"
+IDI_ICON_ADD_INSTANCES ICON "icon_add_instances.ico"
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
@@ -529,7 +534,7 @@
CONTROL 251,IDC_STATIC,"Static",SS_BITMAP,21,34,236,228
GROUPBOX " arranging messages and coregions, setting the length of incomplete",IDC_STATIC,264,7,248,75
LTEXT "message (a) and setting the instances length to",IDC_STATIC,276,18,154,8
- CONTROL "",IDC_ARRANGING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,266,6,10,10
+ CONTROL "",IDC_ARRANGING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,266,7,10,10
CONTROL "constant value (b)",IDC_CONST_INSTANCE_RDO,"Button",BS_AUTORADIOBUTTON | WS_GROUP,276,29,75,10
CONTROL "the first occurrence in diagram",IDC_FIRST_INSTANCE_RDO,
"Button",BS_AUTORADIOBUTTON,276,42,113,10
@@ -598,7 +603,7 @@
VERTGUIDE, 264
VERTGUIDE, 266
VERTGUIDE, 276
- TOPMARGIN, 6
+ TOPMARGIN, 7
BOTTOMMARGIN, 301
END
END
Modified: trunk/src/view/visio/addon/document.cpp
===================================================================
--- trunk/src/view/visio/addon/document.cpp 2011-03-17 13:42:42 UTC (rev 1064)
+++ trunk/src/view/visio/addon/document.cpp 2011-03-18 00:43:24 UTC (rev 1065)
@@ -78,6 +78,9 @@
m_reportVisible = false;
m_reportView = new CReportView(this);
+ beautifyIndex = -1;
+ tightenTimeIndex = -1;
+
m_configProvider = new RegistryConfigProvider();
LoadModulesFromRegistry(HKEY_LOCAL_MACHINE);
@@ -415,12 +418,23 @@
itemAddInstances->AddOnName = ADDON_NAME;
itemAddInstances->AddOnArgs = stringize() << L"/event=" << MENU_ADD_INSTANCES;
itemAddInstances->BeginGroup = true;
+ vslIconFile = vslFileName+_T(",19");
+ itemAddInstances->IconFileName(vslIconFile.c_str());
Visio::IVMenuItemPtr itemMessageSequence = itemDrawing->MenuItems->Add();
itemMessageSequence->Caption = "&Message Sequence...";
itemMessageSequence->AddOnName = ADDON_NAME;
itemMessageSequence->AddOnArgs = stringize() << L"/event=" << MENU_MESSAGE_SEQUENCE;
+ vslIconFile = vslFileName+_T(",16");
+ itemMessageSequence->IconFileName(vslIconFile.c_str());
+ Visio::IVMenuItemPtr itemFlipMsgDirection = itemDrawing->MenuItems->Add();
+ itemFlipMsgDirection->Caption = "&Flip message Direction";
+ itemFlipMsgDirection->AddOnName = ADDON_NAME;
+ itemFlipMsgDirection->AddOnArgs = stringize() << L"/event=" << MENU_FLIP_MESSAGE_DIRECTION;
+ vslIconFile = vslFileName+_T(",17");
+ itemFlipMsgDirection->IconFileName(vslIconFile.c_str());
+
itemMessageEnumerating = itemDrawing->MenuItems->Add();
itemMessageEnumerating->Caption = "Message &numbering";
//itemMessageEnumerating->BeginGroup = true;
@@ -450,8 +464,6 @@
itemRepaint->AddOnArgs = stringize() << L"/event=" << MENU_REPAINT;
itemRepaint->BeginGroup = true;
- //Add pointers for accelerators
- short beautify = -1;
for(TransformerPtrList::const_iterator tpos = m_transformers.begin();
tpos != m_transformers.end(); tpos++)
{
@@ -461,9 +473,20 @@
// note: event numbers 300-399 are reserved for transformers
menuItem3x->AddOnArgs =
stringize() << L"/event=" << 300+(tpos-m_transformers.begin());
- //Make asociation with accelerator (Do it for every item you wnat shortcut to)
+ //Make asociation with accelerator (Do it for every item you want shortcut to) and toolbar icon index
+ vslIconFile = L"";
if(!strcmp(menuItem3x->Caption,"Beautify"))
- beautify = menuItem3x->CmdNum;
+ {
+ beautifyCmdNum = menuItem3x->CmdNum;
+ beautifyIndex = tpos-m_transformers.begin();
+ vslIconFile = vslFileName+_T(",15");
+ }
+ else if(!strcmp(menuItem3x->Caption,"Tighten Time"))
+ {
+ tightenTimeIndex = tpos-m_transformers.begin();
+ vslIconFile = vslFileName+_T(",18");
+ }
+ menuItem3x->IconFileName(vslIconFile.c_str());
}
Visio::IVMenuItemPtr itemEnableEnumerating = itemMessageEnumerating->MenuItems->Add();
@@ -484,9 +507,8 @@
itemSelectNumberingGroup->Caption = "&Select numbering group";
itemSelectNumberingGroup->AddOnName = ADDON_NAME;
itemSelectNumberingGroup->AddOnArgs = stringize() << L"/event=" << MENU_SELECT_NUMBERED_GROUP;
- //TODO: Add icon
- //vslIconFile = vslFileName+_T(",9");
- //itemDisableEnumerating->IconFileName(vslIconFile.c_str());
+ vslIconFile = vslFileName+_T(",14");
+ itemSelectNumberingGroup->IconFileName(vslIconFile.c_str());
Visio::IVMenuItemPtr itemFindFlow = menu->MenuItems->Add();
itemFindFlow->Caption = "&Find Flow...";
@@ -600,17 +622,23 @@
accelItemSelectNumberingGroup->Key = 'N';
accelItemSelectNumberingGroup->Control = true;
accelItemSelectNumberingGroup->Alt = true;
+ //Flip message direction
+ Visio::IVAccelItemPtr accelItemFlipMsgDirection = accelTable->AccelItems->Add();
+ accelItemFlipMsgDirection->CmdNum = itemFlipMsgDirection->CmdNum;
+ accelItemFlipMsgDirection->Key = 0x08;
+ accelItemFlipMsgDirection->Control = false;
+ accelItemFlipMsgDirection->Alt = false;
//Verify
Visio::IVAccelItemPtr accelItemVerify = accelTable->AccelItems->Add();
accelItemVerify->CmdNum = itemVerify->CmdNum;
- accelItemVerify->Key = 'V';
+ accelItemVerify->Key = 'C';
accelItemVerify->Control = true;
accelItemVerify->Alt = true;
//Transforms shortcuts
- if(beautify >= 0)
+ if(beautifyIndex >= 0)
{
Visio::IVAccelItemPtr accelItemBeutify = accelTable->AccelItems->Add();
- accelItemBeutify->CmdNum = beautify;
+ accelItemBeutify->CmdNum = beautifyCmdNum;
accelItemBeutify->Key = 'B';
accelItemBeutify->Control = true;
accelItemBeutify->Alt = true;
@@ -762,7 +790,53 @@
selectNumberingGroup->Enabled = true;
vslIconFile = vslFileName+_T(",14");
selectNumberingGroup->IconFileName(vslIconFile.c_str());
+ //Beautify
+ if(beautifyIndex >= 0)
+ {
+ Visio::IVToolbarItemPtr itemBeautify = m_toolbar->ToolbarItems->Add();
+ itemBeautify->Caption = "Beautify";
+ itemBeautify->AddOnName = ADDON_NAME;
+ itemBeautify->AddOnArgs = stringize() << L"/event=" << 300 + beautifyIndex;
+ vslIconFile = vslFileName+_T(",15");
+ itemBeautify->IconFileName(vslIconFile.c_str());
+ itemBeautify->BeginGroup = true;
+ }
+ //Tighten time
+ if(tightenTimeIndex >= 0)
+ {
+ Visio::IVToolbarItemPtr itemTightenTime = m_toolbar->ToolbarItems->Add();
+ itemTightenTime->Caption = "Tighten Time";
+ itemTightenTime->AddOnName = ADDON_NAME;
+ itemTightenTime->AddOnArgs = stringize() << L"/event=" << 300 + tightenTimeIndex;
+ vslIconFile = vslFileName+_T(",18");
+ itemTightenTime->IconFileName(vslIconFile.c_str());
+ itemTightenTime->BeginGroup = (beautifyIndex >= 0) ? false : true;
+ }
+ //Flip message direction
+ Visio::IVToolbarItemPtr itemFlipMessageDir = m_toolbar->ToolbarItems->Add();
+ itemFlipMessageDir->Caption = "Flip Message Direction";
+ itemFlipMessageDir->AddOnName = ADDON_NAME;
+ itemFlipMessageDir->AddOnArgs = stringize() << L"/event=" << MENU_FLIP_MESSAGE_DIRECTION;
+ vslIconFile = vslFileName+_T(",17");
+ itemFlipMessageDir->IconFileName(vslIconFile.c_str());
+ itemFlipMessageDir->BeginGroup = true;
+ //Message sequence
+ Visio::IVToolbarItemPtr itemMsgSequence = m_toolbar->ToolbarItems->Add();
+ itemMsgSequence->Caption = "Message Sequence";
+ itemMsgSequence->AddOnName = ADDON_NAME;
+ itemMsgSequence->AddOnArgs = stringize() << L"/event=" << MENU_MESSAGE_SEQUENCE;
+ vslIconFile = vslFileName+_T(",16");
+ itemMsgSequence->IconFileName(vslIconFile.c_str());
+
+ //Add instance
+ Visio::IVToolbarItemPtr itemAddInstances = m_toolbar->ToolbarItems->Add();
+ itemAddInstances->Caption = "Add Instances";
+ itemAddInstances->AddOnName = ADDON_NAME;
+ itemAddInstances->AddOnArgs = stringize() << L"/event=" << MENU_ADD_INSTANCES;
+ vslIconFile = vslFileName+_T(",19");
+ itemAddInstances->IconFileName(vslIconFile.c_str());
+
Visio::IVToolbarItemPtr itemVerify = m_toolbar->ToolbarItems->Add();
itemVerify->Caption = "Verify";
itemVerify->AddOnName = ADDON_NAME;
Modified: trunk/src/view/visio/addon/document.h
===================================================================
--- trunk/src/view/visio/addon/document.h 2011-03-17 13:42:42 UTC (rev 1064)
+++ trunk/src/view/visio/addon/document.h 2011-03-18 00:43:24 UTC (rev 1065)
@@ -190,6 +190,10 @@
TransformerPtrList m_transformers;
TransformerPtrList::const_iterator find_transformer(const std::wstring& name) const;
+ short beautifyIndex;
+ short beautifyCmdNum;
+ short tightenTimeIndex;
+
MscPtr run_transformers(MscPtr& msc, const TransformerPtrList& transformer_list);
MeasurementMap m_marker_measurements;
Added: trunk/src/view/visio/addon/icon_add_instances.ico
===================================================================
(Binary files differ)
Property changes on: trunk/src/view/visio/addon/icon_add_instances.ico
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/src/view/visio/addon/icon_beautify.ico
===================================================================
(Binary files differ)
Property changes on: trunk/src/view/visio/addon/icon_beautify.ico
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/src/view/visio/addon/icon_message_sequence.ico
===================================================================
(Binary files differ)
Property changes on: trunk/src/view/visio/addon/icon_message_sequence.ico
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/src/view/visio/addon/icon_reverse_message.ico
===================================================================
(Binary files differ)
Property changes on: trunk/src/view/visio/addon/icon_reverse_message.ico
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/src/view/visio/addon/icon_tighten_time.ico
===================================================================
(Binary files differ)
Property changes on: trunk/src/view/visio/addon/icon_tighten_time.ico
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/src/view/visio/addon/resource.h
===================================================================
--- trunk/src/view/visio/addon/resource.h 2011-03-17 13:42:42 UTC (rev 1064)
+++ trunk/src/view/visio/addon/resource.h 2011-03-18 00:43:24 UTC (rev 1065)
@@ -97,10 +97,15 @@
#define IDI_ICON1 256
#define IDI_ICON_SELECT_GROUP 256
#define IDC_MS_VERTICAL_SPACE 257
+#define IDI_ICON_BEAUTIFY 257
#define IDC_MS_DIR_RIGHT_LEFT 258
+#define IDI_ICON_MESSAGE_SEQUENCE 258
#define IDC_MS_VERTICAL_SPACE2 259
#define IDC_MS_VERTICAL_SPACE_LEFT_RIGHT 259
+#define IDI_ICON_REVERSE_MESSAGE 259
#define IDC_MS_UNITS0 260
+#define IDI_ICON6 260
+#define IDI_ICON_TIGHTEN_TIME 260
#define IDC_MS_UNITS1 261
#define IDC_IF_UNITS0 261
#define IDC_MS_UNITS2 262
@@ -115,6 +120,8 @@
#define IDC_NEAREST_NUMBERED_MSG 265
#define IDC_PRESERVE_SLOPE 265
#define IDC_ORIGINAL_INSTANCE_RDO 265
+#define IDI_ICON3 265
+#define IDI_ICON_ADD_INSTANCES 265
#define IDC_IF_UNITS2 267
#define IDC_IF_UNITS3 268
#define IDC_MS_CONNECT_WITH_LINE 268
@@ -180,9 +187,9 @@
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 257
+#define _APS_NEXT_RESOURCE_VALUE 267
#define _APS_NEXT_COMMAND_VALUE 32768
-#define _APS_NEXT_CONTROL_VALUE 341
+#define _APS_NEXT_CONTROL_VALUE 342
#define _APS_NEXT_SYMED_VALUE 105
#endif
#endif
Modified: trunk/src/view/visio/addon/scstudio.vcproj
===================================================================
--- trunk/src/view/visio/addon/scstudio.vcproj 2011-03-17 13:42:42 UTC (rev 1064)
+++ trunk/src/view/visio/addon/scstudio.vcproj 2011-03-18 00:43:24 UTC (rev 1065)
@@ -570,6 +570,14 @@
>
</File>
<File
+ RelativePath=".\icon_add_instances.ico"
+ >
+ </File>
+ <File
+ RelativePath=".\icon_beautify.ico"
+ >
+ </File>
+ <File
RelativePath=".\icon_check.ico"
>
</File>
@@ -606,6 +614,14 @@
>
</File>
<File
+ RelativePath=".\icon_message_sequence.ico"
+ >
+ </File>
+ <File
+ RelativePath=".\icon_reverse_message.ico"
+ >
+ </File>
+ <File
RelativePath=".\icon_select_add_instances.ico"
>
</File>
@@ -630,6 +646,10 @@
>
</File>
<File
+ RelativePath=".\icon_tighten_time.ico"
+ >
+ </File>
+ <File
RelativePath=".\ImportDistancesBmp.bmp"
>
</File>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mbe...@us...> - 2011-07-07 21:37:32
|
Revision: 1119
http://scstudio.svn.sourceforge.net/scstudio/?rev=1119&view=rev
Author: mbezdeka
Date: 2011-07-07 21:37:26 +0000 (Thu, 07 Jul 2011)
Log Message:
-----------
Bugfix: Fixed bug #3219653 (Undo after Ctr-Alt-F).
- File structure changed
Modified Paths:
--------------
trunk/src/view/visio/addon/addon.cpp
trunk/src/view/visio/addon/document.cpp
trunk/src/view/visio/addon/scstudio.vcproj
Modified: trunk/src/view/visio/addon/addon.cpp
===================================================================
--- trunk/src/view/visio/addon/addon.cpp 2011-07-07 21:16:44 UTC (rev 1118)
+++ trunk/src/view/visio/addon/addon.cpp 2011-07-07 21:37:26 UTC (rev 1119)
@@ -463,8 +463,6 @@
dlg.m_use_const_spacing,
CPageUtils::ConvertUnits(vsoApp, (dlg.m_use_const_spacing ? dlg.m_spacing : dlg.m_total_width), visPageUnits, visMillimeters)
);
-
-
}
HRESULT CStudioAddon::HandleVisioEvent(
Modified: trunk/src/view/visio/addon/document.cpp
===================================================================
--- trunk/src/view/visio/addon/document.cpp 2011-07-07 21:16:44 UTC (rev 1118)
+++ trunk/src/view/visio/addon/document.cpp 2011-07-07 21:37:26 UTC (rev 1119)
@@ -877,7 +877,8 @@
}
VAORC CDocumentMonitor::DrawInstancesField(Visio::IVApplicationPtr vsoApp, int instancesCnt, Coordinate instanceLength, Coordinate instanceWidth, Coordinate startX, Coordinate startY, bool useConstSpacing, Coordinate spacingOrWidth)
-{
+{
+ vsoApp->Undo();
TRACE("CDocumentMonitor::DrawInstancesField() Drawing instances field");
if (instancesCnt < 0 || instanceLength < 0 || instanceWidth < 0)
Modified: trunk/src/view/visio/addon/scstudio.vcproj
===================================================================
--- trunk/src/view/visio/addon/scstudio.vcproj 2011-07-07 21:16:44 UTC (rev 1118)
+++ trunk/src/view/visio/addon/scstudio.vcproj 2011-07-07 21:37:26 UTC (rev 1119)
@@ -240,22 +240,6 @@
>
</File>
<File
- RelativePath=".\beautifySettingADlg.cpp"
- >
- </File>
- <File
- RelativePath=".\beautifySettingADlg.h"
- >
- </File>
- <File
- RelativePath=".\beautifySettingGDlg.cpp"
- >
- </File>
- <File
- RelativePath=".\beautifySettingGDlg.h"
- >
- </File>
- <File
RelativePath=".\dllmodule.cpp"
>
</File>
@@ -292,14 +276,6 @@
>
</File>
<File
- RelativePath=".\enumerationDlg.cpp"
- >
- </File>
- <File
- RelativePath=".\enumerationDlg.h"
- >
- </File>
- <File
RelativePath=".\enums.h"
>
</File>
@@ -352,22 +328,6 @@
>
</File>
<File
- RelativePath=".\globalSettingsDlg.cpp"
- >
- </File>
- <File
- RelativePath=".\globalSettingsDlg.h"
- >
- </File>
- <File
- RelativePath=".\instancesfielddlg.cpp"
- >
- </File>
- <File
- RelativePath=".\instancesfielddlg.h"
- >
- </File>
- <File
RelativePath=".\messageJump.cpp"
>
</File>
@@ -376,14 +336,6 @@
>
</File>
<File
- RelativePath=".\messagesequencedlg.cpp"
- >
- </File>
- <File
- RelativePath=".\messagesequencedlg.h"
- >
- </File>
- <File
RelativePath=".\messageSnapping.cpp"
>
</File>
@@ -396,14 +348,6 @@
>
</File>
<File
- RelativePath=".\numberingGlobalDlg.cpp"
- >
- </File>
- <File
- RelativePath=".\numberingGlobalDlg.h"
- >
- </File>
- <File
RelativePath=".\optionsdlg.cpp"
>
</File>
@@ -420,14 +364,6 @@
>
</File>
<File
- RelativePath=".\protectionGlobalDlg.cpp"
- >
- </File>
- <File
- RelativePath=".\protectionGlobalDlg.h"
- >
- </File>
- <File
RelativePath=".\reportmessage.cpp"
>
</File>
@@ -464,14 +400,6 @@
>
</File>
<File
- RelativePath=".\snapGlobalDlg.cpp"
- >
- </File>
- <File
- RelativePath=".\snapGlobalDlg.h"
- >
- </File>
- <File
RelativePath=".\stdafx.cpp"
>
<FileConfiguration
@@ -503,6 +431,82 @@
RelativePath=".\visualize.h"
>
</File>
+ <Filter
+ Name="Dialogs"
+ >
+ <File
+ RelativePath=".\beautifySettingADlg.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\beautifySettingADlg.h"
+ >
+ </File>
+ <File
+ RelativePath=".\beautifySettingGDlg.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\beautifySettingGDlg.h"
+ >
+ </File>
+ <File
+ RelativePath=".\enumerationDlg.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\enumerationDlg.h"
+ >
+ </File>
+ <File
+ RelativePath=".\globalSettingsDlg.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\globalSettingsDlg.h"
+ >
+ </File>
+ <File
+ RelativePath=".\instancesfielddlg.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\instancesfielddlg.h"
+ >
+ </File>
+ <File
+ RelativePath=".\messagesequencedlg.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\messagesequencedlg.h"
+ >
+ </File>
+ <File
+ RelativePath=".\numberingGlobalDlg.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\numberingGlobalDlg.h"
+ >
+ </File>
+ <File
+ RelativePath=".\protectionGlobalDlg.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\protectionGlobalDlg.h"
+ >
+ </File>
+ <File
+ RelativePath=".\snapGlobalDlg.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\snapGlobalDlg.h"
+ >
+ </File>
+ </Filter>
</Filter>
<Filter
Name="Resource Files"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|