DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
testTickedColorMap.cpp
Go to the documentation of this file.
1
16
29
31
#include <iostream>
32
#include "DGtal/base/Common.h"
33
#include "ConfigTest.h"
34
#include "DGtal/helpers/StdDefs.h"
35
#include "DGtal/io/colormaps/TickedColorMap.h"
36
#include "DGtal/io/colormaps/HueShadeColorMap.h"
37
#include "DGtal/io/colormaps/GradientColorMap.h"
38
#include "DGtal/io/boards/Board2D.h"
40
41
using namespace
std
;
42
using namespace
DGtal
;
43
45
// Functions for testing class TickedColorMap.
47
51
bool
testTickedColorMap
()
52
{
53
unsigned
int
nbok = 0;
54
unsigned
int
nb = 0;
55
56
trace
.
beginBlock
(
"Testing TickedCMAP..."
);
57
58
TickedColorMap<double, HueShadeColorMap<double, 1>
> ticked(0.0,100.0);
59
60
ticked.
addTick
(5.0, 1.0);
61
ticked.
addTick
(9.0, 1.0);
62
ticked.
finalize
();
63
trace
.
info
()<<ticked<<std::endl;
64
65
Color
c = ticked(4.5);
66
nbok += (c ==
Color::White
) ? 1 : 0;
67
nb++;
68
trace
.
info
() <<
"("
<< nbok <<
"/"
<< nb <<
") "
69
<<
"c == white on tick inf.."
<< std::endl;
70
71
c = ticked(5.5);
72
nbok += (c ==
Color::White
) ? 1 : 0;
73
nb++;
74
trace
.
info
() <<
"("
<< nbok <<
"/"
<< nb <<
") "
75
<<
"c == white on tick sup.."
<< std::endl;
76
77
c = ticked(9.5);
78
nbok += (c ==
Color::White
) ? 1 : 0;
79
nb++;
80
trace
.
info
() <<
"("
<< nbok <<
"/"
<< nb <<
") "
81
<<
"c == white on tick sup.. "
<< std::endl;
82
83
c = ticked(8.5);
84
nbok += (c ==
Color::White
) ? 1 : 0;
85
nb++;
86
trace
.
info
() <<
"("
<< nbok <<
"/"
<< nb <<
") "
87
<<
"c == white on tick sup.. "
<< std::endl;
88
89
90
c = ticked(20.0);
91
nbok += (c !=
Color::White
) ? 1 : 0;
92
nb++;
93
trace
.
info
() <<
"("
<< nbok <<
"/"
<< nb <<
") "
94
<<
"c != white outside.. "
<< std::endl;
95
trace
.
endBlock
();
96
97
return
nbok == nb;
98
}
99
100
bool
testCMAP
()
101
{
102
Board2D
board;
103
TickedColorMap<double, HueShadeColorMap<double, 1>
> ticked(0.0,100.0);
104
ticked.
addTick
(5.0,1.2);
105
ticked.
addTick
(19.0,3);
106
ticked.
addTick
(69.0,3.0);
107
ticked.
finalize
();
108
trace
.
info
() << ticked<<std::endl;
109
Z2i::Point
p;
110
111
for
(
unsigned
int
i=0; i < 100; i++)
112
board<<
CustomStyle
(p.
className
(),
new
CustomColors
(ticked(i),ticked(i)))
113
<<
Z2i::Point
(i,0);
114
board.
saveEPS
(
"testTicked.eps"
);
115
116
board.
clear
();
117
TickedColorMap<double, HueShadeColorMap<double, 1>
> ticked2(0.0,100.0);
118
ticked2.
addRegularTicks
(10, 1.0);
119
ticked2.
finalize
();
120
for
(
unsigned
int
i=0; i < 100; i++)
121
board<<
CustomStyle
(p.
className
(),
new
CustomColors
(ticked2(i),ticked2(i)))
122
<<
Z2i::Point
(i,0);
123
board.
saveEPS
(
"testTicked-regular.eps"
);
124
125
//same with gradient colormap (and ticked.colormap() accessor)
126
board.
clear
();
127
TickedColorMap<double, GradientColorMap<double>
> ticked3(0.0,100.0);
128
ticked3.
addRegularTicks
(10, 1.0);
129
ticked3.
finalize
();
130
ticked3.
colormap
()->addColor(
Color::Black
);
131
ticked3.
colormap
()->addColor(
Color::Red
);
132
for
(
unsigned
int
i=0; i < 100; i++)
133
board<<
CustomStyle
(p.
className
(),
new
CustomColors
(ticked3(i),ticked3(i)))
134
<<
Z2i::Point
(i,0);
135
board.
saveEPS
(
"testTicked-gradient-regular.eps"
);
136
137
return
true
;
138
}
139
141
// Standard services - public :
142
143
int
main
(
int
argc,
char
** argv )
144
{
145
trace
.
beginBlock
(
"Testing class TickedColorMap"
);
146
trace
.
info
() <<
"Args:"
;
147
for
(
int
i = 0; i < argc; ++i )
148
trace
.
info
() <<
" "
<< argv[ i ];
149
trace
.
info
() << endl;
150
151
bool
res =
testTickedColorMap
() &&
testCMAP
();
// && ... other tests
152
trace
.
emphase
() << ( res ?
"Passed."
:
"Error."
) << endl;
153
trace
.
endBlock
();
154
return
res ? 0 : 1;
155
}
156
// //
DGtal::Board2D
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition
Board2D.h:71
DGtal::Color
Structure representing an RGB triple with alpha component.
Definition
Color.h:77
DGtal::Color::Red
static const Color Red
Definition
Color.h:425
DGtal::Color::Black
static const Color Black
Definition
Color.h:422
DGtal::Color::White
static const Color White
Definition
Color.h:424
DGtal::PointVector::className
std::string className() const
DGtal::TickedColorMap
Aim: This class adapts any colormap to add "ticks" in the colormap colors.
Definition
TickedColorMap.h:79
DGtal::TickedColorMap::addTick
void addTick(const Value position, const Value thickness)
DGtal::TickedColorMap::addRegularTicks
void addRegularTicks(const unsigned int nbTicks, const Value thickness)
DGtal::TickedColorMap::colormap
ColorMap * colormap() const
Definition
TickedColorMap.h:181
DGtal::TickedColorMap::finalize
void finalize()
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
DGtal::Trace::emphase
std::ostream & emphase()
DGtal::Trace::info
std::ostream & info()
DGtal::Trace::endBlock
double endBlock()
LibBoard::Board::clear
void clear(const DGtal::Color &color=DGtal::Color::None)
Definition
Board.cpp:151
LibBoard::Board::saveEPS
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition
Board.cpp:804
DGtal::Z2i::Point
Space::Point Point
Definition
StdDefs.h:95
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
DGtal::trace
Trace trace
std
STL namespace.
DGtal::CustomColors
Custom style class redefining the pen color and the fill color. You may use Board2D::Color::None for ...
Definition
Board2D.h:279
DGtal::CustomStyle::CustomStyle
CustomStyle(std::string classname, DrawableWithBoard2D *style)
Definition
Board2D.h:224
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
testCMAP
bool testCMAP()
Definition
testTickedColorMap.cpp:100
testTickedColorMap
bool testTickedColorMap()
Definition
testTickedColorMap.cpp:51
tests
io
colormaps
testTickedColorMap.cpp
Generated on
for DGtal by
1.18.0