15 #include "Board/Rect.h"
16 #include "Board/Shapes.h"
17 #include "Board/ShapeList.h"
18 #include "Board/Transforms.h"
22 const float ppmm = 720.0f / 254.0f;
23 const float fig_ppmm = 1143 / 25.4f;
69 const double pageWidth,
70 const double pageHeight,
73 if ( pageWidth <= 0 || pageHeight <= 0 ) {
76 _deltaX = 0.5 * 210 * ppmm - ( rect.left + 0.5 * rect.width );
78 _deltaY = 0.5 * 297 * ppmm - ( rect.top - 0.5 * rect.height );
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;
86 _scale = w * ppmm / rect.width;
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 );
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;
122 const double pageWidth,
123 const double pageHeight,
124 const double margin )
126 if ( pageWidth <= 0 || pageHeight <= 0 ) {
128 _deltaX = 0.5 * 210 * fig_ppmm -
_scale * ( rect.left + 0.5 * rect.width );
130 _deltaY = 0.5 * 297 * fig_ppmm -
_scale * ( rect.top - 0.5 * rect.height );
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;
141 _scale = ( w * fig_ppmm ) / rect.width;
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;
163 int r =
static_cast<int>( 1 +
Transform::round( ( ( depth - _minDepth ) / range ) * 998 ) );
196 const double pageWidth,
197 const double pageHeight,
198 const double margin )
200 if ( pageWidth <= 0 || pageHeight <= 0 ) {
205 _deltaY = - ( rect.top - rect.height );
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;
214 _scale = w * ppmm / rect.width;
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 );
228 TransformCairo::rounded(
double x )
const
234 TransformCairo::mapY(
double y )
const
236 return rounded( _height - ( y * _scale + _deltaY ) );
240 TransformCairo::mapWidth(
double width )
const
247 TransformCairo::setBoundingBox(
const Rect & rect,
248 const double pageWidth,
249 const double pageHeight,
250 const double margin )
252 if ( pageWidth <= 0 || pageHeight <= 0 ) {
255 _deltaX = - rect.left;
257 _deltaY = - ( rect.top - rect.height );
259 _height = rect.height;
261 const double w = pageWidth - 2 * margin;
262 const double h = pageHeight - 2 * margin;
263 if ( rect.height / rect.width > ( h / w ) ) {
264 _scale = h * ppmm / rect.height;
266 _scale = w * ppmm / rect.width;
268 _deltaX = 0.5 * pageWidth * ppmm - _scale * ( rect.left + 0.5 * rect.width );
269 _deltaY = 0.5 * pageHeight * ppmm - _scale * ( rect.top - 0.5 * rect.height );
270 _height = pageHeight * ppmm;