diff options
| author | Jabiertxo Arraiza Cenoz <jtx@jtx-desktop.markerlab.es> | 2017-11-10 18:57:54 +0000 |
|---|---|---|
| committer | Jabiertxo Arraiza Cenoz <jtx@jtx-desktop.markerlab.es> | 2017-11-10 18:57:54 +0000 |
| commit | dc6c4dc337aa2ad766cada2eb06fe4c186a89d14 (patch) | |
| tree | 3fc8d3fd109b7c89751183b8be880e856be5ff34 /src/live_effects | |
| parent | Merge branch 'master' into powerpencil (diff) | |
| parent | Removing regects (diff) | |
| download | inkscape-dc6c4dc337aa2ad766cada2eb06fe4c186a89d14.tar.gz inkscape-dc6c4dc337aa2ad766cada2eb06fe4c186a89d14.zip | |
Merge branch 'master' into powerpencil
Diffstat (limited to 'src/live_effects')
23 files changed, 205 insertions, 147 deletions
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 5674e29dc..f4aad4f53 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -835,13 +835,13 @@ Effect::defaultParamSet() bool valid = prefs->getEntry(pref_path).isValid(); const gchar * set_or_upd; Glib::ustring def = Glib::ustring(_("<b>Default value:</b> ")) + Glib::ustring(param->param_getDefaultSVGValue()) + Glib::ustring("\n"); - Glib::ustring ove = Glib::ustring(_("<b>Default value overrided:</b> ")) + Glib::ustring(prefs->getString(pref_path)) + Glib::ustring("\n"); + Glib::ustring ove = Glib::ustring(_("<b>Default value overridden:</b> ")) + Glib::ustring(prefs->getString(pref_path)) + Glib::ustring("\n"); if (valid) { set_or_upd = _("Update"); def = Glib::ustring(_("<b>Default value:</b> <s>")) + Glib::ustring(param->param_getDefaultSVGValue()) + Glib::ustring("</s>\n"); } else { set_or_upd = _("Set"); - ove = Glib::ustring(_("<b>Default value overrided:</b> None\n")); + ove = Glib::ustring(_("<b>Default value overridden:</b> None\n")); } Glib::ustring cur = Glib::ustring(_("<b>Current parameter value:</b> ")) + Glib::ustring(param->param_getSVGValue()); Gtk::HBox * vbox_param = Gtk::manage( new Gtk::HBox(true) ); @@ -892,7 +892,7 @@ Effect::setDefaultParam(Glib::ustring pref_path, Glib::ustring tooltip, gchar * set->set_label((Glib::ustring)label); unset->set_sensitive(true); Glib::ustring def = Glib::ustring(_("<b>Default value:</b> <s>")) + Glib::ustring(defvalue) + Glib::ustring("</s>\n"); - Glib::ustring ove = Glib::ustring(_("<b>Default value overrided:</b> ")) + Glib::ustring(value) + Glib::ustring("\n"); + Glib::ustring ove = Glib::ustring(_("<b>Default value overridden:</b> ")) + Glib::ustring(value) + Glib::ustring("\n"); Glib::ustring cur = Glib::ustring(_("<b>Current parameter value:</b> ")) + Glib::ustring(value); parameter_label->set_tooltip_markup((tooltip + def + ove + cur).c_str()); } @@ -906,7 +906,7 @@ Effect::unsetDefaultParam(Glib::ustring pref_path, Glib::ustring tooltip, gchar set->set_label((Glib::ustring)label); unset->set_sensitive(false); Glib::ustring def = Glib::ustring(_("<b>Default value:</b> ")) + Glib::ustring(defvalue) + Glib::ustring("\n"); - Glib::ustring ove = Glib::ustring(_("<b>Default value overrided:</b> None\n")); + Glib::ustring ove = Glib::ustring(_("<b>Default value overridden:</b> None\n")); Glib::ustring cur = Glib::ustring(_("<b>Current parameter value:</b> ")) + Glib::ustring(value); parameter_label->set_tooltip_markup((tooltip + def + ove + cur).c_str()); } diff --git a/src/live_effects/lpe-bool.cpp b/src/live_effects/lpe-bool.cpp index 2930414b3..6299b282b 100644 --- a/src/live_effects/lpe-bool.cpp +++ b/src/live_effects/lpe-bool.cpp @@ -121,7 +121,7 @@ sp_pathvector_boolop_slice_intersect(Geom::PathVector const &pathva, Geom::PathV // (i) filter the descr_cmd of the result path with this bool vector // // The main inefficieny here is step (e) because I use a winding function of the area-shape which goes - // through teh complete edge list for each point I ask for, so effort is n-edges-contour * n-edges-area. + // through the complete edge list for each point I ask for, so effort is n-edges-contour * n-edges-area. // It is tricky to improve this without building into the livarot code. // One way might be to decide at the intersection points which edges touching the intersection points are // in by making a loop through all edges on the intersection vertex. Since this is a directed non intersecting diff --git a/src/live_effects/lpe-dynastroke.cpp b/src/live_effects/lpe-dynastroke.cpp index 33e754a8a..d0655d9bd 100644 --- a/src/live_effects/lpe-dynastroke.cpp +++ b/src/live_effects/lpe-dynastroke.cpp @@ -22,7 +22,7 @@ namespace Inkscape { namespace LivePathEffect { //TODO: growfor/fadefor can be expressed in unit of width. -//TODO: make round/sharp end choices independant for start and end. +//TODO: make round/sharp end choices independent for start and end. //TODO: define more styles like in calligtool. //TODO: allow fancy ends. @@ -166,7 +166,7 @@ LPEDynastroke::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & p // General formula: n1 = w*u with ||u||=1 and u.v = -dw/dt Piecewise<SBasis> dw = derivative(w); Piecewise<SBasis> ncomp = sqrt(dot(v,v)-dw*dw,.1,3); - //FIXME: is force continuity usefull? compatible with corners? + //FIXME: is force continuity useful? compatible with corners? // std::cout<<"ici\n"; n1 = -dw*v + ncomp*rot90(v); n1 = w*force_continuity(unitVector(n1),.1); diff --git a/src/live_effects/lpe-embrodery-stitch-ordering.h b/src/live_effects/lpe-embrodery-stitch-ordering.h index b2b5d36db..c307ec555 100644 --- a/src/live_effects/lpe-embrodery-stitch-ordering.h +++ b/src/live_effects/lpe-embrodery-stitch-ordering.h @@ -195,7 +195,7 @@ struct OrderingGroupConnection { Connect(1, toIn); } - // Connect one of the conection endpoints to the given point + // Connect one of the connection endpoints to the given point void Connect(int index, OrderingGroupPoint *point) { assert(point); diff --git a/src/live_effects/lpe-embrodery-stitch.cpp b/src/live_effects/lpe-embrodery-stitch.cpp index f2342032b..282419fd8 100644 --- a/src/live_effects/lpe-embrodery-stitch.cpp +++ b/src/live_effects/lpe-embrodery-stitch.cpp @@ -345,7 +345,7 @@ PathVector LPEEmbroderyStitch::doEffect_path(PathVector const &path_in) Piecewise<D2<SBasis> > pwOneEqdist = arc_length_parametrization(pwOne); Interval pwdomain = pwOneEqdist.domain(); - // Compute the points of teh shortened piece + // Compute the points of the shortened piece Coord len = pwdomain.max() - pwdomain.min(); Coord offs = 0.5 * (show_stitch_gap < 0.5 * len ? show_stitch_gap : 0.5 * len); Point p1 = pwOneEqdist.valueAt(pwdomain.min() + offs); diff --git a/src/live_effects/lpe-envelope.cpp b/src/live_effects/lpe-envelope.cpp index 8528ab14d..688841617 100644 --- a/src/live_effects/lpe-envelope.cpp +++ b/src/live_effects/lpe-envelope.cpp @@ -205,7 +205,7 @@ LPEEnvelope::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd output /= 2.; return output; - /*Of course, the result is not perfect, but on a graphical point of view, this is sufficent.*/ + /*Of course, the result is not perfect, but on a graphical point of view, this is sufficient.*/ } diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp index 2b052ace1..fb78c2065 100644 --- a/src/live_effects/lpe-fillet-chamfer.cpp +++ b/src/live_effects/lpe-fillet-chamfer.cpp @@ -131,7 +131,7 @@ void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem) } //we add the last satellite on open path because _pathvector_satellites is related to nodes, not curves //so maybe in the future we can need this last satellite in other effects - //dont remove for this effect because _pathvector_satellites class has methods when the path is modiffied + //don't remove for this effect because _pathvector_satellites class has methods when the path is modiffied //and we want one method for all uses if (!path_it->closed()) { Satellite satellite(satellite_type); @@ -323,7 +323,7 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem) //mandatory call satellites_param.setEffectType(effectType()); Geom::PathVector const pathv = pathv_to_linear_and_cubic_beziers(sp_curve->get_pathvector()); - //if are diferent sizes call to recalculate + //if are different sizes call to recalculate //TODO: Update the satellite data in paths modified, Satellites satellites = satellites_param.data(); if (satellites.empty()) { @@ -468,7 +468,7 @@ LPEFilletChamfer::doEffect_path(Geom::PathVector const &path_in) Satellite satellite = satellites[path][next_index]; if (Geom::are_near((*curve_it1).initialPoint(), (*curve_it1).finalPoint())) { _degenerate_hide = true; - g_warning("Knots hidded if consecutive nodes has the same position."); + g_warning("Knots hidden if consecutive nodes has the same position."); return path_in; } if (!curve) { //curve == 0 diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index 22c548c1d..b21181ffc 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -520,7 +520,7 @@ collectPathsAndWidths (SPLPEItem const *lpeitem, Geom::PathVector &paths, std::v Geom::PathVector subpaths = pathv_to_linear_and_cubic_beziers(c->get_pathvector()); for (unsigned i=0; i<subpaths.size(); i++){ paths.push_back(subpaths[i]); - //FIXME: do we have to be more carefull when trying to access stroke width? + //FIXME: do we have to be more careful when trying to access stroke width? stroke_widths.push_back(lpeitem->style->stroke_width.computed); } } diff --git a/src/live_effects/lpe-lattice2.cpp b/src/live_effects/lpe-lattice2.cpp index e827491c0..e8642d4e7 100644 --- a/src/live_effects/lpe-lattice2.cpp +++ b/src/live_effects/lpe-lattice2.cpp @@ -103,7 +103,7 @@ Geom::Piecewise<Geom::D2<Geom::SBasis> > LPELattice2::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in) { PathVector pathv = path_from_piecewise(pwd2_in,0.001); - //this is because strange problems whith sb2 and LineSegment + //this is because strange problems with sb2 and LineSegment PathVector cubic = pathv_to_cubicbezier(pathv); Geom::Piecewise<Geom::D2<Geom::SBasis> > const &pwd2_in_linear_and_cubic = paths_to_pw(cubic); D2<SBasis2d> sb2; diff --git a/src/live_effects/lpe-measure-segments.cpp b/src/live_effects/lpe-measure-segments.cpp index 5ed587922..4bc9278fc 100644 --- a/src/live_effects/lpe-measure-segments.cpp +++ b/src/live_effects/lpe-measure-segments.cpp @@ -139,6 +139,7 @@ LPEMeasureSegments::LPEMeasureSegments(LivePathEffectObject *lpeobject) : helpline_overlap.param_set_increments(1, 1); helpline_overlap.param_set_digits(2); star_ellipse_fix = Geom::identity(); + message.param_set_min_height(95); } LPEMeasureSegments::~LPEMeasureSegments() {} diff --git a/src/live_effects/lpe-powerclip.cpp b/src/live_effects/lpe-powerclip.cpp index 40a9cdbfb..18276270d 100644 --- a/src/live_effects/lpe-powerclip.cpp +++ b/src/live_effects/lpe-powerclip.cpp @@ -395,6 +395,25 @@ LPEPowerClip::flattenClip(SPItem * clip_data, Geom::PathVector &path_in) } } +void sp_inverse_powerclip(Inkscape::Selection *sel) { + if (!sel->isEmpty()) { + auto selList = sel->items(); + for(auto i = boost::rbegin(selList); i != boost::rend(selList); ++i) { + SPLPEItem* lpeitem = dynamic_cast<SPLPEItem*>(*i); + if (lpeitem) { + Effect::createAndApply(POWERCLIP, SP_ACTIVE_DOCUMENT, lpeitem); + Effect* lpe = lpeitem->getCurrentLPE(); + lpe->getRepr()->setAttribute("is_inverse", "false"); + lpe->getRepr()->setAttribute("is_visible", "true"); + lpe->getRepr()->setAttribute("inverse", "true"); + lpe->getRepr()->setAttribute("flatten", "false"); + lpe->getRepr()->setAttribute("hide_clip", "false"); + dynamic_cast<LPEPowerClip *>(lpe)->convertShapes(); + } + } + } +} + }; //namespace LivePathEffect }; /* namespace Inkscape */ diff --git a/src/live_effects/lpe-powerclip.h b/src/live_effects/lpe-powerclip.h index 38485b798..6f99d220f 100644 --- a/src/live_effects/lpe-powerclip.h +++ b/src/live_effects/lpe-powerclip.h @@ -38,6 +38,8 @@ private: bool convert_shapes; }; +void sp_inverse_powerclip(Inkscape::Selection *sel); + } //namespace LivePathEffect } //namespace Inkscape #endif diff --git a/src/live_effects/lpe-powermask.cpp b/src/live_effects/lpe-powermask.cpp index 05510f258..883467b6a 100644 --- a/src/live_effects/lpe-powermask.cpp +++ b/src/live_effects/lpe-powermask.cpp @@ -13,12 +13,12 @@ #include "style.h" #include "sp-item-group.h" #include "svg/svg.h" +#include "svg/svg-color.h" #include "ui/tools-switch.h" #include "path-chemistry.h" #include "uri.h" #include "extract-uri.h" #include <bad-uri-exception.h> - // TODO due to internal breakage in glibmm headers, this must be last: #include <glibmm/i18n.h> @@ -29,25 +29,25 @@ 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), + //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), - background_style(_("Background Style"), _("CSS to background"), "background_style", &wr, this,"fill:#ffffff;opacity:1;") + background_color(_("Background color and opacity"), _("Set color and opacity of the background"), "background_color", &wr, this, 0xffffffff) { registerParameter(&uri); registerParameter(&invert); - registerParameter(&wrap); + //registerParameter(&wrap); registerParameter(&hide_mask); registerParameter(&background); - registerParameter(&background_style); - //lock.param_setValue(false); - background_style.param_hide_canvas_text(); + registerParameter(&background_color); + previous_color = background_color.get_value(); } LPEPowerMask::~LPEPowerMask() {} void LPEPowerMask::doBeforeEffect (SPLPEItem const* lpeitem){ + //To avoid close of color dialog and better performance on change color SPObject * mask = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); if(hide_mask && mask) { SP_ITEM(sp_lpe_item)->mask_ref->detach(); @@ -61,35 +61,40 @@ LPEPowerMask::doBeforeEffect (SPLPEItem const* lpeitem){ } 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(); - } + if (previous_color != background_color.get_value()) { + previous_color = background_color.get_value(); + setMask(); } else { + uri.param_setValue(Glib::ustring(extract_uri(sp_lpe_item->getRepr()->attribute("mask"))), true); SP_ITEM(sp_lpe_item)->mask_ref->detach(); + Geom::OptRect bbox = sp_lpe_item->visualBounds(); + if(!bbox) { + return; + } + if (uri.param_getSVGValue()) { + try { + SP_ITEM(sp_lpe_item)->mask_ref->attach(Inkscape::URI(uri.param_getSVGValue())); + } catch (Inkscape::BadURIException &e) { + g_warning("%s", e.what()); + SP_ITEM(sp_lpe_item)->mask_ref->detach(); + } + } else { + SP_ITEM(sp_lpe_item)->mask_ref->detach(); + } + Geom::Rect bboxrect = (*bbox); + bboxrect.expandBy(1); + Geom::Point topleft = bboxrect.corner(0); + Geom::Point topright = bboxrect.corner(1); + Geom::Point bottomright = bboxrect.corner(2); + Geom::Point bottomleft = bboxrect.corner(3); + mask_box.clear(); + mask_box.start(topleft); + mask_box.appendNew<Geom::LineSegment>(topright); + mask_box.appendNew<Geom::LineSegment>(bottomright); + mask_box.appendNew<Geom::LineSegment>(bottomleft); + mask_box.close(); + setMask(); } - Geom::Rect bboxrect = (*bbox); - bboxrect.expandBy(1); - Geom::Point topleft = bboxrect.corner(0); - Geom::Point topright = bboxrect.corner(1); - Geom::Point bottomright = bboxrect.corner(2); - Geom::Point bottomleft = bboxrect.corner(3); - mask_box.clear(); - mask_box.start(topleft); - mask_box.appendNew<Geom::LineSegment>(topright); - mask_box.appendNew<Geom::LineSegment>(bottomright); - mask_box.appendNew<Geom::LineSegment>(bottomleft); - mask_box.close(); - setMask(); } } @@ -145,56 +150,57 @@ LPEPowerMask::setMask(){ filter->appendChild(primitive2); Inkscape::GC::release(primitive2); } - if(wrap && is_visible){ - Glib::ustring g_data_id = mask_id + (Glib::ustring)"_container"; - if((elemref = document->getObjectById(g_data_id))){ - elemref->getRepr()->setPosition(-1); - } else { - Inkscape::XML::Node * container = xml_doc->createElement("svg:g"); - container->setAttribute("id", g_data_id.c_str()); - mask->appendChildRepr(container); - std::vector<SPObject*> mask_list = mask->childList(true); - container->setPosition(-1); - Inkscape::GC::release(container); - for ( std::vector<SPObject*>::const_iterator iter=mask_list.begin();iter!=mask_list.end();++iter) { - SPItem * mask_data = SP_ITEM(*iter); - Inkscape::XML::Node *mask_node = mask_data->getRepr(); - if (! strcmp(mask_data->getId(), box_id.c_str()) || - ! strcmp(mask_data->getId(), g_data_id.c_str())) - { - continue; - } - SPCSSAttr *css = sp_repr_css_attr_new(); - if(mask_node->attribute("style")) { - sp_repr_css_attr_add_from_string(css, mask_node->attribute("style")); - } - char const* filter = sp_repr_css_property (css, "filter", NULL); - if(!filter || !strcmp(filter, filter_uri.c_str())) { - sp_repr_css_set_property (css, "filter", NULL); - } - Glib::ustring css_str; - sp_repr_css_write_string(css, css_str); - mask_node->setAttribute("style", css_str.c_str()); - mask->getRepr()->removeChild(mask_node); - container->appendChild(mask_node); - Inkscape::GC::release(mask_node); - } - } - } else { - Glib::ustring g_data_id = mask_id + (Glib::ustring)"_container"; - if((elemref = document->getObjectById(g_data_id))){ - std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(elemref)); - for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) { - Inkscape::XML::Node *mask_node = (*iter)->getRepr(); - elemref->getRepr()->removeChild(mask_node); - mask->getRepr()->appendChild(mask_node); - Inkscape::GC::release(mask_node); - } - sp_object_ref(elemref, 0 ); - elemref->deleteObject(true); - sp_object_unref(elemref); +//Not sure if finaly need to resurrect this +// if(wrap && is_visible){ +// Glib::ustring g_data_id = mask_id + (Glib::ustring)"_container"; +// if((elemref = document->getObjectById(g_data_id))){ +// elemref->getRepr()->setPosition(-1); +// } else { +// Inkscape::XML::Node * container = xml_doc->createElement("svg:g"); +// container->setAttribute("id", g_data_id.c_str()); +// mask->appendChildRepr(container); +// std::vector<SPObject*> mask_list = mask->childList(true); +// container->setPosition(-1); +// Inkscape::GC::release(container); +// for ( std::vector<SPObject*>::const_iterator iter=mask_list.begin();iter!=mask_list.end();++iter) { +// SPItem * mask_data = SP_ITEM(*iter); +// Inkscape::XML::Node *mask_node = mask_data->getRepr(); +// if (! strcmp(mask_data->getId(), box_id.c_str()) || +// ! strcmp(mask_data->getId(), g_data_id.c_str())) +// { +// continue; +// } +// SPCSSAttr *css = sp_repr_css_attr_new(); +// if(mask_node->attribute("style")) { +// sp_repr_css_attr_add_from_string(css, mask_node->attribute("style")); +// } +// char const* filter = sp_repr_css_property (css, "filter", NULL); +// if(!filter || !strcmp(filter, filter_uri.c_str())) { +// sp_repr_css_set_property (css, "filter", NULL); +// } +// Glib::ustring css_str; +// sp_repr_css_write_string(css, css_str); +// mask_node->setAttribute("style", css_str.c_str()); +// mask->getRepr()->removeChild(mask_node); +// container->appendChild(mask_node); +// Inkscape::GC::release(mask_node); +// } +// } +// } else { + Glib::ustring g_data_id = mask_id + (Glib::ustring)"_container"; + if((elemref = document->getObjectById(g_data_id))){ + std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(elemref)); + for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) { + Inkscape::XML::Node *mask_node = (*iter)->getRepr(); + elemref->getRepr()->removeChild(mask_node); + mask->getRepr()->appendChild(mask_node); + Inkscape::GC::release(mask_node); } + sp_object_ref(elemref, 0 ); + elemref->deleteObject(true); + sp_object_unref(elemref); } +// } std::vector<SPObject*> mask_list = mask->childList(true); for ( std::vector<SPObject*>::const_iterator iter=mask_list.begin();iter!=mask_list.end();++iter) { SPItem * mask_data = SP_ITEM(*iter); @@ -229,7 +235,28 @@ LPEPowerMask::setMask(){ box->setAttribute("id", box_id.c_str()); exist = false; } - box->setAttribute("style", background_style.param_getSVGValue()); + Glib::ustring style; + gchar c[32]; + unsigned const rgb24 = background_color.get_value() >> 8; + sprintf(c, "#%06x", rgb24); + style = Glib::ustring("fill:") + Glib::ustring(c); + Inkscape::SVGOStringStream os; + os << SP_RGBA32_A_F(background_color.get_value()); + style = style + Glib::ustring(";fill-opacity:") + Glib::ustring(os.str()); + SPCSSAttr *css = sp_repr_css_attr_new(); + sp_repr_css_attr_add_from_string(css, style.c_str()); + char const* filter = sp_repr_css_property (css, "filter", NULL); + if(!filter || !strcmp(filter, filter_uri.c_str())) { + if (invert && is_visible) { + sp_repr_css_set_property (css, "filter", filter_uri.c_str()); + } else { + sp_repr_css_set_property (css, "filter", NULL); + } + + } + Glib::ustring css_str; + sp_repr_css_write_string(css, css_str); + box->setAttribute("style", css_str.c_str()); gchar * box_str = sp_svg_write_path( mask_box ); box->setAttribute("d" , box_str); g_free(box_str); @@ -255,33 +282,6 @@ LPEPowerMask::doEffect (SPCurve * curve) { } -//void -//LPEPowerMask::transform_multiply(Geom::Affine const& postmul, bool set) -//{ -// SPMask *mask_path = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); -// if (mask_path && lock) { -// SPMask *mask_path = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); -// std::vector<SPObject*> mask_path_list = mask_path->childList(true); -// Glib::ustring mask_id = (Glib::ustring)mask_path->getId(); -// Glib::ustring box_id = mask_id + (Glib::ustring)"_box"; -// for ( std::vector<SPObject*>::const_iterator iter=mask_path_list.begin();iter!=mask_path_list.end();++iter) { -// SPObject * mask_data = *iter; -// if (! strcmp(mask_data->getId(), box_id.c_str())){ -// continue; -// } -// SP_ITEM(mask_data)->transform *= postmul.inverse(); -// } -// } -// //cycle through all parameters. Most parameters will not need transformation, but path and point params -// for (std::vector<Parameter *>::iterator it = param_vector.begin(); it != param_vector.end(); ++it) { -// Parameter * param = *it; -// param->param_transform_multiply(postmul, set); -// } -// sp_lpe_item_update_patheffect(SP_LPE_ITEM(sp_lpe_item), false, false); -//} - - - void LPEPowerMask::doOnRemove (SPLPEItem const* lpeitem) { @@ -289,7 +289,7 @@ LPEPowerMask::doOnRemove (SPLPEItem const* lpeitem) SPMask *mask = lpeitem->mask_ref->getObject(); if (mask) { invert.param_setValue(false); - wrap.param_setValue(false); + //wrap.param_setValue(false); background.param_setValue(false); setMask(); SPObject *elemref = NULL; @@ -303,6 +303,24 @@ LPEPowerMask::doOnRemove (SPLPEItem const* lpeitem) } } +void sp_inverse_powermask(Inkscape::Selection *sel) { + if (!sel->isEmpty()) { + auto selList = sel->items(); + for(auto i = boost::rbegin(selList); i != boost::rend(selList); ++i) { + SPLPEItem* lpeitem = dynamic_cast<SPLPEItem*>(*i); + if (lpeitem) { + Effect::createAndApply(POWERMASK, SP_ACTIVE_DOCUMENT, lpeitem); + Effect* lpe = lpeitem->getCurrentLPE(); + lpe->getRepr()->setAttribute("invert", "false"); + lpe->getRepr()->setAttribute("is_visible", "true"); + lpe->getRepr()->setAttribute("hide_mask", "false"); + lpe->getRepr()->setAttribute("background", "true"); + lpe->getRepr()->setAttribute("background_color", "#ffffffff"); + } + } + } +} + }; //namespace LivePathEffect }; /* namespace Inkscape */ diff --git a/src/live_effects/lpe-powermask.h b/src/live_effects/lpe-powermask.h index a54424e2f..e81b34fe3 100644 --- a/src/live_effects/lpe-powermask.h +++ b/src/live_effects/lpe-powermask.h @@ -6,10 +6,11 @@ * * Released under GNU GPL, read the file 'COPYING' for more information */ - #include "live_effects/effect.h" +#include "live_effects/parameter/bool.h" #include "live_effects/parameter/text.h" #include "live_effects/parameter/hidden.h" +#include "live_effects/parameter/colorpicker.h" namespace Inkscape { namespace LivePathEffect { @@ -22,19 +23,22 @@ public: virtual void doEffect (SPCurve * curve); virtual void doOnRemove (SPLPEItem const* /*lpeitem*/); virtual void doOnVisibilityToggled(SPLPEItem const* lpeitem); - //virtual void transform_multiply(Geom::Affine const& postmul, bool set); void toggleMaskVisibility(); void setMask(); private: HiddenParam uri; BoolParam invert; - BoolParam wrap; + //BoolParam wrap; BoolParam hide_mask; BoolParam background; - TextParam background_style; + ColorPickerParam background_color; Geom::Path mask_box; + guint32 previous_color; }; +void sp_inverse_powermask(Inkscape::Selection *sel); + } //namespace LivePathEffect } //namespace Inkscape + #endif diff --git a/src/live_effects/lpe-ruler.cpp b/src/live_effects/lpe-ruler.cpp index 7ba5a7913..7726af176 100644 --- a/src/live_effects/lpe-ruler.cpp +++ b/src/live_effects/lpe-ruler.cpp @@ -171,7 +171,7 @@ LPERuler::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_i if (border_marks == BORDERMARK_END || border_marks == BORDERMARK_BOTH){ Point A = pwd2_in.lastValue(); Point n = rot90(unit_vector(speed.lastValue()))*sign; - //speed.lastValue() is somtimes wrong when the path is closed: a tiny line seg might added at the end to fix rounding errors... + //speed.lastValue() is sometimes wrong when the path is closed: a tiny line seg might added at the end to fix rounding errors... //TODO: Find a better fix!! (How do we know if the path was closed?) if ( A == pwd2_in.firstValue() && speed.segs.size() > 1 && diff --git a/src/live_effects/lpe-sketch.cpp b/src/live_effects/lpe-sketch.cpp index e3376b7e5..dfb860de8 100644 --- a/src/live_effects/lpe-sketch.cpp +++ b/src/live_effects/lpe-sketch.cpp @@ -107,7 +107,7 @@ LPESketch::LPESketch(LivePathEffectObject *lpeobject) : tgtlength_rdm.param_set_range(0, 1.); tgt_places_rdmness.param_set_range(0, 1.); //this is not very smart, but required to avoid having lot of tangents stacked on short components. - //Nota: we could specify a density instead of an absolute number, but this would be scale dependant. + //Note: we could specify a density instead of an absolute number, but this would be scale dependent. concatenate_before_pwd2 = true; #endif } diff --git a/src/live_effects/lpe-vonkoch.cpp b/src/live_effects/lpe-vonkoch.cpp index b9fd8908a..f04c243f6 100644 --- a/src/live_effects/lpe-vonkoch.cpp +++ b/src/live_effects/lpe-vonkoch.cpp @@ -169,7 +169,7 @@ LPEVonKoch::doEffect_path (Geom::PathVector const & path_in) } -//Usefull?? +//Useful?? //void //LPEVonKoch::addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec) /*{ diff --git a/src/live_effects/lpe-vonkoch.h b/src/live_effects/lpe-vonkoch.h index bffbebd54..c0cb7ce42 100644 --- a/src/live_effects/lpe-vonkoch.h +++ b/src/live_effects/lpe-vonkoch.h @@ -55,7 +55,7 @@ public: virtual void doBeforeEffect(SPLPEItem const* item); - //Usefull?? + //Useful?? // protected: //virtual void addCanvasIndicators(SPLPEItem const *lpeitem, std::vector<Geom::PathVector> &hp_vec); diff --git a/src/live_effects/lpeobject-reference.h b/src/live_effects/lpeobject-reference.h index 374e715ec..baee35614 100644 --- a/src/live_effects/lpeobject-reference.h +++ b/src/live_effects/lpeobject-reference.h @@ -32,7 +32,7 @@ public: SPObject *owner; - // concerning the LPEObject that is refered to: + // concerning the LPEObject that is referred to: char *lpeobject_href; Inkscape::XML::Node *lpeobject_repr; LivePathEffectObject *lpeobject; diff --git a/src/live_effects/parameter/message.cpp b/src/live_effects/parameter/message.cpp index 39d8f12c7..0e19c07e1 100644 --- a/src/live_effects/parameter/message.cpp +++ b/src/live_effects/parameter/message.cpp @@ -20,7 +20,8 @@ MessageParam::MessageParam( const Glib::ustring& label, const Glib::ustring& tip message(g_strdup(default_message)), defmessage(g_strdup(default_message)) { - + _label = NULL; + _min_height = -1; } void @@ -54,6 +55,16 @@ MessageParam::param_getDefaultSVGValue() const return defmessage; } +void +MessageParam::param_set_min_height(int height) +{ + _min_height = height; + if (_label) { + _label->set_size_request(-1, _min_height); + } +} + + Gtk::Widget * MessageParam::param_newWidget() { @@ -61,11 +72,12 @@ MessageParam::param_newWidget() Gtk::Widget * widg_frame = frame->get_label_widget(); widg_frame->set_margin_right(5); widg_frame->set_margin_left(5); - Gtk::Label * label = new Gtk::Label (message, Gtk::ALIGN_END); - label->set_use_underline (true); - label->set_use_markup(); - label->set_line_wrap(true); - Gtk::Widget * widg_label = dynamic_cast<Gtk::Widget *> (label); + _label = new Gtk::Label (message, Gtk::ALIGN_END); + _label->set_use_underline (true); + _label->set_use_markup(); + _label->set_line_wrap(true); + _label->set_size_request(-1, _min_height); + Gtk::Widget* widg_label = dynamic_cast<Gtk::Widget *> (_label); widg_label->set_margin_top(8); widg_label->set_margin_bottom(10); widg_label->set_margin_right(6); diff --git a/src/live_effects/parameter/message.h b/src/live_effects/parameter/message.h index 63075cf96..2ac2c791a 100644 --- a/src/live_effects/parameter/message.h +++ b/src/live_effects/parameter/message.h @@ -33,10 +33,12 @@ public: void param_setValue(const gchar * message); virtual void param_set_default(); - + void param_set_min_height(int height); const gchar * get_value() const { return message; }; private: + Gtk::Label * _label; + int _min_height; MessageParam(const MessageParam&); MessageParam& operator=(const MessageParam&); gchar * message; diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp index bd6608737..f89fad3ee 100644 --- a/src/live_effects/parameter/path.cpp +++ b/src/live_effects/parameter/path.cpp @@ -343,7 +343,7 @@ PathParam::set_new_value (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & newpa * * If write_to_svg = true : * The new path data is written to SVG. In this case the signal_path_changed signal - * is not directly emited in this method, because writing to SVG + * is not directly emitted in this method, because writing to SVG * triggers the LPEObject to which this belongs to call Effect::setParameter which calls * PathParam::readSVGValue, which finally emits the signal_path_changed signal. * If write_to_svg = false : diff --git a/src/live_effects/parameter/satellitesarray.h b/src/live_effects/parameter/satellitesarray.h index 5ae372ac2..3039eb432 100644 --- a/src/live_effects/parameter/satellitesarray.h +++ b/src/live_effects/parameter/satellitesarray.h @@ -5,14 +5,14 @@ * Inkscape::LivePathEffectParameters * Copyright (C) Jabiertxo Arraiza Cenoz <jabier.arraiza@marker.es> * Special thanks to Johan Engelen for the base of the effect -powerstroke- - * Also to ScislaC for point me to the idea - * Also su_v for his construvtive feedback and time + * Also to ScislaC for pointing me to the idea + * Also su_v for his constructive feedback and time * To Nathan Hurst for his review and help on refactor - * and finaly to Liam P. White for his big help on coding, that save me a lot of - * hours + * and finally to Liam P. White for his big help on coding, + * that saved me a lot of hours * * - * This parameter act as bridge from pathVectorSatellites class to serialize it as a LPE + * This parameter acts as a bridge from pathVectorSatellites class to serialize it as a LPE * parameter * * Released under GNU GPL, read the file 'COPYING' for more information |
