Code

Split SPCanvasItem and SPCanvasGroup to individual .h files. Removed forward header.
[inkscape.git] / src / display / canvas-grid.h
index 0ff2c65f1fdf953a040284a5ca4ad1cffe7f07fc..b8f313948e222fc3931c69f79cc3f01eeb69063d 100644 (file)
@@ -1,35 +1,32 @@
-#ifndef INKSCAPE_CANVAS_GRID_H
-#define INKSCAPE_CANVAS_GRID_H
-
-/*
- * Inkscape::CXYGrid
- *
- * Generic (and quite unintelligent) grid item for gnome canvas
- *
- * Copyright (C) Johan Engelen 2006-2007 <johan@shouraizou.nl>
+/** @file
+ * @brief Cartesian grid item for the Inkscape canvas
+ */
+/* Copyright (C) Johan Engelen 2006-2007 <johan@shouraizou.nl>
  * Copyright (C) Lauris Kaplinski 2000
- *
  */
 
+#ifndef INKSCAPE_CANVAS_GRID_H
+#define INKSCAPE_CANVAS_GRID_H
+
 #include <cstring>
 #include <string>
 
 #include <gtkmm/box.h>
 #include <gtkmm.h>
 
-#include "display/sp-canvas.h"
+#include "sp-canvas-item.h"
 #include "xml/repr.h"
 #include "ui/widget/color-picker.h"
 #include "ui/widget/scalar-unit.h"
 #include "ui/widget/registered-widget.h"
 #include "ui/widget/registry.h"
-//#include "ui/widget/tolerance-slider.h"
 #include "xml/node-event-vector.h"
 #include "snapper.h"
 #include "line-snapper.h"
 
 struct SPDesktop;
 struct SPNamedView;
+struct SPCanvasBuf;
 class SPDocument;
 
 namespace Inkscape {
@@ -82,7 +79,7 @@ public:
 
     GridCanvasItem * createCanvasItem(SPDesktop * desktop);
 
-    virtual void Update (NR::Matrix const &affine, unsigned int flags) = 0;
+    virtual void Update (Geom::Matrix const &affine, unsigned int flags) = 0;
     virtual void Render (SPCanvasBuf *buf) = 0;
 
     virtual void readRepr() = 0;
@@ -90,6 +87,13 @@ public:
 
     Gtk::Widget * newWidget();
 
+    Geom::Point origin;     /**< Origin of the grid */
+    guint32 color;        /**< Color for normal lines */
+    guint32 empcolor;     /**< Color for emphasis lines */
+    gint empspacing;      /**< Spacing between emphasis lines */
+
+    SPUnit const* gridunit;
+
     Inkscape::XML::Node * repr;
     SPDocument *doc;
 
@@ -125,24 +129,18 @@ public:
     CanvasXYGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument * in_doc);
     virtual ~CanvasXYGrid();
 
-    void Update (NR::Matrix const &affine, unsigned int flags);
+    void Update (Geom::Matrix const &affine, unsigned int flags);
     void Render (SPCanvasBuf *buf);
 
     void readRepr();
     void onReprAttrChanged (Inkscape::XML::Node * repr, const gchar *key, const gchar *oldval, const gchar *newval, bool is_interactive);
 
-    NR::Point origin;
-    guint32 color;
-    guint32 empcolor;
-    gint  empspacing;
-    SPUnit const* gridunit;
-
-    NR::Point spacing; /**< Spacing between elements of the grid */
+    Geom::Point spacing; /**< Spacing between elements of the grid */
     bool scaled[2];    /**< Whether the grid is in scaled mode, which can
-                            be different in the X or Y direction, hense two
+                            be different in the X or Y direction, hence two
                             variables */
-    NR::Point ow;      /**< Transformed origin by the affine for the zoom */
-    NR::Point sw;      /**< Transformed spacing by the affine for the zoom */
+    Geom::Point ow;      /**< Transformed origin by the affine for the zoom */
+    Geom::Point sw;      /**< Transformed spacing by the affine for the zoom */
 
 protected:
     virtual Gtk::Widget * newSpecificWidget();
@@ -161,12 +159,16 @@ private:
 class CanvasXYGridSnapper : public LineSnapper
 {
 public:
-    CanvasXYGridSnapper(CanvasXYGrid *grid, SPNamedView const *nv, NR::Coord const d);
+    CanvasXYGridSnapper(CanvasXYGrid *grid, SnapManager *sm, Geom::Coord const d);
     bool ThisSnapperMightSnap() const;
 
+    Geom::Coord getSnapperTolerance() const; //returns the tolerance of the snapper in screen pixels (i.e. independent of zoom)
+    bool getSnapperAlwaysSnap() const; //if true, then the snapper will always snap, regardless of its tolerance
+
 private:
-    LineList _getSnapLines(NR::Point const &p) const;
-    void _addSnappedLine(SnappedConstraints &sc, NR::Point const snapped_point, NR::Coord const snapped_distance, NR::Point const normal_to_line, const NR::Point point_on_line) const;
+    LineList _getSnapLines(Geom::Point const &p) const;
+    void _addSnappedLine(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance,  SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, const Geom::Point point_on_line) const;
+    void _addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const;
     CanvasXYGrid *grid;
 };