DGtal 1.3.0
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | Static Private Attributes
LibBoard::Image Struct Reference

Used to draw image in figure. More...

#include <Board/Shapes.h>

Inheritance diagram for LibBoard::Image:
LibBoard::Rectangle LibBoard::Polyline LibBoard::Shape

Public Member Functions

 Image (double x0, double y0, double width, double height, std::string fileName, int depthValue, double alpha=1.0)
 
const std::string & name () const
 
Imageclone () 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
 
- Public Member Functions inherited from LibBoard::Rectangle
 Rectangle (double x, double y, double width, double height, DGtal::Color penColor, DGtal::Color fillColor, double lineWidth, const LineStyle style=SolidStyle, const LineCap cap=ButtCap, const LineJoin join=MiterJoin, int depth=-1)
 
 Rectangle (const Rect &rect, DGtal::Color penColor, DGtal::Color fillColor, double lineWidth, const LineStyle style=SolidStyle, const LineCap cap=ButtCap, const LineJoin join=MiterJoin, int depth=-1)
 
const std::string & name () const
 
double x () const
 
double y () const
 
double width ()
 
double height ()
 
Point topLeft ()
 
Point topRight ()
 
Point bottomLeft ()
 
Point bottomRight ()
 
Rectangle rotated (double angle, const Point &center) const
 
Rectangle rotated (double angle) const
 
Rectangle translated (double dx, double dy) const
 
Rectangle scaled (double sx, double sy) const
 
Rectangle scaled (double s) const
 
void scaleAll (double s)
 
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
 
Rectangleclone () const
 
- Public Member Functions inherited from LibBoard::Polyline
 Polyline (const std::vector< Point > &points, bool closed, DGtal::Color penColor, DGtal::Color fillColor, double lineWidth, const LineStyle lineStyle=SolidStyle, const LineCap cap=ButtCap, const LineJoin join=MiterJoin, int depth=-1)
 
 Polyline (const Path &path, DGtal::Color penColor, DGtal::Color fillColor, double lineWidth, const LineStyle lineStyle=SolidStyle, const LineCap cap=ButtCap, const LineJoin join=MiterJoin, int depth=-1)
 
 Polyline (bool closed, DGtal::Color penColor, DGtal::Color fillColor, double lineWidth, const LineStyle lineStyle=SolidStyle, const LineCap cap=ButtCap, const LineJoin join=MiterJoin, int depth=-1)
 
const std::string & name () const
 
Point center () const
 
Polylineoperator<< (const Point &p)
 
Pointoperator[] (const unsigned int n)
 
Polylinerotate (double angle, const Point &center)
 
Polyline rotated (double angle, const Point &center) const
 
Polylinerotate (double angle)
 
Polyline rotated (double angle) const
 
Polylinetranslate (double dx, double dy)
 
Polyline translated (double dx, double dy) const
 
Shapescale (double sx, double sy)
 
Shapescale (double s)
 
Polyline scaled (double sx, double sy) const
 
Polyline scaled (double s) const
 
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
 
Polylineclone () const
 
- 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 ()
 
virtual const std::string & name () const
 
virtual Shapeclone () const =0
 
bool filled () const
 
virtual Point center () const =0
 
virtual Shaperotate (double angle, const Point &center)=0
 
virtual Shaperotate (double angle)=0
 
ShaperotateDeg (double angle, const Point &center)
 
ShaperotateDeg (double angle)
 
virtual Shapetranslate (double dx, double dy)=0
 
virtual Shapescale (double sx, double sy)=0
 
virtual Shapescale (double s)=0
 
virtual Rect boundingBox () const =0
 
Rect bbox ()
 
Shapeoperator-- ()
 
Shapeoperator++ ()
 
virtual void scaleAll (double s)=0
 
virtual void flushPostscript (std::ostream &stream, const TransformEPS &transform) const =0
 
virtual void flushFIG (std::ostream &stream, const TransformFIG &transform, std::map< DGtal::Color, int > &colormap) const =0
 
virtual void flushSVG (std::ostream &stream, const TransformSVG &transform) const =0
 
virtual void flushCairo (cairo_t *cr, const TransformCairo &transform) const =0
 
virtual void flushTikZ (std::ostream &stream, const TransformTikZ &transform) const =0
 
int depth () const
 
virtual void depth (int)
 
virtual void shiftDepth (int shift)
 
const DGtal::ColorpenColor () const
 
const DGtal::ColorfillColor () const
 

Protected Attributes

double _x0
 
double _y0
 
double _width
 
double _height
 
std::string _filename
 
double _alpha
 
- Protected Attributes inherited from LibBoard::Rectangle
bool _isRectangle
 
- Protected Attributes inherited from LibBoard::Polyline
Path _path
 
- Protected Attributes inherited from LibBoard::Shape
int _depth
 
DGtal::Color _penColor
 
DGtal::Color _fillColor
 
double _lineWidth
 
LineStyle _lineStyle
 
LineCap _lineCap
 
LineJoin _lineJoin
 

Static Private Attributes

static const std::string _name
 

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::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
 

Detailed Description

Used to draw image in figure.

The Image structure.

Definition at line 1026 of file Board/Shapes.h.

Constructor & Destructor Documentation

◆ Image()

LibBoard::Image::Image ( double  x0,
double  y0,
double  width,
double  height,
std::string  fileName,
int  depthValue,
double  alpha = 1.0 
)
inline

Constructs a Image.

Parameters
x0First coordinate of the start point.
y0Second coordinate of the start point.
widthFirst coordinate of the end point.
heightSecond coordinate of the end point.
fileNamethe image filename.
depthValueThe depth of the image.
alphaThe image transparency used for display (works only is cairo is installed).

Member Function Documentation

◆ clone()

