6c39860b9b5a5ca99d3e667722f36ef7ed674bdc
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 <libnr/nr-coord.h>
11 #include "xml/repr.h"
12 #include <gtkmm/box.h>
14 #include <gtkmm.h>
15 #include "ui/widget/color-picker.h"
16 #include "ui/widget/scalar-unit.h"
18 #include "ui/widget/registered-widget.h"
19 #include "ui/widget/registry.h"
20 //#include "ui/widget/tolerance-slider.h"
22 #include "xml/node-event-vector.h"
24 #include "snapper.h"
25 #include "line-snapper.h"
27 #include "canvas-grid.h"
29 struct SPDesktop;
30 struct SPNamedView;
32 namespace Inkscape {
34 class CanvasAxonomGrid : public CanvasGrid {
35 public:
36 CanvasAxonomGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument * in_doc);
37 virtual ~CanvasAxonomGrid();
39 void Update (NR::Matrix const &affine, unsigned int flags);
40 void Render (SPCanvasBuf *buf);
42 void readRepr();
43 void onReprAttrChanged (Inkscape::XML::Node * repr, const gchar *key, const gchar *oldval, const gchar *newval, bool is_interactive);
45 SPUnit const* gridunit;
47 NR::Point origin; /**< Origin of the grid */
48 double lengthy; /**< The lengths of the primary y-axis */
49 double angle_deg[3]; /**< Angle of each axis (note that angle[2] == 0) */
50 double angle_rad[3]; /**< Angle of each axis (note that angle[2] == 0) */
51 double tan_angle[3]; /**< tan(angle[.]) */
52 guint32 color; /**< Color for normal lines */
53 guint32 empcolor; /**< Color for emphasis lines */
54 gint empspacing; /**< Spacing between emphasis lines */
55 bool scaled; /**< Whether the grid is in scaled mode */
57 NR::Point ow; /**< Transformed origin by the affine for the zoom */
58 double lyw; /**< Transformed length y by the affine for the zoom */
59 double lxw_x;
60 double lxw_z;
61 double spacing_ylines;
63 NR::Point sw; /**< the scaling factors of the affine transform */
65 protected:
66 virtual Gtk::Widget * newSpecificWidget();
68 private:
69 CanvasAxonomGrid(const CanvasAxonomGrid&);
70 CanvasAxonomGrid& operator=(const CanvasAxonomGrid&);
72 void updateWidgets();
73 };
77 class CanvasAxonomGridSnapper : public LineSnapper
78 {
79 public:
80 CanvasAxonomGridSnapper(CanvasAxonomGrid *grid, SPNamedView const *nv, NR::Coord const d);
82 private:
83 LineList _getSnapLines(NR::Point const &p) const;
84 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;
86 CanvasAxonomGrid *grid;
87 };
90 }; //namespace Inkscape
94 #endif