summaryrefslogtreecommitdiffstats
path: root/src/live_effects
diff options
context:
space:
mode:
Diffstat (limited to 'src/live_effects')
-rw-r--r--src/live_effects/CMakeLists.txt6
-rw-r--r--src/live_effects/effect.cpp39
-rw-r--r--src/live_effects/effect.h4
-rw-r--r--src/live_effects/lpe-bendpath.cpp15
-rw-r--r--src/live_effects/lpe-bendpath.h2
-rw-r--r--src/live_effects/lpe-circle_3pts.cpp12
-rw-r--r--src/live_effects/lpe-clone-original.cpp358
-rw-r--r--src/live_effects/lpe-clone-original.h48
-rw-r--r--src/live_effects/lpe-fill-between-many.cpp116
-rw-r--r--src/live_effects/lpe-fill-between-many.h14
-rw-r--r--src/live_effects/lpe-fillet-chamfer.cpp2
-rw-r--r--src/live_effects/lpe-interpolate_points.cpp4
-rw-r--r--src/live_effects/lpe-knot.cpp2
-rw-r--r--src/live_effects/lpe-measure-segments.cpp330
-rw-r--r--src/live_effects/lpe-measure-segments.h26
-rw-r--r--src/live_effects/lpe-patternalongpath.cpp79
-rw-r--r--src/live_effects/lpe-powerclip.cpp133
-rw-r--r--src/live_effects/lpe-powerclip.h12
-rw-r--r--src/live_effects/lpe-powermask.cpp135
-rw-r--r--src/live_effects/lpe-powermask.h11
-rw-r--r--src/live_effects/lpe-powerstroke.cpp4
-rw-r--r--src/live_effects/lpe-ruler.cpp14
-rw-r--r--src/live_effects/makefile.in17
-rw-r--r--src/live_effects/parameter/array.h4
-rw-r--r--src/live_effects/parameter/bool.cpp7
-rw-r--r--src/live_effects/parameter/bool.h1
-rw-r--r--src/live_effects/parameter/colorpicker.cpp151
-rw-r--r--src/live_effects/parameter/colorpicker.h61
-rw-r--r--src/live_effects/parameter/enum.h7
-rw-r--r--src/live_effects/parameter/fontbutton.cpp8
-rw-r--r--src/live_effects/parameter/fontbutton.h1
-rw-r--r--src/live_effects/parameter/hidden.cpp9
-rw-r--r--src/live_effects/parameter/hidden.h1
-rw-r--r--src/live_effects/parameter/item.cpp21
-rw-r--r--src/live_effects/parameter/item.h6
-rw-r--r--src/live_effects/parameter/makefile.in17
-rw-r--r--src/live_effects/parameter/message.cpp101
-rw-r--r--src/live_effects/parameter/message.h61
-rw-r--r--src/live_effects/parameter/originalitem.cpp13
-rw-r--r--src/live_effects/parameter/originalitem.h2
-rw-r--r--src/live_effects/parameter/originalitemarray.cpp470
-rw-r--r--src/live_effects/parameter/originalitemarray.h122
-rw-r--r--src/live_effects/parameter/originalpath.cpp7
-rw-r--r--src/live_effects/parameter/originalpath.h2
-rw-r--r--src/live_effects/parameter/originalpatharray.cpp181
-rw-r--r--src/live_effects/parameter/originalpatharray.h39
-rw-r--r--src/live_effects/parameter/parameter.cpp9
-rw-r--r--src/live_effects/parameter/parameter.h2
-rw-r--r--src/live_effects/parameter/path.cpp46
-rw-r--r--src/live_effects/parameter/path.h3
-rw-r--r--src/live_effects/parameter/point.cpp9
-rw-r--r--src/live_effects/parameter/point.h1
-rw-r--r--src/live_effects/parameter/random.cpp9
-rw-r--r--src/live_effects/parameter/random.h1
-rw-r--r--src/live_effects/parameter/text.cpp33
-rw-r--r--src/live_effects/parameter/text.h2
-rw-r--r--src/live_effects/parameter/togglebutton.cpp23
-rw-r--r--src/live_effects/parameter/togglebutton.h2
-rw-r--r--src/live_effects/parameter/transformedpoint.cpp9
-rw-r--r--src/live_effects/parameter/transformedpoint.h1
-rw-r--r--src/live_effects/parameter/unit.cpp6
-rw-r--r--src/live_effects/parameter/unit.h1
-rw-r--r--src/live_effects/parameter/vector.cpp9
-rw-r--r--src/live_effects/parameter/vector.h1
64 files changed, 2015 insertions, 827 deletions
diff --git a/src/live_effects/CMakeLists.txt b/src/live_effects/CMakeLists.txt
index b1000de01..9d18626bc 100644
--- a/src/live_effects/CMakeLists.txt
+++ b/src/live_effects/CMakeLists.txt
@@ -64,9 +64,12 @@ set(live_effects_SRC
parameter/array.cpp
parameter/bool.cpp
+ parameter/colorpicker.cpp
parameter/hidden.cpp
parameter/item-reference.cpp
parameter/item.cpp
+ parameter/message.cpp
+ parameter/originalitemarray.cpp
parameter/originalitem.cpp
parameter/originalpath.cpp
parameter/originalpatharray.cpp
@@ -154,9 +157,12 @@ set(live_effects_SRC
parameter/array.h
parameter/bool.h
+ parameter/colorpicker.h
parameter/hidden.h
parameter/enum.h
parameter/item.h
+ parameter/message.h
+ parameter/originalitemarray.cpp
parameter/item-reference.h
parameter/originalitem.h
parameter/originalpath.h
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp
index b2ba0acdc..5674e29dc 100644
--- a/src/live_effects/effect.cpp
+++ b/src/live_effects/effect.cpp
@@ -81,6 +81,7 @@
#include "display/curve.h"
#include <stdio.h>
#include <string.h>
+#include <gtkmm/expander.h>
namespace Inkscape {
@@ -562,8 +563,8 @@ void Effect::doBeforeEffect_impl(SPLPEItem const* lpeitem)
setCurrentShape(shape);
doBeforeEffect(lpeitem);
if (apply_to_clippath_and_mask && SP_IS_GROUP(sp_lpe_item)) {
- sp_lpe_item->apply_to_clippath(sp_lpe_item);
- sp_lpe_item->apply_to_mask(sp_lpe_item);
+ sp_lpe_item->applyToClipPath(sp_lpe_item);
+ sp_lpe_item->applyToMask(sp_lpe_item);
}
update_helperpath();
}
@@ -826,29 +827,36 @@ Effect::defaultParamSet()
Glib::ustring * tip = param->param_getTooltip();
const gchar * key = param->param_key.c_str();
const gchar * value = param->param_label.c_str();
- const gchar * tooltip_extra = _(". Change custom values for this parameter");
- Glib::ustring tooltip = param->param_tooltip + (Glib::ustring)tooltip_extra;
+
Glib::ustring pref_path = (Glib::ustring)"/live_effects/" +
effectkey +
(Glib::ustring)"/" +
(Glib::ustring)key;
bool valid = prefs->getEntry(pref_path).isValid();
const gchar * set_or_upd;
+ Glib::ustring def = Glib::ustring(_("<b>Default value:</b> ")) + Glib::ustring(param->param_getDefaultSVGValue()) + Glib::ustring("\n");
+ Glib::ustring ove = Glib::ustring(_("<b>Default value overrided:</b> ")) + Glib::ustring(prefs->getString(pref_path)) + Glib::ustring("\n");
if (valid) {
set_or_upd = _("Update");
+ def = Glib::ustring(_("<b>Default value:</b> <s>")) + Glib::ustring(param->param_getDefaultSVGValue()) + Glib::ustring("</s>\n");
} else {
set_or_upd = _("Set");
+ ove = Glib::ustring(_("<b>Default value overrided:</b> None\n"));
}
+ Glib::ustring cur = Glib::ustring(_("<b>Current parameter value:</b> ")) + Glib::ustring(param->param_getSVGValue());
Gtk::HBox * vbox_param = Gtk::manage( new Gtk::HBox(true) );
Gtk::Label *parameter_label = Gtk::manage(new Gtk::Label(value, Gtk::ALIGN_START));
parameter_label->set_use_markup(true);
- parameter_label->set_use_underline (true);
+ parameter_label->set_use_underline(true);
+ Glib::ustring tooltip = Glib::ustring("<b>") + parameter_label->get_text () + Glib::ustring("</b>\n") + param->param_tooltip + Glib::ustring("\n\n");
parameter_label->set_ellipsize(Pango::ELLIPSIZE_END);
+ parameter_label->set_tooltip_markup((tooltip + def + ove + cur).c_str());
vbox_param->pack_start(*parameter_label, true, true, 2);
Gtk::Button *set = Gtk::manage(new Gtk::Button((Glib::ustring)set_or_upd));
Gtk::Button *unset = Gtk::manage(new Gtk::Button(Glib::ustring(_("Unset"))));
- unset->signal_clicked().connect(sigc::bind<Glib::ustring, Gtk::Button *, Gtk::Button *>(sigc::mem_fun(*this, &Effect::unsetDefaultParam), pref_path, set, unset));
- set->signal_clicked().connect(sigc::bind<Glib::ustring, gchar *, Gtk::Button *, Gtk::Button *>(sigc::mem_fun(*this, &Effect::setDefaultParam), pref_path, param->param_getSVGValue(), set, unset));
+ unset->signal_clicked().connect(sigc::bind<Glib::ustring, Glib::ustring, gchar *, gchar *, Gtk::Label *,Gtk::Button *, Gtk::Button *>(sigc::mem_fun(*this, &Effect::unsetDefaultParam), pref_path, tooltip, param->param_getSVGValue(), param->param_getDefaultSVGValue(), parameter_label, set, unset));
+
+ set->signal_clicked().connect(sigc::bind<Glib::ustring, Glib::ustring, gchar *, gchar *, Gtk::Label *,Gtk::Button *, Gtk::Button *>(sigc::mem_fun(*this, &Effect::setDefaultParam), pref_path, tooltip, param->param_getSVGValue(), param->param_getDefaultSVGValue(), parameter_label, set, unset));
if (!valid) {
unset->set_sensitive(false);
}
@@ -866,30 +874,41 @@ Effect::defaultParamSet()
expander->set_expanded(false);
vbox->pack_start(*dynamic_cast<Gtk::Widget *> (expander), true, true, 2);
if (has_params) {
- return dynamic_cast<Gtk::Widget *>(vbox);
+ Gtk::Widget *vboxwidg = dynamic_cast<Gtk::Widget *>(vbox);
+ vboxwidg->set_margin_bottom(10);
+ vboxwidg->set_margin_top(5);
+ return vboxwidg;
} else {
return NULL;
}
}
void
-Effect::setDefaultParam(Glib::ustring pref_path, gchar * value, Gtk::Button *set , Gtk::Button *unset)
+Effect::setDefaultParam(Glib::ustring pref_path, Glib::ustring tooltip, gchar * value, gchar * defvalue, Gtk::Label *parameter_label, Gtk::Button *set , Gtk::Button *unset)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setString(pref_path, (Glib::ustring)value);
gchar * label = _("Update");
set->set_label((Glib::ustring)label);
unset->set_sensitive(true);
+ Glib::ustring def = Glib::ustring(_("<b>Default value:</b> <s>")) + Glib::ustring(defvalue) + Glib::ustring("</s>\n");
+ Glib::ustring ove = Glib::ustring(_("<b>Default value overrided:</b> ")) + Glib::ustring(value) + Glib::ustring("\n");
+ Glib::ustring cur = Glib::ustring(_("<b>Current parameter value:</b> ")) + Glib::ustring(value);
+ parameter_label->set_tooltip_markup((tooltip + def + ove + cur).c_str());
}
void
-Effect::unsetDefaultParam(Glib::ustring pref_path, Gtk::Button *set, Gtk::Button *unset)
+Effect::unsetDefaultParam(Glib::ustring pref_path, Glib::ustring tooltip, gchar * value, gchar * defvalue, Gtk::Label *parameter_label, Gtk::Button *set , Gtk::Button *unset)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->remove(pref_path);
gchar * label = _("Set");
set->set_label((Glib::ustring)label);
unset->set_sensitive(false);
+ Glib::ustring def = Glib::ustring(_("<b>Default value:</b> ")) + Glib::ustring(defvalue) + Glib::ustring("\n");
+ Glib::ustring ove = Glib::ustring(_("<b>Default value overrided:</b> None\n"));
+ Glib::ustring cur = Glib::ustring(_("<b>Current parameter value:</b> ")) + Glib::ustring(value);
+ parameter_label->set_tooltip_markup((tooltip + def + ove + cur).c_str());
}
Inkscape::XML::Node *Effect::getRepr()
diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h
index e353eba23..d0024f877 100644
--- a/src/live_effects/effect.h
+++ b/src/live_effects/effect.h
@@ -181,8 +181,8 @@ protected:
std::vector<Geom::Point> selectedNodesPoints;
private:
- void setDefaultParam(Glib::ustring pref_path, gchar * value, Gtk::Button *set , Gtk::Button *unset);
- void unsetDefaultParam(Glib::ustring pref_path, Gtk::Button *set , Gtk::Button *unset);
+ void setDefaultParam(Glib::ustring pref_path, Glib::ustring par, gchar * value, gchar * defvalue, Gtk::Label *parameter_label, Gtk::Button *set , Gtk::Button *unset);
+ void unsetDefaultParam(Glib::ustring pref_path, Glib::ustring par, gchar * value, gchar * defvalue, Gtk::Label *parameter_label, Gtk::Button *set , Gtk::Button *unset);
bool provides_own_flash_paths; // if true, the standard flash path is suppressed
bool is_ready;
diff --git a/src/live_effects/lpe-bendpath.cpp b/src/live_effects/lpe-bendpath.cpp
index 5c1953fda..ff5f738eb 100644
--- a/src/live_effects/lpe-bendpath.cpp
+++ b/src/live_effects/lpe-bendpath.cpp
@@ -94,7 +94,7 @@ LPEBendPath::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd
uskeleton = arc_length_parametrization(Piecewise<D2<SBasis> >(bend_path.get_pwd2()),2,.1);
uskeleton = remove_short_cuts(uskeleton,.01);
n = rot90(derivative(uskeleton));
- n = force_continuity(remove_short_cuts(n,.1));
+ n = force_continuity(remove_short_cuts(n,.01));
bend_path.changed = false;
}
@@ -109,9 +109,10 @@ LPEBendPath::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd
Interval bboxHorizontal = vertical_pattern.get_value() ? boundingbox_Y : boundingbox_X;
Interval bboxVertical = vertical_pattern.get_value() ? boundingbox_X : boundingbox_Y;
-
+
+ //+0.1 in x fix bug #1658855
//We use the group bounding box size or the path bbox size to translate well x and y
- x-= bboxHorizontal.min();
+ x-= bboxHorizontal.min() + 0.1;
y-= bboxVertical.middle();
double scaling = uskeleton.cuts.back()/bboxHorizontal.extent();
@@ -151,6 +152,14 @@ LPEBendPath::resetDefaults(SPItem const* item)
}
void
+LPEBendPath::transform_multiply(Geom::Affine const& postmul, bool set)
+{
+ if (sp_lpe_item) {
+ sp_lpe_item_update_patheffect(sp_lpe_item, false, false);
+ }
+}
+
+void
LPEBendPath::addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec)
{
hp_vec.push_back(bp_helper_path);
diff --git a/src/live_effects/lpe-bendpath.h b/src/live_effects/lpe-bendpath.h
index 54c5d70fe..f232687ce 100644
--- a/src/live_effects/lpe-bendpath.h
+++ b/src/live_effects/lpe-bendpath.h
@@ -43,6 +43,8 @@ public:
virtual void resetDefaults(SPItem const* item);
+ virtual void transform_multiply(Geom::Affine const& postmul, bool set);
+
void addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec);
virtual void addKnotHolderEntities(KnotHolder * knotholder, SPItem * item);
diff --git a/src/live_effects/lpe-circle_3pts.cpp b/src/live_effects/lpe-circle_3pts.cpp
index 3410b13f2..c49d5ca4d 100644
--- a/src/live_effects/lpe-circle_3pts.cpp
+++ b/src/live_effects/lpe-circle_3pts.cpp
@@ -40,12 +40,18 @@ static void _circle3(Geom::Point const &A, Geom::Point const &B, Geom::Point con
Point v = (B - A).ccw();
Point w = (C - B).ccw();
+
double det = -v[0] * w[1] + v[1] * w[0];
- Point F = E - D;
- double lambda = 1/det * (-w[1] * F[0] + w[0] * F[1]);
+ Point M;
+ if (!v.isZero()) {
+ Point F = E - D;
+ double lambda = det == 0 ? 0 : (-w[1] * F[0] + w[0] * F[1]) / det;
+ M = D + v * lambda;
+ } else {
+ M = E;
+ }
- Point M = D + v * lambda;
double radius = L2(M - A);
Geom::Circle c(M, radius);
diff --git a/src/live_effects/lpe-clone-original.cpp b/src/live_effects/lpe-clone-original.cpp
index 31bf0e270..15968dd56 100644
--- a/src/live_effects/lpe-clone-original.cpp
+++ b/src/live_effects/lpe-clone-original.cpp
@@ -5,6 +5,10 @@
*/
#include "live_effects/lpe-clone-original.h"
+#include "live_effects/lpe-spiro.h"
+#include "live_effects/lpe-bspline.h"
+#include "live_effects/lpeobject.h"
+#include "live_effects/lpeobject-reference.h"
#include "display/curve.h"
#include "svg/path-string.h"
#include "svg/svg.h"
@@ -18,59 +22,50 @@
namespace Inkscape {
namespace LivePathEffect {
+static const Util::EnumData<Clonelpemethod> ClonelpemethodData[] = {
+ { CLM_NONE, N_("No shape"), "none" },
+ { CLM_ORIGINALD, N_("Without LPE's"), "originald" },
+ { CLM_BSPLINESPIRO, N_("With Spiro or BSpline"), "bsplinespiro" },
+ { CLM_D, N_("With LPE's"), "d" }
+};
+static const Util::EnumDataConverter<Clonelpemethod> CLMConverter(ClonelpemethodData, CLM_END);
+
LPECloneOriginal::LPECloneOriginal(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
linkeditem(_("Linked Item:"), _("Item from which to take the original data"), "linkeditem", &wr, this),
- scale(_("Scale %"), _("Scale item %"), "scale", &wr, this, 100.0),
- preserve_position(_("Preserve position"), _("Preserve position"), "preserve_position", &wr, this, false),
- inverse(_("Inverse clone"), _("Use LPE item as origin"), "inverse", &wr, this, false),
- d(_("Clone shape -d-"), _("Clone shape -d-"), "d", &wr, this, true),
- transform(_("Clone transforms"), _("Clone transforms"), "transform", &wr, this, true),
- fill(_("Clone fill"), _("Clone fill"), "fill", &wr, this, false),
- stroke(_("Clone stroke"), _("Clone stroke"), "stroke", &wr, this, false),
- paintorder(_("Clone paint order"), _("Clone paint order"), "paintorder", &wr, this, false),
- opacity(_("Clone opacity"), _("Clone opacity"), "opacity", &wr, this, false),
- filter(_("Clone filter"), _("Clone filter"), "filter", &wr, this, false),
+ method(_("Shape linked"), _("Shape linked"), "method", CLMConverter, &wr, this, CLM_D),
attributes("Attributes linked", "Attributes linked, comma separated atributes", "attributes", &wr, this,""),
- style_attributes("Style attributes linked", "Style attributes linked, comma separated atributes", "style_attributes", &wr, this,""),
- expanded(false),
- origin(Geom::Point(0,0))
+ style_attributes("Style attributes linked", "Style attributes linked, comma separated attributes like fill, filter, opacity", "style_attributes", &wr, this,""),
+ allow_transforms(_("Alow transforms"), _("Alow transforms"), "allow_transforms", &wr, this, true)
{
//0.92 compatibility
const gchar * linkedpath = this->getRepr()->attribute("linkedpath");
if (linkedpath && strcmp(linkedpath, "") != 0){
this->getRepr()->setAttribute("linkeditem", linkedpath);
this->getRepr()->setAttribute("linkedpath", NULL);
- this->getRepr()->setAttribute("transform", "false");
+ this->getRepr()->setAttribute("method", "bsplinespiro");
+ this->getRepr()->setAttribute("allow_transforms", "false");
};
-
+ is_updating = false;
+ listening = false;
+ linked = g_strdup(this->getRepr()->attribute("linkeditem"));
registerParameter(&linkeditem);
- registerParameter(&scale);
+ registerParameter(&method);
registerParameter(&attributes);
registerParameter(&style_attributes);
- registerParameter(&preserve_position);
- registerParameter(&inverse);
- registerParameter(&d);
- registerParameter(&transform);
- registerParameter(&fill);
- registerParameter(&stroke);
- registerParameter(&paintorder);
- registerParameter(&opacity);
- registerParameter(&filter);
- scale.param_set_range(0.01, 999999.0);
- scale.param_set_increments(1, 1);
- scale.param_set_digits(2);
+ registerParameter(&allow_transforms);
+ prev_allow_trans = allow_transforms;
+ previus_method = method;
+ prev_affine = g_strdup("");
attributes.param_hide_canvas_text();
style_attributes.param_hide_canvas_text();
- preserve_position_changed = preserve_position;
- preserve_affine = Geom::identity();
}
void
-LPECloneOriginal::cloneAttrbutes(SPObject *origin, SPObject *dest, bool live, const char * attributes, const char * style_attributes, bool root)
+LPECloneOriginal::cloneAttrbutes(SPObject *origin, SPObject *dest, const char * attributes, const char * style_attributes)
{
SPDocument * document = SP_ACTIVE_DOCUMENT;
- if (!document) {
+ if (!document || !origin || !dest) {
return;
}
if ( SP_IS_GROUP(origin) && SP_IS_GROUP(dest) && SP_GROUP(origin)->getItemCount() == SP_GROUP(dest)->getItemCount() ) {
@@ -79,7 +74,7 @@ LPECloneOriginal::cloneAttrbutes(SPObject *origin, SPObject *dest, bool live, co
for (std::vector<SPObject * >::iterator obj_it = childs.begin();
obj_it != childs.end(); ++obj_it) {
SPObject *dest_child = dest->nthChild(index);
- cloneAttrbutes((*obj_it), dest_child, live, attributes, style_attributes, false);
+ cloneAttrbutes((*obj_it), dest_child, attributes, style_attributes);
index++;
}
}
@@ -97,7 +92,7 @@ LPECloneOriginal::cloneAttrbutes(SPObject *origin, SPObject *dest, bool live, co
for ( std::vector<SPObject*>::const_iterator iter=mask_list.begin();iter!=mask_list.end();++iter) {
SPObject * mask_data = *iter;
SPObject * mask_dest_data = mask_list_dest[i];
- cloneAttrbutes(mask_data, mask_dest_data, live, attributes, style_attributes, false);
+ cloneAttrbutes(mask_data, mask_dest_data, attributes, style_attributes);
i++;
}
}
@@ -112,86 +107,60 @@ LPECloneOriginal::cloneAttrbutes(SPObject *origin, SPObject *dest, bool live, co
for ( std::vector<SPObject*>::const_iterator iter=clippath_list.begin();iter!=clippath_list.end();++iter) {
SPObject * clippath_data = *iter;
SPObject * clippath_dest_data = clippath_list_dest[i];
- cloneAttrbutes(clippath_data, clippath_dest_data, live, attributes, style_attributes, false);
+ cloneAttrbutes(clippath_data, clippath_dest_data, attributes, style_attributes);
i++;
}
}
}
gchar ** attarray = g_strsplit(attributes, ",", 0);
gchar ** iter = attarray;
- Geom::Affine affine_dest = Geom::identity();
- Geom::Affine affine_origin = Geom::identity();
- Geom::Affine affine_previous = Geom::identity();
- sp_svg_transform_read(SP_ITEM(dest)->getAttribute("transform"), &affine_dest);
- sp_svg_transform_read(SP_ITEM(origin)->getAttribute("transform"), &affine_origin);
while (*iter != NULL) {
const char* attribute = (*iter);
- if ( std::strcmp(attribute, "transform") == 0 ) {
- if (preserve_position) {
- Geom::Affine dest_affine = Geom::identity();
- if (root) {
- dest_affine *= affine_origin;
- if (preserve_affine == Geom::identity()) {
- dest_affine *= Geom::Translate(affine_dest.translation());
- }
- dest_affine *= Geom::Translate(affine_origin.translation()).inverse();
- dest_affine *= Geom::Translate(preserve_affine.translation());
- affine_previous = preserve_affine;
- preserve_affine = Geom::identity();
- gchar * str = sp_svg_transform_write(dest_affine);
- SP_ITEM(dest)->getRepr()->setAttribute("transform", str);
- g_free(str);
- }
- } else {
- gchar * str = sp_svg_transform_write(affine_origin);
- SP_ITEM(dest)->getRepr()->setAttribute("transform", str);
- g_free(str);
- }
- } else if ( shape_dest && shape_origin && live && (std::strcmp(attribute, "d") == 0)) {
- SPCurve *c = NULL;
- if (inverse) {
- c = shape_origin->getCurveBeforeLPE();
- } else {
- c = shape_origin->getCurve();
- }
- if (c) {
- Geom::PathVector c_pv = c->get_pathvector();
- Geom::OptRect orig_bbox = SP_ITEM(origin)->geometricBounds();
- Geom::OptRect dest_bbox = SP_ITEM(dest)->geometricBounds();
- if (dest_bbox && orig_bbox && root) {
- Geom::Point orig_point = (*orig_bbox).corner(0);
- Geom::Point dest_point = (*dest_bbox).corner(0);
- if (scale != 100.0) {
- double scale_affine = scale/100.0;
- Geom::Scale scale = Geom::Scale(scale_affine);
- c_pv *= Geom::Translate(orig_point).inverse();
- c_pv *= scale;
- c_pv *= Geom::Translate(orig_point);
- }
- if (preserve_position) {
- c_pv *= Geom::Translate(dest_point - orig_point);
+ if (strlen(attribute)) {
+ if ( shape_dest && shape_origin && (std::strcmp(attribute, "d") == 0)) {
+ SPCurve *c = NULL;
+ if (method == CLM_BSPLINESPIRO) {
+ c = shape_origin->getCurveBeforeLPE();
+ SPLPEItem * lpe_item = SP_LPE_ITEM(origin);
+ if (lpe_item) {
+ PathEffectList lpelist = lpe_item->getEffectList();
+ PathEffectList::iterator i;
+ for (i = lpelist.begin(); i != lpelist.end(); ++i) {
+ LivePathEffectObject *lpeobj = (*i)->lpeobject;
+ if (lpeobj) {
+ Inkscape::LivePathEffect::Effect *lpe = lpeobj->get_lpe();
+ if (dynamic_cast<Inkscape::LivePathEffect::LPEBSpline *>(lpe)) {
+ LivePathEffect::sp_bspline_do_effect(c, 0);
+ } else if (dynamic_cast<Inkscape::LivePathEffect::LPESpiro *>(lpe)) {
+ LivePathEffect::sp_spiro_do_effect(c);
+ }
+ }
+ }
}
- }
- if (inverse) {
- c_pv *= i2anc_affine(origin, sp_lpe_item);
+ } else if(method == CLM_ORIGINALD) {
+ c = shape_origin->getCurveBeforeLPE();
} else {
- c_pv *= i2anc_affine(dest, sp_lpe_item);
+ c = shape_origin->getCurve();
}
- c->set_pathvector(c_pv);
- if (!path_origin) {
- shape_dest->setCurveInsync(c, TRUE);
- gchar *str = sp_svg_write_path(c_pv);
- dest->getRepr()->setAttribute(attribute, str);
- g_free(str);
+ if (c) {
+ Geom::PathVector c_pv = c->get_pathvector();
+ c_pv *= i2anc_affine(dest, sp_lpe_item);
+ c->set_pathvector(c_pv);
+ if (!path_origin) {
+ shape_dest->setCurveInsync(c, TRUE);
+ gchar *str = sp_svg_write_path(c_pv);
+ dest->getRepr()->setAttribute(attribute, str);
+ g_free(str);
+ } else {
+ shape_dest->setCurve(c, TRUE);
+ }
+ c->unref();
} else {
- shape_dest->setCurve(c, TRUE);
+ dest->getRepr()->setAttribute(attribute, NULL);
}
- c->unref();
} else {
- dest->getRepr()->setAttribute(attribute, NULL);
+ dest->getRepr()->setAttribute(attribute, origin->getRepr()->attribute(attribute));
}
- } else {
- dest->getRepr()->setAttribute(attribute, origin->getRepr()->attribute(attribute));
}
iter++;
}
@@ -204,157 +173,142 @@ LPECloneOriginal::cloneAttrbutes(SPObject *origin, SPObject *dest, bool live, co
gchar ** styleiter = styleattarray;
while (*styleiter != NULL) {
const char* attribute = (*styleiter);
- const char* origin_attribute = sp_repr_css_property(css_origin, attribute, "");
- if (!strlen(origin_attribute)) { //==0
- sp_repr_css_set_property (css_dest, attribute, NULL);
- } else {
- sp_repr_css_set_property (css_dest, attribute, origin_attribute);
+ if (strlen(attribute)) {
+ const char* origin_attribute = sp_repr_css_property(css_origin, attribute, "");
+ if (!strlen(origin_attribute)) { //==0
+ sp_repr_css_set_property (css_dest, attribute, NULL);
+ } else {
+ sp_repr_css_set_property (css_dest, attribute, origin_attribute);
+ }
}
styleiter++;
}
g_strfreev (styleattarray);
Glib::ustring css_str;
sp_repr_css_write_string(css_dest,css_str);
- dest->getRepr()->setAttribute("style", css_str.c_str());
+ dest->getRepr()->setAttribute("style", g_strdup(css_str.c_str()));
}
-
void
LPECloneOriginal::doBeforeEffect (SPLPEItem const* lpeitem){
+ start_listening();
if (linkeditem.linksToItem()) {
- linkeditem.setInverse(inverse);
- if ( preserve_position_changed != preserve_position ) {
- if (!preserve_position) {
- sp_svg_transform_read(SP_ITEM(sp_lpe_item)->getAttribute("transform"), &preserve_affine);
- }
- preserve_position_changed = preserve_position;
- }
Glib::ustring attr = "";
- if (d) {
- attr.append("d,");
- }
- if (transform) {
- attr.append("transform,");
+ if (method != CLM_NONE) {
+ attr += Glib::ustring("d,");
}
- attr.append(Glib::ustring(attributes.param_getSVGValue()).append(","));
+ attr += Glib::ustring(attributes.param_getSVGValue()) + Glib::ustring(",");
if (attr.size() && !Glib::ustring(attributes.param_getSVGValue()).size()) {
attr.erase (attr.size()-1, 1);
}
Glib::ustring style_attr = "";
- if (fill) {
- style_attr.append("fill,").append("fill-rule,");
- }
- if (stroke) {
- style_attr.append("stroke,").append("stroke-width,").append("stroke-linecap,").append("stroke-linejoin,");
- style_attr.append("stroke-opacity,").append("stroke-miterlimit,").append("stroke-dasharray,");
- style_attr.append("stroke-opacity,").append("stroke-dashoffset,").append("marker-start,");
- style_attr.append("marker-mid,").append("marker-end,");
+ if (style_attr.size() && !Glib::ustring(style_attributes.param_getSVGValue()).size()) {
+ style_attr.erase (style_attr.size()-1, 1);
}
- if (paintorder) {
- style_attr.append("paint-order,");
+ style_attr += Glib::ustring(style_attributes.param_getSVGValue()) + Glib::ustring(",");
+
+ SPItem * orig = SP_ITEM(linkeditem.getObject());
+ SPItem * dest = SP_ITEM(sp_lpe_item);
+ Geom::OptRect o_bbox = orig->geometricBounds();
+ Geom::OptRect d_bbox = dest->geometricBounds();
+ gchar * id = g_strdup(orig->getId());
+ if (allow_transforms &&
+ !linkeditem.last_transform.isIdentity() &&
+ linkeditem.last_transform.isTranslation() &&
+ method != CLM_NONE)
+ {
+ Geom::Point expansion_dest = dest->transform.expansion();
+ Geom::Point expansion_orig = orig->transform.expansion();
+ dest->transform *= Geom::Scale(expansion_dest).inverse();
+ dest->transform *= Geom::Scale(expansion_orig);
+ dest->transform *= linkeditem.last_transform.inverse();
+ dest->transform *= Geom::Scale(expansion_orig).inverse();
+ dest->transform *= Geom::Scale(expansion_dest);
}
- if (filter) {
- style_attr.append("filter,");
+ if ((strcmp(id, linked) != 0 || (previus_method != method && previus_method == CLM_NONE )) &&
+ allow_transforms &&
+ o_bbox &&
+ d_bbox)
+ {
+ dest->transform *= Geom::Translate((*o_bbox).corner(0) - (*d_bbox).corner(0)).inverse();
}
- if (opacity) {
- style_attr.append("opacity,");
+ cloneAttrbutes(orig, dest, g_strdup(attr.c_str()), g_strdup(style_attr.c_str()));
+ if (allow_transforms &&
+ previus_method != method &&
+ method == CLM_NONE)
+ {
+ dest->transform *= Geom::Translate((*d_bbox).corner(0) - (*o_bbox).corner(0)).inverse();
}
- if (style_attr.size() && !Glib::ustring(style_attributes.param_getSVGValue()).size()) {
- style_attr.erase (style_attr.size()-1, 1);
- }
- style_attr.append(Glib::ustring(style_attributes.param_getSVGValue()).append(","));
- SPItem * from = inverse ? SP_ITEM(sp_lpe_item) : SP_ITEM(linkeditem.getObject());
- SPItem * to = !inverse ? SP_ITEM(sp_lpe_item) : SP_ITEM(linkeditem.getObject());
- cloneAttrbutes(from, to, true, g_strdup(attr.c_str()), g_strdup(style_attr.c_str()), true);
- Geom::OptRect bbox = from->geometricBounds();
- if (bbox && preserve_position && origin != Geom::Point(0,0)) {
- origin = (*bbox).corner(0) - origin;
- to->transform *= Geom::Translate(origin);
+ if (!allow_transforms) {
+ SP_ITEM(dest)->getRepr()->setAttribute("transform", SP_ITEM(orig)->getAttribute("transform"));
+ } else {
+ SP_ITEM(dest)->getRepr()->setAttribute("transform", sp_svg_transform_write(dest->transform));
+ if (prev_allow_trans == allow_transforms) {
+ prev_affine = g_strdup(SP_ITEM(dest)->getAttribute("transform"));
+ }
}
- bbox = from->geometricBounds();
- if (bbox && preserve_position) {
- origin = (*bbox).corner(0);
+
+ if (prev_allow_trans != allow_transforms && allow_transforms) {
+ SP_ITEM(dest)->getRepr()->setAttribute("transform", prev_affine);
}
+
+ linked = g_strdup(id);
+ g_free(id);
+ } else {
+ linked = g_strdup("");
}
+ previus_method = method;
+ prev_allow_trans = allow_transforms;
}
-
-Gtk::Widget *
-LPECloneOriginal::newWidget()
+void
+LPECloneOriginal::start_listening()
{
- // use manage here, because after deletion of Effect object, others might
- // still be pointing to this widget.
- Gtk::VBox *vbox = Gtk::manage(new Gtk::VBox(Effect::newWidget()));
- vbox->set_border_width(5);
- vbox->set_homogeneous(false);
- vbox->set_spacing(2);
- Gtk::VBox * vbox_expander = Gtk::manage( new Gtk::VBox(Effect::newWidget()) );
- vbox_expander->set_border_width(0);
- vbox_expander->set_spacing(2);
- std::vector<Parameter *>::iterator it = param_vector.begin();
- while (it != param_vector.end()) {
- if ((*it)->widget_is_visible) {
- Parameter * param = *it;
- if (param->param_key == "linkedpath") {
- ++it;
- continue;
- }
- Gtk::Widget * widg = param->param_newWidget();
- Glib::ustring * tip = param->param_getTooltip();
- if (widg) {
- if (param->param_key != "attributes" &&
- param->param_key != "style_attributes") {
- vbox->pack_start(*widg, true, true, 2);
- } else {
- vbox_expander->pack_start(*widg, true, true, 2);
- }
- if (tip) {
- widg->set_tooltip_text(*tip);
- } else {
- widg->set_tooltip_text("");
- widg->set_has_tooltip(false);
- }
- }
- }
-
- ++it;
+ if ( !sp_lpe_item || listening ) {
+ return;
}
- expander = Gtk::manage(new Gtk::Expander(Glib::ustring(_("Show attributes override"))));
- expander->add(*vbox_expander);
- expander->set_expanded(expanded);
- expander->property_expanded().signal_changed().connect(sigc::mem_fun(*this, &LPECloneOriginal::onExpanderChanged) );
- vbox->pack_start(*expander, true, true, 2);
- return dynamic_cast<Gtk::Widget *>(vbox);
+ quit_listening();
+ modified_connection = SP_OBJECT(sp_lpe_item)->connectModified(sigc::mem_fun(*this, &LPECloneOriginal::modified));
+ listening = true;
}
void
-LPECloneOriginal::onExpanderChanged()
+LPECloneOriginal::quit_listening(void)
{
- expanded = expander->get_expanded();
- if(expanded) {
- expander->set_label (Glib::ustring(_("Hide attributes override")));
- } else {
- expander->set_label (Glib::ustring(_("Show attributes override")));
+ modified_connection.disconnect();
+ listening = false;
+}
+
+void
+LPECloneOriginal::modified(SPObject */*obj*/, guint /*flags*/)
+{
+ if ( !sp_lpe_item || is_updating) {
+ is_updating = false;
+ return;
}
+ SP_OBJECT(this->getLPEObj())->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ is_updating = true;
}
LPECloneOriginal::~LPECloneOriginal()
{
-
+ quit_listening();
+ g_free(linked);
+ g_free(prev_affine);
}
void
LPECloneOriginal::transform_multiply(Geom::Affine const& postmul, bool set)
{
- if (linkeditem.linksToItem()) {
- linkeditem.getObject()->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ if (!allow_transforms && linkeditem.linksToItem()) {
+ sp_lpe_item->transform *= postmul.inverse();
}
}
void
LPECloneOriginal::doEffect (SPCurve * curve)
{
- if (linkeditem.linksToItem() && !inverse) {
+ if (linkeditem.linksToItem()) {
SPShape * shape = getCurrentShape();
if(shape){
curve->set_pathvector(shape->getCurve()->get_pathvector());
diff --git a/src/live_effects/lpe-clone-original.h b/src/live_effects/lpe-clone-original.h
index 9bab8553f..8327b6767 100644
--- a/src/live_effects/lpe-clone-original.h
+++ b/src/live_effects/lpe-clone-original.h
@@ -8,18 +8,25 @@
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include <gtkmm/expander.h>
#include "live_effects/effect.h"
+#include "live_effects/parameter/enum.h"
#include "live_effects/parameter/originalitem.h"
-#include "live_effects/parameter/originalpath.h"
-#include "live_effects/parameter/parameter.h"
-#include "live_effects/parameter/point.h"
#include "live_effects/parameter/text.h"
#include "live_effects/lpegroupbbox.h"
+#include <sigc++/sigc++.h>
+
namespace Inkscape {
namespace LivePathEffect {
+enum Clonelpemethod {
+ CLM_NONE,
+ CLM_ORIGINALD,
+ CLM_BSPLINESPIRO,
+ CLM_D,
+ CLM_END
+};
+
class LPECloneOriginal : public Effect, GroupBBoxEffect {
public:
LPECloneOriginal(LivePathEffectObject *lpeobject);
@@ -27,29 +34,24 @@ public:
virtual void doEffect (SPCurve * curve);
virtual void doBeforeEffect (SPLPEItem const* lpeitem);
virtual void transform_multiply(Geom::Affine const& postmul, bool set);
- virtual Gtk::Widget * newWidget();
- void onExpanderChanged();
- void cloneAttrbutes(SPObject *origin, SPObject *dest, bool live, const char * attributes, const char * style_attributes, bool root);
+ void cloneAttrbutes(SPObject *origin, SPObject *dest, const char * attributes, const char * style_attributes);
+ void modified(SPObject */*obj*/, guint /*flags*/);
+ void start_listening();
+ void quit_listening();
private:
- OriginalItemParam linkeditem;
- ScalarParam scale;
- BoolParam preserve_position;
- BoolParam inverse;
- BoolParam d;
- BoolParam transform;
- BoolParam fill;
- BoolParam stroke;
- BoolParam paintorder;
- BoolParam opacity;
- BoolParam filter;
+ OriginalItemParam linkeditem;
+ EnumParam<Clonelpemethod> method;
TextParam attributes;
TextParam style_attributes;
- Geom::Point origin;
- bool preserve_position_changed;
- bool expanded;
- Gtk::Expander * expander;
- Geom::Affine preserve_affine;
+ BoolParam allow_transforms;
+ gchar * linked;
+ Clonelpemethod previus_method;
+ bool listening;
+ bool is_updating;
+ bool prev_allow_trans;
+ gchar * prev_affine;
+ sigc::connection modified_connection;
LPECloneOriginal(const LPECloneOriginal&);
LPECloneOriginal& operator=(const LPECloneOriginal&);
};
diff --git a/src/live_effects/lpe-fill-between-many.cpp b/src/live_effects/lpe-fill-between-many.cpp
index 40fa91c68..7e2131f76 100644
--- a/src/live_effects/lpe-fill-between-many.cpp
+++ b/src/live_effects/lpe-fill-between-many.cpp
@@ -6,10 +6,14 @@
#include "live_effects/lpe-fill-between-many.h"
-
+#include "live_effects/lpeobject.h"
+#include "xml/node.h"
#include "display/curve.h"
+#include "inkscape.h"
+#include "selection.h"
#include "sp-shape.h"
#include "sp-text.h"
+#include "sp-defs.h"
#include "svg/svg.h"
// TODO due to internal breakage in glibmm headers, this must be last:
#include <glibmm/i18n.h>
@@ -17,20 +21,31 @@
namespace Inkscape {
namespace LivePathEffect {
+static const Util::EnumData<Filllpemethod> FilllpemethodData[] = {
+ { FLM_ORIGINALD, N_("Without LPE's"), "originald" },
+ { FLM_BSPLINESPIRO, N_("With Spiro or BSpline"), "bsplinespiro" },
+ { FLM_D, N_("With LPE's"), "d" }
+};
+static const Util::EnumDataConverter<Filllpemethod> FLMConverter(FilllpemethodData, FLM_END);
+
LPEFillBetweenMany::LPEFillBetweenMany(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
linked_paths(_("Linked path:"), _("Paths from which to take the original path data"), "linkedpaths", &wr, this),
+ method(_("LPE's on linked:"), _("LPE's on linked"), "method", FLMConverter, &wr, this, FLM_BSPLINESPIRO),
fuse(_("Fuse coincident points"), _("Fuse coincident points"), "fuse", &wr, this, false),
allow_transforms(_("Allow transforms"), _("Allow transforms"), "allow_transforms", &wr, this, false),
join(_("Join subpaths"), _("Join subpaths"), "join", &wr, this, true),
- close(_("Close"), _("Close path"), "close", &wr, this, true)
+ close(_("Close"), _("Close path"), "close", &wr, this, true),
+ applied("Store the first apply", "", "applied", &wr, this, "false", false)
{
registerParameter(&linked_paths);
+ registerParameter(&method);
registerParameter(&fuse);
registerParameter(&allow_transforms);
registerParameter(&join);
registerParameter(&close);
- transformmultiply = false;
+ registerParameter(&applied);
+ previous_method = FLM_END;
}
LPEFillBetweenMany::~LPEFillBetweenMany()
@@ -38,13 +53,73 @@ LPEFillBetweenMany::~LPEFillBetweenMany()
}
+void LPEFillBetweenMany::doOnApply (SPLPEItem const* lpeitem)
+{
+ SPDocument * document = SP_ACTIVE_DOCUMENT;
+ if (!document) {
+ return;
+ }
+ SPLPEItem *lpe_item = const_cast<SPLPEItem *>(lpeitem);
+ SPObject * parent = lpe_item->parent;
+ if (lpe_item) {
+ SPShape *shape = dynamic_cast<SPShape *>(lpe_item);
+ if (shape) {
+ Inkscape::SVGOStringStream os;
+ if (strcmp(this->lpeobj->getRepr()->attribute("applied"), "false") == 0) {
+ os << '#' << SP_ITEM(lpe_item)->getId() << ",0,1";
+
+ Inkscape::XML::Document *xml_doc = document->getReprDoc();
+ // create the LPE
+ Inkscape::XML::Node *lpe_repr = xml_doc->createElement("inkscape:path-effect");
+ {
+ lpe_repr->setAttribute("effect", "fill_between_many");
+ lpe_repr->setAttribute("linkedpaths", os.str());
+ lpe_repr->setAttribute("applied", "true");
+ lpe_repr->setAttribute("method", "partial");
+ lpe_repr->setAttribute("allow_transforms", "false");
+ document->getDefs()->getRepr()->addChild(lpe_repr, NULL); // adds to <defs> and assigns the 'id' attribute
+ }
+ std::string lpe_id_href = std::string("#") + lpe_repr->attribute("id");
+ Inkscape::GC::release(lpe_repr);
+ Inkscape::XML::Node *clone = xml_doc->createElement("svg:path");
+ {
+ clone->setAttribute("d", "M 0 0", false);
+ // add the new clone to the top of the original's parent
+ parent->appendChildRepr(clone);
+ SPObject *clone_obj = document->getObjectById(clone->attribute("id"));
+ SPLPEItem *clone_lpeitem = dynamic_cast<SPLPEItem *>(clone_obj);
+ if (clone_lpeitem) {
+ clone_lpeitem->addPathEffect(lpe_id_href, false);
+ }
+ }
+ Inkscape::Selection * sel = SP_ACTIVE_DESKTOP->getSelection();
+ sel->set(clone);
+ Inkscape::GC::release(clone);
+ lpe_item->removeCurrentPathEffect(false);
+ }
+ }
+ }
+}
+
void LPEFillBetweenMany::doEffect (SPCurve * curve)
{
+ if (previous_method != method) {
+ if (method == FLM_BSPLINESPIRO) {
+ linked_paths.allowOnlyBsplineSpiro(true);
+ linked_paths.setFromOriginalD(false);
+ } else if(method == FLM_ORIGINALD) {
+ linked_paths.allowOnlyBsplineSpiro(false);
+ linked_paths.setFromOriginalD(true);
+ } else {
+ linked_paths.allowOnlyBsplineSpiro(false);
+ linked_paths.setFromOriginalD(false);
+ }
+ previous_method = method;
+ }
Geom::PathVector res_pathv;
- SPItem * firstObj = NULL;
- for (std::vector<PathAndDirection*>::iterator iter = linked_paths._vector.begin(); iter != linked_paths._vector.end(); ++iter) {
+ for (std::vector<PathAndDirectionAndVisible*>::iterator iter = linked_paths._vector.begin(); iter != linked_paths._vector.end(); ++iter) {
SPObject *obj;
- if ((*iter)->ref.isAttached() && (obj = (*iter)->ref.getObject()) && SP_IS_ITEM(obj) && !(*iter)->_pathvector.empty()) {
+ if ((*iter)->ref.isAttached() && (obj = (*iter)->ref.getObject()) && SP_IS_ITEM(obj) && !(*iter)->_pathvector.empty() && (*iter)->visibled) {
Geom::Path linked_path;
if ((*iter)->reversed) {
linked_path = (*iter)->_pathvector.front().reversed();
@@ -53,36 +128,43 @@ void LPEFillBetweenMany::doEffect (SPCurve * curve)
}
if (!res_pathv.empty() && join) {
- linked_path = linked_path * SP_ITEM(obj)->getRelativeTransform(firstObj);
if (!are_near(res_pathv.front().finalPoint(), linked_path.initialPoint(), 0.01) || !fuse) {
res_pathv.front().appendNew<Geom::LineSegment>(linked_path.initialPoint());
} else {
linked_path.setInitial(res_pathv.front().finalPoint());
}
+ if(!allow_transforms) {
+ Geom::Affine affine = Geom::identity();
+ sp_svg_transform_read(SP_ITEM(obj)->getAttribute("transform"), &affine);
+ linked_path *= affine;
+ }
res_pathv.front().append(linked_path);
} else {
- firstObj = SP_ITEM(obj);
if (close && !join) {
linked_path.close();
}
+ if(!allow_transforms) {
+ Geom::Affine affine = Geom::identity();
+ sp_svg_transform_read(SP_ITEM(obj)->getAttribute("transform"), &affine);
+ linked_path *= affine;
+ }
res_pathv.push_back(linked_path);
}
}
}
+
+ if(!allow_transforms && sp_lpe_item) {
+ SP_ITEM(sp_lpe_item)->transform = Geom::identity();
+ }
+
if (!res_pathv.empty() && close) {
res_pathv.front().close();
}
+
if (res_pathv.empty()) {
res_pathv = curve->get_pathvector();
}
- if(!allow_transforms && !transformmultiply) {
- Geom::Affine affine = Geom::identity();
- sp_svg_transform_read(SP_ITEM(sp_lpe_item)->getAttribute("transform"), &affine);
- res_pathv *= affine.inverse();
- }
- if(transformmultiply) {
- transformmultiply = false;
- }
+
curve->set_pathvector(res_pathv);
}
@@ -91,8 +173,6 @@ LPEFillBetweenMany::transform_multiply(Geom::Affine const& postmul, bool set)
{
if(!allow_transforms && sp_lpe_item) {
SP_ITEM(sp_lpe_item)->transform *= postmul.inverse();
- transformmultiply = true;
- sp_lpe_item_update_patheffect(sp_lpe_item, false, false);
}
}
diff --git a/src/live_effects/lpe-fill-between-many.h b/src/live_effects/lpe-fill-between-many.h
index fe824e936..7ff998309 100644
--- a/src/live_effects/lpe-fill-between-many.h
+++ b/src/live_effects/lpe-fill-between-many.h
@@ -10,25 +10,37 @@
*/
#include "live_effects/effect.h"
+#include "live_effects/parameter/enum.h"
#include "live_effects/parameter/originalpatharray.h"
+#include "live_effects/parameter/hidden.h"
namespace Inkscape {
namespace LivePathEffect {
+enum Filllpemethod {
+ FLM_ORIGINALD,
+ FLM_BSPLINESPIRO,
+ FLM_D,
+ FLM_END
+};
+
class LPEFillBetweenMany : public Effect {
public:
LPEFillBetweenMany(LivePathEffectObject *lpeobject);
virtual ~LPEFillBetweenMany();
+ virtual void doOnApply (SPLPEItem const* lpeitem);
virtual void transform_multiply(Geom::Affine const& postmul, bool set);
virtual void doEffect (SPCurve * curve);
private:
OriginalPathArrayParam linked_paths;
+ EnumParam<Filllpemethod> method;
BoolParam fuse;
BoolParam allow_transforms;
BoolParam join;
BoolParam close;
- bool transformmultiply;
+ HiddenParam applied;
+ Filllpemethod previous_method;
private:
LPEFillBetweenMany(const LPEFillBetweenMany&);
LPEFillBetweenMany& operator=(const LPEFillBetweenMany&);
diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp
index be5979f31..2b052ace1 100644
--- a/src/live_effects/lpe-fillet-chamfer.cpp
+++ b/src/live_effects/lpe-fillet-chamfer.cpp
@@ -98,14 +98,12 @@ void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem)
Geom::PathVector const pathv = pathv_to_linear_and_cubic_beziers(shape->getCurve()->get_pathvector());
Satellites satellites;
double power = radius;
- std::cout << power << "power\n";
if (!flexible) {
SPDocument * document = SP_ACTIVE_DOCUMENT;
SPNamedView *nv = sp_document_namedview(document, NULL);
Glib::ustring display_unit = nv->display_units->abbr;
power = Inkscape::Util::Quantity::convert(power, unit.get_abbreviation(), display_unit.c_str());
}
- std::cout << power << "power22222222\n";
SatelliteType satellite_type = FILLET;
std::map<std::string, SatelliteType> gchar_map_to_satellite_type =
boost::assign::map_list_of("F", FILLET)("IF", INVERSE_FILLET)("C", CHAMFER)("IC", INVERSE_CHAMFER)("KO", INVALID_SATELLITE);
diff --git a/src/live_effects/lpe-interpolate_points.cpp b/src/live_effects/lpe-interpolate_points.cpp
index 0a0bcea14..7d4c88dc1 100644
--- a/src/live_effects/lpe-interpolate_points.cpp
+++ b/src/live_effects/lpe-interpolate_points.cpp
@@ -51,11 +51,7 @@ Geom::PathVector
LPEInterpolatePoints::doEffect_path (Geom::PathVector const & path_in)
{
Geom::PathVector path_out;
-#if __cplusplus <= 199711L
- std::auto_ptr<Geom::Interpolate::Interpolator> interpolator( Geom::Interpolate::Interpolator::create(static_cast<Geom::Interpolate::InterpolatorType>(interpolator_type.get_value())) );
-#else
std::unique_ptr<Geom::Interpolate::Interpolator> interpolator( Geom::Interpolate::Interpolator::create(static_cast<Geom::Interpolate::InterpolatorType>(interpolator_type.get_value())) );
-#endif
for(Geom::PathVector::const_iterator path_it = path_in.begin(); path_it != path_in.end(); ++path_it) {
if (path_it->empty())
diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp
index 261612fdb..22c548c1d 100644
--- a/src/live_effects/lpe-knot.cpp
+++ b/src/live_effects/lpe-knot.cpp
@@ -199,7 +199,7 @@ CrossingPoints::CrossingPoints(Geom::PathVector const &paths) : std::vector<Cros
cp.tj = times[k].second + jj;
push_back(cp);
}else{
- std::cout<<"ooops: find_(self)_intersections returned NaN:";
+ std::cout<<"ooops: find_(self)_intersections returned NaN:" << std::endl;
//std::cout<<"intersection "<<i<<"["<<ii<<"](NaN)= "<<j<<"["<<jj<<"](NaN)\n";
}
}
diff --git a/src/live_effects/lpe-measure-segments.cpp b/src/live_effects/lpe-measure-segments.cpp
index 2ac40b580..5ed587922 100644
--- a/src/live_effects/lpe-measure-segments.cpp
+++ b/src/live_effects/lpe-measure-segments.cpp
@@ -9,6 +9,7 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include "live_effects/lpe-measure-segments.h"
+#include "live_effects/lpeobject.h"
#include <pangomm/fontdescription.h>
#include "ui/dialog/livepatheffect-editor.h"
#include <libnrtype/font-lister.h>
@@ -30,7 +31,10 @@
#include "sp-item.h"
#include "sp-shape.h"
#include "sp-path.h"
+#include "sp-star.h"
+#include "sp-spiral.h"
#include "document.h"
+#include "document-undo.h"
#include <iomanip>
#include <cmath>
@@ -50,17 +54,19 @@ static const Util::EnumDataConverter<OrientationMethod> OMConverter(OrientationM
LPEMeasureSegments::LPEMeasureSegments(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
- unit(_("Unit"), _("Unit"), "unit", &wr, this, "px"),
- fontbutton(_("Font"), _("Font Selector"), "fontbutton", &wr, this),
+ unit(_("Unit"), _("Unit"), "unit", &wr, this, "mm"),
orientation(_("Orientation"), _("Orientation method"), "orientation", OMConverter, &wr, this, OM_PARALLEL, false),
+ coloropacity(_("Color and opacity"), _("Set color and opacity of the measurements"), "coloropacity", &wr, this, 0x000000ff),
+ fontbutton(_("Font"), _("Font Selector"), "fontbutton", &wr, this),
precision(_("Precision"), _("Precision"), "precision", &wr, this, 2),
fix_overlaps(_("Fix overlaps °"), _("Min angle where overlaps are fixed, 180° no fix"), "fix_overlaps", &wr, this, 0),
position(_("Position"), _("Position"), "position", &wr, this, 5),
text_top_bottom(_("Text top/bottom"), _("Text top/bottom"), "text_top_bottom", &wr, this, 0),
- text_right_left(_("Text right/left"), _("Text right/left"), "text_right_left", &wr, this, 0),
helpline_distance(_("Helpline distance"), _("Helpline distance"), "helpline_distance", &wr, this, 0.0),
helpline_overlap(_("Helpline overlap"), _("Helpline overlap"), "helpline_overlap", &wr, this, 2.0),
+ line_width(_("Line width"), _("Line width. DIM line group standard are 0.25 or 0.35"), "line_width", &wr, this, 0.25),
scale(_("Scale"), _("Scaling factor"), "scale", &wr, this, 1.0),
+
format(_("Format"), _("Format the number ex:{measure} {unit}, return to save"), "format", &wr, this,"{measure}{unit}"),
blacklist(_("Blacklist"), _("Optional segment index that exclude measure, comma limited, you can add more LPE like this to fill the holes"), "blacklist", &wr, this,""),
whitelist(_("Inverse blacklist"), _("Blacklist as whitelist"), "whitelist", &wr, this, false),
@@ -68,26 +74,22 @@ LPEMeasureSegments::LPEMeasureSegments(LivePathEffectObject *lpeobject) :
flip_side(_("Flip side"), _("Flip side"), "flip_side", &wr, this, false),
scale_sensitive(_("Scale sensitive"), _("Costrained scale sensitive to transformed containers"), "scale_sensitive", &wr, this, true),
local_locale(_("Local Number Format"), _("Local number format"), "local_locale", &wr, this, true),
- line_group_05(_("Line Group 0.5"), _("Line Group 0.5, from 0.7"), "line_group_05", &wr, this, true),
rotate_anotation(_("Rotate Anotation"), _("Rotate Anotation"), "rotate_anotation", &wr, this, true),
hide_back(_("Hide if label over"), _("Hide DIN line if label over"), "hide_back", &wr, this, true),
- dimline_format(_("CSS DIN line"), _("Override CSS to DIN line, return to save, empty to reset to DIM"), "dimline_format", &wr, this,""),
- helperlines_format(_("CSS helpers"), _("Override CSS to helper lines, return to save, empty to reset to DIM"), "helperlines_format", &wr, this,""),
- anotation_format(_("CSS anotation"), _("Override CSS to anotation text, return to save, empty to reset to DIM"), "anotation_format", &wr, this,""),
- arrows_format(_("CSS arrows"), _("Override CSS to arrows, return to save, empty to reset DIM"), "arrows_format", &wr, this,""),
- expanded(false)
+ message(_("Info Box"), _("Important messages"), "message", &wr, this, _("Use <b>\"Style Dialog\"</b> to more styling. Each meassure element has extra selectors. Use !important to override defaults..."))
{
//set to true the parameters you want to be changed his default values
registerParameter(&unit);
- registerParameter(&fontbutton);
registerParameter(&orientation);
+ registerParameter(&coloropacity);
+ registerParameter(&fontbutton);
registerParameter(&precision);
registerParameter(&fix_overlaps);
registerParameter(&position);
registerParameter(&text_top_bottom);
- registerParameter(&text_right_left);
registerParameter(&helpline_distance);
registerParameter(&helpline_overlap);
+ registerParameter(&line_width);
registerParameter(&scale);
registerParameter(&format);
registerParameter(&blacklist);
@@ -96,13 +98,9 @@ LPEMeasureSegments::LPEMeasureSegments(LivePathEffectObject *lpeobject) :
registerParameter(&flip_side);
registerParameter(&scale_sensitive);
registerParameter(&local_locale);
- registerParameter(&line_group_05);
registerParameter(&rotate_anotation);
registerParameter(&hide_back);
- registerParameter(&dimline_format);
- registerParameter(&helperlines_format);
- registerParameter(&anotation_format);
- registerParameter(&arrows_format);
+ registerParameter(&message);
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -114,10 +112,6 @@ LPEMeasureSegments::LPEMeasureSegments(LivePathEffectObject *lpeobject) :
format.param_hide_canvas_text();
blacklist.param_hide_canvas_text();
- dimline_format.param_hide_canvas_text();
- helperlines_format.param_hide_canvas_text();
- anotation_format.param_hide_canvas_text();
- arrows_format.param_hide_canvas_text();
precision.param_set_range(0, 100);
precision.param_set_increments(1, 1);
precision.param_set_digits(0);
@@ -135,15 +129,16 @@ LPEMeasureSegments::LPEMeasureSegments(LivePathEffectObject *lpeobject) :
text_top_bottom.param_set_range(-999999.0, 999999.0);
text_top_bottom.param_set_increments(1, 1);
text_top_bottom.param_set_digits(2);
- text_right_left.param_set_range(-999999.0, 999999.0);
- text_right_left.param_set_increments(1, 1);
- text_right_left.param_set_digits(2);
+ line_width.param_set_range(-999999.0, 999999.0);
+ line_width.param_set_increments(1, 1);
+ line_width.param_set_digits(2);
helpline_distance.param_set_range(-999999.0, 999999.0);
helpline_distance.param_set_increments(1, 1);
helpline_distance.param_set_digits(2);
helpline_overlap.param_set_range(-999999.0, 999999.0);
helpline_overlap.param_set_increments(1, 1);
helpline_overlap.param_set_digits(2);
+ star_ellipse_fix = Geom::identity();
}
LPEMeasureSegments::~LPEMeasureSegments() {}
@@ -155,6 +150,14 @@ LPEMeasureSegments::createArrowMarker(const char * mode)
if (!document) {
return;
}
+ Glib::ustring style;
+ gchar c[32];
+ unsigned const rgb24 = coloropacity.get_value() >> 8;
+ sprintf(c, "#%06x", rgb24);
+ style = Glib::ustring("fill:") + Glib::ustring(c);
+ Inkscape::SVGOStringStream os;
+ os << SP_RGBA32_A_F(coloropacity.get_value());
+ style = style + Glib::ustring(";fill-opacity:") + Glib::ustring(os.str());
Inkscape::XML::Document *xml_doc = document->getReprDoc();
SPObject *elemref = NULL;
Inkscape::XML::Node *arrow = NULL;
@@ -165,24 +168,19 @@ LPEMeasureSegments::createArrowMarker(const char * mode)
arrow->setAttribute("transform", NULL);
Inkscape::XML::Node *arrow_data = arrow->firstChild();
if (arrow_data) {
- SPCSSAttr *css = sp_repr_css_attr_new();
- sp_repr_css_set_property (css, "fill","#000000");
- sp_repr_css_set_property (css, "stroke","none");
arrow_data->setAttribute("transform", NULL);
- sp_repr_css_attr_add_from_string(css, arrows_format.param_getSVGValue());
- Glib::ustring css_str;
- sp_repr_css_write_string(css,css_str);
- arrow_data->setAttribute("style", css_str.c_str());
+ arrow_data->setAttribute("style", style.c_str());
}
}
} else {
arrow = xml_doc->createElement("svg:marker");
arrow->setAttribute("id", mode);
+ arrow->setAttribute("class", (Glib::ustring(sp_lpe_item->getId()) + Glib::ustring(" ") + Glib::ustring(this->lpeobj->getId()) + Glib::ustring(" measure-arrows-marker")).c_str());
arrow->setAttribute("inkscape:stockid", mode);
arrow->setAttribute("orient", "auto");
arrow->setAttribute("refX", "0.0");
arrow->setAttribute("refY", "0.0");
- arrow->setAttribute("style", "overflow:visible");
+
arrow->setAttribute("sodipodi:insensitive", "true");
/* Create <path> */
Inkscape::XML::Node *arrow_path = xml_doc->createElement("svg:path");
@@ -193,17 +191,11 @@ LPEMeasureSegments::createArrowMarker(const char * mode)
} else if (std::strcmp(mode, "ArrowDINout-start") == 0) {
arrow_path->setAttribute("d", "M 0,0 -16,2.11 -16,0.5 -26,0.5 -26,-0.5 -16,-0.5 -16,-2.11 z");
} else {
- arrow_path->setAttribute("d", "M 0,0 16,2.11 16,0.5 26,0.5 26,-0.5 16,-0.5 16,-2.11 z");
+ arrow_path->setAttribute("d", "M 0,0 16,-2.11 16,-0.5 26,-0.5 26,0.5 16,0.5 16,2.11 z");
}
-
+ arrow_path->setAttribute("class", (Glib::ustring(sp_lpe_item->getId()) + Glib::ustring(" ") + Glib::ustring(this->lpeobj->getId()) + Glib::ustring(" measure-arrows")).c_str());
arrow_path->setAttribute("id", Glib::ustring(mode).append("_path").c_str());
- SPCSSAttr *css = sp_repr_css_attr_new();
- sp_repr_css_set_property (css, "fill","#000000");
- sp_repr_css_set_property (css, "stroke","none");
- sp_repr_css_attr_add_from_string(css, arrows_format.param_getSVGValue());
- Glib::ustring css_str;
- sp_repr_css_write_string(css,css_str);
- arrow_path->setAttribute("style", css_str.c_str());
+ arrow_path->setAttribute("style", style.c_str());
arrow->addChild(arrow_path, NULL);
Inkscape::GC::release(arrow_path);
elemref = SP_OBJECT(document->getDefs()->appendChildRepr(arrow));
@@ -243,7 +235,6 @@ LPEMeasureSegments::createTextLabel(Geom::Point pos, size_t counter, double leng
elemref->deleteObject();
return;
}
- pos = pos - Point::polar(angle, text_right_left);
rtext = elemref->getRepr();
sp_repr_set_svg_double(rtext, "x", pos[Geom::X]);
sp_repr_set_svg_double(rtext, "y", pos[Geom::Y]);
@@ -256,8 +247,8 @@ LPEMeasureSegments::createTextLabel(Geom::Point pos, size_t counter, double leng
rtext = xml_doc->createElement("svg:text");
rtext->setAttribute("xml:space", "preserve");
rtext->setAttribute("id", id);
+ rtext->setAttribute("class", (Glib::ustring(sp_lpe_item->getId()) + Glib::ustring(" ") + Glib::ustring(this->lpeobj->getId()) + Glib::ustring(" measure-labels")).c_str());
rtext->setAttribute("sodipodi:insensitive", "true");
- pos = pos - Point::polar(angle, text_right_left);
sp_repr_set_svg_double(rtext, "x", pos[Geom::X]);
sp_repr_set_svg_double(rtext, "y", pos[Geom::Y]);
rtspan = xml_doc->createElement("svg:tspan");
@@ -281,27 +272,25 @@ LPEMeasureSegments::createTextLabel(Geom::Point pos, size_t counter, double leng
rtext->setAttribute("transform", transform);
g_free(transform);
SPCSSAttr *css = sp_repr_css_attr_new();
- sp_repr_css_attr_add_from_string(css, anotation_format.param_getSVGValue());
Inkscape::FontLister *fontlister = Inkscape::FontLister::get_instance();
fontlister->fill_css(css, Glib::ustring(fontbutton.param_getSVGValue()));
std::stringstream font_size;
font_size.imbue(std::locale::classic());
font_size << fontsize << "pt";
- sp_repr_css_set_property (css, "font-size",font_size.str().c_str());
- sp_repr_css_set_property (css, "line-height","125%");
- sp_repr_css_set_property (css, "letter-spacing","0");
- sp_repr_css_set_property (css, "word-spacing", "0");
- sp_repr_css_set_property (css, "text-align", "center");
- sp_repr_css_set_property (css, "text-anchor", "middle");
- sp_repr_css_set_property (css, "fill", "#000000");
- sp_repr_css_set_property (css, "fill-opacity", "1");
- sp_repr_css_set_property (css, "stroke", "none");
- sp_repr_css_attr_add_from_string(css, anotation_format.param_getSVGValue());
- Glib::ustring css_str;
- sp_repr_css_write_string(css,css_str);
+
+ gchar c[32];
+ unsigned const rgb24 = coloropacity.get_value() >> 8;
+ sprintf(c, "#%06x", rgb24);
+ sp_repr_css_set_property (css, "fill",c);
+ Inkscape::SVGOStringStream os;
+ os << SP_RGBA32_A_F(coloropacity.get_value());
+ sp_repr_css_set_property (css, "fill-opacity",os.str().c_str());
if (!rtspan) {
rtspan = rtext->firstChild();
}
+ sp_repr_css_set_property (css, "font-size",font_size.str().c_str());
+ Glib::ustring css_str;
+ sp_repr_css_write_string(css,css_str);
rtext->setAttribute("style", css_str.c_str());
rtspan->setAttribute("style", NULL);
rtspan->setAttribute("transform", NULL);
@@ -362,7 +351,7 @@ LPEMeasureSegments::createTextLabel(Geom::Point pos, size_t counter, double leng
}
void
-LPEMeasureSegments::createLine(Geom::Point start,Geom::Point end, const char * id, bool main, bool overflow, bool remove, bool arrows)
+LPEMeasureSegments::createLine(Geom::Point start,Geom::Point end, const char * id, bool main, bool remove, bool arrows)
{
SPDocument * document = SP_ACTIVE_DOCUMENT;
if (!document) {
@@ -378,8 +367,11 @@ LPEMeasureSegments::createLine(Geom::Point start,Geom::Point end, const char * i
end = end + Point::polar(angle, helpline_overlap );
}
Geom::PathVector line_pathv;
- if (main && std::abs(text_top_bottom) < fontsize/1.5 && hide_back && !overflow){
- Geom::Path line_path;
+
+ if (main &&
+ std::abs(text_top_bottom) < fontsize/1.5 &&
+ hide_back)
+ {
double k = 0;
if (flip_side) {
k = (Geom::distance(start,end)/2.0) + arrow_gap - (anotation_width/2.0);
@@ -397,7 +389,7 @@ LPEMeasureSegments::createLine(Geom::Point start,Geom::Point end, const char * i
//k = std::max(k , arrow_gap -1);
Geom::Ray ray(end, start);
Geom::Coord angle = ray.angle();
- line_path.start(start);
+ Geom::Path line_path(start);
line_path.appendNew<Geom::LineSegment>(start - Point::polar(angle, k));
line_pathv.push_back(line_path);
line_path.clear();
@@ -405,8 +397,7 @@ LPEMeasureSegments::createLine(Geom::Point start,Geom::Point end, const char * i
line_path.appendNew<Geom::LineSegment>(end);
line_pathv.push_back(line_path);
} else {
- Geom::Path line_path;
- line_path.start(start);
+ Geom::Path line_path(start);
line_path.appendNew<Geom::LineSegment>(end);
line_pathv.push_back(line_path);
}
@@ -427,6 +418,11 @@ LPEMeasureSegments::createLine(Geom::Point start,Geom::Point end, const char * i
}
line = xml_doc->createElement("svg:path");
line->setAttribute("id", id);
+ if (main) {
+ line->setAttribute("class", (Glib::ustring(sp_lpe_item->getId()) + Glib::ustring(" ") + Glib::ustring(this->lpeobj->getId()) + Glib::ustring(" measure-DIM-lines measure-lines")).c_str());
+ } else {
+ line->setAttribute("class", (Glib::ustring(sp_lpe_item->getId()) + Glib::ustring(" ") + Glib::ustring(this->lpeobj->getId()) + Glib::ustring(" measure-helper-lines measure-lines")).c_str());
+ }
gchar * line_str = sp_svg_write_path( line_pathv );
line->setAttribute("d" , line_str);
g_free(line_str);
@@ -434,10 +430,8 @@ LPEMeasureSegments::createLine(Geom::Point start,Geom::Point end, const char * i
line->setAttribute("sodipodi:insensitive", "true");
line_pathv.clear();
- Glib::ustring style = Glib::ustring("stroke:#000000;fill:none;");
- if (overflow && !arrows) {
- line->setAttribute("inkscape:label", "downline");
- } else if (main) {
+ Glib::ustring style;
+ if (main) {
line->setAttribute("inkscape:label", "dinline");
if (arrows_outside) {
style = style + Glib::ustring("marker-start:url(#ArrowDINout-start);marker-end:url(#ArrowDINout-end);");
@@ -449,22 +443,18 @@ LPEMeasureSegments::createLine(Geom::Point start,Geom::Point end, const char * i
}
std::stringstream stroke_w;
stroke_w.imbue(std::locale::classic());
- if (line_group_05) {
- double stroke_width = Inkscape::Util::Quantity::convert(0.25 / doc_scale, "mm", display_unit.c_str());
- stroke_w << stroke_width;
- style = style + Glib::ustring("stroke-width:" + stroke_w.str());
- } else {
- double stroke_width = Inkscape::Util::Quantity::convert(0.35 / doc_scale, "mm", display_unit.c_str());
- stroke_w << stroke_width;
- style = style + Glib::ustring("stroke-width:" + stroke_w.str());
- }
+ double stroke_width = Inkscape::Util::Quantity::convert(line_width / doc_scale, "mm", display_unit.c_str());
+ stroke_w << stroke_width;
+ style = style + Glib::ustring("stroke-width:" + stroke_w.str());
+ gchar c[32];
+ unsigned const rgb24 = coloropacity.get_value() >> 8;
+ sprintf(c, "#%06x", rgb24);
+ style = style + Glib::ustring(";stroke:") + Glib::ustring(c);
+ Inkscape::SVGOStringStream os;
+ os << SP_RGBA32_A_F(coloropacity.get_value());
+ style = style + Glib::ustring(";stroke-opacity:") + Glib::ustring(os.str());
SPCSSAttr *css = sp_repr_css_attr_new();
sp_repr_css_attr_add_from_string(css, style.c_str());
- if (main) {
- sp_repr_css_attr_add_from_string(css, dimline_format.param_getSVGValue());
- } else {
- sp_repr_css_attr_add_from_string(css, helperlines_format.param_getSVGValue());
- }
Glib::ustring css_str;
sp_repr_css_write_string(css,css_str);
line->setAttribute("style", css_str.c_str());
@@ -489,7 +479,54 @@ LPEMeasureSegments::doOnApply(SPLPEItem const* lpeitem)
g_warning("LPE measure line can only be applied to shapes (not groups).");
SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem);
item->removeCurrentPathEffect(false);
+ return;
+ }
+ SPDocument *document = SP_ACTIVE_DOCUMENT;
+ bool saved = DocumentUndo::getUndoSensitive(document);
+ DocumentUndo::setUndoSensitive(document, false);
+ Inkscape::XML::Node *styleNode = NULL;
+ Inkscape::XML::Node* textNode = NULL;
+ Inkscape::XML::Node *root = SP_ACTIVE_DOCUMENT->getReprRoot();
+ for (unsigned i = 0; i < root->childCount(); ++i) {
+ if (Glib::ustring(root->nthChild(i)->name()) == "svg:style") {
+
+ styleNode = root->nthChild(i);
+
+ for (unsigned j = 0; j < styleNode->childCount(); ++j) {
+ if (styleNode->nthChild(j)->type() == Inkscape::XML::TEXT_NODE) {
+ textNode = styleNode->nthChild(j);
+ }
+ }
+
+ if (textNode == NULL) {
+ // Style element found but does not contain text node!
+ std::cerr << "StyleDialog::_getStyleTextNode(): No text node!" << std::endl;
+ textNode = SP_ACTIVE_DOCUMENT->getReprDoc()->createTextNode("");
+ styleNode->appendChild(textNode);
+ Inkscape::GC::release(textNode);
+ }
+ }
+ }
+
+ if (styleNode == NULL) {
+ // Style element not found, create one
+ styleNode = SP_ACTIVE_DOCUMENT->getReprDoc()->createElement("svg:style");
+ textNode = SP_ACTIVE_DOCUMENT->getReprDoc()->createTextNode("");
+
+ styleNode->appendChild(textNode);
+ Inkscape::GC::release(textNode);
+
+ root->addChild(styleNode, NULL);
+ Inkscape::GC::release(styleNode);
}
+ Glib::ustring styleContent = Glib::ustring(textNode->content());
+ if (styleContent.find(".measure-arrows\n{\n") == -1) {
+ styleContent = styleContent + Glib::ustring("\n.measure-arrows") + Glib::ustring("\n{\n}");
+ styleContent = styleContent + Glib::ustring("\n.measure-labels") + Glib::ustring("\n{\nline-height:125%;\nletter-spacing:0;\nword-spacing:0;\ntext-align:center;\ntext-anchor:middle;\nstroke:none;\n}");
+ styleContent = styleContent + Glib::ustring("\n.measure-lines") + Glib::ustring("\n{\n}");
+ textNode->setContent(styleContent.c_str());
+ }
+ DocumentUndo::setUndoSensitive(document, saved);
}
bool
@@ -532,7 +569,7 @@ void
LPEMeasureSegments::doBeforeEffect (SPLPEItem const* lpeitem)
{
SPLPEItem * splpeitem = const_cast<SPLPEItem *>(lpeitem);
- sp_lpe_item->parent = dynamic_cast<SPObject *>(splpeitem->parent);
+
SPDocument * document = SP_ACTIVE_DOCUMENT;
if (!document) {
return;
@@ -555,12 +592,17 @@ LPEMeasureSegments::doBeforeEffect (SPLPEItem const* lpeitem)
}
Geom::Point start_stored;
Geom::Point end_stored;
- Geom::Affine affinetransform = i2anc_affine(SP_OBJECT(lpeitem), SP_OBJECT(document->getRoot()));
+ Geom::Affine affinetransform = i2anc_affine(SP_OBJECT(lpeitem->parent), SP_OBJECT(document->getRoot()));
Geom::PathVector pathvector = pathv_to_linear_and_cubic_beziers(c->get_pathvector());
c->unref();
Geom::Affine writed_transform = Geom::identity();
sp_svg_transform_read(splpeitem->getAttribute("transform"), &writed_transform );
- pathvector *= writed_transform;
+ if (star_ellipse_fix != Geom::identity()) {
+ pathvector *= star_ellipse_fix;
+ star_ellipse_fix = Geom::identity();
+ } else {
+ pathvector *= writed_transform;
+ }
if ((Glib::ustring(format.param_getSVGValue()).empty())) {
format.param_setValue(Glib::ustring("{measure}{unit}"));
}
@@ -670,7 +712,7 @@ LPEMeasureSegments::doBeforeEffect (SPLPEItem const* lpeitem)
} else {
hstart = hstart - Point::polar(angle_cross, position);
}
- createLine(start, hstart, g_strdup(Glib::ustring("infoline-on-start-").append(Glib::ustring::format(counter) + Glib::ustring("-")).append(this->getRepr()->attribute("id")).c_str()), false, false, remove);
+ createLine(start, hstart, g_strdup(Glib::ustring("infoline-on-start-").append(Glib::ustring::format(counter) + Glib::ustring("-")).append(this->getRepr()->attribute("id")).c_str()), false, remove);
if (fix_overlaps != 180 && end_angle_cross != 0) {
double position_turned = position / sin(end_angle_cross/2.0);
@@ -701,47 +743,18 @@ LPEMeasureSegments::doBeforeEffect (SPLPEItem const* lpeitem)
if (scale_sensitive) {
length *= parents_scale;
}
+ if ((anotation_width/2) > Geom::distance(hstart,hend)/2.0) {
+ pos = pos - Point::polar(angle_cross, position);
+ }
if (scale_sensitive && !affinetransform.preservesAngles()) {
createTextLabel(pos, counter, length, angle, remove, false);
} else {
createTextLabel(pos, counter, length, angle, remove, true);
}
- bool overflow = false;
const char * downline = g_strdup(Glib::ustring("downline-").append(Glib::ustring::format(counter) + Glib::ustring("-")).append(this->getRepr()->attribute("id")).c_str());
- //delete residual lines if exist
- createLine(Geom::Point(),Geom::Point(), downline, true, overflow, true, false);
- //Create it
- if ((anotation_width/2) + std::abs(text_right_left / doc_scale) > Geom::distance(hstart,hend)/2.0) {
- Geom::Point sstart = hend - Point::polar(angle_cross, position);
- Geom::Point send = hend - Point::polar(angle_cross, position);
- if ((text_right_left < 0 && flip_side) || (text_right_left > 0 && !flip_side)) {
- sstart = hstart - Point::polar(angle_cross, position);
- send = hstart - Point::polar(angle_cross, position);
- }
- Geom::Point prog_end = Geom::Point();
- if (std::abs(text_top_bottom / doc_scale) < fontsize/1.5 && hide_back) {
- if (text_right_left > 0 ) {
- prog_end = sstart - Point::polar(angle, std::abs(text_right_left / doc_scale) - (anotation_width/1.9) - (Geom::distance(hstart,hend)/2.0));
- } else {
- prog_end = sstart + Point::polar(angle, std::abs(text_right_left / doc_scale) - (anotation_width/1.9) - (Geom::distance(hstart,hend)/2.0));
- }
- } else {
- if (text_right_left / doc_scale > 0 ) {
- prog_end = sstart - Point::polar(angle,(anotation_width/2) + std::abs(text_right_left / doc_scale) - (Geom::distance(hstart,hend)/2.0));
- } else {
- prog_end = sstart + Point::polar(angle,(anotation_width/2) + std::abs(text_right_left / doc_scale) - (Geom::distance(hstart,hend)/2.0));
- }
- }
- overflow = true;
- createLine(sstart, prog_end, downline, true, overflow, false, false);
- }
- //LINE
- arrow_gap = 8 * Inkscape::Util::Quantity::convert(0.35 / doc_scale, "mm", display_unit.c_str());
- if (line_group_05) {
- arrow_gap = 8 * Inkscape::Util::Quantity::convert(0.25 / doc_scale, "mm", display_unit.c_str());
- }
+ arrow_gap = 8 * Inkscape::Util::Quantity::convert(line_width / doc_scale, "mm", display_unit.c_str());
SPCSSAttr *css = sp_repr_css_attr_new();
- sp_repr_css_attr_add_from_string(css, dimline_format.param_getSVGValue());
+
char *oldlocale = g_strdup (setlocale(LC_NUMERIC, NULL));
setlocale (LC_NUMERIC, "C");
double width_line = atof(sp_repr_css_property(css,"stroke-width","-1"));
@@ -753,18 +766,22 @@ LPEMeasureSegments::doBeforeEffect (SPLPEItem const* lpeitem)
if(flip_side) {
arrow_gap *= -1;
}
- createLine(end, hend, g_strdup(Glib::ustring("infoline-on-end-").append(Glib::ustring::format(counter) + Glib::ustring("-")).append(this->getRepr()->attribute("id")).c_str()), false, false, remove);
+ createLine(end, hend, g_strdup(Glib::ustring("infoline-on-end-").append(Glib::ustring::format(counter) + Glib::ustring("-")).append(this->getRepr()->attribute("id")).c_str()), false, remove);
if (!arrows_outside) {
hstart = hstart + Point::polar(angle, arrow_gap);
hend = hend - Point::polar(angle, arrow_gap );
}
- createLine(hstart, hend, g_strdup(Glib::ustring("infoline-").append(Glib::ustring::format(counter) + Glib::ustring("-")).append(this->getRepr()->attribute("id")).c_str()), true, overflow, remove, true);
+ if ((anotation_width/2) < Geom::distance(hstart,hend)/2.0) {
+ createLine(hstart, hend, g_strdup(Glib::ustring("infoline-").append(Glib::ustring::format(counter) + Glib::ustring("-")).append(this->getRepr()->attribute("id")).c_str()), true, remove, true);
+ } else {
+ createLine(hstart, hend, g_strdup(Glib::ustring("infoline-").append(Glib::ustring::format(counter) + Glib::ustring("-")).append(this->getRepr()->attribute("id")).c_str()), true, true, true);
+ }
} else {
const char * downline = g_strdup(Glib::ustring("downline-").append(Glib::ustring::format(counter) + Glib::ustring("-")).append(this->getRepr()->attribute("id")).c_str());
- createLine(Geom::Point(),Geom::Point(), downline, true, true, true, true);
- createLine(Geom::Point(), Geom::Point(), g_strdup(Glib::ustring("infoline-").append(Glib::ustring::format(counter) + Glib::ustring("-")).append(this->getRepr()->attribute("id")).c_str()), true, true, true, true);
- createLine(Geom::Point(), Geom::Point(), g_strdup(Glib::ustring("infoline-on-start-").append(Glib::ustring::format(counter) + Glib::ustring("-")).append(this->getRepr()->attribute("id")).c_str()), true, true, true, true);
- createLine(Geom::Point(), Geom::Point(), g_strdup(Glib::ustring("infoline-on-end-").append(Glib::ustring::format(counter) + Glib::ustring("-")).append(this->getRepr()->attribute("id")).c_str()), true, true, true, true);
+ createLine(Geom::Point(),Geom::Point(), downline, true, true, true);
+ createLine(Geom::Point(), Geom::Point(), g_strdup(Glib::ustring("infoline-").append(Glib::ustring::format(counter) + Glib::ustring("-")).append(this->getRepr()->attribute("id")).c_str()), true, true, true);
+ createLine(Geom::Point(), Geom::Point(), g_strdup(Glib::ustring("infoline-on-start-").append(Glib::ustring::format(counter) + Glib::ustring("-")).append(this->getRepr()->attribute("id")).c_str()), true, true, true);
+ createLine(Geom::Point(), Geom::Point(), g_strdup(Glib::ustring("infoline-on-end-").append(Glib::ustring::format(counter) + Glib::ustring("-")).append(this->getRepr()->attribute("id")).c_str()), true, true, true);
const char * id = g_strdup(Glib::ustring("text-on-").append(Glib::ustring::format(counter) + Glib::ustring("-")).append(this->getRepr()->attribute("id")).c_str());
SPObject *elemref = NULL;
if ((elemref = document->getObjectById(id))) {
@@ -775,10 +792,10 @@ LPEMeasureSegments::doBeforeEffect (SPLPEItem const* lpeitem)
}
for (size_t k = ncurves; k <= previous_size; k++) {
const char * downline = g_strdup(Glib::ustring("downline-").append(Glib::ustring::format(counter) + Glib::ustring("-")).append(this->getRepr()->attribute("id")).c_str());
- createLine(Geom::Point(),Geom::Point(), downline, true, true, true, true);
- createLine(Geom::Point(), Geom::Point(), g_strdup(Glib::ustring("infoline-").append(Glib::ustring::format(k) + Glib::ustring("-")).append(this->getRepr()->attribute("id")).c_str()), true, true, true, true);
- createLine(Geom::Point(), Geom::Point(), g_strdup(Glib::ustring("infoline-on-start-").append(Glib::ustring::format(k) + Glib::ustring("-")).append(this->getRepr()->attribute("id")).c_str()), true, true, true, true);
- createLine(Geom::Point(), Geom::Point(), g_strdup(Glib::ustring("infoline-on-end-").append(Glib::ustring::format(k) + Glib::ustring("-")).append(this->getRepr()->attribute("id")).c_str()), true, true, true, true);
+ createLine(Geom::Point(),Geom::Point(), downline, true, true, true);
+ createLine(Geom::Point(), Geom::Point(), g_strdup(Glib::ustring("infoline-").append(Glib::ustring::format(k) + Glib::ustring("-")).append(this->getRepr()->attribute("id")).c_str()), true, true, true);
+ createLine(Geom::Point(), Geom::Point(), g_strdup(Glib::ustring("infoline-on-start-").append(Glib::ustring::format(k) + Glib::ustring("-")).append(this->getRepr()->attribute("id")).c_str()), true, true, true);
+ createLine(Geom::Point(), Geom::Point(), g_strdup(Glib::ustring("infoline-on-end-").append(Glib::ustring::format(k) + Glib::ustring("-")).append(this->getRepr()->attribute("id")).c_str()), true, true, true);
const char * id = g_strdup(Glib::ustring("text-on-").append(Glib::ustring::format(k) + Glib::ustring("-")).append(this->getRepr()->attribute("id")).c_str());
SPObject *elemref = NULL;
if ((elemref = document->getObjectById(id))) {
@@ -807,61 +824,14 @@ LPEMeasureSegments::doOnRemove (SPLPEItem const* /*lpeitem*/)
processObjects(LPE_ERASE);
}
-Gtk::Widget *LPEMeasureSegments::newWidget()
-{
- // use manage here, because after deletion of Effect object, others might
- // still be pointing to this widget.
- Gtk::VBox *vbox = Gtk::manage(new Gtk::VBox(Effect::newWidget()));
-
- vbox->set_border_width(5);
- vbox->set_homogeneous(false);
- vbox->set_spacing(2);
-
- std::vector<Parameter *>::iterator it = param_vector.begin();
- Gtk::VBox * vbox_expander = Gtk::manage( new Gtk::VBox(Effect::newWidget()) );
- vbox_expander->set_border_width(0);
- vbox_expander->set_spacing(2);
- while (it != param_vector.end()) {
- if ((*it)->widget_is_visible) {
- Parameter *param = *it;
- Gtk::Widget *widg = dynamic_cast<Gtk::Widget *>(param->param_newWidget());
- Glib::ustring *tip = param->param_getTooltip();
- if (widg) {
- if (param->param_key != "dimline_format" &&
- param->param_key != "helperlines_format" &&
- param->param_key != "arrows_format" &&
- param->param_key != "anotation_format") {
- vbox->pack_start(*widg, true, true, 2);
- } else {
- vbox_expander->pack_start(*widg, true, true, 2);
- }
- if (tip) {
- widg->set_tooltip_text(*tip);
- } else {
- widg->set_tooltip_text("");
- widg->set_has_tooltip(false);
- }
- }
- }
-
- ++it;
- }
- expander = Gtk::manage(new Gtk::Expander(Glib::ustring(_("Show DIM CSS style override"))));
- expander->add(*vbox_expander);
- expander->set_expanded(expanded);
- expander->property_expanded().signal_changed().connect(sigc::mem_fun(*this, &LPEMeasureSegments::onExpanderChanged) );
- vbox->pack_start(*expander, true, true, 2);
- return dynamic_cast<Gtk::Widget *>(vbox);
-}
-
void
-LPEMeasureSegments::onExpanderChanged()
+LPEMeasureSegments::transform_multiply(Geom::Affine const& postmul, bool set)
{
- expanded = expander->get_expanded();
- if(expanded) {
- expander->set_label (Glib::ustring(_("Hide DIM CSS style override")));
- } else {
- expander->set_label (Glib::ustring(_("Show DIM CSS style override")));
+ SPStar * star = dynamic_cast<SPStar *>(sp_lpe_item);
+ SPSpiral * spiral = dynamic_cast<SPSpiral *>(sp_lpe_item);
+ if((spiral || star) && !postmul.withoutTranslation().isUniformScale()) {
+ star_ellipse_fix = postmul;
+ sp_lpe_item_update_patheffect(sp_lpe_item, false, false);
}
}
diff --git a/src/live_effects/lpe-measure-segments.h b/src/live_effects/lpe-measure-segments.h
index f7f5be1e3..903a5cbd2 100644
--- a/src/live_effects/lpe-measure-segments.h
+++ b/src/live_effects/lpe-measure-segments.h
@@ -11,15 +11,15 @@
*/
#include "live_effects/effect.h"
-
-#include <gtkmm/expander.h>
+#include "ui/dialog/styledialog.h"
#include "live_effects/parameter/enum.h"
#include "live_effects/parameter/fontbutton.h"
#include "live_effects/parameter/text.h"
#include "live_effects/parameter/unit.h"
#include "live_effects/parameter/bool.h"
-#include "live_effects/parameter/originalpath.h"
+#include "live_effects/parameter/colorpicker.h"
+#include "live_effects/parameter/message.h"
#include <libnrtype/font-lister.h>
#include <2geom/angle.h>
#include <2geom/ray.h>
@@ -44,24 +44,24 @@ public:
virtual void doOnRemove (SPLPEItem const* /*lpeitem*/);
virtual void doEffect (SPCurve * curve){}; //stop the chain
virtual void doOnVisibilityToggled(SPLPEItem const* /*lpeitem*/);
+ virtual void transform_multiply(Geom::Affine const& postmul, bool set);
virtual Geom::PathVector doEffect_path(Geom::PathVector const &path_in);
- void createLine(Geom::Point start,Geom::Point end, const char * id, bool main, bool overflow, bool remove, bool arrows = false);
+ void createLine(Geom::Point start,Geom::Point end, const char * id, bool main, bool remove, bool arrows = false);
void createTextLabel(Geom::Point pos, size_t counter, double length, Geom::Coord angle, bool remove, bool valid);
- void onExpanderChanged();
void createArrowMarker(const char * mode);
bool hasMeassure (size_t i);
- virtual Gtk::Widget *newWidget();
private:
UnitParam unit;
- FontButtonParam fontbutton;
EnumParam<OrientationMethod> orientation;
+ ColorPickerParam coloropacity;
+ FontButtonParam fontbutton;
ScalarParam precision;
ScalarParam fix_overlaps;
ScalarParam position;
ScalarParam text_top_bottom;
- ScalarParam text_right_left;
ScalarParam helpline_distance;
ScalarParam helpline_overlap;
+ ScalarParam line_width;
ScalarParam scale;
TextParam format;
TextParam blacklist;
@@ -70,22 +70,16 @@ private:
BoolParam flip_side;
BoolParam scale_sensitive;
BoolParam local_locale;
- BoolParam line_group_05;
BoolParam rotate_anotation;
BoolParam hide_back;
- TextParam dimline_format;
- TextParam helperlines_format;
- TextParam anotation_format;
- TextParam arrows_format;
+ MessageParam message;
Glib::ustring display_unit;
- bool expanded;
- Gtk::Expander * expander;
double doc_scale;
double fontsize;
double anotation_width;
double previous_size;
double arrow_gap;
-
+ Geom::Affine star_ellipse_fix;
LPEMeasureSegments(const LPEMeasureSegments &);
LPEMeasureSegments &operator=(const LPEMeasureSegments &);
diff --git a/src/live_effects/lpe-patternalongpath.cpp b/src/live_effects/lpe-patternalongpath.cpp
index 22b18e077..4aa172161 100644
--- a/src/live_effects/lpe-patternalongpath.cpp
+++ b/src/live_effects/lpe-patternalongpath.cpp
@@ -294,25 +294,29 @@ KnotHolderEntityWidthPatternAlongPath::knot_set(Geom::Point const &p, Geom::Poin
Geom::Point const s = snap_knot_position(p, state);
SPShape const *sp_shape = dynamic_cast<SPShape const *>(SP_LPE_ITEM(item));
if (sp_shape) {
- Geom::Path const *path_in = sp_shape->getCurveBeforeLPE()->first_path();
- Geom::Point ptA = path_in->pointAt(Geom::PathTime(0, 0.0));
- Geom::Point B = path_in->pointAt(Geom::PathTime(1, 0.0));
- Geom::Curve const *first_curve = &path_in->curveAt(Geom::PathTime(0, 0.0));
- Geom::CubicBezier const *cubic = dynamic_cast<Geom::CubicBezier const *>(&*first_curve);
- Geom::Ray ray(ptA, B);
- if (cubic) {
- ray.setPoints(ptA, (*cubic)[1]);
- }
- ray.setAngle(ray.angle() + Geom::rad_from_deg(90));
- Geom::Point knot_pos = this->knot->pos * item->i2dt_affine().inverse();
- Geom::Coord nearest_to_ray = ray.nearestTime(knot_pos);
- if(nearest_to_ray == 0){
- lpe->prop_scale.param_set_value(-Geom::distance(s , ptA)/(lpe->original_height/2.0));
- } else {
- lpe->prop_scale.param_set_value(Geom::distance(s , ptA)/(lpe->original_height/2.0));
+ SPCurve *curve_before = sp_shape->getCurveBeforeLPE();
+ if (curve_before) {
+ Geom::Path const *path_in = curve_before->first_path();
+ Geom::Point ptA = path_in->pointAt(Geom::PathTime(0, 0.0));
+ Geom::Point B = path_in->pointAt(Geom::PathTime(1, 0.0));
+ Geom::Curve const *first_curve = &path_in->curveAt(Geom::PathTime(0, 0.0));
+ Geom::CubicBezier const *cubic = dynamic_cast<Geom::CubicBezier const *>(&*first_curve);
+ Geom::Ray ray(ptA, B);
+ if (cubic) {
+ ray.setPoints(ptA, (*cubic)[1]);
+ }
+ ray.setAngle(ray.angle() + Geom::rad_from_deg(90));
+ Geom::Point knot_pos = this->knot->pos * item->i2dt_affine().inverse();
+ Geom::Coord nearest_to_ray = ray.nearestTime(knot_pos);
+ if(nearest_to_ray == 0){
+ lpe->prop_scale.param_set_value(-Geom::distance(s , ptA)/(lpe->original_height/2.0));
+ } else {
+ lpe->prop_scale.param_set_value(Geom::distance(s , ptA)/(lpe->original_height/2.0));
+ }
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble("/live_effect/pap/width", lpe->prop_scale);
+ curve_before->unref();
}
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setDouble("/live_effect/pap/width", lpe->prop_scale);
}
sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), false, true);
}
@@ -324,25 +328,28 @@ KnotHolderEntityWidthPatternAlongPath::knot_get() const
SPShape const *sp_shape = dynamic_cast<SPShape const *>(SP_LPE_ITEM(item));
if (sp_shape) {
- Geom::Path const *path_in = sp_shape->getCurveBeforeLPE()->first_path();
- Geom::Point ptA = path_in->pointAt(Geom::PathTime(0, 0.0));
- Geom::Point B = path_in->pointAt(Geom::PathTime(1, 0.0));
- Geom::Curve const *first_curve = &path_in->curveAt(Geom::PathTime(0, 0.0));
- Geom::CubicBezier const *cubic = dynamic_cast<Geom::CubicBezier const *>(&*first_curve);
- Geom::Ray ray(ptA, B);
- if (cubic) {
- ray.setPoints(ptA, (*cubic)[1]);
+ SPCurve *curve_before = sp_shape->getCurveBeforeLPE();
+ if (curve_before) {
+ Geom::Path const *path_in = curve_before->first_path();
+ Geom::Point ptA = path_in->pointAt(Geom::PathTime(0, 0.0));
+ Geom::Point B = path_in->pointAt(Geom::PathTime(1, 0.0));
+ Geom::Curve const *first_curve = &path_in->curveAt(Geom::PathTime(0, 0.0));
+ Geom::CubicBezier const *cubic = dynamic_cast<Geom::CubicBezier const *>(&*first_curve);
+ Geom::Ray ray(ptA, B);
+ if (cubic) {
+ ray.setPoints(ptA, (*cubic)[1]);
+ }
+ ray.setAngle(ray.angle() + Geom::rad_from_deg(90));
+ Geom::Point result_point = Geom::Point::polar(ray.angle(), (lpe->original_height/2.0) * lpe->prop_scale) + ptA;
+
+ pap_helper_path.clear();
+ Geom::Path hp(result_point);
+ hp.appendNew<Geom::LineSegment>(ptA);
+ pap_helper_path.push_back(hp);
+ hp.clear();
+ curve_before->unref();
+ return result_point;
}
- ray.setAngle(ray.angle() + Geom::rad_from_deg(90));
- Geom::Point result_point = Geom::Point::polar(ray.angle(), (lpe->original_height/2.0) * lpe->prop_scale) + ptA;
-
- pap_helper_path.clear();
- Geom::Path hp(result_point);
- hp.appendNew<Geom::LineSegment>(ptA);
- pap_helper_path.push_back(hp);
- hp.clear();
-
- return result_point;
}
return Geom::Point();
}
diff --git a/src/live_effects/lpe-powerclip.cpp b/src/live_effects/lpe-powerclip.cpp
index 43faa35e0..40a9cdbfb 100644
--- a/src/live_effects/lpe-powerclip.cpp
+++ b/src/live_effects/lpe-powerclip.cpp
@@ -4,7 +4,6 @@
#include "live_effects/lpe-powerclip.h"
#include <2geom/path-intersection.h>
#include <2geom/intersection-graph.h>
-#include "display/drawing-item.h"
#include "display/curve.h"
#include "helper/geom.h"
#include "sp-clippath.h"
@@ -13,6 +12,9 @@
#include "sp-item-group.h"
#include "ui/tools-switch.h"
#include "path-chemistry.h"
+#include "uri.h"
+#include "extract-uri.h"
+#include <bad-uri-exception.h>
// TODO due to internal breakage in glibmm headers, this must be last:
#include <glibmm/i18n.h>
@@ -22,19 +24,17 @@ namespace LivePathEffect {
LPEPowerClip::LPEPowerClip(LivePathEffectObject *lpeobject)
: Effect(lpeobject),
+ hide_clip(_("Hide clip"), _("Hide clip"), "hide_clip", &wr, this, false),
+ is_inverse("Store the last inverse apply", "", "is_inverse", &wr, this, "false", false),
+ uri("Store the uri of clip", "", "uri", &wr, this, "false", false),
inverse(_("Inverse clip"), _("Inverse clip"), "inverse", &wr, this, false),
- flatten(_("Flatten clip"), _("Flatten clip, see fill rule once convert to paths"), "flatten", &wr, this, false),
- //loock(_("Lock clip"), _("Lock clip"), "lock", &wr, this, false),
- //tooltip empty to no show in default param set
- is_inverse("Store the last inverse apply", "", "is_inverse", &wr, this, "false", false)
+ flatten(_("Flatten clip"), _("Flatten clip, see fill rule once convert to paths"), "flatten", &wr, this, false)
{
+ registerParameter(&uri);
registerParameter(&inverse);
registerParameter(&flatten);
+ registerParameter(&hide_clip);
registerParameter(&is_inverse);
- //registerParameter(&lock);
- //lock.param_setValue(false);
- is_clip = false;
- hide_clip = false;
convert_shapes = false;
}
@@ -42,22 +42,48 @@ LPEPowerClip::~LPEPowerClip() {}
void
LPEPowerClip::doBeforeEffect (SPLPEItem const* lpeitem){
- original_bbox(lpeitem);
- SPClipPath *clip_path = SP_ITEM(lpeitem)->clip_ref->getObject();
- Geom::Point topleft = Geom::Point(boundingbox_X.min() - 5,boundingbox_Y.max() + 5);
- Geom::Point topright = Geom::Point(boundingbox_X.max() + 5,boundingbox_Y.max() + 5);
- Geom::Point bottomright = Geom::Point(boundingbox_X.max() + 5,boundingbox_Y.min() - 5);
- Geom::Point bottomleft = Geom::Point(boundingbox_X.min() - 5,boundingbox_Y.min() - 5);
- clip_box.clear();
- clip_box.start(topleft);
- clip_box.appendNew<Geom::LineSegment>(topright);
- clip_box.appendNew<Geom::LineSegment>(bottomright);
- clip_box.appendNew<Geom::LineSegment>(bottomleft);
- clip_box.close();
- //clip_path *= sp_lpe_item->i2dt_affine();
+ SPObject * clip_path = SP_ITEM(sp_lpe_item)->clip_ref->getObject();
+ if(hide_clip && clip_path) {
+ SP_ITEM(sp_lpe_item)->clip_ref->detach();
+ } else if (!hide_clip && !clip_path && uri.param_getSVGValue()) {
+ try {
+ SP_ITEM(sp_lpe_item)->clip_ref->attach(Inkscape::URI(uri.param_getSVGValue()));
+ } catch (Inkscape::BadURIException &e) {
+ g_warning("%s", e.what());
+ SP_ITEM(sp_lpe_item)->clip_ref->detach();
+ }
+ }
+ clip_path = SP_ITEM(sp_lpe_item)->clip_ref->getObject();
if (clip_path) {
- is_clip = true;
- const Glib::ustring uri = (Glib::ustring)sp_lpe_item->getRepr()->attribute("clip-path");
+ uri.param_setValue(Glib::ustring(extract_uri(sp_lpe_item->getRepr()->attribute("clip-path"))), true);
+ SP_ITEM(sp_lpe_item)->clip_ref->detach();
+ Geom::OptRect bbox = sp_lpe_item->visualBounds();
+ if(!bbox) {
+ return;
+ }
+ if (uri.param_getSVGValue()) {
+ try {
+ SP_ITEM(sp_lpe_item)->clip_ref->attach(Inkscape::URI(uri.param_getSVGValue()));
+ } catch (Inkscape::BadURIException &e) {
+ g_warning("%s", e.what());
+ SP_ITEM(sp_lpe_item)->clip_ref->detach();
+ }
+ } else {
+ SP_ITEM(sp_lpe_item)->clip_ref->detach();
+ }
+ Geom::Rect bboxrect = (*bbox);
+ bboxrect.expandBy(1);
+ Geom::Point topleft = bboxrect.corner(0);
+ Geom::Point topright = bboxrect.corner(1);
+ Geom::Point bottomright = bboxrect.corner(2);
+ Geom::Point bottomleft = bboxrect.corner(3);
+ clip_box.clear();
+ clip_box.start(topleft);
+ clip_box.appendNew<Geom::LineSegment>(topright);
+ clip_box.appendNew<Geom::LineSegment>(bottomright);
+ clip_box.appendNew<Geom::LineSegment>(bottomleft);
+ clip_box.close();
+ //clip_box *= sp_lpe_item->i2dt_affine();
std::vector<SPObject*> clip_path_list = clip_path->childList(true);
for ( std::vector<SPObject*>::const_iterator iter=clip_path_list.begin();iter!=clip_path_list.end();++iter) {
SPObject * clip_data = *iter;
@@ -133,8 +159,6 @@ LPEPowerClip::doBeforeEffect (SPLPEItem const* lpeitem){
removeInverse(SP_ITEM(clip_data));
}
}
- } else {
- is_clip = false;
}
}
@@ -217,36 +241,6 @@ LPEPowerClip::removeInverse (SPItem * clip_data){
}
void
-LPEPowerClip::toggleClip() {
- SPItem * item = SP_ITEM(sp_lpe_item);
- if (item) {
- SPClipPath *clip_path = item->clip_ref->getObject();
- if (clip_path) {
- hide_clip = !hide_clip;
- if(hide_clip) {
- SPItemView *v;
- for (v = item->display; v != NULL; v = v->next) {
- clip_path->hide(v->arenaitem->key());
- }
- } else {
- Geom::OptRect bbox = item->geometricBounds();
- for (SPItemView *v = item->display; v != NULL; v = v->next) {
- if (!v->arenaitem->key()) {
- v->arenaitem->setKey(SPItem::display_key_new(3));
- }
- Inkscape::DrawingItem *ai = clip_path->show(
- v->arenaitem->drawing(),
- v->arenaitem->key());
- v->arenaitem->setClip(ai);
- clip_path->setBBox(v->arenaitem->key(), bbox);
- }
- }
- clip_path->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
- }
- }
-}
-
-void
LPEPowerClip::convertShapes() {
convert_shapes = true;
sp_lpe_item_update_patheffect(SP_LPE_ITEM(sp_lpe_item), false, false);
@@ -256,7 +250,7 @@ Gtk::Widget *
LPEPowerClip::newWidget()
{
// use manage here, because after deletion of Effect object, others might still be pointing to this widget.
- Gtk::VBox * vbox = Gtk::manage( new Gtk::VBox(Effect::newWidget()) );
+ Gtk::VBox * vbox = Gtk::manage( new Gtk::VBox(Effect::newWidget()));
vbox->set_border_width(5);
vbox->set_homogeneous(false);
@@ -281,17 +275,11 @@ LPEPowerClip::newWidget()
++it;
}
Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false,0));
- Gtk::Button * toggle_button = Gtk::manage(new Gtk::Button(Glib::ustring(_("Toggle clip visibiliy"))));
- toggle_button->signal_clicked().connect(sigc::mem_fun (*this,&LPEPowerClip::toggleClip));
- toggle_button->set_size_request(180,30);
- vbox->pack_start(*hbox, true,true,2);
- hbox->pack_start(*toggle_button, false, false,2);
- Gtk::HBox * hbox2 = Gtk::manage(new Gtk::HBox(false,0));
Gtk::Button * topaths_button = Gtk::manage(new Gtk::Button(Glib::ustring(_("Convert clips to paths, undoable"))));
topaths_button->signal_clicked().connect(sigc::mem_fun (*this,&LPEPowerClip::convertShapes));
topaths_button->set_size_request(220,30);
- vbox->pack_start(*hbox2, true,true,2);
- hbox2->pack_start(*topaths_button, false, false,2);
+ hbox->pack_start(*topaths_button, false, false,2);
+ vbox->pack_start(*hbox, true,true,2);
return dynamic_cast<Gtk::Widget *>(vbox);
}
@@ -301,7 +289,6 @@ LPEPowerClip::doOnRemove (SPLPEItem const* /*lpeitem*/)
SPClipPath *clip_path = SP_ITEM(sp_lpe_item)->clip_ref->getObject();
if(!keep_paths) {
if(clip_path) {
- is_clip = true;
std::vector<SPObject*> clip_path_list = clip_path->childList(true);
for ( std::vector<SPObject*>::const_iterator iter=clip_path_list.begin();iter!=clip_path_list.end();++iter) {
SPObject * clip_data = *iter;
@@ -313,7 +300,6 @@ LPEPowerClip::doOnRemove (SPLPEItem const* /*lpeitem*/)
} else {
if (flatten && clip_path) {
clip_path->deleteObject();
- sp_lpe_item->getRepr()->setAttribute("clip-path", NULL);
}
}
}
@@ -321,7 +307,7 @@ LPEPowerClip::doOnRemove (SPLPEItem const* /*lpeitem*/)
Geom::PathVector
LPEPowerClip::doEffect_path(Geom::PathVector const & path_in){
Geom::PathVector path_out = pathv_to_linear_and_cubic_beziers(path_in);
- if (flatten && is_clip && isVisible()) {
+ if (!hide_clip && flatten && isVisible()) {
SPClipPath *clip_path = SP_ITEM(sp_lpe_item)->clip_ref->getObject();
if(clip_path) {
std::vector<SPObject*> clip_path_list = clip_path->childList(true);
@@ -330,6 +316,7 @@ LPEPowerClip::doEffect_path(Geom::PathVector const & path_in){
flattenClip(SP_ITEM(clip_data), path_out);
}
}
+ SP_ITEM(sp_lpe_item)->clip_ref->detach();
}
return path_out;
}
@@ -346,13 +333,13 @@ LPEPowerClip::doOnVisibilityToggled(SPLPEItem const* lpeitem)
//{
// SPDocument * doc = SP_ACTIVE_DOCUMENT;
// SPClipPath *clip_path = SP_ITEM(sp_lpe_item)->clip_ref->getObject();
-// if (is_clip && lock) {
+// if (clip_path && lock) {
// std::vector<SPObject*> clip_path_list = clip_path->childList(true);
// Glib::ustring clip_id = (Glib::ustring)clip_path->getId();
// Glib::ustring box_id = clip_id + (Glib::ustring)"_box";
// for ( std::vector<SPObject*>::const_iterator iter=clip_path_list.begin();iter!=clip_path_list.end();++iter) {
// SPItem * clip_data = SP_ITEM(*iter);
-// if(inverse && is_clip && lock) {
+// if(inverse && lock) {
// removeInverse(clip_data);
// }
// if (lock) {
@@ -371,7 +358,7 @@ LPEPowerClip::doOnVisibilityToggled(SPLPEItem const* lpeitem)
//// }
//// }
// }
-// if(inverse && is_clip && lock) {
+// if(inverse && lock) {
// doBeforeEffect(sp_lpe_item);
// }
// }
@@ -381,8 +368,8 @@ LPEPowerClip::doOnVisibilityToggled(SPLPEItem const* lpeitem)
// Parameter * param = *it;
// param->param_transform_multiply(postmul, set);
// }
-// toggleClip();
-// toggleClip();
+// toggleClipVisibility();
+// toggleClipVisibility();
//}
void
diff --git a/src/live_effects/lpe-powerclip.h b/src/live_effects/lpe-powerclip.h
index ce46b560a..38485b798 100644
--- a/src/live_effects/lpe-powerclip.h
+++ b/src/live_effects/lpe-powerclip.h
@@ -9,12 +9,11 @@
#include "live_effects/effect.h"
#include "live_effects/parameter/hidden.h"
-#include "live_effects/lpegroupbbox.h"
namespace Inkscape {
namespace LivePathEffect {
-class LPEPowerClip : public Effect, GroupBBoxEffect {
+class LPEPowerClip : public Effect {
public:
LPEPowerClip(LivePathEffectObject *lpeobject);
virtual ~LPEPowerClip();
@@ -24,22 +23,19 @@ public:
virtual Gtk::Widget * newWidget();
//virtual void transform_multiply(Geom::Affine const& postmul, bool set);
virtual void doOnVisibilityToggled(SPLPEItem const* lpeitem);
- void toggleClip();
void addInverse (SPItem * clip_data);
void removeInverse (SPItem * clip_data);
void flattenClip(SPItem * clip_data, Geom::PathVector &path_in);
void convertShapes();
private:
+ HiddenParam is_inverse;
+ HiddenParam uri;
BoolParam inverse;
BoolParam flatten;
- // BoolParam lock;
- HiddenParam is_inverse;
+ BoolParam hide_clip;
Geom::Path clip_box;
Geom::Affine base;
- bool is_clip;
bool convert_shapes;
- bool hide_clip;
- bool previous_hide_clip;
};
} //namespace LivePathEffect
diff --git a/src/live_effects/lpe-powermask.cpp b/src/live_effects/lpe-powermask.cpp
index 434ad6dd4..05510f258 100644
--- a/src/live_effects/lpe-powermask.cpp
+++ b/src/live_effects/lpe-powermask.cpp
@@ -4,7 +4,6 @@
#include "live_effects/lpe-powermask.h"
#include <2geom/path-intersection.h>
#include <2geom/intersection-graph.h>
-#include "display/drawing-item.h"
#include "display/curve.h"
#include "helper/geom.h"
#include "sp-mask.h"
@@ -16,6 +15,9 @@
#include "svg/svg.h"
#include "ui/tools-switch.h"
#include "path-chemistry.h"
+#include "uri.h"
+#include "extract-uri.h"
+#include <bad-uri-exception.h>
// TODO due to internal breakage in glibmm headers, this must be last:
#include <glibmm/i18n.h>
@@ -25,40 +27,68 @@ namespace LivePathEffect {
LPEPowerMask::LPEPowerMask(LivePathEffectObject *lpeobject)
: Effect(lpeobject),
+ uri("Store the uri of mask", "", "uri", &wr, this, "false", false),
invert(_("Invert mask"), _("Invert mask"), "invert", &wr, this, false),
wrap(_("Wrap mask data"), _("Wrap mask data allowing previous filters"), "wrap", &wr, this, false),
+ hide_mask(_("Hide mask"), _("Hide mask"), "hide_mask", &wr, this, false),
background(_("Add background to mask"), _("Add background to mask"), "background", &wr, this, false),
- //lock(_("Lock mask"), _("Lock mask"), "lock", &wr, this, false),
background_style(_("Background Style"), _("CSS to background"), "background_style", &wr, this,"fill:#ffffff;opacity:1;")
-
{
+ registerParameter(&uri);
registerParameter(&invert);
registerParameter(&wrap);
- //registerParameter(&lock);
+ registerParameter(&hide_mask);
registerParameter(&background);
registerParameter(&background_style);
//lock.param_setValue(false);
background_style.param_hide_canvas_text();
- hide_mask = false;
}
LPEPowerMask::~LPEPowerMask() {}
void
LPEPowerMask::doBeforeEffect (SPLPEItem const* lpeitem){
- original_bbox(lpeitem);
- SPMask *mask = SP_ITEM(lpeitem)->mask_ref->getObject();
- Geom::Point topleft = Geom::Point(boundingbox_X.min() - 5,boundingbox_Y.max() + 5);
- Geom::Point topright = Geom::Point(boundingbox_X.max() + 5,boundingbox_Y.max() + 5);
- Geom::Point bottomright = Geom::Point(boundingbox_X.max() + 5,boundingbox_Y.min() - 5);
- Geom::Point bottomleft = Geom::Point(boundingbox_X.min() - 5,boundingbox_Y.min() - 5);
- mask_box.clear();
- mask_box.start(topleft);
- mask_box.appendNew<Geom::LineSegment>(topright);
- mask_box.appendNew<Geom::LineSegment>(bottomright);
- mask_box.appendNew<Geom::LineSegment>(bottomleft);
- mask_box.close();
- if(mask) {
+ SPObject * mask = SP_ITEM(sp_lpe_item)->mask_ref->getObject();
+ if(hide_mask && mask) {
+ SP_ITEM(sp_lpe_item)->mask_ref->detach();
+ } else if (!hide_mask && !mask && uri.param_getSVGValue()) {
+ try {
+ SP_ITEM(sp_lpe_item)->mask_ref->attach(Inkscape::URI(uri.param_getSVGValue()));
+ } catch (Inkscape::BadURIException &e) {
+ g_warning("%s", e.what());
+ SP_ITEM(sp_lpe_item)->mask_ref->detach();
+ }
+ }
+ mask = SP_ITEM(sp_lpe_item)->mask_ref->getObject();
+ if (mask) {
+ uri.param_setValue(Glib::ustring(extract_uri(sp_lpe_item->getRepr()->attribute("mask"))), true);
+ SP_ITEM(sp_lpe_item)->mask_ref->detach();
+ Geom::OptRect bbox = sp_lpe_item->visualBounds();
+ if(!bbox) {
+ return;
+ }
+ if (uri.param_getSVGValue()) {
+ try {
+ SP_ITEM(sp_lpe_item)->mask_ref->attach(Inkscape::URI(uri.param_getSVGValue()));
+ } catch (Inkscape::BadURIException &e) {
+ g_warning("%s", e.what());
+ SP_ITEM(sp_lpe_item)->mask_ref->detach();
+ }
+ } else {
+ SP_ITEM(sp_lpe_item)->mask_ref->detach();
+ }
+ Geom::Rect bboxrect = (*bbox);
+ bboxrect.expandBy(1);
+ Geom::Point topleft = bboxrect.corner(0);
+ Geom::Point topright = bboxrect.corner(1);
+ Geom::Point bottomright = bboxrect.corner(2);
+ Geom::Point bottomleft = bboxrect.corner(3);
+ mask_box.clear();
+ mask_box.start(topleft);
+ mask_box.appendNew<Geom::LineSegment>(topright);
+ mask_box.appendNew<Geom::LineSegment>(bottomright);
+ mask_box.appendNew<Geom::LineSegment>(bottomleft);
+ mask_box.close();
setMask();
}
}
@@ -225,37 +255,6 @@ LPEPowerMask::doEffect (SPCurve * curve)
{
}
-void
-LPEPowerMask::toggleMask() {
- SPItem * item = SP_ITEM(sp_lpe_item);
- if (item) {
- SPMask *mask = item->mask_ref->getObject();
- if (mask) {
- hide_mask = !hide_mask;
- if(hide_mask) {
- SPItemView *v;
- for (v = item->display; v != NULL; v = v->next) {
- mask->sp_mask_hide(v->arenaitem->key());
- }
- } else {
- Geom::OptRect bbox = item->geometricBounds();
- for (SPItemView *v = item->display; v != NULL; v = v->next) {
- if (!v->arenaitem->key()) {
- v->arenaitem->setKey(SPItem::display_key_new(3));
- }
- Inkscape::DrawingItem *ai = mask->sp_mask_show(
- v->arenaitem->drawing(),
- v->arenaitem->key());
- bbox.unionWith(ai->geometricBounds());
- v->arenaitem->setMask(ai);
- mask->sp_mask_set_bbox(v->arenaitem->key(), bbox);
- }
- }
- mask->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
- }
- }
-}
-
//void
//LPEPowerMask::transform_multiply(Geom::Affine const& postmul, bool set)
//{
@@ -283,44 +282,6 @@ LPEPowerMask::toggleMask() {
-Gtk::Widget *
-LPEPowerMask::newWidget()
-{
- // use manage here, because after deletion of Effect object, others might still be pointing to this widget.
- Gtk::VBox * vbox = Gtk::manage( new Gtk::VBox(Effect::newWidget()) );
-
- vbox->set_border_width(5);
- vbox->set_homogeneous(false);
- vbox->set_spacing(6);
-
- std::vector<Parameter *>::iterator it = param_vector.begin();
- while (it != param_vector.end()) {
- if ((*it)->widget_is_visible) {
- Parameter * param = *it;
- Gtk::Widget * widg = dynamic_cast<Gtk::Widget *>(param->param_newWidget());
- Glib::ustring * tip = param->param_getTooltip();
- if (widg) {
- vbox->pack_start(*widg, true, true, 2);
- if (tip) {
- widg->set_tooltip_text(*tip);
- } else {
- widg->set_tooltip_text("");
- widg->set_has_tooltip(false);
- }
- }
- }
-
- ++it;
- }
- Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false,0));
- Gtk::Button * toggle_button = Gtk::manage(new Gtk::Button(Glib::ustring(_("Toggle mask visibiliy"))));
- toggle_button->signal_clicked().connect(sigc::mem_fun (*this,&LPEPowerMask::toggleMask));
- toggle_button->set_size_request(140,30);
- vbox->pack_start(*hbox, true,true,2);
- hbox->pack_start(*toggle_button, false, false,2);
- return dynamic_cast<Gtk::Widget *>(vbox);
-}
-
void
LPEPowerMask::doOnRemove (SPLPEItem const* lpeitem)
{
diff --git a/src/live_effects/lpe-powermask.h b/src/live_effects/lpe-powermask.h
index cd36b3b37..a54424e2f 100644
--- a/src/live_effects/lpe-powermask.h
+++ b/src/live_effects/lpe-powermask.h
@@ -9,31 +9,30 @@
#include "live_effects/effect.h"
#include "live_effects/parameter/text.h"
-#include "live_effects/lpegroupbbox.h"
+#include "live_effects/parameter/hidden.h"
namespace Inkscape {
namespace LivePathEffect {
-class LPEPowerMask : public Effect, GroupBBoxEffect {
+class LPEPowerMask : public Effect {
public:
LPEPowerMask(LivePathEffectObject *lpeobject);
virtual ~LPEPowerMask();
virtual void doBeforeEffect (SPLPEItem const* lpeitem);
virtual void doEffect (SPCurve * curve);
virtual void doOnRemove (SPLPEItem const* /*lpeitem*/);
- virtual Gtk::Widget * newWidget();
virtual void doOnVisibilityToggled(SPLPEItem const* lpeitem);
//virtual void transform_multiply(Geom::Affine const& postmul, bool set);
- void toggleMask();
+ void toggleMaskVisibility();
void setMask();
private:
+ HiddenParam uri;
BoolParam invert;
BoolParam wrap;
+ BoolParam hide_mask;
BoolParam background;
- //BoolParam lock;
TextParam background_style;
Geom::Path mask_box;
- bool hide_mask;
};
} //namespace LivePathEffect
diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp
index 85d7e1e17..51c8451a5 100644
--- a/src/live_effects/lpe-powerstroke.cpp
+++ b/src/live_effects/lpe-powerstroke.cpp
@@ -267,7 +267,7 @@ LPEPowerStroke::doOnApply(SPLPEItem const* lpeitem)
void LPEPowerStroke::doOnRemove(SPLPEItem const* lpeitem)
{
- if (SP_IS_SHAPE(lpeitem)) {
+ if (SP_IS_SHAPE(lpeitem) && !keep_paths) {
SPLPEItem *item = const_cast<SPLPEItem*>(lpeitem);
SPCSSAttr *css = sp_repr_css_attr_new ();
if (lpeitem->style->fill.isPaintserver()) {
@@ -288,7 +288,7 @@ void LPEPowerStroke::doOnRemove(SPLPEItem const* lpeitem)
}
Inkscape::CSSOStringStream os;
- os << offset_points.median_width() * 2;
+ os << std::abs(offset_points.median_width()) * 2;
sp_repr_css_set_property (css, "stroke-width", os.str().c_str());
sp_repr_css_set_property(css, "fill", "none");
diff --git a/src/live_effects/lpe-ruler.cpp b/src/live_effects/lpe-ruler.cpp
index 852592219..7ba5a7913 100644
--- a/src/live_effects/lpe-ruler.cpp
+++ b/src/live_effects/lpe-ruler.cpp
@@ -78,9 +78,12 @@ LPERuler::ruler_mark(Geom::Point const &A, Geom::Point const &n, MarkType const
using namespace Geom;
double real_mark_length = mark_length;
- real_mark_length = Inkscape::Util::Quantity::convert(real_mark_length, unit.get_abbreviation(), "px");
+ SPDocument * document = SP_ACTIVE_DOCUMENT;
+ SPNamedView *nv = sp_document_namedview(document, NULL);
+ Glib::ustring display_unit = nv->display_units->abbr;
+ real_mark_length = Inkscape::Util::Quantity::convert(real_mark_length, unit.get_abbreviation(), display_unit.c_str());
double real_minor_mark_length = minor_mark_length;
- real_minor_mark_length = Inkscape::Util::Quantity::convert(real_minor_mark_length, unit.get_abbreviation(), "px");
+ real_minor_mark_length = Inkscape::Util::Quantity::convert(real_minor_mark_length, unit.get_abbreviation(), display_unit.c_str());
n_major = real_mark_length * n;
n_minor = real_minor_mark_length * n;
@@ -130,10 +133,13 @@ LPERuler::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_i
std::vector<double> s_cuts;
double real_mark_distance = mark_distance;
- real_mark_distance = Inkscape::Util::Quantity::convert(real_mark_distance, unit.get_abbreviation(), "px");
+ SPDocument * document = SP_ACTIVE_DOCUMENT;
+ SPNamedView *nv = sp_document_namedview(document, NULL);
+ Glib::ustring display_unit = nv->display_units->abbr;
+ real_mark_distance = Inkscape::Util::Quantity::convert(real_mark_distance, unit.get_abbreviation(), display_unit.c_str());
double real_offset = offset;
- real_offset = Inkscape::Util::Quantity::convert(real_offset, unit.get_abbreviation(), "px");
+ real_offset = Inkscape::Util::Quantity::convert(real_offset, unit.get_abbreviation(), display_unit.c_str());
for (double s = real_offset; s<totlength; s+=real_mark_distance){
s_cuts.push_back(s);
}
diff --git a/src/live_effects/makefile.in b/src/live_effects/makefile.in
deleted file mode 100644
index 8a4da813b..000000000
--- a/src/live_effects/makefile.in
+++ /dev/null
@@ -1,17 +0,0 @@
-# Convenience stub makefile to call the real Makefile.
-
-@SET_MAKE@
-
-OBJEXT = @OBJEXT@
-
-# Explicit so that it's the default rule.
-all:
- cd .. && $(MAKE) live_effects/all
-
-clean %.a %.$(OBJEXT):
- cd .. && $(MAKE) live_effects/$@
-
-.PHONY: all clean
-
-.SUFFIXES:
-.SUFFIXES: .a .$(OBJEXT)
diff --git a/src/live_effects/parameter/array.h b/src/live_effects/parameter/array.h
index e65d3b55c..c66d53266 100644
--- a/src/live_effects/parameter/array.h
+++ b/src/live_effects/parameter/array.h
@@ -67,6 +67,10 @@ public:
gchar * str = g_strdup(os.str().c_str());
return str;
}
+
+ virtual gchar * param_getDefaultSVGValue() const {
+ return g_strdup("");
+ }
void param_setValue(std::vector<StorageType> const &new_vector) {
_vector = new_vector;
diff --git a/src/live_effects/parameter/bool.cpp b/src/live_effects/parameter/bool.cpp
index f291a8104..1a01f269b 100644
--- a/src/live_effects/parameter/bool.cpp
+++ b/src/live_effects/parameter/bool.cpp
@@ -61,6 +61,13 @@ BoolParam::param_getSVGValue() const
return str;
}
+gchar *
+BoolParam::param_getDefaultSVGValue() const
+{
+ gchar * str = g_strdup(defvalue ? "true" : "false");
+ return str;
+}
+
Gtk::Widget *
BoolParam::param_newWidget()
{
diff --git a/src/live_effects/parameter/bool.h b/src/live_effects/parameter/bool.h
index 417752050..1aa0e3c4a 100644
--- a/src/live_effects/parameter/bool.h
+++ b/src/live_effects/parameter/bool.h
@@ -32,6 +32,7 @@ public:
virtual bool param_readSVGValue(const gchar * strvalue);
virtual gchar * param_getSVGValue() const;
+ virtual gchar * param_getDefaultSVGValue() const;
void param_setValue(bool newvalue);
virtual void param_set_default();
diff --git a/src/live_effects/parameter/colorpicker.cpp b/src/live_effects/parameter/colorpicker.cpp
new file mode 100644
index 000000000..f6521d0c0
--- /dev/null
+++ b/src/live_effects/parameter/colorpicker.cpp
@@ -0,0 +1,151 @@
+/*
+ * Authors:
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include <gtkmm.h>
+#include "ui/widget/registered-widget.h"
+#include "live_effects/parameter/colorpicker.h"
+#include "live_effects/effect.h"
+#include "ui/widget/color-picker.h"
+#include "svg/svg.h"
+#include "svg/svg-color.h"
+#include "color.h"
+#include "inkscape.h"
+#include "svg/stringstream.h"
+#include "verbs.h"
+#include "document.h"
+#include "document-undo.h"
+
+#include <glibmm/i18n.h>
+
+namespace Inkscape {
+
+namespace LivePathEffect {
+
+ColorPickerParam::ColorPickerParam( const Glib::ustring& label, const Glib::ustring& tip,
+ const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
+ Effect* effect, const guint32 default_color )
+ : Parameter(label, tip, key, wr, effect),
+ value(default_color),
+ defvalue(default_color)
+{
+
+}
+
+void
+ColorPickerParam::param_set_default()
+{
+ param_setValue(defvalue);
+}
+
+static guint32 sp_read_color_alpha(gchar const *str, guint32 def)
+{
+ guint32 val = 0;
+ if (str == NULL) return def;
+ while ((*str <= ' ') && *str) str++;
+ if (!*str) return def;
+
+ if (str[0] == '#') {
+ gint i;
+ for (i = 1; str[i]; i++) {
+ int hexval;
+ if (str[i] >= '0' && str[i] <= '9')
+ hexval = str[i] - '0';
+ else if (str[i] >= 'A' && str[i] <= 'F')
+ hexval = str[i] - 'A' + 10;
+ else if (str[i] >= 'a' && str[i] <= 'f')
+ hexval = str[i] - 'a' + 10;
+ else
+ break;
+ val = (val << 4) + hexval;
+ }
+ if (i != 1 + 8) {
+ return def;
+ }
+ }
+ return val;
+}
+
+void
+ColorPickerParam::param_update_default(const gchar * default_value)
+{
+ defvalue = sp_read_color_alpha(default_value, 0x000000ff);
+}
+
+bool
+ColorPickerParam::param_readSVGValue(const gchar * strvalue)
+{
+ param_setValue(sp_read_color_alpha(strvalue, 0x000000ff));
+ return true;
+}
+
+gchar *
+ColorPickerParam::param_getSVGValue() const
+{
+ gchar c[32];
+ sprintf(c, "#%08x", value);
+ return strdup(c);
+}
+
+gchar *
+ColorPickerParam::param_getDefaultSVGValue() const
+{
+ gchar c[32];
+ sprintf(c, "#%08x", defvalue);
+ return strdup(c);
+}
+
+Gtk::Widget *
+ColorPickerParam::param_newWidget()
+{
+ Gtk::HBox *hbox = Gtk::manage(new Gtk::HBox());
+
+ hbox->set_border_width(5);
+ hbox->set_homogeneous(false);
+ hbox->set_spacing(2);
+ Inkscape::UI::Widget::RegisteredColorPicker * colorpickerwdg = Gtk::manage(
+ new Inkscape::UI::Widget::RegisteredColorPicker( param_label,
+ param_label,
+ param_tooltip,
+ param_key,
+ param_key + "_opacity_LPE",
+ *param_wr,
+ param_effect->getRepr(),
+ param_effect->getSPDoc() ) );
+ Gtk::Label * label = new Gtk::Label (param_label, Gtk::ALIGN_END);
+ label->set_use_underline (true);
+ label->set_mnemonic_widget (*colorpickerwdg);
+ SPDocument *document = SP_ACTIVE_DOCUMENT;
+ bool saved = DocumentUndo::getUndoSensitive(document);
+ DocumentUndo::setUndoSensitive(document, false);
+ colorpickerwdg->setRgba32(value);
+ DocumentUndo::setUndoSensitive(document, saved);
+ colorpickerwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change color button parameter"));
+ hbox->pack_start(*dynamic_cast<Gtk::Widget *> (label), true, true);
+ hbox->pack_start(*dynamic_cast<Gtk::Widget *> (colorpickerwdg), true, true);
+ return dynamic_cast<Gtk::Widget *> (hbox);
+}
+
+void
+ColorPickerParam::param_setValue(const guint32 newvalue)
+{
+ value = newvalue;
+}
+
+
+} /* namespace LivePathEffect */
+
+} /* namespace Inkscape */
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/live_effects/parameter/colorpicker.h b/src/live_effects/parameter/colorpicker.h
new file mode 100644
index 000000000..84ae2f6d5
--- /dev/null
+++ b/src/live_effects/parameter/colorpicker.h
@@ -0,0 +1,61 @@
+#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_COLOR_BUTTON_H
+#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_COLOR_BUTTON_H
+
+/*
+ * Inkscape::LivePathEffectParameters
+ *
+ * Authors:
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+#include <glib.h>
+#include "live_effects/parameter/parameter.h"
+
+namespace Inkscape {
+
+namespace LivePathEffect {
+
+class ColorPickerParam : public Parameter {
+public:
+ ColorPickerParam( const Glib::ustring& label,
+ const Glib::ustring& tip,
+ const Glib::ustring& key,
+ Inkscape::UI::Widget::Registry* wr,
+ Effect* effect,
+ const guint32 default_color = 0x000000ff);
+ virtual ~ColorPickerParam() {}
+
+ virtual Gtk::Widget * param_newWidget();
+ virtual bool param_readSVGValue(const gchar * strvalue);
+ void param_update_default(const gchar * default_value);
+ virtual gchar * param_getSVGValue() const;
+ virtual gchar * param_getDefaultSVGValue() const;
+
+ void param_setValue(guint32 newvalue);
+
+ virtual void param_set_default();
+
+ const guint32 get_value() const { return value; };
+
+private:
+ ColorPickerParam(const ColorPickerParam&);
+ ColorPickerParam& operator=(const ColorPickerParam&);
+ guint32 value;
+ guint32 defvalue;
+};
+
+} //namespace LivePathEffect
+
+} //namespace Inkscape
+
+#endif
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/live_effects/parameter/enum.h b/src/live_effects/parameter/enum.h
index 78fa87a4f..ca237c0f7 100644
--- a/src/live_effects/parameter/enum.h
+++ b/src/live_effects/parameter/enum.h
@@ -64,7 +64,12 @@ public:
gchar * str = g_strdup( enumdataconv->get_key(value).c_str() );
return str;
};
-
+
+ gchar * param_getDefaultSVGValue() const {
+ gchar * str = g_strdup( enumdataconv->get_key(defvalue).c_str() );
+ return str;
+ };
+
E get_value() const {
return value;
}
diff --git a/src/live_effects/parameter/fontbutton.cpp b/src/live_effects/parameter/fontbutton.cpp
index ca8908f0e..49edb850a 100644
--- a/src/live_effects/parameter/fontbutton.cpp
+++ b/src/live_effects/parameter/fontbutton.cpp
@@ -55,6 +55,14 @@ FontButtonParam::param_getSVGValue() const
return g_strdup(value.c_str());
}
+gchar *
+FontButtonParam::param_getDefaultSVGValue() const
+{
+ return g_strdup(defvalue.c_str());
+}
+
+
+
Gtk::Widget *
FontButtonParam::param_newWidget()
{
diff --git a/src/live_effects/parameter/fontbutton.h b/src/live_effects/parameter/fontbutton.h
index 60e1aa46e..e2d0e1bb2 100644
--- a/src/live_effects/parameter/fontbutton.h
+++ b/src/live_effects/parameter/fontbutton.h
@@ -28,6 +28,7 @@ public:
virtual bool param_readSVGValue(const gchar * strvalue);
void param_update_default(const gchar * default_value);
virtual gchar * param_getSVGValue() const;
+ virtual gchar * param_getDefaultSVGValue() const;
void param_setValue(Glib::ustring newvalue);
diff --git a/src/live_effects/parameter/hidden.cpp b/src/live_effects/parameter/hidden.cpp
index e8c55ebd3..e08881f6d 100644
--- a/src/live_effects/parameter/hidden.cpp
+++ b/src/live_effects/parameter/hidden.cpp
@@ -59,6 +59,15 @@ HiddenParam::param_getSVGValue() const
return str;
}
+gchar *
+HiddenParam::param_getDefaultSVGValue() const
+{
+ Inkscape::SVGOStringStream os;
+ os << defvalue;
+ gchar * str = g_strdup(os.str().c_str());
+ return str;
+}
+
Gtk::Widget *
HiddenParam::param_newWidget()
{
diff --git a/src/live_effects/parameter/hidden.h b/src/live_effects/parameter/hidden.h
index c3fba5575..b41c6c93c 100644
--- a/src/live_effects/parameter/hidden.h
+++ b/src/live_effects/parameter/hidden.h
@@ -37,6 +37,7 @@ public:
virtual bool param_readSVGValue(const gchar * strvalue);
virtual gchar * param_getSVGValue() const;
+ virtual gchar * param_getDefaultSVGValue() const;
void param_setValue(Glib::ustring newvalue, bool write = false);
virtual void param_set_default();
diff --git a/src/live_effects/parameter/item.cpp b/src/live_effects/parameter/item.cpp
index 71134b118..bf7402d99 100644
--- a/src/live_effects/parameter/item.cpp
+++ b/src/live_effects/parameter/item.cpp
@@ -43,6 +43,7 @@ ItemParam::ItemParam( const Glib::ustring& label, const Glib::ustring& tip,
href(NULL),
ref( (SPObject*)effect->getLPEObj() )
{
+ last_transform = Geom::identity();
defvalue = g_strdup(default_value);
ref_changed_connection = ref.changedSignal().connect(sigc::mem_fun(*this, &ItemParam::ref_changed));
}
@@ -101,7 +102,16 @@ ItemParam::param_readSVGValue(const gchar * strvalue)
gchar *
ItemParam::param_getSVGValue() const
{
- return g_strdup(href);
+ if (href) {
+ return g_strdup(href);
+ }
+ return g_strdup("");
+}
+
+gchar *
+ItemParam::param_getDefaultSVGValue() const
+{
+ return g_strdup(defvalue);
}
Gtk::Widget *
@@ -204,9 +214,18 @@ ItemParam::linked_modified_callback(SPObject *linked_obj, guint /*flags*/)
{
emit_changed();
SP_OBJECT(param_effect->getLPEObj())->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ last_transform = Geom::identity();
}
void
+ItemParam::linked_transformed_callback(Geom::Affine const *rel_transf, SPItem */*moved_item*/)
+{
+ last_transform = *rel_transf;
+ SP_OBJECT(param_effect->getLPEObj())->requestModified(SP_OBJECT_MODIFIED_FLAG);
+}
+
+
+void
ItemParam::on_link_button_click()
{
Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
diff --git a/src/live_effects/parameter/item.h b/src/live_effects/parameter/item.h
index 89c32f9bd..d32098db5 100644
--- a/src/live_effects/parameter/item.h
+++ b/src/live_effects/parameter/item.h
@@ -34,14 +34,14 @@ public:
virtual bool param_readSVGValue(const gchar * strvalue);
virtual gchar * param_getSVGValue() const;
-
+ virtual gchar * param_getDefaultSVGValue() const;
virtual void param_set_default();
virtual void param_update_default(const gchar * default_value);
void param_set_and_write_default();
virtual void addCanvasIndicators(SPLPEItem const* lpeitem, std::vector<Geom::PathVector> &hp_vec);
-
sigc::signal <void> signal_item_pasted;
sigc::signal <void> signal_item_changed;
+ Geom::Affine last_transform;
bool changed; /* this gets set whenever the path is changed (this is set to true, and then the signal_item_changed signal is emitted).
* the user must set it back to false if she wants to use it sensibly */
protected:
@@ -60,7 +60,7 @@ protected:
void linked_modified(SPObject *linked_obj, guint flags);
void linked_transformed(Geom::Affine const *rel_transf, SPItem *moved_item);
virtual void linked_modified_callback(SPObject *linked_obj, guint flags);
- virtual void linked_transformed_callback(Geom::Affine const * /*rel_transf*/, SPItem * /*moved_item*/) {};
+ virtual void linked_transformed_callback(Geom::Affine const *rel_transf, SPItem */*moved_item*/);
void on_link_button_click();
void emit_changed();
diff --git a/src/live_effects/parameter/makefile.in b/src/live_effects/parameter/makefile.in
deleted file mode 100644
index af48c8e7a..000000000
--- a/src/live_effects/parameter/makefile.in
+++ /dev/null
@@ -1,17 +0,0 @@
-# Convenience stub makefile to call the real Makefile.
-
-@SET_MAKE@
-
-OBJEXT = @OBJEXT@
-
-# Explicit so that it's the default rule.
-all:
- cd ../.. && $(MAKE) live_effects/parameter/all
-
-clean %.a %.$(OBJEXT):
- cd ../.. && $(MAKE) live_effects/parameter/$@
-
-.PHONY: all clean
-
-.SUFFIXES:
-.SUFFIXES: .a .$(OBJEXT)
diff --git a/src/live_effects/parameter/message.cpp b/src/live_effects/parameter/message.cpp
new file mode 100644
index 000000000..39d8f12c7
--- /dev/null
+++ b/src/live_effects/parameter/message.cpp
@@ -0,0 +1,101 @@
+/*
+ * Authors:
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include <gtkmm.h>
+#include "live_effects/parameter/message.h"
+#include "live_effects/effect.h"
+#include <glibmm/i18n.h>
+
+namespace Inkscape {
+
+namespace LivePathEffect {
+
+MessageParam::MessageParam( const Glib::ustring& label, const Glib::ustring& tip,
+ const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
+ Effect* effect, const gchar * default_message )
+ : Parameter(label, tip, key, wr, effect),
+ message(g_strdup(default_message)),
+ defmessage(g_strdup(default_message))
+{
+
+}
+
+void
+MessageParam::param_set_default()
+{
+ param_setValue(defmessage);
+}
+
+void
+MessageParam::param_update_default(const gchar * default_message)
+{
+ defmessage = g_strdup(default_message);
+}
+
+bool
+MessageParam::param_readSVGValue(const gchar * strvalue)
+{
+ param_setValue(strvalue);
+ return true;
+}
+
+gchar *
+MessageParam::param_getSVGValue() const
+{
+ return message;
+}
+
+gchar *
+MessageParam::param_getDefaultSVGValue() const
+{
+ return defmessage;
+}
+
+Gtk::Widget *
+MessageParam::param_newWidget()
+{
+ Gtk::Frame * frame = new Gtk::Frame (param_label);
+ Gtk::Widget * widg_frame = frame->get_label_widget();
+ widg_frame->set_margin_right(5);
+ widg_frame->set_margin_left(5);
+ Gtk::Label * label = new Gtk::Label (message, Gtk::ALIGN_END);
+ label->set_use_underline (true);
+ label->set_use_markup();
+ label->set_line_wrap(true);
+ Gtk::Widget * widg_label = dynamic_cast<Gtk::Widget *> (label);
+ widg_label->set_margin_top(8);
+ widg_label->set_margin_bottom(10);
+ widg_label->set_margin_right(6);
+ widg_label->set_margin_left(6);
+
+ frame->add(*widg_label);
+ return dynamic_cast<Gtk::Widget *> (frame);
+}
+
+void
+MessageParam::param_setValue(const gchar * strvalue)
+{
+ if (strcmp(strvalue, message) != 0) {
+ param_effect->upd_params = true;
+ }
+ message = g_strdup(strvalue);
+}
+
+
+} /* namespace LivePathEffect */
+
+} /* namespace Inkscape */
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/live_effects/parameter/message.h b/src/live_effects/parameter/message.h
new file mode 100644
index 000000000..63075cf96
--- /dev/null
+++ b/src/live_effects/parameter/message.h
@@ -0,0 +1,61 @@
+#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_MESSAGE_H
+#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_MESSAGE_H
+
+/*
+ * Inkscape::LivePathEffectParameters
+ *
+ * Authors:
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+#include <glib.h>
+#include "live_effects/parameter/parameter.h"
+
+namespace Inkscape {
+
+namespace LivePathEffect {
+
+class MessageParam : public Parameter {
+public:
+ MessageParam( const Glib::ustring& label,
+ const Glib::ustring& tip,
+ const Glib::ustring& key,
+ Inkscape::UI::Widget::Registry* wr,
+ Effect* effect,
+ const gchar * default_message = "Default message");
+ virtual ~MessageParam() {}
+
+ virtual Gtk::Widget * param_newWidget();
+ virtual bool param_readSVGValue(const gchar * strvalue);
+ void param_update_default(const gchar * default_value);
+ virtual gchar * param_getSVGValue() const;
+ virtual gchar * param_getDefaultSVGValue() const;
+
+ void param_setValue(const gchar * message);
+
+ virtual void param_set_default();
+
+ const gchar * get_value() const { return message; };
+
+private:
+ MessageParam(const MessageParam&);
+ MessageParam& operator=(const MessageParam&);
+ gchar * message;
+ gchar * defmessage;
+};
+
+} //namespace LivePathEffect
+
+} //namespace Inkscape
+
+#endif
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/live_effects/parameter/originalitem.cpp b/src/live_effects/parameter/originalitem.cpp
index 81ab41c56..e828e1800 100644
--- a/src/live_effects/parameter/originalitem.cpp
+++ b/src/live_effects/parameter/originalitem.cpp
@@ -87,17 +87,16 @@ OriginalItemParam::param_newWidget()
void
OriginalItemParam::linked_modified_callback(SPObject *linked_obj, guint /*flags*/)
{
- if (!inverse) {
- emit_changed();
- SP_OBJECT(param_effect->getLPEObj())->requestModified(SP_OBJECT_MODIFIED_FLAG);
- }
+ emit_changed();
+ SP_OBJECT(param_effect->getLPEObj())->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ last_transform = Geom::identity();
}
void
-OriginalItemParam::linked_transformed_callback(Geom::Affine const * /*rel_transf*/, SPItem * /*moved_item*/)
+OriginalItemParam::linked_transformed_callback(Geom::Affine const * rel_transf, SPItem *moved_item)
{
-/** \todo find good way to compensate for referenced item transform, like done for normal clones.
- * See sp-use.cpp: sp_use_move_compensate */
+ last_transform = *rel_transf;
+ SP_OBJECT(param_effect->getLPEObj())->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
diff --git a/src/live_effects/parameter/originalitem.h b/src/live_effects/parameter/originalitem.h
index 58d04e05a..168728f86 100644
--- a/src/live_effects/parameter/originalitem.h
+++ b/src/live_effects/parameter/originalitem.h
@@ -23,7 +23,6 @@ public:
Inkscape::UI::Widget::Registry* wr,
Effect* effect);
virtual ~OriginalItemParam();
- void setInverse(bool inversed) { inverse = inversed; }
bool linksToItem() const { return (href != NULL); }
SPItem * getObject() const { return ref.getObject(); }
@@ -36,7 +35,6 @@ protected:
void on_select_original_button_click();
private:
- bool inverse;
OriginalItemParam(const OriginalItemParam&);
OriginalItemParam& operator=(const OriginalItemParam&);
};
diff --git a/src/live_effects/parameter/originalitemarray.cpp b/src/live_effects/parameter/originalitemarray.cpp
new file mode 100644
index 000000000..f45de4ad8
--- /dev/null
+++ b/src/live_effects/parameter/originalitemarray.cpp
@@ -0,0 +1,470 @@
+/*
+ * Copyright (C) Theodore Janeczko 2012 <flutterguy317@gmail.com>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include "live_effects/parameter/originalitemarray.h"
+
+#include <gtkmm/widget.h>
+#include <gtkmm/icontheme.h>
+#include <gtkmm/imagemenuitem.h>
+#include <gtkmm/separatormenuitem.h>
+#include <gtkmm/scrolledwindow.h>
+
+#include <glibmm/i18n.h>
+
+#include "inkscape.h"
+#include "ui/clipboard.h"
+#include "svg/svg.h"
+#include "svg/stringstream.h"
+#include "originalitem.h"
+#include "uri.h"
+
+#include "live_effects/effect.h"
+
+#include "verbs.h"
+#include "document-undo.h"
+#include "document.h"
+
+namespace Inkscape {
+
+namespace LivePathEffect {
+
+class OriginalItemArrayParam::ModelColumns : public Gtk::TreeModel::ColumnRecord
+{
+public:
+
+ ModelColumns()
+ {
+ add(_colObject);
+ add(_colLabel);
+ add(_colActive);
+ }
+ virtual ~ModelColumns() {}
+
+ Gtk::TreeModelColumn<ItemAndActive*> _colObject;
+ Gtk::TreeModelColumn<Glib::ustring> _colLabel;
+ Gtk::TreeModelColumn<bool> _colActive;
+};
+
+OriginalItemArrayParam::OriginalItemArrayParam( const Glib::ustring& label,
+ const Glib::ustring& tip,
+ const Glib::ustring& key,
+ Inkscape::UI::Widget::Registry* wr,
+ Effect* effect )
+: Parameter(label, tip, key, wr, effect),
+ _vector(),
+ _tree(),
+ _text_renderer(),
+ _toggle_active(),
+ _scroller()
+{
+ _model = new ModelColumns();
+ _store = Gtk::TreeStore::create(*_model);
+ _tree.set_model(_store);
+
+ _tree.set_reorderable(true);
+ _tree.enable_model_drag_dest (Gdk::ACTION_MOVE);
+
+ Gtk::CellRendererToggle * _toggle_active = manage(new Gtk::CellRendererToggle());
+ int activeColNum = _tree.append_column(_("Active"), *_toggle_active) - 1;
+ Gtk::TreeViewColumn* col_active = _tree.get_column(activeColNum);
+ _toggle_active->set_activatable(true);
+ _toggle_active->signal_toggled().connect(sigc::mem_fun(*this, &OriginalItemArrayParam::on_active_toggled));
+ col_active->add_attribute(_toggle_active->property_active(), _model->_colActive);
+
+ _text_renderer = manage(new Gtk::CellRendererText());
+ int nameColNum = _tree.append_column(_("Name"), *_text_renderer) - 1;
+ _name_column = _tree.get_column(nameColNum);
+ _name_column->add_attribute(_text_renderer->property_text(), _model->_colLabel);
+
+ _tree.set_expander_column( *_tree.get_column(nameColNum) );
+ _tree.set_search_column(_model->_colLabel);
+
+ //quick little hack -- newer versions of gtk gave the item zero space allotment
+ _scroller.set_size_request(-1, 120);
+
+ _scroller.add(_tree);
+ _scroller.set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC );
+ //_scroller.set_shadow_type(Gtk::SHADOW_IN);
+
+ oncanvas_editable = true;
+}
+
+OriginalItemArrayParam::~OriginalItemArrayParam()
+{
+ while (!_vector.empty()) {
+ ItemAndActive *w = _vector.back();
+ _vector.pop_back();
+ unlink(w);
+ delete w;
+ }
+ delete _model;
+}
+
+void OriginalItemArrayParam::on_active_toggled(const Glib::ustring& item)
+{
+ Gtk::TreeModel::iterator iter = _store->get_iter(item);
+ Gtk::TreeModel::Row row = *iter;
+ ItemAndActive *w = row[_model->_colObject];
+ row[_model->_colActive] = !row[_model->_colActive];
+ w->actived = row[_model->_colActive];
+
+ gchar * full = param_getSVGValue();
+ param_write_to_repr(full);
+ g_free(full);
+ DocumentUndo::done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
+ _("Link item parameter to item"));
+}
+
+void OriginalItemArrayParam::param_set_default()
+{
+
+}
+
+Gtk::Widget* OriginalItemArrayParam::param_newWidget()
+{
+ Gtk::VBox* vbox = Gtk::manage(new Gtk::VBox());
+ Gtk::HBox* hbox = Gtk::manage(new Gtk::HBox());
+
+ vbox->pack_start(_scroller, Gtk::PACK_EXPAND_WIDGET);
+
+
+ { // Paste item to link button
+ Gtk::Image *pIcon = Gtk::manage(new Gtk::Image());
+ pIcon->set_from_icon_name("edit-clone", Gtk::ICON_SIZE_BUTTON);
+ Gtk::Button *pButton = Gtk::manage(new Gtk::Button());
+ pButton->set_relief(Gtk::RELIEF_NONE);
+ pIcon->show();
+ pButton->add(*pIcon);
+ pButton->show();
+ pButton->signal_clicked().connect(sigc::mem_fun(*this, &OriginalItemArrayParam::on_link_button_click));
+ hbox->pack_start(*pButton, Gtk::PACK_SHRINK);
+ pButton->set_tooltip_text(_("Link to item"));
+ }
+
+ { // Remove linked item
+ Gtk::Image *pIcon = Gtk::manage(new Gtk::Image());
+ pIcon->set_from_icon_name("gtk-remove", Gtk::ICON_SIZE_BUTTON);
+ Gtk::Button *pButton = Gtk::manage(new Gtk::Button());
+ pButton->set_relief(Gtk::RELIEF_NONE);
+ pIcon->show();
+ pButton->add(*pIcon);
+ pButton->show();
+ pButton->signal_clicked().connect(sigc::mem_fun(*this, &OriginalItemArrayParam::on_remove_button_click));
+ hbox->pack_start(*pButton, Gtk::PACK_SHRINK);
+ pButton->set_tooltip_text(_("Remove Item"));
+ }
+
+ { // Move Down
+ Gtk::Image *pIcon = Gtk::manage(new Gtk::Image());
+ pIcon->set_from_icon_name( "gtk-go-down", Gtk::ICON_SIZE_BUTTON);
+ Gtk::Button *pButton = Gtk::manage(new Gtk::Button());
+ pButton->set_relief(Gtk::RELIEF_NONE);
+ pIcon->show();
+ pButton->add(*pIcon);
+ pButton->show();
+ pButton->signal_clicked().connect(sigc::mem_fun(*this, &OriginalItemArrayParam::on_down_button_click));
+ hbox->pack_end(*pButton, Gtk::PACK_SHRINK);
+ pButton->set_tooltip_text(_("Move Down"));
+ }
+
+ { // Move Down
+ Gtk::Image *pIcon = Gtk::manage(new Gtk::Image());
+ pIcon->set_from_icon_name( "gtk-go-up", Gtk::ICON_SIZE_BUTTON);
+ Gtk::Button *pButton = Gtk::manage(new Gtk::Button());
+ pButton->set_relief(Gtk::RELIEF_NONE);
+ pIcon->show();
+ pButton->add(*pIcon);
+ pButton->show();
+ pButton->signal_clicked().connect(sigc::mem_fun(*this, &OriginalItemArrayParam::on_up_button_click));
+ hbox->pack_end(*pButton, Gtk::PACK_SHRINK);
+ pButton->set_tooltip_text(_("Move Up"));
+ }
+
+ vbox->pack_end(*hbox, Gtk::PACK_SHRINK);
+
+ vbox->show_all_children(true);
+
+ return vbox;
+}
+
+bool OriginalItemArrayParam::_selectIndex(const Gtk::TreeIter& iter, int* i)
+{
+ if ((*i)-- <= 0) {
+ _tree.get_selection()->select(iter);
+ return true;
+ }
+ return false;
+}
+
+void OriginalItemArrayParam::on_up_button_click()
+{
+ Gtk::TreeModel::iterator iter = _tree.get_selection()->get_selected();
+ if (iter) {
+ Gtk::TreeModel::Row row = *iter;
+
+ int i = -1;
+ std::vector<ItemAndActive*>::iterator piter = _vector.begin();
+ for (std::vector<ItemAndActive*>::iterator iter = _vector.begin(); iter != _vector.end(); piter = iter, i++, ++iter) {
+ if (*iter == row[_model->_colObject]) {
+ _vector.erase(iter);
+ _vector.insert(piter, row[_model->_colObject]);
+ break;
+ }
+ }
+
+ gchar * full = param_getSVGValue();
+ param_write_to_repr(full);
+ g_free(full);
+
+ DocumentUndo::done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
+ _("Move item up"));
+
+ _store->foreach_iter(sigc::bind<int*>(sigc::mem_fun(*this, &OriginalItemArrayParam::_selectIndex), &i));
+ }
+}
+
+void OriginalItemArrayParam::on_down_button_click()
+{
+ Gtk::TreeModel::iterator iter = _tree.get_selection()->get_selected();
+ if (iter) {
+ Gtk::TreeModel::Row row = *iter;
+
+ int i = 0;
+ for (std::vector<ItemAndActive*>::iterator iter = _vector.begin(); iter != _vector.end(); i++, ++iter) {
+ if (*iter == row[_model->_colObject]) {
+ std::vector<ItemAndActive*>::iterator niter = _vector.erase(iter);
+ if (niter != _vector.end()) {
+ ++niter;
+ i++;
+ }
+ _vector.insert(niter, row[_model->_colObject]);
+ break;
+ }
+ }
+
+ gchar * full = param_getSVGValue();
+ param_write_to_repr(full);
+ g_free(full);
+
+ DocumentUndo::done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
+ _("Move item down"));
+
+ _store->foreach_iter(sigc::bind<int*>(sigc::mem_fun(*this, &OriginalItemArrayParam::_selectIndex), &i));
+ }
+}
+
+void OriginalItemArrayParam::on_remove_button_click()
+{
+ Gtk::TreeModel::iterator iter = _tree.get_selection()->get_selected();
+ if (iter) {
+ Gtk::TreeModel::Row row = *iter;
+ remove_link(row[_model->_colObject]);
+
+ gchar * full = param_getSVGValue();
+ param_write_to_repr(full);
+ g_free(full);
+
+ DocumentUndo::done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
+ _("Remove item"));
+ }
+
+}
+
+void
+OriginalItemArrayParam::on_link_button_click()
+{
+ Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
+ //without second parameter populate all elements filled inside the called function
+ std::vector<Glib::ustring> itemsid = cm->getElementsOfType(SP_ACTIVE_DESKTOP);
+
+ if (itemsid.empty()) {
+ return;
+ }
+
+ bool foundOne = false;
+ Inkscape::SVGOStringStream os;
+ for (std::vector<ItemAndActive*>::const_iterator iter = _vector.begin(); iter != _vector.end(); ++iter) {
+ if (foundOne) {
+ os << "|";
+ } else {
+ foundOne = true;
+ }
+ os << (*iter)->href << "," << ((*iter)->actived ? "1" : "0");
+ }
+ for (auto i=itemsid.begin();i!=itemsid.end();++i) {
+ Glib::ustring itemid = *i;
+ // add '#' at start to make it an uri.
+ itemid.insert(itemid.begin(), '#');
+
+ if (foundOne) {
+ os << "|";
+ } else {
+ foundOne = true;
+ }
+ os << itemid.c_str() << ",1";
+ }
+ param_write_to_repr(os.str().c_str());
+ DocumentUndo::done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
+ _("Link itemarray parameter to item"));
+}
+
+void OriginalItemArrayParam::unlink(ItemAndActive* to)
+{
+ to->linked_modified_connection.disconnect();
+ to->linked_delete_connection.disconnect();
+ to->ref.detach();
+ if (to->href) {
+ g_free(to->href);
+ to->href = NULL;
+ }
+}
+
+void OriginalItemArrayParam::remove_link(ItemAndActive* to)
+{
+ unlink(to);
+ for (std::vector<ItemAndActive*>::iterator iter = _vector.begin(); iter != _vector.end(); ++iter) {
+ if (*iter == to) {
+ ItemAndActive *w = *iter;
+ _vector.erase(iter);
+ delete w;
+ return;
+ }
+ }
+}
+
+void OriginalItemArrayParam::linked_delete(SPObject */*deleted*/, ItemAndActive* /*to*/)
+{
+ //remove_link(to);
+
+ gchar * full = param_getSVGValue();
+ param_write_to_repr(full);
+ g_free(full);
+}
+
+bool OriginalItemArrayParam::_updateLink(const Gtk::TreeIter& iter, ItemAndActive* pd)
+{
+ Gtk::TreeModel::Row row = *iter;
+ if (row[_model->_colObject] == pd) {
+ SPObject *obj = pd->ref.getObject();
+ row[_model->_colLabel] = obj && obj->getId() ? ( obj->label() ? obj->label() : obj->getId() ) : pd->href;
+ return true;
+ }
+ return false;
+}
+
+void OriginalItemArrayParam::linked_changed(SPObject */*old_obj*/, SPObject *new_obj, ItemAndActive* to)
+{
+ to->linked_delete_connection.disconnect();
+ to->linked_modified_connection.disconnect();
+ to->linked_transformed_connection.disconnect();
+
+ if (new_obj && SP_IS_ITEM(new_obj)) {
+ to->linked_delete_connection = new_obj->connectDelete(sigc::bind<ItemAndActive*>(sigc::mem_fun(*this, &OriginalItemArrayParam::linked_delete), to));
+ to->linked_modified_connection = new_obj->connectModified(sigc::bind<ItemAndActive*>(sigc::mem_fun(*this, &OriginalItemArrayParam::linked_modified), to));
+ to->linked_transformed_connection = SP_ITEM(new_obj)->connectTransformed(sigc::bind<ItemAndActive*>(sigc::mem_fun(*this, &OriginalItemArrayParam::linked_transformed), to));
+
+ linked_modified(new_obj, SP_OBJECT_MODIFIED_FLAG, to);
+ } else {
+ SP_OBJECT(param_effect->getLPEObj())->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ _store->foreach_iter(sigc::bind<ItemAndActive*>(sigc::mem_fun(*this, &OriginalItemArrayParam::_updateLink), to));
+ }
+}
+
+void OriginalItemArrayParam::linked_modified(SPObject *linked_obj, guint flags, ItemAndActive* to)
+{
+ if (!to) {
+ return;
+ }
+ SP_OBJECT(param_effect->getLPEObj())->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ _store->foreach_iter(sigc::bind<ItemAndActive*>(sigc::mem_fun(*this, &OriginalItemArrayParam::_updateLink), to));
+}
+
+bool OriginalItemArrayParam::param_readSVGValue(const gchar* strvalue)
+{
+ if (strvalue) {
+ while (!_vector.empty()) {
+ ItemAndActive *w = _vector.back();
+ unlink(w);
+ _vector.pop_back();
+ delete w;
+ }
+ _store->clear();
+
+ gchar ** strarray = g_strsplit(strvalue, "|", 0);
+ for (gchar ** iter = strarray; *iter != NULL; iter++) {
+ if ((*iter)[0] == '#') {
+ gchar ** substrarray = g_strsplit(*iter, ",", 0);
+ ItemAndActive* w = new ItemAndActive((SPObject *)param_effect->getLPEObj());
+ w->href = g_strdup(*substrarray);
+ w->actived = *(substrarray+1) != NULL && (*(substrarray+1))[0] == '1';
+ w->linked_changed_connection = w->ref.changedSignal().connect(sigc::bind<ItemAndActive *>(sigc::mem_fun(*this, &OriginalItemArrayParam::linked_changed), w));
+ w->ref.attach(URI(w->href));
+
+ _vector.push_back(w);
+
+ Gtk::TreeModel::iterator iter = _store->append();
+ Gtk::TreeModel::Row row = *iter;
+ SPObject *obj = w->ref.getObject();
+
+ row[_model->_colObject] = w;
+ row[_model->_colLabel] = obj ? ( obj->label() ? obj->label() : obj->getId() ) : w->href;
+ row[_model->_colActive] = w->actived;
+ g_strfreev (substrarray);
+ }
+ }
+ g_strfreev (strarray);
+ return true;
+ }
+ return false;
+}
+
+gchar * OriginalItemArrayParam::param_getSVGValue() const
+{
+ Inkscape::SVGOStringStream os;
+ bool foundOne = false;
+ for (std::vector<ItemAndActive*>::const_iterator iter = _vector.begin(); iter != _vector.end(); ++iter) {
+ if (foundOne) {
+ os << "|";
+ } else {
+ foundOne = true;
+ }
+ os << (*iter)->href << "," << ((*iter)->actived ? "1" : "0");
+ }
+ gchar * str = g_strdup(os.str().c_str());
+ return str;
+}
+
+gchar * OriginalItemArrayParam::param_getDefaultSVGValue() const
+{
+ return g_strdup("");
+}
+
+void OriginalItemArrayParam::update()
+{
+ for (std::vector<ItemAndActive*>::iterator iter = _vector.begin(); iter != _vector.end(); ++iter) {
+ SPObject *linked_obj = (*iter)->ref.getObject();
+ linked_modified(linked_obj, SP_OBJECT_MODIFIED_FLAG, *iter);
+ }
+}
+
+} /* namespace LivePathEffect */
+
+} /* namespace Inkscape */
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/live_effects/parameter/originalitemarray.h b/src/live_effects/parameter/originalitemarray.h
new file mode 100644
index 000000000..f93d865ec
--- /dev/null
+++ b/src/live_effects/parameter/originalitemarray.h
@@ -0,0 +1,122 @@
+#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_ORIGINALITEMARRAY_H
+#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_ORIGINALITEMARRAY_H
+
+/*
+ * Inkscape::LivePathEffectParameters
+ *
+ * Copyright (C) Theodore Janeczko 2012 <flutterguy317@gmail.com>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include <vector>
+
+#include <gtkmm/box.h>
+#include <gtkmm/treeview.h>
+#include <gtkmm/treestore.h>
+#include <gtkmm/scrolledwindow.h>
+
+#include "live_effects/parameter/parameter.h"
+#include "live_effects/parameter/item-reference.h"
+
+#include "svg/svg.h"
+#include "svg/stringstream.h"
+#include "item-reference.h"
+#include "sp-object.h"
+
+namespace Inkscape {
+
+namespace LivePathEffect {
+
+class ItemAndActive {
+public:
+ ItemAndActive(SPObject *owner)
+ : href(NULL),
+ ref(owner),
+ actived(true)
+ {
+
+ }
+ gchar *href;
+ URIReference ref;
+ bool actived;
+
+ sigc::connection linked_changed_connection;
+ sigc::connection linked_delete_connection;
+ sigc::connection linked_modified_connection;
+ sigc::connection linked_transformed_connection;
+};
+
+class OriginalItemArrayParam : public Parameter {
+public:
+ class ModelColumns;
+
+ OriginalItemArrayParam( const Glib::ustring& label,
+ const Glib::ustring& tip,
+ const Glib::ustring& key,
+ Inkscape::UI::Widget::Registry* wr,
+ Effect* effect);
+
+ virtual ~OriginalItemArrayParam();
+
+ virtual Gtk::Widget * param_newWidget();
+ virtual bool param_readSVGValue(const gchar * strvalue);
+ virtual gchar * param_getSVGValue() const;
+ virtual gchar * param_getDefaultSVGValue() const;
+ virtual void param_set_default();
+ virtual void param_update_default(const gchar * default_value){};
+ /** Disable the canvas indicators of parent class by overriding this method */
+ virtual void param_editOncanvas(SPItem * /*item*/, SPDesktop * /*dt*/) {};
+ /** Disable the canvas indicators of parent class by overriding this method */
+ virtual void addCanvasIndicators(SPLPEItem const* /*lpeitem*/, std::vector<Geom::PathVector> & /*hp_vec*/) {};
+
+ std::vector<ItemAndActive*> _vector;
+
+protected:
+ bool _updateLink(const Gtk::TreeIter& iter, ItemAndActive* pd);
+ bool _selectIndex(const Gtk::TreeIter& iter, int* i);
+ void unlink(ItemAndActive* to);
+ void remove_link(ItemAndActive* to);
+ void setItem(SPObject *linked_obj, guint flags, ItemAndActive* to);
+
+ void linked_changed(SPObject *old_obj, SPObject *new_obj, ItemAndActive* to);
+ void linked_modified(SPObject *linked_obj, guint flags, ItemAndActive* to);
+ void linked_transformed(Geom::Affine const *, SPItem *, ItemAndActive*) {}
+ void linked_delete(SPObject *deleted, ItemAndActive* to);
+
+ ModelColumns *_model;
+ Glib::RefPtr<Gtk::TreeStore> _store;
+ Gtk::TreeView _tree;
+ Gtk::CellRendererText *_text_renderer;
+ Gtk::CellRendererToggle *_toggle_active;
+ Gtk::TreeView::Column *_name_column;
+ Gtk::ScrolledWindow _scroller;
+
+ void on_link_button_click();
+ void on_remove_button_click();
+ void on_up_button_click();
+ void on_down_button_click();
+ void on_active_toggled(const Glib::ustring& item);
+
+private:
+ void update();
+ OriginalItemArrayParam(const OriginalItemArrayParam&);
+ OriginalItemArrayParam& operator=(const OriginalItemArrayParam&);
+};
+
+} //namespace LivePathEffect
+
+} //namespace Inkscape
+
+#endif
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/live_effects/parameter/originalpath.cpp b/src/live_effects/parameter/originalpath.cpp
index 62483d7fb..3f833d2ac 100644
--- a/src/live_effects/parameter/originalpath.cpp
+++ b/src/live_effects/parameter/originalpath.cpp
@@ -36,6 +36,7 @@ OriginalPathParam::OriginalPathParam( const Glib::ustring& label, const Glib::us
: PathParam(label, tip, key, wr, effect, "")
{
oncanvas_editable = false;
+ _from_original_d = false;
}
OriginalPathParam::~OriginalPathParam()
@@ -90,7 +91,11 @@ OriginalPathParam::linked_modified_callback(SPObject *linked_obj, guint /*flags*
{
SPCurve *curve = NULL;
if (SP_IS_SHAPE(linked_obj)) {
- curve = SP_SHAPE(linked_obj)->getCurve();
+ if (_from_original_d) {
+ curve = SP_SHAPE(linked_obj)->getCurveBeforeLPE();
+ } else {
+ curve = SP_SHAPE(linked_obj)->getCurve();
+ }
}
if (SP_IS_TEXT(linked_obj)) {
curve = SP_TEXT(linked_obj)->getNormalizedBpath();
diff --git a/src/live_effects/parameter/originalpath.h b/src/live_effects/parameter/originalpath.h
index b3feec41f..ec80d1026 100644
--- a/src/live_effects/parameter/originalpath.h
+++ b/src/live_effects/parameter/originalpath.h
@@ -32,6 +32,7 @@ public:
virtual void param_editOncanvas(SPItem * /*item*/, SPDesktop * /*dt*/) {};
/** Disable the canvas indicators of parent class by overriding this method */
virtual void addCanvasIndicators(SPLPEItem const* /*lpeitem*/, std::vector<Geom::PathVector> & /*hp_vec*/) {};
+ void setFromOriginalD(bool from_original_d){ _from_original_d = from_original_d; };
protected:
virtual void linked_modified_callback(SPObject *linked_obj, guint flags);
@@ -40,6 +41,7 @@ protected:
void on_select_original_button_click();
private:
+ bool _from_original_d;
OriginalPathParam(const OriginalPathParam&);
OriginalPathParam& operator=(const OriginalPathParam&);
};
diff --git a/src/live_effects/parameter/originalpatharray.cpp b/src/live_effects/parameter/originalpatharray.cpp
index 92859de05..a98c91770 100644
--- a/src/live_effects/parameter/originalpatharray.cpp
+++ b/src/live_effects/parameter/originalpatharray.cpp
@@ -9,6 +9,10 @@
#endif
#include "live_effects/parameter/originalpatharray.h"
+#include "live_effects/lpe-spiro.h"
+#include "live_effects/lpe-bspline.h"
+#include "live_effects/lpeobject.h"
+#include "live_effects/lpeobject-reference.h"
#include <gtkmm/widget.h>
#include <gtkmm/icontheme.h>
@@ -19,7 +23,6 @@
#include <glibmm/i18n.h>
#include "inkscape.h"
-#include "icon-size.h"
#include "ui/clipboard.h"
#include "svg/svg.h"
#include "svg/stringstream.h"
@@ -50,12 +53,14 @@ public:
add(_colObject);
add(_colLabel);
add(_colReverse);
+ add(_colVisible);
}
virtual ~ModelColumns() {}
- Gtk::TreeModelColumn<PathAndDirection*> _colObject;
+ Gtk::TreeModelColumn<PathAndDirectionAndVisible*> _colObject;
Gtk::TreeModelColumn<Glib::ustring> _colLabel;
Gtk::TreeModelColumn<bool> _colReverse;
+ Gtk::TreeModelColumn<bool> _colVisible;
};
OriginalPathArrayParam::OriginalPathArrayParam( const Glib::ustring& label,
@@ -67,7 +72,8 @@ OriginalPathArrayParam::OriginalPathArrayParam( const Glib::ustring& label,
_vector(),
_tree(),
_text_renderer(),
- _toggle_renderer(),
+ _toggle_reverse(),
+ _toggle_visible(),
_scroller()
{
_model = new ModelColumns();
@@ -77,6 +83,22 @@ OriginalPathArrayParam::OriginalPathArrayParam( const Glib::ustring& label,
_tree.set_reorderable(true);
_tree.enable_model_drag_dest (Gdk::ACTION_MOVE);
+
+ Gtk::CellRendererToggle * _toggle_reverse = manage(new Gtk::CellRendererToggle());
+ int reverseColNum = _tree.append_column(_("Reverse"), *_toggle_reverse) - 1;
+ Gtk::TreeViewColumn* col_reverse = _tree.get_column(reverseColNum);
+ _toggle_reverse->set_activatable(true);
+ _toggle_reverse->signal_toggled().connect(sigc::mem_fun(*this, &OriginalPathArrayParam::on_reverse_toggled));
+ col_reverse->add_attribute(_toggle_reverse->property_active(), _model->_colReverse);
+
+
+ Gtk::CellRendererToggle * _toggle_visible = manage(new Gtk::CellRendererToggle());
+ int visibleColNum = _tree.append_column(_("Visible"), *_toggle_visible) - 1;
+ Gtk::TreeViewColumn* col_visible = _tree.get_column(visibleColNum);
+ _toggle_visible->set_activatable(true);
+ _toggle_visible->signal_toggled().connect(sigc::mem_fun(*this, &OriginalPathArrayParam::on_visible_toggled));
+ col_visible->add_attribute(_toggle_visible->property_active(), _model->_colVisible);
+
_text_renderer = manage(new Gtk::CellRendererText());
int nameColNum = _tree.append_column(_("Name"), *_text_renderer) - 1;
_name_column = _tree.get_column(nameColNum);
@@ -85,13 +107,6 @@ OriginalPathArrayParam::OriginalPathArrayParam( const Glib::ustring& label,
_tree.set_expander_column( *_tree.get_column(nameColNum) );
_tree.set_search_column(_model->_colLabel);
- Gtk::CellRendererToggle * _toggle_renderer = manage(new Gtk::CellRendererToggle());
- int toggleColNum = _tree.append_column(_("Reverse"), *_toggle_renderer) - 1;
- Gtk::TreeViewColumn* col = _tree.get_column(toggleColNum);
- _toggle_renderer->set_activatable(true);
- _toggle_renderer->signal_toggled().connect(sigc::mem_fun(*this, &OriginalPathArrayParam::on_reverse_toggled));
- col->add_attribute(_toggle_renderer->property_active(), _model->_colReverse);
-
//quick little hack -- newer versions of gtk gave the item zero space allotment
_scroller.set_size_request(-1, 120);
@@ -100,13 +115,15 @@ OriginalPathArrayParam::OriginalPathArrayParam( const Glib::ustring& label,
//_scroller.set_shadow_type(Gtk::SHADOW_IN);
oncanvas_editable = true;
+ _from_original_d = false;
+ _allow_only_bspline_spiro = false;
}
OriginalPathArrayParam::~OriginalPathArrayParam()
{
while (!_vector.empty()) {
- PathAndDirection *w = _vector.back();
+ PathAndDirectionAndVisible *w = _vector.back();
_vector.pop_back();
unlink(w);
delete w;
@@ -118,7 +135,7 @@ void OriginalPathArrayParam::on_reverse_toggled(const Glib::ustring& path)
{
Gtk::TreeModel::iterator iter = _store->get_iter(path);
Gtk::TreeModel::Row row = *iter;
- PathAndDirection *w = row[_model->_colObject];
+ PathAndDirectionAndVisible *w = row[_model->_colObject];
row[_model->_colReverse] = !row[_model->_colReverse];
w->reversed = row[_model->_colReverse];
@@ -129,6 +146,21 @@ void OriginalPathArrayParam::on_reverse_toggled(const Glib::ustring& path)
_("Link path parameter to path"));
}
+void OriginalPathArrayParam::on_visible_toggled(const Glib::ustring& path)
+{
+ Gtk::TreeModel::iterator iter = _store->get_iter(path);
+ Gtk::TreeModel::Row row = *iter;
+ PathAndDirectionAndVisible *w = row[_model->_colObject];
+ row[_model->_colVisible] = !row[_model->_colVisible];
+ w->visibled = row[_model->_colVisible];
+
+ gchar * full = param_getSVGValue();
+ param_write_to_repr(full);
+ g_free(full);
+ DocumentUndo::done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
+ _("Toggle path parameter to path"));
+}
+
void OriginalPathArrayParam::param_set_default()
{
@@ -217,8 +249,8 @@ void OriginalPathArrayParam::on_up_button_click()
Gtk::TreeModel::Row row = *iter;
int i = -1;
- std::vector<PathAndDirection*>::iterator piter = _vector.begin();
- for (std::vector<PathAndDirection*>::iterator iter = _vector.begin(); iter != _vector.end(); piter = iter, i++, ++iter) {
+ std::vector<PathAndDirectionAndVisible*>::iterator piter = _vector.begin();
+ for (std::vector<PathAndDirectionAndVisible*>::iterator iter = _vector.begin(); iter != _vector.end(); piter = iter, i++, ++iter) {
if (*iter == row[_model->_colObject]) {
_vector.erase(iter);
_vector.insert(piter, row[_model->_colObject]);
@@ -244,9 +276,9 @@ void OriginalPathArrayParam::on_down_button_click()
Gtk::TreeModel::Row row = *iter;
int i = 0;
- for (std::vector<PathAndDirection*>::iterator iter = _vector.begin(); iter != _vector.end(); i++, ++iter) {
+ for (std::vector<PathAndDirectionAndVisible*>::iterator iter = _vector.begin(); iter != _vector.end(); i++, ++iter) {
if (*iter == row[_model->_colObject]) {
- std::vector<PathAndDirection*>::iterator niter = _vector.erase(iter);
+ std::vector<PathAndDirectionAndVisible*>::iterator niter = _vector.erase(iter);
if (niter != _vector.end()) {
++niter;
i++;
@@ -288,37 +320,40 @@ void
OriginalPathArrayParam::on_link_button_click()
{
Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
- Glib::ustring pathid = cm->getShapeOrTextObjectId(SP_ACTIVE_DESKTOP);
-
- if (pathid == "") {
+ std::vector<Glib::ustring> pathsid = cm->getElementsOfType(SP_ACTIVE_DESKTOP, "svg:path");
+ std::vector<Glib::ustring> textsid = cm->getElementsOfType(SP_ACTIVE_DESKTOP, "svg:text");
+ pathsid.insert(pathsid.end(), textsid.begin(), textsid.end());
+ if (pathsid.empty()) {
return;
}
- // add '#' at start to make it an uri.
- pathid.insert(pathid.begin(), '#');
-
- Inkscape::SVGOStringStream os;
bool foundOne = false;
- for (std::vector<PathAndDirection*>::const_iterator iter = _vector.begin(); iter != _vector.end(); ++iter) {
+ Inkscape::SVGOStringStream os;
+ for (std::vector<PathAndDirectionAndVisible*>::const_iterator iter = _vector.begin(); iter != _vector.end(); ++iter) {
if (foundOne) {
os << "|";
} else {
foundOne = true;
}
- os << (*iter)->href << "," << ((*iter)->reversed ? "1" : "0");
+ os << (*iter)->href << "," << ((*iter)->reversed ? "1" : "0") << "," << ((*iter)->visibled ? "1" : "0");
}
-
- if (foundOne) {
- os << "|";
+ for (auto i=pathsid.begin();i!=pathsid.end();++i) {
+ Glib::ustring pathid = *i;
+ // add '#' at start to make it an uri.
+ pathid.insert(pathid.begin(), '#');
+
+ if (foundOne) {
+ os << "|";
+ } else {
+ foundOne = true;
+ }
+ os << pathid.c_str() << ",0,1";
}
-
- os << pathid.c_str() << ",0";
-
param_write_to_repr(os.str().c_str());
DocumentUndo::done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
- _("Link path parameter to path"));
+ _("Link patharray parameter to path"));
}
-void OriginalPathArrayParam::unlink(PathAndDirection* to)
+void OriginalPathArrayParam::unlink(PathAndDirectionAndVisible* to)
{
to->linked_modified_connection.disconnect();
to->linked_delete_connection.disconnect();
@@ -327,15 +362,15 @@ void OriginalPathArrayParam::unlink(PathAndDirection* to)
if (to->href) {
g_free(to->href);
to->href = NULL;
- }
+ }
}
-void OriginalPathArrayParam::remove_link(PathAndDirection* to)
+void OriginalPathArrayParam::remove_link(PathAndDirectionAndVisible* to)
{
unlink(to);
- for (std::vector<PathAndDirection*>::iterator iter = _vector.begin(); iter != _vector.end(); ++iter) {
+ for (std::vector<PathAndDirectionAndVisible*>::iterator iter = _vector.begin(); iter != _vector.end(); ++iter) {
if (*iter == to) {
- PathAndDirection *w = *iter;
+ PathAndDirectionAndVisible *w = *iter;
_vector.erase(iter);
delete w;
return;
@@ -343,7 +378,7 @@ void OriginalPathArrayParam::remove_link(PathAndDirection* to)
}
}
-void OriginalPathArrayParam::linked_delete(SPObject */*deleted*/, PathAndDirection* /*to*/)
+void OriginalPathArrayParam::linked_delete(SPObject */*deleted*/, PathAndDirectionAndVisible* /*to*/)
{
//remove_link(to);
@@ -352,7 +387,7 @@ void OriginalPathArrayParam::linked_delete(SPObject */*deleted*/, PathAndDirecti
g_free(full);
}
-bool OriginalPathArrayParam::_updateLink(const Gtk::TreeIter& iter, PathAndDirection* pd)
+bool OriginalPathArrayParam::_updateLink(const Gtk::TreeIter& iter, PathAndDirectionAndVisible* pd)
{
Gtk::TreeModel::Row row = *iter;
if (row[_model->_colObject] == pd) {
@@ -363,35 +398,54 @@ bool OriginalPathArrayParam::_updateLink(const Gtk::TreeIter& iter, PathAndDirec
return false;
}
-void OriginalPathArrayParam::linked_changed(SPObject */*old_obj*/, SPObject *new_obj, PathAndDirection* to)
+void OriginalPathArrayParam::linked_changed(SPObject */*old_obj*/, SPObject *new_obj, PathAndDirectionAndVisible* to)
{
to->linked_delete_connection.disconnect();
to->linked_modified_connection.disconnect();
to->linked_transformed_connection.disconnect();
if (new_obj && SP_IS_ITEM(new_obj)) {
- to->linked_delete_connection = new_obj->connectDelete(sigc::bind<PathAndDirection*>(sigc::mem_fun(*this, &OriginalPathArrayParam::linked_delete), to));
- to->linked_modified_connection = new_obj->connectModified(sigc::bind<PathAndDirection*>(sigc::mem_fun(*this, &OriginalPathArrayParam::linked_modified), to));
- to->linked_transformed_connection = SP_ITEM(new_obj)->connectTransformed(sigc::bind<PathAndDirection*>(sigc::mem_fun(*this, &OriginalPathArrayParam::linked_transformed), to));
+ to->linked_delete_connection = new_obj->connectDelete(sigc::bind<PathAndDirectionAndVisible*>(sigc::mem_fun(*this, &OriginalPathArrayParam::linked_delete), to));
+ to->linked_modified_connection = new_obj->connectModified(sigc::bind<PathAndDirectionAndVisible*>(sigc::mem_fun(*this, &OriginalPathArrayParam::linked_modified), to));
+ to->linked_transformed_connection = SP_ITEM(new_obj)->connectTransformed(sigc::bind<PathAndDirectionAndVisible*>(sigc::mem_fun(*this, &OriginalPathArrayParam::linked_transformed), to));
linked_modified(new_obj, SP_OBJECT_MODIFIED_FLAG, to);
} else {
to->_pathvector = Geom::PathVector();
SP_OBJECT(param_effect->getLPEObj())->requestModified(SP_OBJECT_MODIFIED_FLAG);
- _store->foreach_iter(sigc::bind<PathAndDirection*>(sigc::mem_fun(*this, &OriginalPathArrayParam::_updateLink), to));
+ _store->foreach_iter(sigc::bind<PathAndDirectionAndVisible*>(sigc::mem_fun(*this, &OriginalPathArrayParam::_updateLink), to));
}
}
-void OriginalPathArrayParam::setPathVector(SPObject *linked_obj, guint /*flags*/, PathAndDirection* to)
+void OriginalPathArrayParam::setPathVector(SPObject *linked_obj, guint /*flags*/, PathAndDirectionAndVisible* to)
{
if (!to) {
return;
}
SPCurve *curve = NULL;
if (SP_IS_SHAPE(linked_obj)) {
- curve = SP_SHAPE(linked_obj)->getCurve();
- }
- if (SP_IS_TEXT(linked_obj)) {
+ SPLPEItem * lpe_item = SP_LPE_ITEM(linked_obj);
+ if (_from_original_d) {
+ curve = SP_SHAPE(linked_obj)->getCurveBeforeLPE();
+ } else if (_allow_only_bspline_spiro && lpe_item && lpe_item->hasPathEffect()){
+ curve = SP_SHAPE(linked_obj)->getCurveBeforeLPE();
+ PathEffectList lpelist = lpe_item->getEffectList();
+ PathEffectList::iterator i;
+ for (i = lpelist.begin(); i != lpelist.end(); ++i) {
+ LivePathEffectObject *lpeobj = (*i)->lpeobject;
+ if (lpeobj) {
+ Inkscape::LivePathEffect::Effect *lpe = lpeobj->get_lpe();
+ if (dynamic_cast<Inkscape::LivePathEffect::LPEBSpline *>(lpe)) {
+ LivePathEffect::sp_bspline_do_effect(curve, 0);
+ } else if (dynamic_cast<Inkscape::LivePathEffect::LPESpiro *>(lpe)) {
+ LivePathEffect::sp_spiro_do_effect(curve);
+ }
+ }
+ }
+ } else {
+ curve = SP_SHAPE(linked_obj)->getCurve();
+ }
+ } else if (SP_IS_TEXT(linked_obj)) {
curve = SP_TEXT(linked_obj)->getNormalizedBpath();
}
@@ -404,21 +458,21 @@ void OriginalPathArrayParam::setPathVector(SPObject *linked_obj, guint /*flags*/
}
}
-void OriginalPathArrayParam::linked_modified(SPObject *linked_obj, guint flags, PathAndDirection* to)
+void OriginalPathArrayParam::linked_modified(SPObject *linked_obj, guint flags, PathAndDirectionAndVisible* to)
{
if (!to) {
return;
}
setPathVector(linked_obj, flags, to);
SP_OBJECT(param_effect->getLPEObj())->requestModified(SP_OBJECT_MODIFIED_FLAG);
- _store->foreach_iter(sigc::bind<PathAndDirection*>(sigc::mem_fun(*this, &OriginalPathArrayParam::_updateLink), to));
+ _store->foreach_iter(sigc::bind<PathAndDirectionAndVisible*>(sigc::mem_fun(*this, &OriginalPathArrayParam::_updateLink), to));
}
bool OriginalPathArrayParam::param_readSVGValue(const gchar* strvalue)
{
if (strvalue) {
while (!_vector.empty()) {
- PathAndDirection *w = _vector.back();
+ PathAndDirectionAndVisible *w = _vector.back();
unlink(w);
_vector.pop_back();
delete w;
@@ -429,11 +483,12 @@ bool OriginalPathArrayParam::param_readSVGValue(const gchar* strvalue)
for (gchar ** iter = strarray; *iter != NULL; iter++) {
if ((*iter)[0] == '#') {
gchar ** substrarray = g_strsplit(*iter, ",", 0);
- PathAndDirection* w = new PathAndDirection((SPObject *)param_effect->getLPEObj());
+ PathAndDirectionAndVisible* w = new PathAndDirectionAndVisible((SPObject *)param_effect->getLPEObj());
w->href = g_strdup(*substrarray);
w->reversed = *(substrarray+1) != NULL && (*(substrarray+1))[0] == '1';
-
- w->linked_changed_connection = w->ref.changedSignal().connect(sigc::bind<PathAndDirection *>(sigc::mem_fun(*this, &OriginalPathArrayParam::linked_changed), w));
+ //Like this to make backwards compatible, new value added in 0.93
+ w->visibled = *(substrarray+2) == NULL || (*(substrarray+2))[0] == '1';
+ w->linked_changed_connection = w->ref.changedSignal().connect(sigc::bind<PathAndDirectionAndVisible *>(sigc::mem_fun(*this, &OriginalPathArrayParam::linked_changed), w));
w->ref.attach(URI(w->href));
_vector.push_back(w);
@@ -445,6 +500,7 @@ bool OriginalPathArrayParam::param_readSVGValue(const gchar* strvalue)
row[_model->_colObject] = w;
row[_model->_colLabel] = obj ? ( obj->label() ? obj->label() : obj->getId() ) : w->href;
row[_model->_colReverse] = w->reversed;
+ row[_model->_colVisible] = w->visibled;
g_strfreev (substrarray);
}
}
@@ -458,18 +514,31 @@ gchar * OriginalPathArrayParam::param_getSVGValue() const
{
Inkscape::SVGOStringStream os;
bool foundOne = false;
- for (std::vector<PathAndDirection*>::const_iterator iter = _vector.begin(); iter != _vector.end(); ++iter) {
+ for (std::vector<PathAndDirectionAndVisible*>::const_iterator iter = _vector.begin(); iter != _vector.end(); ++iter) {
if (foundOne) {
os << "|";
} else {
foundOne = true;
}
- os << (*iter)->href << "," << ((*iter)->reversed ? "1" : "0");
+ os << (*iter)->href << "," << ((*iter)->reversed ? "1" : "0") << "," << ((*iter)->visibled ? "1" : "0");
}
gchar * str = g_strdup(os.str().c_str());
return str;
}
+gchar * OriginalPathArrayParam::param_getDefaultSVGValue() const
+{
+ return "";
+}
+
+void OriginalPathArrayParam::update()
+{
+ for (std::vector<PathAndDirectionAndVisible*>::iterator iter = _vector.begin(); iter != _vector.end(); ++iter) {
+ SPObject *linked_obj = (*iter)->ref.getObject();
+ linked_modified(linked_obj, SP_OBJECT_MODIFIED_FLAG, *iter);
+ }
+}
+
} /* namespace LivePathEffect */
} /* namespace Inkscape */
diff --git a/src/live_effects/parameter/originalpatharray.h b/src/live_effects/parameter/originalpatharray.h
index fe9371644..c80d5daf3 100644
--- a/src/live_effects/parameter/originalpatharray.h
+++ b/src/live_effects/parameter/originalpatharray.h
@@ -28,13 +28,14 @@ namespace Inkscape {
namespace LivePathEffect {
-class PathAndDirection {
+class PathAndDirectionAndVisible {
public:
- PathAndDirection(SPObject *owner)
+ PathAndDirectionAndVisible(SPObject *owner)
: href(NULL),
ref(owner),
_pathvector(Geom::PathVector()),
- reversed(false)
+ reversed(false),
+ visibled(true)
{
}
@@ -42,6 +43,7 @@ public:
URIReference ref;
Geom::PathVector _pathvector;
bool reversed;
+ bool visibled;
sigc::connection linked_changed_connection;
sigc::connection linked_delete_connection;
@@ -64,31 +66,36 @@ public:
virtual Gtk::Widget * param_newWidget();
virtual bool param_readSVGValue(const gchar * strvalue);
virtual gchar * param_getSVGValue() const;
+ virtual gchar * param_getDefaultSVGValue() const;
virtual void param_set_default();
virtual void param_update_default(const gchar * default_value){};
/** Disable the canvas indicators of parent class by overriding this method */
virtual void param_editOncanvas(SPItem * /*item*/, SPDesktop * /*dt*/) {};
/** Disable the canvas indicators of parent class by overriding this method */
virtual void addCanvasIndicators(SPLPEItem const* /*lpeitem*/, std::vector<Geom::PathVector> & /*hp_vec*/) {};
- std::vector<PathAndDirection*> _vector;
-
+ void setFromOriginalD(bool from_original_d){ _from_original_d = from_original_d; update();};
+ void allowOnlyBsplineSpiro(bool allow_only_bspline_spiro){ _allow_only_bspline_spiro = allow_only_bspline_spiro; update();};
+
+ std::vector<PathAndDirectionAndVisible*> _vector;
+
protected:
- bool _updateLink(const Gtk::TreeIter& iter, PathAndDirection* pd);
+ bool _updateLink(const Gtk::TreeIter& iter, PathAndDirectionAndVisible* pd);
bool _selectIndex(const Gtk::TreeIter& iter, int* i);
- void unlink(PathAndDirection* to);
- void remove_link(PathAndDirection* to);
- void setPathVector(SPObject *linked_obj, guint flags, PathAndDirection* to);
+ void unlink(PathAndDirectionAndVisible* to);
+ void remove_link(PathAndDirectionAndVisible* to);
+ void setPathVector(SPObject *linked_obj, guint flags, PathAndDirectionAndVisible* to);
- void linked_changed(SPObject *old_obj, SPObject *new_obj, PathAndDirection* to);
- void linked_modified(SPObject *linked_obj, guint flags, PathAndDirection* to);
- void linked_transformed(Geom::Affine const *, SPItem *, PathAndDirection*) {}
- void linked_delete(SPObject *deleted, PathAndDirection* to);
+ void linked_changed(SPObject *old_obj, SPObject *new_obj, PathAndDirectionAndVisible* to);
+ void linked_modified(SPObject *linked_obj, guint flags, PathAndDirectionAndVisible* to);
+ void linked_transformed(Geom::Affine const *, SPItem *, PathAndDirectionAndVisible*) {}
+ void linked_delete(SPObject *deleted, PathAndDirectionAndVisible* to);
ModelColumns *_model;
Glib::RefPtr<Gtk::TreeStore> _store;
Gtk::TreeView _tree;
Gtk::CellRendererText *_text_renderer;
- Gtk::CellRendererToggle *_toggle_renderer;
+ Gtk::CellRendererToggle *_toggle_reverse;
+ Gtk::CellRendererToggle *_toggle_visible;
Gtk::TreeView::Column *_name_column;
Gtk::ScrolledWindow _scroller;
@@ -97,8 +104,12 @@ protected:
void on_up_button_click();
void on_down_button_click();
void on_reverse_toggled(const Glib::ustring& path);
+ void on_visible_toggled(const Glib::ustring& path);
private:
+ bool _from_original_d;
+ bool _allow_only_bspline_spiro;
+ void update();
OriginalPathArrayParam(const OriginalPathArrayParam&);
OriginalPathArrayParam& operator=(const OriginalPathArrayParam&);
};
diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp
index 2f73488aa..319ab3fe8 100644
--- a/src/live_effects/parameter/parameter.cpp
+++ b/src/live_effects/parameter/parameter.cpp
@@ -95,6 +95,15 @@ ScalarParam::param_getSVGValue() const
return str;
}
+gchar *
+ScalarParam::param_getDefaultSVGValue() const
+{
+ Inkscape::SVGOStringStream os;
+ os << defvalue;
+ gchar * str = g_strdup(os.str().c_str());
+ return str;
+}
+
void
ScalarParam::param_set_default()
{
diff --git a/src/live_effects/parameter/parameter.h b/src/live_effects/parameter/parameter.h
index 7ab7e30dd..1586ef346 100644
--- a/src/live_effects/parameter/parameter.h
+++ b/src/live_effects/parameter/parameter.h
@@ -57,6 +57,7 @@ public:
virtual bool param_readSVGValue(const gchar * strvalue) = 0; // returns true if new value is valid / accepted.
virtual gchar * param_getSVGValue() const = 0;
+ virtual gchar * param_getDefaultSVGValue() const = 0;
virtual void param_widget_is_visible(bool is_visible) {widget_is_visible = is_visible;}
void write_to_SVG();
@@ -109,6 +110,7 @@ public:
virtual bool param_readSVGValue(const gchar * strvalue);
virtual gchar * param_getSVGValue() const;
+ virtual gchar * param_getDefaultSVGValue() const;
virtual void param_set_default();
void param_update_default(gdouble default_value);
diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp
index ec011b855..bd6608737 100644
--- a/src/live_effects/parameter/path.cpp
+++ b/src/live_effects/parameter/path.cpp
@@ -68,6 +68,7 @@ PathParam::PathParam( const Glib::ustring& label, const Glib::ustring& tip,
defvalue = g_strdup(default_value);
param_readSVGValue(defvalue);
oncanvas_editable = true;
+ _from_original_d = false;
_edit_button = true;
_copy_button = true;
_paste_button = true;
@@ -78,21 +79,24 @@ PathParam::PathParam( const Glib::ustring& label, const Glib::ustring& tip,
PathParam::~PathParam()
{
remove_link();
- using namespace Inkscape::UI;
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- if (desktop) {
- if (tools_isactive(desktop, TOOLS_NODES)) {
- SPItem * item = SP_ACTIVE_DESKTOP->getSelection()->singleItem();
- if (item != NULL) {
- Inkscape::UI::Tools::NodeTool *nt = static_cast<Inkscape::UI::Tools::NodeTool*>(desktop->event_context);
- std::set<ShapeRecord> shapes;
- ShapeRecord r;
- r.item = item;
- shapes.insert(r);
- nt->_multipath->setItems(shapes);
- }
- }
- }
+//TODO: Removed to fix a bug https://bugs.launchpad.net/inkscape/+bug/1716926
+// Maybe wee need to resurrect, not know when this code is added, but seems also not working now in a few test I do.
+// in the future and do a deeper fix in multi-path-manipulator
+// using namespace Inkscape::UI;
+// SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+// if (desktop) {
+// if (tools_isactive(desktop, TOOLS_NODES)) {
+// SPItem * item = SP_ACTIVE_DESKTOP->getSelection()->singleItem();
+// if (item) {
+// Inkscape::UI::Tools::NodeTool *nt = static_cast<Inkscape::UI::Tools::NodeTool*>(desktop->event_context);
+// std::set<ShapeRecord> shapes;
+// ShapeRecord r;
+// r.item = item;
+// shapes.insert(r);
+// nt->_multipath->setItems(shapes);
+// }
+// }
+// }
g_free(defvalue);
}
@@ -169,6 +173,12 @@ PathParam::param_getSVGValue() const
}
}
+gchar *
+PathParam::param_getDefaultSVGValue() const
+{
+ return g_strdup(defvalue);
+}
+
void
PathParam::set_buttons(bool edit_button, bool copy_button, bool paste_button, bool link_button)
{
@@ -444,7 +454,11 @@ PathParam::linked_modified_callback(SPObject *linked_obj, guint /*flags*/)
{
SPCurve *curve = NULL;
if (SP_IS_SHAPE(linked_obj)) {
- curve = SP_SHAPE(linked_obj)->getCurve();
+ if (_from_original_d) {
+ curve = SP_SHAPE(linked_obj)->getCurveBeforeLPE();
+ } else {
+ curve = SP_SHAPE(linked_obj)->getCurve();
+ }
}
if (SP_IS_TEXT(linked_obj)) {
curve = SP_TEXT(linked_obj)->getNormalizedBpath();
diff --git a/src/live_effects/parameter/path.h b/src/live_effects/parameter/path.h
index ff5e4f1b8..635056772 100644
--- a/src/live_effects/parameter/path.h
+++ b/src/live_effects/parameter/path.h
@@ -38,6 +38,7 @@ public:
virtual bool param_readSVGValue(const gchar * strvalue);
virtual gchar * param_getSVGValue() const;
+ virtual gchar * param_getDefaultSVGValue() const;
virtual void param_set_default();
virtual void param_update_default(const gchar * default_value);
@@ -50,6 +51,7 @@ public:
virtual void addCanvasIndicators(SPLPEItem const* lpeitem, std::vector<Geom::PathVector> &hp_vec);
virtual void param_transform_multiply(Geom::Affine const& /*postmul*/, bool /*set*/);
+ void setFromOriginalD(bool from_original_d){ _from_original_d = from_original_d; };
sigc::signal <void> signal_path_pasted;
sigc::signal <void> signal_path_changed;
@@ -91,6 +93,7 @@ protected:
gchar * defvalue;
private:
+ bool _from_original_d;
bool _edit_button;
bool _copy_button;
bool _paste_button;
diff --git a/src/live_effects/parameter/point.cpp b/src/live_effects/parameter/point.cpp
index 331a86f81..da6edf812 100644
--- a/src/live_effects/parameter/point.cpp
+++ b/src/live_effects/parameter/point.cpp
@@ -115,6 +115,15 @@ PointParam::param_getSVGValue() const
return str;
}
+gchar *
+PointParam::param_getDefaultSVGValue() const
+{
+ Inkscape::SVGOStringStream os;
+ os << defvalue;
+ gchar * str = g_strdup(os.str().c_str());
+ return str;
+}
+
void
PointParam::param_transform_multiply(Geom::Affine const& postmul, bool /*set*/)
{
diff --git a/src/live_effects/parameter/point.h b/src/live_effects/parameter/point.h
index a5153ad80..03256f6d0 100644
--- a/src/live_effects/parameter/point.h
+++ b/src/live_effects/parameter/point.h
@@ -38,6 +38,7 @@ public:
bool param_readSVGValue(const gchar * strvalue);
gchar * param_getSVGValue() const;
+ gchar * param_getDefaultSVGValue() const;
inline const gchar *handleTip() const { return handle_tip ? handle_tip : param_tooltip.c_str(); }
void param_setValue(Geom::Point newpoint, bool write = false);
void param_set_default();
diff --git a/src/live_effects/parameter/random.cpp b/src/live_effects/parameter/random.cpp
index b1375adda..c2c1b5440 100644
--- a/src/live_effects/parameter/random.cpp
+++ b/src/live_effects/parameter/random.cpp
@@ -71,6 +71,15 @@ RandomParam::param_getSVGValue() const
return str;
}
+gchar *
+RandomParam::param_getDefaultSVGValue() const
+{
+ Inkscape::SVGOStringStream os;
+ os << defvalue << ';' << defseed;
+ gchar * str = g_strdup(os.str().c_str());
+ return str;
+}
+
void
RandomParam::param_set_default()
{
diff --git a/src/live_effects/parameter/random.h b/src/live_effects/parameter/random.h
index 5fb6027ac..c10473e85 100644
--- a/src/live_effects/parameter/random.h
+++ b/src/live_effects/parameter/random.h
@@ -31,6 +31,7 @@ public:
virtual bool param_readSVGValue(const gchar * strvalue);
virtual gchar * param_getSVGValue() const;
+ virtual gchar * param_getDefaultSVGValue() const;
virtual void param_set_default();
virtual Gtk::Widget * param_newWidget();
diff --git a/src/live_effects/parameter/text.cpp b/src/live_effects/parameter/text.cpp
index f40708917..7e56b2c75 100644
--- a/src/live_effects/parameter/text.cpp
+++ b/src/live_effects/parameter/text.cpp
@@ -9,7 +9,7 @@
*/
#include "ui/widget/registered-widget.h"
-#include <glibmm/i18n.h>
+#include <gtkmm/alignment.h>
#include "live_effects/parameter/text.h"
#include "live_effects/effect.h"
@@ -18,9 +18,10 @@
#include "inkscape.h"
#include "verbs.h"
#include "display/canvas-text.h"
-
#include <2geom/sbasis-geometric.h>
+#include <glibmm/i18n.h>
+
namespace Inkscape {
namespace LivePathEffect {
@@ -115,6 +116,23 @@ TextParam::param_getSVGValue() const
return str;
}
+gchar *
+TextParam::param_getDefaultSVGValue() const
+{
+ Inkscape::SVGOStringStream os;
+ os << defvalue;
+ gchar * str = g_strdup(os.str().c_str());
+ return str;
+}
+
+void
+TextParam::setTextParam(Inkscape::UI::Widget::RegisteredText *rsu)
+{
+ Glib::ustring str(rsu->getText());
+ param_setValue(str);
+ write_to_SVG();
+}
+
Gtk::Widget *
TextParam::param_newWidget()
{
@@ -122,9 +140,16 @@ TextParam::param_newWidget()
param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc()));
rsu->setText(value);
rsu->setProgrammatically = false;
-
rsu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change text parameter"));
- return dynamic_cast<Gtk::Widget *> (rsu);
+ Gtk::Box *text_container = Gtk::manage(new Gtk::Box());
+ Gtk::Button *set = Gtk::manage(new Gtk::Button(Glib::ustring("✔")));
+ set->signal_clicked()
+ .connect(sigc::bind<Inkscape::UI::Widget::RegisteredText *>(sigc::mem_fun(*this, &TextParam::setTextParam),rsu));
+ text_container->pack_start(*rsu, false, false, 2);
+ text_container->pack_start(*set, false, false, 2);
+ Gtk::Widget *return_widg = dynamic_cast<Gtk::Widget *> (text_container);
+ return_widg->set_halign(Gtk::ALIGN_END);
+ return return_widg;
}
void
diff --git a/src/live_effects/parameter/text.h b/src/live_effects/parameter/text.h
index 137f3ee02..a9de26a52 100644
--- a/src/live_effects/parameter/text.h
+++ b/src/live_effects/parameter/text.h
@@ -38,9 +38,11 @@ public:
virtual bool param_readSVGValue(const gchar * strvalue);
virtual gchar * param_getSVGValue() const;
+ virtual gchar * param_getDefaultSVGValue() const;
void param_setValue(Glib::ustring newvalue);
void param_hide_canvas_text();
+ void setTextParam(Inkscape::UI::Widget::RegisteredText *rsu);
virtual void param_set_default();
virtual void param_update_default(const gchar * default_value);
void setPos(Geom::Point pos);
diff --git a/src/live_effects/parameter/togglebutton.cpp b/src/live_effects/parameter/togglebutton.cpp
index 6aad8b3a6..e26884d6a 100644
--- a/src/live_effects/parameter/togglebutton.cpp
+++ b/src/live_effects/parameter/togglebutton.cpp
@@ -59,6 +59,13 @@ ToggleButtonParam::param_getSVGValue() const
return str;
}
+gchar *
+ToggleButtonParam::param_getDefaultSVGValue() const
+{
+ gchar * str = g_strdup(defvalue ? "true" : "false");
+ return str;
+}
+
void
ToggleButtonParam::param_update_default(bool default_value)
{
@@ -140,21 +147,25 @@ ToggleButtonParam::refresh_button()
if(!box_button){
return;
}
- GList * childs = gtk_container_get_children(GTK_CONTAINER(box_button->gobj()));
- guint total_widgets = g_list_length (childs);
+ std::vector<Gtk::Widget*> children = Glib::wrap(GTK_CONTAINER(box_button))->get_children();
if (!param_label.empty()) {
+ Gtk::Label *lab = dynamic_cast<Gtk::Label*>(children[children.size()-1]);
+ if (!lab) return;
if(value || inactive_label.empty()){
- gtk_label_set_text(GTK_LABEL(g_list_nth_data(childs, total_widgets-1)), param_label.c_str());
+ lab->set_text(param_label.c_str());
}else{
- gtk_label_set_text(GTK_LABEL(g_list_nth_data(childs, total_widgets-1)), inactive_label.c_str());
+ lab->set_text(inactive_label.c_str());
}
}
if ( _icon_active ) {
GdkPixbuf * icon_pixbuf = NULL;
+ Gtk::Image *im = dynamic_cast<Gtk::Image*>(children[0]);
+ Gtk::IconSize is(_icon_size);
+ if (!im) return;
if(!value){
- gtk_image_set_from_icon_name (GTK_IMAGE(g_list_nth_data(childs, 0)), _icon_inactive, _icon_size);
+ im->set_from_icon_name(_icon_inactive, is);
} else {
- gtk_image_set_from_icon_name (GTK_IMAGE(g_list_nth_data(childs, 0)), _icon_active, _icon_size);
+ im->set_from_icon_name(_icon_active, is);
}
}
}
diff --git a/src/live_effects/parameter/togglebutton.h b/src/live_effects/parameter/togglebutton.h
index 02b9d5127..c5f8a3c28 100644
--- a/src/live_effects/parameter/togglebutton.h
+++ b/src/live_effects/parameter/togglebutton.h
@@ -12,7 +12,6 @@
#include <sigc++/signal.h>
#include "live_effects/parameter/parameter.h"
-#include "icon-size.h"
#include "ui/widget/registered-widget.h"
namespace Inkscape {
@@ -41,6 +40,7 @@ public:
virtual bool param_readSVGValue(const gchar * strvalue);
virtual gchar * param_getSVGValue() const;
+ virtual gchar * param_getDefaultSVGValue() const;
void param_setValue(bool newvalue);
virtual void param_set_default();
diff --git a/src/live_effects/parameter/transformedpoint.cpp b/src/live_effects/parameter/transformedpoint.cpp
index 22d5ba3a4..6ec2d0943 100644
--- a/src/live_effects/parameter/transformedpoint.cpp
+++ b/src/live_effects/parameter/transformedpoint.cpp
@@ -82,6 +82,15 @@ TransformedPointParam::param_getSVGValue() const
return str;
}
+gchar *
+TransformedPointParam::param_getDefaultSVGValue() const
+{
+ Inkscape::SVGOStringStream os;
+ os << defvalue;
+ gchar * str = g_strdup(os.str().c_str());
+ return str;
+}
+
void
TransformedPointParam::param_update_default(Geom::Point default_point)
{
diff --git a/src/live_effects/parameter/transformedpoint.h b/src/live_effects/parameter/transformedpoint.h
index 269cc508e..8b92d81ba 100644
--- a/src/live_effects/parameter/transformedpoint.h
+++ b/src/live_effects/parameter/transformedpoint.h
@@ -37,6 +37,7 @@ public:
virtual bool param_readSVGValue(const gchar * strvalue);
virtual gchar * param_getSVGValue() const;
+ virtual gchar * param_getDefaultSVGValue() const;
Geom::Point getVector() const { return vector; };
Geom::Point getOrigin() const { return origin; };
diff --git a/src/live_effects/parameter/unit.cpp b/src/live_effects/parameter/unit.cpp
index b9b91c1e6..9199e592d 100644
--- a/src/live_effects/parameter/unit.cpp
+++ b/src/live_effects/parameter/unit.cpp
@@ -48,6 +48,12 @@ UnitParam::param_getSVGValue() const
return g_strdup(unit->abbr.c_str());
}
+gchar *
+UnitParam::param_getDefaultSVGValue() const
+{
+ return g_strdup(defunit->abbr.c_str());
+}
+
void
UnitParam::param_set_default()
{
diff --git a/src/live_effects/parameter/unit.h b/src/live_effects/parameter/unit.h
index c662b6edc..86e1a24b3 100644
--- a/src/live_effects/parameter/unit.h
+++ b/src/live_effects/parameter/unit.h
@@ -31,6 +31,7 @@ public:
virtual bool param_readSVGValue(const gchar * strvalue);
virtual gchar * param_getSVGValue() const;
+ virtual gchar * param_getDefaultSVGValue() const;
virtual void param_set_default();
void param_set_value(Inkscape::Util::Unit const &val);
virtual void param_update_default(const gchar * default_unit);
diff --git a/src/live_effects/parameter/vector.cpp b/src/live_effects/parameter/vector.cpp
index 470fa9c2d..6b565536e 100644
--- a/src/live_effects/parameter/vector.cpp
+++ b/src/live_effects/parameter/vector.cpp
@@ -101,6 +101,15 @@ VectorParam::param_getSVGValue() const
return str;
}
+gchar *
+VectorParam::param_getDefaultSVGValue() const
+{
+ Inkscape::SVGOStringStream os;
+ os << defvalue;
+ gchar * str = g_strdup(os.str().c_str());
+ return str;
+}
+
Gtk::Widget *
VectorParam::param_newWidget()
{
diff --git a/src/live_effects/parameter/vector.h b/src/live_effects/parameter/vector.h
index d270e9f43..8c842e805 100644
--- a/src/live_effects/parameter/vector.h
+++ b/src/live_effects/parameter/vector.h
@@ -36,6 +36,7 @@ public:
virtual bool param_readSVGValue(const gchar * strvalue);
virtual gchar * param_getSVGValue() const;
+ virtual gchar * param_getDefaultSVGValue() const;
Geom::Point getVector() const { return vector; };
Geom::Point getOrigin() const { return origin; };