diff options
| -rw-r--r-- | src/live_effects/lpe-measure-segments.cpp | 225 | ||||
| -rw-r--r-- | src/live_effects/lpe-measure-segments.h | 3 | ||||
| -rw-r--r-- | src/ui/tool/curve-drag-point.cpp | 1 |
3 files changed, 123 insertions, 106 deletions
diff --git a/src/live_effects/lpe-measure-segments.cpp b/src/live_effects/lpe-measure-segments.cpp index e72bfbc82..401c9f48a 100644 --- a/src/live_effects/lpe-measure-segments.cpp +++ b/src/live_effects/lpe-measure-segments.cpp @@ -41,6 +41,7 @@ #include "inkscape.h" #include "preferences.h" #include "path-chemistry.h" +#include "style.h" #include <cmath> #include <iomanip> @@ -89,6 +90,7 @@ LPEMeasureSegments::LPEMeasureSegments(LivePathEffectObject *lpeobject) : rotate_anotation(_("Rotate labels"), _("Labels are parallel to the dimension line"), "rotate_anotation", &wr, this, true), hide_back(_("Hide line under label"), _("Hide the dimension line where the label overlaps it"), "hide_back", &wr, this, true), hide_arrows(_("Hide arrows"), _("Don't show any arrows"), "hide_arrows", &wr, this, false), + // active for 1.1 smallx100(_("Multiply values < 1"), _("Multiply values smaller than 1 by 100 and leave out the unit"), "smallx100", &wr, this, false), linked_items(_("Linked objects:"), _("Objects whose nodes are projected onto the path and generate new measurements"), "linked_items", &wr, this), distance_projection(_("Distance"), _("Distance of the dimension lines from the outermost node"), "distance_projection", &wr, this, 20.0), @@ -126,6 +128,7 @@ LPEMeasureSegments::LPEMeasureSegments(LivePathEffectObject *lpeobject) : registerParameter(&rotate_anotation); registerParameter(&hide_back); registerParameter(&hide_arrows); + // active for 1.1 registerParameter(&smallx100); registerParameter(&linked_items); registerParameter(&distance_projection); @@ -181,20 +184,25 @@ LPEMeasureSegments::LPEMeasureSegments(LivePathEffectObject *lpeobject) : locale_base = strdup(setlocale(LC_NUMERIC, nullptr)); previous_size = 0; pagenumber = 0; + anotation_width = 0; + fontsize = 0; + rgb32 = 0; + arrow_gap = 0; + //TODO: add newlines for 1.1 (not easy) helpdata.param_update_default(_("<b><big>General</big></b>\n" - "Display and position dimension lines and labels\n\n" - "<b><big>Projection</big></b>\n" - "Show a line with measurements based on the selected items\n\n" - "<b><big>Options</big></b>\n" - "Options for color, precision, label formatting and display\n\n" - "<b><big>Tips</big></b>\n" - "<b><i>Custom styling:</i></b> To further customize the styles, " - "use the XML editor to find out the class or ID, then use the " - "Style dialog to apply a new style.\n" - "<b><i>Blacklists:</i></b> allow to hide some segments or projection steps.\n" - "<b><i>Multiple Measure LPEs:</i></b> In the same object, in conjunction with blacklists," - "this allows for labels and measurements with different orientations or additional projections.\n" - "<b><i>Set Defaults:</i></b> For every LPE, default values can be set at the bottom.")); + "Display and position dimension lines and labels\n\n" + "<b><big>Projection</big></b>\n" + "Show a line with measurements based on the selected items\n\n" + "<b><big>Options</big></b>\n" + "Options for color, precision, label formatting and display\n\n" + "<b><big>Tips</big></b>\n" + "<b><i>Custom styling:</i></b> To further customize the styles, " + "use the XML editor to find out the class or ID, then use the " + "Style dialog to apply a new style.\n" + "<b><i>Blacklists:</i></b> allow to hide some segments or projection steps.\n" + "<b><i>Multiple Measure LPEs:</i></b> In the same object, in conjunction with blacklists," + "this allows for labels and measurements with different orientations or additional projections.\n" + "<b><i>Set Defaults:</i></b> For every LPE, default values can be set at the bottom.")); } LPEMeasureSegments::~LPEMeasureSegments() { @@ -252,10 +260,20 @@ LPEMeasureSegments::newWidget() param->param_key == "whitelist" || param->param_key == "showindex" || param->param_key == "local_locale" || - param->param_key == "smallx100" || param->param_key == "hide_arrows" ) { vbox2->pack_start(*widg, false, true, 2); + } else if (//TOD: unhack for 1.1 + param->param_key == "smallx100" ) + { + Glib::ustring widgl = param->param_label; + size_t pos = widgl.find("<"); + if (pos != std::string::npos ) { + widgl.erase(pos, 1); + widgl.insert(pos, "<"); + } + param->param_label = widgl.c_str(); + vbox2->pack_start(*widg, false, true, 2); } else if (param->param_key == "helpdata") { vbox3->pack_start(*widg, false, true, 2); @@ -342,7 +360,7 @@ LPEMeasureSegments::createArrowMarker(Glib::ustring mode) Glib::ustring classarrow = itemid; classarrow += " "; classarrow += lpobjid; - classarrow += " measure-arrows-marker"; + classarrow += " measure-arrow-marker"; arrow->setAttribute("class", classarrow.c_str()); arrow->setAttribute("inkscape:stockid", mode.c_str()); arrow->setAttribute("orient", "auto"); @@ -364,7 +382,7 @@ LPEMeasureSegments::createArrowMarker(Glib::ustring mode) Glib::ustring classarrowpath = itemid; classarrowpath += " "; classarrowpath += lpobjid; - classarrowpath += " measure-arrows"; + classarrowpath += " measure-arrow"; arrow_path->setAttribute("class", classarrowpath.c_str()); Glib::ustring arrowpath = mode + Glib::ustring("_path"); arrow_path->setAttribute("id", arrowpath.c_str()); @@ -385,8 +403,6 @@ LPEMeasureSegments::createTextLabel(Geom::Point pos, size_t counter, double leng return; } Inkscape::XML::Document *xml_doc = document->getReprDoc(); - Inkscape::XML::Node *rtext = nullptr; - Glib::ustring lpobjid = this->lpeobj->getId(); Glib::ustring itemid = sp_lpe_item->getId(); Glib::ustring id = Glib::ustring("text-on-"); @@ -394,7 +410,9 @@ LPEMeasureSegments::createTextLabel(Geom::Point pos, size_t counter, double leng id += "-"; id += lpobjid; SPObject *elemref = nullptr; + Inkscape::XML::Node *rtext = nullptr; Inkscape::XML::Node *rtspan = nullptr; + Inkscape::XML::Node *rstring = nullptr; elemref = document->getObjectById(id.c_str()); if (elemref) { rtext = elemref->getRepr(); @@ -402,6 +420,15 @@ LPEMeasureSegments::createTextLabel(Geom::Point pos, size_t counter, double leng sp_repr_set_svg_double(rtext, "y", pos[Geom::Y]); rtext->setAttribute("sodipodi:insensitive", "true"); rtext->setAttribute("transform", nullptr); + rtspan = rtext->firstChild(); + rstring = rtspan->firstChild(); + rtspan->setAttribute("x", nullptr); + rtspan->setAttribute("y", nullptr); + Glib::ustring classlabel = itemid; + classlabel += " "; + classlabel += lpobjid; + classlabel += " measure-label"; + rtext->setAttribute("class", classlabel.c_str()); } else { rtext = xml_doc->createElement("svg:text"); rtext->setAttribute("xml:space", "preserve"); @@ -409,13 +436,23 @@ LPEMeasureSegments::createTextLabel(Geom::Point pos, size_t counter, double leng Glib::ustring classlabel = itemid; classlabel += " "; classlabel += lpobjid; - classlabel += " measure-labels"; + classlabel += " measure-label"; rtext->setAttribute("class", classlabel.c_str()); rtext->setAttribute("sodipodi:insensitive", "true"); + rtext->setAttribute("transform", nullptr); 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"); rtspan->setAttribute("sodipodi:role", "line"); + rtspan->setAttribute("x", nullptr); + rtspan->setAttribute("y", nullptr); + elemref = document->getRoot()->appendChildRepr(rtext); + Inkscape::GC::release(rtext); + rtext->addChild(rtspan, nullptr); + Inkscape::GC::release(rtspan); + rstring = xml_doc->createTextNode(""); + rtspan->addChild(rstring, nullptr); + Inkscape::GC::release(rstring); } SPCSSAttr *css = sp_repr_css_attr_new(); Inkscape::FontLister *fontlister = Inkscape::FontLister::get_instance(); @@ -424,32 +461,25 @@ LPEMeasureSegments::createTextLabel(Geom::Point pos, size_t counter, double leng g_free(fontbutton_str); std::stringstream font_size; setlocale (LC_NUMERIC, "C"); - font_size << fontsize << "pt"; - setlocale (LC_NUMERIC, locale_base); + font_size << fontsize << "px"; + setlocale (LC_NUMERIC, locale_base); gchar c[32]; sprintf(c, "#%06x", rgb32 >> 8); 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()); + sp_repr_css_unset_property (css, "-inkscape-font-specification"); if (remove) { sp_repr_css_set_property (css, "display","none"); } - 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", css_str.c_str()); rtspan->setAttribute("transform", nullptr); sp_repr_css_attr_unref (css); - if (!elemref) { - rtext->addChild(rtspan, nullptr); - Inkscape::GC::release(rtspan); - } length = Inkscape::Util::Quantity::convert(length, display_unit.c_str(), unit.get_abbreviation()); if (local_locale) { setlocale (LC_NUMERIC, ""); @@ -458,11 +488,12 @@ LPEMeasureSegments::createTextLabel(Geom::Point pos, size_t counter, double leng } gchar length_str[64]; bool x100 = false; + // active for 1.1 if (smallx100 && length < 1 ) { length *=100; x100 = true; g_snprintf(length_str, 64, "%.*f", (int)precision - 2, length); - } else { + } else { g_snprintf(length_str, 64, "%.*f", (int)precision, length); } setlocale (LC_NUMERIC, locale_base); @@ -471,41 +502,33 @@ LPEMeasureSegments::createTextLabel(Geom::Point pos, size_t counter, double leng g_free(format_str); size_t s = label_value.find(Glib::ustring("{measure}"),0); if(s < label_value.length()) { - label_value.replace(s,s+9,length_str); + label_value.replace(s, 9, length_str); } s = label_value.find(Glib::ustring("{unit}"),0); if(s < label_value.length()) { if (x100) { - label_value.replace(s,s+6,""); + label_value.replace(s, 6, ""); } else { - label_value.replace(s,s+6,unit.get_abbreviation()); + label_value.replace(s, 6, unit.get_abbreviation()); } } + if (showindex) { label_value = Glib::ustring("[") + Glib::ustring::format(counter) + Glib::ustring("] ") + label_value; } - if ( !valid ) { + if (!valid) { label_value = Glib::ustring(_("Non Uniform Scale")); } - Inkscape::XML::Node *rstring = nullptr; - if (!elemref) { - rstring = xml_doc->createTextNode(label_value.c_str()); - rtspan->addChild(rstring, nullptr); - Inkscape::GC::release(rstring); - } else { - rstring = rtspan->firstChild(); - rstring->setContent(label_value.c_str()); - } - if (!elemref) { - elemref = document->getRoot()->appendChildRepr(rtext); - Inkscape::GC::release(rtext); - } - Geom::OptRect bounds = SP_ITEM(elemref)->bounds(SPItem::GEOMETRIC_BBOX); + rstring->setContent(label_value.c_str()); + // this boring hack is to update the text with document scale inituialy loaded without root transform + Geom::OptRect bounds = SP_ITEM(elemref)->geometricBounds(); if (bounds) { - anotation_width = bounds->width() * 1.15; + anotation_width = bounds->width(); + sp_repr_set_svg_double(rtext, "x", pos[Geom::X] - (anotation_width / 2.0)); rtspan->setAttribute("style", nullptr); } + gchar * transform; if (rotate_anotation) { Geom::Affine affine = Geom::Affine(Geom::Translate(pos).inverse()); @@ -549,7 +572,7 @@ LPEMeasureSegments::createLine(Geom::Point start,Geom::Point end, Glib::ustring } Geom::PathVector line_pathv; - double k = (Geom::distance(start,end)/2.0) - (anotation_width/10.0) - (anotation_width/2.0); + double k = (Geom::distance(start,end)/2.0) - (anotation_width/1.7); if (main && std::abs(text_top_bottom) < fontsize/1.5 && hide_back && @@ -583,13 +606,13 @@ LPEMeasureSegments::createLine(Geom::Point start,Geom::Point end, Glib::ustring Glib::ustring classlinedim = itemid; classlinedim += " "; classlinedim += lpobjid; - classlinedim += " measure-DIM-lines measure-lines"; + classlinedim += " measure-DIM-line measure-line"; line->setAttribute("class", classlinedim.c_str()); } else { Glib::ustring classlinehelper = itemid; classlinehelper += " "; classlinehelper += lpobjid; - classlinehelper += " measure-helper-lines measure-lines"; + classlinehelper += " measure-helper-line measure-line"; line->setAttribute("class", classlinehelper.c_str()); } gchar * line_str = sp_svg_write_path( line_pathv ); @@ -659,15 +682,12 @@ LPEMeasureSegments::doOnApply(SPLPEItem const* lpeitem) Inkscape::XML::Node *root = 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 == nullptr) { // Style element found but does not contain text node! std::cerr << "StyleDialog::_getStyleTextNode(): No text node!" << std::endl; @@ -688,21 +708,17 @@ LPEMeasureSegments::doOnApply(SPLPEItem const* lpeitem) styleNode->appendChild(textNode); Inkscape::GC::release(textNode); } + // To fix old meassuring files pre 1.0 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{\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}"); + if (styleContent.find(".measure-arrow\n{\n") == std::string::npos) { + styleContent = styleContent + Glib::ustring("\n.measure-arrow") + Glib::ustring("\n{\n}"); + styleContent = styleContent + Glib::ustring("\n.measure-label") + Glib::ustring("\n{\n\n}"); + styleContent = styleContent + Glib::ustring("\n.measure-line") + Glib::ustring("\n{\n}"); textNode->setContent(styleContent.c_str()); } DocumentUndo::setUndoSensitive(document, saved); } -Geom::PathVector -LPEMeasureSegments::doEffect_path (Geom::PathVector const & path_in) { - return path_in; -} - bool LPEMeasureSegments::isWhitelist (size_t i, std::string listsegments, bool whitelist) { @@ -750,7 +766,7 @@ transformNodes(std::vector< Point > nodes, Geom::Affine transform) } std::vector< Point > -getNodes(SPItem * item, Geom::Affine transform, bool onbbox, bool centers, bool bboxonly) +getNodes(SPItem * item, Geom::Affine transform, bool onbbox, bool centers, bool bboxonly, double angle_projection) { std::vector< Point > current_nodes; SPShape * shape = dynamic_cast<SPShape *> (item); @@ -758,14 +774,15 @@ getNodes(SPItem * item, Geom::Affine transform, bool onbbox, bool centers, bool SPGroup * group = dynamic_cast<SPGroup *> (item); SPFlowtext * flowtext = dynamic_cast<SPFlowtext *> (item); //TODO handle clones/use + if (group) { std::vector<SPItem*> const item_list = sp_item_group_item_list(group); for (auto sub_item : item_list) { - std::vector< Point > nodes = transformNodes(getNodes(sub_item, sub_item->transform, onbbox, centers, bboxonly), transform); + std::vector< Point > nodes = transformNodes(getNodes(sub_item, sub_item->transform, onbbox, centers, bboxonly, angle_projection), transform); current_nodes.insert(current_nodes.end(), nodes.begin(), nodes.end()); } } else if (shape && !bboxonly) { - SPCurve * c = shape->getCurve(); + SPCurve * c = shape->getCurveForEdit(); current_nodes = transformNodes(c->get_pathvector().nodes(), transform); c->unref(); } else if ((text || flowtext) && !bboxonly) { @@ -799,9 +816,16 @@ getNodes(SPItem * item, Geom::Affine transform, bool onbbox, bool centers, bool Geom::OptRect bbox = item->geometricBounds(); if (bbox && onbbox) { current_nodes.push_back((*bbox).corner(0) * transform); - current_nodes.push_back((*bbox).corner(1) * transform); current_nodes.push_back((*bbox).corner(2) * transform); - current_nodes.push_back((*bbox).corner(3) * transform); + if (!Geom::are_near(angle_projection, 0.0) && + !Geom::are_near(angle_projection, 90.0) && + !Geom::are_near(angle_projection, 180.0) && + !Geom::are_near(angle_projection, 360.0)) + { + current_nodes.push_back((*bbox).corner(1) * transform); + current_nodes.push_back((*bbox).corner(3) * transform); + } + } if (bbox && centers) { current_nodes.push_back((*bbox).midpoint() * transform); @@ -810,9 +834,6 @@ getNodes(SPItem * item, Geom::Affine transform, bool onbbox, bool centers, bool return current_nodes; } -bool sortPoints (Geom::Point a,Geom::Point b) { - return (a[Geom::Y] < b[Geom::Y]); -} void LPEMeasureSegments::doBeforeEffect (SPLPEItem const* lpeitem) @@ -833,7 +854,6 @@ LPEMeasureSegments::doBeforeEffect (SPLPEItem const* lpeitem) std::vector< Point > nodes; if (active_projection) { Geom::OptRect bbox = sp_lpe_item->geometricBounds(); - Geom::Point pojpoint = Geom::Point(); if (bbox) { Geom::Point mid = bbox->midpoint(); double angle = Geom::rad_from_deg(angle_projection); @@ -841,17 +861,8 @@ LPEMeasureSegments::doBeforeEffect (SPLPEItem const* lpeitem) transform *= Geom::Translate(mid).inverse(); transform *= Geom::Rotate(angle).inverse(); transform *= Geom::Translate(mid); - std::vector< Point > current_nodes = getNodes(splpeitem, transform, onbbox, centers, bboxonly); + std::vector< Point > current_nodes = getNodes(splpeitem, transform, onbbox, centers, bboxonly, angle_projection); nodes.insert(nodes.end(),current_nodes.begin(), current_nodes.end()); - std::vector<Point> result; - Geom::Point pojpoint = Geom::Point(); - double maxdistance = -std::numeric_limits<double>::max(); - for (auto & node : nodes) { - Geom::Point point = node; - if (point[Geom::X] > maxdistance) { - maxdistance = point[Geom::X]; - } - } for (auto & iter : linked_items._vector) { SPObject *obj; if (iter->ref.isAttached() && iter->actived && (obj = iter->ref.getObject()) && SP_IS_ITEM(obj)) { @@ -862,27 +873,30 @@ LPEMeasureSegments::doBeforeEffect (SPLPEItem const* lpeitem) transform *= Geom::Translate(-mid); transform *= Geom::Rotate(angle).inverse(); transform *= Geom::Translate(mid); - std::vector< Point > current_nodes = getNodes(item, transform, onbbox, centers, bboxonly); + std::vector< Point > current_nodes = getNodes(item, transform, onbbox, centers, bboxonly, angle_projection); nodes.insert(nodes.end(),current_nodes.begin(), current_nodes.end()); } } } - + double maxdistance = -std::numeric_limits<double>::max(); + std::vector<double> result; for (auto & node : nodes) { Geom::Point point = node; - double dproj = Inkscape::Util::Quantity::convert(distance_projection, display_unit.c_str(), unit.get_abbreviation()); - Geom::Coord xpos = maxdistance + dproj; - result.emplace_back(xpos, point[Geom::Y]); + if (point[Geom::X] > maxdistance) { + maxdistance = point[Geom::X]; + } + result.push_back(point[Geom::Y]); } - std::sort (result.begin(), result.end(), sortPoints); - result.erase( unique(result.begin(), result.end() ), result.end() ); + double dproj = Inkscape::Util::Quantity::convert(distance_projection, display_unit.c_str(), unit.get_abbreviation()); + Geom::Coord xpos = maxdistance + dproj; + std::sort (result.begin(), result.end()); Geom::Path path; - Geom::Point prevpoint(0,0); + Geom::Point prevpoint(Geom::infinity(),Geom::infinity()); size_t counter = 0; bool started = false; Geom::Point point = Geom::Point(); for (auto & iter : result) { - point = iter; + point = Geom::Point(xpos, iter); if (Geom::are_near(prevpoint, point)){ continue; } @@ -917,15 +931,17 @@ LPEMeasureSegments::doBeforeEffect (SPLPEItem const* lpeitem) colorchanged = true; } rgb32 = color32; - SPCurve * c = nullptr; gchar * fontbutton_str = fontbutton.param_getSVGValue(); Glib::ustring fontdesc_ustring = Glib::ustring(fontbutton_str); Pango::FontDescription fontdesc(fontdesc_ustring); - fontsize = fontdesc.get_size()/(double)Pango::SCALE; - fontsize *= document->getRoot()->c2p.inverse().expansionX(); + double newfontsize = fontdesc.get_size() / (double)Pango::SCALE; g_free(fontbutton_str); - fontsize *= document->getRoot()->c2p.inverse().expansionX(); - c = shape->getCurve(); + bool fontsizechanged = false; + if (newfontsize != fontsize) { + fontsize = Inkscape::Util::Quantity::convert(newfontsize, "pt", display_unit.c_str()); + fontsizechanged = true; + } + SPCurve *c = shape->getCurveForEdit(); Geom::Point prev_stored = Geom::Point(0,0); Geom::Point start_stored = Geom::Point(0,0); Geom::Point end_stored = Geom::Point(0,0); @@ -985,7 +1001,7 @@ LPEMeasureSegments::doBeforeEffect (SPLPEItem const* lpeitem) if (elemref){ SPPath* path = dynamic_cast<SPPath *>(elemref); if (path) { - SPCurve* prevcurve = path->getCurve(); + SPCurve* prevcurve = path->getCurveForEdit(); if (prevcurve) { prev_stored = *prevcurve->first_point(); } @@ -1000,7 +1016,7 @@ LPEMeasureSegments::doBeforeEffect (SPLPEItem const* lpeitem) if (elemref) { SPPath* path = dynamic_cast<SPPath *>(elemref); if (path) { - SPCurve* startcurve = path->getCurve(); + SPCurve* startcurve = path->getCurveForEdit(); if (startcurve) { start_stored = *startcurve->first_point(); } @@ -1015,7 +1031,7 @@ LPEMeasureSegments::doBeforeEffect (SPLPEItem const* lpeitem) if (elemref) { SPPath* path = dynamic_cast<SPPath *>(elemref); if (path) { - SPCurve* endcurve = path->getCurve(); + SPCurve* endcurve = path->getCurveForEdit(); if (endcurve) { end_stored = *endcurve->first_point(); } @@ -1030,7 +1046,7 @@ LPEMeasureSegments::doBeforeEffect (SPLPEItem const* lpeitem) if (elemref) { SPPath* path = dynamic_cast<SPPath *>(elemref); if (path) { - SPCurve* nextcurve = path->getCurve(); + SPCurve* nextcurve = path->getCurveForEdit(); if (nextcurve) { next_stored = *nextcurve->first_point(); } @@ -1072,7 +1088,8 @@ LPEMeasureSegments::doBeforeEffect (SPLPEItem const* lpeitem) if (((Geom::are_near(prev, prev_stored, 0.01) && Geom::are_near(next, next_stored, 0.01)) || fix_overlaps_degree == 180) && Geom::are_near(start, start_stored, 0.01) && Geom::are_near(end, end_stored, 0.01) && - !this->refresh_widgets && !colorchanged) { + !this->refresh_widgets && !colorchanged && !fontsizechanged && !is_load && anotation_width) + { continue; } Geom::Point hstart = start; @@ -1165,7 +1182,7 @@ LPEMeasureSegments::doBeforeEffect (SPLPEItem const* lpeitem) previous_fix_overlaps = false; } length = Geom::distance(start,end) * scale; - Geom::Point pos = Geom::middle_point(hstart,hend); + Geom::Point pos = Geom::middle_point(hstart, hend); if (!hide_arrows) { if (arrows_outside) { createArrowMarker(Glib::ustring("ArrowDINout-start")); @@ -1217,7 +1234,7 @@ LPEMeasureSegments::doBeforeEffect (SPLPEItem const* lpeitem) hstart = hstart + Point::polar(angle, arrow_gap); hend = hend - Point::polar(angle, arrow_gap ); } - if ((Geom::distance(hstart,hend)/2.0) > (anotation_width/1.9) + arrow_gap) { + if ((Geom::distance(hstart, hend) / 2.0) > (anotation_width / 1.9) + arrow_gap) { createLine(hstart, hend, Glib::ustring("infoline-"), counter, true, false, true); } else { createLine(hstart, hend, Glib::ustring("infoline-"), counter, true, true, true); diff --git a/src/live_effects/lpe-measure-segments.h b/src/live_effects/lpe-measure-segments.h index 105bdb36f..ea7c8e7a8 100644 --- a/src/live_effects/lpe-measure-segments.h +++ b/src/live_effects/lpe-measure-segments.h @@ -39,7 +39,7 @@ public: void doOnApply(SPLPEItem const* lpeitem) override; void doBeforeEffect (SPLPEItem const* lpeitem) override; void doOnRemove(SPLPEItem const* /*lpeitem*/) override; - Geom::PathVector doEffect_path (Geom::PathVector const & path_in) override; + void doEffect (SPCurve * curve) override {}; void doOnVisibilityToggled(SPLPEItem const* /*lpeitem*/) override; Gtk::Widget * newWidget() override; void createLine(Geom::Point start,Geom::Point end, Glib::ustring name, size_t counter, bool main, bool remove, bool arrows = false); @@ -83,7 +83,6 @@ private: BoolParam avoid_overlapping; MessageParam helpdata; Glib::ustring display_unit; - bool locked_pagenumber; double fontsize; double anotation_width; double previous_size; diff --git a/src/ui/tool/curve-drag-point.cpp b/src/ui/tool/curve-drag-point.cpp index 931726275..4e878d07e 100644 --- a/src/ui/tool/curve-drag-point.cpp +++ b/src/ui/tool/curve-drag-point.cpp @@ -69,6 +69,7 @@ bool CurveDragPoint::grabbed(GdkEventMotion */*event*/) void CurveDragPoint::dragged(Geom::Point &new_pos, GdkEventMotion *event) { + if (!first || !first.next()) return; NodeList::iterator second = first.next(); // special cancel handling - retract handles when if the segment was degenerate |