Image * LibBoard::Image::clone ( ) const
virtual

Return a copy of the shape.

Returns
copye of the shape.

Reimplemented from LibBoard::Rectangle.

Definition at line 639 of file Shapes.cpp.

639 {
640 return new Image(*this);
641}
ImageContainerBySTLVector< Domain, Value > Image

◆ flushCairo()

void LibBoard::Image::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.

Reimplemented from LibBoard::Rectangle.

Definition at line 686 of file Shapes.cpp.

688{
689 int w, h;
690 cairo_surface_t *image;
691 cairo_save (cr);
692 std::string extension = _filename.substr(_filename.find_last_of(".") + 1);
693 ASSERT(extension=="png");
694 image = cairo_image_surface_create_from_png (_filename.c_str());
695 assert(cairo_surface_status (image) == CAIRO_STATUS_SUCCESS);
696 w = cairo_image_surface_get_width (image);
697 h = cairo_image_surface_get_height (image);
698
699 // tr
700 cairo_translate (cr, transform.mapX( _path[0].x ), transform.mapY( _path[0].y ));
701 //cairo_scale (cr, transform.scale( _path[1].x - _path[0].x )/w, transform.scale( _path[0].y - _path[3].y )/h);
702 cairo_scale (cr, transform.scale( (_path[1] - _path[0]).norm() )/w, transform.scale( (_path[0] - _path[3]).norm() )/h);
703 // tr
704
705 cairo_set_source_surface (cr, image, 0, 0);
706 cairo_paint_with_alpha(cr, _alpha);
707 cairo_surface_destroy (image);
708
709 cairo_restore (cr);
710}
std::string _filename

References _alpha, _filename, and LibBoard::Polyline::_path.

◆ flushFIG()

void LibBoard::Image::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.

Reimplemented from LibBoard::Rectangle.

Definition at line 644 of file Shapes.cpp.

648{
649 stream << "2 5 ";
650 // Line style
651 stream << _lineStyle << " ";
652 // Thickness
653 stream << ( _penColor.valid()?transform.mapWidth( _lineWidth ):0 ) << " ";
654 // Pen color
655 stream << colormap[ _penColor ] << " ";
656 // Fill color
657 stream << "0 ";
658 // Depth
659 stream << transform.mapDepth( _depth ) << " "
660 << "-1 -1 0.000 0 0 -1 0 0 5" << std::endl <<" 0 "
661 << _filename << std::endl;
662 _path.flushFIG( stream, transform );
663 stream << std::endl;
664}
bool valid() const
void flushFIG(std::ostream &stream, const TransformFIG &transform) const
Definition: Path.cpp:173
DGtal::Color _penColor
Definition: Board/Shapes.h:296
LineStyle _lineStyle
Definition: Board/Shapes.h:299

References LibBoard::Shape::_depth, _filename, LibBoard::Shape::_lineStyle, LibBoard::Shape::_lineWidth, LibBoard::Polyline::_path, LibBoard::Shape::_penColor, LibBoard::Path::flushFIG(), and DGtal::Color::valid().

◆ flushSVG()

void LibBoard::Image::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.

Reimplemented from LibBoard::Rectangle.

Definition at line 669 of file Shapes.cpp.

671{
672
673 stream << "<image x=\"" << transform.mapX( _path[0].x ) << '"'
674 << " y=\"" << transform.mapY( _path[0].y ) << '"'
675 << " width=\"" << transform.scale( (_path[1] - _path[0]).norm() ) << '"'
676 << " height=\"" << transform.scale( (_path[0] - _path[3]).norm() ) << '"'
677 << " xlink:href=\""<< _filename << "\" >" << std::endl
678 << " <title>My image</title>"<<std::endl
679 << " </image>" << std::endl;
680
681
682}

References _filename, and LibBoard::Polyline::_path.

◆ flushTikZ()

void LibBoard::Image::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.

Reimplemented from LibBoard::Rectangle.

Definition at line 714 of file Shapes.cpp.

717{
718 stream << "\\node [below right=0pt] at ("
719 << transform.mapX( _path[0].x ) << "pt,"
720 << transform.mapY( _path[0].y ) << "pt) {\\pgfimage["
721 << "width=" << transform.scale( (_path[1] - _path[0]).norm() ) << "pt,"
722 << "height=" << transform.scale( (_path[0] - _path[3]).norm() ) << "pt,"
723 << "]{" << _filename << "}};" << std::endl;
724}

References _filename, and LibBoard::Polyline::_path.

◆ name()

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

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

Returns
objet name

Reimplemented from LibBoard::Rectangle.

Definition at line 633 of file Shapes.cpp.

634{
635 return _name;
636}
static const std::string _name

References _name.

Field Documentation

◆ _alpha

double LibBoard::Image::_alpha
protected

Definition at line 1076 of file Board/Shapes.h.

Referenced by flushCairo().

◆ _filename

std::string LibBoard::Image::_filename
protected

Definition at line 1075 of file Board/Shapes.h.

Referenced by flushCairo(), flushFIG(), flushSVG(), and flushTikZ().

◆ _height

double LibBoard::Image::_height
protected

Definition at line 1074 of file Board/Shapes.h.

◆ _name

const std::string LibBoard::Image::_name
staticprivate

The generic name of the shape.

Definition at line 1068 of file Board/Shapes.h.

Referenced by name().

◆ _width

double LibBoard::Image::_width
protected

Definition at line 1073 of file Board/Shapes.h.

◆ _x0

double LibBoard::Image::_x0
protected

First coordinate of the bottom left point.

Definition at line 1071 of file Board/Shapes.h.

◆ _y0

double LibBoard::Image::_y0
protected

Second coordinate of the bottom left point.

Definition at line 1072 of file Board/Shapes.h.


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