diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/knotholder.cpp | 3 | ||||
| -rw-r--r-- | src/knotholder.h | 2 | ||||
| -rw-r--r-- | src/live_effects/effect.cpp | 4 | ||||
| -rw-r--r-- | src/live_effects/effect.h | 2 | ||||
| -rw-r--r-- | src/live_effects/lpe-measure-line.cpp | 528 | ||||
| -rw-r--r-- | src/live_effects/lpe-measure-line.h | 9 | ||||
| -rw-r--r-- | src/live_effects/parameter/parameter.cpp | 43 | ||||
| -rw-r--r-- | src/live_effects/parameter/parameter.h | 2 | ||||
| -rw-r--r-- | src/ui/dialog/livepatheffect-editor.cpp | 8 | ||||
| -rw-r--r-- | src/ui/widget/registered-widget.cpp | 1 | ||||
| -rw-r--r-- | src/ui/widget/scalar.cpp | 6 | ||||
| -rw-r--r-- | src/ui/widget/scalar.h | 2 |
12 files changed, 213 insertions, 397 deletions
diff --git a/src/knotholder.cpp b/src/knotholder.cpp index eed358001..a2d1cf017 100644 --- a/src/knotholder.cpp +++ b/src/knotholder.cpp @@ -17,7 +17,6 @@ #include "document.h" #include "document-undo.h" -#include "selection.h" #include "sp-shape.h" #include "knot.h" #include "knotholder.h" @@ -203,7 +202,7 @@ KnotHolder::knot_moved_handler(SPKnot *knot, Geom::Point const &p, guint state) } void -KnotHolder::knot_ungrabbed_handler(SPKnot */*knot*/, guint /*state*/) +KnotHolder::knot_ungrabbed_handler(SPKnot */*knot*/, guint) { this->dragging = false; diff --git a/src/knotholder.h b/src/knotholder.h index f055a163a..f1bacebe5 100644 --- a/src/knotholder.h +++ b/src/knotholder.h @@ -51,7 +51,7 @@ public: void knot_moved_handler(SPKnot *knot, Geom::Point const &p, unsigned int state); void knot_clicked_handler(SPKnot *knot, unsigned int state); - void knot_ungrabbed_handler(SPKnot *knot, unsigned int state); + void knot_ungrabbed_handler(SPKnot *knot, unsigned int); void add(KnotHolderEntity *e); diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index a62e8b62b..7efc1a711 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -454,7 +454,9 @@ void Effect::doAfterEffect (SPLPEItem const* /*lpeitem*/) void Effect::doOnRemove (SPLPEItem const* /*lpeitem*/) { } - +void Effect::doOnVisibilityToggled(SPLPEItem const* /*lpeitem*/) +{ +} //secret impl methods (shhhh!) void Effect::doOnApply_impl(SPLPEItem const* lpeitem) { diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h index e0a7cbe6b..f54624302 100644 --- a/src/live_effects/effect.h +++ b/src/live_effects/effect.h @@ -66,7 +66,7 @@ public: virtual void doAfterEffect (SPLPEItem const* lpeitem); virtual void doOnRemove (SPLPEItem const* lpeitem); - + virtual void doOnVisibilityToggled(SPLPEItem const* lpeitem); void writeParamsToSVG(); virtual void acceptParamPath (SPPath const* param_path); diff --git a/src/live_effects/lpe-measure-line.cpp b/src/live_effects/lpe-measure-line.cpp index d0252aea9..6d58e2b7d 100644 --- a/src/live_effects/lpe-measure-line.cpp +++ b/src/live_effects/lpe-measure-line.cpp @@ -39,11 +39,7 @@ namespace LivePathEffect { static const Util::EnumData<OrientationMethod> OrientationMethodData[] = { { OM_HORIZONTAL, N_("Horizontal"), "horizontal" }, { OM_VERTICAL, N_("Vertical"), "vertical" }, - { OM_PARALLEL, N_("Parallel"), "parallel" }, - { OM_PARALLEL_VERTICAL, N_("Parallel and vertical,"), "parallel_vertical" }, - { OM_PARALLEL_HORIZONTAL, N_("Parallel and horizontal"), "parallel_horizontal" }, - { OM_VERTICAL_HORIZONTAL, N_("Vertical and horizontal"), "vertical_horizontal" }, - { OM_PARALLEL_VERTICAL_HORIZONTAL, N_("Parallel, vertical and horizontal"), "parallel_vertical_horizontal" } + { OM_PARALLEL, N_("Parallel"), "parallel" } }; static const Util::EnumDataConverter<OrientationMethod> OMConverter(OrientationMethodData, OM_END); @@ -51,9 +47,7 @@ LPEMeasureLine::LPEMeasureLine(LivePathEffectObject *lpeobject) : Effect(lpeobject), fontbutton(_("Font*"), _("Font Selector"), "fontbutton", &wr, this), orientation(_("Orientation"), _("Orientation method"), "orientation", OMConverter, &wr, this, OM_PARALLEL, false), - origin(_("Optional Origin"), _("Optional origin"), "origin", &wr, this), - curve_linked(_("Curve on optional origin"), _("Curve on optional origin, set 0 to start/end"), "curve_linked", &wr, this, 1), - origin_offset(_("Optional origin offset*"), _("Optional origin offset"), "origin_offset", &wr, this, 5), + curve_linked(_("Curve on origin"), _("Curve on origin, set 0 to start/end"), "curve_linked", &wr, this, 1), scale(_("Scale*"), _("Scaling factor"), "scale", &wr, this, 1.0), precision(_("Precision*"), _("Precision"), "precision", &wr, this, 2), offset_right_left(_("Offset right left*"), _("Offset right left"), "offset_right_left", &wr, this, 0), @@ -68,9 +62,7 @@ LPEMeasureLine::LPEMeasureLine(LivePathEffectObject *lpeobject) : { registerParameter(&fontbutton); registerParameter(&orientation); - registerParameter(&origin); registerParameter(&curve_linked); - registerParameter(&origin_offset); registerParameter(&scale); registerParameter(&precision); registerParameter(&offset_right_left); @@ -88,7 +80,6 @@ LPEMeasureLine::LPEMeasureLine(LivePathEffectObject *lpeobject) : precision.param_update_default(prefs->getInt("/live_effects/measure-line/precision", 2)); offset_right_left.param_update_default(prefs->getDouble("/live_effects/measure-line/offset_right_left", 0.0)); offset_top_bottom.param_update_default(prefs->getDouble("/live_effects/measure-line/offset_top_bottom", 5.0)); - origin_offset.param_update_default(prefs->getDouble("/live_effects/measure-line/origin_offset", 5.0)); unit.param_update_default(prefs->getString("/live_effects/measure-line/unit")); reverse.param_update_default(prefs->getBool("/live_effects/measure-line/reverse")); color_as_line.param_update_default(prefs->getBool("/live_effects/measure-line/color_as_line")); @@ -98,7 +89,7 @@ LPEMeasureLine::LPEMeasureLine(LivePathEffectObject *lpeobject) : precision.param_set_increments(1, 1); precision.param_set_digits(0); precision.param_make_integer(true); - curve_linked.param_set_range(1, 999); + curve_linked.param_set_range(0, 999); curve_linked.param_set_increments(1, 1); curve_linked.param_set_digits(0); curve_linked.param_make_integer(true); @@ -109,9 +100,6 @@ LPEMeasureLine::LPEMeasureLine(LivePathEffectObject *lpeobject) : offset_top_bottom.param_set_range(-999999.0, 999999.0); offset_top_bottom.param_set_increments(1, 1); offset_top_bottom.param_set_digits(2); - origin_offset.param_set_range(-999999.0, 999999.0); - origin_offset.param_set_increments(1, 1); - origin_offset.param_set_digits(2); gap_start.param_set_range(-999999.0, 999999.0); gap_start.param_set_increments(1, 1); gap_start.param_set_digits(2); @@ -120,8 +108,6 @@ LPEMeasureLine::LPEMeasureLine(LivePathEffectObject *lpeobject) : gap_end.param_set_digits(2); } -bool LPEMeasureLine::alerts_off = false; - LPEMeasureLine::~LPEMeasureLine() {} void @@ -131,16 +117,24 @@ LPEMeasureLine::doOnApply(SPLPEItem const* lpeitem) g_warning("LPE measure line can only be applied to shapes (not groups)."); SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem); item->removeCurrentPathEffect(false); - } else { - if(!alerts_off) { - char *msg = _("The \"measure line\" path effect could update original path on the object you are applying it to if link it to other path. If this is not what you want, click Cancel."); - Gtk::MessageDialog dialog(msg, false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_OK_CANCEL, true); - gint response = dialog.run(); - alerts_off = true; - if(response == GTK_RESPONSE_CANCEL) { - SPLPEItem* item = const_cast<SPLPEItem*>(lpeitem); - item->removeCurrentPathEffect(false); - return; + } +} + +void +LPEMeasureLine::doOnVisibilityToggled(SPLPEItem const* /*lpeitem*/) +{ + if (SPDesktop *desktop = SP_ACTIVE_DESKTOP) { + Inkscape::URI SVGElem_uri(((Glib::ustring)"#" + (Glib::ustring)this->getRepr()->attribute("id") + (Glib::ustring)"_text").c_str()); + Inkscape::URIReference* SVGElemRef = new Inkscape::URIReference(desktop->doc()); + SVGElemRef->attach(SVGElem_uri); + SPObject *elemref = NULL; + Inkscape::XML::Node *rtext = NULL; + if (elemref = SVGElemRef->getObject()) { + rtext = elemref->getRepr(); + if (!this->isVisible()) { + rtext->setAttribute("style", "display:none"); + } else { + rtext->setAttribute("style", NULL); } } } @@ -154,266 +148,166 @@ LPEMeasureLine::doBeforeEffect (SPLPEItem const* lpeitem) if (sp_path) { Geom::PathVector pathvector = sp_path->get_original_curve()->get_pathvector(); if (SPDesktop *desktop = SP_ACTIVE_DESKTOP) { - Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); - std::vector<OrientationMethod> orientations; - std::vector<OrientationMethod> orientations_remove; - if ( orientation == OM_HORIZONTAL || - orientation == OM_PARALLEL_VERTICAL_HORIZONTAL || - orientation == OM_PARALLEL_HORIZONTAL || - orientation == OM_VERTICAL_HORIZONTAL) - { - orientations.push_back(OM_HORIZONTAL); - } else { - orientations_remove.push_back(OM_HORIZONTAL); - } - if ( orientation == OM_VERTICAL || - orientation == OM_PARALLEL_VERTICAL_HORIZONTAL || - orientation == OM_PARALLEL_VERTICAL || - orientation == OM_VERTICAL_HORIZONTAL) - { - orientations.push_back(OM_VERTICAL); - } else { - orientations_remove.push_back(OM_VERTICAL); + size_t ncurves = pathvector.curveCount(); + curve_linked.param_set_range(0, ncurves); + Geom::Point s = pathvector.initialPoint(); + Geom::Point e = pathvector.finalPoint(); + if (curve_linked) { //0 start-end nodes + s = pathvector.pointAt(curve_linked -1); + e = pathvector.pointAt(curve_linked); } - if ( orientation == OM_PARALLEL || - orientation == OM_PARALLEL_VERTICAL_HORIZONTAL || - orientation == OM_PARALLEL_VERTICAL || - orientation == OM_PARALLEL_HORIZONTAL) - { - orientations.push_back(OM_PARALLEL); - } else { - orientations_remove.push_back(OM_PARALLEL); - } - for (std::vector<OrientationMethod>::const_iterator om_it = orientations.begin(); om_it != orientations.end(); ++om_it) { - Geom::Point s = pathvector.initialPoint(); - Geom::Point e = pathvector.finalPoint(); - Glib::ustring orientation_str; - Inkscape::XML::Node *rtext = NULL; - if (*om_it == OM_VERTICAL) { - orientation_str = "vertical"; - } - if (*om_it == OM_HORIZONTAL) { - orientation_str = "horizontal"; + Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); + Glib::ustring orientation_str; + Inkscape::XML::Node *rtext = NULL; + if (orientation == OM_VERTICAL) { + orientation_str = "vertical"; + Coord xpos = std::max(s[Geom::X],e[Geom::X]); + if (reverse) { + xpos = std::min(s[Geom::X],e[Geom::X]); } - if (*om_it == OM_PARALLEL) { - orientation_str = "parallel"; + s[Geom::X] = xpos; + e[Geom::X] = xpos; + if (s[Geom::Y] > e[Geom::Y]) { + swap(s,e); } - if (origin.linksToPath() && origin.getObject() && !origin.get_pathvector().empty()) { - pathvector = origin.get_pathvector(); - size_t ncurves = pathvector.curveCount(); - curve_linked.param_set_range(1, ncurves); - if(previous_ncurves != ncurves) { - this->upd_params = true; - previous_ncurves = ncurves; - } - s = pathvector.pointAt(curve_linked -1); - e = pathvector.pointAt(curve_linked); - if(*om_it == OM_VERTICAL) { - Coord xpos = std::max(s[Geom::X],e[Geom::X]); - if (reverse) { - xpos = std::min(s[Geom::X],e[Geom::X]); - } - s[Geom::X] = xpos; - e[Geom::X] = xpos; - if (s[Geom::Y] > e[Geom::Y]) { - swap(s,e); - } - } - if(*om_it == OM_HORIZONTAL) { - Coord ypos = std::max(s[Geom::Y],e[Geom::Y]); - if (reverse) { - ypos = std::min(s[Geom::Y],e[Geom::Y]); - } - s[Geom::Y] = ypos; - e[Geom::Y] = ypos; - if (s[Geom::X] < e[Geom::X]) { - swap(s,e); - } - } - Geom::Ray ray(s,e); - Geom::Coord angle = ray.angle(); - if (reverse) { - angle = std::fmod(angle + rad_from_deg(180), 2*M_PI); - if (angle < 0) angle += 2*M_PI; - } - Geom::Coord angle_cross = std::fmod(angle + rad_from_deg(90), 2*M_PI); - if (angle_cross < 0) angle_cross += 2*M_PI; - s = s - Point::polar(angle_cross, origin_offset); - e = e - Point::polar(angle_cross, origin_offset); - Geom::Path path; - path.start( s ); - path.appendNew<Geom::LineSegment>( e ); - Geom::PathVector line_upd; - line_upd.push_back(path); - Inkscape::XML::Node *line = SP_OBJECT(sp_path)->getRepr(); - gchar *str = sp_svg_write_path(line_upd); - line->setAttribute("inkscape:original-d", str); - } else { - if(*om_it == OM_VERTICAL) { - Coord xpos = std::max(s[Geom::X],e[Geom::X]); - if (reverse) { - xpos = std::min(s[Geom::X],e[Geom::X]); - } - s[Geom::X] = xpos; - e[Geom::X] = xpos; - if (s[Geom::Y] > e[Geom::Y]) { - swap(s,e); - } - } - if(*om_it == OM_HORIZONTAL) { - Coord ypos = std::max(s[Geom::Y],e[Geom::Y]); - if (reverse) { - ypos = std::min(s[Geom::Y],e[Geom::Y]); - } - s[Geom::Y] = ypos; - e[Geom::Y] = ypos; - if (s[Geom::X] < e[Geom::X]) { - swap(s,e); - } - } - } - double length = Geom::distance(s, e) * scale; - Geom::Point pos = Geom::middle_point(s,e); - Geom::Ray ray(s,e); - Geom::Coord angle = ray.angle(); - doc_unit = Inkscape::Util::unit_table.getUnit(desktop->doc()->getRoot()->height.unit)->abbr; + } + if (orientation == OM_HORIZONTAL) { + orientation_str = "horizontal"; + Coord ypos = std::max(s[Geom::Y],e[Geom::Y]); if (reverse) { - angle = std::fmod(angle + rad_from_deg(180), 2*M_PI); - if (angle < 0) angle += 2*M_PI; + ypos = std::min(s[Geom::Y],e[Geom::Y]); } - Geom::Point newpos = pos - Point::polar(angle, offset_right_left); - Geom::Coord angle_cross = std::fmod(angle + rad_from_deg(90), 2*M_PI); - if (angle_cross < 0) angle_cross += 2*M_PI; - newpos = newpos - Point::polar(angle_cross, offset_top_bottom); - Inkscape::URI SVGElem_uri(((Glib::ustring)"#" + (Glib::ustring)SP_OBJECT(lpeitem)->getId() + (Glib::ustring)"_DINnumber_" + orientation_str).c_str()); - Inkscape::URIReference* SVGElemRef = new Inkscape::URIReference(desktop->doc()); - SVGElemRef->attach(SVGElem_uri); - SPObject *elemref = NULL; - Inkscape::XML::Node *rtspan = NULL; - if (elemref = SVGElemRef->getObject()) { - rtext = elemref->getRepr(); - sp_repr_set_svg_double(rtext, "x", newpos[Geom::X]); - sp_repr_set_svg_double(rtext, "y", newpos[Geom::Y]); - } else { - rtext = xml_doc->createElement("svg:text"); - rtext->setAttribute("xml:space", "preserve"); - rtext->setAttribute("sodipodi:insensitive", "true"); - rtext->setAttribute("id", ((Glib::ustring)SP_OBJECT(lpeitem)->getId() + (Glib::ustring)"_DINnumber_" + orientation_str).c_str()); - /* Set style */ - sp_repr_set_svg_double(rtext, "x", newpos[Geom::X]); - sp_repr_set_svg_double(rtext, "y", newpos[Geom::Y]); - /* Create <tspan> */ - rtspan = xml_doc->createElement("svg:tspan"); - rtspan->setAttribute("sodipodi:role", "line"); + s[Geom::Y] = ypos; + e[Geom::Y] = ypos; + if (s[Geom::X] < e[Geom::X]) { + swap(s,e); } - SPCSSAttr *css = sp_repr_css_attr_new(); - Pango::FontDescription fontdesc((Glib::ustring)fontbutton.param_getSVGValue()); - double fontsize = fontdesc.get_size()/Pango::SCALE; - 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"); - if (color_as_line) { - if (lpeitem->style) { - if (lpeitem->style->stroke.isPaintserver()) { - SPPaintServer * server = lpeitem->style->getStrokePaintServer(); - if (server) { - Glib::ustring str; - str += "url(#"; - str += server->getId(); - str += ")"; - sp_repr_css_set_property (css, "fill", str.c_str()); - } - } else if (lpeitem->style->stroke.isColor()) { - gchar c[64]; - sp_svg_write_color (c, sizeof(c), lpeitem->style->stroke.value.color.toRGBA32(SP_SCALE24_TO_FLOAT(lpeitem->style->stroke_opacity.value))); - sp_repr_css_set_property (css, "fill", c); - } else { - sp_repr_css_set_property (css, "fill", "#000000"); + } + if (orientation == OM_PARALLEL) { + orientation_str = "parallel"; + } + double length = Geom::distance(s, e) * scale; + Geom::Point pos = Geom::middle_point(s,e); + Geom::Ray ray(s,e); + Geom::Coord angle = ray.angle(); + doc_unit = Inkscape::Util::unit_table.getUnit(desktop->doc()->getRoot()->height.unit)->abbr; + if (reverse) { + angle = std::fmod(angle + rad_from_deg(180), 2*M_PI); + if (angle < 0) angle += 2*M_PI; + } + Geom::Point newpos = pos - Point::polar(angle, offset_right_left); + Geom::Coord angle_cross = std::fmod(angle + rad_from_deg(90), 2*M_PI); + if (angle_cross < 0) angle_cross += 2*M_PI; + newpos = newpos - Point::polar(angle_cross, offset_top_bottom); + Inkscape::URI SVGElem_uri(((Glib::ustring)"#" + (Glib::ustring)this->getRepr()->attribute("id") + (Glib::ustring)"_text").c_str()); + Inkscape::URIReference* SVGElemRef = new Inkscape::URIReference(desktop->doc()); + SVGElemRef->attach(SVGElem_uri); + SPObject *elemref = NULL; + Inkscape::XML::Node *rtspan = NULL; + if (elemref = SVGElemRef->getObject()) { + rtext = elemref->getRepr(); + sp_repr_set_svg_double(rtext, "x", newpos[Geom::X]); + sp_repr_set_svg_double(rtext, "y", newpos[Geom::Y]); + } else { + rtext = xml_doc->createElement("svg:text"); + rtext->setAttribute("xml:space", "preserve"); + rtext->setAttribute("sodipodi:insensitive", "true"); + rtext->setAttribute("id", ((Glib::ustring)this->getRepr()->attribute("id") + (Glib::ustring)"_text").c_str()); + /* Set style */ + sp_repr_set_svg_double(rtext, "x", newpos[Geom::X]); + sp_repr_set_svg_double(rtext, "y", newpos[Geom::Y]); + /* Create <tspan> */ + rtspan = xml_doc->createElement("svg:tspan"); + rtspan->setAttribute("sodipodi:role", "line"); + } + SPCSSAttr *css = sp_repr_css_attr_new(); + Pango::FontDescription fontdesc((Glib::ustring)fontbutton.param_getSVGValue()); + double fontsize = fontdesc.get_size()/Pango::SCALE; + 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"); + if (color_as_line) { + if (lpeitem->style) { + if (lpeitem->style->stroke.isPaintserver()) { + SPPaintServer * server = lpeitem->style->getStrokePaintServer(); + if (server) { + Glib::ustring str; + str += "url(#"; + str += server->getId(); + str += ")"; + sp_repr_css_set_property (css, "fill", str.c_str()); } + } else if (lpeitem->style->stroke.isColor()) { + gchar c[64]; + sp_svg_write_color (c, sizeof(c), lpeitem->style->stroke.value.color.toRGBA32(SP_SCALE24_TO_FLOAT(lpeitem->style->stroke_opacity.value))); + sp_repr_css_set_property (css, "fill", c); } else { - sp_repr_css_unset_property (css, "#000000"); + sp_repr_css_set_property (css, "fill", "#000000"); } } else { - 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"); - Glib::ustring css_str; - sp_repr_css_write_string(css,css_str); - if (!rtspan) { - rtspan = rtext->firstChild(); - } - rtspan->setAttribute("style", css_str.c_str()); - sp_repr_css_attr_unref (css); - if (!elemref) { - rtext->addChild(rtspan, NULL); - Inkscape::GC::release(rtspan); - } - /* Create TEXT */ - if (!scale_insensitive) { - Geom::Affine affinetransform = i2anc_affine(SP_OBJECT(lpeitem), SP_OBJECT(desktop->doc()->getRoot())); - length *= (affinetransform.expansionX() + affinetransform.expansionY()) / 2.0; - } - length = Inkscape::Util::Quantity::convert(length, doc_unit.c_str(), unit.get_abbreviation()); - std::stringstream length_str; - length_str.precision(precision); - length_str.setf(std::ios::fixed, std::ios::floatfield); - if (local_locale) { - length_str.imbue(std::locale("")); - } else { - length_str.imbue(std::locale::classic()); - } - length_str << std::fixed << length; - length_str << unit.get_abbreviation(); - Inkscape::XML::Node *rstring = NULL; - if (!elemref) { - rstring = xml_doc->createTextNode(length_str.str().c_str()); - rtspan->addChild(rstring, NULL); - Inkscape::GC::release(rstring); - } else { - rstring = rtspan->firstChild(); - rstring->setContent(length_str.str().c_str()); + sp_repr_css_unset_property (css, "#000000"); } - SPObject * text_obj = NULL; - if (!elemref) { - text_obj = SP_OBJECT(desktop->currentLayer()->appendChildRepr(rtext)); - Inkscape::GC::release(rtext); - } else { - text_obj = desktop->currentLayer()->get_child_by_repr(rtext); - } - Geom::Affine affine = Geom::Affine(Geom::Translate(newpos).inverse()); - affine *= Geom::Rotate(angle); - affine *= Geom::Translate(newpos); - SP_ITEM(text_obj)->transform = affine * i2anc_affine(SP_OBJECT(lpeitem), SP_OBJECT(desktop->doc()->getRoot())); - text_obj->updateRepr(); + } else { + sp_repr_css_set_property (css, "fill", "#000000"); } - for (std::vector<OrientationMethod>::const_iterator omdel_it = orientations_remove.begin(); omdel_it != orientations_remove.end(); ++omdel_it) { - Glib::ustring orientation_str; - if (*omdel_it == OM_VERTICAL) { - orientation_str = "vertical"; - } - if (*omdel_it == OM_HORIZONTAL) { - orientation_str = "horizontal"; - } - if (*omdel_it == OM_PARALLEL) { - orientation_str = "parallel"; - } - Inkscape::URI SVGElem_uri(((Glib::ustring)"#" + (Glib::ustring)SP_OBJECT(lpeitem)->getId() + (Glib::ustring)"_DINnumber_" + orientation_str).c_str()); - Inkscape::URIReference* SVGElemRef = new Inkscape::URIReference(desktop->doc()); - SVGElemRef->attach(SVGElem_uri); - SPObject *elemref = NULL; - if (elemref = SVGElemRef->getObject()) { - elemref->deleteObject(); - } + sp_repr_css_set_property (css, "fill-opacity", "1"); + sp_repr_css_set_property (css, "stroke", "none"); + Glib::ustring css_str; + sp_repr_css_write_string(css,css_str); + if (!rtspan) { + rtspan = rtext->firstChild(); + } + rtspan->setAttribute("style", css_str.c_str()); + sp_repr_css_attr_unref (css); + if (!elemref) { + rtext->addChild(rtspan, NULL); + Inkscape::GC::release(rtspan); + } + /* Create TEXT */ + if (!scale_insensitive) { + Geom::Affine affinetransform = i2anc_affine(SP_OBJECT(lpeitem), SP_OBJECT(desktop->doc()->getRoot())); + length *= (affinetransform.expansionX() + affinetransform.expansionY()) / 2.0; + } + length = Inkscape::Util::Quantity::convert(length, doc_unit.c_str(), unit.get_abbreviation()); + std::stringstream length_str; + length_str.precision(precision); + length_str.setf(std::ios::fixed, std::ios::floatfield); + if (local_locale) { + length_str.imbue(std::locale("")); + } else { + length_str.imbue(std::locale::classic()); } + length_str << std::fixed << length; + length_str << unit.get_abbreviation(); + Inkscape::XML::Node *rstring = NULL; + if (!elemref) { + rstring = xml_doc->createTextNode(length_str.str().c_str()); + rtspan->addChild(rstring, NULL); + Inkscape::GC::release(rstring); + } else { + rstring = rtspan->firstChild(); + rstring->setContent(length_str.str().c_str()); + } + SPObject * text_obj = NULL; + if (!elemref) { + text_obj = SP_OBJECT(desktop->currentLayer()->appendChildRepr(rtext)); + Inkscape::GC::release(rtext); + } else { + text_obj = desktop->currentLayer()->get_child_by_repr(rtext); + } + Geom::Affine affine = Geom::Affine(Geom::Translate(newpos).inverse()); + affine *= Geom::Rotate(angle); + affine *= Geom::Translate(newpos); + SP_ITEM(text_obj)->transform = affine * i2anc_affine(SP_OBJECT(lpeitem), SP_OBJECT(desktop->doc()->getRoot())); + text_obj->updateRepr(); } } } @@ -422,49 +316,13 @@ void LPEMeasureLine::doOnRemove (SPLPEItem const* lpeitem) { if (SPDesktop *desktop = SP_ACTIVE_DESKTOP) { SPLPEItem * splpeitem = const_cast<SPLPEItem *>(lpeitem); - std::vector<OrientationMethod> orientations; - std::vector<OrientationMethod> orientations_remove; - if ( orientation == OM_HORIZONTAL || - orientation == OM_PARALLEL_VERTICAL_HORIZONTAL || - orientation == OM_PARALLEL_HORIZONTAL || - orientation == OM_VERTICAL_HORIZONTAL) - { - orientations.push_back(OM_HORIZONTAL); - } - if ( orientation == OM_VERTICAL || - orientation == OM_PARALLEL_VERTICAL_HORIZONTAL || - orientation == OM_PARALLEL_VERTICAL || - orientation == OM_VERTICAL_HORIZONTAL) - { - orientations.push_back(OM_VERTICAL); - } - if ( orientation == OM_PARALLEL || - orientation == OM_PARALLEL_VERTICAL_HORIZONTAL || - orientation == OM_PARALLEL_VERTICAL || - orientation == OM_PARALLEL_HORIZONTAL) - { - orientations.push_back(OM_PARALLEL); - } - for (std::vector<OrientationMethod>::const_iterator om_it = orientations.begin(); om_it != orientations.end(); ++om_it) { - Glib::ustring orientation_str; - Inkscape::XML::Node *rtext = NULL; - if (*om_it == OM_VERTICAL) { - orientation_str = "vertical"; - } - if (*om_it == OM_HORIZONTAL) { - orientation_str = "horizontal"; - } - if (*om_it == OM_PARALLEL) { - orientation_str = "parallel"; - } - Inkscape::URI SVGElem_uri(((Glib::ustring)"#" + (Glib::ustring)SP_OBJECT(lpeitem)->getId() + (Glib::ustring)"_DINnumber_" + orientation_str).c_str()); - Inkscape::URIReference* SVGElemRef = new Inkscape::URIReference(desktop->doc()); - SVGElemRef->attach(SVGElem_uri); - SPObject *elemref = NULL; - Inkscape::XML::Node *rtspan = NULL; - if (elemref = SVGElemRef->getObject()) { - elemref->deleteObject(); - } + Inkscape::URI SVGElem_uri(((Glib::ustring)this->getRepr()->attribute("id") + (Glib::ustring)"_text").c_str()); + Inkscape::URIReference* SVGElemRef = new Inkscape::URIReference(desktop->doc()); + SVGElemRef->attach(SVGElem_uri); + SPObject *elemref = NULL; + Inkscape::XML::Node *rtspan = NULL; + if (elemref = SVGElemRef->getObject()) { + elemref->deleteObject(); } } } @@ -509,40 +367,7 @@ Gtk::Widget *LPEMeasureLine::newWidget() Geom::PathVector LPEMeasureLine::doEffect_path(Geom::PathVector const &path_in) { - Geom::Path path; - Geom::Point s = path_in.initialPoint(); - Geom::Point e = path_in.finalPoint(); - Geom::Ray ray(s,e); - Geom::Coord angle = ray.angle(); - if (reverse) { - angle = std::fmod(angle + rad_from_deg(180), 2*M_PI); - if (angle < 0) angle += 2*M_PI; - } - s = s - Point::polar(angle, gap_start); - angle = std::fmod(angle + rad_from_deg(180), 2*M_PI); - if (angle < 0) angle += 2*M_PI; - e = e - Point::polar(angle, gap_end); -// if(orientation == OM_VERTICAL) { -// Coord xpos = std::max(s[Geom::X],e[Geom::X]); -// if (reverse) { -// xpos = std::min(s[Geom::X],e[Geom::X]); -// } -// s[Geom::X] = xpos; -// e[Geom::X] = xpos; -// } -// if(orientation == OM_HORIZONTAL) { -// Coord ypos = std::max(s[Geom::Y],e[Geom::Y]); -// if (reverse) { -// ypos = std::min(s[Geom::Y],e[Geom::Y]); -// } -// s[Geom::Y] = ypos; -// e[Geom::Y] = ypos; -// } - path.start( s ); - path.appendNew<Geom::LineSegment>( e ); - Geom::PathVector output; - output.push_back(path); - return output; + return path_in; } void @@ -554,7 +379,6 @@ LPEMeasureLine::saveDefault() prefs->setInt("/live_effects/measure-line/precision", precision); prefs->setDouble("/live_effects/measure-line/offset_right_left", offset_right_left); prefs->setDouble("/live_effects/measure-line/offset_top_bottom", offset_top_bottom); - prefs->setDouble("/live_effects/measure-line/origin_offset", origin_offset); prefs->setString("/live_effects/measure-line/unit", (Glib::ustring)unit.get_abbreviation()); prefs->setBool("/live_effects/measure-line/reverse", reverse); prefs->setBool("/live_effects/measure-line/color_as_line", color_as_line); diff --git a/src/live_effects/lpe-measure-line.h b/src/live_effects/lpe-measure-line.h index 05f9b2f73..834194841 100644 --- a/src/live_effects/lpe-measure-line.h +++ b/src/live_effects/lpe-measure-line.h @@ -29,10 +29,6 @@ enum OrientationMethod { OM_HORIZONTAL, OM_VERTICAL, OM_PARALLEL, - OM_PARALLEL_VERTICAL, - OM_PARALLEL_HORIZONTAL, - OM_VERTICAL_HORIZONTAL, - OM_PARALLEL_VERTICAL_HORIZONTAL, OM_END }; @@ -43,29 +39,26 @@ public: virtual void doBeforeEffect (SPLPEItem const* lpeitem); virtual void doOnApply(SPLPEItem const* lpeitem); virtual void doOnRemove (SPLPEItem const* lpeitem); + virtual void doOnVisibilityToggled(SPLPEItem const* /*lpeitem*/); virtual Geom::PathVector doEffect_path(Geom::PathVector const &path_in); void saveDefault(); virtual Gtk::Widget *newWidget(); private: FontButtonParam fontbutton; EnumParam<OrientationMethod> orientation; - OriginalPathParam origin; ScalarParam curve_linked; - ScalarParam origin_offset; ScalarParam scale; ScalarParam precision; ScalarParam offset_right_left; ScalarParam offset_top_bottom; ScalarParam gap_start; ScalarParam gap_end; - size_t previous_ncurves; UnitParam unit; BoolParam reverse; BoolParam color_as_line; BoolParam scale_insensitive; BoolParam local_locale; Glib::ustring doc_unit; - static bool alerts_off; /* Geom::Affine affine_over;*/ LPEMeasureLine(const LPEMeasureLine &); LPEMeasureLine &operator=(const LPEMeasureLine &); diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp index 3f8fced4b..befac4df1 100644 --- a/src/live_effects/parameter/parameter.cpp +++ b/src/live_effects/parameter/parameter.cpp @@ -5,8 +5,8 @@ */ -#include "live_effects/parameter/parameter.h" #include "live_effects/effect.h" +#include "live_effects/parameter/parameter.h" #include "svg/svg.h" #include "xml/repr.h" @@ -66,8 +66,7 @@ ScalarParam::ScalarParam( const Glib::ustring& label, const Glib::ustring& tip, inc_page(1), add_slider(false), overwrite_widget(false), - hide_widget(no_widget), - _rsu(NULL) + hide_widget(no_widget) { } @@ -111,6 +110,7 @@ ScalarParam::param_update_default(gdouble default_value) void ScalarParam::param_set_value(gdouble val) { + param_effect->upd_params = true; value = val; if (integer) value = round(value); @@ -118,9 +118,6 @@ ScalarParam::param_set_value(gdouble val) value = max; if (value < min) value = min; - if (_rsu) { - _rsu->setValue(val); - } } void @@ -131,7 +128,7 @@ ScalarParam::param_set_range(gdouble min, gdouble max) // Once again, in gtk2, this is not a problem. But in gtk3, // widgets get allocated the amount of size they ask for, // leading to excessively long widgets. - + param_effect->upd_params = true; if (min >= -SCALARPARAM_G_MAXDOUBLE) { this->min = min; } else { @@ -140,10 +137,7 @@ ScalarParam::param_set_range(gdouble min, gdouble max) if (max <= SCALARPARAM_G_MAXDOUBLE) { this->max = max; } else { - this->max = SCALARPARAM_G_MAXDOUBLE; - } - if (_rsu) { - _rsu->setRange(this->min, this->max); + this->max = SCALARPARAM_G_MAXDOUBLE; } param_set_value(value); // reset value to see whether it is in ranges } @@ -151,6 +145,7 @@ ScalarParam::param_set_range(gdouble min, gdouble max) void ScalarParam::param_make_integer(bool yes) { + param_effect->upd_params = true; integer = yes; digits = 0; inc_step = 1; @@ -167,22 +162,22 @@ Gtk::Widget * ScalarParam::param_newWidget() { if(!hide_widget){ - _rsu = Gtk::manage( new Inkscape::UI::Widget::RegisteredScalar( + Inkscape::UI::Widget::RegisteredScalar *rsu = Gtk::manage( new Inkscape::UI::Widget::RegisteredScalar( param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc() ) ); - _rsu->setValue(value); - _rsu->setDigits(digits); - _rsu->setIncrements(inc_step, inc_page); - _rsu->setRange(min, max); - _rsu->setProgrammatically = false; + rsu->setValue(value); + rsu->setDigits(digits); + rsu->setIncrements(inc_step, inc_page); + rsu->setRange(min, max); + rsu->setProgrammatically = false; if (add_slider) { - _rsu->addSlider(); + rsu->addSlider(); } if(!overwrite_widget){ - _rsu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change scalar parameter")); + rsu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change scalar parameter")); } param_effect->upd_params = false; - return dynamic_cast<Gtk::Widget *> (_rsu); + return dynamic_cast<Gtk::Widget *> (rsu); } else { return NULL; } @@ -191,20 +186,16 @@ ScalarParam::param_newWidget() void ScalarParam::param_set_digits(unsigned digits) { + param_effect->upd_params = true; this->digits = digits; - if (_rsu) { - _rsu->setDigits(this->digits); - } } void ScalarParam::param_set_increments(double step, double page) { + param_effect->upd_params = true; inc_step = step; inc_page = page; - if (_rsu) { - _rsu->setIncrements(inc_step, inc_page); - } } diff --git a/src/live_effects/parameter/parameter.h b/src/live_effects/parameter/parameter.h index 63c55203e..3658bded8 100644 --- a/src/live_effects/parameter/parameter.h +++ b/src/live_effects/parameter/parameter.h @@ -117,7 +117,6 @@ public: void param_set_range(gdouble min, gdouble max); void param_set_digits(unsigned digits); void param_set_increments(double step, double page); - void addSlider(bool add_slider_widget) { add_slider = add_slider_widget; }; void param_overwrite_widget(bool overwrite_widget); @@ -141,7 +140,6 @@ protected: private: ScalarParam(const ScalarParam&); ScalarParam& operator=(const ScalarParam&); - Inkscape::UI::Widget::RegisteredScalar *_rsu; }; } //namespace LivePathEffect diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index 7205beaa8..e177ae01e 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -589,6 +589,14 @@ void LivePathEffectEditor::on_visibility_toggled( Glib::ustring const& str ) /* FIXME: this explicit writing to SVG is wrong. The lpe_item should have a method to disable/enable an effect within its stack. * So one can call: lpe_item->setActive(lpeobjref->lpeobject); */ lpeobjref->lpeobject->get_lpe()->getRepr()->setAttribute("is_visible", newValue ? "true" : "false"); + Inkscape::Selection *sel = _getSelection(); + if ( sel && !sel->isEmpty() ) { + SPItem *item = sel->singleItem(); + SPLPEItem *lpeitem = dynamic_cast<SPLPEItem *>(item); + if ( lpeitem ) { + lpeobjref->lpeobject->get_lpe()->doOnVisibilityToggled(lpeitem); + } + } DocumentUndo::done( current_desktop->getDocument(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, newValue ? _("Activate path effect") : _("Deactivate path effect")); } diff --git a/src/ui/widget/registered-widget.cpp b/src/ui/widget/registered-widget.cpp index 38bb7f7cc..923949b72 100644 --- a/src/ui/widget/registered-widget.cpp +++ b/src/ui/widget/registered-widget.cpp @@ -298,7 +298,6 @@ RegisteredScalar::on_value_changed() setProgrammatically = false; return; } - if (_wr->isUpdating()) { return; } diff --git a/src/ui/widget/scalar.cpp b/src/ui/widget/scalar.cpp index fca8a7974..80a2454b0 100644 --- a/src/ui/widget/scalar.cpp +++ b/src/ui/widget/scalar.cpp @@ -126,10 +126,12 @@ void Scalar::setRange(double min, double max) static_cast<SpinButton*>(_widget)->set_range(min, max); } -void Scalar::setValue(double value) +void Scalar::setValue(double value, bool setProg) { g_assert(_widget != NULL); - setProgrammatically = true; // callback is supposed to reset back, if it cares + if (setProg) { + setProgrammatically = true; // callback is supposed to reset back, if it cares + } static_cast<SpinButton*>(_widget)->set_value(value); } diff --git a/src/ui/widget/scalar.h b/src/ui/widget/scalar.h index 86d7aee28..9cceeaa1f 100644 --- a/src/ui/widget/scalar.h +++ b/src/ui/widget/scalar.h @@ -139,7 +139,7 @@ public: /** * Sets the value of the spin button. */ - void setValue(double value); + void setValue(double value, bool setProg = true); /** * Manually forces an update of the spin button. |
