diff options
| author | su_v <suv-sf@users.sourceforge.net> | 2013-08-29 21:06:10 +0000 |
|---|---|---|
| committer | ~suv <suv-sf@users.sourceforge.net> | 2013-08-29 21:06:10 +0000 |
| commit | 4d331e73a76dce7d703716093923ca01b3cc5936 (patch) | |
| tree | b444657ba269b25f60684e66858a138b74fe240d /src/measure-context.cpp | |
| parent | Fix compiler warnings (diff) | |
| parent | Updating outdated test. Fixes bug #1202271. (diff) | |
| download | inkscape-4d331e73a76dce7d703716093923ca01b3cc5936.tar.gz inkscape-4d331e73a76dce7d703716093923ca01b3cc5936.zip | |
merge from trunk (r12487)
(bzr r11668.1.75)
Diffstat (limited to 'src/measure-context.cpp')
| -rw-r--r-- | src/measure-context.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/measure-context.cpp b/src/measure-context.cpp index dc23cf5c6..37e87d3d9 100644 --- a/src/measure-context.cpp +++ b/src/measure-context.cpp @@ -13,7 +13,7 @@ #include <gdk/gdkkeysyms.h> #include <boost/none_t.hpp> -#include "helper/units.h" +#include "util/units.h" #include "macros.h" #include "display/curve.h" #include "sp-shape.h" @@ -46,6 +46,7 @@ using Inkscape::ControlManager; using Inkscape::CTLINE_SECONDARY; +using Inkscape::Util::unit_table; static void sp_measure_context_setup(SPEventContext *ec); static void sp_measure_context_finish(SPEventContext *ec); @@ -494,7 +495,6 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv } curve->transform(item->i2doc_affine()); - Geom::PathVector pathv = curve->get_pathvector(); calculate_intersections(desktop, item, lineseg, curve, intersections); @@ -515,8 +515,10 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv std::sort(intersections.begin(), intersections.end(), GeomPointSortPredicate); } - SPUnitId unitid = static_cast<SPUnitId>(prefs->getInt("/tools/measure/unitid", SP_UNIT_PX)); - SPUnit unit = sp_unit_get_by_id(unitid); + Glib::ustring unit_name = prefs->getString("/tools/measure/unit"); + if (!unit_name.compare("")) { + unit_name = "px"; + } double fontsize = prefs->getInt("/tools/measure/fontsize"); @@ -527,7 +529,7 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv for (size_t idx = 1; idx < intersections.size(); ++idx) { LabelPlacement placement; placement.lengthVal = (intersections[idx] - intersections[idx - 1]).length(); - sp_convert_distance(&placement.lengthVal, &sp_unit_get_by_id(SP_UNIT_PX), &unit); + placement.lengthVal = Inkscape::Util::Quantity::convert(placement.lengthVal, "px", unit_name); placement.offset = DIMENSION_OFFSET; placement.start = desktop->doc2dt( (intersections[idx - 1] + intersections[idx]) / 2 ); placement.end = placement.start - (normal * placement.offset); @@ -543,7 +545,7 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv LabelPlacement &place = *it; // TODO cleanup memory, Glib::ustring, etc.: - gchar *measure_str = g_strdup_printf("%.2f %s", place.lengthVal, unit.abbr); + gchar *measure_str = g_strdup_printf("%.2f %s", place.lengthVal, unit_name.c_str()); SPCanvasText *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, place.end, @@ -584,10 +586,10 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv { double totallengthval = (end_point - start_point).length(); - sp_convert_distance(&totallengthval, &sp_unit_get_by_id(SP_UNIT_PX), &unit); + totallengthval = Inkscape::Util::Quantity::convert(totallengthval, "px", unit_name); // TODO cleanup memory, Glib::ustring, etc.: - gchar *totallength_str = g_strdup_printf("%.2f %s", totallengthval, unit.abbr); + gchar *totallength_str = g_strdup_printf("%.2f %s", totallengthval, unit_name.c_str()); SPCanvasText *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, end_point + desktop->w2d(Geom::Point(3*fontsize, -fontsize)), @@ -605,10 +607,10 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv if (intersections.size() > 2) { double totallengthval = (intersections[intersections.size()-1] - intersections[0]).length(); - sp_convert_distance(&totallengthval, &sp_unit_get_by_id(SP_UNIT_PX), &unit); + totallengthval = Inkscape::Util::Quantity::convert(totallengthval, "px", unit_name); // TODO cleanup memory, Glib::ustring, etc.: - gchar *total_str = g_strdup_printf("%.2f %s", totallengthval, unit.abbr); + gchar *total_str = g_strdup_printf("%.2f %s", totallengthval, unit_name.c_str()); SPCanvasText *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, desktop->doc2dt((intersections[0] + intersections[intersections.size()-1])/2) + normal * 60, |
