summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMaximilian Albert <maximilian.albert@gmail.com>2007-08-16 14:50:40 +0000
committercilix42 <cilix42@users.sourceforge.net>2007-08-16 14:50:40 +0000
commiteb0e63b411b5f0713e73e95b9865294bd83fb646 (patch)
tree97773c5edb1f092ab1b3114e67005f7e9e9f987d /src
parentDon't use lowercase keyboard shortcuts in 3D box tool (diff)
downloadinkscape-eb0e63b411b5f0713e73e95b9865294bd83fb646.tar.gz
inkscape-eb0e63b411b5f0713e73e95b9865294bd83fb646.zip
Remember last used style for single 3D box faces (also fixes bug with wrongly assigned faces for duplicated boxes, e.g.)
(bzr r3481)
Diffstat (limited to 'src')
-rw-r--r--src/attributes.cpp1
-rw-r--r--src/attributes.h1
-rw-r--r--src/box3d-context.cpp2
-rw-r--r--src/box3d-face.cpp33
-rw-r--r--src/box3d-face.h1
-rw-r--r--src/box3d.cpp6
-rw-r--r--src/desktop-style.cpp12
-rw-r--r--src/preferences-skeleton.h12
8 files changed, 63 insertions, 5 deletions
diff --git a/src/attributes.cpp b/src/attributes.cpp
index 9541ff01e..8ac3c8c74 100644
--- a/src/attributes.cpp
+++ b/src/attributes.cpp
@@ -117,6 +117,7 @@ static SPStyleProp const props[] = {
{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 847266ff3..73ecf0252 100644
--- a/src/attributes.h
+++ b/src/attributes.h
@@ -117,6 +117,7 @@ enum SPAttributeEnum {
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 cca0a25c6..3b45abdb2 100644
--- a/src/box3d-context.cpp
+++ b/src/box3d-context.cpp
@@ -581,7 +581,7 @@ static void sp_3dbox_drag(SP3DBoxContext &bc, guint state)
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 096e7d7a6..9a6ca2ef2 100644
--- a/src/box3d-face.cpp
+++ b/src/box3d-face.cpp
@@ -13,6 +13,7 @@
#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
@@ -178,11 +179,24 @@ void Box3DFace::hook_path_to_3dbox(SPPath * existing_path)
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);
}
@@ -239,6 +253,19 @@ gchar * Box3DFace::axes_string()
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 e69c81e24..d3d83e702 100644
--- a/src/box3d-face.h
+++ b/src/box3d-face.h
@@ -49,6 +49,7 @@ public:
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 c9c03ea9c..dad0ae88c 100644
--- a/src/box3d.cpp
+++ b/src/box3d.cpp
@@ -514,7 +514,11 @@ sp_3dbox_link_to_existing_paths (SP3DBox *box, Inkscape::XML::Node *repr) {
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 a6a4d8567..56fc9d4be 100644
--- a/src/desktop-style.cpp
+++ b/src/desktop-style.cpp
@@ -37,6 +37,7 @@
#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);
}
diff --git a/src/preferences-skeleton.h b/src/preferences-skeleton.h
index 9e5514565..2cceb2a78 100644
--- a/src/preferences-skeleton.h
+++ b/src/preferences-skeleton.h
@@ -238,6 +238,18 @@ static char const preferences_skeleton[] =
" 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"