DGtal 2.2.0
Loading...
Searching...
No Matches
LibBoard::Group Struct Reference

A group of shapes. A group is basically a ShapeList except that when rendered in either an SVG of a FIG file, it is a true compound element. More...

#include <Board/ShapeList.h>

Inheritance diagram for LibBoard::Group:
[legend]

Public Member Functions

 Group (int depthValue=-1)
 Group (const Group &other)
 ~Group ()
const std::string & name () const
Shape & rotate (double angle, const Point &center)
Shape & rotate (double angle)
Group rotated (double angle, const Point &center)
Group rotated (double angle)
Shape & translate (double dx, double dy)
Group translated (double dx, double dy)
Shape & scale (double sx, double sy)
Shape & scale (double s)
Group scaled (double sx, double sy)
Group scaled (double s)
void setClippingRectangle (float x, float y, float width, float height)
void setClippingPath (const std::vector< Point > &points)
void setClippingPath (const Path &path)
void flushPostscript (std::ostream &stream, const TransformEPS &transform) const
void flushFIG (std::ostream &stream, const TransformFIG &transform, std::map< DGtal::Color, int > &colormap) const
void flushSVG (std::ostream &stream, const TransformSVG &transform) const
void flushCairo (cairo_t *cr, const TransformCairo &transform) const
void flushTikZ (std::ostream &stream, const TransformTikZ &transform) const
Group & operator= (const Group &other)
Shape * clone () const
Rect boundingBox () const
Public Member Functions inherited from LibBoard::ShapeList
 ShapeList (int depth=-1)
 ShapeList (const ShapeList &other)
 ~ShapeList ()
const std::string & name () const
ShapeList & clear ()
Point center () const
Shape & rotate (double angle, const Point &center)
ShapeList rotated (double angle, const Point &center)
Shape & rotate (double angle)
ShapeList rotated (double angle)
Shape & translate (double dx, double dy)
ShapeList translated (double dx, double dy)
Shape & scale (double sx, double sy)
Shape & scale (double s)
ShapeList scaled (double sx, double sy)
ShapeList scaled (double s)
void scaleAll (double s)
void flushPostscript (std::ostream &stream, const TransformEPS &transform) const
void flushFIG (std::ostream &stream, const TransformFIG &transform, std::map< DGtal::Color, int > &colormap) const
void flushSVG (std::ostream &stream, const TransformSVG &transform) const
void flushCairo (cairo_t *cr, const TransformCairo &transform) const
void flushTikZ (std::ostream &stream, const TransformTikZ &transform) const
Rect boundingBox () const
virtual int minDepth () const
virtual int maxDepth () const
void shiftDepth (int shift)
Shape * clone () const
ShapeList & operator= (const ShapeList &other)
ShapeList & operator<< (const Shape &shape)
ShapeList & operator+= (const Shape &shape)
ShapeList & insert (const Shape &shape, int depth)
ShapeList & dup (unsigned int copies=1)
template<typename T>
T & last (const unsigned int position=0)
Shape & last (const unsigned int position=0)
Shape & top ()
Public Member Functions inherited from LibBoard::Shape
 Shape (DGtal::Color penColor, DGtal::Color fillColor, double lineWidth, LineStyle style, const LineCap cap, const LineJoin join, int depth)
virtual ~Shape ()
bool filled () const
Shape & rotateDeg (double angle, const Point &center)
Shape & rotateDeg (double angle)
Rect bbox ()
Shape & operator-- ()
Shape & operator++ ()
int depth () const
virtual void depth (int)
const DGtal::Color & penColor () const
const DGtal::Color & fillColor () const

Private Attributes

Path _clippingPath

Static Private Attributes

static const std::string _name
static unsigned int _clippingCount = 0

Additional Inherited Members

Public Types inherited from LibBoard::Shape
enum  LineCap { ButtCap = 0 , RoundCap , SquareCap }
enum  LineJoin { MiterJoin = 0 , RoundJoin , BevelJoin }
enum  LineStyle {
  SolidStyle = 0 , DashStyle , DotStyle , DashDotStyle ,
  DashDotDotStyle , DashDotDotDotStyle
}
Protected Member Functions inherited from LibBoard::ShapeList
void addShape (const Shape &shape, double scaleFactor)
void free ()
Protected Member Functions inherited from LibBoard::Shape
std::string svgProperties (const TransformSVG &transform) const
std::string postscriptProperties () const
void setCairoDashStyle (cairo_t *cr, LineStyle type) const
std::string tikzProperties (const TransformTikZ &transform) const
Protected Attributes inherited from LibBoard::ShapeList
std::vector< Shape * > _shapes
int _nextDepth
Protected Attributes inherited from LibBoard::Shape
int _depth
DGtal::Color _penColor
DGtal::Color _fillColor
double _lineWidth
LineStyle _lineStyle
LineCap _lineCap
LineJoin _lineJoin

Detailed Description

A group of shapes. A group is basically a ShapeList except that when rendered in either an SVG of a FIG file, it is a true compound element.

The Group structure.

Definition at line 183 of file ShapeList.h.

Constructor & Destructor Documentation

◆ Group() [1/2]

LibBoard::Group::Group ( int depthValue = -1)
inline

Definition at line 185 of file ShapeList.h.

186 : ShapeList( depthValue ), _clippingPath( true /* closed path */ ) { }
ShapeList(int depth=-1)
Definition ShapeList.h:6

References _clippingPath, and LibBoard::ShapeList::ShapeList().

Referenced by clone(), Group(), operator=(), rotated(), rotated(), scaled(), scaled(), and translated().

◆ Group() [2/2]

LibBoard::Group::Group ( const Group & other)
inline

Definition at line 188 of file ShapeList.h.

189 : ShapeList( other ), _clippingPath( other._clippingPath ) { }

References _clippingPath, Group(), and LibBoard::ShapeList::ShapeList().

◆ ~Group()

LibBoard::Group::~Group ( )
inline

Definition at line 191 of file ShapeList.h.

191{ };

Member Function Documentation

◆ boundingBox()

Rect LibBoard::Group::boundingBox ( ) const
virtual

Returns the bounding box of the figure.

Returns
The rectangle of the bounding box.

Implements LibBoard::Shape.

Definition at line 680 of file ShapeList.cpp.

681{
682 if ( _clippingPath.size() > 2 )
684 else
685 return ShapeList::boundingBox();
686}
unsigned int size() const
Definition Path.h:249
Rect boundingBox() const
Definition Path.cpp:272
Rect boundingBox() const

References _clippingPath, LibBoard::Path::boundingBox(), LibBoard::ShapeList::boundingBox(), and LibBoard::Path::size().

Referenced by flushFIG().

◆ clone()

Shape * LibBoard::Group::clone ( ) const
virtual

Return a copy of the shape.

Returns
copye of the shape.

Implements LibBoard::Shape.

Definition at line 690 of file ShapeList.cpp.

691{
692 return new Group( *this );
693}
Group(int depthValue=-1)
Definition ShapeList.h:185

References Group().

◆ flushCairo()

void LibBoard::Group::flushCairo ( cairo_t * cr,
const TransformCairo & transform ) const
virtual

Writes the cairo code of the shape in a cairo drawing context according to a transform.

Parameters
crThe cairo drawing context.
transformA 2D transform to be applied.

Implements LibBoard::Shape.

Definition at line 661 of file ShapeList.cpp.

663{
664 //todo
665 //ShapeList::flushCairo( cr, transform );
666}

◆ flushFIG()

void LibBoard::Group::flushFIG ( std::ostream & stream,
const TransformFIG & transform,
std::map< DGtal::Color, int > & colormap ) const
virtual

Writes the FIG code of the shape in a stream according to a transform.

Parameters
streamThe output stream.
transformA 2D transform to be applied.
colormapA colormap.

Implements LibBoard::Shape.

Definition at line 620 of file ShapeList.cpp.

