DGtal 1.3.0
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes
LibBoard::TransformFIG Struct Reference

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

#include <Board/Transforms.h>

Inheritance diagram for LibBoard::TransformFIG:
LibBoard::Transform

Public Member Functions

 TransformFIG ()
 
double rounded (double x) const
 
double mapY (double y) const
 
int mapWidth (double width) const
 
void setBoundingBox (const Rect &rect, const double pageWidth, const double pageHeight, const double margin)
 
void setDepthRange (const ShapeList &shapes)
 
int mapDepth (int depth) const
 
- Public Member Functions inherited from LibBoard::Transform
 Transform ()
 
virtual ~Transform ()
 
virtual double mapX (double x) const
 
virtual double mapY (double y) const =0
 
virtual void apply (double &x, double &y) const
 
virtual double scale (double x) const
 
virtual double rounded (double x) const
 
virtual void setBoundingBox (const Rect &rect, const double pageWidth, const double pageHeight, const double margin)=0
 

Private Attributes

int _maxDepth
 
int _minDepth
 

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 XFig output.

The TransformFIG structure.

Definition at line 73 of file Transforms.h.

Constructor & Destructor Documentation

◆ TransformFIG()

LibBoard::TransformFIG::TransformFIG ( )
inline

Member Function Documentation

◆ mapDepth()

int LibBoard::TransformFIG::mapDepth ( int  depth) const

Definition at line 158 of file Transforms.cpp.

159{
160 if ( depth > _maxDepth ) return 999;
161 if ( _maxDepth - _minDepth > 998 ) {
162 double range = _maxDepth - _minDepth;
163 int r = static_cast<int>( 1 + Transform::round( ( ( depth - _minDepth ) / range ) * 998 ) );
164 return r>=0?r:0;
165 } else {
166 int r = 1 + depth - _minDepth;
167 return r>=0?r:0;
168 }
169}
static double round(const double &x)

References _maxDepth, _minDepth, and LibBoard::Transform::round().

◆ mapWidth()

int LibBoard::TransformFIG::mapWidth ( double  width) const

Definition at line 111 of file Transforms.cpp.

112{
113 // FIG width unit is 1/160 inch
114 // Postscript points are 1/72 inch
115 if ( width == 0.0 ) return 0;
116 int result = static_cast<int>( Transform::round( 160 * ( width / 72.0 ) ) );
117 return result>0?result:1;
118}

References LibBoard::Transform::round().

◆ mapY()

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

Implements LibBoard::Transform.

Definition at line 105 of file Transforms.cpp.

106{
107 return rounded( _height - ( y * _scale + _deltaY ) );
108}
double rounded(double x) const
Definition: Transforms.cpp:99

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

◆ rounded()

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

Reimplemented from LibBoard::Transform.

Definition at line 99 of file Transforms.cpp.

100{
101 return Transform::round( x );
102}

References LibBoard::Transform::round().

Referenced by mapY().

◆ setBoundingBox()

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

Implements LibBoard::Transform.

Definition at line 121 of file Transforms.cpp.

125{
126 if ( pageWidth <= 0 || pageHeight <= 0 ) {
127 _scale = fig_ppmm / ppmm;
128 _deltaX = 0.5 * 210 * fig_ppmm - _scale * ( rect.left + 0.5 * rect.width );
129 //_deltaX = - rect.left;
130 _deltaY = 0.5 * 297 * fig_ppmm - _scale * ( rect.top - 0.5 * rect.height );
131 // _deltaY = - rect.top;
132 // _deltaY = - ( rect.top - rect.height );
133 //_height = rect.height;
134 _height = 297 * fig_ppmm;
135 } else {
136 const double w = pageWidth - 2 * margin;
137 const double h = pageHeight - 2 * margin;
138 if ( rect.height / rect.width > ( h / w ) ) {
139 _scale = ( h * fig_ppmm ) / rect.height;
140 } else {
141 _scale = ( w * fig_ppmm ) / rect.width;
142 }
143 _deltaX = 0.5 * pageWidth * fig_ppmm - _scale * ( rect.left + 0.5 * rect.width );
144 _deltaY = 0.5 * pageHeight * fig_ppmm - _scale * ( rect.top - 0.5 * rect.height );
145 _height = pageHeight * fig_ppmm;
146 }
147 // float ppmm = (1200/25.4);
148}

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.

◆ setDepthRange()

void LibBoard::TransformFIG::setDepthRange ( const ShapeList shapes)

Definition at line 151 of file Transforms.cpp.

152{
153 _maxDepth = shapes.maxDepth();
154 _minDepth = shapes.minDepth();
155}

References _maxDepth, _minDepth, LibBoard::ShapeList::maxDepth(), and LibBoard::ShapeList::minDepth().

Field Documentation

◆ _maxDepth

int LibBoard::TransformFIG::_maxDepth
private

Definition at line 86 of file Transforms.h.

Referenced by mapDepth(), and setDepthRange().

◆ _minDepth

int LibBoard::TransformFIG::_minDepth
private

Definition at line 87 of file Transforms.h.

Referenced by mapDepth(), and setDepthRange().


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