Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
sp-guide.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
/*
5 * Authors:
6 * Lauris Kaplinski 2000
7 * Johan Engelen 2007
8 * Abhishek Sharma
9 * Jon A. Cruz <jon@joncruz.org>
10 *
11 * Copyright (C) 2018 Authors
12 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
13 */
14#ifndef SEEN_SP_GUIDE_H
15#define SEEN_SP_GUIDE_H
16
17#include <2geom/point.h>
18#include <vector>
19
21#include "sp-object.h"
22
23typedef unsigned int guint32;
24extern "C" {
25 typedef void (*GCallback) ();
26}
27
28class SPDesktop;
29
30namespace Inkscape {
31 class CanvasItemGroup;
32 class CanvasItemGuideLine;
33
34namespace UI::Widget {
35 class Canvas;
36
37}
38} // namespace Inkscape
39
40
41/* Represents the constraint on p that dot(g.direction, p) == g.position. */
42class SPGuide final : public SPObject {
43public:
44 SPGuide();
45 ~SPGuide() override = default;
46 int tag() const override { return tag_of<decltype(*this)>; }
47
48 void set_color(const unsigned r, const unsigned g, const unsigned b, bool const commit);
49 void setColor(guint32 c);
50 void setHiColor(guint32 h) { hicolor = h; }
51
52 guint32 getColor() const { return color; }
53 guint32 getHiColor() const { return hicolor; }
56
57 void moveto(Geom::Point const point_on_line, bool const commit);
58 void set_normal(Geom::Point const normal_to_line, bool const commit);
59
60 void set_label(const char* label, bool const commit);
61 char const* getLabel() const { return label; }
62
63 void set_locked(const bool locked, bool const commit);
64 bool getLocked() const { return locked; }
65
66 void fix_orientation();
67
68 static SPGuide *createSPGuide(SPDocument *doc, Geom::Point const &pt1, Geom::Point const &pt2);
70
73 void showSPGuide(); // argument-free versions
74 void hideSPGuide();
75 bool remove(bool force=false);
76
77 void sensitize(Inkscape::UI::Widget::Canvas *canvas, bool sensitive);
78
79 bool isHorizontal() const { return (normal_to_line[Geom::X] == 0.); };
80 bool isVertical() const { return (normal_to_line[Geom::Y] == 0.); };
81
82 char* description(bool const verbose = true) const;
83
84 double angle() const { return std::atan2( - normal_to_line[Geom::X], normal_to_line[Geom::Y] ); }
85
86protected:
87 void build(SPDocument* doc, Inkscape::XML::Node* repr) override;
88 void release() override;
89 void set(SPAttr key, const char* value) override;
90
91 char* label;
92 std::vector<CanvasItemPtr<Inkscape::CanvasItemGuideLine>> views; // See display/control/guideline.h.
93 bool locked;
96
99};
100
101// These functions rightfully belong to SPDesktop. What gives?!
102void sp_guide_pt_pairs_to_guides(SPDocument *doc, std::list<std::pair<Geom::Point, Geom::Point> > &pts);
105
106#endif // SEEN_SP_GUIDE_H
107
108/*
109 Local Variables:
110 mode:c++
111 c-file-style:"stroustrup"
112 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
113 indent-tabs-mode:nil
114 fill-column:99
115 End:
116*/
117// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
Cartesian point / 2D vector and related operations.
SPAttr
Definition attributes.h:27
constexpr int tag_of
Convenience function to retrieve the tag (class id) of a given type.
Definition cast.h:26
Two-dimensional point that doubles as a vector.
Definition point.h:66
A widget for Inkscape's canvas.
Definition canvas.h:62
Interface for refcounted XML nodes.
Definition node.h:80
To do: update description of desktop.
Definition desktop.h:149
Typed SVG document implementation.
Definition document.h:101
void set_locked(const bool locked, bool const commit)
Definition sp-guide.cpp:452
guint32 getHiColor() const
Definition sp-guide.h:53
void setHiColor(guint32 h)
Definition sp-guide.h:50
void fix_orientation()
Definition sp-guide.cpp:200
char * description(bool const verbose=true) const
Returns a human-readable description of the guideline for use in dialog boxes and status bar.
Definition sp-guide.cpp:482
double angle() const
Definition sp-guide.h:84
Geom::Point getNormal() const
Definition sp-guide.h:55
void sensitize(Inkscape::UI::Widget::Canvas *canvas, bool sensitive)
Definition sp-guide.cpp:348
guint32 hicolor
Definition sp-guide.h:98
bool isHorizontal() const
Definition sp-guide.h:79
void build(SPDocument *doc, Inkscape::XML::Node *repr) override
Definition sp-guide.cpp:63
int tag() const override
Definition sp-guide.h:46
void set_color(const unsigned r, const unsigned g, const unsigned b, bool const commit)
Definition sp-guide.cpp:436
void setColor(guint32 c)
Definition sp-guide.cpp:55
bool locked
Definition sp-guide.h:93
void moveto(Geom::Point const point_on_line, bool const commit)
Definition sp-guide.cpp:367
Geom::Point point_on_line
Definition sp-guide.h:95
guint32 color
Definition sp-guide.h:97
bool isVertical() const
Definition sp-guide.h:80
~SPGuide() override=default
Geom::Point normal_to_line
Definition sp-guide.h:94
std::vector< CanvasItemPtr< Inkscape::CanvasItemGuideLine > > views
Definition sp-guide.h:92
void set_normal(Geom::Point const normal_to_line, bool const commit)
Definition sp-guide.cpp:412
static SPGuide * createSPGuide(SPDocument *doc, Geom::Point const &pt1, Geom::Point const &pt2)
Definition sp-guide.cpp:209
guint32 getColor() const
Definition sp-guide.h:52
SPGuide * duplicate()
Definition sp-guide.cpp:257
void hideSPGuide()
Definition sp-guide.cpp:341
char * label
Definition sp-guide.h:91
Geom::Point getPoint() const
Definition sp-guide.h:54
bool getLocked() const
Definition sp-guide.h:64
bool remove(bool force=false)
Definition sp-guide.cpp:529
void showSPGuide()
Definition sp-guide.cpp:320
void set_label(const char *label, bool const commit)
Definition sp-guide.cpp:464
void release() override
Definition sp-guide.cpp:77
char const * getLabel() const
Definition sp-guide.h:61
SPObject is an abstract base class of all of the document nodes at the SVG document level.
Definition sp-object.h:160
Inkscape::XML::Node * repr
Definition sp-object.h:193
double c[8][4]
unsigned int guint32
@ Y
Definition coord.h:48
@ X
Definition coord.h:48
Helper class to stream background task notifications as a series of messages.
static cairo_user_data_key_t key
unsigned int guint32
Definition sp-guide.h:23
void sp_guide_create_guides_around_page(SPDocument *doc)
Definition sp-guide.cpp:275
void sp_guide_pt_pairs_to_guides(SPDocument *doc, std::list< std::pair< Geom::Point, Geom::Point > > &pts)
Definition sp-guide.cpp:268
void sp_guide_delete_all_guides(SPDocument *doc)
Definition sp-guide.cpp:290
void(* GCallback)()
Definition sp-guide.h:25