diff options
| author | Matthew Petroff <matthew@mpetroff.net> | 2013-07-17 05:13:49 +0000 |
|---|---|---|
| committer | Matthew Petroff <matthew@mpetroff.net> | 2013-07-17 05:13:49 +0000 |
| commit | dd59aa3bb2cab030296a4622e5166f0e3f8d5445 (patch) | |
| tree | a86612c94d3ddce3edf696ea17fefb58b0accccf /src/util/units.h | |
| parent | Temporary fixes/kludges. (diff) | |
| parent | Shape calculations. re-introduce grid of a smaller size. (http://article.gman... (diff) | |
| download | inkscape-dd59aa3bb2cab030296a4622e5166f0e3f8d5445.tar.gz inkscape-dd59aa3bb2cab030296a4622e5166f0e3f8d5445.zip | |
Merge from trunk.
(bzr r12380.1.17)
Diffstat (limited to 'src/util/units.h')
| -rw-r--r-- | src/util/units.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/util/units.h b/src/util/units.h index f275d7c3a..ead49d3b4 100644 --- a/src/util/units.h +++ b/src/util/units.h @@ -47,6 +47,26 @@ const char DEG[] = "°"; class Unit { public: + Unit(); + Unit(UnitType type, + double factor, + Glib::ustring const &name, + Glib::ustring const &name_plural, + Glib::ustring const &abbr, + Glib::ustring const &description); + + void clear(); + + bool isAbsolute() const { return type != UNIT_TYPE_DIMENSIONLESS; } + + /** + * Returns the suggested precision to use for displaying numbers + * of this unit. + */ + int defaultDigits() const; + + UnitType type; + double factor; Glib::ustring name; Glib::ustring name_plural; Glib::ustring abbr; @@ -70,25 +90,50 @@ class Unit { class UnitTable { public: + /** + * Initializes the unit tables and identifies the primary unit types. + * + * The primary unit's conversion factor is required to be 1.00 + */ UnitTable(); virtual ~UnitTable(); typedef std::map<Glib::ustring, Unit*> UnitMap; + /** Add a new unit to the table */ void addUnit(Unit const& u, bool primary); + + /** Retrieve a given unit based on its string identifier */ Unit getUnit(Glib::ustring const& name) const; + + /** Remove a unit definition from the given unit type table */ bool deleteUnit(Unit const& u); + + /** Returns true if the given string 'name' is a valid unit in the table */ bool hasUnit(Glib::ustring const &name) const; + /** Provides an iteratable list of items in the given unit table */ UnitTable::UnitMap units(UnitType type) const; + /** Returns the default unit abbr for the given type */ Glib::ustring primary(UnitType type) const; double getScale() const; + void setScale(); bool load(Glib::ustring const &filename); + + /** Loads units from a text file. + * + * loadText loads and merges the contents of the given file into the UnitTable, + * possibly overwriting existing unit definitions. + * + * @param filename file to be loaded + */ bool loadText(Glib::ustring const &filename); + + /** Saves the current UnitTable to the given file. */ bool save(Glib::ustring const &filename); protected: @@ -119,3 +164,13 @@ public: } // namespace Inkscape #endif // define INKSCAPE_UTIL_UNITS_H +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : |
