summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bb0242d)
raw | patch | inline | side by side (parent: bb0242d)
author | mjwybrow <mjwybrow@users.sourceforge.net> | |
Tue, 14 Feb 2006 00:36:28 +0000 (00:36 +0000) | ||
committer | mjwybrow <mjwybrow@users.sourceforge.net> | |
Tue, 14 Feb 2006 00:36:28 +0000 (00:36 +0000) |
src/conn-avoid-ref.h, src/libavoid/connector.cpp,
src/libavoid/connector.h:
Change the behaviour and naming of some connector querying code
after feedback from Tim Dwyer in implementing graph drawing
functionality.
src/libavoid/connector.h:
Change the behaviour and naming of some connector querying code
after feedback from Tim Dwyer in implementing graph drawing
functionality.
diff --git a/ChangeLog b/ChangeLog
index f55fd6ba2992a41c7232bada50e02a45a33c8cad..c5ff0b589f65596630a1f1ac0e3b3a3220738f83 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
+2006-02-13 Michael Wybrow <mjwybrow@users.sourceforge.net>
+
+ * src/graphlayout/graphlayout.cpp, src/conn-avoid-ref.cpp,
+ src/conn-avoid-ref.h, src/libavoid/connector.cpp,
+ src/libavoid/connector.h:
+
+ Change the behaviour and naming of some connector querying code
+ after feedback from Tim Dwyer in implementing graph drawing
+ functionality.
+
2006-02-11 Michael Wybrow <mjwybrow@users.sourceforge.net>
* src/sp-conn-end-pair.cpp, src/conn-avoid-ref.cpp:
diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp
index d7cca60f915f2e27de08e24f584fffb66c3f110c..d832a34b4b81491a31d3c9ea234cf1cbc3868090 100644 (file)
--- a/src/conn-avoid-ref.cpp
+++ b/src/conn-avoid-ref.cpp
}
+GSList *SPAvoidRef::getAttachedShapes(const unsigned int type)
+{
+ GSList *list = NULL;
+
+ Avoid::IntList shapes;
+ GQuark shapeId = g_quark_from_string(item->id);
+ Avoid::attachedShapes(shapes, shapeId, type);
+
+ Avoid::IntList::iterator finish = shapes.end();
+ for (Avoid::IntList::iterator i = shapes.begin(); i != finish; ++i) {
+ const gchar *connId = g_quark_to_string(*i);
+ SPObject *obj = item->document->getObjectById(connId);
+ if (obj == NULL) {
+ g_warning("getAttachedShapes: Object with id=\"%s\" is not "
+ "found. Skipping.", connId);
+ continue;
+ }
+ SPItem *shapeItem = SP_ITEM(obj);
+ list = g_slist_prepend(list, shapeItem);
+ }
+ return list;
+}
+
+
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::attachedConns(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 *citem = SP_ITEM(item->document->getObjectById(connId));
- g_assert(citem != NULL);
- list = g_slist_prepend(list, citem);
+ SPObject *obj = item->document->getObjectById(connId);
+ if (obj == NULL) {
+ g_warning("getAttachedConnectors: Object with id=\"%s\" is not "
+ "found. Skipping.", connId);
+ continue;
+ }
+ SPItem *connItem = SP_ITEM(obj);
+ list = g_slist_prepend(list, connItem);
}
return list;
}
diff --git a/src/conn-avoid-ref.h b/src/conn-avoid-ref.h
index 28d5de28a2fcc69747502620c01a19607efe5607..a30dc4b9366794bb3da87d2343e6f1319be7f209 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':
+ // Returns a list of SPItems of all connectors/shapes attached to
+ // this object. Pass one of the following for 'type':
// Avoid::ConnRef::runningTo
// Avoid::ConnRef::runningFrom
// Avoid::ConnRef::runningToAndFrom
+ GSList *getAttachedShapes(const unsigned int type);
GSList *getAttachedConnectors(const unsigned int type);
private:
index 77452aff2323506d60934a4a2a221e86cb8c79ae..112a942a7ecd238ebad67190ca10b6bd5eafbed7 100644 (file)
using NR::X; using NR::Y;
SPItem *itu=*it;
Vertex u=nodelookup[itu->id];
- GSList *nlist=itu->avoidRef->getAttachedConnectors(Avoid::ConnRef::runningFrom);
+ GSList *nlist=itu->avoidRef->getAttachedShapes(Avoid::ConnRef::runningFrom);
std::list<SPItem *> neighbours;
neighbours.insert<GSListConstIterator<SPItem *> >(neighbours.end(),nlist,NULL);
for (std::list<SPItem *>::iterator ne(neighbours.begin());
index 06a0cd4aae24e81ab9adba6db33b30ff60336a26..4d582174157f679df1eab4bd5ab8d2a51ebda74e 100644 (file)
const unsigned int ConnRef::runningToAndFrom =
ConnRef::runningTo | ConnRef::runningFrom;
+// XXX: attachedShapes and attachedConns both need to be rewritten
+// for constant time lookup of attached objects once this info
+// is stored better within libavoid.
-void attachedToShape(IntList &conns, const unsigned int shapeId,
+
+ // Returns a list of connector Ids of all the connectors of type
+ // 'type' attached to the shape with the ID 'shapeId'.
+void attachedConns(IntList &conns, const unsigned int shapeId,
const unsigned int type)
{
ConnRefList::iterator fin = connRefs.end();
}
+ // Returns a list of shape Ids of all the shapes attached to the
+ // shape with the ID 'shapeId' with connection type 'type'.
+void attachedShapes(IntList &shapes, 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)) {
+ if ((*i)->_srcId != 0)
+ {
+ // Only if there is a shape attached to the other end.
+ shapes.push_back((*i)->_srcId);
+ }
+ }
+ else if ((type & ConnRef::runningFrom) && ((*i)->_srcId == shapeId)) {
+ if ((*i)->_dstId != 0)
+ {
+ // Only if there is a shape attached to the other end.
+ shapes.push_back((*i)->_dstId);
+ }
+ }
+ }
+}
+
+
// It's intended this function is called after shape movement has
// happened to alert connectors that they need to be rerouted.
void callbackAllInvalidConnectors(void)
index 1fd4255a8a6726550bd99aee289bf190d78fd4e1..a08b9ab8af19bd185fab5ec6ee93e2f2ff95a753 100644 (file)
--- a/src/libavoid/connector.h
+++ b/src/libavoid/connector.h
void makePathInvalid(void);
friend void markConnectors(ShapeRef *shape);
- friend void attachedToShape(IntList &conns,
+ friend void attachedShapes(IntList &shapes,
+ const unsigned int shapeId, const unsigned int type);
+ friend void attachedConns(IntList &conns,
const unsigned int shapeId, const unsigned int type);
static const unsigned int runningTo;
extern ConnRefList connRefs;
extern void callbackAllInvalidConnectors(void);
-extern void attachedToShape(IntList &conns, const unsigned int shapeId,
+extern void attachedConns(IntList &conns, const unsigned int shapeId,
+ const unsigned int type);
+extern void attachedShapes(IntList &shapes, const unsigned int shapeId,
const unsigned int type);
}