summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAbhishek Sharma Public <spyzerdotabhishek0at-signgmaildotcom>2010-07-17 07:18:31 +0000
committerAbhishek Sharma Public <spyzerdotabhishek0at-signgmaildotcom>2010-07-17 07:18:31 +0000
commit150ac8ed3274e060e3349b5c0901ec8c7c7e3d4e (patch)
treee05bd4506842f0e70e80e4327bd438d715d8dd70 /src
parentSPShape c++ified to the extent it was possible and more changes done for XML ... (diff)
downloadinkscape-150ac8ed3274e060e3349b5c0901ec8c7c7e3d4e.tar.gz
inkscape-150ac8ed3274e060e3349b5c0901ec8c7c7e3d4e.zip
More in XML privatisation with new create3DBox function and other supplements to efficiently hide information.
(bzr r9546.1.8)
Diffstat (limited to 'src')
-rw-r--r--src/box3d-context.cpp36
-rw-r--r--src/box3d-side.cpp12
-rw-r--r--src/box3d-side.h1
-rw-r--r--src/box3d.cpp12
-rw-r--r--src/box3d.h1
-rw-r--r--src/desktop.cpp22
-rw-r--r--src/desktop.h2
7 files changed, 70 insertions, 16 deletions
diff --git a/src/box3d-context.cpp b/src/box3d-context.cpp
index e48f7e17d..99cf28963 100644
--- a/src/box3d-context.cpp
+++ b/src/box3d-context.cpp
@@ -588,25 +588,28 @@ static void sp_box3d_drag(Box3DContext &bc, guint /*state*/)
//Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_EVENT_CONTEXT_DOCUMENT(&bc));
/*To be removed for directly accessing the XML Document*/
- Inkscape::XML::Document *xml_doc = desktop->doc()->rdoc;
- Inkscape::XML::Node *repr = xml_doc->createElement("svg:g");
- repr->setAttribute("sodipodi:type", "inkscape:box3d");
-
+ //Inkscape::XML::Document *xml_doc = desktop->doc()->rdoc;
+ //Inkscape::XML::Node *repr = xml_doc->createElement("svg:g");
+ //repr->setAttribute("sodipodi:type", "inkscape:box3d");
+ SPBox3D *box3d = 0;
+ box3d = SPBox3D::createBox3D((SPItem *)desktop->currentLayer());
/* Set style */
- sp_desktop_apply_style_tool (desktop, repr, "/tools/shapes/3dbox", false);
-
- bc.item = (SPItem *) desktop->currentLayer()->appendChildRepr(repr);
- Inkscape::GC::release(repr);
- Inkscape::XML::Node *repr_side;
+ desktop->applyCurrentOrToolStyle(box3d, "/tools/shapes/3dbox", false);
+
+ bc.item = box3d;
+ //bc.item = (SPItem *) desktop->currentLayer()->appendChildRepr(repr);
+ //Inkscape::GC::release(repr);
+ //Inkscape::XML::Node *repr_side;
// TODO: Incorporate this in box3d-side.cpp!
for (int i = 0; i < 6; ++i) {
- repr_side = xml_doc->createElement("svg:path");
- repr_side->setAttribute("sodipodi:type", "inkscape:box3dside");
- repr->addChild(repr_side, NULL);
+ //repr_side = xml_doc->createElement("svg:path");
+ //repr_side->setAttribute("sodipodi:type", "inkscape:box3dside");
+ //repr->addChild(repr_side, NULL);
//Box3DSide *side = SP_BOX3D_SIDE(inkscape_active_document()->getObjectByRepr (repr_side));
- Box3DSide *side = SP_BOX3D_SIDE(desktop->doc()->getObjectByRepr(repr_side));
-
+ //Box3DSide *side = SP_BOX3D_SIDE(desktop->doc()->getObjectByRepr(repr_side));
+ Box3DSide *side = Box3DSide::createBox3DSide(box3d);
+
guint desc = Box3D::int_to_face(i);
Box3D::Axis plane = (Box3D::Axis) (desc & 0x7);
@@ -635,11 +638,12 @@ static void sp_box3d_drag(Box3DContext &bc, guint /*state*/)
// use default style
GString *pstring = g_string_new("");
g_string_printf (pstring, "/tools/shapes/3dbox/%s", box3d_side_axes_string(side));
- sp_desktop_apply_style_tool (desktop, side->getRepr(), pstring->str, false);
+ desktop->applyCurrentOrToolStyle (side, pstring->str, false);
}
- SP_OBJECT(side)->updateRepr(); // calls box3d_side_write() and updates, e.g., the axes string description
+ //SP_OBJECT(side)->updateRepr(); // calls box3d_side_write() and updates, e.g., the axes string description
+ side->updateRepr(); // calls box3d_side_write() and updates, e.g., the axes string description
}
box3d_set_z_orders(SP_BOX3D(bc.item));
diff --git a/src/box3d-side.cpp b/src/box3d-side.cpp
index 9059e9705..d6f1f6b42 100644
--- a/src/box3d-side.cpp
+++ b/src/box3d-side.cpp
@@ -185,6 +185,18 @@ box3d_side_update (SPObject *object, SPCtx *ctx, guint flags)
if (((SPObjectClass *) parent_class)->update)
((SPObjectClass *) parent_class)->update (object, ctx, flags);
}
+
+/* Create a new Box3DSide and append it to the parent box */
+Box3DSide * Box3DSide::createBox3DSide(SPBox3D *box)
+{
+ Box3DSide *box3d_side = 0;
+ Inkscape::XML::Document *xml_doc = box->document->rdoc;
+ Inkscape::XML::Node *repr_side = xml_doc->createElement("svg:path");
+ repr_side->setAttribute("sodipodi:type", "inkscape:box3dside");
+ box3d_side = (Box3DSide *)box->appendChildRepr(repr_side);
+ return box3d_side;
+}
+
/*
* Function which return the type attribute for Box3D.
* Acts as a replacement for directly accessing the XML Tree directly.
diff --git a/src/box3d-side.h b/src/box3d-side.h
index 6014ddaae..29a4a6b00 100644
--- a/src/box3d-side.h
+++ b/src/box3d-side.h
@@ -32,6 +32,7 @@ struct Box3DSide : public SPPolygon {
Box3D::Axis dir2;
Box3D::FrontOrRear front_or_rear;
long long int getFaceId();
+ static Box3DSide * createBox3DSide(SPBox3D *box);
};
struct Box3DSideClass {
diff --git a/src/box3d.cpp b/src/box3d.cpp
index 1facf2c0c..250c1f500 100644
--- a/src/box3d.cpp
+++ b/src/box3d.cpp
@@ -511,6 +511,18 @@ box3d_snap (SPBox3D *box, int id, Proj::Pt3 const &pt_proj, Proj::Pt3 const &sta
return box3d_get_perspective(box)->perspective_impl->tmat.preimage (result, z_coord, Proj::Z);
}
+/*create a SPBox3D and append it to the parent*/
+
+SPBox3D * SPBox3D::createBox3D(SPItem * parent)
+{
+ SPBox3D *box3d = 0;
+ Inkscape::XML::Document *xml_doc = parent->document->rdoc;
+ Inkscape::XML::Node *repr = xml_doc->createElement("svg:g");
+ repr->setAttribute("sodipodi:type", "inkscape:box3d");
+ box3d = (SPBox3D *)parent->appendChildRepr(repr);
+ return box3d;
+}
+
void
box3d_set_corner (SPBox3D *box, const guint id, Geom::Point const &new_pos, const Box3D::Axis movement, bool constrained) {
g_return_if_fail ((movement != Box3D::NONE) && (movement != Box3D::XYZ));
diff --git a/src/box3d.h b/src/box3d.h
index 182a312e1..e313f4285 100644
--- a/src/box3d.h
+++ b/src/box3d.h
@@ -45,6 +45,7 @@ class SPBox3D : public SPGroup {
Box3D::Axis swapped; // to indicate which coordinates are swapped during dragging
gint my_counter; // for debugging only
+ static SPBox3D * createBox3D(SPItem * parent);
};
class SPBox3DClass {
diff --git a/src/desktop.cpp b/src/desktop.cpp
index d5e7974ea..3f9fc7806 100644
--- a/src/desktop.cpp
+++ b/src/desktop.cpp
@@ -90,6 +90,7 @@
#include "display/canvas-grid.h"
#include "widgets/desktop-widget.h"
#include "box3d-context.h"
+#include "desktop-style.h"
// TODO those includes are only for node tool quick zoom. Remove them after fixing it.
#include "ui/tool/node-tool.h"
@@ -961,6 +962,27 @@ SPDesktop::zoom_absolute_keep_point (double cx, double cy, double px, double py,
}
/**
+ * Apply the desktop's current style or the tool style to the object.
+ */
+void SPDesktop::applyCurrentOrToolStyle(SPObject *obj, Glib::ustring const &tool_path, bool with_text)
+{
+ SPCSSAttr *css_current = sp_desktop_get_style(this, with_text);
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+
+ if (prefs->getBool(tool_path + "/usecurrent") && css_current) {
+ sp_repr_css_set(obj->getRepr(), css_current, "style");
+ } else {
+ SPCSSAttr *css = prefs->getInheritedStyle(tool_path + "/style");
+ sp_repr_css_set(obj->getRepr(), css, "style");
+ sp_repr_css_attr_unref(css);
+ }
+ if (css_current) {
+ sp_repr_css_attr_unref(css_current);
+ }
+
+}
+
+/**
* Zoom to center with absolute zoom factor.
*/
void
diff --git a/src/desktop.h b/src/desktop.h
index 00f6cfdd5..59ba3f957 100644
--- a/src/desktop.h
+++ b/src/desktop.h
@@ -324,6 +324,8 @@ struct SPDesktop : public Inkscape::UI::View::View
virtual bool onDeleteUI (GdkEventAny*);
virtual bool onWindowStateEvent (GdkEventWindowState* event);
+ void applyCurrentOrToolStyle(SPObject *obj, Glib::ustring const &tool_path, bool with_text);
+
private:
Inkscape::UI::View::EditWidgetInterface *_widget;
Inkscape::Application *_inkscape;