Code

4fc4032db44b2b08cff27a78fededf4ffa91553b
[inkscape.git] / src / sp-guide.h
1 #ifndef SEEN_SP_GUIDE_H
2 #define SEEN_SP_GUIDE_H
4 /*
5  * SPGuide
6  *
7  * A guideline
8  *
9  * Copyright (C) Lauris Kaplinski 2000
10  * Copyright (C) Johan Engelen 2007
11  *   Abhishek Sharma
12  *   Jon A. Cruz <jon@joncruz.org>
13  *
14  */
16 #include <vector>
18 #include "display/display-forward.h"
19 #include <2geom/point.h>
20 #include "sp-object.h"
21 #include "sp-guide-attachment.h"
23 #define SP_TYPE_GUIDE            (sp_guide_get_type())
24 #define SP_GUIDE(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_GUIDE, SPGuide))
25 #define SP_GUIDE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_GUIDE, SPGuideClass))
26 #define SP_IS_GUIDE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_GUIDE))
27 #define SP_IS_GUIDE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_GUIDE))
29 /* Represents the constraint on p that dot(g.direction, p) == g.position. */
30 class SPGuide : public SPObject {
31 public:
32     Geom::Point normal_to_line;
33     Geom::Point point_on_line;
35     guint32 color;
36     guint32 hicolor;
37     GSList *views;
38     std::vector<SPGuideAttachment> attached_items;
40     inline bool isHorizontal() const { return (normal_to_line[Geom::X] == 0.); };
41     inline bool isVertical() const { return (normal_to_line[Geom::Y] == 0.); };
42     inline double angle() const { return std::atan2( - normal_to_line[Geom::X], normal_to_line[Geom::Y] ); };
43     static SPGuide *createSPGuide(SPDesktop *desktop, Geom::Point const &pt1, Geom::Point const &pt2);
44     void showSPGuide(SPCanvasGroup *group, GCallback handler);
45     void hideSPGuide(SPCanvas *canvas);
46     void sensitize(SPCanvas *canvas, gboolean sensitive);
47     Geom::Point getPositionFrom(Geom::Point const &pt) const;
48     double getDistanceFrom(Geom::Point const &pt) const;
49 };
51 class SPGuideClass {
52 public:
53     SPObjectClass parent_class;
54 };
56 GType sp_guide_get_type();
58 void sp_guide_pt_pairs_to_guides(SPDesktop *dt, std::list<std::pair<Geom::Point, Geom::Point> > &pts);
59 void sp_guide_create_guides_around_page(SPDesktop *dt);
61 void sp_guide_moveto(SPGuide const &guide, Geom::Point const point_on_line, bool const commit);
62 void sp_guide_set_normal(SPGuide const &guide, Geom::Point const normal_to_line, bool const commit);
63 void sp_guide_remove(SPGuide *guide);
65 char *sp_guide_description(SPGuide const *guide, const bool verbose = true);
68 #endif // SEEN_SP_GUIDE_H
70 /*
71   Local Variables:
72   mode:c++
73   c-file-style:"stroustrup"
74   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
75   indent-tabs-mode:nil
76   fill-column:99
77   End:
78 */
79 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :