diff options
| author | Markus Engel <markus.engel@tum.de> | 2013-08-30 21:35:42 +0000 |
|---|---|---|
| committer | Markus Engel <markus.engel@tum.de> | 2013-08-30 21:35:42 +0000 |
| commit | 8756c49b91fd4262b6770ac3b2f229209bdae96b (patch) | |
| tree | 67ac89d7bc7c69e04e811324734dccafc07f33c9 /src/lpe-tool-context.cpp | |
| parent | Merged from trunk (r12465). (diff) | |
| parent | Merge emf/wmf work (diff) | |
| download | inkscape-8756c49b91fd4262b6770ac3b2f229209bdae96b.tar.gz inkscape-8756c49b91fd4262b6770ac3b2f229209bdae96b.zip | |
Merged from trunk (r12488).
(bzr r11608.1.120)
Diffstat (limited to 'src/lpe-tool-context.cpp')
| -rw-r--r-- | src/lpe-tool-context.cpp | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/src/lpe-tool-context.cpp b/src/lpe-tool-context.cpp index f0846b306..63707c1c5 100644 --- a/src/lpe-tool-context.cpp +++ b/src/lpe-tool-context.cpp @@ -37,10 +37,12 @@ #include "display/canvas-text.h" #include "message-stack.h" #include "sp-path.h" -#include "helper/units.h" +#include "util/units.h" #include "lpe-tool-context.h" +using Inkscape::Util::unit_table; + void sp_lpetool_context_selection_changed(Inkscape::Selection *selection, gpointer data); const int num_subtools = 8; @@ -414,13 +416,16 @@ lpetool_create_measuring_items(SPLPEToolContext *lc, Inkscape::Selection *select if (!show) sp_canvas_item_hide(SP_CANVAS_ITEM(canvas_text)); - SPUnitId unitid = static_cast<SPUnitId>(prefs->getInt("/tools/lpetool/unitid", SP_UNIT_PX)); - SPUnit unit = sp_unit_get_by_id(unitid); + Inkscape::Util::Unit unit; + if (prefs->getString("/tools/lpetool/unit").compare("")) { + unit = unit_table.getUnit(prefs->getString("/tools/lpetool/unit")); + } else { + unit = unit_table.getUnit("px"); + } lengthval = Geom::length(pwd2); - gboolean success; - success = sp_convert_distance(&lengthval, &sp_unit_get_by_id(SP_UNIT_PX), &unit); - arc_length = g_strdup_printf("%.2f %s", lengthval, success ? sp_unit_get_abbreviation(&unit) : "px"); + lengthval = Inkscape::Util::Quantity::convert(lengthval, "px", unit); + arc_length = g_strdup_printf("%.2f %s", lengthval, unit.abbr.c_str()); sp_canvastext_set_text (canvas_text, arc_length); set_pos_and_anchor(canvas_text, pwd2, 0.5, 10); // TODO: must we free arc_length? @@ -450,12 +455,15 @@ lpetool_update_measuring_items(SPLPEToolContext *lc) SPPath *path = i->first; SPCurve *curve = SP_SHAPE(path)->getCurve(); Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = Geom::paths_to_pw(curve->get_pathvector()); - SPUnitId unitid = static_cast<SPUnitId>(prefs->getInt("/tools/lpetool/unitid", SP_UNIT_PX)); - SPUnit unit = sp_unit_get_by_id(unitid); + Inkscape::Util::Unit unit; + if (prefs->getString("/tools/lpetool/unit").compare("")) { + unit = unit_table.getUnit(prefs->getString("/tools/lpetool/unit")); + } else { + unit = unit_table.getUnit("px"); + } double lengthval = Geom::length(pwd2); - gboolean success; - success = sp_convert_distance(&lengthval, &sp_unit_get_by_id(SP_UNIT_PX), &unit); - gchar *arc_length = g_strdup_printf("%.2f %s", lengthval, success ? sp_unit_get_abbreviation(&unit) : "px"); + lengthval = Inkscape::Util::Quantity::convert(lengthval, "px", unit); + gchar *arc_length = g_strdup_printf("%.2f %s", lengthval, unit.abbr.c_str()); sp_canvastext_set_text (SP_CANVASTEXT(i->second), arc_length); set_pos_and_anchor(SP_CANVASTEXT(i->second), pwd2, 0.5, 10); // TODO: must we free arc_length? |
