Code

replace text strings by ints for tools/bounding_box
[inkscape.git] / src / seltrans.h
index e8aee252ec4175c7db574bf55810d828f66773f3..d06e0527626c7629ae65dc227ead958ffead6c73 100644 (file)
@@ -4,9 +4,10 @@
 /*
  * Helper object for transforming selected items
  *
- * Author:
+ * Authors:
  *   Lauris Kaplinski <lauris@kaplinski.com>
  *   Carl Hetherington <inkscape@carlh.net>
+ *   Diederik van Lierop <mail@diedenrezi.nl>
  *
  * Copyright (C) 2006      Johan Engelen <johan@shouraizou.nl>
  * Copyright (C) 1999-2002 Lauris Kaplinski
@@ -18,6 +19,7 @@
 #include <libnr/nr-point.h>
 #include <libnr/nr-matrix.h>
 #include <libnr/nr-rect.h>
+#include "knot.h"
 #include "forward.h"
 #include "selcue.h"
 #include "message-context.h"
@@ -31,6 +33,8 @@ class SPSelTransHandle;
 namespace Inkscape
 {
 
+NR::scale calcScaleFactors(NR::Point const &initial_point, NR::Point const &new_point, NR::Point const &origin, bool const skew = false);
+
 namespace XML
 {
   class Node;
@@ -84,7 +88,10 @@ public:
     bool isGrabbed() {
         return _grabbed;    
     }
-    
+       bool centerIsVisible() {
+               return ( _chandle && SP_KNOT_IS_VISIBLE (_chandle) );
+       }
+
 private:
     void _updateHandles();
     void _updateVolatileState();
@@ -92,16 +99,21 @@ private:
     void _selModified(Inkscape::Selection *selection, guint flags);
     void _showHandles(SPKnot *knot[], SPSelTransHandle const handle[], gint num,
                       gchar const *even_tip, gchar const *odd_tip);
+    NR::Point _getGeomHandlePos(NR::Point const &visual_handle_pos);
+    NR::Point _calcAbsAffineDefault(NR::scale const default_scale);
+    NR::Point _calcAbsAffineGeom(NR::scale const geom_scale);
 
     enum State {
-        STATE_SCALE,
-       STATE_ROTATE
+        STATE_SCALE, //scale or stretch
+        STATE_ROTATE //rotate or skew
     };
     
     SPDesktop *_desktop;
 
-    std::vector<std::pair<SPItem *, NR::Matrix> > _items;
-    std::vector<std::pair<SPItem *, NR::Point> > _items_centers;
+    std::vector<SPItem *> _items;
+    std::vector<SPItem const *> _items_const;
+    std::vector<NR::Matrix> _items_affines;
+    std::vector<NR::Point> _items_centers;
     
     std::vector<NR::Point> _snap_points;
     std::vector<NR::Point> _bbox_points;
@@ -117,10 +129,30 @@ private:
     bool _empty;
     bool _changed;
 
-    NR::Maybe<NR::Rect> _box;
+    SPItem::BBoxType _snap_bbox_type;
+    
+    NR::Maybe<NR::Rect> _bbox;
+    NR::Maybe<NR::Rect> _approximate_bbox;
+    NR::Maybe<NR::Rect> _geometric_bbox;
     gdouble _strokewidth;
-    NR::Matrix _current;
-    NR::Point _opposite; ///< opposite point to where a scale is taking place
+    
+    NR::Matrix _current_relative_affine;
+    NR::Matrix _absolute_affine;
+    NR::Matrix _relative_affine;
+    /* According to Merriam - Webster's online dictionary
+     * Affine: a transformation (as a translation, a rotation, or a uniform stretching) that carries straight
+     * lines into straight lines and parallel lines into parallel lines but may alter distance between points
+     * and angles between lines <affine geometry>
+     */
+    
+    NR::Point _opposite; ///< opposite point to where a scale is taking place    
+    NR::Point _opposite_for_specpoints;
+    NR::Point _opposite_for_bboxpoints;
+    NR::Point _origin_for_specpoints;
+    NR::Point _origin_for_bboxpoints;
+
+    gdouble _handle_x;
+    gdouble _handle_y;
 
     NR::Maybe<NR::Point> _center;
     bool _center_is_set; ///< we've already set _center, no need to reread it from items
@@ -133,13 +165,14 @@ private:
     SPCanvasItem *_l[4];
     guint _sel_changed_id;
     guint _sel_modified_id;
-    GSList *_stamp_cache;    
+    GSList *_stamp_cache;
 
     NR::Point _origin; ///< position of origin for transforms
     NR::Point _point; ///< original position of the knot being used for the current transform
+    NR::Point _point_geom; ///< original position of the knot being used for the current transform
     Inkscape::MessageContext _message_context;
-    SigC::Connection _sel_changed_connection;
-    SigC::Connection _sel_modified_connection;
+    sigc::connection _sel_changed_connection;
+    sigc::connection _sel_modified_connection;
 };
 
 }