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

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

#include <Board/Transforms.h>

Inheritance 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

◆ mapWidth()

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

Definition at line 188 of file Transforms.cpp.

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)

References LibBoard::Transform::round().

◆ mapY()

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

Implements LibBoard::Transform.

Definition at line 182 of file Transforms.cpp.

183{
184 return rounded( _height - ( y * _scale + _deltaY ) );
185}
double rounded(double x) const

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

◆ rounded()

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

Reimplemented from LibBoard::Transform.

Definition at line 176 of file Transforms.cpp.

177{
178 return Transform::round( 100*x ) / 100.0f;
179}

References LibBoard::Transform::round().

Referenced by mapY().

◆ setBoundingBox()

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.

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}

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: