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