X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fdisplay%2Fcanvas-axonomgrid.h;h=e36804d7c409d60b125fac8fc99fcc55e17c857b;hb=b4b6e9c6f7dca6891f586984f1b26f81c61174ba;hp=79de72b43340abe7adf65eba7980445207a3f723;hpb=91934be261c16d036521379306a74b0991720e67;p=inkscape.git diff --git a/src/display/canvas-axonomgrid.h b/src/display/canvas-axonomgrid.h index 79de72b43..e36804d7c 100644 --- a/src/display/canvas-axonomgrid.h +++ b/src/display/canvas-axonomgrid.h @@ -1,59 +1,94 @@ -#ifndef SP_CANVAS_AXONOMGRID_H -#define SP_CANVAS_AXONOMGRID_H +#ifndef CANVAS_AXONOMGRID_H +#define CANVAS_AXONOMGRID_H /* - * SPCAxonomGrid + * Copyright (C) 2006-2007 Johan Engelen * - * Generic (and quite unintelligent) modified copy of the grid item for gnome canvas - * - * Copyright (C) 2006 Johan Engelen - * Copyright (C) 2000 Lauris Kaplinski 2000 - * - */ + */ #include -#include - - -#define SP_TYPE_CAXONOMGRID (sp_caxonomgrid_get_type ()) -#define SP_CAXONOMGRID(obj) (GTK_CHECK_CAST ((obj), SP_TYPE_CAXONOMGRID, SPCAxonomGrid)) -#define SP_CAXONOMGRID_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), SP_TYPE_CAXONOMGRID, SPCAxonomGridClass)) -#define SP_IS_CAXONOMGRID(obj) (GTK_CHECK_TYPE ((obj), SP_TYPE_CAXONOMGRID)) -#define SP_IS_CAXONOMGRID_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), SP_TYPE_CAXONOMGRID)) - - -/** \brief All the variables that are tracked for a axonometric grid specific - canvas item. */ -struct SPCAxonomGrid : public SPCanvasItem{ - NR::Point origin; /**< Origin of the grid */ - double lengthy; /**< The lengths of the primary y-axis */ - double angle_deg[3]; /**< Angle of each axis (note that angle[2] == 0) */ - double angle_rad[3]; /**< Angle of each axis (note that angle[2] == 0) */ - double tan_angle[3]; /**< tan(angle[.]) */ - guint32 color; /**< Color for normal lines */ - guint32 empcolor; /**< Color for emphasis lines */ - gint empspacing; /**< Spacing between emphasis lines */ - bool scaled; /**< Whether the grid is in scaled mode */ - - NR::Point ow; /**< Transformed origin by the affine for the zoom */ - double lyw; /**< Transformed length y by the affine for the zoom */ - double lxw_x; - double lxw_z; - double spacing_ylines; - - NR::Point sw; /**< the scaling factors of the affine transform */ +#include "xml/repr.h" +#include + +#include +#include "ui/widget/color-picker.h" +#include "ui/widget/scalar-unit.h" + +#include "ui/widget/registered-widget.h" +#include "ui/widget/registry.h" + +#include "xml/node-event-vector.h" + +#include "snapper.h" +#include "line-snapper.h" + +#include "canvas-grid.h" + +struct SPDesktop; +struct SPNamedView; + +namespace Inkscape { + +class CanvasAxonomGrid : public CanvasGrid { +public: + CanvasAxonomGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument * in_doc); + virtual ~CanvasAxonomGrid(); + + 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); + + double lengthy; /**< The lengths of the primary y-axis */ + double angle_deg[3]; /**< Angle of each axis (note that angle[2] == 0) */ + double angle_rad[3]; /**< Angle of each axis (note that angle[2] == 0) */ + double tan_angle[3]; /**< tan(angle[.]) */ + + bool scaled; /**< Whether the grid is in scaled mode */ + + Geom::Point ow; /**< Transformed origin by the affine for the zoom */ + double lyw; /**< Transformed length y by the affine for the zoom */ + double lxw_x; + double lxw_z; + double spacing_ylines; + + Geom::Point sw; /**< the scaling factors of the affine transform */ + +protected: + virtual Gtk::Widget * newSpecificWidget(); + +private: + CanvasAxonomGrid(const CanvasAxonomGrid&); + CanvasAxonomGrid& operator=(const CanvasAxonomGrid&); + + void updateWidgets(); }; -struct SPCAxonomGridClass { - SPCanvasItemClass parent_class; + + +class CanvasAxonomGridSnapper : public LineSnapper +{ +public: + CanvasAxonomGridSnapper(CanvasAxonomGrid *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(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; + + CanvasAxonomGrid *grid; }; -/* Standard Gtk function */ -GtkType sp_caxonomgrid_get_type (void); +}; //namespace Inkscape -#endif +#endif