12#include <glibmm/i18n.h>
40namespace LivePathEffect {
43 {
CLM_NONE, N_(
"Transformation Only"),
"none" },
44 {
CLM_D, N_(
"Original Shape + LPEs"),
"d" },
52 , linkeditem(_(
"Linked Object:"), _(
"Select the object to use as the source for original data."),
"linkeditem", &wr, this)
53 , method(_(
"Shape"), _(
"Choose how path geometry is synchronized from the original object: Transformations only, original path data, path with Live Path Effects, or Spiro/BSpline shapes only."),
"method",
CLMConverter, &wr, this,
CLM_D)
54 , allow_transforms(_(
"Allow Transformations"), _(
"This allows you to change the position, scale, and rotation of the clone."),
"allow_transforms", &wr, this, true)
55 , attributes(_(
"Attributes"), _(
"Attributes of the original object that the clone should copy, written as a comma-separated list e.g. 'transform, style, clip-path, X, Y'."),
56 "attributes", &wr, this,
"")
57 , css_properties(_(
"CSS Properties"),
58 _(
"Specify which CSS properties the clone should copy from the original object, using a comma-separated list (for example: 'fill, filter, opacity')."),
59 "css_properties", &wr, this,
"")
63 if (linkedpath && strcmp(linkedpath,
"") != 0){
72 if (
getLPEObj()->getAttribute(
"linkeditem")) {
117 auto const vbox = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL, 6);
120 std::vector<Parameter *>::iterator it =
param_vector.begin();
122 if ((*it)->widget_is_visible) {
130 widg->set_tooltip_markup(*tip);
132 widg->set_tooltip_text(
"");
133 widg->set_has_tooltip(
false);
139 auto const sync_button = Gtk::make_managed<Gtk::Button>(Glib::ustring(_(
"Unlink Shape - Transformation Only")));
149 if (!document || !
origin || !dest) {
153 auto group_origin = cast<SPGroup>(
origin);
154 auto group_dest = cast<SPGroup>(dest);
155 if (group_origin && group_dest && group_origin->getItemCount() == group_dest->getItemCount()) {
156 std::vector< SPObject * > childs = group_origin->childList(
true);
158 for (
auto &
child : childs) {
163 }
else if ((!group_origin && group_dest) ||
164 ( group_origin && !group_dest))
166 g_warning(
"LPE Clone Original: for this path effect to work properly, the same type and the same number of children are required");
170 auto shape_origin = cast<SPShape>(
origin);
171 auto shape_dest = cast<SPShape>(dest);
172 auto path_dest = cast<SPPath>(dest);
175 gchar ** iter = attarray;
177 const char *attribute = g_strstrip(*iter);
178 if (strlen(attribute)) {
183 g_strfreev(attarray);
188 const char *attribute = g_strstrip(*iter);
189 if (strlen(attribute) && shape_dest && shape_origin) {
190 if (std::strcmp(attribute,
"d") == 0) {
191 std::optional<Geom::PathVector>
c;
194 auto lpe_item = cast<SPLPEItem>(
origin);
197 PathEffectList::iterator i;
198 for (i = lpelist.begin(); i != lpelist.end(); ++i) {
225 shape_dest->setCurveInsync(std::move(*
c));
233 }
else if (strlen(attribute)) {
242 g_strfreev(attarray);
249 css_dest = css_origin;
252 gchar ** styleiter = styleattarray;
254 const char *attribute = g_strstrip(*styleiter);
255 if (strlen(attribute)) {
260 g_strfreev(styleattarray);
263 styleiter = styleattarray;
265 const char *attribute = g_strstrip(*styleiter);
266 if (strlen(attribute)) {
268 if (!strlen(origin_attribute)) {
276 g_strfreev(styleattarray);
278 Glib::ustring css_str;
310 auto text_origin = cast<SPText>(
orig);
319 Glib::ustring attr =
"d,";
320 if (text_origin && dest_shape) {
321 auto curve = text_origin->getNormalizedBpath();
325 dest_shape->setCurveInsync(
curve);
330 dest->setAttribute(
"transform",
nullptr);
334 attr += attributes_str +
",";
335 if (attr.size() && attributes_str.empty()) {
336 attr.erase (attr.size()-1, 1);
339 Glib::ustring style_attr =
"";
340 if (style_attr.size() && css_properties_str.empty()) {
341 style_attr.erase (style_attr.size()-1, 1);
343 style_attr += css_properties_str +
",";
358 if (lpeitems[0] && lpeitems[0]->getAttribute(
"class")) {
360 size_t pos = fromclone.find(
"fromclone");
361 if (pos != Glib::ustring::npos && !lpeitems[0]->document->isSeeking()) {
377 Glib::ustring fromclone = lpeitem->
getAttribute(
"class");
378 size_t pos = fromclone.find(
"fromclone");
385 if (
SPUse *clone = cast<SPUse>(oset.singleItem())) {
386 auto transform_use = clone->get_root_transform();
387 clone->transform *= transform_use.inverse();
391 clone->transform *= item_t;
394 clone->doWriteTransform(clone->transform);
395 clone->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
408 if (!current_curve_before) {
414 curve = *current_curve;
3x3 matrix representing an affine transformation.
std::vector< Parameter * > param_vector
void registerParameter(Parameter *param)
LivePathEffectObject * lpeobj
bool isOnClipboard()
The lpe is on clipboard.
std::vector< SPLPEItem * > getCurrrentLPEItems() const
LivePathEffectObject * getLPEObj()
void param_set_value(E val)
void original_bbox(SPLPEItem const *lpeitem, bool absolute=false, bool clip_mask=false, Geom::Affine base_transform=Geom::identity())
void doOnRemove(SPLPEItem const *) override
LPECloneOriginal(LivePathEffectObject *lpeobject)
bool doOnOpen(SPLPEItem const *lpeitem) override
Is performed on load document or revert If the item is fixed legacy return true.
Gtk::Widget * newWidget() override
This creates a managed widget.
Glib::ustring old_attributes
OriginalSatelliteParam linkeditem
void cloneAttributes(SPObject *origin, SPObject *dest, const gchar *attributes, const gchar *css_properties, bool init)
EnumParam< Clonelpemethod > method
void doBeforeEffect(SPLPEItem const *lpeitem) override
Is performed each time before the effect is updated.
~LPECloneOriginal() override
Glib::ustring old_css_properties
void doEffect(Geom::PathVector &curve) override
bool getHolderRemove() override
BoolParam allow_transforms
Glib::ustring const * param_getTooltip() const
void connect_selection_changed()
virtual Gtk::Widget * param_newWidget()=0
std::shared_ptr< SatelliteReference > lperef
void start_listening(SPObject *to)
SPObject * getObject() const
void param_hide_canvas_text()
Glib::ustring param_getSVGValue() const override
Simplified management of enumerations of svg items with UI labels.
Inkscape::LivePathEffect::Effect * get_lpe()
To do: update description of desktop.
Inkscape::UI::Tools::ToolBase * getTool() const
Typed SVG document implementation.
SPObject is an abstract base class of all of the document nodes at the SVG document level.
void setAttributeOrRemoveIfEmpty(Inkscape::Util::const_char_ptr key, Inkscape::Util::const_char_ptr value)
void setAttribute(Inkscape::Util::const_char_ptr key, Inkscape::Util::const_char_ptr value)
void removeAttribute(char const *key)
char const * getAttribute(char const *name) const
SPObject * nthChild(unsigned index)
void requestDisplayUpdate(unsigned int flags)
Queues an deferred update of this object's display.
Geom::PathVector const * curve() const
Return a borrowed pointer to the curve (if any exists) or NULL if there is no curve.
Geom::PathVector const * curveBeforeLPE() const
Return a borrowed pointer of the curve before LPE (if any exists) or NULL if there is no curve.
auto ptr_to_opt(T const &p)
Create a std::optional<T> from a (generalised) pointer to T.
Affine identity()
Create an identity matrix.
void sp_bspline_do_effect(Geom::PathVector &curve, double helper_size, Geom::PathVector &hp, bool uniform)
static const Util::EnumData< Clonelpemethod > ClonelpemethodData[]
static const Util::EnumDataConverter< Clonelpemethod > CLMConverter(ClonelpemethodData, CLM_END)
void sp_spiro_do_effect(Geom::PathVector &curve)
void pack_start(Gtk::Box &box, Gtk::Widget &child, bool const expand, bool const fill, unsigned const padding)
Adds child to box, packed with reference to the start of box.
auto to_opt(char const *s)
auto to_cstr(std::optional< std::string > const &s)
Helper class to stream background task notifications as a series of messages.
Helpers for using Gtk::Boxes, encapsulating large changes between GTK3 & GTK4.
Inkscape::SVG::PathString - builder for SVG path strings.
SPCSSAttr * sp_repr_css_attr_new()
Creates an empty SPCSSAttr (a class for manipulating CSS style properties).
void sp_repr_css_write_string(SPCSSAttr *css, Glib::ustring &str)
Write a style attribute string from a list of properties stored in an SPCSAttr object.
char const * sp_repr_css_property(SPCSSAttr *css, gchar const *name, gchar const *defval)
Returns a character string of the value of a given style property or a default value if the attribute...
void sp_repr_css_set_property(SPCSSAttr *css, gchar const *name, gchar const *value)
Set a style property to a new value (e.g.
void sp_repr_css_attr_add_from_string(SPCSSAttr *css, gchar const *p)
Use libcroco to parse a string for CSS properties and then merge them into an existing SPCSSAttr.
TODO: insert short description here.
SPCSSAttr - interface for CSS Attributes.
void sp_lpe_item_update_patheffect(SPLPEItem *lpeitem, bool wholetree, bool write, bool with_satellites)
Calls any registered handlers for the update_patheffect action.
std::list< PathEffectSharedPtr > PathEffectList
Simplified management of enumerations of svg items with UI labels.
bool sp_svg_transform_read(gchar const *str, Geom::Affine *transform)
static void sp_svg_write_path(Inkscape::SVG::PathString &str, Geom::Path const &p, bool normalize=false)
void init(int argc, char **argv, Toy *t, int width=600, int height=600)