Code

1) snap midpoints of line segments (both as source and as target)
[inkscape.git] / src / display / canvas-axonomgrid.h
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);
75 private:
76     LineList _getSnapLines(Geom::Point const &p) const;
77     void _addSnappedLine(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, Geom::Point const normal_to_line, const Geom::Point point_on_line) const;
79     CanvasAxonomGrid *grid;
80 };
83 }; //namespace Inkscape
87 #endif