DGtal 1.4.0
Loading...
Searching...
No Matches
LibBoard::TransformCairo Struct Reference

Structure representing a scaling and translation suitable for an Cairo output. More...

#include <Board/Transforms.h>

Inheritance diagram for LibBoard::TransformCairo:
[legend]

Public Member Functions

double rounded (double x) const
 
double mapY (double y) const
 
double mapWidth (double width) const
 
void setBoundingBox (const Rect &rect, const double pageWidth, const double pageHeight, const double margin)
 
- Public Member Functions inherited from LibBoard::Transform
 Transform ()
 
virtual ~Transform ()
 
virtual double mapX (double x) const
 
virtual void apply (double &x, double &y) const
 
virtual double scale (double x) const
 

Additional Inherited Members

- Static Public Member Functions inherited from LibBoard::Transform
static double round (const double &x)
 
- Protected Attributes inherited from LibBoard::Transform
double _scale
 
double _deltaX
 
double _deltaY
 
double _height
 

Detailed Description

Structure representing a scaling and translation suitable for an Cairo output.

The TransformCairo structure.

Definition at line 112 of file Transforms.h.

Member Function Documentation

◆ mapWidth()

double LibBoard::TransformCairo::mapWidth ( double width) const

Definition at line 240 of file Transforms.cpp.

241{
242 // return Transform::round( 1000 * width / ppmm ) / 1000.0;
243 return Transform::round( 1000 * width / ppmm ) / 1000.0;
244}
static double round(const double &x)

References LibBoard::Transform::round().

◆ mapY()

double LibBoard::TransformCairo::mapY ( double y) const
virtual

Implements LibBoard::Transform.

Definition at line 234 of file Transforms.cpp.

235{
236 return rounded( _height - ( y * _scale + _deltaY ) );
237}
double rounded(double x) const

References LibBoard::Transform::_deltaY, LibBoard::Transform::_height, LibBoard::Transform::_scale, and rounded().

◆ rounded()

double LibBoard::TransformCairo::rounded ( double x) const
virtual

Reimplemented from LibBoard::Transform.

Definition at line 228 of file Transforms.cpp.

229{
230 return Transform::round( 100*x ) / 100.0f;
231}

References LibBoard::Transform::round().

Referenced by mapY().

◆ setBoundingBox()

void LibBoard::TransformCairo::setBoundingBox ( const Rect & rect,
const double pageWidth,
const double pageHeight,
const double margin )
virtual

Implements LibBoard::Transform.

Definition at line 247 of file Transforms.cpp.

251{
252 if ( pageWidth <= 0 || pageHeight <= 0 ) {
253 _scale = 1.0f;
254 // _deltaX = 0.5 * 210 * ppmm - ( rect.left + 0.5 * rect.width );
255 _deltaX = - rect.left;
256 // _deltaY = 0.5 * 297 * ppmm - ( rect.top - 0.5 * rect.height );
257 _deltaY = - ( rect.top - rect.height );
258 // _height = 297 * fig_ppmm;
259 _height = rect.height;
260 } else {
261 const double w = pageWidth - 2 * margin;
262 const double h = pageHeight - 2 * margin;
263 if ( rect.height / rect.width > ( h / w ) ) {
264 _scale = h * ppmm / rect.height;
265 } else {
266 _scale = w * ppmm / rect.width;
267 }
268 _deltaX = 0.5 * pageWidth * ppmm - _scale * ( rect.left + 0.5 * rect.width );
269 _deltaY = 0.5 * pageHeight * ppmm - _scale * ( rect.top - 0.5 * rect.height );
270 _height = pageHeight * ppmm;
271 }
272}

References LibBoard::Transform::_deltaX, LibBoard::Transform::_deltaY, LibBoard::Transform::_height, LibBoard::Transform::_scale, LibBoard::Rect::height, LibBoard::Rect::left, LibBoard::Rect::top, and LibBoard::Rect::width.


The documentation for this struct was generated from the following files: