summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f1fbeab)
raw | patch | inline | side by side (parent: f1fbeab)
author | cilix42 <cilix42@users.sourceforge.net> | |
Thu, 16 Aug 2007 14:50:40 +0000 (14:50 +0000) | ||
committer | cilix42 <cilix42@users.sourceforge.net> | |
Thu, 16 Aug 2007 14:50:40 +0000 (14:50 +0000) |
diff --git a/src/attributes.cpp b/src/attributes.cpp
index 9541ff01e769a829b61c37971aa78f91bfef3620..8ac3c8c74baaf40a6f69056b6e3613291aeb709a 100644 (file)
--- a/src/attributes.cpp
+++ b/src/attributes.cpp
{SP_ATTR_INKSCAPE_3DBOX_CORNER_B, "inkscape:box3dcornerB"}, // "lower right front" corner
{SP_ATTR_INKSCAPE_3DBOX_CORNER_C, "inkscape:box3dcornerC"}, // "lower right rear" corner
{SP_ATTR_INKSCAPE_3DBOX_PERSPECTIVE, "inkscape:perspective"},
+ {SP_ATTR_INKSCAPE_3DBOX_FACE, "inkscape:box3dface"},
/* SPEllipse */
{SP_ATTR_R, "r"},
{SP_ATTR_CX, "cx"},
diff --git a/src/attributes.h b/src/attributes.h
index 847266ff3e0f079d07a619fde361d5d3723d6082..73ecf0252568cd4bab3b77fd813beb95040e63d2 100644 (file)
--- a/src/attributes.h
+++ b/src/attributes.h
SP_ATTR_INKSCAPE_3DBOX_CORNER_B, // "lower right front" corner
SP_ATTR_INKSCAPE_3DBOX_CORNER_C, // "lower right rear" corner
SP_ATTR_INKSCAPE_3DBOX_PERSPECTIVE,
+ SP_ATTR_INKSCAPE_3DBOX_FACE,
/* SPEllipse */
SP_ATTR_R,
SP_ATTR_CX,
diff --git a/src/box3d-context.cpp b/src/box3d-context.cpp
index cca0a25c61bc0f7d31c7b78e7ee79dfa12e7c6a6..3b45abdb2450a14da587007aea11f1dd8a292074 100644 (file)
--- a/src/box3d-context.cpp
+++ b/src/box3d-context.cpp
Inkscape::GC::release(repr);
bc.item->transform = SP_ITEM(desktop->currentRoot())->getRelativeTransform(desktop->currentLayer());
- /* Hook paths to the faces of the box */
+ /* Hook paths to the faces of the box (applies last used style if necessary) */
for (int i = 0; i < 6; ++i) {
SP_3DBOX(bc.item)->faces[i]->hook_path_to_3dbox();
}
diff --git a/src/box3d-face.cpp b/src/box3d-face.cpp
index 096e7d7a6bbbd9868bbef2e94c6699f95b1f3178..9a6ca2ef25cd74dbff6130225116388f0bca616b 100644 (file)
--- a/src/box3d-face.cpp
+++ b/src/box3d-face.cpp
#include "svg/svg.h"
#include "box3d-face.h"
+#include "prefs-utils.h"
// FIXME: It's quite redundant to pass the box plus the corners plus the axes. At least the corners can
// theoretically be reconstructed from the box and the axes, but in order to do this we need
SPDesktop *desktop = inkscape_active_desktop();
Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(SP_OBJECT(parent_box3d)));
- GString *pstring = g_string_new("");
- g_string_printf (pstring, "tools.shapes.3dbox.%s", axes_string());
+ /* apply style */
+ bool use_current = prefs_get_int_attribute("tools.shapes.3dbox", "usecurrent", 0);
Inkscape::XML::Node *repr_face = xml_doc->createElement("svg:path");
- sp_desktop_apply_style_tool (desktop, repr_face, pstring->str, false);
+ repr_face->setAttribute("inkscape:box3dface", this->axes_string());
+
+ gchar *descr = g_strconcat ("desktop.", axes_string(), NULL);
+ const gchar * cur_style = prefs_get_string_attribute(descr, "style");
+ if (use_current && cur_style !=NULL) {
+ /* use last used style */
+ repr_face->setAttribute("style", cur_style);
+ } else {
+ /* use default style */
+ GString *pstring = g_string_new("");
+ g_string_printf (pstring, "tools.shapes.3dbox.%s", axes_string());
+ sp_desktop_apply_style_tool (desktop, repr_face, pstring->str, false);
+ }
+ g_free (descr);
this->path = SP_PATH(SP_OBJECT(parent_box3d)->appendChildRepr(repr_face));
Inkscape::GC::release(repr_face);
}
return pstring->str;
}
+gint Box3DFace::descr_to_id (gchar const *descr)
+{
+ if (!strcmp (descr, "XYrear")) { return 5; }
+ if (!strcmp (descr, "XYfront")) { return 4; }
+ if (!strcmp (descr, "XZbottom")) { return 3; }
+ if (!strcmp (descr, "XZtop")) { return 2; }
+ if (!strcmp (descr, "YZleft")) { return 1; }
+ if (!strcmp (descr, "YZright")) { return 0; }
+
+ g_warning ("Invalid description of 3D box face.\n");
+ return -1;
+}
+
/*
Local Variables:
mode:c++
diff --git a/src/box3d-face.h b/src/box3d-face.h
index e69c81e24c8e557295a575491f7bfbb713259dc8..d3d83e7026034f3de138f32010298afdafec6b94 100644 (file)
--- a/src/box3d-face.h
+++ b/src/box3d-face.h
inline void raise_to_top() { SP_ITEM (path)->raiseToTop(); }
gchar * axes_string();
gchar * svg_repr_string();
+ static gint descr_to_id (gchar const *descr);
private:
NR::Point *corners[4];
diff --git a/src/box3d.cpp b/src/box3d.cpp
index c9c03ea9cefc88e666fb0f6b5052ea033ff44a06..dad0ae88cd7df11059a199153ae126dae9a9f9cb 100644 (file)
--- a/src/box3d.cpp
+++ b/src/box3d.cpp
g_warning ("SVG representation of 3D boxes should only contain paths.\n");
continue;
}
- box->faces[face_id]->hook_path_to_3dbox(SP_PATH(face_object));
+ // TODO: Currently we don't check whether all paths are being linked to different faces.
+ // This is no problem with valid SVG files. It may lead to crashes, however,
+ // in case a file is corrupt (e.g., two or more faces have identical descriptions).
+ gint id = Box3DFace::descr_to_id (i->attribute ("inkscape:box3dface"));
+ box->faces[id]->hook_path_to_3dbox(SP_PATH(face_object));
++face_id;
}
if (face_id < 6) {
diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp
index a6a4d8567518399c31f87e2c39d42e9d67ed4792..56fc9d4be7fc14552b7103587d249e8a3ab53b02 100644 (file)
--- a/src/desktop-style.cpp
+++ b/src/desktop-style.cpp
#include "sp-tspan.h"
#include "xml/repr.h"
#include "libnrtype/font-style-to-pos.h"
+#include "sp-path.h"
#include "desktop-style.h"
@@ -161,6 +162,17 @@ sp_desktop_set_style(SPDesktop *desktop, SPCSSAttr *css, bool change, bool write
sp_repr_css_merge(css_write, css);
sp_css_attr_unset_uris(css_write);
sp_repr_css_change(inkscape_get_repr(INKSCAPE, "desktop"), css_write, "style");
+ for (const GSList *i = desktop->selection->itemList(); i != NULL; i = i->next) {
+ /* last used styles for 3D box faces are stored separately */
+ if (SP_IS_PATH (i->data)) {
+ const char * descr = SP_OBJECT_REPR (G_OBJECT (i->data))->attribute ("inkscape:box3dface");
+ if (descr != NULL) {
+ gchar *style_grp = g_strconcat ("desktop.", descr, NULL);
+ sp_repr_css_change(inkscape_get_repr(INKSCAPE, style_grp), css_write, "style");
+ g_free (style_grp);
+ }
+ }
+ }
sp_repr_css_attr_unref(css_write);
}
index 9e5514565cf3497fdeadb6d65c27a752915aeddf..2cceb2a78e7938a7b26ecb898b119581ad2384c0 100644 (file)
" y=\"0\"\n"
" fullscreen=\"0\"\n"
" id=\"geometry\" />\n"
+" <group\n"
+" id=\"XYfront\" />\n"
+" <group\n"
+" id=\"XYrear\" />\n"
+" <group\n"
+" id=\"XZtop\" />\n"
+" <group\n"
+" id=\"XZbottom\" />\n"
+" <group\n"
+" id=\"YZleft\" />\n"
+" <group\n"
+" id=\"YZright\" />\n"
" </group>\n"
"\n"
" <group id=\"devices\">\n"