Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
lpe-jointype.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2/* Authors:
3 *
4 * Liam P White
5 *
6 * Copyright (C) 2014 Authors
7 *
8 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
9 */
10
11#include "lpe-jointype.h"
12
13#include <glibmm/i18n.h>
14
16
17#include "preferences.h"
18#include "style.h"
19
24#include "object/sp-shape.h"
25
26namespace Inkscape {
27namespace LivePathEffect {
28
30 // clang-format off
31 {JOIN_BEVEL, N_("Beveled"), "bevel"},
32 {JOIN_ROUND, N_("Rounded"), "round"},
33 {JOIN_MITER, N_("Miter"), "miter"},
34 {JOIN_MITER_CLIP, N_("Miter Clip"), "miter-clip"},
35 {JOIN_EXTRAPOLATE, N_("Extrapolated arc"), "extrp_arc"},
36 {JOIN_EXTRAPOLATE1, N_("Extrapolated arc Alt1"), "extrp_arc1"},
37 {JOIN_EXTRAPOLATE2, N_("Extrapolated arc Alt2"), "extrp_arc2"},
38 {JOIN_EXTRAPOLATE3, N_("Extrapolated arc Alt3"), "extrp_arc3"},
39 // clang-format on
40};
41
43 {BUTT_FLAT, N_("Butt"), "butt"},
44 {BUTT_ROUND, N_("Rounded"), "round"},
45 {BUTT_SQUARE, N_("Square"), "square"},
46 {BUTT_PEAK, N_("Peak"), "peak"},
47 //{BUTT_LEANED, N_("Leaned"), "leaned"}
48};
49
52
54 Effect(lpeobject),
55 line_width(_("Line width"), _("Thickness of the stroke"), "line_width", &wr, this, 1.),
56 linecap_type(_("Line cap"), _("The end shape of the stroke"), "linecap_type", CapTypeConverter, &wr, this, BUTT_FLAT),
57 linejoin_type(_("Join:"), _("Determines the shape of the path's corners"), "linejoin_type", JoinTypeConverter, &wr, this, JOIN_EXTRAPOLATE),
58 //start_lean(_("Start path lean"), _("Start path lean"), "start_lean", &wr, this, 0.),
59 //end_lean(_("End path lean"), _("End path lean"), "end_lean", &wr, this, 0.),
60 miter_limit(_("Miter limit:"), _("Maximum length of the miter join (in units of stroke width)"), "miter_limit", &wr, this, 100.),
61 attempt_force_join(_("Force miter"), _("Overrides the miter limit and forces a join."), "attempt_force_join", &wr, this, true)
62{
63 show_orig_path = true;
67 //registerParameter(&start_lean);
68 //registerParameter(&end_lean);
71 //start_lean.param_set_range(-1,1);
72 //start_lean.param_set_increments(0.1, 0.1);
73 //start_lean.param_set_digits(4);
74 //end_lean.param_set_range(-1,1);
75 //end_lean.param_set_increments(0.1, 0.1);
76 //end_lean.param_set_digits(4);
77}
78
80
82{
83 if (!is<SPShape>(lpeitem)) {
84 return;
85 }
86
88 auto lpeitem_mutable = const_cast<SPLPEItem *>(lpeitem);
89 auto item = cast<SPShape>(lpeitem_mutable);
90 double width = (lpeitem && lpeitem->style) ? lpeitem->style->stroke_width.computed : 1.;
91
93
94 Glib::ustring pref_path = (Glib::ustring)"/live_effects/" +
95 (Glib::ustring)LPETypeConverter.get_key(effectType()).c_str() +
96 (Glib::ustring)"/" +
97 (Glib::ustring)"line_width";
98
99 bool valid = prefs->getEntry(pref_path).isValidDouble();
100
101 if (!valid) {
103 }
104
106}
107
108void LPEJoinType::transform_multiply(Geom::Affine const &postmul, bool /*set*/)
109{
111 bool transform_stroke = prefs ? prefs->getBool("/options/transform/stroke", true) : true;
112 if (transform_stroke) {
113 line_width.param_transform_multiply(postmul, false);
114 }
115}
116
117//from LPEPowerStroke -- sets stroke color from existing fill color
118
120{
121 auto lpeitem_mutable = const_cast<SPLPEItem *>(lpeitem);
122 auto shape = cast<SPShape>(lpeitem_mutable);
123 if (shape) {
125 }
126}
127
129{
131 for (const auto & i : path_in) {
133 (attempt_force_join ? std::numeric_limits<double>::max() : miter_limit),
134 static_cast<LineJoinType>(linejoin_type.get_value()),
135 static_cast<LineCapType>(linecap_type.get_value()));
136 ret.insert(ret.begin(), tmp.begin(), tmp.end());
137 }
138
139 return ret;
140}
141
142} // namespace LivePathEffect
143} // namespace Inkscape
144
145/*
146 Local Variables:
147 mode:c++
148 c-file-style:"stroustrup"
149 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
150 indent-tabs-mode:nil
151 fill-column:99
152 End:
153*/
154// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 :
3x3 matrix representing an affine transformation.
Definition affine.h:70
Sequence of subpaths.
Definition pathvector.h:122
iterator insert(iterator pos, Path const &p)
Definition pathvector.h:179
iterator begin()
Definition pathvector.h:151
iterator end()
Definition pathvector.h:152
void registerParameter(Parameter *param)
Definition effect.cpp:1704
EffectType effectType() const
Definition effect.cpp:1182
void transform_multiply(Geom::Affine const &postmul, bool set) override
Overridden function to apply transforms for example to powerstroke, jointtype or tapperstroke.
Geom::PathVector doEffect_path(Geom::PathVector const &path_in) override
EnumParam< unsigned > linejoin_type
void doOnApply(SPLPEItem const *lpeitem) override
Is performed a single time when the effect is freshly applied to a path.
LPEJoinType(LivePathEffectObject *lpeobject)
void doOnRemove(SPLPEItem const *lpeitem) override
void param_transform_multiply(Geom::Affine const &postmul, bool set) override
bool isValidDouble() const
Check if the preference value can be interpreted as a floating point value.
Preference storage class.
Definition preferences.h:61
bool getBool(Glib::ustring const &pref_path, bool def=false)
Retrieve a Boolean value.
static Preferences * get()
Access the singleton Preferences object.
Entry const getEntry(Glib::ustring const &pref_path)
Retrieve a preference entry without specifying its type.
Simplified management of enumerations of svg items with UI labels.
Definition enums.h:42
SPStyle * style
Represents the style properties, whether from presentation attributes, the style attribute,...
Definition sp-object.h:248
T< SPAttr::STROKE_WIDTH, SPILength > stroke_width
stroke-width
Definition style.h:249
Elliptical arc curve.
Fill/stroke conversion routines for LPEs which draw a stroke.
SPItem * item
void lpe_shape_convert_stroke_and_fill(SPShape *shape)
Prepares a SPShape's fill and stroke for use in a path effect by setting the existing stroke properti...
void lpe_shape_revert_stroke_and_fill(SPShape *shape, double width)
Applies the fill of the SPShape to its stroke, sets the stroke width to the provided parameter,...
static const Util::EnumData< unsigned > CapTypeData[]
static const Util::EnumDataConverter< unsigned > JoinTypeConverter(JoinTypeData, sizeof(JoinTypeData)/sizeof(*JoinTypeData))
const EnumEffectDataConverter< EffectType > LPETypeConverter
defined in effect.cpp
static const Util::EnumData< unsigned > JoinTypeData[]
static const Util::EnumDataConverter< unsigned > CapTypeConverter(CapTypeData, sizeof(CapTypeData)/sizeof(*CapTypeData))
Helper class to stream background task notifications as a series of messages.
Geom::PathVector outline(Geom::Path const &input, double width, double miter, LineJoinType join, LineCapType butt, double tolerance)
Strokes the path given by input.
Singleton class to access the preferences file in a convenient way.
Simplified management of enumerations of svg items with UI labels.
Definition enums.h:27
SPStyle - a style object for SPItem objects.
double width