diff options
| author | Jabiertxof <jtx@jtx> | 2017-01-23 22:40:10 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx> | 2017-01-23 22:40:10 +0000 |
| commit | 8a7004fa550bb1d5eff8ca6ce716b391ea8d9ff8 (patch) | |
| tree | 598923b2b554aeaf77457a83c399c616a7ecc162 /src/live_effects | |
| parent | Remove unnecesatry text parameter (diff) | |
| parent | fix nodes reverting back during editing (diff) | |
| download | inkscape-8a7004fa550bb1d5eff8ca6ce716b391ea8d9ff8.tar.gz inkscape-8a7004fa550bb1d5eff8ca6ce716b391ea8d9ff8.zip | |
Add fixes sugested by Martin Owens
(bzr r15392.1.7)
Diffstat (limited to 'src/live_effects')
| -rw-r--r-- | src/live_effects/effect.cpp | 65 | ||||
| -rw-r--r-- | src/live_effects/effect.h | 2 | ||||
| -rw-r--r-- | src/live_effects/lpe-copy_rotate.cpp | 127 | ||||
| -rw-r--r-- | src/live_effects/lpe-copy_rotate.h | 2 | ||||
| -rw-r--r-- | src/live_effects/lpe-patternalongpath.cpp | 14 | ||||
| -rw-r--r-- | src/live_effects/lpe-perspective-envelope.cpp | 2 | ||||
| -rw-r--r-- | src/live_effects/parameter/vector.cpp | 2 |
7 files changed, 109 insertions, 105 deletions
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 5cc0d6f20..227f91594 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -392,15 +392,15 @@ Effect::doOnApply (SPLPEItem const*/*lpeitem*/) } void -Effect::setSelectedNodePoints(std::vector<Geom::Point> sNP) +Effect::setCurrentZoom(double cZ) { - selectedNodesPoints = sNP; + current_zoom = cZ; } void -Effect::setCurrentZoom(double cZ) +Effect::setSelectedNodePoints(std::vector<Geom::Point> sNP) { - current_zoom = cZ; + selectedNodesPoints = sNP; } bool @@ -423,6 +423,63 @@ Effect::isNodePointSelected(Geom::Point const &nodePoint) const return false; } +void +Effect::processObjects(LpeAction lpe_action) +{ + SPDocument * document = SP_ACTIVE_DOCUMENT; + for (std::vector<const char *>::iterator el_it = items.begin(); + el_it != items.end(); ++el_it) { + const char * id = *el_it; + if (!id || strlen(id) == 0) { + return; + } + SPObject *elemref = NULL; + if (elemref = document->getObjectById(id)) { + Inkscape::XML::Node * elemnode = elemref->getRepr(); + std::vector<SPItem*> item_list; + item_list.push_back(SP_ITEM(elemref)); + std::vector<Inkscape::XML::Node*> item_to_select; + std::vector<SPItem*> item_selected; + SPCSSAttr *css; + Glib::ustring css_str; + switch (lpe_action){ + case LPE_TO_OBJECTS: + if (SP_ITEM(elemref)->isHidden()) { + elemref->deleteObject(); + } else { + if (elemnode->attribute("inkscape:path-effect")) { + sp_item_list_to_curves(item_list, item_selected, item_to_select); + } + elemnode->setAttribute("sodipodi:insensitive", NULL); + } + break; + + case LPE_ERASE: + elemref->deleteObject(); + break; + + case LPE_VISIBILITY: + css = sp_repr_css_attr_new(); + sp_repr_css_attr_add_from_string(css, elemref->getRepr()->attribute("style")); + if (!this->isVisible()/* && std::strcmp(elemref->getId(),sp_lpe_item->getId()) != 0*/) { + css->setAttribute("display", "none"); + } else { + css->setAttribute("display", NULL); + } + sp_repr_css_write_string(css,css_str); + elemnode->setAttribute("style", css_str.c_str()); + break; + + default: + break; + } + } + } + if (lpe_action == LPE_ERASE || lpe_action == LPE_TO_OBJECTS) { + items.clear(); + } +} + /** * Is performed each time before the effect is updated. */ diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h index 9a2d4c67d..2f42ab3f6 100644 --- a/src/live_effects/effect.h +++ b/src/live_effects/effect.h @@ -79,6 +79,7 @@ public: static int acceptsNumClicks(EffectType type); int acceptsNumClicks() const { return acceptsNumClicks(effectType()); } void doAcceptPathPreparations(SPLPEItem *lpeitem); + void processObjects(LpeAction lpe_action); /* * isReady() indicates whether all preparations which are necessary to apply the LPE are done, @@ -171,6 +172,7 @@ protected: bool concatenate_before_pwd2; SPLPEItem * sp_lpe_item; // these get stored in doBeforeEffect_impl, and derived classes may do as they please with them. + std::vector<const char *> items; double current_zoom; std::vector<Geom::Point> selectedNodesPoints; private: diff --git a/src/live_effects/lpe-copy_rotate.cpp b/src/live_effects/lpe-copy_rotate.cpp index a074665b5..a4d844fdd 100644 --- a/src/live_effects/lpe-copy_rotate.cpp +++ b/src/live_effects/lpe-copy_rotate.cpp @@ -218,39 +218,43 @@ LPECopyRotate::toItem(Geom::Affine transform, size_t i, bool reset) phantom = elemref->getRepr(); } else { phantom = sp_lpe_item->getRepr()->duplicate(xml_doc); - phantom->setAttribute("inkscape:path-effect", NULL); - phantom->setAttribute("inkscape:original-d", NULL); - phantom->setAttribute("sodipodi:type", NULL); - phantom->setAttribute("sodipodi:rx", NULL); - phantom->setAttribute("sodipodi:ry", NULL); - phantom->setAttribute("sodipodi:cx", NULL); - phantom->setAttribute("sodipodi:cy", NULL); - phantom->setAttribute("sodipodi:end", NULL); - phantom->setAttribute("sodipodi:start", NULL); - phantom->setAttribute("inkscape:flatsided", NULL); - phantom->setAttribute("inkscape:randomized", NULL); - phantom->setAttribute("inkscape:rounded", NULL); - phantom->setAttribute("sodipodi:arg1", NULL); - phantom->setAttribute("sodipodi:arg2", NULL); - phantom->setAttribute("sodipodi:r1", NULL); - phantom->setAttribute("sodipodi:r2", NULL); - phantom->setAttribute("sodipodi:sides", NULL); - phantom->setAttribute("inkscape:randomized", NULL); - phantom->setAttribute("sodipodi:argument", NULL); - phantom->setAttribute("sodipodi:expansion", NULL); - phantom->setAttribute("sodipodi:radius", NULL); - phantom->setAttribute("sodipodi:revolution", NULL); - phantom->setAttribute("sodipodi:t0", NULL); - phantom->setAttribute("inkscape:randomized", NULL); - phantom->setAttribute("inkscape:randomized", NULL); - phantom->setAttribute("inkscape:randomized", NULL); - phantom->setAttribute("x", NULL); - phantom->setAttribute("y", NULL); - phantom->setAttribute("rx", NULL); - phantom->setAttribute("ry", NULL); - phantom->setAttribute("width", NULL); - phantom->setAttribute("height", NULL); + std::vector<const char *> attrs; + attrs->push_back("inkscape:path-effect"); + attrs->push_back("inkscape:original-d"); + attrs->push_back("sodipodi:type"); + attrs->push_back("sodipodi:rx"); + attrs->push_back("sodipodi:ry"); + attrs->push_back("sodipodi:cx"); + attrs->push_back("sodipodi:cy"); + attrs->push_back("sodipodi:end"); + attrs->push_back("sodipodi:start"); + attrs->push_back("inkscape:flatsided"); + attrs->push_back("inkscape:randomized"); + attrs->push_back("inkscape:rounded"); + attrs->push_back("sodipodi:arg1"); + attrs->push_back("sodipodi:arg2"); + attrs->push_back("sodipodi:r1"); + attrs->push_back("sodipodi:r2"); + attrs->push_back("sodipodi:sides"); + attrs->push_back("inkscape:randomized"); + attrs->push_back("sodipodi:argument"); + attrs->push_back("sodipodi:expansion"); + attrs->push_back("sodipodi:radius"); + attrs->push_back("sodipodi:revolution"); + attrs->push_back("sodipodi:t0"); + attrs->push_back("inkscape:randomized"); + attrs->push_back("inkscape:randomized"); + attrs->push_back("inkscape:randomized"); + attrs->push_back("x"); + attrs->push_back("y"); + attrs->push_back("rx"); + attrs->push_back("ry"); + attrs->push_back("width"); + attrs->push_back("height"); phantom->setAttribute("id", elemref_id); + for(const char * attr : attrs) { + phantom->setAttribute(attr, NULL); + } } if (!elemref) { elemref = container->appendChildRepr(phantom); @@ -703,8 +707,6 @@ LPECopyRotate::resetDefaults(SPItem const* item) original_bbox(SP_LPE_ITEM(item)); } - -//TODO: Migrate the tree next function to effect.cpp/h to avoid duplication void LPECopyRotate::doOnVisibilityToggled(SPLPEItem const* /*lpeitem*/) { @@ -722,63 +724,6 @@ LPECopyRotate::doOnRemove (SPLPEItem const* /*lpeitem*/) processObjects(LPE_ERASE); } -void -LPECopyRotate::processObjects(LpeAction lpe_action) -{ - SPDocument * document = SP_ACTIVE_DOCUMENT; - for (std::vector<const char *>::iterator el_it = items.begin(); - el_it != items.end(); ++el_it) { - const char * id = *el_it; - if (!id || strlen(id) == 0) { - return; - } - SPObject *elemref = NULL; - if (elemref = document->getObjectById(id)) { - Inkscape::XML::Node * elemnode = elemref->getRepr(); - std::vector<SPItem*> item_list; - item_list.push_back(SP_ITEM(elemref)); - std::vector<Inkscape::XML::Node*> item_to_select; - std::vector<SPItem*> item_selected; - SPCSSAttr *css; - Glib::ustring css_str; - switch (lpe_action){ - case LPE_TO_OBJECTS: - if (SP_ITEM(elemref)->isHidden()) { - elemref->deleteObject(); - } else { - if (elemnode->attribute("inkscape:path-effect")) { - sp_item_list_to_curves(item_list, item_selected, item_to_select); - } - elemnode->setAttribute("sodipodi:insensitive", NULL); - } - break; - - case LPE_ERASE: - elemref->deleteObject(); - break; - - case LPE_VISIBILITY: - css = sp_repr_css_attr_new(); - sp_repr_css_attr_add_from_string(css, elemref->getRepr()->attribute("style")); - if (!this->isVisible()/* && std::strcmp(elemref->getId(),sp_lpe_item->getId()) != 0*/) { - css->setAttribute("display", "none"); - } else { - css->setAttribute("display", NULL); - } - sp_repr_css_write_string(css,css_str); - elemnode->setAttribute("style", css_str.c_str()); - break; - - default: - break; - } - } - } - if (lpe_action == LPE_ERASE || lpe_action == LPE_TO_OBJECTS) { - items.clear(); - } -} - } //namespace LivePathEffect } /* namespace Inkscape */ diff --git a/src/live_effects/lpe-copy_rotate.h b/src/live_effects/lpe-copy_rotate.h index 6d6d06c4d..dbec2e1c3 100644 --- a/src/live_effects/lpe-copy_rotate.h +++ b/src/live_effects/lpe-copy_rotate.h @@ -39,7 +39,6 @@ public: virtual void doOnRemove (SPLPEItem const* /*lpeitem*/); virtual void doOnVisibilityToggled(SPLPEItem const* /*lpeitem*/); virtual Gtk::Widget * newWidget(); - void processObjects(LpeAction lpe_action); void toItem(Geom::Affine transform, size_t i, bool reset); void cloneD(SPObject *origin, SPObject *dest, bool root, bool reset); void resetStyles(); @@ -65,7 +64,6 @@ private: Geom::Point previous_start_point; double dist_angle_handle; double previous_num_copies; - std::vector<const char *> items; bool reset; SPObject * container; LPECopyRotate(const LPECopyRotate&); diff --git a/src/live_effects/lpe-patternalongpath.cpp b/src/live_effects/lpe-patternalongpath.cpp index c1853ef22..966e9020e 100644 --- a/src/live_effects/lpe-patternalongpath.cpp +++ b/src/live_effects/lpe-patternalongpath.cpp @@ -11,6 +11,7 @@ #include <2geom/bezier-to-sbasis.h> #include "knotholder.h" +#include <cmath> #include <algorithm> // TODO due to internal breakage in glibmm headers, this must be last: #include <glibmm/i18n.h> @@ -161,7 +162,7 @@ LPEPatternAlongPath::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > con // spacing.param_set_range(-pattBndsX.extent()*.9, Geom::infinity()); // } - y0+=noffset; + y0 += noffset; std::vector<Geom::Piecewise<Geom::D2<Geom::SBasis> > > paths_in; paths_in = split_at_discontinuities(pwd2_in); @@ -197,7 +198,7 @@ LPEPatternAlongPath::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > con case PAPCT_REPEATED_STRETCHED: // if uskeleton is closed: - if(path_i.segs.front().at0() == path_i.segs.back().at1()){ + if (are_near(path_i.segs.front().at0(), path_i.segs.back().at1())){ nbCopies = std::max(1, static_cast<int>(std::floor((uskeleton.domain().extent() - toffset)/(pattBndsX->extent()+xspace)))); pattBndsX = Interval(pattBndsX->min(),pattBndsX->max()+xspace); scaling = (uskeleton.domain().extent() - toffset)/(((double)nbCopies)*pattBndsX->extent()); @@ -213,11 +214,13 @@ LPEPatternAlongPath::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > con return pwd2_in; }; + //Ceil to 6 decimals + scaling = ceil(scaling * 1000000) / 1000000; double pattWidth = pattBndsX->extent() * scaling; - x*=scaling; + x *= scaling; if ( scale_y_rel.get_value() ) { - y*=(scaling * prop_scale); + y *= prop_scale * scaling; } else { y *= prop_scale; } @@ -235,7 +238,7 @@ LPEPatternAlongPath::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > con offs+=pattWidth; } } - if (fuse_tolerance > 0){ + if (fuse_tolerance > 0){ pre_output = fuse_nearby_ends(pre_output, fuse_tolerance); for (unsigned i=0; i<pre_output.size(); i++){ output.concat(pre_output[i]); @@ -264,7 +267,6 @@ LPEPatternAlongPath::transform_multiply(Geom::Affine const& postmul, bool set) pattern.param_transform_multiply(postmul, set); pattern.write_to_SVG(); } - sp_lpe_item_update_patheffect (sp_lpe_item, false, true); } void diff --git a/src/live_effects/lpe-perspective-envelope.cpp b/src/live_effects/lpe-perspective-envelope.cpp index e0dac0687..18b5b724d 100644 --- a/src/live_effects/lpe-perspective-envelope.cpp +++ b/src/live_effects/lpe-perspective-envelope.cpp @@ -379,7 +379,7 @@ LPEPerspectiveEnvelope::newWidget() hbox_down_handles->pack_start(*widg, true, true, 2); } if (tip) { - widg->set_tooltip_text(*tip); + widg->set_tooltip_markup(*tip); } else { widg->set_tooltip_text(""); widg->set_has_tooltip(false); diff --git a/src/live_effects/parameter/vector.cpp b/src/live_effects/parameter/vector.cpp index aa16a2b98..55b4d4b32 100644 --- a/src/live_effects/parameter/vector.cpp +++ b/src/live_effects/parameter/vector.cpp @@ -116,7 +116,7 @@ VectorParam::set_and_write_new_values(Geom::Point const &new_origin, Geom::Point void VectorParam::param_transform_multiply(Geom::Affine const& postmul, bool /*set*/) { - set_and_write_new_values( origin * postmul, vector * postmul.withoutTranslation() ); + set_and_write_new_values( origin * postmul, vector * postmul.withoutTranslation() ); } |
