diff options
| author | Matthew Petroff <matthew@mpetroff.net> | 2013-07-18 20:40:36 +0000 |
|---|---|---|
| committer | Matthew Petroff <matthew@mpetroff.net> | 2013-07-18 20:40:36 +0000 |
| commit | 51ffb1d56821be424fc50c91e486d6143976ba30 (patch) | |
| tree | f7415eda4b030e6087fa36b0440ee07106ceacb4 /src/util/units.cpp | |
| parent | Added more convienient unit conversion functions. (diff) | |
| download | inkscape-51ffb1d56821be424fc50c91e486d6143976ba30.tar.gz inkscape-51ffb1d56821be424fc50c91e486d6143976ba30.zip | |
Added more more convientent unit functions.
(bzr r12380.1.27)
Diffstat (limited to 'src/util/units.cpp')
| -rw-r--r-- | src/util/units.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/util/units.cpp b/src/util/units.cpp index ed8fbfa34..ffbd74fdd 100644 --- a/src/util/units.cpp +++ b/src/util/units.cpp @@ -140,6 +140,12 @@ bool Unit::compatibleWith(const Unit *u) const { // Different, incompatible types return false; } +bool Unit::compatibleWith(const Glib::ustring u) const +{ + static UnitTable unit_table; + Unit compatible_unit = unit_table.getUnit(u); + return compatibleWith(&compatible_unit); +} /** Check if units are equal. */ bool operator== (const Unit &u1, const Unit &u2) { @@ -455,11 +461,22 @@ Quantity::Quantity(double q, const Unit *u) { unit = u; quantity = q; } +Quantity::Quantity(double q, const Glib::ustring u) { + UnitTable unit_table; + unit = new Unit(unit_table.getUnit(u)); + quantity = q; +} /** Checks if a quantity is compatible with the specified unit. */ bool Quantity::compatibleWith(const Unit *u) const { return unit->compatibleWith(u); } +bool Quantity::compatibleWith(const Glib::ustring u) const +{ + static UnitTable unit_table; + Unit other_unit = unit_table.getUnit(u); + return compatibleWith(&other_unit); +} /** Return the quantity's value in the specified unit. */ double Quantity::value(const Unit *u) const { |
