Code

fix pasting style after copying a text span
[inkscape.git] / src / persp3d.cpp
index a2da34e7ae65dee5ac349507b9b0ef7d48f199da..916e9f25f421fe071452b070e4088abfb2cf9bdf 100644 (file)
@@ -30,7 +30,7 @@ static void persp3d_build(SPObject *object, SPDocument *document, Inkscape::XML:
 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);
 
@@ -190,7 +190,7 @@ persp3d_set(SPObject *object, unsigned key, gchar const *value)
 static void
 persp3d_update(SPObject *object, SPCtx *ctx, guint flags)
 {
-    if (flags & SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG) {
+    if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
 
         /* TODO: Should we update anything here? */
 
@@ -256,14 +256,13 @@ persp3d_document_first_persp (SPDocument *document) {
  * 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");
     }
 
@@ -283,13 +282,13 @@ persp3d_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
     }
 
     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 {
@@ -297,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
@@ -362,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);
 
@@ -377,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);
@@ -579,6 +578,9 @@ persp3d_has_all_boxes_in_selection (Persp3D *persp) {
     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) {
@@ -602,6 +604,10 @@ 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);