1 #ifndef CANVAS_AXONOMGRID_H
2 #define CANVAS_AXONOMGRID_H
4 /*
5 * Copyright (C) 2006-2007 Johan Engelen <johan@shouraizou.nl>
6 *
7 */
9 #include <display/sp-canvas.h>
10 #include "xml/repr.h"
11 #include <gtkmm/box.h>
13 #include <gtkmm.h>
14 #include "ui/widget/color-picker.h"
15 #include "ui/widget/scalar-unit.h"
17 #include "ui/widget/registered-widget.h"
18 #include "ui/widget/registry.h"
20 #include "xml/node-event-vector.h"
22 #include "snapper.h"
23 #include "line-snapper.h"
25 #include "canvas-grid.h"
27 struct SPDesktop;
28 struct SPNamedView;
30 namespace Inkscape {
32 class CanvasAxonomGrid : public CanvasGrid {
33 public:
34 CanvasAxonomGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument * in_doc);
35 virtual ~CanvasAxonomGrid();
37 void Update (Geom::Matrix const &affine, unsigned int flags);
38 void Render (SPCanvasBuf *buf);
40 void readRepr();
41 void onReprAttrChanged (Inkscape::XML::Node * repr, const gchar *key, const gchar *oldval, const gchar *newval, bool is_interactive);
43 double lengthy; /**< The lengths of the primary y-axis */
44 double angle_deg[3]; /**< Angle of each axis (note that angle[2] == 0) */
45 double angle_rad[3]; /**< Angle of each axis (note that angle[2] == 0) */
46 double tan_angle[3]; /**< tan(angle[.]) */
48 bool scaled; /**< Whether the grid is in scaled mode */
50 Geom::Point ow; /**< Transformed origin by the affine for the zoom */
51 double lyw; /**< Transformed length y by the affine for the zoom */
52 double lxw_x;
53 double lxw_z;
54 double spacing_ylines;
56 Geom::Point sw; /**< the scaling factors of the affine transform */
58 protected:
59 virtual Gtk::Widget * newSpecificWidget();
61 private:
62 CanvasAxonomGrid(const CanvasAxonomGrid&);
63 CanvasAxonomGrid& operator=(const CanvasAxonomGrid&);
65 void updateWidgets();
66 };
70 class CanvasAxonomGridSnapper : public LineSnapper
71 {
72 public:
73 CanvasAxonomGridSnapper(CanvasAxonomGrid *grid, SnapManager *sm, Geom::Coord const d);
74 bool ThisSnapperMightSnap() const;
76 Geom::Coord getSnapperTolerance() const; //returns the tolerance of the snapper in screen pixels (i.e. independent of zoom)
77 bool getSnapperAlwaysSnap() const; //if true, then the snapper will always snap, regardless of its tolerance
79 private:
80 LineList _getSnapLines(Geom::Point const &p) const;
81 void _addSnappedLine(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, SnapTargetType const &target, Geom::Point const normal_to_line, const Geom::Point point_on_line) const;
83 CanvasAxonomGrid *grid;
84 };
87 }; //namespace Inkscape
91 #endif