DGtal  0.9.4beta
Public Member Functions | Protected Attributes | Static Private Attributes
LibBoard::Image Struct Reference

#include <Board/Shapes.h>

Inheritance diagram for LibBoard::Image:
[legend]
Collaboration diagram for LibBoard::Image:
[legend]

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)
 
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)
 
- 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)
 
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 flushPostscript (std::ostream &stream, const TransformEPS &transform) const
 
Rect boundingBox () 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 ()
 
bool filled () const
 
ShaperotateDeg (double angle, const Point &center)
 
ShaperotateDeg (double angle)
 
Rect bbox ()
 
Shapeoperator-- ()
 
Shapeoperator++ ()
 
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

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).

Referenced by clone().

Member Function Documentation

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

Return a copy of the shape.

Returns
copye of the shape.

Reimplemented from LibBoard::Rectangle.

Definition at line 640 of file Shapes.cpp.

References Image().

640  {
641  return new Image(*this);
642 }
Image(double x0, double y0, double width, double height, std::string fileName, int depthValue, double alpha=1.0)
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 687 of file Shapes.cpp.

References _alpha, _filename, LibBoard::Polyline::_path, LibBoard::Transform::mapX(), LibBoard::TransformCairo::mapY(), and LibBoard::Transform::scale().

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

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

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

References _filename, LibBoard::Polyline::_path, LibBoard::Transform::mapX(), LibBoard::TransformSVG::mapY(), and LibBoard::Transform::scale().

672 {
673 
674  stream << "<image x=\"" << transform.mapX( _path[0].x ) << '"'
675  << " y=\"" << transform.mapY( _path[0].y ) << '"'
676  << " width=\"" << transform.scale( (_path[1] - _path[0]).norm() ) << '"'
677  << " height=\"" << transform.scale( (_path[0] - _path[3]).norm() ) << '"'
678  << " xlink:href=\""<< _filename << "\" >" << std::endl
679  << " <title>My image</title>"<<std::endl
680  << " </image>" << std::endl;
681 
682 
683 }
std::string _filename
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 715 of file Shapes.cpp.

References _filename, LibBoard::Polyline::_path, LibBoard::Transform::mapX(), LibBoard::TransformSVG::mapY(), and LibBoard::Transform::scale().

718 {
719  stream << "\\node [below right=0pt] at ("
720  << transform.mapX( _path[0].x ) << "pt,"
721  << transform.mapY( _path[0].y ) << "pt) {\\pgfimage["
722  << "width=" << transform.scale( (_path[1] - _path[0]).norm() ) << "pt,"
723  << "height=" << transform.scale( (_path[0] - _path[3]).norm() ) << "pt,"
724  << "]{" << _filename << "}};" << std::endl;
725 }
std::string _filename
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 634 of file Shapes.cpp.

References _name.

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

Field Documentation

double LibBoard::Image::_alpha
protected

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

Referenced by flushCairo().

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

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

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

double LibBoard::Image::_height
protected

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

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().

double LibBoard::Image::_width
protected

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

double LibBoard::Image::_x0
protected

First coordinate of the bottom left point.

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

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: