|
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.
|