Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
connector-tool.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2#ifndef SEEN_CONNECTOR_CONTEXT_H
3#define SEEN_CONNECTOR_CONTEXT_H
4
5/*
6 * Connector creation tool
7 *
8 * Authors:
9 * Michael Wybrow <mjwybrow@users.sourceforge.net>
10 *
11 * Copyright (C) 2005 Michael Wybrow
12 *
13 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
14 */
15
16#include <2geom/pathvector.h>
17
18#include "ui/tools/tool-base.h"
19
20#include "xml/node-observer.h"
21
22class SPItem;
23class SPKnot;
24
25namespace Avoid {
26 class ConnRef;
27}
28
29namespace Inkscape {
30class CanvasItemBpath;
31class Selection;
32namespace XML { class Node; }
33struct ButtonPressEvent;
34struct MotionEvent;
35struct ButtonReleaseEvent;
36} // namespace Inkscape
37
38#define SP_CONNECTOR_CONTEXT(obj) (dynamic_cast<Inkscape::UI::Tools::ConnectorTool*>((Inkscape::UI::Tools::ToolBase*)obj))
39
40enum {
47};
48
49using SPKnotList = std::map<SPKnot *, int>;
50
51namespace Inkscape::UI::Tools {
52
53class ConnectorTool;
54
56{
57 friend class ConnectorTool;
58 ~CCToolShapeNodeObserver() override = default; // can only exist as a direct base of ConnectorTool
59
61};
62
64{
65 friend class ConnectorTool;
66 ~CCToolLayerNodeObserver() override = default; // can only exist as a direct base of ConnectorTool
67
69};
70
72 : public ToolBase
75{
76public:
78 ~ConnectorTool() override;
79
82
84 gint npoints{0};
85 unsigned int state : 4;
86
87 // Red curve
89 std::optional<Geom::PathVector> red_curve;
90 uint32_t red_color{0xff00007f};
91
92 // Green curve
93 std::optional<Geom::PathVector> green_curve;
94
95 // The new connector
96 SPItem *newconn{nullptr};
98 gdouble curvature{0.0};
99 bool isOrthogonal{false};
100
101 // The active shape
105
106 // Same as above, but for the active connector
109 sigc::connection sel_changed_connection;
110
111 // The activehandle
113
114 // The selected handle, used in editing mode
116
119
122 sigc::connection endpt_handler_connection[2];
123 gchar *shref{nullptr};
124 gchar *sub_shref{nullptr};
125 gchar *ehref {nullptr};
126 gchar *sub_ehref{nullptr};
127
128 void set(Preferences::Entry const &val) override;
129 bool root_handler(CanvasEvent const &event) override;
130 bool item_handler(SPItem* item, CanvasEvent const &event) override;
131
135
136private:
138
139 bool _handleButtonPress(ButtonPressEvent const &bevent);
140 bool _handleMotionNotify(MotionEvent const &mevent);
141 bool _handleButtonRelease(ButtonReleaseEvent const &revent);
142 bool _handleKeyPress(guint const keyval);
143
144 void _setInitialPoint(Geom::Point const p);
147 void _resetColors();
148 void _finish();
151
152 void _activeShapeAddKnot(SPItem* item, SPItem* subitem);
154 bool _ptHandleTest(Geom::Point& p, gchar **href, gchar **subhref);
155
156 void _reroutingFinish(Geom::Point *const p);
157
162};
163
164void cc_selection_set_avoid(SPDesktop *, bool const set_ignore);
168
169} // namespace Inkscape::UI::Tools
170
171#endif /* !SEEN_CONNECTOR_CONTEXT_H */
172
173/*
174 Local Variables:
175 mode:c++
176 c-file-style:"stroustrup"
177 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
178 indent-tabs-mode:nil
179 fill-column:99
180 End:
181*/
182// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
The ConnRef class represents a connector object.
Definition connector.h:132
Sequence of subpaths.
Definition pathvector.h:122
Two-dimensional point that doubles as a vector.
Definition point.h:66
Data type representing a typeless value of a preference.
The set of selected SPObjects for a given document and layer model.
Definition selection.h:80
void notifyChildRemoved(Inkscape::XML::Node &, Inkscape::XML::Node &, Inkscape::XML::Node *) final
Child removal callback.
void notifyAttributeChanged(Inkscape::XML::Node &, GQuark, Util::ptr_shared, Util::ptr_shared) final
Attribute change callback.
void _activeShapeAddKnot(SPItem *item, SPItem *subitem)
bool _handleKeyPress(guint const keyval)
bool _handleMotionNotify(MotionEvent const &mevent)
Inkscape::XML::Node * active_shape_layer_repr
CCToolShapeNodeObserver & shapeNodeObserver()
std::optional< Geom::PathVector > red_curve
bool item_handler(SPItem *item, CanvasEvent const &event) override
Handles item specific events.
CCToolLayerNodeObserver & layerNodeObserver()
Inkscape::CanvasItemBpath * red_bpath
void _concatColorsAndFlush()
Concats red, blue and green.
void _setInitialPoint(Geom::Point const p)
void _reroutingFinish(Geom::Point *const p)
void _setSubsequentPoint(Geom::Point const p)
void _flushWhite(Geom::PathVector &c)
bool _ptHandleTest(Geom::Point &p, gchar **href, gchar **subhref)
void _selectionChanged(Inkscape::Selection *selection)
sigc::connection endpt_handler_connection[2]
std::optional< Geom::PathVector > green_curve
gint npoints
\invar npoints in {0, 2}.
Inkscape::XML::Node * active_shape_repr
bool root_handler(CanvasEvent const &event) override
bool _handleButtonPress(ButtonPressEvent const &bevent)
Inkscape::XML::Node * active_conn_repr
bool _handleButtonRelease(ButtonReleaseEvent const &revent)
Base class for Event processors.
Definition tool-base.h:95
Interface for XML node observers.
Interface for refcounted XML nodes.
Definition node.h:80
To do: update description of desktop.
Definition desktop.h:149
Base class for visual SVG elements.
Definition sp-item.h:109
Desktop-bound visual control object.
Definition knot.h:51
std::map< SPKnot *, int > SPKnotList
@ SP_CONNECTOR_CONTEXT_REROUTING
@ SP_CONNECTOR_CONTEXT_DRAGGING
@ SP_CONNECTOR_CONTEXT_IDLE
@ SP_CONNECTOR_CONTEXT_STOP
@ SP_CONNECTOR_CONTEXT_CLOSE
@ SP_CONNECTOR_CONTEXT_NEWCONNPOINT
double c[8][4]
SPItem * item
libavoid: Object-avoiding orthogonal and polyline connector routing library.
void cc_remove_connection_point(ConnectorTool *cc)
bool cc_item_is_connector(SPItem *item)
void cc_selection_set_avoid(SPDesktop *desktop, bool const set_avoid)
void cc_create_connection_point(ConnectorTool *cc)
Helper class to stream background task notifications as a series of messages.
Interface for XML node observers.
PathVector - a sequence of subpaths.
guint32 GQuark
A mouse button (left/right/middle) is pressed.
A mouse button (left/right/middle) is released.
Abstract base class for events.
Movement of the mouse pointer.
SPDesktop * desktop