Code

A simple layout document as to what, why and how is cppification.
[inkscape.git] / src / sp-guide.h
1 #ifndef SP_GUIDE_H
2 #define SP_GUIDE_H
4 /*
5  * SPGuide
6  *
7  * A guideline
8  *
9  * Copyright (C) Lauris Kaplinski 2000
10  * Copyright (C) Johan Engelen 2007
11  *
12  */
14 #include <vector>
16 #include "display/display-forward.h"
17 #include <2geom/point.h>
18 #include "sp-object.h"
19 #include "sp-guide-attachment.h"
21 #define SP_TYPE_GUIDE            (sp_guide_get_type())
22 #define SP_GUIDE(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_GUIDE, SPGuide))
23 #define SP_GUIDE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_GUIDE, SPGuideClass))
24 #define SP_IS_GUIDE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_GUIDE))
25 #define SP_IS_GUIDE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_GUIDE))
27 /* Represents the constraint on p that dot(g.direction, p) == g.position. */
28 class SPGuide : public SPObject {
29         public:
30     Geom::Point normal_to_line;
31     Geom::Point point_on_line;
33     guint32 color;
34     guint32 hicolor;
35     GSList *views;
36     std::vector<SPGuideAttachment> attached_items;
38     inline bool is_horizontal() const { return (normal_to_line[Geom::X] == 0.); };
39     inline bool is_vertical() const { return (normal_to_line[Geom::Y] == 0.); };
40     inline double angle() const { return std::atan2( - normal_to_line[Geom::X], normal_to_line[Geom::Y] ); };
41         static SPGuide *createSPGuide(SPDesktop *desktop, Geom::Point const &pt1, Geom::Point const &pt2);
42         void showSPGuide(SPCanvasGroup *group, GCallback handler);
43         void hideSPGuide(SPCanvas *canvas);
44         void sensitize(SPCanvas *canvas, gboolean sensitive);
45         Geom::Point getPositionFrom(Geom::Point const &pt) const;
46         double getDistanceFrom(Geom::Point const &pt) const;
47 };
49 class SPGuideClass {
50         public:
51     SPObjectClass parent_class;
52 };
54 GType sp_guide_get_type();
56 //SPGuide *sp_guide_create(SPDesktop *desktop, Geom::Point const &pt1, Geom::Point const &pt2);
57 void sp_guide_pt_pairs_to_guides(SPDesktop *dt, std::list<std::pair<Geom::Point, Geom::Point> > &pts);
58 void sp_guide_create_guides_around_page(SPDesktop *dt);
60 //void sp_guide_show(SPGuide *guide, SPCanvasGroup *group, GCallback handler);
61 //void sp_guide_hide(SPGuide *guide, SPCanvas *canvas);
62 //void sp_guide_sensitize(SPGuide *guide, SPCanvas *canvas, gboolean sensitive);
64 //Geom::Point sp_guide_position_from_pt(SPGuide const *guide, Geom::Point const &pt);
65 //double sp_guide_distance_from_pt(SPGuide const *guide, Geom::Point const &pt);
66 void sp_guide_moveto(SPGuide const &guide, Geom::Point const point_on_line, bool const commit);
67 void sp_guide_set_normal(SPGuide const &guide, Geom::Point const normal_to_line, bool const commit);
68 void sp_guide_remove(SPGuide *guide);
70 char *sp_guide_description(SPGuide const *guide, const bool verbose = true);
73 #endif /* !SP_GUIDE_H */
75 /*
76   Local Variables:
77   mode:c++
78   c-file-style:"stroustrup"
79   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
80   indent-tabs-mode:nil
81   fill-column:99
82   End:
83 */
84 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :