14 #include "Board/ShapeList.h"
15 #include "Board/Tools.h"
54 std::vector<Shape*>::const_iterator i =
_shapes.begin();
55 std::vector<Shape*>::const_iterator end =
_shapes.end();
64 if ( ! other.
_shapes.size() )
return;
66 std::vector<Shape*>::iterator t =
_shapes.begin();
67 std::vector<Shape*>::const_iterator i = other.
_shapes.begin();
68 std::vector<Shape*>::const_iterator end = other.
_shapes.end();
80 if ( ! other.
_shapes.size() )
return *
this;
82 std::vector<Shape*>::iterator t =
_shapes.begin();
83 std::vector<Shape*>::const_iterator i = other.
_shapes.begin();
84 std::vector<Shape*>::const_iterator end = other.
_shapes.end();
96 if (
typeid( shape ) ==
typeid(
ShapeList ) ) {
99 std::vector<Shape*> shapes = sl.
_shapes;
101 std::vector<Shape*>::iterator i = shapes.begin();
102 std::vector<Shape*>::iterator end = shapes.end();
111 if ( s->depth() == -1 )
114 if (
typeid( shape ) ==
typeid(
Group ) ) {
124 if (
typeid( shape ) ==
typeid(
ShapeList ) ) {
127 std::vector<Shape*> shapes = sl.
_shapes;
129 std::vector<Shape*>::iterator i = shapes.begin();
130 std::vector<Shape*>::iterator end = shapes.end();
134 if ( scaleFactor != 1.0 )
135 s->scaleAll( scaleFactor );
141 if ( s->depth() == -1 )
143 if ( scaleFactor != 1.0 )
144 s->scaleAll( scaleFactor );
146 if (
typeid( shape ) ==
typeid(
Group ) ) {
156 warning <<
"dup() called with an empty list of shapes.\n";
168 if (
typeid( shape ) ==
typeid(
ShapeList ) ) {
170 std::vector<Shape*>::const_iterator i = sl.
_shapes.begin();
171 std::vector<Shape*>::const_iterator end = sl.
_shapes.end();
186 warning <<
"ShapeList::insert() not implemented yet.\n";
193 std::vector<Shape*>::const_iterator i =
_shapes.begin();
194 std::vector<Shape*>::const_iterator end =
_shapes.end();
195 double f = 1.0 /
_shapes.size();
198 r += f * (*i)->center();
207 std::vector<Shape*>::iterator i =
_shapes.begin();
208 std::vector<Shape*>::iterator end =
_shapes.end();
210 (*i)->rotate( angle, rotCenter );
220 return static_cast<ShapeList&
>( r.rotate( angle, rotCenter ) );
238 std::vector<Shape*>::iterator i =
_shapes.begin();
239 std::vector<Shape*>::iterator end =
_shapes.end();
241 (*i)->translate( dx, dy );
258 std::vector<Shape*>::iterator i =
_shapes.begin();
259 std::vector<Shape*>::iterator end =
_shapes.end();
261 delta = (*i)->center() - c;
264 (*i)->scale( sx, sy );
265 delta = ( c + delta ) - (*i)->center();
292 std::vector<Shape*>::iterator i =
_shapes.begin();
293 std::vector<Shape*>::iterator end =
_shapes.end();
303 std::vector< Shape* > shapes =
_shapes;
305 std::vector< Shape* >::const_iterator i = shapes.begin();
306 std::vector< Shape* >::const_iterator end = shapes.end();
307 stream <<
"%%% Begin ShapeList\n";
311 stream <<
"%%% End ShapeList\n";
317 std::map<DGtal::Color,int> & colormap )
const
319 std::vector< Shape* > shapes =
_shapes;
321 std::vector< Shape* >::const_iterator i = shapes.begin();
322 std::vector< Shape* >::const_iterator end = shapes.end();
324 (*i)->flushFIG( stream, transform, colormap );
333 std::vector< Shape* > shapes =
_shapes;
335 std::vector< Shape* >::const_iterator i = shapes.begin();
336 std::vector< Shape* >::const_iterator end = shapes.end();
339 (*i)->flushSVG( stream, transform );
350 std::vector< Shape* > shapes =
_shapes;
352 std::vector< Shape* >::const_iterator i = shapes.begin();
353 std::vector< Shape* >::const_iterator end = shapes.end();
356 (*i)->flushCairo( cr, transform );
366 std::vector< Shape* > shapes =
_shapes;
368 std::vector< Shape* >::const_iterator i = shapes.begin();
369 std::vector< Shape* >::const_iterator end = shapes.end();
370 stream <<
"\\begin{scope}\n";
372 (*i)->flushTikZ( stream, transform );
375 stream <<
"\\end{scope}\n";
382 std::vector< Shape* >::const_iterator i =
_shapes.begin();
383 std::vector< Shape* >::const_iterator end =
_shapes.end();
384 if ( i == end )
return r;
385 r = (*i)->boundingBox();
388 r = r || (*i)->boundingBox();
400 std::vector< Shape* >::const_iterator i =
_shapes.begin();
401 std::vector< Shape* >::const_iterator end =
_shapes.end();
409 if ( d < res ) res = d;
417 #define _HAS_MSVC_MIN_ true
423 int res = std::numeric_limits<int>::min();
426 std::vector< Shape* >::const_iterator i =
_shapes.begin();
427 std::vector< Shape* >::const_iterator end =
_shapes.end();
435 if ( d > res ) res = d;
441 #if defined( _HAS_MSVC_MIN_ )
442 #define min(A,B) ((A)<(B)?(A):(B))
448 std::vector< Shape* >::const_iterator i =
_shapes.begin();
449 std::vector< Shape* >::const_iterator end =
_shapes.end();
464 return last<Shape>( position );
470 return last<Shape>( 0 );
538 return static_cast<const Group &
>(
Group( *this ).rotate( angle, rotCenter ) );
544 return static_cast<const Group &
>(
Group( *this ).rotate( angle ) );
550 return static_cast<const Group &
>(
Group( *this ).translate( dx, dy ) );
556 return static_cast<const Group &
>(
Group( *this ).scale( sx, sy ) );
562 return static_cast<const Group &
>(
Group( *this ).scale( s ) );
580 std::vector<Point>::const_iterator it = points.begin();
581 std::vector<Point>::const_iterator end = points.end();
582 while ( it != end ) {
605 stream <<
" gsave n ";
607 stream <<
" 0 slw clip " << std::endl;
609 stream <<
" grestore\n";
613 stream <<
"%%% Begin Group\n";
615 stream <<
"%%% End Group\n";
622 std::map<DGtal::Color,int> & colormap )
const
625 stream <<
"# Begin group\n";
627 << transform.mapX( box.
left ) <<
" "
628 << transform.mapY( box.
top ) <<
" "
629 << transform.mapX( box.
left + box.
width ) <<
" "
630 << transform.mapY( box.
top - box.
height ) <<
"\n";
633 stream <<
"# End Group\n";
641 stream <<
"<g clip-rule=\"nonzero\">\n"
643 <<
" <path clip-rule=\"evenodd\" d=\"";
646 stream <<
" </clipPath>\n";
647 stream <<
"<g clip-path=\"url(#LocalClipPath" <<
_clippingCount <<
")\">\n";
674 stream <<
"\\begin{scope}\n";
676 stream <<
"\\end{scope}\n";
692 return new Group( *
this );
bool shapeGreaterDepth(const Shape *s1, const Shape *s2)
A group of shapes. A group is basically a ShapeList except that when rendered in either an SVG of a F...
static unsigned int _clippingCount
void flushSVG(std::ostream &stream, const TransformSVG &transform) const
Shape & rotate(double angle, const Point ¢er)
Group rotated(double angle, const Point ¢er)
static const std::string _name
const std::string & name() const
void flushFIG(std::ostream &stream, const TransformFIG &transform, std::map< DGtal::Color, int > &colormap) const
void flushCairo(cairo_t *cr, const TransformCairo &transform) const
Group scaled(double sx, double sy)
void flushPostscript(std::ostream &stream, const TransformEPS &transform) const
Group & operator=(const Group &other)
Group translated(double dx, double dy)
Shape & translate(double dx, double dy)
Shape & scale(double sx, double sy)
void setClippingPath(const std::vector< Point > &points)
void setClippingRectangle(float x, float y, float width, float height)
void flushTikZ(std::ostream &stream, const TransformTikZ &transform) const
A path, according to Postscript and SVG definition.
unsigned int size() const
Path & scale(double sx, double sy)
void setClosed(bool closed)
Path & translate(double dx, double dy)
void flushPostscript(std::ostream &stream, const TransformEPS &transform) const
void flushSVGCommands(std::ostream &stream, const TransformSVG &transform) const
Path & rotate(double angle, const Point ¢er)
Struct representing a 2D point.
Struct representing a rectangle on the plane.
void addShape(const Shape &shape, double scaleFactor)
ShapeList scaled(double sx, double sy)
void flushCairo(cairo_t *cr, const TransformCairo &transform) const
const std::string & name() const
void flushPostscript(std::ostream &stream, const TransformEPS &transform) const
void flushFIG(std::ostream &stream, const TransformFIG &transform, std::map< DGtal::Color, int > &colormap) const
Shape & rotate(double angle, const Point ¢er)
void flushSVG(std::ostream &stream, const TransformSVG &transform) const
virtual int minDepth() const
std::vector< Shape * > _shapes
T & last(const unsigned int position=0)
void flushTikZ(std::ostream &stream, const TransformTikZ &transform) const
Shape & translate(double dx, double dy)
void shiftDepth(int shift)
ShapeList & insert(const Shape &shape, int depth)
ShapeList & dup(unsigned int copies=1)
Shape & scale(double sx, double sy)
ShapeList translated(double dx, double dy)
static const std::string _name
ShapeList rotated(double angle, const Point ¢er)
virtual int maxDepth() const
ShapeList & operator<<(const Shape &shape)
ShapeList & operator+=(const Shape &shape)
ShapeList & operator=(const ShapeList &other)
Abstract structure for a 2D shape.
virtual Shape * clone() const =0