summaryrefslogtreecommitdiffstats
path: root/src/libavoid/connector.cpp
diff options
context:
space:
mode:
authormjwybrow <mjwybrow@users.sourceforge.net>2006-02-10 04:23:35 +0000
committermjwybrow <mjwybrow@users.sourceforge.net>2006-02-10 04:23:35 +0000
commitbf26c1cb6feedab295da4823ef571a7e66fc36ed (patch)
tree1c99174b02c8a3c84d4f53403d16b3978bd23e3b /src/libavoid/connector.cpp
parentAdd unit conversion. (diff)
downloadinkscape-bf26c1cb6feedab295da4823ef571a7e66fc36ed.tar.gz
inkscape-bf26c1cb6feedab295da4823ef571a7e66fc36ed.zip
* src/sp-conn-end-pair.cpp, src/sp-conn-end-pair.h,
src/conn-avoid-ref.cpp, src/conn-avoid-ref.h, src/libavoid/connector.cpp, src/libavoid/connector.h, src/libavoid/visibility.cpp: Add some code to allow querying of items and connectors to find out what is attached to them. This will allow graph layout algorithms (currently being work on by Tim Dwyer) to determine a graph structure from the diagram. (bzr r107)
Diffstat (limited to 'src/libavoid/connector.cpp')
-rw-r--r--src/libavoid/connector.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/libavoid/connector.cpp b/src/libavoid/connector.cpp
index 870095415..04bf7aaad 100644
--- a/src/libavoid/connector.cpp
+++ b/src/libavoid/connector.cpp
@@ -20,6 +20,7 @@
*
*/
+#include "libavoid/connector.h"
#include "libavoid/graph.h"
#include "libavoid/makepath.h"
#include "libavoid/visibility.h"
@@ -34,6 +35,8 @@ ConnRefList connRefs;
ConnRef::ConnRef(const unsigned int id)
: _id(id)
+ , _srcId(0)
+ , _dstId(0)
, _needs_reroute_flag(true)
, _false_path(false)
, _active(false)
@@ -52,6 +55,8 @@ ConnRef::ConnRef(const unsigned int id)
ConnRef::ConnRef(const unsigned int id, const Point& src, const Point& dst)
: _id(id)
+ , _srcId(0)
+ , _dstId(0)
, _needs_reroute_flag(true)
, _false_path(false)
, _active(false)
@@ -154,6 +159,19 @@ void ConnRef::updateEndPoint(const unsigned int type, const Point& point)
}
+void ConnRef::setEndPointId(const unsigned int type, const unsigned int id)
+{
+ if (type == (unsigned int) VertID::src)
+ {
+ _srcId = id;
+ }
+ else // if (type == (unsigned int) VertID::dst)
+ {
+ _dstId = id;
+ }
+}
+
+
void ConnRef::makeActive(void)
{
assert(!_active);
@@ -398,6 +416,26 @@ int ConnRef::generatePath(Point p0, Point p1)
//============================================================================
+const unsigned int ConnRef::runningTo = 1;
+const unsigned int ConnRef::runningFrom = 2;
+const unsigned int ConnRef::runningToAndFrom =
+ ConnRef::runningTo | ConnRef::runningFrom;
+
+
+void attachedToShape(IntList &conns, const unsigned int shapeId,
+ const unsigned int type)
+{
+ ConnRefList::iterator fin = connRefs.end();
+ for (ConnRefList::iterator i = connRefs.begin(); i != fin; ++i) {
+ if ((type & ConnRef::runningTo) && ((*i)->_dstId == shapeId)) {
+ conns.push_back((*i)->_id);
+ }
+ else if ((type & ConnRef::runningFrom) && ((*i)->_srcId == shapeId)) {
+ conns.push_back((*i)->_id);
+ }
+ }
+}
+
// It's intended this function is called after shape movement has
// happened to alert connectors that they need to be rerouted.