DGtal 1.3.0
Loading...
Searching...
No Matches
Functions
testTickedColorMap.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "ConfigTest.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/io/colormaps/TickedColorMap.h"
#include "DGtal/io/colormaps/HueShadeColorMap.h"
#include "DGtal/io/colormaps/GradientColorMap.h"
#include "DGtal/io/boards/Board2D.h"

Go to the source code of this file.

Functions

bool testTickedColorMap ()
 
bool testCMAP ()
 
int main (int argc, char **argv)
 

Detailed Description

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
David Coeurjolly (david.nosp@m..coe.nosp@m.urjol.nosp@m.ly@l.nosp@m.iris..nosp@m.cnrs.nosp@m..fr ) Laboratoire d'InfoRmatique en Image et Systemes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
Date
2015/04/04

Functions for testing class TickedColorMap.

This file is part of the DGtal library.

Definition in file testTickedColorMap.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 143 of file testTickedColorMap.cpp.

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}
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
std::ostream & info()
double endBlock()
Trace trace
Definition: Common.h:154
bool testCMAP()
bool testTickedColorMap()

References DGtal::Trace::beginBlock(), DGtal::Trace::emphase(), DGtal::Trace::endBlock(), DGtal::Trace::info(), testCMAP(), testTickedColorMap(), and DGtal::trace.

◆ testCMAP()

bool testCMAP ( )

Definition at line 100 of file testTickedColorMap.cpp.

101{
102 Board2D board;
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();
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();
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}
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition: Board2D.h:71
static const Color Red
Definition: Color.h:416
static const Color Black
Definition: Color.h:413
Aim: This class adapts any colormap to add "ticks" in the colormap colors.
void clear(const DGtal::Color &color=DGtal::Color::None)
Definition: Board.cpp:152
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:805
Space::Point Point
Definition: StdDefs.h:95
Custom style class redefining the pen color and the fill color. You may use Board2D::Color::None for ...
Definition: Board2D.h:279

References DGtal::TickedColorMap< TValue, TColorMap >::addRegularTicks(), DGtal::TickedColorMap< TValue, TColorMap >::addTick(), DGtal::Color::Black, LibBoard::Board::clear(), DGtal::TickedColorMap< TValue, TColorMap >::colormap(), DGtal::TickedColorMap< TValue, TColorMap >::finalize(), DGtal::Trace::info(), DGtal::Color::Red, LibBoard::Board::saveEPS(), and DGtal::trace.

Referenced by main().

◆ testTickedColorMap()

bool testTickedColorMap ( )

Example of a test. To be completed.

Definition at line 51 of file testTickedColorMap.cpp.

52{
53 unsigned int nbok = 0;
54 unsigned int nb = 0;
55
56 trace.beginBlock ( "Testing TickedCMAP..." );
57
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;
96
97 return nbok == nb;
98}
Structure representing an RGB triple with alpha component.
Definition: Color.h:68
static const Color White
Definition: Color.h:415

References DGtal::TickedColorMap< TValue, TColorMap >::addTick(), DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::TickedColorMap< TValue, TColorMap >::finalize(), DGtal::Trace::info(), DGtal::trace, and DGtal::Color::White.

Referenced by main().