summaryrefslogtreecommitdiffstats
path: root/src/util/units.cpp
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2014-11-24 21:38:54 +0000
committerJabiertxof <jtx@jtx.marker.es>2014-11-24 21:38:54 +0000
commit5497de6e39d4fc31a6824eb9f9e638635de4521b (patch)
treed1e5d867d3b9f618846bdfe65e147b23df8ed58a /src/util/units.cpp
parentFixing bend from clipboard to trunk 0.92 (diff)
parentFix a bug in pen/cil modes triangle in/out (diff)
downloadinkscape-5497de6e39d4fc31a6824eb9f9e638635de4521b.tar.gz
inkscape-5497de6e39d4fc31a6824eb9f9e638635de4521b.zip
update to trunk
(bzr r12588.1.37)
Diffstat (limited to 'src/util/units.cpp')
-rw-r--r--src/util/units.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/util/units.cpp b/src/util/units.cpp
index 3d635e2d2..8ad3560dd 100644
--- a/src/util/units.cpp
+++ b/src/util/units.cpp
@@ -21,6 +21,8 @@
#include <glibmm/fileutils.h>
#include <glibmm/markup.h>
+#include <2geom/coord.h>
+
#include "util/units.h"
#include "path-prefix.h"
#include "streq.h"
@@ -279,6 +281,28 @@ Unit const *UnitTable::getUnit(SVGLength::Unit u) const
return &_empty_unit;
}
+Unit const *UnitTable::findUnit(double factor, UnitType type) const
+{
+ const double eps = factor * 0.01; // allow for 1% deviation
+
+ UnitCodeMap::const_iterator cit = _unit_map.begin();
+ while (cit != _unit_map.end()) {
+ if (cit->second->type == type) {
+ if (Geom::are_near(cit->second->factor, factor, eps)) {
+ // unit found!
+ break;
+ }
+ }
+ ++cit;
+ }
+
+ if (cit != _unit_map.end()) {
+ return cit->second;
+ } else {
+ return getUnit(_primary_unit[type]);
+ }
+}
+
Quantity UnitTable::parseQuantity(Glib::ustring const &q) const
{
Glib::MatchInfo match_info;