DGtal  0.9.4beta
Public Member Functions | Private Attributes
LibBoard::TransformFIG Struct Reference

#include <Board/Transforms.h>

Inheritance diagram for LibBoard::TransformFIG:
[legend]
Collaboration diagram for LibBoard::TransformFIG:
[legend]

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 void apply (double &x, double &y) const
 
virtual double scale (double x) const
 

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

LibBoard::TransformFIG::TransformFIG ( )
inline

Definition at line 10 of file Transforms.h.

21  {

Member Function Documentation

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

Definition at line 158 of file Transforms.cpp.

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

Referenced by LibBoard::Dot::flushFIG(), LibBoard::Line::flushFIG(), LibBoard::Arrow::flushFIG(), LibBoard::Polyline::flushFIG(), LibBoard::Rectangle::flushFIG(), LibBoard::Image::flushFIG(), LibBoard::Ellipse::flushFIG(), and LibBoard::Text::flushFIG().

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)
Definition: Transforms.h:15
int LibBoard::TransformFIG::mapWidth ( double  width) const

Definition at line 111 of file Transforms.cpp.

References LibBoard::Transform::round().

Referenced by LibBoard::Dot::flushFIG(), LibBoard::Line::flushFIG(), LibBoard::Arrow::flushFIG(), LibBoard::Polyline::flushFIG(), LibBoard::Rectangle::flushFIG(), LibBoard::Image::flushFIG(), and LibBoard::Ellipse::flushFIG().

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

Reimplemented from LibBoard::Transform.

Definition at line 99 of file Transforms.cpp.

References LibBoard::Transform::round().

Referenced by mapY().

100 {
101  return Transform::round( x );
102 }
static double round(const double &x)
Definition: Transforms.h:15
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.

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

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 }
void LibBoard::TransformFIG::setDepthRange ( const ShapeList shapes)

Definition at line 151 of file Transforms.cpp.

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

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

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

Field Documentation

int LibBoard::TransformFIG::_maxDepth
private

Definition at line 86 of file Transforms.h.

Referenced by mapDepth(), and setDepthRange().

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: