Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
lpe-line_segment.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
6/*
7 * Authors:
8 * Maximilian Albert
9 *
10 * Copyright (C) Maximilian Albert 2008 <maximilian.albert@gmail.com>
11 *
12 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
13 */
14
15#include "lpe-line_segment.h"
16
17#include <glibmm/i18n.h>
18
19#include "object/sp-lpe-item.h"
20#include "ui/tools/lpe-tool.h"
21
22namespace Inkscape {
23namespace LivePathEffect {
24
26 {END_CLOSED , N_("Closed"), "closed"},
27 {END_OPEN_INITIAL , N_("Open start"), "open_start"},
28 {END_OPEN_FINAL , N_("Open end"), "open_end"},
29 {END_OPEN_BOTH , N_("Open both"), "open_both"},
30};
32
34 Effect(lpeobject),
35 end_type(_("End type:"), _("Determines on which side the line or line segment is infinite."), "end_type", EndTypeConverter, &wr, this, END_OPEN_BOTH)
36{
37 /* register all your parameters here, so Inkscape knows which parameters this effect has: */
39}
40
42
47
50{
51 Geom::PathVector output;
52
53 A = path_in.initialPoint();
54 B = path_in.finalPoint();
55
56 Geom::Rect dummyRect(bboxA, bboxB);
57 std::optional<Geom::LineSegment> intersection_segment = Geom::Line(A, B).clip(dummyRect);
58
59 if (!intersection_segment) {
60 g_warning ("Possible error - no intersection with limiting bounding box.");
61 return path_in;
62 }
63
65 A = intersection_segment->initialPoint();
66 }
67
69 B = intersection_segment->finalPoint();
70 }
71
72 Geom::Path path(A);
74
75 output.push_back(path);
76
77 return output;
78}
79
80} //namespace LivePathEffect
81} /* namespace Inkscape */
82
83/*
84 Local Variables:
85 mode:c++
86 c-file-style:"stroustrup"
87 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
88 indent-tabs-mode:nil
89 fill-column:99
90 End:
91*/
92// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
Infinite line on a plane.
Definition line.h:53
std::optional< LineSegment > clip(Rect const &r) const
Return the portion of the line that is inside the given rectangle.
Definition line.cpp:151
Sequence of subpaths.
Definition pathvector.h:122
void push_back(Path const &path)
Append a path at the end.
Definition pathvector.h:172
Point finalPoint() const
Get the last point in the last path of the vector.
Definition pathvector.h:222
Point initialPoint() const
Get the first point in the first path of the vector.
Definition pathvector.h:217
Sequence of contiguous curves, aka spline.
Definition path.h:353
void appendNew(Args &&... args)
Append a new curve to the path.
Definition path.h:804
Axis aligned, non-empty rectangle.
Definition rect.h:92
void registerParameter(Parameter *param)
Definition effect.cpp:1704
void doBeforeEffect(SPLPEItem const *lpeitem) override
Is performed each time before the effect is updated.
Geom::PathVector doEffect_path(Geom::PathVector const &path_in) override
LPELineSegment(LivePathEffectObject *lpeobject)
Simplified management of enumerations of svg items with UI labels.
Definition enums.h:42
SPDocument * document
Definition sp-object.h:188
LPE <line_segment> implementation.
LPETool: a generic tool composed of subtools that are given by LPEs.
static const Util::EnumDataConverter< EndType > EndTypeConverter(EndTypeData, sizeof(EndTypeData)/sizeof(*EndTypeData))
static const Util::EnumData< EndType > EndTypeData[]
std::pair< Geom::Point, Geom::Point > lpetool_get_limiting_bbox_corners(SPDocument const *document)
Definition lpe-tool.cpp:233
Helper class to stream background task notifications as a series of messages.
Base class for live path effect items.
Simplified management of enumerations of svg items with UI labels.
Definition enums.h:27