summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4197d99)
raw | patch | inline | side by side (parent: 4197d99)
author | mjwybrow <mjwybrow@users.sourceforge.net> | |
Fri, 10 Feb 2006 04:23:35 +0000 (04:23 +0000) | ||
committer | mjwybrow <mjwybrow@users.sourceforge.net> | |
Fri, 10 Feb 2006 04:23:35 +0000 (04:23 +0000) |
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.
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.
diff --git a/ChangeLog b/ChangeLog
index 79e1f51f1cf66e394e1dfde934bedcce5e216606..12d7681955fd552e74222c0d849d4d4968d68e51 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
+2006-02-10 Michael Wybrow <mjwybrow@users.sourceforge.net>
+
+ * 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.
+
2006-02-07 MenTaLguY <mental@rydia.net>
* src/widgets/icon.cpp: get rid of icon prerender time messages
2006-02-07 MenTaLguY <mental@rydia.net>
- * src/debug/gc-heap.h, src/debug/logger.cpp, src/debug/sysv-heap.h,
- src/jabber_whiteboard/deserializer.cpp, src/sp-object.cpp,
- src/util/share.h, src/xml/simple-node.cpp:
+ * src/debug/gc-heap.h, src/debug/logger.cpp, src/debug/sysv-heap.h,
+ src/jabber_whiteboard/deserializer.cpp, src/sp-object.cpp,
+ src/util/share.h, src/xml/simple-node.cpp:
share_static -> share_static_string
diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp
index 6575609022ba557f48479756250e90ed29b299af..8fbdfb6739a97e491fbd77f27f7cdcddaa098566 100644 (file)
--- a/src/conn-avoid-ref.cpp
+++ b/src/conn-avoid-ref.cpp
#include "libnr/nr-rect-ops.h"
#include "libavoid/polyutil.h"
#include "libavoid/incremental.h"
+#include "libavoid/connector.h"
#include "xml/simple-node.cpp"
#include "document.h"
#include "prefs-utils.h"
}
+GSList *SPAvoidRef::getAttachedConnectors(const unsigned int type)
+{
+ GSList *list = NULL;
+
+ Avoid::IntList conns;
+ GQuark shapeId = g_quark_from_string(item->id);
+ Avoid::attachedToShape(conns, shapeId, type);
+
+ Avoid::IntList::iterator finish = conns.end();
+ for (Avoid::IntList::iterator i = conns.begin(); i != finish; ++i) {
+ const gchar *connId = g_quark_to_string(*i);
+ SPItem *item = SP_ITEM(item->document->getObjectById(connId));
+ g_assert(item != NULL);
+ list = g_slist_prepend(list, item);
+ }
+ return list;
+}
+
+
static Avoid::Polygn avoid_item_poly(SPItem const *item)
{
SPDesktop *desktop = inkscape_active_desktop();
diff --git a/src/conn-avoid-ref.h b/src/conn-avoid-ref.h
index ac9295cf917450307ab3a3c23834d15ce04b6757..28d5de28a2fcc69747502620c01a19607efe5607 100644 (file)
--- a/src/conn-avoid-ref.h
+++ b/src/conn-avoid-ref.h
void setAvoid(char const *value);
void handleSettingChange(void);
+
+ // Returns a list of SPItems of all connectors attached to this
+ // object. Pass one of the following for 'type':
+ // Avoid::ConnRef::runningTo
+ // Avoid::ConnRef::runningFrom
+ // Avoid::ConnRef::runningToAndFrom
+ GSList *getAttachedConnectors(const unsigned int type);
private:
SPItem *item;
index 87009541593c4b8a65be7071e0fd8ad84d05d027..04bf7aaada6b573ad8479174a4f263d343b934f0 100644 (file)
*
*/
+#include "libavoid/connector.h"
#include "libavoid/graph.h"
#include "libavoid/makepath.h"
#include "libavoid/visibility.h"
ConnRef::ConnRef(const unsigned int id)
: _id(id)
+ , _srcId(0)
+ , _dstId(0)
, _needs_reroute_flag(true)
, _false_path(false)
, _active(false)
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)
}
+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);
//============================================================================
+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.
index 71713ae414ac61552d5d0b7012b2c1269160eaa5..1fd4255a8a6726550bd99aee289bf190d78fd4e1 100644 (file)
--- a/src/libavoid/connector.h
+++ b/src/libavoid/connector.h
class ConnRef;
typedef std::list<ConnRef *> ConnRefList;
+typedef std::list<unsigned int> IntList;
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);
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;
extern ConnRefList connRefs;
extern void callbackAllInvalidConnectors(void);
+extern void attachedToShape(IntList &conns, const unsigned int shapeId,
+ const unsigned int type);
}
index 84e38037d2531f8a8fa3b13931ac622d2b841e58..6154bd39678fd30adbd098b7eb210bb522e2b6bd 100644 (file)
#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>
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);
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);
index ff1005a1636e474c130a08289008ef803c731cb0..bb5d89107f521b617b9f4034e093b450a2dede71 100644 (file)
--- a/src/sp-conn-end-pair.cpp
+++ b/src/sp-conn-end-pair.cpp
_connRef->lateSetup(src, dst);
_connRef->setCallback(&emitPathInvalidationNotification, _path);
}
+ // Store the ID of the objects attached to the connector.
+ storeIds();
}
}
-
+
+
+void SPConnEndPair::storeIds(void)
+{
+ if (_connEnd[0]->href) {
+ GQuark itemId = g_quark_from_string(_connEnd[0]->href);
+ _connRef->setEndPointId(Avoid::VertID::src, itemId);
+ }
+ else {
+ _connRef->setEndPointId(Avoid::VertID::src, 0);
+ }
+ if (_connEnd[1]->href) {
+ GQuark itemId = g_quark_from_string(_connEnd[1]->href);
+ _connRef->setEndPointId(Avoid::VertID::tar, itemId);
+ }
+ else {
+ _connRef->setEndPointId(Avoid::VertID::tar, 0);
+ }
+}
+
bool
SPConnEndPair::isAutoRoutingConn(void)
diff --git a/src/sp-conn-end-pair.h b/src/sp-conn-end-pair.h
index 9807b4f149093bc5ad9835b44539251306e9d573..3f130da32661058a37e0c22e9e20c2e93a2282bf 100644 (file)
--- a/src/sp-conn-end-pair.h
+++ b/src/sp-conn-end-pair.h
// A sigc connection for transformed signal.
sigc::connection _transformed_connection;
+
+ void storeIds(void);
};