scantools
1.0.4
Graphics manipulation with a view towards scanned documents
|
The length stores a length and converts between units. More...
#include <length.h>
Public Types | |
enum | unit { cm , in , mm , pt } |
List of supported units. More... | |
Public Member Functions | |
length () | |
Constructs a zero length. | |
length (qreal l, unit u) | |
Constructs length of given value and unit. More... | |
length (QString lstring, bool *ok=0) | |
Constructs length from a string. More... | |
qreal | get (unit u) const |
Returns length in given unit. More... | |
void | set (qreal l, unit u) |
Sets length. More... | |
bool | set (QString lstring) |
Constructs length from a string. More... | |
bool | isNonPositive () const |
Check if length is positive. More... | |
operator QString () const | |
Convert to human-readable string. More... | |
bool | operator== (const length other) const |
Checks for equality. More... | |
const length | operator+ (const length rhs) const |
Sum of the lengths. More... | |
const length | operator- (const length rhs) const |
Difference of two lengths. More... | |
const length | operator/ (const qreal div) const |
Divide a length by a number. More... | |
The length stores a length and converts between units.
This is a trivial class that helps with length storage and conversions. Lengthes are stored intenally in 1/360mm, which allows conversions between units without rounding error.
The class "length" is known to the QMetaType systen and can be used as a custom type in QVariant.
enum length::unit |
|
inline |
|
inlineexplicit |
Constructs length from a string.
This is a convenience method that calls set(QString) internally.
lstring | A string of the form "<number> unit", such as "12.3 mm". |
ok | If the string is not recoginzed *ok is set to false and the paper size if empty. Otherwise, *ok is set to true. |
qreal length::get | ( | unit | u | ) | const |
Returns length in given unit.
u | Unit |
|
inline |
|
inline |
|
inline |
|
inline |
void length::set | ( | qreal | l, |
unit | u | ||
) |
Sets length.
l | Scalar value of the length |
u | Unit for the length |
bool length::set | ( | QString | lstring | ) |
Constructs length from a string.
lstring | A string of the form "<number> unit", such as "12.3 mm". |