DGtal  0.9.3beta
Public Member Functions
LibBoard::TransformCairo Struct Reference

#include <Board/Transforms.h>

Inheritance diagram for LibBoard::TransformCairo:
[legend]
Collaboration 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

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

Definition at line 240 of file Transforms.cpp.

References LibBoard::Transform::round().

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)
Definition: Transforms.h:15
double LibBoard::TransformCairo::mapY ( double  y) const
virtual
double LibBoard::TransformCairo::rounded ( double  x) const
virtual

Reimplemented from LibBoard::Transform.

Definition at line 228 of file Transforms.cpp.

References LibBoard::Transform::round().

Referenced by mapY().

229 {
230  return Transform::round( 100*x ) / 100.0f;
231 }
static double round(const double &x)
Definition: Transforms.h:15
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.

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.

Referenced by LibBoard::Board::saveCairo().

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 }

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