scantools  1.0.4
Graphics manipulation with a view towards scanned documents
Public Types | Public Member Functions | Static Public Attributes | Friends | Related Functions | List of all members
resolution Class Reference

The resolution class stores a resolution and converts between units. More...

#include <resolution.h>

Public Types

enum  unit { dpcm , dpi , dpm }
 List of supported units. More...
 

Public Member Functions

 resolution ()
 Constructs a zero resolution.
 
 resolution (qreal l, unit u)
 Constructs resolution of given value and unit. More...
 
qreal get (unit u) const
 Get numerical value for resolution. More...
 
void set (qreal l, unit u)
 Sets resolution in given unit. More...
 
bool isNonPositive () const
 Check if resolution is zero or less. More...
 
bool isZero () const
 Fuzzy check if resolution is zero. More...
 
bool isValid () const
 Check if resolution is valid. More...
 
 operator QString () const
 Convert to string. More...
 
bool operator== (const resolution other) const
 Check for equality. More...
 

Static Public Attributes

static const int minResDPI = 10
 Minimal resolution handled by scantools. More...
 
static const int maxResDPI = 10000
 Maximal resolution handled by scantools. More...
 

Friends

resolution qMax (const resolution res1, const resolution res2)
 Find the maximum of two resolutions. More...
 

Related Functions

(Note that these are not member functions.)

length operator/ (qreal numerator, const resolution denominator)
 Divide a scalar ("number of dots") by a resolution to obtain a length. More...
 
resolution operator/ (qreal numerator, const length denominator)
 Divide a scalar by a length to obtain a resolution. More...
 

Detailed Description

The resolution class stores a resolution and converts between units.

This is a trivial class that helps with resolution storage and conversions. Resolutiones are stored intenally in 1/100 dot/cm, which allows conversions between units without rounding error.

The class "resolution" is known to the QMetaType systen and can be used as a custom type in QVariant.

Definition at line 39 of file resolution.h.

Member Enumeration Documentation

◆ unit

List of supported units.

Enumerator
dpcm 

Pixel per Centimeter.

dpi 

Pixel per Inch.

dpm 

Pixel per Millimeter.

Definition at line 53 of file resolution.h.

Constructor & Destructor Documentation

◆ resolution()

resolution::resolution ( qreal  l,
unit  u 
)
inline

Constructs resolution of given value and unit.

Parameters
lLength
uUnit

Definition at line 69 of file resolution.h.

Member Function Documentation

◆ get()

qreal resolution::get ( unit  u) const

Get numerical value for resolution.

Parameters
uUnit
Returns
resolution in given unit

◆ isNonPositive()

bool resolution::isNonPositive ( ) const
inline

Check if resolution is zero or less.

Returns
true if resolution is zero or less

Definition at line 92 of file resolution.h.

◆ isValid()

bool resolution::isValid ( ) const
inline

Check if resolution is valid.

Returns
true if the resolution is bounded by minResDPI and maxResDPI

Definition at line 108 of file resolution.h.

◆ isZero()

bool resolution::isZero ( ) const
inline

Fuzzy check if resolution is zero.

Returns
true if resolution is zero

Definition at line 100 of file resolution.h.

◆ operator QString()

resolution::operator QString ( ) const
inline

Convert to string.

Returns
resolution in dpi as a human-readable string

Definition at line 116 of file resolution.h.

◆ operator==()

bool resolution::operator== ( const resolution  other) const
inline

Check for equality.

Parameters
otherOther resolution
Returns
True iff resolutions are equal.

Definition at line 126 of file resolution.h.

◆ set()

void resolution::set ( qreal  l,
unit  u 
)

Sets resolution in given unit.

Parameters
lLength
uUnit

Friends And Related Function Documentation

◆ operator/() [1/2]

resolution operator/ ( qreal  numerator,
const length  denominator 
)
related

Divide a scalar by a length to obtain a resolution.

Parameters
numeratorScalar ("Number of dots")
denominatorlength
Returns
Resolution

Definition at line 179 of file resolution.h.

◆ operator/() [2/2]

length operator/ ( qreal  numerator,
const resolution  denominator 
)
related

Divide a scalar ("number of dots") by a resolution to obtain a length.

Parameters
numeratorScalar ("Number of dots")
denominatorResolution
Returns
length

Definition at line 164 of file resolution.h.

◆ qMax

resolution qMax ( const resolution  res1,
const resolution  res2 
)
friend

Find the maximum of two resolutions.

Maximum of two resolutions.

Parameters
res1First resolution
res2Second resolution
Returns
Largest resolution

Definition at line 185 of file resolution.h.

Member Data Documentation

◆ maxResDPI

const int resolution::maxResDPI = 10000
static

Maximal resolution handled by scantools.

All classes, functions and methods of this library require that all numbers describing graphical resolution are smaller than or equal to maxRes, which is specified in dots per inch.

Definition at line 145 of file resolution.h.

◆ minResDPI

const int resolution::minResDPI = 10
static

Minimal resolution handled by scantools.

All classes, functions and methods of this library require that all numbers describing graphical resolution are larger than or equal to minRes, which is specified in dots per inch.

Definition at line 137 of file resolution.h.


The documentation for this class was generated from the following file: