summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/display/drawing-item.cpp24
-rw-r--r--src/display/drawing-item.h2
-rw-r--r--src/sp-object.cpp16
-rw-r--r--src/sp-object.h2
-rw-r--r--src/sp-root.cpp9
-rw-r--r--src/xml/node.h2
-rw-r--r--src/xml/simple-node.cpp20
-rw-r--r--src/xml/simple-node.h3
8 files changed, 78 insertions, 0 deletions
diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp
index 8ed74b550..8a438e1c2 100644
--- a/src/display/drawing-item.cpp
+++ b/src/display/drawing-item.cpp
@@ -908,6 +908,30 @@ DrawingItem::pick(Geom::Point const &p, double delta, unsigned flags)
return NULL;
}
+
+// For debugging: Print drawing tree structure.
+void
+DrawingItem::recursivePrintTree( unsigned level )
+{
+ if (level == 0) {
+ std::cout << "Display Item Tree" << std::endl;
+ }
+ std::cout << "DI: ";
+ for (unsigned i = 0; i < level; ++i) {
+ std::cout << " ";
+ }
+ SPObject *object = static_cast<SPObject *>(_user_data);
+ if (object) {
+ std::cout << (object->getId()?object->getId():"No object id") << std::endl;
+ } else {
+ std::cout << "No associated object" << std::endl;
+ }
+ for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) {
+ i->recursivePrintTree( level+1 );
+ }
+}
+
+
/**
* Marks the current visual bounding box of the item for redrawing.
* This is called whenever the object changes its visible appearance.
diff --git a/src/display/drawing-item.h b/src/display/drawing-item.h
index 9b399e6e3..585f3811f 100644
--- a/src/display/drawing-item.h
+++ b/src/display/drawing-item.h
@@ -131,6 +131,8 @@ public:
void clip(DrawingContext &dc, Geom::IntRect const &area);
DrawingItem *pick(Geom::Point const &p, double delta, unsigned flags = 0);
+ void recursivePrintTree(unsigned level = 0); // For debugging
+
protected:
enum ChildType {
CHILD_ORPHAN = 0, // no parent - implies _parent == NULL
diff --git a/src/sp-object.cpp b/src/sp-object.cpp
index 4e45eb824..3b09d80e8 100644
--- a/src/sp-object.cpp
+++ b/src/sp-object.cpp
@@ -1523,6 +1523,22 @@ char* SPObject::textualContent() const
return g_string_free(text, FALSE);
}
+// For debugging: Print SP tree structure.
+void SPObject::recursivePrintTree( unsigned level )
+{
+ if (level == 0) {
+ std::cout << "SP Object Tree" << std::endl;
+ }
+ std::cout << "SP: ";
+ for (unsigned i = 0; i < level; ++i) {
+ std::cout << " ";
+ }
+ std::cout << (getId()?getId():"No object id") << std::endl;
+ for (SPObject *child = children; child; child = child->next) {
+ child->recursivePrintTree( level+1 );
+ }
+}
+
/*
Local Variables:
mode:c++
diff --git a/src/sp-object.h b/src/sp-object.h
index d08add0bf..669dfc713 100644
--- a/src/sp-object.h
+++ b/src/sp-object.h
@@ -854,6 +854,8 @@ protected:
public:
virtual void read_content();
+
+ void recursivePrintTree(unsigned level = 0); // For debugging
};
diff --git a/src/sp-root.cpp b/src/sp-root.cpp
index 12570e03e..85582e209 100644
--- a/src/sp-root.cpp
+++ b/src/sp-root.cpp
@@ -375,6 +375,15 @@ Inkscape::DrawingItem *SPRoot::show(Inkscape::Drawing &drawing, unsigned int key
g->setChildTransform(this->c2p);
}
+ // Uncomment to print out XML tree
+ // getRepr()->recursivePrintTree(0);
+
+ // Uncomment to print out SP Object tree
+ // recursivePrintTree(0);
+
+ // Uncomment to print out Display Item tree
+ // ai->recursivePrintTree(0);
+
return ai;
}
diff --git a/src/xml/node.h b/src/xml/node.h
index 8bb70acc0..29cfdab46 100644
--- a/src/xml/node.h
+++ b/src/xml/node.h
@@ -469,6 +469,8 @@ public:
* @deprecated Use synthesizeEvents(NodeObserver &) instead
*/
virtual void synthesizeEvents(NodeEventVector const *vector, void *data)=0;
+
+ virtual void recursivePrintTree(unsigned level)=0;
/*@}*/
diff --git a/src/xml/simple-node.cpp b/src/xml/simple-node.cpp
index 4965f81c8..3cbedc80b 100644
--- a/src/xml/simple-node.cpp
+++ b/src/xml/simple-node.cpp
@@ -606,6 +606,26 @@ void SimpleNode::synthesizeEvents(NodeObserver &observer) {
synthesizeEvents(&OBSERVER_EVENT_VECTOR, &observer);
}
+void SimpleNode::recursivePrintTree(unsigned level) {
+
+ if (level == 0) {
+ std::cout << "XML Node Tree" << std::endl;
+ }
+ std::cout << "XML: ";
+ for (unsigned i = 0; i < level; ++i) {
+ std::cout << " ";
+ }
+ char const *id=attribute("id");
+ if (id) {
+ std::cout << id << std::endl;
+ } else {
+ std::cout << name() << std::endl;
+ }
+ for (SimpleNode *child = _first_child; child != NULL; child = child->_next) {
+ child->recursivePrintTree( level+1 );
+ }
+}
+
Node *SimpleNode::root() {
Node *parent=this;
while (parent->parent()) {
diff --git a/src/xml/simple-node.h b/src/xml/simple-node.h
index 1fcb9193b..d09392249 100644
--- a/src/xml/simple-node.h
+++ b/src/xml/simple-node.h
@@ -19,6 +19,7 @@
#define SEEN_INKSCAPE_XML_SIMPLE_NODE_H
#include <cassert>
+#include <iostream>
#include "xml/node.h"
#include "xml/attribute-record.h"
@@ -120,6 +121,8 @@ public:
_subtree_observers.remove(observer);
}
+ void recursivePrintTree(unsigned level = 0);
+
protected:
SimpleNode(int code, Document *document);
SimpleNode(SimpleNode const &repr, Document *document);