623{
624 Rect box = boundingBox();
625 stream << "# Begin group\n";
626 stream << "6 "
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";
631 ShapeList::flushFIG( stream, transform, colormap );
632 stream << "-6\n";
633 stream << "# End Group\n";
634}
void transform(std::vector< OutputValue > &output_values, std::vector< std::size_t > &input2output, std::vector< std::size_t > &output2input, ForwardIterator itb, ForwardIterator ite, const ConversionFct &F, bool remove_duplicates)
Rect boundingBox() const
void flushFIG(std::ostream &stream, const TransformFIG &transform, std::map< DGtal::Color, int > &colormap) const

References boundingBox(), LibBoard::ShapeList::flushFIG(), LibBoard::Rect::height, LibBoard::Rect::left, LibBoard::Rect::top, and LibBoard::Rect::width.

◆ flushPostscript()

void LibBoard::Group::flushPostscript ( std::ostream & stream,
const TransformEPS & transform ) const
virtual

Writes the EPS code of the shape in a stream according to a transform.

Parameters
streamThe output stream.
transformA 2D transform to be applied.

Implements LibBoard::Shape.

Definition at line 600 of file ShapeList.cpp.

602{
603 if ( _clippingPath.size() > 2 ) {
604 stream << "%%% Begin Clipped Group " << _clippingCount << "\n";
605 stream << " gsave n ";
606 _clippingPath.flushPostscript( stream, transform );
607 stream << " 0 slw clip " << std::endl;
608 ShapeList::flushPostscript( stream, transform );
609 stream << " grestore\n";
610 stream << "%%% End Clipped Group " << _clippingCount << "\n";
612 } else {
613 stream << "%%% Begin Group\n";
614 ShapeList::flushPostscript( stream, transform );
615 stream << "%%% End Group\n";
616 }
617}
static unsigned int _clippingCount
Definition ShapeList.h:273
void flushPostscript(std::ostream &stream, const TransformEPS &transform) const
Definition Path.cpp:154
void flushPostscript(std::ostream &stream, const TransformEPS &transform) const

References _clippingCount, _clippingPath, LibBoard::Path::flushPostscript(), LibBoard::ShapeList::flushPostscript(), and LibBoard::Path::size().

◆ flushSVG()

void LibBoard::Group::flushSVG ( std::ostream & stream,
const TransformSVG & transform ) const
virtual

Writes the SVG code of the shape in a stream according to a transform.

Parameters
streamThe output stream.
transformA 2D transform to be applied.

Implements LibBoard::Shape.

Definition at line 637 of file ShapeList.cpp.

639{
640 if ( _clippingPath.size() > 2 ) {
641 stream << "<g clip-rule=\"nonzero\">\n"
642 << " <clipPath id=\"LocalClipPath" << _clippingCount << "\">\n"
643 << " <path clip-rule=\"evenodd\" d=\"";
644 _clippingPath.flushSVGCommands( stream, transform );
645 stream << "\" />\n";
646 stream << " </clipPath>\n";
647 stream << "<g clip-path=\"url(#LocalClipPath" << _clippingCount <<")\">\n";
649 ShapeList::flushSVG( stream, transform );
650 stream << "</g>\n";
651 stream << "</g>\n";
652 } else {
653 stream << "<g>\n";
654 ShapeList::flushSVG( stream, transform );
655 stream << "</g>\n";
656 }
657}
void flushSVGCommands(std::ostream &stream, const TransformSVG &transform) const
Definition Path.cpp:193
void flushSVG(std::ostream &stream, const TransformSVG &transform) const

References _clippingCount, _clippingPath, LibBoard::ShapeList::flushSVG(), LibBoard::Path::flushSVGCommands(), and LibBoard::Path::size().

◆ flushTikZ()

void LibBoard::Group::flushTikZ ( std::ostream & stream,
const TransformTikZ & transform ) const
virtual

Writes the TikZ code of the shape in a stream according to a transform.

Parameters
streamThe output stream.
transformA 2D transform to be applied.

Implements LibBoard::Shape.

Definition at line 670 of file ShapeList.cpp.

672{
673 // FIXME: implement clipping
674 stream << "\\begin{scope}\n";
675 ShapeList::flushTikZ( stream, transform );
676 stream << "\\end{scope}\n";
677}
void flushTikZ(std::ostream &stream, const TransformTikZ &transform) const

References LibBoard::ShapeList::flushTikZ().

◆ name()

const std::string & LibBoard::Group::name ( ) const
virtual

Returns the generic name of the shape (e.g., Circle, Rectangle, etc.)

Returns
object name

Reimplemented from LibBoard::Shape.

Definition at line 481 of file ShapeList.cpp.

482{
483 return _name;
484}
static const std::string _name
Definition ShapeList.h:271

References _name.

◆ operator=()

Group & LibBoard::Group::operator= ( const Group & other)

Definition at line 696 of file ShapeList.cpp.

697{
698 ShapeList::operator=( other );
699 return *this;
700}
ShapeList & operator=(const ShapeList &other)
Definition ShapeList.cpp:77

References Group(), and LibBoard::ShapeList::operator=().

◆ rotate() [1/2]

Shape & LibBoard::Group::rotate ( double angle)
virtual

Rotate the shape around its center.

Parameters
angleThe rotation angle in radian.
Returns
A reference to the shape itself.

Implements LibBoard::Shape.

Definition at line 495 of file ShapeList.cpp.

496{
499 return (*this);
500}
Path & rotate(double angle, const Point &center)
Definition Path.cpp:43
Shape & rotate(double angle, const Point &center)
Point center() const
double angle(const DGtal::Z2i::RealPoint &point)

References _clippingPath, angle(), LibBoard::ShapeList::center(), LibBoard::Path::rotate(), and LibBoard::ShapeList::rotate().

◆ rotate() [2/2]

Shape & LibBoard::Group::rotate ( double angle,
const Point & center )
virtual

Rotate the shape around a given center of rotation.

Parameters
angleThe rotation angle in radian.
centerThe center of rotation.
Returns
A reference to the shape itself.

Implements LibBoard::Shape.

Definition at line 487 of file ShapeList.cpp.

488{
489 ShapeList::rotate( angle, rotCenter );
490 _clippingPath.rotate( angle, rotCenter );
491 return (*this);
492}

References _clippingPath, angle(), LibBoard::Path::rotate(), and LibBoard::ShapeList::rotate().

◆ rotated() [1/2]

Group LibBoard::Group::rotated ( double angle)

Definition at line 542 of file ShapeList.cpp.

543{
544 return static_cast<const Group &>( Group( *this ).rotate( angle ) );
545}

References angle(), and Group().

◆ rotated() [2/2]

Group LibBoard::Group::rotated ( double angle,
const Point & center )

Definition at line 536 of file ShapeList.cpp.

537{
538 return static_cast<const Group &>( Group( *this ).rotate( angle, rotCenter ) );
539}

References angle(), and Group().

◆ scale() [1/2]

Shape & LibBoard::Group::scale ( double s)
virtual

Scale the shape along both axis.

Parameters
sThe scale factor along both axis.
Returns
The shape itself.

Implements LibBoard::Shape.

Definition at line 524 of file ShapeList.cpp.

525{
526 Point delta = _clippingPath.center() - center();
527 delta *= s;
528 _clippingPath.scale( s );
529 ShapeList::scale( s );
530 delta = ( center() + delta ) - _clippingPath.center();
531 _clippingPath.translate( delta.x, delta.y );
532 return (*this);
533}
Path & scale(double sx, double sy)
Definition Path.cpp:108
Point center() const
Definition Path.cpp:36
Path & translate(double dx, double dy)
Definition Path.cpp:81
Shape & scale(double sx, double sy)
MyPointD Point

References _clippingPath, LibBoard::Path::center(), LibBoard::ShapeList::center(), LibBoard::Path::scale(), LibBoard::ShapeList::scale(), LibBoard::Path::translate(), LibBoard::Point::x, and LibBoard::Point::y.

◆ scale() [2/2]

Shape & LibBoard::Group::scale ( double sx,
double sy )
virtual

Scale the shape along the x an y axis.

Parameters
sxThe scale factor along the x axis.
syThe scale factor along the y axis.
Returns
The shape itself.

Implements LibBoard::Shape.

Definition at line 511 of file ShapeList.cpp.

