DGtal  0.9.4beta
Public Member Functions
LibBoard::TransformSVG Struct Reference

#include <Board/Transforms.h>

Inheritance diagram for LibBoard::TransformSVG:
[legend]
Collaboration diagram for LibBoard::TransformSVG:
[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 SVG output.

The TransformSVG structure.

Definition at line 95 of file Transforms.h.

Member Function Documentation

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

Definition at line 188 of file Transforms.cpp.

References LibBoard::Transform::round().

Referenced by LibBoard::Arrow::flushSVG(), LibBoard::Shape::svgProperties(), and LibBoard::Shape::tikzProperties().

189 {
190  // return Transform::round( 1000 * width / ppmm ) / 1000.0;
191  return Transform::round( 1000 * width / ppmm ) / 1000.0;
192 }
static double round(const double &x)
Definition: Transforms.h:15
double LibBoard::TransformSVG::mapY ( double  y) const
virtual
double LibBoard::TransformSVG::rounded ( double  x) const
virtual

Reimplemented from LibBoard::Transform.

Definition at line 176 of file Transforms.cpp.

References LibBoard::Transform::round().

Referenced by mapY().

177 {
178  return Transform::round( 100*x ) / 100.0f;
179 }
static double round(const double &x)
Definition: Transforms.h:15
void LibBoard::TransformSVG::setBoundingBox ( const Rect rect,
const double  pageWidth,
const double  pageHeight,
const double  margin 
)
virtual

Implements LibBoard::Transform.

Definition at line 195 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::saveSVG(), and LibBoard::Board::saveTikZ().

199 {
200  if ( pageWidth <= 0 || pageHeight <= 0 ) {
201  _scale = 1.0f;
202  // _deltaX = 0.5 * 210 * ppmm - ( rect.left + 0.5 * rect.width );
203  _deltaX = - rect.left;
204  // _deltaY = 0.5 * 297 * ppmm - ( rect.top - 0.5 * rect.height );
205  _deltaY = - ( rect.top - rect.height );
206  // _height = 297 * fig_ppmm;
207  _height = rect.height;
208  } else {
209  const double w = pageWidth - 2 * margin;
210  const double h = pageHeight - 2 * margin;
211  if ( rect.height / rect.width > ( h / w ) ) {
212  _scale = h * ppmm / rect.height;
213  } else {
214  _scale = w * ppmm / rect.width;
215  }
216  _deltaX = 0.5 * pageWidth * ppmm - _scale * ( rect.left + 0.5 * rect.width );
217  _deltaY = 0.5 * pageHeight * ppmm - _scale * ( rect.top - 0.5 * rect.height );
218  _height = pageHeight * ppmm;
219  }
220 }

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