|
From: <mbe...@us...> - 2010-07-23 00:03:53
|
Revision: 837
http://scstudio.svn.sourceforge.net/scstudio/?rev=837&view=rev
Author: mbezdeka
Date: 2010-07-23 00:03:47 +0000 (Fri, 23 Jul 2010)
Log Message:
-----------
Message snapping
- complete help added
- bugs fixed
Modified Paths:
--------------
trunk/doc/help/frontend/message-snapping.html
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/globalSettingsDlg.cpp
trunk/src/view/visio/addon/globalSettingsDlg.h
trunk/src/view/visio/addon/messageSnapping.cpp
trunk/src/view/visio/addon/numberingGlobalDlg.cpp
trunk/src/view/visio/addon/numberingGlobalDlg.h
trunk/src/view/visio/addon/pageutils.cpp
trunk/src/view/visio/addon/pageutils.h
Added Paths:
-----------
trunk/doc/help/frontend/pictures/message_snapping_options.png
Modified: trunk/doc/help/frontend/message-snapping.html
===================================================================
--- trunk/doc/help/frontend/message-snapping.html 2010-07-16 11:51:14 UTC (rev 836)
+++ trunk/doc/help/frontend/message-snapping.html 2010-07-23 00:03:47 UTC (rev 837)
@@ -6,6 +6,36 @@
</head>
<body>
<h1>Message Snapping</h1>
-<p>When a message is dropped onto the drawing a user has to connect this message to the instances manually. If Message snapping is enabled then all new messages are automatically snapped to the nearest instances as soon as the user releases the mouse button.</p>
+<p>When a message is dropped onto the drawing a user has to connect this message to the instances manually. If Message snapping is enabled then all new messages are automatically snapped to the nearest instances as soon as the user releases the mouse button. The nearest instances are taken from the mouse position.</p>
+<p>Snapping can be enabled via <code>Check -> Drawing -> Settings...</code>, tab Snap & Glue. Following dialog will be shown:</p>
+<p>
+<img src="pictures/message_snapping_options.png" alt="Message Snapping options dialog">
+</p>
+
+<p>
+Options are:<br>
+<code>Enable/disable message snapping</code><br>
+ - sets whether message snapping is enabled, otherwise all other options are disabled.
+</p>
+
+<p>
+When the message is already dropped on the page, user can still use snapping. As the message is moved, it automatically snaps to the nearest instance(s) (if exists). Since the message can be oblique, three types of snapping are provided:<br><br>
+<code>straighten</code><br>
+ - the message is straigten on the current location of the mouse cursor and snapped to instance(s).<br>
+<code>preserve vertical distance between send - receive</code><br>
+ - endpoint(s) of the message are horizontally stretched and snapped to the nearest instance(s).<br>
+<code>preserve slope</code><br>
+ - the message stays obliqued as it was. The endpoint(s) will be prolonged to the nearest instance(s).<br>
+</p>
+
+<h2>Multiple message snapping</h2>
+<i>Not implemented yet</i>
+
+<h2>Restrictions</h2>
+
+- Lost and Found messages are snapped only at one endpoint.<br>
+- Messages can be snapped only to the instances lines. Instance's head and end symbols are ignored.<br>
+
+
Added: trunk/doc/help/frontend/pictures/message_snapping_options.png
===================================================================
(Binary files differ)
Property changes on: trunk/doc/help/frontend/pictures/message_snapping_options.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/src/view/visio/addon/addon.cpp
===================================================================
--- trunk/src/view/visio/addon/addon.cpp 2010-07-16 11:51:14 UTC (rev 836)
+++ trunk/src/view/visio/addon/addon.cpp 2010-07-23 00:03:47 UTC (rev 837)
@@ -59,13 +59,20 @@
{
m_pIAddonSink = NULL;
m_keyButtonState = 0;
+
m_mousePosX = m_mousePosY = 0.0;
+ m_mouseRelPosX = m_mouseRelPosY = 0.0;
+
m_bCellChanged = false;
m_bShapeDeleted = false;
+
m_bSnap = false;
m_bMoving = false;
m_bBeginChanged = false;
m_bEndChanged = false;
+ m_bCtrlDown = false;
+ m_bKeyDown = false;
+ m_bOnDropShape = false;
};
VAORC CStudioAddon::About(LPVAOV2LSTRUCT pV2L)
@@ -482,9 +489,9 @@
HandleMouseMove(pSubjectObj, pSourceObj);
break;
- case Visio::visEvtCodeMouseUp:
- TRACE("CStudioAddon::HandleVisioEvent() visEvtCodeMouseUp");
- HandleMouseUp(pSubjectObj, pSourceObj);
+ case Visio::visEvtCodeMouseDown:
+ TRACE("CStudioAddon::HandleVisioEvent() visEvtCodeMouseDown");
+ HandleMouseDown(pSubjectObj, pSourceObj);
break;
case Visio::visEvtCodeWinSelChange:
@@ -635,6 +642,12 @@
if (!(oldState & modifiers) && (m_keyButtonState & modifiers)) {
GetDocumentMonitor(vsoApp, vsoApp->ActiveDocument)->ToggleToolbarItems(true);
}
+
+ //Message snapping
+ if(m_keyButtonState & visKeyControl)
+ m_bCtrlDown = true;
+
+ m_bKeyDown = true;
}
void CStudioAddon::HandleKeyUp(Visio::IVKeyboardEventPtr vsoKeyboardEvent, Visio::IVApplicationPtr vsoApp)
@@ -653,6 +666,9 @@
if ((oldState & modifiers) && !(m_keyButtonState & modifiers)) {
GetDocumentMonitor(vsoApp, vsoApp->ActiveDocument)->ToggleToolbarItems(false);
}
+
+ //Message snapping
+ m_bCtrlDown = false;
}
void CStudioAddon::HandleMouseMove(Visio::IVMouseEventPtr vsoMouseEvent, Visio::IVApplicationPtr vsoApp)
@@ -661,12 +677,27 @@
m_mousePosY = vsoMouseEvent->y;
}
-void CStudioAddon::HandleMouseUp(Visio::IVMouseEventPtr vsoMouseEvent, Visio::IVApplicationPtr vsoApp)
+void CStudioAddon::HandleMouseDown(Visio::IVMouseEventPtr vsoMouseEvent, Visio::IVApplicationPtr vsoApp)
{
+ //Message snapping
+ if(vsoApp->ActiveWindow->Selection->Count == 1)
+ {
+ Visio::IVShapePtr shape = vsoApp->ActiveWindow->Selection->Item[1];
+ m_mouseRelPosX = m_mousePosX - shape->Cells["PinX"]->Result[""];
+ m_mouseRelPosY = m_mousePosY - shape->Cells["PinY"]->Result[""];
+ }
}
void CStudioAddon::HandleWinSelChange(Visio::IVApplicationPtr vsoApp)
{
+ //Message snapping
+ if(vsoApp->ActiveWindow->Selection->Count == 1)
+ {
+ Visio::IVShapePtr shape = vsoApp->ActiveWindow->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;
@@ -679,46 +710,43 @@
void CStudioAddon::HandleNonePending(Visio::IVApplicationPtr vsoApp)
{
+ ////////////////////////////////////////////////////
//Message snapping
- if(m_bSnap && vsoApp->ActiveWindow->Selection->Count)
+#define _u(x) CPageUtils::ConvertUnits(vsoApp, x, 0, visPageUnits)
+ if(!m_bOnDropShape && m_bSnap && vsoApp->ActiveWindow->Selection->Count && 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 && GetDocumentMonitor(vsoApp,vsoApp->ActiveDocument)->isMessageShape(msgShape))
+ if(msgShape && m_bBeginChanged && m_bEndChanged && docMon->isMessageShape(msgShape))
{
- //Resize shape
- if(m_bMoving && (m_bBeginChanged ^ m_bEndChanged))
- {
- m_mousePosX = m_bBeginChanged ? msgShape->Cells["BeginX"]->Result[""] : msgShape->Cells["EndX"]->Result[""];
- m_mousePosY = m_bBeginChanged ? msgShape->Cells["BeginY"]->Result[""] : msgShape->Cells["EndY"]->Result[""];
- }
+ //If endpoints movement would be enabled, here would be condition (m_bMoving && (m_bBeginChanged ^ m_bEndChanged))
- GetDocumentMonitor(vsoApp,vsoApp->ActiveDocument)->autoSnapping(msgShape,
- CPageUtils::ConvertUnits(vsoApp->ActivePage, m_mousePosX, 0, visPageUnits),
- CPageUtils::ConvertUnits(vsoApp->ActivePage, m_mousePosY, 0, visPageUnits));
+ //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);
+
+
+ //Do snapping
+ docMon->autoSnapping(msgShape, newPosX, newPosY);
}
}
else //NOTE: Multiple selection - preserve connecting to instances
{
- MsgSnapType currentSnapType = CMessageSnapping::getSnapType();
- CMessageSnapping::setSnapType(MSSNAP_PRESERVE_SLOPE);
- for(int i=1; i<=selection->Count; i++)
- {
- Visio::IVShapePtr msgShape = selection->Item[i];
- if(GetDocumentMonitor(vsoApp,vsoApp->ActiveDocument)->isMessageShape(msgShape))
- GetDocumentMonitor(vsoApp,vsoApp->ActiveDocument)->autoSnapping(msgShape, msgShape->Cells["PinX"]->Result[visPageUnits],
- msgShape->Cells["PinY"]->Result[visPageUnits]);
- }
- CMessageSnapping::setSnapType(currentSnapType);
+ //Not implemented yet
}
}
//Set variables to false
- m_bSnap = m_bMoving = m_bBeginChanged = m_bEndChanged = false;
+ m_bSnap = m_bMoving = m_bBeginChanged = m_bEndChanged = m_bKeyDown = false;
+#undef _u
-
+ ////////////////////////////////////////////////////
//Message numbering
if(m_bShapeDeleted || m_bCellChanged)
{
@@ -749,6 +777,9 @@
//Set variables to false to prevent this function from loop
m_bShapeDeleted = m_bCellChanged = false;
}
+
+ //Reset OnDropShape state
+ m_bOnDropShape = false;
}
void CStudioAddon::HandleBeforeTextEdit(Visio::IVShapePtr shapePtr, Visio::IVApplicationPtr vsoApp)
@@ -856,7 +887,7 @@
vsoApp->EventList->AddAdvise(Visio::visEvtCodeKeyDown, varSink, _T(""), _T("KeyDown"));
vsoApp->EventList->AddAdvise(Visio::visEvtCodeKeyUp, varSink, _T(""), _T("KeyUp"));
vsoApp->EventList->AddAdvise(Visio::visEvtCodeMouseMove, varSink, _T(""), _T("MouseMove"));
- vsoApp->EventList->AddAdvise(Visio::visEvtCodeMouseUp, varSink, _T(""), _T("MouseUp"));
+ vsoApp->EventList->AddAdvise(Visio::visEvtCodeMouseDown, varSink, _T(""), _T("MouseDown"));
// Message enumeration events
vsoApp->EventList->AddAdvise(Visio::visEvtCodeShapeBeforeTextEdit, varSink, _T(""), _T("BeforeTextEdit"));
vsoApp->EventList->AddAdvise(Visio::visEvtCodeShapeExitTextEdit, varSink, _T(""), _T("AfterTextEdit"));
Modified: trunk/src/view/visio/addon/addon.h
===================================================================
--- trunk/src/view/visio/addon/addon.h 2010-07-16 11:51:14 UTC (rev 836)
+++ trunk/src/view/visio/addon/addon.h 2010-07-23 00:03:47 UTC (rev 837)
@@ -55,7 +55,7 @@
void HandleKeyDown(Visio::IVKeyboardEventPtr vsoKeyboardEvent, Visio::IVApplicationPtr vsoApp);
void HandleKeyUp(Visio::IVKeyboardEventPtr vsoKeyboardEvent, Visio::IVApplicationPtr vsoApp);
void HandleMouseMove(Visio::IVMouseEventPtr vsoMouseEvent, Visio::IVApplicationPtr vsoApp);
- void HandleMouseUp(Visio::IVMouseEventPtr vsoMouseEvent, Visio::IVApplicationPtr vsoApp);
+ void HandleMouseDown(Visio::IVMouseEventPtr vsoMouseEvent, Visio::IVApplicationPtr vsoApp);
void HandleWinSelChange(Visio::IVApplicationPtr vsoApp);
void HandleBeforeTextEdit(Visio::IVShapePtr shapePtr, Visio::IVApplicationPtr vsoApp);
void HandleAfterTextEdit(Visio::IVShapePtr shapePtr, Visio::IVApplicationPtr vsoApp);
@@ -116,6 +116,14 @@
*/
double GetPrevMousePosY(Visio::IVApplicationPtr vsoApp) { return m_prevMousePosY[vsoApp]; }
+ double GetRelMousePosX() { return m_mouseRelPosX; }
+ double GetRelMousePosY() { return m_mouseRelPosY; }
+
+ void SetOnDropShapeState(bool state) { m_bOnDropShape = state; m_bSnap = state; }
+ bool GetOnDropShapeState() { return m_bOnDropShape; }
+
+ bool GetCtrlKeyDown() { return m_bCtrlDown; }
+
private:
IUnknown *m_pIAddonSink;
Visio::IVEventPtr m_vsoMarkerEvent;
@@ -145,6 +153,11 @@
bool m_bBeginChanged;
bool m_bEndChanged;
bool m_bMoving;
+ bool m_bCtrlDown;
+ bool m_bKeyDown;
+ bool m_bOnDropShape;
+ double m_mouseRelPosX;
+ double m_mouseRelPosY;
};
// $Id$
Modified: trunk/src/view/visio/addon/dllmodule.rc
===================================================================
--- trunk/src/view/visio/addon/dllmodule.rc 2010-07-16 11:51:14 UTC (rev 836)
+++ trunk/src/view/visio/addon/dllmodule.rc 2010-07-23 00:03:47 UTC (rev 837)
@@ -229,8 +229,8 @@
CAPTION "Dialog"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
- CONTROL "Enable message snapping",IDC_SNAP_ENABLED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,7,98,10
- GROUPBOX "Oblique message snapping options",IDC_STATIC,7,22,261,61
+ 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 "preserve vertical distance between send - receive",IDC_PRESERVE_VERTICAL,
"Button",BS_AUTORADIOBUTTON,13,51,176,10
Modified: trunk/src/view/visio/addon/document.cpp
===================================================================
--- trunk/src/view/visio/addon/document.cpp 2010-07-16 11:51:14 UTC (rev 836)
+++ trunk/src/view/visio/addon/document.cpp 2010-07-23 00:03:47 UTC (rev 837)
@@ -243,6 +243,7 @@
VAORC CDocumentMonitor::OnDropShape(int iDocumentIndex, int iPageIndex, _bstr_t sShapeU)
{
+ m_addon->SetOnDropShapeState(true);
// ignore events when undoing or redoing
if(m_vsoApp->IsUndoingOrRedoing == VARIANT_TRUE)
return VAORC_SUCCESS;
@@ -262,10 +263,19 @@
case ST_BMSC_MESSAGE_FOUND:
if(vsoShape->Text.length() == 0)
vsoShape->Text = _T("NAME");
- //Check whether snapping is enabled
- if(CMessageSnapping::isEnabled())
- autoSnapping(vsoShape,CPageUtils::ConvertUnits(m_vsoApp,m_addon->GetMousePosX(),0,visPageUnits),
- CPageUtils::ConvertUnits(m_vsoApp,m_addon->GetMousePosY(),0,visPageUnits));
+
+ if(CMessageSnapping::isEnabled()) //Check whether snapping is enabled
+ {
+ double posX = CShapeUtils::GetShapeCellProperty(vsoShape,"PinX",visPageUnits), posY = CShapeUtils::GetShapeCellProperty(vsoShape,"PinY",visPageUnits);
+ if(m_addon->GetCtrlKeyDown())
+ {
+ posX += CPageUtils::ConvertUnits(m_vsoApp, m_addon->GetRelMousePosX(), 0, visPageUnits);
+ posY += CPageUtils::ConvertUnits(m_vsoApp, m_addon->GetRelMousePosY(), 0, visPageUnits);
+ }
+ m_vsoApp->EventsEnabled = false;
+ autoSnapping(vsoShape,posX, posY);
+ m_vsoApp->EventsEnabled = true;
+ }
autoEnumerate(vsoShape);
break;
@@ -1691,7 +1701,7 @@
VAORC CDocumentMonitor::OnMenuGlobalSettings(Visio::IVApplicationPtr vsoApp)
{
- CGlobalSettingsDlg sheet(_T("Settings"));
+ CGlobalSettingsDlg sheet(vsoApp, _T("Settings"));
sheet.DoModal();
//Message Numbering processing
@@ -2154,6 +2164,9 @@
void CDocumentMonitor::autoSnapping(Visio::IVShapePtr msgShape, double posX, double posY)
{
+ long scopeID = msgShape->Application->BeginUndoScope(_T("AutoSnapping"));
+#define _sp(x) CShapeUtils::GetShapeCellProperty(msgShape, x, visPageUnits)
+
//Step 1: Get snap type
MsgSnapType snapType = CMessageSnapping::getSnapType();
@@ -2163,44 +2176,79 @@
return;
}
- double msgBegY = CShapeUtils::GetShapeCellProperty(msgShape,"BeginY", visPageUnits);
- double msgEndY = CShapeUtils::GetShapeCellProperty(msgShape,"EndY", visPageUnits);
+ double msgBegY = _sp("BeginY"), msgEndY = _sp("EndY");
+ VEC2 msgVec(msgShape->Cells["EndX"]->Result[""] - msgShape->Cells["BeginX"]->Result[""], //NOTE: vector for preservind message length
+ msgShape->Cells["EndY"]->Result[""]- msgShape->Cells["BeginY"]->Result[""]);
- //if message is only horizontal we can take as Y coord PinY and don't have to calculate oblique
- if(msgShape->Cells["BeginY"]->Result[visPageUnits] == msgEndY) //DODELAT!
+ //Step 2: If message is only horizontal we can take as Y coord PinY and don't have to calculate oblique
+ if(msgBegY == msgEndY)
{
- posY = CShapeUtils::GetShapeCellProperty(msgShape, "PinY", visPageUnits);
+ posY = _sp("PinY");
snapType = MSSNAP_STRAIGHTEN;
}
-
- //Step 2: Get all instance matching criteria
+
+ //Step 3: Get all instance matching criteria
std::vector<Visio::IVShapePtr> instShapes = CMessageSnapping::getIntersectInstances(msgShape, posY, snapType);
- //Step 3: Get the closest instance on the left and on the right
- std::pair<Visio::IVShapePtr,Visio::IVShapePtr> closestInst = CMessageSnapping::getClosestInstancePair(msgShape, posX, posY, instShapes, snapType);
-
- //Step 4:Glue to them
+ //Step 4: Get the closest instance on the left and on the right
+ std::pair<Visio::IVShapePtr,Visio::IVShapePtr> closestInst;
+ if(snapType == MSSNAP_PRESERVE_VERTICAL)
+ {
+ //left closest instance
+ std::pair<Visio::IVShapePtr,Visio::IVShapePtr> closestInstLeft = CMessageSnapping::getClosestInstancePair(msgShape, posX, _sp("BeginY"), instShapes, MSSNAP_STRAIGHTEN);
+ std::pair<Visio::IVShapePtr,Visio::IVShapePtr> closestInstRight = CMessageSnapping::getClosestInstancePair(msgShape, posX, _sp("EndY"), instShapes, MSSNAP_STRAIGHTEN);
+ closestInst.first = ((_sp("BeginX") - _sp("EndX")) < 0) ? closestInstLeft.first : closestInstRight.first;
+ closestInst.second =((_sp("BeginX") - _sp("EndX")) < 0) ? closestInstRight.second : closestInstLeft.second;
+ }
+ else
+ closestInst = CMessageSnapping::getClosestInstancePair(msgShape, posX, posY, instShapes, snapType);
+
+ //Step 5:Glue to them
CMessageSnapping::glueMsgToInstancesPair(msgShape, closestInst.first, closestInst.second,posY, snapType);
-
- //Step 5: Straighten messages when it's snapped only to one instance (must disable events, because CellChanged would be triggered)
- if((closestInst.first ^ closestInst.second) && snapType == MSSNAP_STRAIGHTEN)
+
+ //Step 6: Do some corrections
+ if(closestInst.first ^ closestInst.second)
{
- if((CShapeUtils::GetShapeCellProperty(msgShape, "EndX", visPageUnits) - CShapeUtils::GetShapeCellProperty(msgShape, "BeginX", visPageUnits)) < 0)
+ //Step 6.1: If message is left-oriented switch pointers
+ if((_sp("EndX") - _sp("BeginX")) < 0)
{
Visio::IVShapePtr buffer = closestInst.first;
closestInst.first = closestInst.second;
closestInst.second = buffer;
}
+
+ //Step 6.2: Straighten messages when it's snapped only to one instance (must disable events, because CellChanged would be triggered)
+ if(snapType == MSSNAP_STRAIGHTEN)
+ {
+ msgShape->Application->EventsEnabled = false;
+ if(!closestInst.second)
+ msgShape->Cells["EndY"]->FormulaU = stringize() << msgShape->Cells["BeginY"]->Result[""];
+ else if(!closestInst.first)
+ msgShape->Cells["BeginY"]->FormulaU = stringize() << msgShape->Cells["EndY"]->Result[""];
+ msgShape->Application->EventsEnabled = true;
+ }
+ //Step 6.3: If message is snapped only to one instance, preserve its length
msgShape->Application->EventsEnabled = false;
- if(!closestInst.second)
- msgShape->Cells["EndY"]->FormulaU = stringize() << msgShape->Cells["BeginY"]->Result[""];
- else if(!closestInst.first)
- msgShape->Cells["BeginY"]->FormulaU = stringize() << msgShape->Cells["EndY"]->Result[""];
+ 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;
+ }
+
+ 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->Application->EventsEnabled = true;
}
- //FIXME: preserve vertical distance can't sometimes find the closest instance
+#undef _sp
+ msgShape->Application->EndUndoScope(scopeID,true);
+
+ //FIXME: When MSSNAP_STRAIGHTEN is in use then copying msgs using ctrl doesn't work correctly
+ //FIXME: When user add a new shape and hold ctrl key, snapping doesn't work correctly
}
// $Id$
Modified: trunk/src/view/visio/addon/globalSettingsDlg.cpp
===================================================================
--- trunk/src/view/visio/addon/globalSettingsDlg.cpp 2010-07-16 11:51:14 UTC (rev 836)
+++ trunk/src/view/visio/addon/globalSettingsDlg.cpp 2010-07-23 00:03:47 UTC (rev 837)
@@ -20,13 +20,13 @@
#include "dllmodule.h"
#include "GlobalSettingsDlg.h"
-CGlobalSettingsDlg::CGlobalSettingsDlg(ATL::_U_STRINGorID title,UINT uStartPage, HWND hWndParent):
+CGlobalSettingsDlg::CGlobalSettingsDlg(Visio::IVApplicationPtr vsoApp, ATL::_U_STRINGorID title,UINT uStartPage, HWND hWndParent):
CPropertySheetImpl<CGlobalSettingsDlg>(title,uStartPage,hWndParent)
{
m_bCentered = false;
//Disable APPLY button and CONTEXT HELP button
- m_psh.dwFlags |= PSH_NOAPPLYNOW | PSH_NOCONTEXTHELP;
+ m_psh.dwFlags |= PSH_NOAPPLYNOW | PSH_NOCONTEXTHELP | PSH_HASHELP;
//Adding pages
page1.SetTitle(_T("Numbering")); AddPage(page1);
Modified: trunk/src/view/visio/addon/globalSettingsDlg.h
===================================================================
--- trunk/src/view/visio/addon/globalSettingsDlg.h 2010-07-16 11:51:14 UTC (rev 836)
+++ trunk/src/view/visio/addon/globalSettingsDlg.h 2010-07-23 00:03:47 UTC (rev 837)
@@ -29,7 +29,7 @@
class CGlobalSettingsDlg : public CPropertySheetImpl<CGlobalSettingsDlg>
{
public:
- CGlobalSettingsDlg(ATL::_U_STRINGorID title = (LPCTSTR) NULL,
+ CGlobalSettingsDlg(Visio::IVApplicationPtr vsoApp, ATL::_U_STRINGorID title = (LPCTSTR) NULL,
UINT uStartPage = 0, HWND hWndParent = NULL);
BEGIN_MSG_MAP(CGlobalSettingsDlg)
@@ -46,6 +46,8 @@
//Pages of property sheet
CNumberingGlobalDlg page1;
CSnapGlobalDlg page2;
+
+ Visio::IVApplicationPtr m_vsoApp;
};
// $Id$
\ No newline at end of file
Modified: trunk/src/view/visio/addon/messageSnapping.cpp
===================================================================
--- trunk/src/view/visio/addon/messageSnapping.cpp 2010-07-16 11:51:14 UTC (rev 836)
+++ trunk/src/view/visio/addon/messageSnapping.cpp 2010-07-23 00:03:47 UTC (rev 837)
@@ -23,10 +23,7 @@
bool CMessageSnapping::isEnabled()
{
- if(!GetRegistry<bool>(_T("Software\\Sequence Chart Studio\\MessageSnapping"), NULL, _T("SnapEnabled"), 0))
- return false;
-
- return true;
+ return GetRegistry<bool>(_T("Software\\Sequence Chart Studio\\MessageSnapping"), NULL, _T("SnapEnabled"), 0);
}
MsgSnapType CMessageSnapping::getSnapType()
@@ -85,6 +82,7 @@
PVEC2 result = getIntersectionWithInstance(msgShape, shape);
if(result)
instShapes.push_back(shape);
+
delete result;
}
else
@@ -101,23 +99,40 @@
std::pair<Visio::IVShapePtr, Visio::IVShapePtr> CMessageSnapping::getClosestInstancePair(Visio::IVShapePtr msgShape, double msgSnapPointX, double msgSnapPointY,
const std::vector<Visio::IVShapePtr>& instances, MsgSnapType snapType)
{
- /*
- TODO: try to find a way how to get closest instance better when instance is in diagonal position
- For example, compute intersection as a intersection of two vectors
- */
Visio::IVShapePtr leftClosestInstance = NULL;
Visio::IVShapePtr rightClosestInstance = NULL;
double leftClosestInstanceDist = 0, rightClosestInstanceDist = 0;
- double instPinX, instPinY, distance, mouseDistX;
+ double instBeginX, instBeginY, instEndX, instEndY, distance, mouseDistX;
+ double msgBeginY = msgShape->Cells["BeginY"]->Result[visPageUnits];
+ double msgEndY = msgShape->Cells["EndY"]->Result[visPageUnits];
+
+#define _ip(x) CShapeUtils::GetShapeCellProperty((*it),x, visPageUnits);
+
for(std::vector<Visio::IVShapePtr>::const_iterator it = instances.begin(); it != instances.end(); it++)
{
- instPinX = CShapeUtils::GetShapeCellProperty((*it),"PinX", visPageUnits);
- instPinY = CShapeUtils::GetShapeCellProperty((*it),"PinY", visPageUnits);
+ instBeginX = _ip("BeginX"); instBeginY = _ip("BeginY"); instEndX = _ip("EndX"); instEndY = _ip("EndY");
- distance = sqrt(pow((msgSnapPointX - instPinX),2) + pow((msgSnapPointY - instPinY),2));
- mouseDistX = msgSnapPointX - instPinX;
+ //Get intersection point with instance
+ PVEC2 intPoint = NULL;
+ switch(snapType)
+ {
+ case MSSNAP_STRAIGHTEN:
+ intPoint = CPageUtils::getIntersectionPoint(VEC2(msgSnapPointX, msgSnapPointY), VEC2(msgSnapPointX - 1, msgSnapPointY), VEC2(instEndX, instEndY), VEC2(instBeginX, instBeginY));
+ break;
+ case MSSNAP_PRESERVE_SLOPE:
+ intPoint = CMessageSnapping::getIntersectionWithInstance(msgShape, (*it));
+ break;
+ }
+
+ if(!intPoint || intPoint->y > instBeginY || intPoint->y < instEndY)
+ continue;
+ mouseDistX = msgSnapPointX - intPoint->x;
+ distance = sqrt(pow((msgSnapPointX - intPoint->x),2) + pow((msgSnapPointY - intPoint->y),2));
+
+ delete intPoint;
+
if(mouseDistX < 0)
{
if(!rightClosestInstance || distance < rightClosestInstanceDist)
@@ -138,6 +153,22 @@
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
+ double shapeLeft = msgShape->Cells["BeginX"]->Result[""];
+ double shapeRight = msgShape->Cells["EndX"]->Result[""];
+
+ switch(get_shape_type(msgShape))
+ {
+ case ST_BMSC_MESSAGE_FOUND:
+ (shapeLeft <= shapeRight) ? leftClosestInstance = NULL : rightClosestInstance = NULL;
+ break;
+ case ST_BMSC_MESSAGE_LOST:
+ (shapeLeft <= shapeRight) ? rightClosestInstance = NULL : leftClosestInstance = NULL;
+ break;
+ }
+
return std::pair<Visio::IVShapePtr, Visio::IVShapePtr>(leftClosestInstance,rightClosestInstance);
}
@@ -156,17 +187,6 @@
rightInstance = buffer;
}
- //restrict snapping for FOUND and LOST messages
- switch(get_shape_type(msgShape))
- {
- case ST_BMSC_MESSAGE_FOUND:
- leftInstance = NULL;
- break;
- case ST_BMSC_MESSAGE_LOST:
- rightInstance = NULL;
- break;
- }
-
double yLeftPos, yRightPos;
double msgBegY = CShapeUtils::GetShapeCellProperty(msgShape,"BeginY", visPageUnits);
double msgEndY = CShapeUtils::GetShapeCellProperty(msgShape,"EndY", visPageUnits);
@@ -241,17 +261,19 @@
PVEC2 CMessageSnapping::getIntersectionWithInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape)
{
+#define _s(x) CShapeUtils::GetShapeCellProperty(msgShape, x, visPageUnits)
+#define _i(x) CShapeUtils::GetShapeCellProperty(instanceShape, x, visPageUnits)
+
VEC2 p1,p2,p3,p4;
- p1.x = CShapeUtils::GetShapeCellProperty(msgShape,"EndX", visPageUnits);
- p1.y = CShapeUtils::GetShapeCellProperty(msgShape,"EndY", visPageUnits);
- p2.x = CShapeUtils::GetShapeCellProperty(msgShape,"BeginX", visPageUnits);
- p2.y = CShapeUtils::GetShapeCellProperty(msgShape,"BeginY", visPageUnits);
+ p1.x = _s("EndX"); p1.y = _s("EndY");
+ p2.x = _s("BeginX"); p2.y = _s("BeginY");
- p3.x = CShapeUtils::GetShapeCellProperty(instanceShape,"EndX", visPageUnits);
- p3.y = CShapeUtils::GetShapeCellProperty(instanceShape,"EndY", visPageUnits);
- p4.x = CShapeUtils::GetShapeCellProperty(instanceShape,"BeginX", visPageUnits);
- p4.y = CShapeUtils::GetShapeCellProperty(instanceShape,"BeginY", visPageUnits);
+ p3.x = _i("EndX"); p3.y = _i("EndY");
+ p4.x = _i("BeginX"); p4.y = _i("BeginY");
+#undef _s
+#undef _i
+
PVEC2 result = CPageUtils::getIntersectionPoint(p1, p2, p3, p4);
if(!result)
return NULL;
Modified: trunk/src/view/visio/addon/numberingGlobalDlg.cpp
===================================================================
--- trunk/src/view/visio/addon/numberingGlobalDlg.cpp 2010-07-16 11:51:14 UTC (rev 836)
+++ trunk/src/view/visio/addon/numberingGlobalDlg.cpp 2010-07-23 00:03:47 UTC (rev 837)
@@ -20,9 +20,11 @@
#include "dllmodule.h"
#include "numberingGlobalDlg.h"
#include "enumerateUtils.h"
+#include "document.h"
BOOL CNumberingGlobalDlg::OnInitDialog(HWND hWndFocus, LPARAM lParam)
{
+ //Loading registry data
m_bAutoEnum = GetRegistry<bool>(GetRegistryFolder(), NULL, _T("AutoEnum"), 0);
DoDataExchange(FALSE); //update data from variables to fields
@@ -130,6 +132,7 @@
return PSNRET_INVALID;
}
+
void CNumberingGlobalDlg::EnableAllControls(bool bEnable)
{
m_nearestMsg.EnableWindow(bEnable);
Modified: trunk/src/view/visio/addon/numberingGlobalDlg.h
===================================================================
--- trunk/src/view/visio/addon/numberingGlobalDlg.h 2010-07-16 11:51:14 UTC (rev 836)
+++ trunk/src/view/visio/addon/numberingGlobalDlg.h 2010-07-23 00:03:47 UTC (rev 837)
@@ -34,6 +34,10 @@
public:
enum { IDD = IDD_NUMBERING_GLOBAL };
+ CNumberingGlobalDlg() { //set dialog properties
+ m_psp.dwFlags |= PSP_HASHELP;
+ };
+
BEGIN_MSG_MAP(CNumberingGlobalDlg)
MSG_WM_INITDIALOG(OnInitDialog)
CHAIN_MSG_MAP(CPropertyPageImpl<CNumberingGlobalDlg>)
Modified: trunk/src/view/visio/addon/pageutils.cpp
===================================================================
--- trunk/src/view/visio/addon/pageutils.cpp 2010-07-16 11:51:14 UTC (rev 836)
+++ trunk/src/view/visio/addon/pageutils.cpp 2010-07-23 00:03:47 UTC (rev 837)
@@ -141,7 +141,8 @@
if(d == 0)
return NULL;
- double pre = (x1*y2 - y1*x2), post = (x3*y4 - y3*x4);
+ double pre = (x1*y2 - y1*x2);
+ double post = (x3*y4 - y3*x4);
double x = ( pre * (x3 - x4) - (x1 - x2) * post ) / d;
double y = ( pre * (y3 - y4) - (y1 - y2) * post ) / d;
Modified: trunk/src/view/visio/addon/pageutils.h
===================================================================
--- trunk/src/view/visio/addon/pageutils.h 2010-07-16 11:51:14 UTC (rev 836)
+++ trunk/src/view/visio/addon/pageutils.h 2010-07-23 00:03:47 UTC (rev 837)
@@ -22,6 +22,8 @@
typedef struct _Vec2
{
+ _Vec2() {};
+ _Vec2(double _x, double _y): x(_x), y(_y) {};
double x;
double y;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|