DGtal 1.3.0
Loading...
Searching...
No Matches
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)
35#define Board2D_RECURSES
36
37#if !defined Board2D_h
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
52namespace 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
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 {
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)
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition: Board2D.h:71
std::map< std::string, std::string > ModeMapping
Definition: Board2D.h:84
std::string getMode(const std::string &objectName) const
bool isValid() const
Definition: Board2D.cpp:107
void selfDisplay(std::ostream &out) const
Definition: Board2D.cpp:97
Board2D & operator<<(const TDrawableWithBoard2D &object)
LibBoard::Shape Shape
Definition: Board2D.h:86
std::map< std::string, CountedPtr< DrawableWithBoard2D > > StyleMapping
Definition: Board2D.h:78
Board2D & operator=(const Board2D &other)
Definition: Board2D.cpp:78
StyleMapping myStyles
Definition: Board2D.h:165
ModeMapping myModes
Definition: Board2D.h:175
Structure representing an RGB triple with alpha component.
Definition: Color.h:68
static const Color None
Definition: Color.h:412
Aim: Smart pointer based on reference counts.
Definition: CountedPtr.h:80
Class for EPS, FIG or SVG drawings.
Definition: Board.h:35
Board & setPenColor(const DGtal::Color &color)
Definition: Board.cpp:298
Board & setLineCap(Shape::LineCap cap)
Board & setLineJoin(Shape::LineJoin join)
Board & setFillColor(const DGtal::Color &color)
Definition: Board.cpp:322
Board & setLineWidth(double width)
Definition: Board.cpp:329
Board & setLineStyle(Shape::LineStyle style)
DGtal is the top-level namespace which contains all DGtal functions and types.
DomainDrawMode
Definition: Board2D.h:57
@ GRID
Definition: Board2D.h:57
@ PAVING
Definition: Board2D.h:57
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
Custom style class redefining the pen color and the fill color. You may use Board2D::Color::None for ...
Definition: Board2D.h:279
virtual void setStyle(Board2D &aboard) const
Definition: Board2D.h:294
CustomColors(const Color &penColor, const Color &fillColor)
Definition: Board2D.h:289
Custom style class redefining the fill color. You may use Board2D::Color::None for transparent color.
Definition: Board2D.h:343
virtual void setStyle(Board2D &aboard) const
Definition: Board2D.h:355
CustomFillColor(const Color &fillColor)
Definition: Board2D.h:351
Custom style class redefining the pen color. You may use Board2D::Color::None for transparent color.
Definition: Board2D.h:313
CustomPenColor(const Color &penColor)
Definition: Board2D.h:321
virtual void setStyle(Board2D &aboard) const
Definition: Board2D.h:325
Custom style class redefining the pen attributes. You may use Board2D::Color::None for transparent co...
Definition: Board2D.h:374
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
Color myFillColor
Definition: Board2D.h:376
Board2D::Shape::LineStyle myLineStyle
Definition: Board2D.h:378
Board2D::Shape::LineJoin myLineJoin
Definition: Board2D.h:380
Color myPenColor
Definition: Board2D.h:375
virtual void setStyle(Board2D &aboard) const
Definition: Board2D.h:411
Board2D::Shape::LineCap myLineCap
Definition: Board2D.h:379
double myLineWidth
Definition: Board2D.h:377
std::string myClassname
Definition: Board2D.h:238
std::string className() const
Definition: Board2D.h:228
CountedPtr< DrawableWithBoard2D > myStyle
Definition: Board2D.h:239
CustomStyle(std::string classname, DrawableWithBoard2D *style)
Definition: Board2D.h:224
std::string className() const
Definition: Board2D.h:197
Modifier class in a Board2D stream. Useful to choose your own mode for a given class....
Definition: Board2D.h:247
std::string myMode
Definition: Board2D.h:264
std::string myClassname
Definition: Board2D.h:263
SetMode(std::string classname, std::string mode)
Definition: Board2D.h:254
Abstract structure for a 2D shape.
Definition: Board/Shapes.h:58