From 1f0a20e9f4270de3aff4b9ce0484e1d26c6d58da Mon Sep 17 00:00:00 2001 From: Jabiertxo Arraiza Cenoz Date: Fri, 8 Sep 2017 22:28:13 +0200 Subject: Fix for bug: 1715433 :: Clone original LPE can no longer be used to fill a powerstroke path --- src/live_effects/lpe-fill-between-many.cpp | 1 + src/live_effects/parameter/originalpath.cpp | 7 +++++- src/live_effects/parameter/originalpath.h | 2 ++ src/live_effects/parameter/originalpatharray.cpp | 28 +++++++++++++++++++++++- src/live_effects/parameter/originalpatharray.h | 5 +++++ src/live_effects/parameter/path.cpp | 7 +++++- src/live_effects/parameter/path.h | 2 ++ 7 files changed, 49 insertions(+), 3 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-fill-between-many.cpp b/src/live_effects/lpe-fill-between-many.cpp index 40fa91c68..ded8819fc 100644 --- a/src/live_effects/lpe-fill-between-many.cpp +++ b/src/live_effects/lpe-fill-between-many.cpp @@ -31,6 +31,7 @@ LPEFillBetweenMany::LPEFillBetweenMany(LivePathEffectObject *lpeobject) : registerParameter(&join); registerParameter(&close); transformmultiply = false; + linked_paths.allowOnlyBsplineSpiro(true); } LPEFillBetweenMany::~LPEFillBetweenMany() 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 & /*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..2513a0d5e 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 #include @@ -100,6 +104,8 @@ 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; } @@ -389,7 +395,27 @@ void OriginalPathArrayParam::setPathVector(SPObject *linked_obj, guint /*flags*/ } SPCurve *curve = NULL; if (SP_IS_SHAPE(linked_obj)) { - curve = SP_SHAPE(linked_obj)->getCurve(); + 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(lpe)) { + LivePathEffect::sp_bspline_do_effect(curve, 0); + } else if (dynamic_cast(lpe)) { + LivePathEffect::sp_spiro_do_effect(curve); + } + } + } + } 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/originalpatharray.h b/src/live_effects/parameter/originalpatharray.h index fe9371644..eb1114c3f 100644 --- a/src/live_effects/parameter/originalpatharray.h +++ b/src/live_effects/parameter/originalpatharray.h @@ -70,6 +70,9 @@ 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 & /*hp_vec*/) {}; + void setFromOriginalD(bool from_original_d){ _from_original_d = from_original_d; }; + void allowOnlyBsplineSpiro(bool allow_only_bspline_spiro){ _allow_only_bspline_spiro = allow_only_bspline_spiro; }; + std::vector _vector; protected: @@ -99,6 +102,8 @@ protected: void on_reverse_toggled(const Glib::ustring& path); private: + bool _from_original_d; + bool _allow_only_bspline_spiro; OriginalPathArrayParam(const OriginalPathArrayParam&); OriginalPathArrayParam& operator=(const OriginalPathArrayParam&); }; diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp index ec011b855..470535314 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; @@ -444,7 +445,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..c8efb11e0 100644 --- a/src/live_effects/parameter/path.h +++ b/src/live_effects/parameter/path.h @@ -50,6 +50,7 @@ public: virtual void addCanvasIndicators(SPLPEItem const* lpeitem, std::vector &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 signal_path_pasted; sigc::signal signal_path_changed; @@ -91,6 +92,7 @@ protected: gchar * defvalue; private: + bool _from_original_d; bool _edit_button; bool _copy_button; bool _paste_button; -- cgit v1.2.3 From 30faf29165b1bcd936e9e0ca3ecc8b4bad4c94d2 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 9 Sep 2017 03:54:39 +0200 Subject: This commit is based on a coment on bug #1670644. And allow to fill the fill between many LPE widget that allow attach all paths on the clipboard instead only one Also added to this widget the option visible, to allow work with multiples paths wigout getting full cracy --- src/live_effects/lpe-fill-between-many.cpp | 15 ++- src/live_effects/lpe-fill-between-many.h | 2 + src/live_effects/parameter/originalpatharray.cpp | 134 ++++++++++++++--------- src/live_effects/parameter/originalpatharray.h | 28 +++-- 4 files changed, 114 insertions(+), 65 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-fill-between-many.cpp b/src/live_effects/lpe-fill-between-many.cpp index ded8819fc..8b5cb9b95 100644 --- a/src/live_effects/lpe-fill-between-many.cpp +++ b/src/live_effects/lpe-fill-between-many.cpp @@ -20,12 +20,16 @@ namespace LivePathEffect { LPEFillBetweenMany::LPEFillBetweenMany(LivePathEffectObject *lpeobject) : Effect(lpeobject), linked_paths(_("Linked path:"), _("Paths from which to take the original path data"), "linkedpaths", &wr, this), + original_visible(_("Original path visible"), _("Original path visibled"), "original_visible", &wr, this, true), + original_reversed(_("Original path reversed"), _("Reverse original path"), "original_reversed", &wr, this, false), 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) { registerParameter(&linked_paths); + registerParameter(&original_visible); + registerParameter(&original_reversed); registerParameter(&fuse); registerParameter(&allow_transforms); registerParameter(&join); @@ -43,9 +47,16 @@ void LPEFillBetweenMany::doEffect (SPCurve * curve) { Geom::PathVector res_pathv; SPItem * firstObj = NULL; - for (std::vector::iterator iter = linked_paths._vector.begin(); iter != linked_paths._vector.end(); ++iter) { + if (original_visible) { + Geom::PathVector original = curve->get_pathvector(); + if (original_reversed) { + original = original.reversed(); + } + res_pathv = original; + } + for (std::vector::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(); diff --git a/src/live_effects/lpe-fill-between-many.h b/src/live_effects/lpe-fill-between-many.h index fe824e936..5bea53aba 100644 --- a/src/live_effects/lpe-fill-between-many.h +++ b/src/live_effects/lpe-fill-between-many.h @@ -24,6 +24,8 @@ public: private: OriginalPathArrayParam linked_paths; + BoolParam original_visible; + BoolParam original_reversed; BoolParam fuse; BoolParam allow_transforms; BoolParam join; diff --git a/src/live_effects/parameter/originalpatharray.cpp b/src/live_effects/parameter/originalpatharray.cpp index 2513a0d5e..13bd23634 100644 --- a/src/live_effects/parameter/originalpatharray.cpp +++ b/src/live_effects/parameter/originalpatharray.cpp @@ -54,12 +54,14 @@ public: add(_colObject); add(_colLabel); add(_colReverse); + add(_colVisible); } virtual ~ModelColumns() {} - Gtk::TreeModelColumn _colObject; + Gtk::TreeModelColumn _colObject; Gtk::TreeModelColumn _colLabel; Gtk::TreeModelColumn _colReverse; + Gtk::TreeModelColumn _colVisible; }; OriginalPathArrayParam::OriginalPathArrayParam( const Glib::ustring& label, @@ -72,6 +74,7 @@ OriginalPathArrayParam::OriginalPathArrayParam( const Glib::ustring& label, _tree(), _text_renderer(), _toggle_renderer(), + _toggle_visible(), _scroller() { _model = new ModelColumns(); @@ -81,13 +84,6 @@ OriginalPathArrayParam::OriginalPathArrayParam( const Glib::ustring& label, _tree.set_reorderable(true); _tree.enable_model_drag_dest (Gdk::ACTION_MOVE); - _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); Gtk::CellRendererToggle * _toggle_renderer = manage(new Gtk::CellRendererToggle()); int toggleColNum = _tree.append_column(_("Reverse"), *_toggle_renderer) - 1; @@ -96,6 +92,22 @@ OriginalPathArrayParam::OriginalPathArrayParam( const Glib::ustring& label, _toggle_renderer->signal_toggled().connect(sigc::mem_fun(*this, &OriginalPathArrayParam::on_reverse_toggled)); col->add_attribute(_toggle_renderer->property_active(), _model->_colReverse); + + Gtk::CellRendererToggle * _toggle_visible = manage(new Gtk::CellRendererToggle()); + int toggleColNum2 = _tree.append_column(_("Visible"), *_toggle_visible) - 1; + Gtk::TreeViewColumn* col2 = _tree.get_column(toggleColNum2); + _toggle_visible->set_activatable(true); + _toggle_visible->signal_toggled().connect(sigc::mem_fun(*this, &OriginalPathArrayParam::on_visible_toggled)); + col2->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); + _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); @@ -112,7 +124,7 @@ OriginalPathArrayParam::OriginalPathArrayParam( const Glib::ustring& label, OriginalPathArrayParam::~OriginalPathArrayParam() { while (!_vector.empty()) { - PathAndDirection *w = _vector.back(); + PathAndDirectionAndVisible *w = _vector.back(); _vector.pop_back(); unlink(w); delete w; @@ -124,7 +136,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]; @@ -135,6 +147,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() { @@ -223,8 +250,8 @@ void OriginalPathArrayParam::on_up_button_click() Gtk::TreeModel::Row row = *iter; int i = -1; - std::vector::iterator piter = _vector.begin(); - for (std::vector::iterator iter = _vector.begin(); iter != _vector.end(); piter = iter, i++, ++iter) { + std::vector::iterator piter = _vector.begin(); + for (std::vector::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]); @@ -250,9 +277,9 @@ void OriginalPathArrayParam::on_down_button_click() Gtk::TreeModel::Row row = *iter; int i = 0; - for (std::vector::iterator iter = _vector.begin(); iter != _vector.end(); i++, ++iter) { + for (std::vector::iterator iter = _vector.begin(); iter != _vector.end(); i++, ++iter) { if (*iter == row[_model->_colObject]) { - std::vector::iterator niter = _vector.erase(iter); + std::vector::iterator niter = _vector.erase(iter); if (niter != _vector.end()) { ++niter; i++; @@ -294,37 +321,40 @@ void OriginalPathArrayParam::on_link_button_click() { Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get(); - Glib::ustring pathid = cm->getShapeOrTextObjectId(SP_ACTIVE_DESKTOP); + std::vector pathsid = cm->getElementsOfType(SP_ACTIVE_DESKTOP, "svg:path"); - if (pathid == "") { + 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::const_iterator iter = _vector.begin(); iter != _vector.end(); ++iter) { + 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(), '#'); + bool foundOne = false; + for (std::vector::const_iterator iter = _vector.begin(); iter != _vector.end(); ++iter) { + if (foundOne) { + os << "|"; + } else { + foundOne = true; + } + os << (*iter)->href << "," << ((*iter)->reversed ? "1" : "0") << "," << ((*iter)->visibled ? "1" : "0"); + } + if (foundOne) { os << "|"; - } else { - foundOne = true; } - os << (*iter)->href << "," << ((*iter)->reversed ? "1" : "0"); - } - - if (foundOne) { - os << "|"; + os << pathid.c_str() << ",0"; + if (*i != *(--pathsid.end())) { + os << "|"; + } } - - 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")); } -void OriginalPathArrayParam::unlink(PathAndDirection* to) +void OriginalPathArrayParam::unlink(PathAndDirectionAndVisible* to) { to->linked_modified_connection.disconnect(); to->linked_delete_connection.disconnect(); @@ -336,12 +366,12 @@ void OriginalPathArrayParam::unlink(PathAndDirection* to) } } -void OriginalPathArrayParam::remove_link(PathAndDirection* to) +void OriginalPathArrayParam::remove_link(PathAndDirectionAndVisible* to) { unlink(to); - for (std::vector::iterator iter = _vector.begin(); iter != _vector.end(); ++iter) { + for (std::vector::iterator iter = _vector.begin(); iter != _vector.end(); ++iter) { if (*iter == to) { - PathAndDirection *w = *iter; + PathAndDirectionAndVisible *w = *iter; _vector.erase(iter); delete w; return; @@ -349,7 +379,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); @@ -358,7 +388,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) { @@ -369,26 +399,26 @@ 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(sigc::mem_fun(*this, &OriginalPathArrayParam::linked_delete), to)); - to->linked_modified_connection = new_obj->connectModified(sigc::bind(sigc::mem_fun(*this, &OriginalPathArrayParam::linked_modified), to)); - to->linked_transformed_connection = SP_ITEM(new_obj)->connectTransformed(sigc::bind(sigc::mem_fun(*this, &OriginalPathArrayParam::linked_transformed), to)); + to->linked_delete_connection = new_obj->connectDelete(sigc::bind(sigc::mem_fun(*this, &OriginalPathArrayParam::linked_delete), to)); + to->linked_modified_connection = new_obj->connectModified(sigc::bind(sigc::mem_fun(*this, &OriginalPathArrayParam::linked_modified), to)); + to->linked_transformed_connection = SP_ITEM(new_obj)->connectTransformed(sigc::bind(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(sigc::mem_fun(*this, &OriginalPathArrayParam::_updateLink), to)); + _store->foreach_iter(sigc::bind(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; @@ -430,21 +460,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(sigc::mem_fun(*this, &OriginalPathArrayParam::_updateLink), to)); + _store->foreach_iter(sigc::bind(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; @@ -455,11 +485,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(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(sigc::mem_fun(*this, &OriginalPathArrayParam::linked_changed), w)); w->ref.attach(URI(w->href)); _vector.push_back(w); @@ -471,6 +502,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); } } @@ -484,13 +516,13 @@ gchar * OriginalPathArrayParam::param_getSVGValue() const { Inkscape::SVGOStringStream os; bool foundOne = false; - for (std::vector::const_iterator iter = _vector.begin(); iter != _vector.end(); ++iter) { + for (std::vector::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; diff --git a/src/live_effects/parameter/originalpatharray.h b/src/live_effects/parameter/originalpatharray.h index eb1114c3f..51810a5cf 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; @@ -73,25 +75,26 @@ public: void setFromOriginalD(bool from_original_d){ _from_original_d = from_original_d; }; void allowOnlyBsplineSpiro(bool allow_only_bspline_spiro){ _allow_only_bspline_spiro = allow_only_bspline_spiro; }; - std::vector _vector; + std::vector _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 _store; Gtk::TreeView _tree; Gtk::CellRendererText *_text_renderer; Gtk::CellRendererToggle *_toggle_renderer; + Gtk::CellRendererToggle *_toggle_visible; Gtk::TreeView::Column *_name_column; Gtk::ScrolledWindow _scroller; @@ -100,6 +103,7 @@ 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; -- cgit v1.2.3 From b5d3bcd190a8b4c95613eeb82e2b768b08b693ce Mon Sep 17 00:00:00 2001 From: Jabiertxo Arraiza Cenoz Date: Wed, 13 Sep 2017 17:10:44 +0200 Subject: Fixes for clone original LPE --- src/live_effects/lpe-fill-between-many.cpp | 122 ++++++++++++++++++----- src/live_effects/lpe-fill-between-many.h | 16 ++- src/live_effects/parameter/originalpatharray.cpp | 35 ++++--- src/live_effects/parameter/originalpatharray.h | 7 +- 4 files changed, 132 insertions(+), 48 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-fill-between-many.cpp b/src/live_effects/lpe-fill-between-many.cpp index 8b5cb9b95..e380ca2dd 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 @@ -17,25 +21,31 @@ namespace Inkscape { namespace LivePathEffect { +static const Util::EnumData FilllpemethodData[] = { + { FLM_NONE, N_("Without LPE"), "none" }, + { FLM_PARTIAL, N_("Spiro/BSpline"), "partial" }, + { FLM_ALL, N_("All LPE"), "all" } +}; +static const Util::EnumDataConverter 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), - original_visible(_("Original path visible"), _("Original path visibled"), "original_visible", &wr, this, true), - original_reversed(_("Original path reversed"), _("Reverse original path"), "original_reversed", &wr, this, false), + method(_("LPE's on linked:"), _("LPE's on linked"), "method", FLMConverter, &wr, this, FLM_PARTIAL), 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(&original_visible); - registerParameter(&original_reversed); + registerParameter(&method); registerParameter(&fuse); registerParameter(&allow_transforms); registerParameter(&join); registerParameter(&close); - transformmultiply = false; - linked_paths.allowOnlyBsplineSpiro(true); + registerParameter(&applied); + previous_method = FLM_END; } LPEFillBetweenMany::~LPEFillBetweenMany() @@ -43,17 +53,70 @@ LPEFillBetweenMany::~LPEFillBetweenMany() } +void LPEFillBetweenMany::doOnApply (SPLPEItem const* lpeitem) +{ + SPDocument * document = SP_ACTIVE_DOCUMENT; + if (!document) { + return; + } + SPLPEItem *lpe_item = const_cast(lpeitem); + SPObject * parent = lpe_item->parent; + if (lpe_item) { + SPShape *shape = dynamic_cast(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 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(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) { - Geom::PathVector res_pathv; - SPItem * firstObj = NULL; - if (original_visible) { - Geom::PathVector original = curve->get_pathvector(); - if (original_reversed) { - original = original.reversed(); + if (previous_method != method) { + if (method == FLM_PARTIAL) { + linked_paths.allowOnlyBsplineSpiro(true); + linked_paths.setFromOriginalD(false); + } else if(method == FLM_NONE) { + linked_paths.allowOnlyBsplineSpiro(false); + linked_paths.setFromOriginalD(true); + } else { + linked_paths.allowOnlyBsplineSpiro(false); + linked_paths.setFromOriginalD(false); } - res_pathv = original; + previous_method = method; } + Geom::PathVector res_pathv; for (std::vector::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() && (*iter)->visibled) { @@ -65,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(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); } @@ -103,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 5bea53aba..da3a532bf 100644 --- a/src/live_effects/lpe-fill-between-many.h +++ b/src/live_effects/lpe-fill-between-many.h @@ -10,27 +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_NONE, + FLM_PARTIAL, + FLM_ALL, + 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; - BoolParam original_visible; - BoolParam original_reversed; + EnumParam 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/parameter/originalpatharray.cpp b/src/live_effects/parameter/originalpatharray.cpp index 13bd23634..0b1eb4802 100644 --- a/src/live_effects/parameter/originalpatharray.cpp +++ b/src/live_effects/parameter/originalpatharray.cpp @@ -326,28 +326,25 @@ OriginalPathArrayParam::on_link_button_click() if (pathsid.empty()) { return; } + bool foundOne = false; Inkscape::SVGOStringStream os; + for (std::vector::const_iterator iter = _vector.begin(); iter != _vector.end(); ++iter) { + if (foundOne) { + os << "|"; + } else { + foundOne = true; + } + os << (*iter)->href << "," << ((*iter)->reversed ? "1" : "0") << "," << ((*iter)->visibled ? "1" : "0"); + } 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(), '#'); - bool foundOne = false; - for (std::vector::const_iterator iter = _vector.begin(); iter != _vector.end(); ++iter) { - if (foundOne) { - os << "|"; - } else { - foundOne = true; - } - os << (*iter)->href << "," << ((*iter)->reversed ? "1" : "0") << "," << ((*iter)->visibled ? "1" : "0"); - } - + if (foundOne) { os << "|"; } - os << pathid.c_str() << ",0"; - if (*i != *(--pathsid.end())) { - os << "|"; - } + os << pathid.c_str() << ",0,1"; } param_write_to_repr(os.str().c_str()); DocumentUndo::done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, @@ -363,7 +360,7 @@ void OriginalPathArrayParam::unlink(PathAndDirectionAndVisible* to) if (to->href) { g_free(to->href); to->href = NULL; - } + } } void OriginalPathArrayParam::remove_link(PathAndDirectionAndVisible* to) @@ -528,6 +525,14 @@ gchar * OriginalPathArrayParam::param_getSVGValue() const return str; } +void OriginalPathArrayParam::update() +{ + for (std::vector::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 51810a5cf..cffa2911f 100644 --- a/src/live_effects/parameter/originalpatharray.h +++ b/src/live_effects/parameter/originalpatharray.h @@ -72,11 +72,11 @@ 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 & /*hp_vec*/) {}; - void setFromOriginalD(bool from_original_d){ _from_original_d = from_original_d; }; - void allowOnlyBsplineSpiro(bool allow_only_bspline_spiro){ _allow_only_bspline_spiro = allow_only_bspline_spiro; }; + 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 _vector; - + protected: bool _updateLink(const Gtk::TreeIter& iter, PathAndDirectionAndVisible* pd); bool _selectIndex(const Gtk::TreeIter& iter, int* i); @@ -108,6 +108,7 @@ protected: private: bool _from_original_d; bool _allow_only_bspline_spiro; + void update(); OriginalPathArrayParam(const OriginalPathArrayParam&); OriginalPathArrayParam& operator=(const OriginalPathArrayParam&); }; -- cgit v1.2.3 From 58ef38f81c81f38149952f48e674a5fa5402bb98 Mon Sep 17 00:00:00 2001 From: Jabiertxo Arraiza Cenoz Date: Wed, 13 Sep 2017 18:35:35 +0200 Subject: Fixes for bug #1716926. Consider backport --- src/live_effects/lpe-patternalongpath.cpp | 79 +++++++++++++++++-------------- src/live_effects/parameter/path.cpp | 33 +++++++------ 2 files changed, 61 insertions(+), 51 deletions(-) (limited to 'src/live_effects') 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(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(&*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(&*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(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(&*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(&*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(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(ptA); - pap_helper_path.push_back(hp); - hp.clear(); - - return result_point; } return Geom::Point(); } diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp index 470535314..a91e50db8 100644 --- a/src/live_effects/parameter/path.cpp +++ b/src/live_effects/parameter/path.cpp @@ -79,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(desktop->event_context); - std::set 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(desktop->event_context); +// std::set shapes; +// ShapeRecord r; +// r.item = item; +// shapes.insert(r); +// nt->_multipath->setItems(shapes); +// } +// } +// } g_free(defvalue); } -- cgit v1.2.3 From bf5a9dd8028a965e4f072ea45a802b4feb6f821a Mon Sep 17 00:00:00 2001 From: Jabiertxo Arraiza Cenoz Date: Thu, 14 Sep 2017 11:05:47 +0200 Subject: Added new LPE parameter to store Items array, also bugfixing in patharray parameter --- src/live_effects/CMakeLists.txt | 2 + src/live_effects/parameter/originalitemarray.cpp | 458 +++++++++++++++++++++++ src/live_effects/parameter/originalitemarray.h | 120 ++++++ src/live_effects/parameter/originalpatharray.cpp | 10 +- 4 files changed, 586 insertions(+), 4 deletions(-) create mode 100644 src/live_effects/parameter/originalitemarray.cpp create mode 100644 src/live_effects/parameter/originalitemarray.h (limited to 'src/live_effects') diff --git a/src/live_effects/CMakeLists.txt b/src/live_effects/CMakeLists.txt index b1000de01..2c16e2383 100644 --- a/src/live_effects/CMakeLists.txt +++ b/src/live_effects/CMakeLists.txt @@ -67,6 +67,7 @@ set(live_effects_SRC parameter/hidden.cpp parameter/item-reference.cpp parameter/item.cpp + parameter/originalitemarray.cpp parameter/originalitem.cpp parameter/originalpath.cpp parameter/originalpatharray.cpp @@ -157,6 +158,7 @@ set(live_effects_SRC parameter/hidden.h parameter/enum.h parameter/item.h + parameter/originalitemarray.cpp parameter/item-reference.h parameter/originalitem.h parameter/originalpath.h diff --git a/src/live_effects/parameter/originalitemarray.cpp b/src/live_effects/parameter/originalitemarray.cpp new file mode 100644 index 000000000..fddbfe4ce --- /dev/null +++ b/src/live_effects/parameter/originalitemarray.cpp @@ -0,0 +1,458 @@ +/* + * Copyright (C) Theodore Janeczko 2012 + * + * 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 +#include +#include +#include +#include + +#include + +#include "inkscape.h" +#include "icon-size.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(_colActived); + } + virtual ~ModelColumns() {} + + Gtk::TreeModelColumn _colObject; + Gtk::TreeModelColumn _colLabel; + Gtk::TreeModelColumn _colActived; +}; + +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_renderer(), + _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_renderer = manage(new Gtk::CellRendererToggle()); + int toggleColNum = _tree.append_column(_("Active"), *_toggle_renderer) - 1; + Gtk::TreeViewColumn* col = _tree.get_column(toggleColNum); + _toggle_renderer->set_activatable(true); + _toggle_renderer->signal_toggled().connect(sigc::mem_fun(*this, &OriginalItemArrayParam::on_active_toggled)); + col->add_attribute(_toggle_renderer->property_active(), _model->_colActived); + + _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->_colActived] = !row[_model->_colActived]; + w->actived = row[_model->_colActived]; + + 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::iterator piter = _vector.begin(); + for (std::vector::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(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::iterator iter = _vector.begin(); iter != _vector.end(); i++, ++iter) { + if (*iter == row[_model->_colObject]) { + std::vector::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(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 itemsid = cm->getElementsOfType(SP_ACTIVE_DESKTOP); + + if (itemsid.empty()) { + return; + } + + bool foundOne = false; + Inkscape::SVGOStringStream os; + for (std::vector::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::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(sigc::mem_fun(*this, &OriginalItemArrayParam::linked_delete), to)); + to->linked_modified_connection = new_obj->connectModified(sigc::bind(sigc::mem_fun(*this, &OriginalItemArrayParam::linked_modified), to)); + to->linked_transformed_connection = SP_ITEM(new_obj)->connectTransformed(sigc::bind(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(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(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(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->_colActived] = 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::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; +} + +} /* 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..3b300bd25 --- /dev/null +++ b/src/live_effects/parameter/originalitemarray.h @@ -0,0 +1,120 @@ +#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_ORIGINALITEMARRAY_H +#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_ORIGINALITEMARRAY_H + +/* + * Inkscape::LivePathEffectParameters + * + * Copyright (C) Theodore Janeczko 2012 + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include + +#include +#include +#include +#include + +#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 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 & /*hp_vec*/) {}; + + std::vector _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 _store; + Gtk::TreeView _tree; + Gtk::CellRendererText *_text_renderer; + Gtk::CellRendererToggle *_toggle_renderer; + 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& actived); + +private: + 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/originalpatharray.cpp b/src/live_effects/parameter/originalpatharray.cpp index 0b1eb4802..8ac07b98f 100644 --- a/src/live_effects/parameter/originalpatharray.cpp +++ b/src/live_effects/parameter/originalpatharray.cpp @@ -322,7 +322,8 @@ OriginalPathArrayParam::on_link_button_click() { Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get(); std::vector pathsid = cm->getElementsOfType(SP_ACTIVE_DESKTOP, "svg:path"); - + std::vector textsid = cm->getElementsOfType(SP_ACTIVE_DESKTOP, "svg:text"); + pathsid.insert(pathsid.end(), textsid.begin(), textsid.end()); if (pathsid.empty()) { return; } @@ -343,12 +344,14 @@ OriginalPathArrayParam::on_link_button_click() if (foundOne) { os << "|"; + } else { + foundOne = true; } os << pathid.c_str() << ",0,1"; } 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(PathAndDirectionAndVisible* to) @@ -443,8 +446,7 @@ void OriginalPathArrayParam::setPathVector(SPObject *linked_obj, guint /*flags*/ } else { curve = SP_SHAPE(linked_obj)->getCurve(); } - } - if (SP_IS_TEXT(linked_obj)) { + } else if (SP_IS_TEXT(linked_obj)) { curve = SP_TEXT(linked_obj)->getNormalizedBpath(); } -- cgit v1.2.3 From f38f101c22e8afeceacc49bcd09b43bac47347e7 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 16 Sep 2017 16:00:54 +0200 Subject: Fix a bug on uninicialitated variable, that perform diferent results in debug and in release mode. Thanks Michael for help me finfing this bug. Also sused to remove some unnneded code in path chemistry and to better naming the variable uninicilitated --- src/live_effects/lpe-clone-original.cpp | 2 +- src/live_effects/parameter/originalitem.cpp | 3 ++- src/live_effects/parameter/originalitem.h | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-clone-original.cpp b/src/live_effects/lpe-clone-original.cpp index 31bf0e270..e72735370 100644 --- a/src/live_effects/lpe-clone-original.cpp +++ b/src/live_effects/lpe-clone-original.cpp @@ -221,7 +221,7 @@ LPECloneOriginal::cloneAttrbutes(SPObject *origin, SPObject *dest, bool live, co void LPECloneOriginal::doBeforeEffect (SPLPEItem const* lpeitem){ if (linkeditem.linksToItem()) { - linkeditem.setInverse(inverse); + linkeditem.setInsensitive(inverse); if ( preserve_position_changed != preserve_position ) { if (!preserve_position) { sp_svg_transform_read(SP_ITEM(sp_lpe_item)->getAttribute("transform"), &preserve_affine); diff --git a/src/live_effects/parameter/originalitem.cpp b/src/live_effects/parameter/originalitem.cpp index 81ab41c56..6de70be17 100644 --- a/src/live_effects/parameter/originalitem.cpp +++ b/src/live_effects/parameter/originalitem.cpp @@ -35,6 +35,7 @@ OriginalItemParam::OriginalItemParam( const Glib::ustring& label, const Glib::us Effect* effect) : ItemParam(label, tip, key, wr, effect, "") { + _insensitive = false; } OriginalItemParam::~OriginalItemParam() @@ -87,7 +88,7 @@ OriginalItemParam::param_newWidget() void OriginalItemParam::linked_modified_callback(SPObject *linked_obj, guint /*flags*/) { - if (!inverse) { + if (!_insensitive) { emit_changed(); 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..9b692c503 100644 --- a/src/live_effects/parameter/originalitem.h +++ b/src/live_effects/parameter/originalitem.h @@ -23,7 +23,7 @@ public: Inkscape::UI::Widget::Registry* wr, Effect* effect); virtual ~OriginalItemParam(); - void setInverse(bool inversed) { inverse = inversed; } + void setInsensitive(bool insensitive) { insensitive = _insensitive; } bool linksToItem() const { return (href != NULL); } SPItem * getObject() const { return ref.getObject(); } @@ -36,7 +36,7 @@ protected: void on_select_original_button_click(); private: - bool inverse; + bool _insensitive; OriginalItemParam(const OriginalItemParam&); OriginalItemParam& operator=(const OriginalItemParam&); }; -- cgit v1.2.3 From d3520b305d8a29fb6dd0c32c782601465a7d677f Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 16 Sep 2017 23:00:19 +0200 Subject: Fix bug #1658855, bend from clipboard end point get some spike --- src/live_effects/lpe-bendpath.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bendpath.cpp b/src/live_effects/lpe-bendpath.cpp index 5c1953fda..39714e629 100644 --- a/src/live_effects/lpe-bendpath.cpp +++ b/src/live_effects/lpe-bendpath.cpp @@ -94,7 +94,7 @@ LPEBendPath::doEffect_pwd2 (Geom::Piecewise > const & pwd uskeleton = arc_length_parametrization(Piecewise >(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 > 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(); -- cgit v1.2.3 From b715d8f04c609173b2e9600660e22fc00f9d328f Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 16 Sep 2017 23:40:25 +0200 Subject: Fix bug #1460858 Ruler LPE does not consider drawing scale (page size / viewBox) --- src/live_effects/lpe-ruler.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/live_effects') 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 > const & pwd2_i std::vector 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 Date: Sun, 17 Sep 2017 18:06:00 +0200 Subject: Flushing std::cout --- src/live_effects/lpe-fillet-chamfer.cpp | 2 -- src/live_effects/lpe-knot.cpp | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'src/live_effects') 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 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-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 Date: Tue, 19 Sep 2017 22:20:03 +0200 Subject: Fix bug #1718224 Removing PowerStroke LPE from path in master sets negative stroke width --- src/live_effects/lpe-powerstroke.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index d87f92fcc..6576e6a62 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -276,7 +276,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"); -- cgit v1.2.3 From a474159bf7130e9b46a8da1efaf32e9eac4c55b7 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Thu, 21 Sep 2017 23:12:27 +0200 Subject: Fix for bug #1715433 Clone original LPE can no longer be used to fill a powerstroke path --- src/live_effects/lpe-clone-original.cpp | 284 +++++++---------------- src/live_effects/lpe-clone-original.h | 35 ++- src/live_effects/lpe-fill-between-many.cpp | 12 +- src/live_effects/lpe-fill-between-many.h | 6 +- src/live_effects/parameter/originalitemarray.cpp | 32 ++- src/live_effects/parameter/originalitemarray.h | 5 +- src/live_effects/parameter/originalpatharray.cpp | 20 +- src/live_effects/parameter/originalpatharray.h | 2 +- 8 files changed, 134 insertions(+), 262 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-clone-original.cpp b/src/live_effects/lpe-clone-original.cpp index e72735370..b035cc1d0 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,45 @@ namespace Inkscape { namespace LivePathEffect { +static const Util::EnumData 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 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"); }; 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); 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 +69,7 @@ LPECloneOriginal::cloneAttrbutes(SPObject *origin, SPObject *dest, bool live, co for (std::vector::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 +87,7 @@ LPECloneOriginal::cloneAttrbutes(SPObject *origin, SPObject *dest, bool live, co for ( std::vector::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 +102,60 @@ LPECloneOriginal::cloneAttrbutes(SPObject *origin, SPObject *dest, bool live, co for ( std::vector::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()); + 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(lpe)) { + LivePathEffect::sp_bspline_do_effect(c, 0); + } else if (dynamic_cast(lpe)) { + LivePathEffect::sp_spiro_do_effect(c); + } + } + } } - 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 (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,11 +168,13 @@ 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++; } @@ -221,123 +187,29 @@ LPECloneOriginal::cloneAttrbutes(SPObject *origin, SPObject *dest, bool live, co void LPECloneOriginal::doBeforeEffect (SPLPEItem const* lpeitem){ if (linkeditem.linksToItem()) { - linkeditem.setInsensitive(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) { + if (method != CLM_NONE) { attr.append("d,"); } - if (transform) { - attr.append("transform,"); - } attr.append(Glib::ustring(attributes.param_getSVGValue()).append(",")); 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 (paintorder) { - style_attr.append("paint-order,"); - } - if (filter) { - style_attr.append("filter,"); - } - if (opacity) { - style_attr.append("opacity,"); - } 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); - } - bbox = from->geometricBounds(); - if (bbox && preserve_position) { - origin = (*bbox).corner(0); + SPItem * origin = SP_ITEM(linkeditem.getObject()); + SPItem * dest = SP_ITEM(sp_lpe_item); + cloneAttrbutes(origin, dest, g_strdup(attr.c_str()), g_strdup(style_attr.c_str())); + if (!allow_transforms) { + SP_ITEM(dest)->getRepr()->setAttribute("transform", SP_ITEM(origin)->getAttribute("transform")); } } } - -Gtk::Widget * -LPECloneOriginal::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); - Gtk::VBox * vbox_expander = Gtk::manage( new Gtk::VBox(Effect::newWidget()) ); - vbox_expander->set_border_width(0); - vbox_expander->set_spacing(2); - std::vector::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; - } - 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(vbox); -} - -void -LPECloneOriginal::onExpanderChanged() -{ - expanded = expander->get_expanded(); - if(expanded) { - expander->set_label (Glib::ustring(_("Hide attributes override"))); - } else { - expander->set_label (Glib::ustring(_("Show attributes override"))); - } -} - LPECloneOriginal::~LPECloneOriginal() { @@ -346,15 +218,15 @@ LPECloneOriginal::~LPECloneOriginal() 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..b78b144bc 100644 --- a/src/live_effects/lpe-clone-original.h +++ b/src/live_effects/lpe-clone-original.h @@ -10,16 +10,22 @@ */ #include #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" 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 +33,14 @@ 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); 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 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; 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 e380ca2dd..7e2131f76 100644 --- a/src/live_effects/lpe-fill-between-many.cpp +++ b/src/live_effects/lpe-fill-between-many.cpp @@ -22,16 +22,16 @@ namespace Inkscape { namespace LivePathEffect { static const Util::EnumData FilllpemethodData[] = { - { FLM_NONE, N_("Without LPE"), "none" }, - { FLM_PARTIAL, N_("Spiro/BSpline"), "partial" }, - { FLM_ALL, N_("All LPE"), "all" } + { 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 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_PARTIAL), + 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), @@ -104,10 +104,10 @@ void LPEFillBetweenMany::doOnApply (SPLPEItem const* lpeitem) void LPEFillBetweenMany::doEffect (SPCurve * curve) { if (previous_method != method) { - if (method == FLM_PARTIAL) { + if (method == FLM_BSPLINESPIRO) { linked_paths.allowOnlyBsplineSpiro(true); linked_paths.setFromOriginalD(false); - } else if(method == FLM_NONE) { + } else if(method == FLM_ORIGINALD) { linked_paths.allowOnlyBsplineSpiro(false); linked_paths.setFromOriginalD(true); } else { diff --git a/src/live_effects/lpe-fill-between-many.h b/src/live_effects/lpe-fill-between-many.h index da3a532bf..7ff998309 100644 --- a/src/live_effects/lpe-fill-between-many.h +++ b/src/live_effects/lpe-fill-between-many.h @@ -18,9 +18,9 @@ namespace Inkscape { namespace LivePathEffect { enum Filllpemethod { - FLM_NONE, - FLM_PARTIAL, - FLM_ALL, + FLM_ORIGINALD, + FLM_BSPLINESPIRO, + FLM_D, FLM_END }; diff --git a/src/live_effects/parameter/originalitemarray.cpp b/src/live_effects/parameter/originalitemarray.cpp index fddbfe4ce..24b002e18 100644 --- a/src/live_effects/parameter/originalitemarray.cpp +++ b/src/live_effects/parameter/originalitemarray.cpp @@ -44,13 +44,13 @@ public: { add(_colObject); add(_colLabel); - add(_colActived); + add(_colActive); } virtual ~ModelColumns() {} Gtk::TreeModelColumn _colObject; Gtk::TreeModelColumn _colLabel; - Gtk::TreeModelColumn _colActived; + Gtk::TreeModelColumn _colActive; }; OriginalItemArrayParam::OriginalItemArrayParam( const Glib::ustring& label, @@ -62,7 +62,7 @@ OriginalItemArrayParam::OriginalItemArrayParam( const Glib::ustring& label, _vector(), _tree(), _text_renderer(), - _toggle_renderer(), + _toggle_active(), _scroller() { _model = new ModelColumns(); @@ -72,12 +72,12 @@ OriginalItemArrayParam::OriginalItemArrayParam( const Glib::ustring& label, _tree.set_reorderable(true); _tree.enable_model_drag_dest (Gdk::ACTION_MOVE); - Gtk::CellRendererToggle * _toggle_renderer = manage(new Gtk::CellRendererToggle()); - int toggleColNum = _tree.append_column(_("Active"), *_toggle_renderer) - 1; - Gtk::TreeViewColumn* col = _tree.get_column(toggleColNum); - _toggle_renderer->set_activatable(true); - _toggle_renderer->signal_toggled().connect(sigc::mem_fun(*this, &OriginalItemArrayParam::on_active_toggled)); - col->add_attribute(_toggle_renderer->property_active(), _model->_colActived); + 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; @@ -113,8 +113,8 @@ 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->_colActived] = !row[_model->_colActived]; - w->actived = row[_model->_colActived]; + row[_model->_colActive] = !row[_model->_colActive]; + w->actived = row[_model->_colActive]; gchar * full = param_getSVGValue(); param_write_to_repr(full); @@ -416,7 +416,7 @@ bool OriginalItemArrayParam::param_readSVGValue(const gchar* strvalue) row[_model->_colObject] = w; row[_model->_colLabel] = obj ? ( obj->label() ? obj->label() : obj->getId() ) : w->href; - row[_model->_colActived] = w->actived; + row[_model->_colActive] = w->actived; g_strfreev (substrarray); } } @@ -442,6 +442,14 @@ gchar * OriginalItemArrayParam::param_getSVGValue() const return str; } +void OriginalItemArrayParam::update() +{ + for (std::vector::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/originalitemarray.h b/src/live_effects/parameter/originalitemarray.h index 3b300bd25..f600aba34 100644 --- a/src/live_effects/parameter/originalitemarray.h +++ b/src/live_effects/parameter/originalitemarray.h @@ -87,7 +87,7 @@ protected: Glib::RefPtr _store; Gtk::TreeView _tree; Gtk::CellRendererText *_text_renderer; - Gtk::CellRendererToggle *_toggle_renderer; + Gtk::CellRendererToggle *_toggle_active; Gtk::TreeView::Column *_name_column; Gtk::ScrolledWindow _scroller; @@ -95,9 +95,10 @@ protected: void on_remove_button_click(); void on_up_button_click(); void on_down_button_click(); - void on_active_toggled(const Glib::ustring& actived); + void on_active_toggled(const Glib::ustring& item); private: + void update(); OriginalItemArrayParam(const OriginalItemArrayParam&); OriginalItemArrayParam& operator=(const OriginalItemArrayParam&); }; diff --git a/src/live_effects/parameter/originalpatharray.cpp b/src/live_effects/parameter/originalpatharray.cpp index 8ac07b98f..d67f08e5b 100644 --- a/src/live_effects/parameter/originalpatharray.cpp +++ b/src/live_effects/parameter/originalpatharray.cpp @@ -73,7 +73,7 @@ OriginalPathArrayParam::OriginalPathArrayParam( const Glib::ustring& label, _vector(), _tree(), _text_renderer(), - _toggle_renderer(), + _toggle_reverse(), _toggle_visible(), _scroller() { @@ -85,20 +85,20 @@ OriginalPathArrayParam::OriginalPathArrayParam( const Glib::ustring& label, _tree.enable_model_drag_dest (Gdk::ACTION_MOVE); - 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); + 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 toggleColNum2 = _tree.append_column(_("Visible"), *_toggle_visible) - 1; - Gtk::TreeViewColumn* col2 = _tree.get_column(toggleColNum2); + 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)); - col2->add_attribute(_toggle_visible->property_active(), _model->_colVisible); + 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; diff --git a/src/live_effects/parameter/originalpatharray.h b/src/live_effects/parameter/originalpatharray.h index cffa2911f..0ba6984c2 100644 --- a/src/live_effects/parameter/originalpatharray.h +++ b/src/live_effects/parameter/originalpatharray.h @@ -93,7 +93,7 @@ protected: Glib::RefPtr _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; -- cgit v1.2.3 From 1fe4a0658bfe9140476fd475ddc7f40948ca63fa Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Thu, 21 Sep 2017 23:33:54 +0200 Subject: Add some sugesstions and fixes from CR to measure segments --- src/live_effects/lpe-measure-segments.cpp | 15 ++++++++------- src/live_effects/lpe-measure-segments.h | 1 + 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-measure-segments.cpp b/src/live_effects/lpe-measure-segments.cpp index 2ac40b580..2eae30b4d 100644 --- a/src/live_effects/lpe-measure-segments.cpp +++ b/src/live_effects/lpe-measure-segments.cpp @@ -50,7 +50,7 @@ static const Util::EnumDataConverter OMConverter(OrientationM LPEMeasureSegments::LPEMeasureSegments(LivePathEffectObject *lpeobject) : Effect(lpeobject), - unit(_("Unit"), _("Unit"), "unit", &wr, this, "px"), + unit(_("Unit"), _("Unit"), "unit", &wr, this, "mm"), fontbutton(_("Font"), _("Font Selector"), "fontbutton", &wr, this), orientation(_("Orientation"), _("Orientation method"), "orientation", OMConverter, &wr, this, OM_PARALLEL, false), precision(_("Precision"), _("Precision"), "precision", &wr, this, 2), @@ -846,7 +846,7 @@ Gtk::Widget *LPEMeasureSegments::newWidget() ++it; } - expander = Gtk::manage(new Gtk::Expander(Glib::ustring(_("Show DIM CSS style override")))); + expander = Gtk::manage(new Gtk::Expander(Glib::ustring(_("CSS Style Override")))); expander->add(*vbox_expander); expander->set_expanded(expanded); expander->property_expanded().signal_changed().connect(sigc::mem_fun(*this, &LPEMeasureSegments::onExpanderChanged) ); @@ -854,15 +854,16 @@ Gtk::Widget *LPEMeasureSegments::newWidget() return dynamic_cast(vbox); } +void +LPEMeasureSegments::transform_multiply(Geom::Affine const& postmul, bool set) +{ + sp_lpe_item_update_patheffect(sp_lpe_item, false, false); +} + void LPEMeasureSegments::onExpanderChanged() { 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"))); - } } Geom::PathVector diff --git a/src/live_effects/lpe-measure-segments.h b/src/live_effects/lpe-measure-segments.h index f7f5be1e3..7383aeca8 100644 --- a/src/live_effects/lpe-measure-segments.h +++ b/src/live_effects/lpe-measure-segments.h @@ -44,6 +44,7 @@ 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 createTextLabel(Geom::Point pos, size_t counter, double length, Geom::Coord angle, bool remove, bool valid); -- cgit v1.2.3 From 1711a79b8604d9e6d936e25eaf966154ff122483 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Fri, 22 Sep 2017 18:00:59 +0200 Subject: Add tooltip to set default LPE widget --- src/live_effects/effect.cpp | 29 ++++++++++++++++++------ src/live_effects/effect.h | 4 ++-- src/live_effects/parameter/array.h | 4 ++++ src/live_effects/parameter/bool.cpp | 7 ++++++ src/live_effects/parameter/bool.h | 1 + src/live_effects/parameter/enum.h | 7 +++++- src/live_effects/parameter/fontbutton.cpp | 8 +++++++ src/live_effects/parameter/fontbutton.h | 1 + src/live_effects/parameter/hidden.cpp | 9 ++++++++ src/live_effects/parameter/hidden.h | 1 + src/live_effects/parameter/item.cpp | 6 +++++ src/live_effects/parameter/item.h | 1 + src/live_effects/parameter/originalitemarray.cpp | 5 ++++ src/live_effects/parameter/originalitemarray.h | 1 + src/live_effects/parameter/originalpatharray.cpp | 5 ++++ src/live_effects/parameter/originalpatharray.h | 1 + src/live_effects/parameter/parameter.cpp | 9 ++++++++ src/live_effects/parameter/parameter.h | 2 ++ src/live_effects/parameter/path.cpp | 6 +++++ src/live_effects/parameter/path.h | 1 + src/live_effects/parameter/point.cpp | 9 ++++++++ src/live_effects/parameter/point.h | 1 + src/live_effects/parameter/random.cpp | 9 ++++++++ src/live_effects/parameter/random.h | 1 + src/live_effects/parameter/text.cpp | 9 ++++++++ src/live_effects/parameter/text.h | 1 + src/live_effects/parameter/togglebutton.cpp | 7 ++++++ src/live_effects/parameter/togglebutton.h | 1 + src/live_effects/parameter/transformedpoint.cpp | 9 ++++++++ src/live_effects/parameter/transformedpoint.h | 1 + src/live_effects/parameter/unit.cpp | 6 +++++ src/live_effects/parameter/unit.h | 1 + src/live_effects/parameter/vector.cpp | 9 ++++++++ src/live_effects/parameter/vector.h | 1 + 34 files changed, 163 insertions(+), 10 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index b2ba0acdc..dcc60af14 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -826,29 +826,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(_("Default value: ")) + Glib::ustring(param->param_getDefaultSVGValue()) + Glib::ustring("\n"); + Glib::ustring ove = Glib::ustring(_("Default value overrided: ")) + Glib::ustring(prefs->getString(pref_path)) + Glib::ustring("\n"); if (valid) { set_or_upd = _("Update"); + def = Glib::ustring(_("Default value: ")) + Glib::ustring(param->param_getDefaultSVGValue()) + Glib::ustring("\n"); } else { set_or_upd = _("Set"); + ove = Glib::ustring(_("Default value overrided: None\n")); } + Glib::ustring cur = Glib::ustring(_("Current parameter value: ")) + 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("") + parameter_label->get_text () + Glib::ustring("\n") + param->param_tooltip + Glib::ustring("\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(sigc::mem_fun(*this, &Effect::unsetDefaultParam), pref_path, set, unset)); - set->signal_clicked().connect(sigc::bind(sigc::mem_fun(*this, &Effect::setDefaultParam), pref_path, param->param_getSVGValue(), set, unset)); + unset->signal_clicked().connect(sigc::bind(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(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); } @@ -873,23 +880,31 @@ Effect::defaultParamSet() } 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(_("Default value: ")) + Glib::ustring(defvalue) + Glib::ustring("\n"); + Glib::ustring ove = Glib::ustring(_("Default value overrided: ")) + Glib::ustring(value) + Glib::ustring("\n"); + Glib::ustring cur = Glib::ustring(_("Current parameter value: ")) + 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(_("Default value: ")) + Glib::ustring(defvalue) + Glib::ustring("\n"); + Glib::ustring ove = Glib::ustring(_("Default value overrided: None\n")); + Glib::ustring cur = Glib::ustring(_("Current parameter value: ")) + 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 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/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 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/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..149fd6627 100644 --- a/src/live_effects/parameter/item.cpp +++ b/src/live_effects/parameter/item.cpp @@ -104,6 +104,12 @@ ItemParam::param_getSVGValue() const return g_strdup(href); } +gchar * +ItemParam::param_getDefaultSVGValue() const +{ + return g_strdup(defvalue); +} + Gtk::Widget * ItemParam::param_newWidget() { diff --git a/src/live_effects/parameter/item.h b/src/live_effects/parameter/item.h index 89c32f9bd..b98294258 100644 --- a/src/live_effects/parameter/item.h +++ b/src/live_effects/parameter/item.h @@ -34,6 +34,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); diff --git a/src/live_effects/parameter/originalitemarray.cpp b/src/live_effects/parameter/originalitemarray.cpp index 24b002e18..83c237f2e 100644 --- a/src/live_effects/parameter/originalitemarray.cpp +++ b/src/live_effects/parameter/originalitemarray.cpp @@ -442,6 +442,11 @@ gchar * OriginalItemArrayParam::param_getSVGValue() const return str; } +gchar * OriginalItemArrayParam::param_getDefaultSVGValue() const +{ + return ""; +} + void OriginalItemArrayParam::update() { for (std::vector::iterator iter = _vector.begin(); iter != _vector.end(); ++iter) { diff --git a/src/live_effects/parameter/originalitemarray.h b/src/live_effects/parameter/originalitemarray.h index f600aba34..f93d865ec 100644 --- a/src/live_effects/parameter/originalitemarray.h +++ b/src/live_effects/parameter/originalitemarray.h @@ -62,6 +62,7 @@ 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 */ diff --git a/src/live_effects/parameter/originalpatharray.cpp b/src/live_effects/parameter/originalpatharray.cpp index d67f08e5b..4535b6aa5 100644 --- a/src/live_effects/parameter/originalpatharray.cpp +++ b/src/live_effects/parameter/originalpatharray.cpp @@ -527,6 +527,11 @@ gchar * OriginalPathArrayParam::param_getSVGValue() const return str; } +gchar * OriginalPathArrayParam::param_getDefaultSVGValue() const +{ + return ""; +} + void OriginalPathArrayParam::update() { for (std::vector::iterator iter = _vector.begin(); iter != _vector.end(); ++iter) { diff --git a/src/live_effects/parameter/originalpatharray.h b/src/live_effects/parameter/originalpatharray.h index 0ba6984c2..c80d5daf3 100644 --- a/src/live_effects/parameter/originalpatharray.h +++ b/src/live_effects/parameter/originalpatharray.h @@ -66,6 +66,7 @@ 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 */ 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 a91e50db8..bd6608737 100644 --- a/src/live_effects/parameter/path.cpp +++ b/src/live_effects/parameter/path.cpp @@ -173,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) { diff --git a/src/live_effects/parameter/path.h b/src/live_effects/parameter/path.h index c8efb11e0..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); 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..3f41bfeed 100644 --- a/src/live_effects/parameter/text.cpp +++ b/src/live_effects/parameter/text.cpp @@ -115,6 +115,15 @@ 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; +} + Gtk::Widget * TextParam::param_newWidget() { diff --git a/src/live_effects/parameter/text.h b/src/live_effects/parameter/text.h index 137f3ee02..460ef8629 100644 --- a/src/live_effects/parameter/text.h +++ b/src/live_effects/parameter/text.h @@ -38,6 +38,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); void param_hide_canvas_text(); diff --git a/src/live_effects/parameter/togglebutton.cpp b/src/live_effects/parameter/togglebutton.cpp index 6aad8b3a6..16b8f9067 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) { diff --git a/src/live_effects/parameter/togglebutton.h b/src/live_effects/parameter/togglebutton.h index 02b9d5127..4d043b340 100644 --- a/src/live_effects/parameter/togglebutton.h +++ b/src/live_effects/parameter/togglebutton.h @@ -41,6 +41,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; }; -- cgit v1.2.3 From 89708dcf567d0de08eb59811b434c9f282768e40 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Fri, 22 Sep 2017 18:12:15 +0200 Subject: Minor tootltip tweak --- src/live_effects/effect.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/live_effects') diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index dcc60af14..fcb4b5cb2 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -847,7 +847,7 @@ Effect::defaultParamSet() 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); - Glib::ustring tooltip = Glib::ustring("") + parameter_label->get_text () + Glib::ustring("\n") + param->param_tooltip + Glib::ustring("\n"); + Glib::ustring tooltip = Glib::ustring("") + parameter_label->get_text () + Glib::ustring("\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); -- cgit v1.2.3 From 943cb6ba767b1f3fd35fb3bb74161f224a53cdc7 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Mon, 25 Sep 2017 21:33:14 +0200 Subject: Add improvements to meassure segments LPE pointed by CR --- src/live_effects/CMakeLists.txt | 4 + src/live_effects/lpe-measure-segments.cpp | 225 ++++++++++++++--------------- src/live_effects/lpe-measure-segments.h | 21 +-- src/live_effects/parameter/colorpicker.cpp | 151 +++++++++++++++++++ src/live_effects/parameter/colorpicker.h | 61 ++++++++ src/live_effects/parameter/message.cpp | 101 +++++++++++++ src/live_effects/parameter/message.h | 61 ++++++++ 7 files changed, 492 insertions(+), 132 deletions(-) create mode 100644 src/live_effects/parameter/colorpicker.cpp create mode 100644 src/live_effects/parameter/colorpicker.h create mode 100644 src/live_effects/parameter/message.cpp create mode 100644 src/live_effects/parameter/message.h (limited to 'src/live_effects') diff --git a/src/live_effects/CMakeLists.txt b/src/live_effects/CMakeLists.txt index 2c16e2383..9d18626bc 100644 --- a/src/live_effects/CMakeLists.txt +++ b/src/live_effects/CMakeLists.txt @@ -64,9 +64,11 @@ 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 @@ -155,9 +157,11 @@ 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 diff --git a/src/live_effects/lpe-measure-segments.cpp b/src/live_effects/lpe-measure-segments.cpp index 2eae30b4d..a3d4627ef 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 #include "ui/dialog/livepatheffect-editor.h" #include @@ -31,6 +32,7 @@ #include "sp-shape.h" #include "sp-path.h" #include "document.h" +#include "document-undo.h" #include #include @@ -51,8 +53,9 @@ static const Util::EnumDataConverter OMConverter(OrientationM LPEMeasureSegments::LPEMeasureSegments(LivePathEffectObject *lpeobject) : Effect(lpeobject), unit(_("Unit"), _("Unit"), "unit", &wr, this, "mm"), - fontbutton(_("Font"), _("Font Selector"), "fontbutton", &wr, this), 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), @@ -60,7 +63,9 @@ LPEMeasureSegments::LPEMeasureSegments(LivePathEffectObject *lpeobject) : 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 standar 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,19 +73,15 @@ 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 \"Style Dialog\" to more styling. Each meassure element has extra selectors...")) { //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); @@ -88,6 +89,7 @@ LPEMeasureSegments::LPEMeasureSegments(LivePathEffectObject *lpeobject) : 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,6 +129,9 @@ 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); + line_width.param_set_range(-999999.0, 999999.0); + line_width.param_set_increments(1, 1); + line_width.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); @@ -155,6 +152,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 +170,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")).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 */ Inkscape::XML::Node *arrow_path = xml_doc->createElement("svg:path"); @@ -197,13 +197,7 @@ LPEMeasureSegments::createArrowMarker(const char * mode) } 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)); @@ -256,6 +250,7 @@ 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]); @@ -281,27 +276,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); @@ -427,6 +420,12 @@ 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")).c_str()); + } else { + line->setAttribute("class", (Glib::ustring(sp_lpe_item->getId()) + Glib::ustring(" ") + Glib::ustring(this->lpeobj->getId()) + Glib::ustring(" measure-helper-lines")).c_str()); + } + line->setAttribute("class", (Glib::ustring(sp_lpe_item->getId()) + Glib::ustring(" ") + Glib::ustring(this->lpeobj->getId()) + Glib::ustring(" measure-line")).c_str()); gchar * line_str = sp_svg_write_path( line_pathv ); line->setAttribute("d" , line_str); g_free(line_str); @@ -434,7 +433,7 @@ 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;"); + Glib::ustring style; if (overflow && !arrows) { line->setAttribute("inkscape:label", "downline"); } else if (main) { @@ -449,22 +448,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()); @@ -490,6 +485,56 @@ LPEMeasureSegments::doOnApply(SPLPEItem const* lpeitem) SPLPEItem * item = const_cast(lpeitem); item->removeCurrentPathEffect(false); } + 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{\nfill:#ff0000 !important;\nstroke:none;\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;\nfill:#000000;\nfill-opacity:1;\nstroke:none;\n}"); + styleContent = styleContent + Glib::ustring("\n.measure-DIM-lines") + Glib::ustring("\n{\nstroke:#000000;\nfill:none;\n}"); + styleContent = styleContent + Glib::ustring("\n.measure-helper-lines") + Glib::ustring("\n{\nstroke:#000000;\nfill:none;\n}"); + } +// styleContent = styleContent + Glib::ustring("\n.") + Glib::ustring(lpeitem->getId()) + Glib::ustring("\n{}"); +// styleContent = styleContent + Glib::ustring("\n.measure-labels.") + Glib::ustring(lpeitem->getId()) + Glib::ustring("\n{}\n"); +// styleContent = styleContent + Glib::ustring("\n.measure-arrows.") + Glib::ustring(lpeitem->getId()) + Glib::ustring("\n{}\n"); + textNode->setContent(styleContent.c_str()); + DocumentUndo::setUndoSensitive(document, saved); } bool @@ -736,12 +781,9 @@ LPEMeasureSegments::doBeforeEffect (SPLPEItem const* lpeitem) 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")); @@ -807,65 +849,12 @@ 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::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(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(_("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(vbox); -} - void LPEMeasureSegments::transform_multiply(Geom::Affine const& postmul, bool set) { sp_lpe_item_update_patheffect(sp_lpe_item, false, false); } -void -LPEMeasureSegments::onExpanderChanged() -{ - expanded = expander->get_expanded(); -} - Geom::PathVector LPEMeasureSegments::doEffect_path(Geom::PathVector const &path_in) { diff --git a/src/live_effects/lpe-measure-segments.h b/src/live_effects/lpe-measure-segments.h index 7383aeca8..7c4fd4073 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 +#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 #include <2geom/angle.h> #include <2geom/ray.h> @@ -48,14 +48,13 @@ public: 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 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 orientation; + ColorPickerParam coloropacity; + FontButtonParam fontbutton; ScalarParam precision; ScalarParam fix_overlaps; ScalarParam position; @@ -63,6 +62,7 @@ private: ScalarParam text_right_left; ScalarParam helpline_distance; ScalarParam helpline_overlap; + ScalarParam line_width; ScalarParam scale; TextParam format; TextParam blacklist; @@ -71,22 +71,15 @@ 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; - LPEMeasureSegments(const LPEMeasureSegments &); LPEMeasureSegments &operator=(const LPEMeasureSegments &); 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 +#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 + +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 (label), true, true); + hbox->pack_start(*dynamic_cast (colorpickerwdg), true, true); + return dynamic_cast (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 +#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/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 +#include "live_effects/parameter/message.h" +#include "live_effects/effect.h" +#include + +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 (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 (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 +#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 : -- cgit v1.2.3 From db78328c47443816f23f32f59acd8f7df0ef4fee Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Tue, 26 Sep 2017 01:35:27 +0200 Subject: CSS fixes to measure line LPE --- src/live_effects/lpe-measure-segments.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-measure-segments.cpp b/src/live_effects/lpe-measure-segments.cpp index a3d4627ef..26e6cbe03 100644 --- a/src/live_effects/lpe-measure-segments.cpp +++ b/src/live_effects/lpe-measure-segments.cpp @@ -421,11 +421,10 @@ 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")).c_str()); + 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")).c_str()); + 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()); } - line->setAttribute("class", (Glib::ustring(sp_lpe_item->getId()) + Glib::ustring(" ") + Glib::ustring(this->lpeobj->getId()) + Glib::ustring(" measure-line")).c_str()); gchar * line_str = sp_svg_write_path( line_pathv ); line->setAttribute("d" , line_str); g_free(line_str); @@ -525,10 +524,9 @@ LPEMeasureSegments::doOnApply(SPLPEItem const* lpeitem) } 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{\nfill:#ff0000 !important;\nstroke:none;\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;\nfill:#000000;\nfill-opacity:1;\nstroke:none;\n}"); - styleContent = styleContent + Glib::ustring("\n.measure-DIM-lines") + Glib::ustring("\n{\nstroke:#000000;\nfill:none;\n}"); - styleContent = styleContent + Glib::ustring("\n.measure-helper-lines") + Glib::ustring("\n{\nstroke:#000000;\nfill:none;\n}"); + 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}"); } // styleContent = styleContent + Glib::ustring("\n.") + Glib::ustring(lpeitem->getId()) + Glib::ustring("\n{}"); // styleContent = styleContent + Glib::ustring("\n.measure-labels.") + Glib::ustring(lpeitem->getId()) + Glib::ustring("\n{}\n"); -- cgit v1.2.3 From 4ced018164553d115a24947ec74dace836e99732 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Sat, 30 Sep 2017 02:25:47 +0200 Subject: Hunted every GList to the last (except in libnrtype and libcroco) --- src/live_effects/parameter/togglebutton.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/parameter/togglebutton.cpp b/src/live_effects/parameter/togglebutton.cpp index 16b8f9067..e26884d6a 100644 --- a/src/live_effects/parameter/togglebutton.cpp +++ b/src/live_effects/parameter/togglebutton.cpp @@ -147,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 children = Glib::wrap(GTK_CONTAINER(box_button))->get_children(); if (!param_label.empty()) { + Gtk::Label *lab = dynamic_cast(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(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); } } } -- cgit v1.2.3 From c94904488d68f4c4c97a5eedb2067d82e3859790 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 30 Sep 2017 14:25:40 +0200 Subject: Improvements to meassure segments LPE and a little styling tweak to default LPE params --- src/live_effects/effect.cpp | 4 +- src/live_effects/lpe-measure-segments.cpp | 87 ++++++++++--------------------- src/live_effects/lpe-measure-segments.h | 3 +- 3 files changed, 32 insertions(+), 62 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index fcb4b5cb2..703852881 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -873,7 +873,9 @@ Effect::defaultParamSet() expander->set_expanded(false); vbox->pack_start(*dynamic_cast (expander), true, true, 2); if (has_params) { - return dynamic_cast(vbox); + Gtk::Widget *vboxwidg = dynamic_cast(vbox); + vboxwidg->set_margin_bottom(15); + return vboxwidg; } else { return NULL; } diff --git a/src/live_effects/lpe-measure-segments.cpp b/src/live_effects/lpe-measure-segments.cpp index 26e6cbe03..b929f5154 100644 --- a/src/live_effects/lpe-measure-segments.cpp +++ b/src/live_effects/lpe-measure-segments.cpp @@ -60,10 +60,9 @@ LPEMeasureSegments::LPEMeasureSegments(LivePathEffectObject *lpeobject) : 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 standar are 0.25 or 0.35"), "line_width", &wr, this, 0.25), + 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}"), @@ -86,7 +85,6 @@ LPEMeasureSegments::LPEMeasureSegments(LivePathEffectObject *lpeobject) : registerParameter(&fix_overlaps); registerParameter(&position); registerParameter(&text_top_bottom); - registerParameter(&text_right_left); registerParameter(&helpline_distance); registerParameter(&helpline_overlap); registerParameter(&line_width); @@ -132,9 +130,6 @@ LPEMeasureSegments::LPEMeasureSegments(LivePathEffectObject *lpeobject) : line_width.param_set_range(-999999.0, 999999.0); line_width.param_set_increments(1, 1); line_width.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); helpline_distance.param_set_range(-999999.0, 999999.0); helpline_distance.param_set_increments(1, 1); helpline_distance.param_set_digits(2); @@ -177,7 +172,7 @@ LPEMeasureSegments::createArrowMarker(const char * mode) } 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")).c_str()); + 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"); @@ -193,9 +188,9 @@ 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()); arrow_path->setAttribute("style", style.c_str()); arrow->addChild(arrow_path, NULL); @@ -237,7 +232,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]); @@ -252,7 +246,6 @@ LPEMeasureSegments::createTextLabel(Geom::Point pos, size_t counter, double leng 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"); @@ -355,7 +348,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) { @@ -371,7 +364,10 @@ 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){ + + if (main && + std::abs(text_top_bottom) < fontsize/1.5 && + hide_back){ Geom::Path line_path; double k = 0; if (flip_side) { @@ -433,9 +429,7 @@ LPEMeasureSegments::createLine(Geom::Point start,Geom::Point end, const char * i line_pathv.clear(); Glib::ustring style; - if (overflow && !arrows) { - line->setAttribute("inkscape:label", "downline"); - } else if (main) { + if (main) { line->setAttribute("inkscape:label", "dinline"); if (arrows_outside) { style = style + Glib::ustring("marker-start:url(#ArrowDINout-start);marker-end:url(#ArrowDINout-end);"); @@ -528,9 +522,6 @@ LPEMeasureSegments::doOnApply(SPLPEItem const* lpeitem) 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}"); } -// styleContent = styleContent + Glib::ustring("\n.") + Glib::ustring(lpeitem->getId()) + Glib::ustring("\n{}"); -// styleContent = styleContent + Glib::ustring("\n.measure-labels.") + Glib::ustring(lpeitem->getId()) + Glib::ustring("\n{}\n"); -// styleContent = styleContent + Glib::ustring("\n.measure-arrows.") + Glib::ustring(lpeitem->getId()) + Glib::ustring("\n{}\n"); textNode->setContent(styleContent.c_str()); DocumentUndo::setUndoSensitive(document, saved); } @@ -713,7 +704,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); @@ -744,41 +735,15 @@ 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(line_width / doc_scale, "mm", display_unit.c_str()); SPCSSAttr *css = sp_repr_css_attr_new(); @@ -793,18 +758,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))) { @@ -815,10 +784,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))) { diff --git a/src/live_effects/lpe-measure-segments.h b/src/live_effects/lpe-measure-segments.h index 7c4fd4073..0b4ed5ef7 100644 --- a/src/live_effects/lpe-measure-segments.h +++ b/src/live_effects/lpe-measure-segments.h @@ -46,7 +46,7 @@ public: 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 createArrowMarker(const char * mode); bool hasMeassure (size_t i); @@ -59,7 +59,6 @@ private: ScalarParam fix_overlaps; ScalarParam position; ScalarParam text_top_bottom; - ScalarParam text_right_left; ScalarParam helpline_distance; ScalarParam helpline_overlap; ScalarParam line_width; -- cgit v1.2.3 From 3e9296b964b8d0bd941991e05866882a689f4ac4 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 30 Sep 2017 18:15:54 +0200 Subject: Fix bug in comment #20 From Maren in bug #1715433. Clone original LPE can no longer be used to fill a powerstroke path --- src/live_effects/lpe-clone-original.cpp | 8 ++++---- src/live_effects/parameter/item.cpp | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-clone-original.cpp b/src/live_effects/lpe-clone-original.cpp index b035cc1d0..6e5ad66bf 100644 --- a/src/live_effects/lpe-clone-original.cpp +++ b/src/live_effects/lpe-clone-original.cpp @@ -181,7 +181,7 @@ LPECloneOriginal::cloneAttrbutes(SPObject *origin, SPObject *dest, const char * 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 @@ -189,9 +189,9 @@ LPECloneOriginal::doBeforeEffect (SPLPEItem const* lpeitem){ if (linkeditem.linksToItem()) { Glib::ustring attr = ""; if (method != CLM_NONE) { - attr.append("d,"); + 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); } @@ -199,7 +199,7 @@ LPECloneOriginal::doBeforeEffect (SPLPEItem const* lpeitem){ 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(",")); + style_attr += Glib::ustring(style_attributes.param_getSVGValue()) + Glib::ustring(","); SPItem * origin = SP_ITEM(linkeditem.getObject()); SPItem * dest = SP_ITEM(sp_lpe_item); diff --git a/src/live_effects/parameter/item.cpp b/src/live_effects/parameter/item.cpp index 149fd6627..e075cab1a 100644 --- a/src/live_effects/parameter/item.cpp +++ b/src/live_effects/parameter/item.cpp @@ -101,7 +101,10 @@ 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 * -- cgit v1.2.3 From 6d91668aef6c3bcf4bfe247de1f58ba4b11cf367 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sun, 1 Oct 2017 13:12:42 +0200 Subject: Add button to apply on path parameter as suggest Maren in bug #1715433#23 --- src/live_effects/parameter/text.cpp | 24 ++++++++++++++++++++---- src/live_effects/parameter/text.h | 1 + 2 files changed, 21 insertions(+), 4 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/parameter/text.cpp b/src/live_effects/parameter/text.cpp index 3f41bfeed..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 +#include #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 + namespace Inkscape { namespace LivePathEffect { @@ -124,6 +125,14 @@ TextParam::param_getDefaultSVGValue() const 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() { @@ -131,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 (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(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 (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 460ef8629..a9de26a52 100644 --- a/src/live_effects/parameter/text.h +++ b/src/live_effects/parameter/text.h @@ -42,6 +42,7 @@ public: 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); -- cgit v1.2.3 From ad03eb3eed2ad07c086fea71326c56701f3cf6e1 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sun, 1 Oct 2017 15:05:59 +0200 Subject: A little styling tweak to a LPE expander --- src/live_effects/effect.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/live_effects') diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 703852881..2332ab8f2 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -874,7 +874,8 @@ Effect::defaultParamSet() vbox->pack_start(*dynamic_cast (expander), true, true, 2); if (has_params) { Gtk::Widget *vboxwidg = dynamic_cast(vbox); - vboxwidg->set_margin_bottom(15); + vboxwidg->set_margin_bottom(10); + vboxwidg->set_margin_top(5); return vboxwidg; } else { return NULL; -- cgit v1.2.3 From fc21cbb9a2d2f830c217d7ea96311be36a561e62 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sun, 1 Oct 2017 23:59:23 +0200 Subject: Add better transform handle to Clone Item LPE --- src/live_effects/effect.cpp | 1 + src/live_effects/lpe-clone-original.cpp | 81 ++++++++++++++++++++++-- src/live_effects/lpe-clone-original.h | 11 +++- src/live_effects/parameter/item.cpp | 10 +++ src/live_effects/parameter/item.h | 5 +- src/live_effects/parameter/originalitem.cpp | 14 ++-- src/live_effects/parameter/originalitem.h | 2 - src/live_effects/parameter/originalitemarray.cpp | 2 +- 8 files changed, 104 insertions(+), 22 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 2332ab8f2..2e1160764 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -81,6 +81,7 @@ #include "display/curve.h" #include #include +#include namespace Inkscape { diff --git a/src/live_effects/lpe-clone-original.cpp b/src/live_effects/lpe-clone-original.cpp index 6e5ad66bf..2d577bffd 100644 --- a/src/live_effects/lpe-clone-original.cpp +++ b/src/live_effects/lpe-clone-original.cpp @@ -46,7 +46,10 @@ LPECloneOriginal::LPECloneOriginal(LivePathEffectObject *lpeobject) : this->getRepr()->setAttribute("method", "bsplinespiro"); this->getRepr()->setAttribute("allow_transforms", "false"); }; - + is_updating = false; + listening = false; + previus_method = CLM_D; + linked = g_strdup(this->getRepr()->attribute("linkeditem")); registerParameter(&linkeditem); registerParameter(&method); registerParameter(&attributes); @@ -183,9 +186,9 @@ LPECloneOriginal::cloneAttrbutes(SPObject *origin, SPObject *dest, const char * sp_repr_css_write_string(css_dest,css_str); dest->getRepr()->setAttribute("style", g_strdup(css_str.c_str())); } - void LPECloneOriginal::doBeforeEffect (SPLPEItem const* lpeitem){ + start_listening(); if (linkeditem.linksToItem()) { Glib::ustring attr = ""; if (method != CLM_NONE) { @@ -201,18 +204,82 @@ LPECloneOriginal::doBeforeEffect (SPLPEItem const* lpeitem){ } style_attr += Glib::ustring(style_attributes.param_getSVGValue()) + Glib::ustring(","); - SPItem * origin = SP_ITEM(linkeditem.getObject()); - SPItem * dest = SP_ITEM(sp_lpe_item); - cloneAttrbutes(origin, dest, g_strdup(attr.c_str()), g_strdup(style_attr.c_str())); + 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 ((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(); + } + 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 (!allow_transforms) { - SP_ITEM(dest)->getRepr()->setAttribute("transform", SP_ITEM(origin)->getAttribute("transform")); + SP_ITEM(dest)->getRepr()->setAttribute("transform", SP_ITEM(orig)->getAttribute("transform")); } + linked = g_strdup(id); + g_free(id); + } else { + linked = g_strdup(""); } + previus_method = method; } -LPECloneOriginal::~LPECloneOriginal() +void +LPECloneOriginal::start_listening() +{ + if ( !sp_lpe_item || listening ) { + return; + } + quit_listening(); + modified_connection = SP_OBJECT(sp_lpe_item)->connectModified(sigc::mem_fun(*this, &LPECloneOriginal::modified)); + listening = true; +} + +void +LPECloneOriginal::quit_listening(void) { + 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); } void diff --git a/src/live_effects/lpe-clone-original.h b/src/live_effects/lpe-clone-original.h index b78b144bc..e429d6817 100644 --- a/src/live_effects/lpe-clone-original.h +++ b/src/live_effects/lpe-clone-original.h @@ -8,13 +8,14 @@ * * Released under GNU GPL, read the file 'COPYING' for more information */ -#include #include "live_effects/effect.h" #include "live_effects/parameter/enum.h" #include "live_effects/parameter/originalitem.h" #include "live_effects/parameter/text.h" #include "live_effects/lpegroupbbox.h" +#include + namespace Inkscape { namespace LivePathEffect { @@ -34,6 +35,9 @@ public: virtual void doBeforeEffect (SPLPEItem const* lpeitem); virtual void transform_multiply(Geom::Affine const& postmul, bool set); 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; @@ -41,6 +45,11 @@ private: TextParam attributes; TextParam style_attributes; BoolParam allow_transforms; + gchar * linked; + Clonelpemethod previus_method; + bool listening; + bool is_updating; + sigc::connection modified_connection; LPECloneOriginal(const LPECloneOriginal&); LPECloneOriginal& operator=(const LPECloneOriginal&); }; diff --git a/src/live_effects/parameter/item.cpp b/src/live_effects/parameter/item.cpp index e075cab1a..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)); } @@ -213,8 +214,17 @@ 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() { diff --git a/src/live_effects/parameter/item.h b/src/live_effects/parameter/item.h index b98294258..d32098db5 100644 --- a/src/live_effects/parameter/item.h +++ b/src/live_effects/parameter/item.h @@ -35,14 +35,13 @@ 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 &hp_vec); - sigc::signal signal_item_pasted; sigc::signal 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: @@ -61,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/originalitem.cpp b/src/live_effects/parameter/originalitem.cpp index 6de70be17..e828e1800 100644 --- a/src/live_effects/parameter/originalitem.cpp +++ b/src/live_effects/parameter/originalitem.cpp @@ -35,7 +35,6 @@ OriginalItemParam::OriginalItemParam( const Glib::ustring& label, const Glib::us Effect* effect) : ItemParam(label, tip, key, wr, effect, "") { - _insensitive = false; } OriginalItemParam::~OriginalItemParam() @@ -88,17 +87,16 @@ OriginalItemParam::param_newWidget() void OriginalItemParam::linked_modified_callback(SPObject *linked_obj, guint /*flags*/) { - if (!_insensitive) { - 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 9b692c503..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 setInsensitive(bool insensitive) { insensitive = _insensitive; } 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 _insensitive; OriginalItemParam(const OriginalItemParam&); OriginalItemParam& operator=(const OriginalItemParam&); }; diff --git a/src/live_effects/parameter/originalitemarray.cpp b/src/live_effects/parameter/originalitemarray.cpp index 83c237f2e..830d8aa90 100644 --- a/src/live_effects/parameter/originalitemarray.cpp +++ b/src/live_effects/parameter/originalitemarray.cpp @@ -444,7 +444,7 @@ gchar * OriginalItemArrayParam::param_getSVGValue() const gchar * OriginalItemArrayParam::param_getDefaultSVGValue() const { - return ""; + return g_strdup(""); } void OriginalItemArrayParam::update() -- cgit v1.2.3 From 5e751a51beffbf8a1a292a16c6850215945c95e5 Mon Sep 17 00:00:00 2001 From: Jabiertxo Arraiza Cenoz Date: Mon, 2 Oct 2017 14:11:30 +0200 Subject: Improvements to translations in clone LPE --- src/live_effects/lpe-clone-original.cpp | 17 ++++++++++++++++- src/live_effects/lpe-clone-original.h | 2 ++ 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-clone-original.cpp b/src/live_effects/lpe-clone-original.cpp index 2d577bffd..15968dd56 100644 --- a/src/live_effects/lpe-clone-original.cpp +++ b/src/live_effects/lpe-clone-original.cpp @@ -48,13 +48,15 @@ LPECloneOriginal::LPECloneOriginal(LivePathEffectObject *lpeobject) : }; is_updating = false; listening = false; - previus_method = CLM_D; linked = g_strdup(this->getRepr()->attribute("linkeditem")); registerParameter(&linkeditem); registerParameter(&method); registerParameter(&attributes); registerParameter(&style_attributes); 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(); } @@ -236,15 +238,27 @@ LPECloneOriginal::doBeforeEffect (SPLPEItem const* lpeitem){ { dest->transform *= Geom::Translate((*d_bbox).corner(0) - (*o_bbox).corner(0)).inverse(); } + 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")); + } } + + 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; } void @@ -280,6 +294,7 @@ LPECloneOriginal::~LPECloneOriginal() { quit_listening(); g_free(linked); + g_free(prev_affine); } void diff --git a/src/live_effects/lpe-clone-original.h b/src/live_effects/lpe-clone-original.h index e429d6817..8327b6767 100644 --- a/src/live_effects/lpe-clone-original.h +++ b/src/live_effects/lpe-clone-original.h @@ -49,6 +49,8 @@ private: 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&); -- cgit v1.2.3 From 24e870081a4213b3eda28d9f044fbe51520676f3 Mon Sep 17 00:00:00 2001 From: Jabiertxo Arraiza Cenoz Date: Fri, 6 Oct 2017 19:34:00 +0200 Subject: Fix for bug #412928 Allow clip/mask set inverse --- src/live_effects/lpe-powerclip.cpp | 133 +++++++++++++++++------------------- src/live_effects/lpe-powerclip.h | 12 ++-- src/live_effects/lpe-powermask.cpp | 135 +++++++++++++------------------------ src/live_effects/lpe-powermask.h | 11 ++- 4 files changed, 117 insertions(+), 174 deletions(-) (limited to 'src/live_effects') 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 // TODO due to internal breakage in glibmm headers, this must be last: #include @@ -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(topright); - clip_box.appendNew(bottomright); - clip_box.appendNew(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(topright); + clip_box.appendNew(bottomright); + clip_box.appendNew(bottomleft); + clip_box.close(); + //clip_box *= sp_lpe_item->i2dt_affine(); std::vector clip_path_list = clip_path->childList(true); for ( std::vector::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; } } @@ -216,36 +240,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; @@ -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(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 clip_path_list = clip_path->childList(true); for ( std::vector::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 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 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::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 // TODO due to internal breakage in glibmm headers, this must be last: #include @@ -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(topright); - mask_box.appendNew(bottomright); - mask_box.appendNew(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(topright); + mask_box.appendNew(bottomright); + mask_box.appendNew(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::iterator it = param_vector.begin(); - while (it != param_vector.end()) { - if ((*it)->widget_is_visible) { - Parameter * param = *it; - Gtk::Widget * widg = dynamic_cast(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(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 -- cgit v1.2.3 From 8bc47bf27b1cdb5a05a88a0600ad69a2a6bfde46 Mon Sep 17 00:00:00 2001 From: Stefano Facchini Date: Sun, 8 Oct 2017 12:35:03 +0200 Subject: Circle3pts LPE: handle overlapping points If two of the three points overlap, just draw the circle having that segment as diameter. This is not rigorous mathematically, but it is a reasonable behavior and avoid a crash when snapping is on. --- src/live_effects/lpe-circle_3pts.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/live_effects') 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); -- cgit v1.2.3 From f318dbfe434769ab62b4f9d2971de89f1ebffc71 Mon Sep 17 00:00:00 2001 From: Jabiertxo Arraiza Cenoz Date: Mon, 9 Oct 2017 20:33:01 +0200 Subject: Fixes for transforms in LPE shapes --- src/live_effects/lpe-measure-segments.cpp | 21 +++++++++++++++++---- src/live_effects/lpe-measure-segments.h | 3 ++- 2 files changed, 19 insertions(+), 5 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-measure-segments.cpp b/src/live_effects/lpe-measure-segments.cpp index b929f5154..738990bc0 100644 --- a/src/live_effects/lpe-measure-segments.cpp +++ b/src/live_effects/lpe-measure-segments.cpp @@ -31,6 +31,8 @@ #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 @@ -136,6 +138,7 @@ LPEMeasureSegments::LPEMeasureSegments(LivePathEffectObject *lpeobject) : 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() {} @@ -566,7 +569,7 @@ void LPEMeasureSegments::doBeforeEffect (SPLPEItem const* lpeitem) { SPLPEItem * splpeitem = const_cast(lpeitem); - sp_lpe_item->parent = dynamic_cast(splpeitem->parent); + SPDocument * document = SP_ACTIVE_DOCUMENT; if (!document) { return; @@ -589,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}")); } @@ -819,7 +827,12 @@ LPEMeasureSegments::doOnRemove (SPLPEItem const* /*lpeitem*/) void LPEMeasureSegments::transform_multiply(Geom::Affine const& postmul, bool set) { - sp_lpe_item_update_patheffect(sp_lpe_item, false, false); + SPStar * star = dynamic_cast(sp_lpe_item); + SPSpiral * spiral = dynamic_cast(sp_lpe_item); + if((spiral || star) && !postmul.withoutTranslation().isUniformScale()) { + star_ellipse_fix = postmul; + sp_lpe_item_update_patheffect(sp_lpe_item, false, false); + } } Geom::PathVector diff --git a/src/live_effects/lpe-measure-segments.h b/src/live_effects/lpe-measure-segments.h index 0b4ed5ef7..3b14fb191 100644 --- a/src/live_effects/lpe-measure-segments.h +++ b/src/live_effects/lpe-measure-segments.h @@ -44,7 +44,7 @@ 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 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 remove, bool arrows = false); void createTextLabel(Geom::Point pos, size_t counter, double length, Geom::Coord angle, bool remove, bool valid); @@ -79,6 +79,7 @@ private: double anotation_width; double previous_size; double arrow_gap; + Geom::Affine star_ellipse_fix; LPEMeasureSegments(const LPEMeasureSegments &); LPEMeasureSegments &operator=(const LPEMeasureSegments &); -- cgit v1.2.3 From c001f1a01e89595de48dcae99411e1ac0b18209a Mon Sep 17 00:00:00 2001 From: Jabiertxo Arraiza Cenoz Date: Tue, 10 Oct 2017 13:08:51 +0200 Subject: Fix a bug pointed by CR on copyng throught layers --- src/live_effects/lpe-measure-segments.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-measure-segments.cpp b/src/live_effects/lpe-measure-segments.cpp index 738990bc0..90f469963 100644 --- a/src/live_effects/lpe-measure-segments.cpp +++ b/src/live_effects/lpe-measure-segments.cpp @@ -370,8 +370,8 @@ LPEMeasureSegments::createLine(Geom::Point start,Geom::Point end, const char * i if (main && std::abs(text_top_bottom) < fontsize/1.5 && - hide_back){ - Geom::Path line_path; + hide_back) + { double k = 0; if (flip_side) { k = (Geom::distance(start,end)/2.0) + arrow_gap - (anotation_width/2.0); @@ -389,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(start - Point::polar(angle, k)); line_pathv.push_back(line_path); line_path.clear(); @@ -397,8 +397,7 @@ LPEMeasureSegments::createLine(Geom::Point start,Geom::Point end, const char * i line_path.appendNew(end); line_pathv.push_back(line_path); } else { - Geom::Path line_path; - line_path.start(start); + Geom::Path line_path(start); line_path.appendNew(end); line_pathv.push_back(line_path); } -- cgit v1.2.3 From 8a5208f4a875cd7a70739f5b559e6a116c0c280a Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Tue, 10 Oct 2017 23:06:27 +0200 Subject: Prevent crash in measure LPE when pasting LPE to multiple elements --- src/live_effects/lpe-measure-segments.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-measure-segments.cpp b/src/live_effects/lpe-measure-segments.cpp index 90f469963..6d1f46535 100644 --- a/src/live_effects/lpe-measure-segments.cpp +++ b/src/live_effects/lpe-measure-segments.cpp @@ -479,6 +479,7 @@ LPEMeasureSegments::doOnApply(SPLPEItem const* lpeitem) g_warning("LPE measure line can only be applied to shapes (not groups)."); SPLPEItem * item = const_cast(lpeitem); item->removeCurrentPathEffect(false); + return; } SPDocument *document = SP_ACTIVE_DOCUMENT; bool saved = DocumentUndo::getUndoSensitive(document); @@ -523,8 +524,8 @@ LPEMeasureSegments::doOnApply(SPLPEItem const* lpeitem) 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()); } - textNode->setContent(styleContent.c_str()); DocumentUndo::setUndoSensitive(document, saved); } -- cgit v1.2.3 From ee527cbb228c6fba9c83bba5058d1a68ac647060 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 14 Oct 2017 21:29:10 +0200 Subject: Fixing problems with nested LPE and convert to paths --- src/live_effects/effect.cpp | 4 ++-- src/live_effects/lpe-bendpath.cpp | 8 ++++++++ src/live_effects/lpe-bendpath.h | 2 ++ src/live_effects/lpe-measure-segments.h | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 2e1160764..5674e29dc 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -563,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(); } diff --git a/src/live_effects/lpe-bendpath.cpp b/src/live_effects/lpe-bendpath.cpp index 39714e629..ff5f738eb 100644 --- a/src/live_effects/lpe-bendpath.cpp +++ b/src/live_effects/lpe-bendpath.cpp @@ -151,6 +151,14 @@ LPEBendPath::resetDefaults(SPItem const* item) bend_path.set_new_value( path.toPwSb(), true ); } +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 &hp_vec) { 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 &hp_vec); virtual void addKnotHolderEntities(KnotHolder * knotholder, SPItem * item); diff --git a/src/live_effects/lpe-measure-segments.h b/src/live_effects/lpe-measure-segments.h index 3b14fb191..903a5cbd2 100644 --- a/src/live_effects/lpe-measure-segments.h +++ b/src/live_effects/lpe-measure-segments.h @@ -44,7 +44,7 @@ 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 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 remove, bool arrows = false); void createTextLabel(Geom::Point pos, size_t counter, double length, Geom::Coord angle, bool remove, bool valid); -- cgit v1.2.3 From 65f6d664e3b0cc41356807a2df728655fbf62c1c Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 14 Oct 2017 21:33:23 +0200 Subject: Add note to use important in measure dialog --- src/live_effects/lpe-measure-segments.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-measure-segments.cpp b/src/live_effects/lpe-measure-segments.cpp index 6d1f46535..5ed587922 100644 --- a/src/live_effects/lpe-measure-segments.cpp +++ b/src/live_effects/lpe-measure-segments.cpp @@ -76,7 +76,7 @@ LPEMeasureSegments::LPEMeasureSegments(LivePathEffectObject *lpeobject) : local_locale(_("Local Number Format"), _("Local number format"), "local_locale", &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), - message(_("Info Box"), _("Important messages"), "message", &wr, this, _("Use \"Style Dialog\" to more styling. Each meassure element has extra selectors...")) + message(_("Info Box"), _("Important messages"), "message", &wr, this, _("Use \"Style Dialog\" 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); -- cgit v1.2.3 From c943a6db760a6c5eb8110179c240e8f7bd021ac5 Mon Sep 17 00:00:00 2001 From: Jan Lingscheid Date: Mon, 16 Oct 2017 13:00:24 +0200 Subject: Remove std::auto_ptr As C++11-compiler is now mandatory, conditional use of auto_ptr is no longer usefull. This commit does not remove the usage of std::auto_ptr in 2geom. --- src/live_effects/lpe-interpolate_points.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/live_effects') 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 interpolator( Geom::Interpolate::Interpolator::create(static_cast(interpolator_type.get_value())) ); -#else std::unique_ptr interpolator( Geom::Interpolate::Interpolator::create(static_cast(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()) -- cgit v1.2.3 From 347e5f3b12400d94812eefc275e1197ed224470b Mon Sep 17 00:00:00 2001 From: Stefano Facchini Date: Tue, 17 Oct 2017 22:22:10 +0200 Subject: Remove unused icon-size.h --- src/live_effects/parameter/originalitemarray.cpp | 1 - src/live_effects/parameter/originalpatharray.cpp | 1 - src/live_effects/parameter/togglebutton.h | 1 - 3 files changed, 3 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/parameter/originalitemarray.cpp b/src/live_effects/parameter/originalitemarray.cpp index 830d8aa90..f45de4ad8 100644 --- a/src/live_effects/parameter/originalitemarray.cpp +++ b/src/live_effects/parameter/originalitemarray.cpp @@ -19,7 +19,6 @@ #include #include "inkscape.h" -#include "icon-size.h" #include "ui/clipboard.h" #include "svg/svg.h" #include "svg/stringstream.h" diff --git a/src/live_effects/parameter/originalpatharray.cpp b/src/live_effects/parameter/originalpatharray.cpp index 4535b6aa5..a98c91770 100644 --- a/src/live_effects/parameter/originalpatharray.cpp +++ b/src/live_effects/parameter/originalpatharray.cpp @@ -23,7 +23,6 @@ #include #include "inkscape.h" -#include "icon-size.h" #include "ui/clipboard.h" #include "svg/svg.h" #include "svg/stringstream.h" diff --git a/src/live_effects/parameter/togglebutton.h b/src/live_effects/parameter/togglebutton.h index 4d043b340..c5f8a3c28 100644 --- a/src/live_effects/parameter/togglebutton.h +++ b/src/live_effects/parameter/togglebutton.h @@ -12,7 +12,6 @@ #include #include "live_effects/parameter/parameter.h" -#include "icon-size.h" #include "ui/widget/registered-widget.h" namespace Inkscape { -- cgit v1.2.3 From 935c7b7808cb7c0e2d9952fda8962359d63781a2 Mon Sep 17 00:00:00 2001 From: Stefano Facchini Date: Tue, 17 Oct 2017 22:27:43 +0200 Subject: Remove all unused makefile.in --- src/live_effects/makefile.in | 17 ----------------- src/live_effects/parameter/makefile.in | 17 ----------------- 2 files changed, 34 deletions(-) delete mode 100644 src/live_effects/makefile.in delete mode 100644 src/live_effects/parameter/makefile.in (limited to 'src/live_effects') 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/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) -- cgit v1.2.3 From 01225070a051a96818fd9d0c218cafb982cdce21 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sun, 29 Oct 2017 13:56:41 +0100 Subject: Fix a bug converting to paths nested LPE with powerstroke --- src/live_effects/lpe-powerstroke.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index 6576e6a62..8066ade61 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -255,7 +255,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(lpeitem); SPCSSAttr *css = sp_repr_css_attr_new (); if (lpeitem->style->fill.isPaintserver()) { -- cgit v1.2.3