diff options
| author | Jabiertxof <jtx@jtx> | 2016-12-07 01:00:05 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx> | 2016-12-07 01:00:05 +0000 |
| commit | 4faef66de872ba1abd4e652ead9b66fc3394eda0 (patch) | |
| tree | 853663b2263add0b9461b08f788ef60cbf81098e /src | |
| parent | Remove obsolete comment (diff) | |
| download | inkscape-4faef66de872ba1abd4e652ead9b66fc3394eda0.tar.gz inkscape-4faef66de872ba1abd4e652ead9b66fc3394eda0.zip | |
Fix measure LPE to fit future extra objects based LPE
(bzr r15304)
Diffstat (limited to 'src')
| -rw-r--r-- | src/live_effects/lpe-measure-line.cpp | 44 | ||||
| -rw-r--r-- | src/live_effects/lpe-measure-line.h | 1 |
2 files changed, 32 insertions, 13 deletions
diff --git a/src/live_effects/lpe-measure-line.cpp b/src/live_effects/lpe-measure-line.cpp index a1de035fb..8b73781b5 100644 --- a/src/live_effects/lpe-measure-line.cpp +++ b/src/live_effects/lpe-measure-line.cpp @@ -14,6 +14,7 @@ #include <libnrtype/font-lister.h> #include "inkscape.h" #include "xml/node.h" +#include "xml/sp-css-attr.h" #include "uri.h" #include "uri-references.h" #include "preferences.h" @@ -61,6 +62,7 @@ LPEMeasureLine::LPEMeasureLine(LivePathEffectObject *lpeobject) : helpline_overlap(_("Helpline overlap*"), _("Helpline overlap"), "helpline_overlap", &wr, this, 2.0), 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}"), + id_origin("id_origin", "id_origin", "id_origin", &wr, this,""), arrows_outside(_("Arrows outside"), _("Arrows outside"), "arrows_outside", &wr, this, false), 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), @@ -97,6 +99,8 @@ LPEMeasureLine::LPEMeasureLine(LivePathEffectObject *lpeobject) : registerParameter(&helperlines_format); registerParameter(&anotation_format); registerParameter(&arrows_format); + registerParameter(&id_origin); + id_origin.param_hide_canvas_text(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); Glib::ustring fontbutton_value = prefs->getString("/live_effects/measure-line/fontbutton"); if(fontbutton_value.empty()){ @@ -505,6 +509,8 @@ LPEMeasureLine::doOnApply(SPLPEItem const* lpeitem) SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem); item->removeCurrentPathEffect(false); } + id_origin.param_setValue(Glib::ustring(lpeitem->getId())); + id_origin.write_to_SVG(); } void @@ -701,31 +707,43 @@ LPEMeasureLine::doOnRemove (SPLPEItem const* /*lpeitem*/) void LPEMeasureLine::processObjects(LpeAction lpe_action) { - if (SPDesktop *desktop = SP_ACTIVE_DESKTOP) { - for (std::vector<const char *>::const_iterator el_it = elements.begin(); - el_it != elements.end();++el_it) { - const char * id = (const char *)(*el_it); - std::cout << id << "asdfffgasdfasdsdgf\n"; + for (std::vector<const char *>::iterator el_it = elements.begin(); + el_it != elements.end(); ++el_it) { + const char * id = *el_it; Inkscape::URI SVGElem_uri(Glib::ustring("#").append(id).c_str()); Inkscape::URIReference* SVGElemRef = new Inkscape::URIReference(desktop->doc()); SVGElemRef->attach(SVGElem_uri); SPObject *elemref = NULL; if (elemref = SVGElemRef->getObject()) { + SPCSSAttr *css; + Glib::ustring css_str; switch (lpe_action){ case LPE_TO_OBJECTS: + elemref->getRepr()->setAttribute("inkscape:path-effect", NULL); elemref->getRepr()->setAttribute("sodipodi:insensitive", NULL); - break; + break; + case LPE_ERASE: - elemref->deleteObject(); - break; - default: //LPE_VISIBILITY - if (!this->isVisible()) { - elemref->getRepr()->setAttribute("style", "display:none"); + if (std::strcmp(elemref->getId(),id_origin.param_getSVGValue()) != 0) { + 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(),id_origin.param_getSVGValue()) != 0) { + css->setAttribute("display", "none"); } else { - elemref->getRepr()->setAttribute("style", NULL); + css->setAttribute("display", NULL); } - break; + sp_repr_css_write_string(css,css_str); + elemref->getRepr()->setAttribute("style", css_str.c_str()); + break; + + default: + break; } } } diff --git a/src/live_effects/lpe-measure-line.h b/src/live_effects/lpe-measure-line.h index cb902e74f..565644c07 100644 --- a/src/live_effects/lpe-measure-line.h +++ b/src/live_effects/lpe-measure-line.h @@ -68,6 +68,7 @@ private: ScalarParam helpline_overlap; ScalarParam scale; TextParam format; + TextParam id_origin; BoolParam arrows_outside; BoolParam flip_side; BoolParam scale_sensitive; |
