DGtal 1.4.0
Loading...
Searching...
No Matches
testBoard2DCustomStyle.cpp
Go to the documentation of this file.
1
31#include <iostream>
32#include "DGtal/base/Common.h"
33
34#include "DGtal/kernel/SpaceND.h"
35#include "DGtal/kernel/domains/HyperRectDomain.h"
36#include "DGtal/kernel/sets/DigitalSetBySTLVector.h"
37#include "DGtal/kernel/sets/DigitalSetBySTLSet.h"
38#include "DGtal/kernel/sets/DigitalSetSelector.h"
39#include "DGtal/io/boards/Board2D.h"
40
42
43using namespace std;
44using namespace DGtal;
45
46
47
51struct MyDrawStyleCustomGreen : public DrawableWithBoard2D
52{
53 virtual void setStyle( DGtal::Board2D & aBoard ) const
54 {
55 aBoard.setFillColorRGBi(0,160,0);
56 aBoard.setPenColorRGBi(80,0,0);
57 }
58};
59
61// Functions for testing class Board2DCustomStyle.
63
68{
69 unsigned int nbok = 0;
70 unsigned int nb = 0;
71
72 typedef SpaceND<2> Z2;
73
75 typedef Z2::Point Point;
76 Point p1( -10, -10 );
77 Point p2( 10, 10 );
78 Domain domain( p1, p2 );
79 typedef DigitalSetSelector
80 < Domain, BIG_DS + HIGH_ITER_DS + HIGH_BEL_DS >::Type SpecificSet;
81 SpecificSet mySet( domain );
82
83 Point c( 0, 0 );
84 mySet.insert( c );
85 Point d( 5, 2 );
86 mySet.insert( d );
87 Point e( 1, -3 );
88 mySet.insert( e );
89
90
91 Board2D board;
93
94 board << SetMode( domain.className(), "Grid" ) << domain
95 << domain
96 << mySet;
97 board.saveSVG("testcustom-prev.svg");
98
99 board.clear();
100
101 board << SetMode( domain.className(), "Grid" ) << domain
102 << domain
103 << CustomStyle( mySet.className(), new MyDrawStyleCustomGreen )
104 << mySet;
105 board.saveSVG("testcustom-next.svg");
106
107
108 return nbok == nb;
109}
110
112// Standard services - public :
113
114int main( int argc, char** argv )
115{
116 trace.beginBlock ( "Testing class Board2DCustomStyle" );
117 trace.info() << "Args:";
118 for ( int i = 0; i < argc; ++i )
119 trace.info() << " " << argv[ i ];
120 trace.info() << endl;
121
122 bool res = testBoard2DCustomStyle(); // && ... other tests
123 trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
124 trace.endBlock();
125 return res ? 0 : 1;
126}
127// //
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition Board2D.h:71
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
std::string className() const
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
std::ostream & info()
double endBlock()
Board & setPenColorRGBi(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha=255)
Definition Board.cpp:277
void clear(const DGtal::Color &color=DGtal::Color::None)
Definition Board.cpp:151
Board & setFillColorRGBi(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha=255)
Definition Board.cpp:304
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition Board.cpp:1011
void setUnit(Unit unit)
Definition Board.cpp:239
DGtal is the top-level namespace which contains all DGtal functions and types.
Trace trace
Definition Common.h:153
STL namespace.
Aim: Automatically defines an adequate digital set type according to the hints given by the user.
Modifier class in a Board2D stream. Useful to choose your own mode for a given class....
Definition Board2D.h:247
int main()
Definition testBits.cpp:56
bool testBoard2DCustomStyle()
MyPointD Point
Domain domain
HyperRectDomain< Space > Domain