summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMaximilian Albert <maximilian.albert@gmail.com>2007-07-10 14:07:52 +0000
committercilix42 <cilix42@users.sourceforge.net>2007-07-10 14:07:52 +0000
commit1b7cb8770d6323a7e96801adf5f7b87beec72512 (patch)
treecb2eca790e3aea052b6241349331930fd3dbb486 /src
parentCreate all 3D box faces in the beginning (fixes resizing bug; first step towa... (diff)
downloadinkscape-1b7cb8770d6323a7e96801adf5f7b87beec72512.tar.gz
inkscape-1b7cb8770d6323a7e96801adf5f7b87beec72512.zip
Different default styles for non-parallel 3D box faces
(bzr r3213)
Diffstat (limited to 'src')
-rw-r--r--src/box3d-context.cpp2
-rw-r--r--src/box3d-face.cpp44
-rw-r--r--src/box3d-face.h3
-rw-r--r--src/preferences-skeleton.h9
4 files changed, 47 insertions, 11 deletions
diff --git a/src/box3d-context.cpp b/src/box3d-context.cpp
index 395623171..0da88ac1d 100644
--- a/src/box3d-context.cpp
+++ b/src/box3d-context.cpp
@@ -523,7 +523,7 @@ static void sp_3dbox_drag(SP3DBoxContext &bc, guint state)
repr->setAttribute("sodipodi:type", "inkscape:3dbox");
/* Set style */
- //sp_desktop_apply_style_tool (desktop, repr, "tools.shapes.3dbox", false);
+ sp_desktop_apply_style_tool (desktop, repr, "tools.shapes.3dbox", false);
bc.item = (SPItem *) desktop->currentLayer()->appendChildRepr(repr);
Inkscape::GC::release(repr);
diff --git a/src/box3d-face.cpp b/src/box3d-face.cpp
index 2c2d6209a..02c84e22c 100644
--- a/src/box3d-face.cpp
+++ b/src/box3d-face.cpp
@@ -21,12 +21,12 @@
// box3d-face.h).
Box3DFace::Box3DFace(SP3DBox *box, NR::Point &A, NR::Point &B, NR::Point &C, NR::Point &D,
Box3D::Axis plane, Box3D::FrontOrRear rel_pos)
- : path (NULL), parent_box3d (box)
+ : front_or_rear (rel_pos), path (NULL), parent_box3d (box)
{
- /*
- Box3D::Axis axis = (rel_pos == Box3D::FRONT ? Box3D::NONE : Box3D::third_axis_direction (plane));
dir1 = extract_first_axis_direction (plane);
dir2 = extract_second_axis_direction (plane);
+ /*
+ Box3D::Axis axis = (rel_pos == Box3D::FRONT ? Box3D::NONE : Box3D::third_axis_direction (plane));
set_corners (box->corners[axis],
box->corners[axis ^ dir1],
box->corners[axis ^ dir1 ^ dir2],
@@ -156,6 +156,8 @@ NR::Point Box3DFace::operator[](unsigned int i)
return *corners[i % 4];
}
+
+
/**
* Append the curve's path as a child to the given 3D box (since SP3DBox
* is derived from SPGroup, so we can append children to its svg representation)
@@ -166,9 +168,13 @@ void Box3DFace::hook_path_to_3dbox()
SPDesktop *desktop = inkscape_active_desktop();
Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_EVENT_CONTEXT_DOCUMENT(inkscape_active_event_context()));
+ GString *pstring = g_string_new("");
+ g_string_printf (pstring, "tools.shapes.3dbox.%s", axes_string());
+
Inkscape::XML::Node *repr_face = xml_doc->createElement("svg:path");
- sp_desktop_apply_style_tool (desktop, repr_face, "tools.shapes.3dbox", false);
+ sp_desktop_apply_style_tool (desktop, repr_face, pstring->str, false);
this->path = SP_PATH(SP_OBJECT(parent_box3d)->appendChildRepr(repr_face));
+
Inkscape::GC::release(repr_face);
}
@@ -197,15 +203,35 @@ void Box3DFace::set_curve()
sp_curve_unref(curve);
}
+gchar * Box3DFace::axes_string()
+{
+ GString *pstring = g_string_new("");
+ g_string_printf (pstring, "%s", Box3D::string_from_axes ((Box3D::Axis) (dir1 ^ dir2)));
+ switch ((Box3D::Axis) (dir1 ^ dir2)) {
+ case Box3D::XY:
+ g_string_append_printf (pstring, (front_or_rear == Box3D::FRONT) ? "front" : "rear");
+ break;
+ case Box3D::XZ:
+ g_string_append_printf (pstring, (front_or_rear == Box3D::FRONT) ? "top" : "bottom");
+ break;
+ case Box3D::YZ:
+ g_string_append_printf (pstring, (front_or_rear == Box3D::FRONT) ? "right" : "left");
+ break;
+ default:
+ break;
+ }
+ return pstring->str;
+}
+
gchar * Box3DFace::svg_repr_string()
{
NR::Matrix const i2d (sp_item_i2d_affine (SP_ITEM (this->parent_box3d)));
GString *pstring = g_string_new("");
- g_string_sprintf (pstring, "M %f,%f L %f,%f L %f,%f L %f,%f z",
- ((*corners[0]) * i2d)[NR::X], ((*corners[0]) * i2d)[NR::Y],
- ((*corners[1]) * i2d)[NR::X], ((*corners[1]) * i2d)[NR::Y],
- ((*corners[2]) * i2d)[NR::X], ((*corners[2]) * i2d)[NR::Y],
- ((*corners[3]) * i2d)[NR::X], ((*corners[3]) * i2d)[NR::Y]);
+ g_string_printf (pstring, "M %f,%f L %f,%f L %f,%f L %f,%f z",
+ ((*corners[0]) * i2d)[NR::X], ((*corners[0]) * i2d)[NR::Y],
+ ((*corners[1]) * i2d)[NR::X], ((*corners[1]) * i2d)[NR::Y],
+ ((*corners[2]) * i2d)[NR::X], ((*corners[2]) * i2d)[NR::Y],
+ ((*corners[3]) * i2d)[NR::X], ((*corners[3]) * i2d)[NR::Y]);
return pstring->str;
}
diff --git a/src/box3d-face.h b/src/box3d-face.h
index 08729150e..04e012b41 100644
--- a/src/box3d-face.h
+++ b/src/box3d-face.h
@@ -45,6 +45,7 @@ public:
void hook_path_to_3dbox();
void set_path_repr();
void set_curve();
+ gchar * axes_string();
gchar * svg_repr_string();
private:
@@ -52,6 +53,8 @@ private:
Box3D::Axis dir1;
Box3D::Axis dir2;
+
+ Box3D::FrontOrRear front_or_rear;
SPPath *path;
SP3DBox *parent_box3d;
diff --git a/src/preferences-skeleton.h b/src/preferences-skeleton.h
index ead8e7a62..d1d6bd529 100644
--- a/src/preferences-skeleton.h
+++ b/src/preferences-skeleton.h
@@ -51,7 +51,14 @@ static char const preferences_skeleton[] =
" style=\"fill:none;stroke:black;stroke-opacity:1;stroke-width:1px;stroke-linejoin:miter;stroke-linecap:butt;\">\n"
" <group id=\"shapes\" style=\"fill-rule:evenodd;\" selcue=\"1\" gradientdrag=\"1\">\n"
" <eventcontext id=\"rect\" style=\"fill:blue;\" usecurrent=\"1\"/>\n"
-" <eventcontext id=\"3dbox\" style=\"fill:blue;\" usecurrent=\"1\"/>\n"
+" <eventcontext id=\"3dbox\" style=\"fill:none;stroke:blue;stroke-linejoin:round;\" usecurrent=\"0\">\n"
+" <side id=\"XYfront\" style=\"stroke:#0000ff;stroke-width:2.5px;\" usecurrent=\"0\"/>\n"
+" <side id=\"XYrear\" style=\"stroke:#0000ff;stroke-width:2.5px;\" usecurrent=\"0\"/>\n"
+" <side id=\"XZtop\" style=\"stroke:#f0ee00;stroke-width:2.5px;\" usecurrent=\"0\"/>\n"
+" <side id=\"XZbottom\" style=\"stroke:#f0ee00;stroke-width:2.5px;\" usecurrent=\"0\"/>\n"
+" <side id=\"YZright\" style=\"stroke:#ff0000;stroke-width:2.5px;\" usecurrent=\"0\"/>\n"
+" <side id=\"YZleft\" style=\"stroke:#ff0000;stroke-width:2.5px;\" usecurrent=\"0\"/>\n"
+" </eventcontext>\n"
" <eventcontext id=\"arc\" style=\"fill:red;\" end=\"0\" start=\"0\" usecurrent=\"1\"/>\n"
" <eventcontext id=\"star\" magnitude=\"5\" style=\"fill:yellow;\" usecurrent=\"1\"/>\n"
" <eventcontext id=\"spiral\" style=\"fill:none;\" usecurrent=\"0\"/>\n"