15 #include "Board/Path.h"
16 #include "Board/Transforms.h"
38 return Point( bbox.left + bbox.width/2.0,
39 bbox.top - bbox.height/2.0 );
45 std::vector<Point>::iterator i =
_points.begin();
46 std::vector<Point>::iterator end =
_points.end();
48 i->rotate( angle, rotCenter );
58 std::vector<Point>::iterator i = res._points.begin();
59 std::vector<Point>::iterator end = res._points.end();
61 i->rotate( angle, rotCenter );
77 return static_cast<Path&
>( res.rotate( angle,
center() ) );
83 std::vector<Point>::iterator i =
_points.begin();
84 std::vector<Point>::iterator end =
_points.end();
85 Point delta( dx, dy );
97 std::vector<Point>::iterator i = res._points.begin();
98 std::vector<Point>::iterator end = res._points.end();
99 Point delta( dx, dy );
112 std::vector<Point>::iterator i =
_points.begin();
113 std::vector<Point>::iterator end =
_points.end();
133 return Path(*this).scale( sx, sy );
139 return Path(*this).scale( s, s );
145 std::vector<Point>::iterator it =
_points.begin();
146 std::vector<Point>::iterator end =
_points.end();
147 while ( it != end ) {
155 const TransformEPS & transform )
const
159 std::vector<Point>::const_iterator i =
_points.begin();
160 std::vector<Point>::const_iterator end =
_points.end();
162 stream << transform.mapX( i->x ) <<
" " << transform.mapY( i->y ) <<
" m";
165 stream <<
" " << transform.mapX( i->x ) <<
" " << transform.mapY( i->y ) <<
" l";
168 if (
_closed ) stream <<
" cp";
174 const TransformFIG & transform )
const
179 std::vector<Point>::const_iterator i =
_points.begin();
180 std::vector<Point>::const_iterator end =
_points.end();
182 stream <<
" " <<
static_cast<int>( transform.mapX( i->x ) )
183 <<
" " << static_cast<int>( transform.mapY( i->y ) );
187 stream <<
" " <<
static_cast<int>( transform.mapX(
_points.begin()->x ) )
188 <<
" " <<
static_cast<int>( transform.mapY(
_points.begin()->y ) );
194 const TransformSVG & transform )
const
198 std::vector<Point>::const_iterator i =
_points.begin();
199 std::vector<Point>::const_iterator end =
_points.end();
202 stream <<
"M " << transform.mapX( i->x ) <<
" " << transform.mapY( i->y );
205 stream <<
" L " << transform.mapX( i->x ) <<
" " << transform.mapY( i->y );
207 count = ( count + 1 ) % 6;
208 if ( !count ) stream <<
"\n ";
211 stream <<
" Z" << std::endl;
216 const TransformSVG & transform )
const
220 std::vector<Point>::const_iterator i =
_points.begin();
221 std::vector<Point>::const_iterator end =
_points.end();
223 stream << transform.mapX( i->x ) <<
"," << transform.mapY( i->y );
226 stream <<
" " << transform.mapX( i->x ) <<
"," << transform.mapY( i->y );
228 count = ( count + 1 ) % 6;
229 if ( !count ) stream <<
"\n ";
235 Path::flushCairoPoints( cairo_t *cr,
236 const TransformCairo & transform )
const
240 std::vector<Point>::const_iterator i =
_points.begin();
241 std::vector<Point>::const_iterator end =
_points.end();
243 cairo_move_to (cr, transform.mapX( i->x ), transform.mapY( i->y ));
246 cairo_line_to (cr, transform.mapX( i->x ), transform.mapY( i->y ));
248 count = ( count + 1 ) % 6;
256 const TransformTikZ & transform )
const
260 std::vector<Point>::const_iterator i =
_points.begin();
261 std::vector<Point>::const_iterator end =
_points.end();
262 stream <<
'(' << transform.mapX( i->x ) <<
"," << transform.mapY( i->y ) <<
')';
266 <<
'(' << transform.mapX( i->x ) <<
"," << transform.mapY( i->y ) <<
')';
275 return Rect( 0, 0, 0, 0 );
277 std::vector< Point >::const_iterator i =
_points.begin();
278 std::vector< Point >::const_iterator end =
_points.end();
285 if ( i->x < rect.left ) {
286 double dw = rect.left - i->x;
289 }
else if ( i->x > rect.left + rect.width ) {
290 rect.width = i->x - rect.left;
292 if ( i->y > rect.top ) {
293 double dh = i->y - rect.top;
296 }
else if ( i->y < rect.top - rect.height ) {
297 rect.height = rect.top - i->y;