512{
513 Point delta = _clippingPath.center() - center();
514 delta.x *= sx;
515 delta.y *= sy;
516 _clippingPath.scale( sx, sy );
517 ShapeList::scale( sx, sy );
518 delta = ( center() + delta ) - _clippingPath.center();
519 _clippingPath.translate( delta.x, delta.y );
520 return (*this);
521}

References _clippingPath, LibBoard::Path::center(), LibBoard::ShapeList::center(), LibBoard::Path::scale(), LibBoard::ShapeList::scale(), LibBoard::Path::translate(), LibBoard::Point::x, and LibBoard::Point::y.

◆ scaled() [1/2]

Group LibBoard::Group::scaled ( double s)

Definition at line 560 of file ShapeList.cpp.

561{
562 return static_cast<const Group &>( Group( *this ).scale( s ) );
563}

References Group().

◆ scaled() [2/2]

Group LibBoard::Group::scaled ( double sx,
double sy )

Definition at line 554 of file ShapeList.cpp.

555{
556 return static_cast<const Group &>( Group( *this ).scale( sx, sy ) );
557}

References Group().

◆ setClippingPath() [1/2]

void LibBoard::Group::setClippingPath ( const Path & path)

Define a clipping path for the group.

Parameters
pathA path.

Definition at line 589 of file ShapeList.cpp.

590{
591 _clippingPath = path;
592 _clippingPath.setClosed( true );
593 if ( _clippingPath.size() > 1 ) {
594 if ( _clippingPath[0] == _clippingPath[ _clippingPath.size() - 1 ] )
596 }
597}
Path & pop_back()
Definition Path.cpp:22
void setClosed(bool closed)
Definition Path.h:255

References _clippingPath, LibBoard::Path::pop_back(), LibBoard::Path::setClosed(), and LibBoard::Path::size().

◆ setClippingPath() [2/2]

void LibBoard::Group::setClippingPath ( const std::vector< Point > & points)

Define a clipping path for the group.

Parameters
pointsA path.

Definition at line 577 of file ShapeList.cpp.

578{
580 std::vector<Point>::const_iterator it = points.begin();
581 std::vector<Point>::const_iterator end = points.end();
582 while ( it != end ) {
583 _clippingPath << *it;
584 ++it;
585 }
586}
void clear()
Definition Path.h:231

References _clippingPath, and LibBoard::Path::clear().

◆ setClippingRectangle()

void LibBoard::Group::setClippingRectangle ( float x,
float y,
float width,
float height )

Define a clipping rectangle for the group.

Parameters
xlower corner of the rectangle
ylower corner of the rectangle
widthwidth
heightheight

Definition at line 567 of file ShapeList.cpp.

568{
570 _clippingPath << Point( x, y );
571 _clippingPath << Point( x + width, y );
572 _clippingPath << Point( x + width, y - height);
573 _clippingPath << Point( x , y - height );
574}

References _clippingPath, and LibBoard::Path::clear().

◆ translate()

Shape & LibBoard::Group::translate ( double dx,
double dy )
virtual

Translate the shape by a given offset.

Parameters
dxThe x offset.
dyThe y offset.
Returns
A reference to the shape itself.

Implements LibBoard::Shape.

Definition at line 503 of file ShapeList.cpp.

504{
505 ShapeList::translate( dx, dy );
506 _clippingPath.translate( dx, dy );
507 return (*this);
508}
Shape & translate(double dx, double dy)

References _clippingPath, LibBoard::Path::translate(), and LibBoard::ShapeList::translate().

◆ translated()

Group LibBoard::Group::translated ( double dx,
double dy )

Definition at line 548 of file ShapeList.cpp.

549{
550 return static_cast<const Group &>( Group( *this ).translate( dx, dy ) );
551}

References Group().

Field Documentation

◆ _clippingCount

unsigned int LibBoard::Group::_clippingCount = 0
staticprivate

Definition at line 273 of file ShapeList.h.

Referenced by flushPostscript(), and flushSVG().

◆ _clippingPath

Path LibBoard::Group::_clippingPath
private

◆ _name

const std::string LibBoard::Group::_name
staticprivate

The generic name of the shape.

Definition at line 271 of file ShapeList.h.

Referenced by name().


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