DGtal  1.4.2
LibBoard::TransformEPS Struct Reference

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

#include <Board/Transforms.h>

Inheritance diagram for LibBoard::TransformEPS:
[legend]

Public Member Functions

double mapY (double y) 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
 
virtual double rounded (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 EPS output.

The TransformEPS structure.

Definition at line 59 of file Transforms.h.

Member Function Documentation

◆ mapY()

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

Implements LibBoard::Transform.

Definition at line 62 of file Transforms.cpp.

63 {
64  return rounded( y * _scale + _deltaY );
65 }
virtual double rounded(double x) const
Definition: Transforms.cpp:33

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

◆ setBoundingBox()

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

Implements LibBoard::Transform.

Definition at line 68 of file Transforms.cpp.

72 {
73  if ( pageWidth <= 0 || pageHeight <= 0 ) {
74  _scale = 1.0f;
75  // _deltaX = - rect.left;
76  _deltaX = 0.5 * 210 * ppmm - ( rect.left + 0.5 * rect.width );
77  // _deltaY = - ( rect.top - rect.height );
78  _deltaY = 0.5 * 297 * ppmm - ( rect.top - 0.5 * rect.height );
79  _height = rect.height;
80  } else {
81  const double w = pageWidth - 2 * margin;
82  const double h = pageHeight - 2 * margin;
83  if ( ( rect.height / rect.width ) > ( h / w ) ) {
84  _scale = h * ppmm / rect.height;
85  } else {
86  _scale = w * ppmm / rect.width;
87  }
88  _deltaX = 0.5 * pageWidth * ppmm - _scale * ( rect.left + 0.5 * rect.width );
89  _deltaY = 0.5 * pageHeight * ppmm - _scale * ( rect.top - 0.5 * rect.height );
90  _height = pageHeight * ppmm;
91  }
92 }

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::saveEPS().


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