diff options
| author | mjwybrow <mjwybrow@users.sourceforge.net> | 2006-02-10 04:23:35 +0000 |
|---|---|---|
| committer | mjwybrow <mjwybrow@users.sourceforge.net> | 2006-02-10 04:23:35 +0000 |
| commit | bf26c1cb6feedab295da4823ef571a7e66fc36ed (patch) | |
| tree | 1c99174b02c8a3c84d4f53403d16b3978bd23e3b /src/libavoid | |
| parent | Add unit conversion. (diff) | |
| download | inkscape-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')
| -rw-r--r-- | src/libavoid/connector.cpp | 38 | ||||
| -rw-r--r-- | src/libavoid/connector.h | 11 | ||||
| -rw-r--r-- | src/libavoid/visibility.cpp | 10 |
3 files changed, 57 insertions, 2 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. diff --git a/src/libavoid/connector.h b/src/libavoid/connector.h index 71713ae41..1fd4255a8 100644 --- a/src/libavoid/connector.h +++ b/src/libavoid/connector.h @@ -33,6 +33,7 @@ namespace Avoid { class ConnRef; typedef std::list<ConnRef *> ConnRefList; +typedef std::list<unsigned int> IntList; class ConnRef @@ -48,6 +49,7 @@ class ConnRef void freeRoute(void); void calcRouteDist(void); void updateEndPoint(const unsigned int type, const Point& point); + void setEndPointId(const unsigned int type, const unsigned int id); void makeActive(void); void makeInactive(void); void lateSetup(const Point& src, const Point& dst); @@ -62,9 +64,16 @@ class ConnRef void makePathInvalid(void); friend void markConnectors(ShapeRef *shape); + friend void attachedToShape(IntList &conns, + const unsigned int shapeId, const unsigned int type); + static const unsigned int runningTo; + static const unsigned int runningFrom; + static const unsigned int runningToAndFrom; + private: unsigned int _id; + unsigned int _srcId, _dstId; bool _needs_reroute_flag; bool _false_path; bool _active; @@ -82,6 +91,8 @@ class ConnRef extern ConnRefList connRefs; extern void callbackAllInvalidConnectors(void); +extern void attachedToShape(IntList &conns, const unsigned int shapeId, + const unsigned int type); } diff --git a/src/libavoid/visibility.cpp b/src/libavoid/visibility.cpp index 84e38037d..6154bd396 100644 --- a/src/libavoid/visibility.cpp +++ b/src/libavoid/visibility.cpp @@ -26,7 +26,9 @@ #include "libavoid/shape.h" #include "libavoid/debug.h" #include "libavoid/visibility.h" +#include "libavoid/vertices.h" #include "libavoid/graph.h" +#include "libavoid/geometry.h" #include <math.h> @@ -602,7 +604,9 @@ void vertexSweep(VertInf *vert) EdgeSet::iterator ePtr; if (prevDir == BEHIND) { - ePtr = e.find(prevPair); + // XXX: Strangely e.find does not return the correct results. + // ePtr = e.find(prevPair); + ePtr = std::find(e.begin(), e.end(), prevPair); if (ePtr != e.end()) { e.erase(ePtr); @@ -625,7 +629,9 @@ void vertexSweep(VertInf *vert) if (nextDir == BEHIND) { - ePtr = e.find(nextPair); + // XXX: Strangely e.find does not return the correct results. + // ePtr = e.find(nextPair); + ePtr = std::find(e.begin(), e.end(), nextPair); if (ePtr != e.end()) { e.erase(ePtr); |
