#include <Pt/Gfx/Scaling.h>

Conversion between logical units and pixels. More...

Public Member Functions

 Scaling (double scaleFactor=1.0)
 Constructs a scaling with the given factor.
double scaleFactor () const
 Returns the scale factor.
void setScaleFactor (double scaleFactor)
 Sets the scale factor.
double toPhysical (double n) const
 Converts a scalar value to physical units.
Gfx::PointF toPhysical (const Gfx::PointF &p) const
 Converts a point to physical units.
Gfx::SizeF toPhysical (const Gfx::SizeF &s) const
 Converts a size to physical units.
Gfx::RectF toPhysical (const Gfx::RectF &r) const
 Converts a rectangle to physical units.
double toLogical (double n) const
 Converts a scalar value to logical units.
Gfx::PointF toLogical (const Gfx::PointF &p) const
 Converts a point to logical units.
Gfx::SizeF toLogical (const Gfx::SizeF &s) const
 Converts a size to logical units.
Gfx::RectF toLogical (const Gfx::RectF &r) const
 Converts a rectangle to logical units.
double align (double n) const
 Aligns a scalar value to the nearest physical pixel.
double alignPixel (double n) const
 Aligns a scalar value to a pixel center.
double alignContour (size_t n) const
 Aligns a contour width while preserving visible thickness.
Gfx::PointF align (const Gfx::PointF &p) const
 Aligns a point to physical pixels.
Gfx::SizeF align (const Gfx::SizeF &s) const
 Aligns a size to physical pixels.
Gfx::RectF align (const Gfx::RectF &rect) const
 Aligns a rectangle to physical pixels.

(Note that these are not member symbols.)

bool operator== (const Scaling &a, const Scaling &b)
 Returns true if both scalings are equal.
bool operator!= (const Scaling &a, const Scaling &b)
 Returns true if both scalings are different.
bool operator< (const Scaling &a, const Scaling &b)
 Returns true if one scaling sorts before another.

Detailed Description

Scaling is the factor a PaintSurface uses to map logical drawing coordinates to physical pixels. toPhysical() multiplies by that factor. toLogical() divides. Alignment helpers snap geometry to pixel boundaries. A painter reads scaling from the target; set it on a Bitmap with setScaleFactor().