Inkscape
Vector Graphics Editor
|
SVG length type. More...
#include <svg-length.h>
Public Types | |
enum | Unit { NONE , PX , PT , PC , MM , CM , INCH , EM , EX , PERCENT , LAST_UNIT = PERCENT } |
Public Member Functions | |
SVGLength () | |
float | operator= (float v) |
bool | operator== (const SVGLength &rhs) const |
bool | operator!= (const SVGLength &rhs) const |
operator bool () const | |
bool | read (char const *str) |
void | readOrUnset (char const *str, Unit u=NONE, float v=0, float c=0) |
bool | readAbsolute (char const *str) |
std::string | getUnit () const |
Returns the unit used as a string. | |
bool | isAbsolute () |
Is this length an absolute value (uses an absolute unit). | |
std::string | write () const |
std::string | toString (const std::string &unit, double doc_scale, std::optional< unsigned int > precision={}, bool add_unit=true) const |
Write out length in user unit, for the user to use. | |
double | toValue (const std::string &out_unit) const |
Caulate the length in a user unit. | |
bool | fromString (const std::string &input, const std::string &unit, std::optional< double > scale={}) |
Read from user input, any non-unitised value is converted internally. | |
void | set (Unit u, float v) |
void | set (Unit u, float v, float c) |
void | unset (Unit u=NONE, float v=0, float c=0) |
void | scale (double scale) |
void | update (double em, double ex, double scale) |
Public Attributes | |
bool | _set |
Unit | unit |
float | value |
float | computed |
SVG length type.
Definition at line 22 of file svg-length.h.
enum SVGLength::Unit |
Enumerator | |
---|---|
NONE | |
PX | |
PT | |
PC | |
MM | |
CM | |
INCH | |
EM | |
EX | |
PERCENT | |
LAST_UNIT |
Definition at line 26 of file svg-length.h.
SVGLength::SVGLength | ( | ) |
Definition at line 142 of file svg-length.cpp.
bool SVGLength::fromString | ( | const std::string & | input, |
const std::string & | default_unit, | ||
std::optional< double > | doc_scale = {} |
||
) |
Read from user input, any non-unitised value is converted internally.
input | - The string input |
default_unit | - The unit used by the display. Set to empty string for xml reading. |
doc_scale | - The scale values with units should apply to make those units correct for this document. |
Definition at line 493 of file svg-length.cpp.
References computed, NONE, PERCENT, read(), scale(), unit, and value.
Referenced by SVGBox::fromString().
std::string SVGLength::getUnit | ( | ) | const |
Returns the unit used as a string.
Definition at line 207 of file svg-length.cpp.
References sp_svg_length_get_css_units(), and unit.
bool SVGLength::isAbsolute | ( | ) |
Is this length an absolute value (uses an absolute unit).
Definition at line 217 of file svg-length.cpp.
References svg_length_absolute_unit(), and unit.
|
inline |
Definition at line 71 of file svg-length.h.
References _set.
|
inline |
Definition at line 67 of file svg-length.h.
|
inline |
|
inline |
bool SVGLength::read | ( | char const * | str | ) |
Definition at line 152 of file svg-length.cpp.
References _set, c, computed, sp_svg_length_read_lff(), unit, and value.
Referenced by fromString(), readOrUnset(), SPFilterPrimitive::resolve_slots(), SPFeBlend::resolve_slots(), SPFeComposite::resolve_slots(), SPFeDisplacementMap::resolve_slots(), SPImage::set(), SPMeshGradient::set(), SPRadialGradient::set(), SPRect::set(), SPRoot::set(), and SPGrid::set().
bool SVGLength::readAbsolute | ( | char const * | str | ) |
Definition at line 177 of file svg-length.cpp.
References _set, c, computed, sp_svg_length_read_lff(), svg_length_absolute_unit(), unit, and value.
Definition at line 633 of file svg-length.cpp.
References c, read(), and unset().
Referenced by TextTagAttributes::readSingleAttribute(), SPFilterPrimitive::set(), SPGenericEllipse::set(), SPFilter::set(), SPLine::set(), SPLinearGradient::set(), SPPattern::set(), SPRect::set(), SPSymbol::set(), SPUse::set(), SPPage::set(), SPTextPath::set(), SPHatchPath::set(), SPHatch::set(), and SPMarker::set().
void SVGLength::scale | ( | double | scale | ) |
Definition at line 557 of file svg-length.cpp.
References computed, scale, and value.
Referenced by fromString(), SPGenericEllipse::set_transform(), and SPRect::set_transform().
void SVGLength::set | ( | SVGLength::Unit | u, |
float | v | ||
) |
Definition at line 507 of file svg-length.cpp.
References _set, CM, computed, Inkscape::Util::Quantity::convert(), EM, EX, INCH, MM, NONE, PC, PERCENT, PT, PX, unit, and value.
Referenced by Inkscape::Filters::Filter::_common_init(), SVGBox::set(), SPRoot::setRootDimensions(), and SPItem::visualBounds().
void SVGLength::set | ( | SVGLength::Unit | u, |
float | v, | ||
float | c | ||
) |
std::string SVGLength::toString | ( | const std::string & | out_unit, |
double | doc_scale, | ||
std::optional< unsigned int > | precision = {} , |
||
bool | add_unit = true |
||
) | const |
Write out length in user unit, for the user to use.
out_unit | - The unit to convert the computed px into |
Definition at line 458 of file svg-length.cpp.
References Inkscape::Util::format_number(), PERCENT, Inkscape::SVGOStringStream::str(), toValue(), unit, value, and write().
Referenced by SPMeshGradient::create_drawing_paintserver(), and SVGBox::toString().
double SVGLength::toValue | ( | const std::string & | out_unit | ) | const |
Caulate the length in a user unit.
out_unit | - The unit to convert the computed px into |
Definition at line 481 of file svg-length.cpp.
References computed, and Inkscape::Util::Quantity::convert().
Referenced by toString().
void SVGLength::unset | ( | SVGLength::Unit | u = NONE , |
float | v = 0 , |
||
float | c = 0 |
||
) |
Definition at line 549 of file svg-length.cpp.
References _set, c, computed, unit, and value.
Referenced by Inkscape::Filters::FilterPrimitive::FilterPrimitive(), readOrUnset(), SPImage::set(), SPMeshGradient::set(), SPRadialGradient::set(), SPRect::set(), SPRoot::set(), SPGenericEllipse::setVisibleRx(), SPRect::setVisibleRx(), SPGenericEllipse::setVisibleRy(), SPFilterPrimitive::SPFilterPrimitive(), SPHatch::SPHatch(), SPImage::SPImage(), SPLine::SPLine(), SPLinearGradient::SPLinearGradient(), SPMeshGradient::SPMeshGradient(), SPRadialGradient::SPRadialGradient(), SPRoot::SPRoot(), SPUse::SPUse(), and SPRoot::unset_x_and_y().
void SVGLength::update | ( | double | em, |
double | ex, | ||
double | scale | ||
) |
Definition at line 563 of file svg-length.cpp.
References computed, EM, EX, PERCENT, scale, unit, and value.
Referenced by SPGenericEllipse::set(), SPRect::set(), SVGBox::update(), SPLinearGradient::update(), SPGenericEllipse::update(), SPLine::update(), SPRadialGradient::update(), SPRect::update(), SPSymbol::update(), and SPItem::visualBounds().
std::string SVGLength::write | ( | ) | const |
Definition at line 447 of file svg-length.cpp.
References sp_svg_length_write_with_units().
Referenced by SPPage::copyFrom(), SPFilterPrimitive::resolve_slots(), Inkscape::XML::Node::setAttributeSvgLength(), SVGBox::toString(), and toString().
bool SVGLength::_set |
Definition at line 41 of file svg-length.h.
Referenced by SPText::_buildLayoutInput(), SPFlowtext::_buildLayoutInput(), Inkscape::Text::Layout::appendText(), SPDimensions::calcDimsFromParentViewport(), Inkscape::Text::Layout::clear(), SPRect::compensateRxRy(), Inkscape::Filters::FilterPrimitive::filter_primitive_area(), Inkscape::Text::Layout::fitToPathAlign(), SPUse::get_xy_offset(), Inkscape::Text::Layout::getTextLengthIncrementDue(), Inkscape::Text::Layout::getTextLengthMultiplierDue(), SPRect::getVisibleHeight(), SPGenericEllipse::getVisibleRx(), SPRect::getVisibleRx(), SPGenericEllipse::getVisibleRy(), SPRect::getVisibleRy(), SPRect::getVisibleWidth(), SPUse::has_xy_offset(), TextTagAttributes::mergeInto(), operator bool(), operator=(), read(), readAbsolute(), SPRadialGradient::set(), set(), set(), SPRect::set_shape(), SPText::set_transform(), SPGenericEllipse::set_transform(), SPRect::set_transform(), SPRoot::setRootDimensions(), SPRect::setRx(), SPRect::setRy(), sp_textpath_to_text(), Inkscape::Extension::Internal::LaTeXTextRenderer::sp_use_render(), Inkscape::Extension::Internal::sp_use_render(), sp_validate_marker(), SPTextPath::SPTextPath(), unset(), SPImage::update(), SPSymbol::update(), SPFilter::write(), SPTextPath::write(), SPMarker::write(), SPImage::write(), SPLinearGradient::write(), SPMeshGradient::write(), SPRadialGradient::write(), SPRect::write(), SPSymbol::write(), SPDimensions::writeDimensions(), and TextTagAttributes::writeTo().
float SVGLength::computed |
Definition at line 50 of file svg-length.h.
Referenced by SPText::_buildLayoutInput(), SPFlowtext::_buildLayoutInput(), Inkscape::Text::Layout::_calculateCursorShapeForEmpty(), Inkscape::UI::Widget::CanvasGrid::_createGuide(), _ungroup_compensate_source_transform(), SPHatchPath::_updateView(), Inkscape::Text::Layout::appendText(), SPUse::bbox(), SPImage::bbox(), SPHatchPath::bounds(), SPDimensions::calcDimsFromParentViewport(), SPRect::compensateRxRy(), SPLine::convert_to_guides(), SPRect::convert_to_guides(), SPMeshNodeArray::create(), SPLinearGradient::create_drawing_paintserver(), SPRadialGradient::create_drawing_paintserver(), SPImage::cropToArea(), SPImage::cropToArea(), InkFileExportCmd::do_export_png(), SPDocument::doc2dt(), Inkscape::Filters::Filter::filter_effect_area(), Inkscape::Filters::FilterPrimitive::filter_primitive_area(), Inkscape::UI::Tools::ArcTool::finishItem(), Inkscape::UI::Tools::RectTool::finishItem(), Inkscape::Text::Layout::fitToPathAlign(), SPDocument::fitToRect(), fromString(), SVGBox::get(), SPGrid::get_gap(), SPGrid::get_margin(), Inkscape::Extension::Internal::PdfBuilder::Document::get_radial_pattern(), SPUse::get_xy_offset(), SPPage::getBleed(), SPPage::getDocumentMargin(), SPDocument::getDocumentScale(), SPGrid::getEffectiveOriginAndSpacing(), SPLinearGradient::getLine(), SPGrid::getOrigin(), SPGenericEllipse::getPointAtAngle(), SPPage::getRect(), SPRect::getRect(), SPGrid::getSpacing(), SPRect::getVisibleHeight(), SPGenericEllipse::getVisibleRx(), SPRect::getVisibleRx(), SPGenericEllipse::getVisibleRy(), SPRect::getVisibleRy(), SPRect::getVisibleWidth(), SPUse::has_xy_offset(), Inkscape::Extension::Internal::PrintMetafile::hold_gradient(), TextTagAttributes::insertSingleAttribute(), TextTagAttributes::mergeInto(), operator=(), operator==(), Inkscape::Extension::Internal::PdfBuilder::DrawContext::paint_item_clone(), SPImage::print(), SPUse::print(), read(), SPMeshNodeArray::read(), readAbsolute(), Inkscape::Extension::Internal::CairoRenderer::renderHatchPath(), scale(), SPRadialGradient::set(), SPRoot::set(), SPGuide::set(), set(), set(), SPGenericEllipse::set_shape(), SPLine::set_shape(), SPRect::set_shape(), SPImage::set_transform(), SPLine::set_transform(), SPGenericEllipse::set_transform(), SPRect::set_transform(), SPPage::setDocumentRect(), SPDocument::setDocumentScale(), SPDocument::setHeight(), SPRoot::setRootDimensions(), SPRect::setVisibleHeight(), SPRect::setVisibleRx(), SPRect::setVisibleRy(), SPRect::setVisibleWidth(), SPDocument::setWidth(), SPDocument::setWidthAndHeight(), SPUse::show(), SPGenericEllipse::snappoints(), SPImage::snappoints(), SPRect::snappoints(), sp_genericellipse_side(), sp_rect_clamp_radii(), sp_textpath_to_text(), Inkscape::Extension::Internal::LaTeXTextRenderer::sp_use_render(), Inkscape::Extension::Internal::sp_use_render(), sp_validate_marker(), toValue(), unset(), update(), SPMarker::update(), SPGrid::update(), SPImage::update(), SPRoot::update(), SPSymbol::update(), SPUse::update(), SPDocument::update_desktop_affine(), SPPage::update_relatives(), SPItem::visualBounds(), SPFilter::write(), SPTextPath::write(), SPMarker::write(), SPPage::write(), SPGenericEllipse::write(), SPImage::write(), SPLine::write(), SPLinearGradient::write(), SPMeshGradient::write(), SPRadialGradient::write(), SPRoot::write(), and SPMeshNodeArray::write().
Unit SVGLength::unit |
Definition at line 44 of file svg-length.h.
Referenced by SPText::_buildLayoutInput(), Inkscape::Text::Layout::appendText(), SPDimensions::calcDimsFromParentViewport(), Inkscape::Filters::Filter::filter_effect_area(), Inkscape::Filters::FilterPrimitive::filter_primitive_area(), Inkscape::Text::Layout::fitToPathAlign(), SPDocument::fitToRect(), fromString(), SPDocument::getHeight(), getUnit(), SPDocument::getWidth(), isAbsolute(), TextTagAttributes::mergeInto(), operator=(), operator==(), read(), readAbsolute(), SPRadialGradient::set(), set(), set(), SPDocument::setHeight(), SPRoot::setRootDimensions(), SPDocument::setWidth(), SPDocument::setWidthAndHeight(), sp_textpath_to_text(), toString(), unset(), update(), SPImage::update(), SPItem::visualBounds(), and SPTextPath::write().
float SVGLength::value |
Definition at line 47 of file svg-length.h.
Referenced by SPText::_buildLayoutInput(), SPFlowtext::_buildLayoutInput(), Inkscape::Text::Layout::appendText(), Inkscape::UI::Dialog::PolarArrangeTab::arrange(), SPDimensions::calcDimsFromParentViewport(), Inkscape::Filters::FilterPrimitive::filter_primitive_area(), fromString(), SPDocument::getDocumentScale(), SPDocument::getHeight(), SPDocument::getWidth(), TextTagAttributes::mergeInto(), operator=(), operator==(), read(), readAbsolute(), scale(), SPRadialGradient::set(), SPRect::set(), set(), set(), SPDocument::setHeight(), SPRoot::setRootDimensions(), SPDocument::setWidth(), SPDocument::setWidthAndHeight(), toString(), unset(), update(), and Inkscape::UI::Dialog::DocumentProperties::update_widgets().