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 <2geom/point.h>
19 #include "sp-object.h"
20 #include "sp-guide-attachment.h"
22 struct SPCanvas;
23 struct SPCanvasGroup;
25 #define SP_TYPE_GUIDE (sp_guide_get_type())
26 #define SP_GUIDE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_GUIDE, SPGuide))
27 #define SP_GUIDE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_GUIDE, SPGuideClass))
28 #define SP_IS_GUIDE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_GUIDE))
29 #define SP_IS_GUIDE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_GUIDE))
31 /* Represents the constraint on p that dot(g.direction, p) == g.position. */
32 class SPGuide : public SPObject {
33 public:
34 Geom::Point normal_to_line;
35 Geom::Point point_on_line;
37 guint32 color;
38 guint32 hicolor;
39 GSList *views;
40 std::vector<SPGuideAttachment> attached_items;
42 inline bool isHorizontal() const { return (normal_to_line[Geom::X] == 0.); };
43 inline bool isVertical() const { return (normal_to_line[Geom::Y] == 0.); };
44 inline double angle() const { return std::atan2( - normal_to_line[Geom::X], normal_to_line[Geom::Y] ); };
45 static SPGuide *createSPGuide(SPDesktop *desktop, Geom::Point const &pt1, Geom::Point const &pt2);
46 void showSPGuide(SPCanvasGroup *group, GCallback handler);
47 void hideSPGuide(SPCanvas *canvas);
48 void sensitize(SPCanvas *canvas, gboolean sensitive);
49 Geom::Point getPositionFrom(Geom::Point const &pt) const;
50 double getDistanceFrom(Geom::Point const &pt) const;
51 };
53 class SPGuideClass {
54 public:
55 SPObjectClass parent_class;
56 };
58 GType sp_guide_get_type();
60 void sp_guide_pt_pairs_to_guides(SPDesktop *dt, std::list<std::pair<Geom::Point, Geom::Point> > &pts);
61 void sp_guide_create_guides_around_page(SPDesktop *dt);
63 void sp_guide_moveto(SPGuide const &guide, Geom::Point const point_on_line, bool const commit);
64 void sp_guide_set_normal(SPGuide const &guide, Geom::Point const normal_to_line, bool const commit);
65 void sp_guide_remove(SPGuide *guide);
67 char *sp_guide_description(SPGuide const *guide, const bool verbose = true);
70 #endif // SEEN_SP_GUIDE_H
72 /*
73 Local Variables:
74 mode:c++
75 c-file-style:"stroustrup"
76 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
77 indent-tabs-mode:nil
78 fill-column:99
79 End:
80 */
81 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :