diff --git a/src/persp3d.cpp b/src/persp3d.cpp
index 34189960846bb0359188c18b1c3ca60372fcfd9b..71d12619bc5d60582611eb4e59f87f0ae738e036 100644 (file)
--- a/src/persp3d.cpp
+++ b/src/persp3d.cpp
static void persp3d_release(SPObject *object);
static void persp3d_set(SPObject *object, unsigned key, gchar const *value);
static void persp3d_update(SPObject *object, SPCtx *ctx, guint flags);
-static Inkscape::XML::Node *persp3d_write(SPObject *object, Inkscape::XML::Node *repr, guint flags);
+static Inkscape::XML::Node *persp3d_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
static void persp3d_on_repr_attr_changed (Inkscape::XML::Node * repr, const gchar *key, const gchar *oldval, const gchar *newval, bool is_interactive, void * data);
@@ -230,7 +230,6 @@ persp3d_create_xml_element (SPDocument *document, Persp3D *dup) {// if dup is gi
str = proj_origin.coord_string();
repr->setAttribute("inkscape:persp3d-origin", str);
g_free (str);
- Inkscape::GC::release(repr);
}
/* Append the new persp3d to defs */
* Virtual write: write object attributes to repr.
*/
static Inkscape::XML::Node *
-persp3d_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
+persp3d_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
{
Persp3D *persp = SP_PERSP3D(object);
if ((flags & SP_OBJECT_WRITE_BUILD & SP_OBJECT_WRITE_EXT) && !repr) {
// this is where we end up when saving as plain SVG (also in other circumstances?);
// hence we don't set the sodipodi:type attribute
- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object));
repr = xml_doc->createElement("inkscape:perspective");
}
}
if (((SPObjectClass *) persp3d_parent_class)->write)
- (* ((SPObjectClass *) persp3d_parent_class)->write)(object, repr, flags);
+ (* ((SPObjectClass *) persp3d_parent_class)->write)(object, xml_doc, repr, flags);
return repr;
}
/* convenience wrapper around persp3d_get_finite_dir() and persp3d_get_infinite_dir() */
-NR::Point persp3d_get_PL_dir_from_pt (Persp3D *persp, NR::Point const &pt, Proj::Axis axis) {
+Geom::Point persp3d_get_PL_dir_from_pt (Persp3D *persp, Geom::Point const &pt, Proj::Axis axis) {
if (persp3d_VP_is_finite(persp, axis)) {
return persp3d_get_finite_dir(persp, pt, axis);
} else {
@@ -298,20 +296,20 @@ NR::Point persp3d_get_PL_dir_from_pt (Persp3D *persp, NR::Point const &pt, Proj:
}
}
-NR::Point
-persp3d_get_finite_dir (Persp3D *persp, NR::Point const &pt, Proj::Axis axis) {
+Geom::Point
+persp3d_get_finite_dir (Persp3D *persp, Geom::Point const &pt, Proj::Axis axis) {
Box3D::PerspectiveLine pl(pt, axis, persp);
return pl.direction();
}
-NR::Point
+Geom::Point
persp3d_get_infinite_dir (Persp3D *persp, Proj::Axis axis) {
Proj::Pt2 vp(persp3d_get_VP(persp, axis));
if (vp[2] != 0.0) {
g_print ("VP should be infinite but is (%f : %f : %f)\n", vp[0], vp[1], vp[2]);
- g_return_val_if_fail(vp[2] != 0.0, NR::Point(0.0, 0.0));
+ g_return_val_if_fail(vp[2] != 0.0, Geom::Point(0.0, 0.0));
}
- return NR::Point(vp[0], vp[1]);
+ return Geom::Point(vp[0], vp[1]);
}
double
@@ -363,8 +361,8 @@ persp3d_rotate_VP (Persp3D *persp, Proj::Axis axis, double angle, bool alt_press
return;
}
Proj::Pt2 v_dir_proj (persp->tmat.column(axis));
- NR::Point v_dir (v_dir_proj[0], v_dir_proj[1]);
- double a = NR::atan2 (v_dir) * 180/M_PI;
+ Geom::Point v_dir (v_dir_proj[0], v_dir_proj[1]);
+ double a = Geom::atan2 (v_dir) * 180/M_PI;
a += alt_pressed ? 0.5 * ((angle > 0 ) - (angle < 0)) : angle; // the r.h.s. yields +/-0.5 or angle
persp->tmat.set_infinite_direction (axis, a);
@@ -378,7 +376,7 @@ persp3d_update_with_point (Persp3D *persp, Proj::Axis const axis, Proj::Pt2 cons
}
void
-persp3d_apply_affine_transformation (Persp3D *persp, NR::Matrix const &xform) {
+persp3d_apply_affine_transformation (Persp3D *persp, Geom::Matrix const &xform) {
persp->tmat *= xform;
persp3d_update_box_reprs(persp);
SP_OBJECT(persp)->updateRepr(SP_OBJECT_WRITE_EXT);
return true;
}
+/**
+ * For each perspective having a box in \a selection, determine all its unselected boxes.
+ */
// TODO: Check where we can use pass-by-reference (or so) instead of recreating all the lists afresh.
std::map<Persp3D *, std::list<SPBox3D *> >
persp3d_unselected_boxes(Inkscape::Selection *selection) {
return punsel;
}
+/**
+ * Split all perspectives with a box in \a selection by moving their unselected boxes to newly
+ * created perspectives.
+ */
void
persp3d_split_perspectives_according_to_selection(Inkscape::Selection *selection) {
std::map<Persp3D *, std::list<SPBox3D *> > punsel = persp3d_unselected_boxes(selection);