DGtal  1.3.beta
Board2D.h
1 
17 #pragma once
18 
31 #if defined(Board2D_RECURSES)
32 #error Recursive header files inclusion detected in Board2D.h
33 #else // defined(Board2D_RECURSES)
34 
35 #define Board2D_RECURSES
36 
37 #if !defined Board2D_h
38 
39 #define Board2D_h
40 
42 // Inclusions
43 #include <iostream>
44 #include "Board/Board.h"
45 #include "DGtal/base/Common.h"
46 #include "DGtal/base/CountedPtr.h"
47 #include "DGtal/io/Color.h"
49 
50 
51 
52 namespace DGtal
53 {
57  enum DomainDrawMode { GRID = 0, PAVING = 1 };
58 
59 
61  // class Board2D
70  class Board2D : public LibBoard::Board
71  {
72  // ----------------------- local types ------------------------------
73  public:
78  typedef std::map< std::string,CountedPtr<DrawableWithBoard2D> > StyleMapping;
79 
84  typedef std::map< std::string, std::string > ModeMapping;
85 
87 
88  // ----------------------- Standard services ------------------------------
89  public:
90 
94  ~Board2D();
95 
101  Board2D( const Color & aBackgroundColor = Color::None );
102 
108  Board2D( const Board2D & other );
109 
115  Board2D & operator= ( const Board2D & other );
116 
124  std::string getMode( const std::string & objectName ) const;
125 
134  template <typename TDrawableWithBoard2D>
135  Board2D & operator<<( const TDrawableWithBoard2D & object );
136 
137 
138  // ----------------------- Interface --------------------------------------
139  public:
140 
145  void selfDisplay ( std::ostream & out ) const;
146 
151  bool isValid() const;
152 
153  // ------------------------- Public Datas ------------------------------
154  public:
166 
176  // ------------------------- Private Datas --------------------------------
177  private:
178 
179  }; // end of class Board2D
180 
181 
188  std::ostream&
189  operator<< ( std::ostream & out, const Board2D & object );
190 
197  std::string className() const
198  {
199  return "DrawWithBoardModifier";
200  }
201 
202  /*DrawableWithBoard2D* defaultStyle( std::string = "" ) const
203  {
204  return 0;
205  }*/
206 
207  /*virtual void setStyle( Board2D & ) const
208  {}*/
209  };
210 
211 
224  CustomStyle( std::string classname, DrawableWithBoard2D* style )
225  : myClassname( classname ), myStyle( style )
226  {}
227 
228  std::string className() const
229  {
230  return "CustomStyle";
231  }
232 
233  /*void setStyle( Board2D & board ) const
234  {
235  board.myStyles[ myClassname ] = myStyle;
236  }*/
237 
238  std::string myClassname;
240  };
241 
247  struct SetMode : public DrawWithBoardModifier {
254  SetMode( std::string classname, std::string mode )
255  : myClassname( classname ), myMode( mode )
256  {}
257 
258  /*void setStyle( Board2D & board ) const
259  {
260  board.myModes[ myClassname ] = myMode;
261  }*/
262 
263  std::string myClassname;
264  std::string myMode;
265  };
266 
279  {
282 
289  CustomColors( const Color & penColor,
290  const Color & fillColor )
291  : myPenColor( penColor ), myFillColor( fillColor )
292  {}
293 
294  virtual void setStyle( Board2D & aboard) const
295  {
296  aboard.setFillColor( myFillColor);
297  aboard.setPenColor( myPenColor );
298  }
299  };
300 
313  {
315 
321  CustomPenColor( const Color & penColor )
322  : myPenColor( penColor )
323  {}
324 
325  virtual void setStyle( Board2D & aboard) const
326  {
327  aboard.setPenColor( myPenColor );
328  }
329  };
330 
343  {
345 
351  CustomFillColor( const Color & fillColor )
352  : myFillColor( fillColor )
353  {}
354 
355  virtual void setStyle( Board2D & aboard) const
356  {
357  aboard.setFillColor( myFillColor );
358  }
359  };
360 
374  {
377  double myLineWidth;
381  int myDepth;
400  CustomPen( const Color & penColor,
401  const Color & fillColor,
402  double lineWidth = 1.0,
406  : myPenColor( penColor ), myFillColor( fillColor ),
407  myLineWidth( lineWidth ),
408  myLineStyle( lineStyle ), myLineCap ( lineCap ), myLineJoin( lineJoin )
409  {}
410 
411  virtual void setStyle( Board2D & aboard) const
412  {
413  aboard.setPenColor( myPenColor );
414  aboard.setFillColor( myFillColor );
415  aboard.setLineWidth( myLineWidth );
416  aboard.setLineStyle( myLineStyle );
417  aboard.setLineCap( myLineCap );
418  aboard.setLineJoin( myLineJoin );
419  }
420  };
421 
422 } // namespace DGtal
423 
424 
426 // Includes inline functions.
427 
428 #include "DGtal/io/Display2DFactory.h"
429 #include "DGtal/io/Style2DFactory.h"
430 #include "DGtal/io/boards/Board2D.ih"
431 
432 // //
434 
435 #endif // !defined Board2D_h
436 
437 #undef Board2D_RECURSES
438 #endif // else defined(Board2D_RECURSES)
DGtal::CustomPen::myFillColor
Color myFillColor
Definition: Board2D.h:376
DGtal::CustomStyle::myStyle
CountedPtr< DrawableWithBoard2D > myStyle
Definition: Board2D.h:239
DGtal::CustomStyle::className
std::string className() const
Definition: Board2D.h:228
DGtal::CustomFillColor::myFillColor
Color myFillColor
Definition: Board2D.h:344
DGtal::CustomPen::myLineStyle
Board2D::Shape::LineStyle myLineStyle
Definition: Board2D.h:378
DGtal::DomainDrawMode
DomainDrawMode
Definition: Board2D.h:57
LibBoard::Board::setPenColor
Board & setPenColor(const DGtal::Color &color)
Definition: Board.cpp:298
DGtal::CustomFillColor::setStyle
virtual void setStyle(Board2D &aboard) const
Definition: Board2D.h:355
LibBoard::Board::setLineCap
Board & setLineCap(Shape::LineCap cap)
DGtal::CustomPen::myPenColor
Color myPenColor
Definition: Board2D.h:375
DGtal::CustomColors::CustomColors
CustomColors(const Color &penColor, const Color &fillColor)
Definition: Board2D.h:289
DGtal::CustomPen::myLineWidth
double myLineWidth
Definition: Board2D.h:377
DGtal::CustomPen
Custom style class redefining the pen attributes. You may use Board2D::Color::None for transparent co...
Definition: Board2D.h:373
DGtal::Color
Structure representing an RGB triple with alpha component.
Definition: Color.h:66
LibBoard::Board
Class for EPS, FIG or SVG drawings.
Definition: Board.h:35
LibBoard::Shape::LineCap
LineCap
Definition: Board/Shapes.h:60
DGtal::CustomPenColor::myPenColor
Color myPenColor
Definition: Board2D.h:314
DGtal::Board2D::ModeMapping
std::map< std::string, std::string > ModeMapping
Definition: Board2D.h:84
DGtal::SetMode::myClassname
std::string myClassname
Definition: Board2D.h:263
DGtal::CustomPen::myDepth
int myDepth
Definition: Board2D.h:381
DGtal::Board2D::myStyles
StyleMapping myStyles
Definition: Board2D.h:165
DGtal::Board2D::myModes
ModeMapping myModes
Definition: Board2D.h:175
DGtal::Board2D::~Board2D
~Board2D()
Definition: Board2D.cpp:45
DGtal::Board2D::operator=
Board2D & operator=(const Board2D &other)
Definition: Board2D.cpp:78
LibBoard::Shape::MiterJoin
@ MiterJoin
Definition: Board/Shapes.h:61
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ATu0v1< TKSpace, TLinearAlgebra > &object)
DGtal::SetMode::myMode
std::string myMode
Definition: Board2D.h:264
DGtal::CustomPen::CustomPen
CustomPen(const Color &penColor, const Color &fillColor, double lineWidth=1.0, Board2D::Shape::LineStyle lineStyle=Board2D::Shape::SolidStyle, Board2D::Shape::LineCap lineCap=Board2D::Shape::ButtCap, Board2D::Shape::LineJoin lineJoin=Board2D::Shape::MiterJoin)
Definition: Board2D.h:400
LibBoard::Board::setLineStyle
Board & setLineStyle(Shape::LineStyle style)
DGtal::Board2D::StyleMapping
std::map< std::string, CountedPtr< DrawableWithBoard2D > > StyleMapping
Definition: Board2D.h:78
DGtal::CustomStyle
Definition: Board2D.h:217
DGtal::Board2D::operator<<
Board2D & operator<<(const TDrawableWithBoard2D &object)
LibBoard::Board::setLineJoin
Board & setLineJoin(Shape::LineJoin join)
DGtal::CustomFillColor
Custom style class redefining the fill color. You may use Board2D::Color::None for transparent color.
Definition: Board2D.h:342
LibBoard::Shape::SolidStyle
@ SolidStyle
Definition: Board/Shapes.h:62
DGtal::CustomStyle::CustomStyle
CustomStyle(std::string classname, DrawableWithBoard2D *style)
Definition: Board2D.h:224
LibBoard::Shape::LineJoin
LineJoin
Definition: Board/Shapes.h:61
DGtal::CustomPenColor::setStyle
virtual void setStyle(Board2D &aboard) const
Definition: Board2D.h:325
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::PAVING
@ PAVING
Definition: Board2D.h:57
DGtal::Board2D::Board2D
Board2D(const Color &aBackgroundColor=Color::None)
Definition: Board2D.cpp:54
DGtal::CustomFillColor::CustomFillColor
CustomFillColor(const Color &fillColor)
Definition: Board2D.h:351
LibBoard::Shape
Abstract structure for a 2D shape.
Definition: Board/Shapes.h:58
DGtal::CustomColors
Custom style class redefining the pen color and the fill color. You may use Board2D::Color::None for ...
Definition: Board2D.h:278
DGtal::Board2D::selfDisplay
void selfDisplay(std::ostream &out) const
Definition: Board2D.cpp:97
DGtal::CountedPtr< DrawableWithBoard2D >
DGtal::CustomPen::myLineJoin
Board2D::Shape::LineJoin myLineJoin
Definition: Board2D.h:380
DGtal::CustomPen::setStyle
virtual void setStyle(Board2D &aboard) const
Definition: Board2D.h:411
DGtal::DrawableWithBoard2D
Definition: Common.h:221
DGtal::Board2D::isValid
bool isValid() const
Definition: Board2D.cpp:107
DGtal::Board2D
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition: Board2D.h:70
DGtal::CustomColors::myPenColor
Color myPenColor
Definition: Board2D.h:280
DGtal::Board2D::getMode
std::string getMode(const std::string &objectName) const
DGtal::CustomColors::setStyle
virtual void setStyle(Board2D &aboard) const
Definition: Board2D.h:294
LibBoard::Shape::ButtCap
@ ButtCap
Definition: Board/Shapes.h:60
LibBoard::Shape::LineStyle
LineStyle
Definition: Board/Shapes.h:62
DGtal::SetMode
Modifier class in a Board2D stream. Useful to choose your own mode for a given class....
Definition: Board2D.h:247
DGtal::Color::None
static const Color None
Definition: Color.h:388
LibBoard::Board::setFillColor
Board & setFillColor(const DGtal::Color &color)
Definition: Board.cpp:322
DGtal::DrawWithBoardModifier::className
std::string className() const
Definition: Board2D.h:197
LibBoard::Board::setLineWidth
Board & setLineWidth(double width)
Definition: Board.cpp:329
DGtal::Board2D::Shape
LibBoard::Shape Shape
Definition: Board2D.h:86
DGtal::CustomPenColor::CustomPenColor
CustomPenColor(const Color &penColor)
Definition: Board2D.h:321
DGtal::CustomPenColor
Custom style class redefining the pen color. You may use Board2D::Color::None for transparent color.
Definition: Board2D.h:312
DGtal::CustomColors::myFillColor
Color myFillColor
Definition: Board2D.h:281
DGtal::SetMode::SetMode
SetMode(std::string classname, std::string mode)
Definition: Board2D.h:254
DGtal::CustomPen::myLineCap
Board2D::Shape::LineCap myLineCap
Definition: Board2D.h:379
DGtal::GRID
@ GRID
Definition: Board2D.h:57
DGtal::CustomStyle::myClassname
std::string myClassname
Definition: Board2D.h:238
DGtal::DrawWithBoardModifier
Definition: Board2D.h:196