Inkscape
Vector Graphics Editor
|
#include <units.h>
Public Types | |
typedef std::unordered_map< Glib::ustring, UnitMetric > | MetricMap |
typedef std::unordered_map< Glib::ustring, Unit > | UnitMap |
typedef std::unordered_map< unsigned, Unit * > | UnitCodeMap |
Public Member Functions | |
UnitTable () | |
Initializes the unit tables and identifies the primary unit types. | |
UnitTable (std::string const &filename) | |
virtual | ~UnitTable () |
void | addMetric (UnitMetric const &u, bool primary) |
Unit metrics. | |
UnitMetric const * | getUnitMetric (Glib::ustring const &name) const |
void | addUnit (Unit const &u, bool primary) |
Add a new unit to the table. | |
Unit const * | getUnit (Glib::ustring const &name) const |
Retrieve a given unit based on its string identifier. | |
Unit const * | getUnit (char const *name) const |
Unit const * | findUnit (double factor, UnitType type) const |
Try to find a unit based on its conversion factor to the primary. | |
Unit const * | getUnit (SVGLength::Unit u) const |
Retrieve a given unit based on its SVGLength unit. | |
Quantity | parseQuantity (Glib::ustring const &q) const |
Retrieve a quantity based on its string identifier. | |
bool | hasUnit (Glib::ustring const &name) const |
Remove a unit definition from the given unit type table * / DISABLED, unsafe with the current passing around pointers to Unit objects in this table. | |
UnitMap | units (UnitType type) const |
Provides an iterable list of items in the given unit table. | |
Glib::ustring | primary (UnitType type) const |
Returns the default unit abbr for the given type. | |
double | getScale () const |
void | setScale () |
bool | load (std::string const &filename) |
Load units from an XML file. | |
Static Public Member Functions | |
static UnitTable & | get () |
Protected Attributes | |
MetricMap | _metric_map |
UnitCodeMap | _unit_map |
Glib::ustring | _primary_unit [UNIT_TYPE_QTY] |
Glib::ustring | _default_metric |
double | _linear_scale |
Static Protected Attributes | |
static Unit | _empty_unit |
Private Member Functions | |
UnitTable (UnitTable const &t) | |
UnitTable | operator= (UnitTable const &t) |
typedef std::unordered_map<Glib::ustring, UnitMetric> Inkscape::Util::UnitTable::MetricMap |
typedef std::unordered_map<unsigned, Unit*> Inkscape::Util::UnitTable::UnitCodeMap |
typedef std::unordered_map<Glib::ustring, Unit> Inkscape::Util::UnitTable::UnitMap |
Inkscape::Util::UnitTable::UnitTable | ( | ) |
Inkscape::Util::UnitTable::UnitTable | ( | std::string const & | filename | ) |
|
virtual |
|
private |
void Inkscape::Util::UnitTable::addMetric | ( | UnitMetric const & | u, |
bool | primary | ||
) |
Unit metrics.
Definition at line 279 of file units.cpp.
References _default_metric, _metric_map, Inkscape::Util::UnitMetric::name, and primary().
void Inkscape::Util::UnitTable::addUnit | ( | Unit const & | u, |
bool | primary | ||
) |
Add a new unit to the table.
Definition at line 299 of file units.cpp.
References _primary_unit, _unit_map, Inkscape::Util::Unit::abbr, primary(), and Inkscape::Util::Unit::type.
Referenced by Inkscape::UI::Widget::UnitMenu::addUnit().
Try to find a unit based on its conversion factor to the primary.
Definition at line 333 of file units.cpp.
References _primary_unit, _unit_map, Geom::are_near(), and getUnit().
|
static |
Definition at line 441 of file units.cpp.
Referenced by Inkscape::UI::Widget::UnitTracker::_setActive(), Inkscape::UI::Toolbar::PageToolbar::_unit_to_size(), Inkscape::UI::Widget::UnitMenu::addUnit(), Inkscape::Util::Quantity::compatibleWith(), Inkscape::Util::Unit::compatibleWith(), Inkscape::Util::Quantity::convert(), Inkscape::Util::Unit::convert(), Inkscape::Util::Quantity::convert(), Inkscape::Util::Quantity::convert(), Inkscape::Util::Unit::convert(), Inkscape::Util::Quantity::convert(), Inkscape::UI::Widget::Ruler::create_context_menu(), Inkscape::UI::Tools::LpeTool::create_measuring_items(), Inkscape::PaperSize::findPaperSize(), Inkscape::Extension::Internal::TemplateBase::get_template_unit(), Inkscape::UI::Widget::UnitMenu::getConversion(), Inkscape::PaperSize::getPageSizes(), Inkscape::PageManager::getSizeLabel(), Inkscape::UI::Widget::UnitMenu::getUnit(), Inkscape::Util::Unit::getUnitMetric(), Inkscape::Preferences::Entry::isConvertibleTo(), Inkscape::Preferences::Entry::isValidDouble(), Inkscape::UI::Widget::SelectedStyle::make_popup_units(), Inkscape::Extension::Internal::TemplateBase::match_template_size(), Inkscape::UI::Widget::ScalarUnit::on_unit_changed(), Inkscape::UI::Toolbar::PaintbucketToolbar::PaintbucketToolbar(), Inkscape::PaperSize::PaperSize(), Inkscape::LivePathEffect::UnitParam::param_set_value(), Inkscape::Extension::Internal::TemplateBase::resize_to_template(), Inkscape::Util::ExpressionEvaluator::resolveUnit(), Inkscape::UI::Tools::CalligraphicTool::root_handler(), Inkscape::UI::Toolbar::SelectToolbar::SelectToolbar(), Inkscape::UI::Tools::DynamicBase::set(), Inkscape::UI::Widget::UnitTracker::setActiveUnitByAbbr(), Inkscape::UI::Widget::UnitMenu::setUnitType(), sp_parse_document_units(), Inkscape::Util::Quantity::string(), Inkscape::UI::Widget::StrokeStyle::StrokeStyle(), Inkscape::UI::Toolbar::TextToolbar::TextToolbar(), Inkscape::LivePathEffect::UnitParam::UnitParam(), Inkscape::UI::Widget::UnitTracker::UnitTracker(), Inkscape::UI::Tools::LpeTool::update_measuring_items(), Inkscape::UI::Dialog::DocumentProperties::update_widgets(), and Inkscape::Util::Quantity::value().
double Inkscape::Util::UnitTable::getScale | ( | ) | const |
Unit const * Inkscape::Util::UnitTable::getUnit | ( | char const * | name | ) | const |
Definition at line 307 of file units.cpp.
References _empty_unit, and _unit_map.
Unit const * Inkscape::Util::UnitTable::getUnit | ( | Glib::ustring const & | name | ) | const |
Retrieve a given unit based on its string identifier.
Definition at line 316 of file units.cpp.
References getUnit().
Referenced by Inkscape::UI::Toolbar::PageToolbar::_unit_to_size(), Inkscape::Util::Quantity::convert(), Inkscape::PaperSize::findPaperSize(), findUnit(), Inkscape::PageManager::getSizeLabel(), getUnit(), Inkscape::Preferences::Entry::isConvertibleTo(), Inkscape::Extension::Internal::TemplateBase::match_template_size(), Inkscape::UI::Toolbar::PaintbucketToolbar::PaintbucketToolbar(), Inkscape::PaperSize::PaperSize(), Inkscape::Extension::Internal::TemplateBase::resize_to_template(), Inkscape::UI::Tools::CalligraphicTool::root_handler(), Inkscape::UI::Tools::DynamicBase::set(), Inkscape::UI::Widget::UnitTracker::setActiveUnitByAbbr(), and Inkscape::UI::Dialog::DocumentProperties::update_widgets().
Unit const * Inkscape::Util::UnitTable::getUnit | ( | SVGLength::Unit | u | ) | const |
Retrieve a given unit based on its SVGLength unit.
Definition at line 320 of file units.cpp.
References _empty_unit, _unit_map, and SVGLength::LAST_UNIT.
UnitMetric const * Inkscape::Util::UnitTable::getUnitMetric | ( | Glib::ustring const & | name | ) | const |
Definition at line 287 of file units.cpp.
References _default_metric, _metric_map, getUnitMetric(), and name.
Referenced by Inkscape::Util::Unit::getUnitMetric(), and getUnitMetric().
bool Inkscape::Util::UnitTable::hasUnit | ( | Glib::ustring const & | name | ) | const |
Remove a unit definition from the given unit type table * / DISABLED, unsafe with the current passing around pointers to Unit objects in this table.
Returns true if the given string 'name' is a valid unit in the table
Definition at line 400 of file units.cpp.
References _unit_map.
Referenced by Inkscape::Preferences::Entry::isValidDouble().
bool Inkscape::Util::UnitTable::load | ( | std::string const & | filename | ) |
Load units from an XML file.
Loads and merges the contents of the given file into the UnitTable, possibly overwriting existing unit definitions.
filename | file to be loaded |
Definition at line 423 of file units.cpp.
Referenced by UnitTable(), and UnitTable().
Quantity Inkscape::Util::UnitTable::parseQuantity | ( | Glib::ustring const & | q | ) | const |
Glib::ustring Inkscape::Util::UnitTable::primary | ( | UnitType | type | ) | const |
Returns the default unit abbr for the given type.
Definition at line 418 of file units.cpp.
References _primary_unit.
Referenced by addMetric(), and addUnit().
void Inkscape::Util::UnitTable::setScale | ( | ) |
UnitTable::UnitMap Inkscape::Util::UnitTable::units | ( | UnitType | type | ) | const |
Provides an iterable list of items in the given unit table.
Definition at line 406 of file units.cpp.
References _unit_map.
Referenced by Inkscape::UI::Widget::Ruler::create_context_menu(), and Inkscape::UI::Widget::UnitTracker::UnitTracker().
|
protected |
Definition at line 215 of file units.h.
Referenced by addMetric(), and getUnitMetric().
|
staticprotected |
|
protected |
Definition at line 212 of file units.h.
Referenced by addMetric(), and getUnitMetric().
|
protected |
Definition at line 214 of file units.h.
Referenced by addUnit(), findUnit(), and primary().
|
protected |
Definition at line 213 of file units.h.
Referenced by addUnit(), findUnit(), getUnit(), getUnit(), hasUnit(), units(), and ~UnitTable().