index a9e317534b90dd12740b80b49aef5681741f8786..750fef1b0ee7bf56b192bd39570a85801f735227 100644 (file)
-#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>
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;
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;
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
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();
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, 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) const;
CanvasXYGrid *grid;
};