diff --git a/src/box3d-face.cpp b/src/box3d-face.cpp
index 287e5e2053e6182ad9117bd38157382d9553c267..a1b7ae863c45f6629005f01defada8948d11d493 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
} else {
if (align_along_PL) {
Box3D::Axis dir3 = Box3D::third_axis_direction (dir1, dir2);
- Box3D::Line line1(*SP3DBoxContext::current_perspective->get_vanishing_point(dir1), lr);
- Box3D::Line line2(*pt_align, *SP3DBoxContext::current_perspective->get_vanishing_point(dir3));
+ Box3D::Line line1(*Box3D::Perspective3D::current_perspective->get_vanishing_point(dir1), lr);
+ Box3D::Line line2(*pt_align, *Box3D::Perspective3D::current_perspective->get_vanishing_point(dir3));
corners[2] = *line1.intersect(line2);
} else {
- corners[2] = Box3D::Line(*pt_align, *SP3DBoxContext::current_perspective->get_vanishing_point(dir1)).closest_to(lr);
+ corners[2] = Box3D::Line(*pt_align, *Box3D::Perspective3D::current_perspective->get_vanishing_point(dir1)).closest_to(lr);
}
}
*
* Note that several other functions rely on this precise order.
*/
+/***
void
Box3DFace::set_face (NR::Point const A, NR::Point const C, Box3D::Axis const axis1, Box3D::Axis const axis2)
{
@@ -130,12 +132,12 @@ Box3DFace::set_face (NR::Point const A, NR::Point const C, Box3D::Axis const axi
return;
SP3DBoxContext *bc = SP_3DBOX_CONTEXT(inkscape_active_event_context());
- Box3D::PerspectiveLine line1 (A, axis1);
- Box3D::PerspectiveLine line2 (C, axis2);
+ Box3D::PerspectiveLine line1 (A, axis1, Box3D::Perspective3D::current_perspective);
+ Box3D::PerspectiveLine line2 (C, axis2, Box3D::Perspective3D::current_perspective);
NR::Maybe<NR::Point> B = line1.intersect(line2);
- Box3D::PerspectiveLine line3 (*corners[0], axis2);
- Box3D::PerspectiveLine line4 (*corners[2], axis1);
+ Box3D::PerspectiveLine line3 (*corners[0], axis2, Box3D::Perspective3D::current_perspective);
+ Box3D::PerspectiveLine line4 (*corners[2], axis1, Box3D::Perspective3D::current_perspective);
NR::Maybe<NR::Point> D = line3.intersect(line4);
// FIXME: How to handle the case if one of the intersections doesn't exist?
@@ -149,7 +151,7 @@ Box3DFace::set_face (NR::Point const A, NR::Point const C, Box3D::Axis const axi
this->dir1 = axis1;
this->dir2 = axis2;
}
-
+***/
NR::Point Box3DFace::operator[](unsigned int i)
{
return;
}
- SPDesktop *desktop = inkscape_active_desktop();
+ /* create new path for face */
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());
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());
this->path = SP_PATH(SP_OBJECT(parent_box3d)->appendChildRepr(repr_face));
Inkscape::GC::release(repr_face);
+
+ /* set the correct style */
+ this->set_style (repr_face);
+}
+
+void Box3DFace::set_style(Inkscape::XML::Node *repr_face, bool extruded)
+{
+ if (repr_face == NULL) {
+ repr_face = SP_OBJECT_REPR (this->path);
+ }
+
+ if (!extruded && !strcmp (axes_string (), "XYrear")) {
+ // to avoid "flashing" during the initial dragging process, we make the rear face invisible in this case
+ repr_face->setAttribute("style", "fill:none");
+ return;
+ }
+
+ gchar *descr = g_strconcat ("desktop.", axes_string (), NULL);
+ const gchar * cur_style = prefs_get_string_attribute(descr, "style");
+ g_free (descr);
+
+ SPDesktop *desktop = inkscape_active_desktop();
+ bool use_current = prefs_get_int_attribute("tools.shapes.3dbox", "usecurrent", 0);
+ 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);
+ }
}
/**
void Box3DFace::set_curve()
{
if (this->path == NULL) {
- g_warning("this->path is NULL! \n");
return;
}
NR::Matrix const i2d (sp_item_i2d_affine (SP_ITEM (this->parent_box3d)));
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++