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);
37 ~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 Gtk::Widget & getWidget();
47 SPUnit const* gridunit;
49 NR::Point origin; /**< Origin of the grid */
50 double lengthy; /**< The lengths of the primary y-axis */
51 double angle_deg[3]; /**< Angle of each axis (note that angle[2] == 0) */
52 double angle_rad[3]; /**< Angle of each axis (note that angle[2] == 0) */
53 double tan_angle[3]; /**< tan(angle[.]) */
54 guint32 color; /**< Color for normal lines */
55 guint32 empcolor; /**< Color for emphasis lines */
56 gint empspacing; /**< Spacing between emphasis lines */
57 bool scaled; /**< Whether the grid is in scaled mode */
59 NR::Point ow; /**< Transformed origin by the affine for the zoom */
60 double lyw; /**< Transformed length y by the affine for the zoom */
61 double lxw_x;
62 double lxw_z;
63 double spacing_ylines;
65 NR::Point sw; /**< the scaling factors of the affine transform */
68 private:
69 CanvasAxonomGrid(const CanvasAxonomGrid&);
70 CanvasAxonomGrid& operator=(const CanvasAxonomGrid&);
72 void updateWidgets();
74 Gtk::Table table;
76 Inkscape::UI::Widget::RegisteredCheckButton _rcbgrid, _rcbsnbb, _rcbsnnod;
77 Inkscape::UI::Widget::RegisteredUnitMenu _rumg, _rums;
78 Inkscape::UI::Widget::RegisteredScalarUnit _rsu_ox, _rsu_oy, _rsu_sy, _rsu_ax, _rsu_az;
79 Inkscape::UI::Widget::RegisteredColorPicker _rcp_gcol, _rcp_gmcol;
80 Inkscape::UI::Widget::RegisteredSuffixedInteger _rsi;
82 Inkscape::UI::Widget::Registry _wr;
84 };
88 class CanvasAxonomGridSnapper : public LineSnapper
89 {
90 public:
91 CanvasAxonomGridSnapper(CanvasAxonomGrid *grid, SPNamedView const *nv, NR::Coord const d);
93 private:
94 LineList _getSnapLines(NR::Point const &p) const;
96 CanvasAxonomGrid *grid;
97 };
100 }; //namespace Inkscape
104 #endif