39 #include <visp3/core/vpConfig.h> 41 #if defined(VISP_HAVE_DISPLAY) 45 #include <visp3/core/vpMath.h> 46 #include <visp3/core/vpMeterPixelConversion.h> 47 #include <visp3/core/vpPixelMeterConversion.h> 48 #include <visp3/gui/vpDisplayD3D.h> 49 #include <visp3/gui/vpDisplayGDI.h> 50 #include <visp3/gui/vpDisplayGTK.h> 51 #include <visp3/gui/vpDisplayOpenCV.h> 52 #include <visp3/gui/vpDisplayX.h> 53 #include <visp3/gui/vpPlot.h> 61 vpPlot::vpPlot() : I(), display(NULL), graphNbr(1), graphList(NULL), margei(30), margej(40), factori(1.f), factorj(1.)
81 vpPlot::vpPlot(
unsigned int graph_nbr,
unsigned int height,
unsigned int width,
int x,
82 int y,
const std::string &title)
83 :
I(), display(NULL), graphNbr(1), graphList(NULL), margei(30), margej(40), factori(1.f), factorj(1.)
85 init(graph_nbr, height, width, x, y, title);
100 void vpPlot::init(
unsigned int graph_nbr,
unsigned int height,
unsigned int width,
int x,
101 int y,
const std::string &title)
103 I.
init(height, width, 255);
105 #if defined VISP_HAVE_X11 107 #elif defined VISP_HAVE_GDI 109 #elif defined VISP_HAVE_OPENCV 111 #elif defined VISP_HAVE_GTK 113 #elif defined VISP_HAVE_D3D9 117 display->init(
I, x, y, title.c_str());
121 factori = height / 700.0f;
122 factorj = width / 700.0f;
124 initNbGraph(graph_nbr);
132 if (graphList != NULL) {
136 if (display != NULL) {
151 void vpPlot::initNbGraph(
unsigned int nbGraph)
156 graphList =
new vpPlotGraph[nbGraph];
161 graphList[0].initSize(
vpImagePoint(0, 0), (
unsigned int)(700 * factorj), (
unsigned int)(700 * factori), margei,
165 graphList[0].initSize(
vpImagePoint(0, 0), (
unsigned int)(700 * factorj), (
unsigned int)(350 * factori), margei,
167 graphList[1].initSize(
vpImagePoint((
unsigned int)(350 * factori), 0), (
unsigned int)(700 * factorj),
168 (
unsigned int)(350 * factori), margei, margej);
171 graphList[0].initSize(
vpImagePoint(0, 0), (
unsigned int)(350 * factorj), (
unsigned int)(350 * factori), margei,
173 graphList[1].initSize(
vpImagePoint(0, (
unsigned int)(350 * factorj)), (
unsigned int)(350 * factorj),
174 (
unsigned int)(350 * factori), margei, margej);
175 graphList[2].initSize(
vpImagePoint((
unsigned int)(350 * factori), 0), (
unsigned int)(700 * factorj),
176 (
unsigned int)(350 * factori), margei, margej);
179 graphList[0].initSize(
vpImagePoint(0, 0), (
unsigned int)(350 * factorj), (
unsigned int)(350 * factori), margei,
181 graphList[1].initSize(
vpImagePoint(0, (
unsigned int)(350 * factorj)), (
unsigned int)(350 * factorj),
182 (
unsigned int)(350 * factori), margei, margej);
183 graphList[2].initSize(
vpImagePoint((
unsigned int)(350 * factori), 0), (
unsigned int)(350 * factorj),
184 (
unsigned int)(350 * factori), margei, margej);
185 graphList[3].initSize(
vpImagePoint((
unsigned int)(350 * factori), (
unsigned int)(350 * factorj)),
186 (
unsigned int)(350 * factorj), (
unsigned int)(350 * factori), margei, margej);
190 for (
unsigned int i = 0; i < graphNbr; i++) {
191 graphList[i].title.clear();
192 graphList[i].unitx.clear();
193 graphList[i].unity.clear();
194 graphList[i].unitz.clear();
228 void vpPlot::initRange(
unsigned int graphNum,
double xmin,
double xmax,
double ymin,
double ymax)
230 (graphList + graphNum)->initScale(
I, xmin, xmax, 10, ymin, ymax, 10,
true,
true);
247 void vpPlot::initRange(
unsigned int graphNum,
double xmin,
double xmax,
double ymin,
double ymax,
double zmin,
250 (graphList + graphNum)->initScale(
I, xmin, xmax, 10, ymin, ymax, 10, zmin, zmax, 10,
true,
true);
263 (graphList + graphNum)->setCurveColor(curveNum, color);
269 void vpPlot::displayGrid()
271 for (
unsigned int i = 0; i < graphNbr; i++)
272 graphList[i].displayGrid(
I);
286 void vpPlot::plot(
unsigned int graphNum,
unsigned int curveNum,
double x,
double y)
288 (graphList + graphNum)->
plot(
I, curveNum, x, y);
304 if ((graphList + graphNum)->curveNbr == v_y.
getRows()) {
305 for (
unsigned int i = 0; i < v_y.
getRows(); ++i)
306 this->
plot(graphNum, i, x, v_y[i]);
308 vpTRACE(
"error in plot vector : not the right dimension");
323 if ((graphList + graphNum)->curveNbr == v_y.
getRows()) {
324 for (
unsigned int i = 0; i < v_y.
getRows(); ++i)
325 this->
plot(graphNum, i, x, v_y[i]);
327 vpTRACE(
"error in plot vector : not the right dimension");
343 if ((graphList + graphNum)->curveNbr == v_y.
getRows()) {
344 for (
unsigned int i = 0; i < v_y.
getRows(); ++i)
345 this->
plot(graphNum, i, x, v_y[i]);
347 vpTRACE(
"error in plot vector : not the right dimension");
362 if ((graphList + graphNum)->curveNbr == v_y.
getRows()) {
363 for (
unsigned int i = 0; i < v_y.
getRows(); ++i)
364 this->
plot(graphNum, i, x, v_y[i]);
366 vpTRACE(
"error in plot vector : not the right dimension");
382 if ((graphList + graphNum)->curveNbr == v_y.
size()) {
383 for (
unsigned int i = 0; i < v_y.
size(); ++i)
384 this->
plot(graphNum, i, x, v_y[i]);
386 vpTRACE(
"error in plot vector : not the right dimension");
405 return (graphList + graphNum)->plot(
I, curveNum, x, y, z);
424 if ((graphList + graphNum)->curveNbr == v_y.
getRows() && (graphList + graphNum)->curveNbr == v_z.
getRows()) {
425 for (
unsigned int i = 0; i < v_y.
getRows(); ++i)
426 button = this->
plot(graphNum, i, x, v_y[i], v_z[i]);
428 vpTRACE(
"error in plot vector : not the right dimension");
443 bool blocked =
false;
444 unsigned int iblocked = 0;
450 for (
unsigned int i = 0; i < graphNbr; i++) {
456 if ((graphList + iblocked)->move(
I, b)) {
457 (graphList + iblocked)->replot3D(
I);
459 blocked = (graphList + iblocked)->blocked;
461 if ((graphList + iblocked)->move(
I, b)) {
462 (graphList + iblocked)->replot3D(
I);
464 blocked = (graphList + iblocked)->blocked;
485 for (
unsigned int i = 0; i < graphNbr; i++) {
500 (graphList + graphNum)->
setTitle(title);
512 (graphList + graphNum)->
setUnitX(unitx);
524 (graphList + graphNum)->
setUnitY(unity);
536 (graphList + graphNum)->
setUnitZ(unitz);
549 (graphList + graphNum)->
setLegend(curveNum, legend);
562 for (
unsigned int i = 0; i < (graphList + graphNum)->curveNbr; i++)
563 (graphList + graphNum)->resetPointList(i);
576 (graphList + graphNum)->setCurveThickness(curveNum, thickness);
589 for (
unsigned int curveNum = 0; curveNum < (graphList + graphNum)->curveNbr; curveNum++)
590 (graphList + graphNum)->setCurveThickness(curveNum, thickness);
646 void vpPlot::saveData(
unsigned int graphNum,
const std::string &dataFile,
const std::string &title_prefix)
648 std::ofstream fichier;
649 fichier.open(dataFile.c_str());
652 double *p =
new double[3];
655 std::vector<std::list<double>::const_iterator> vec_iter_pointListx((graphList + graphNum)->curveNbr);
656 std::vector<std::list<double>::const_iterator> vec_iter_pointListy((graphList + graphNum)->curveNbr);
657 std::vector<std::list<double>::const_iterator> vec_iter_pointListz((graphList + graphNum)->curveNbr);
659 fichier << title_prefix << (graphList + graphNum)->title << std::endl;
661 for (ind = 0; ind < (graphList + graphNum)->curveNbr; ind++) {
662 vec_iter_pointListx[ind] = (graphList + graphNum)->curveList[ind].pointListx.begin();
663 vec_iter_pointListy[ind] = (graphList + graphNum)->curveList[ind].pointListy.begin();
664 vec_iter_pointListz[ind] = (graphList + graphNum)->curveList[ind].pointListz.begin();
670 while (end ==
false) {
672 for (ind = 0; ind < (graphList + graphNum)->curveNbr; ind++) {
678 if ((vec_iter_pointListx[ind] != (graphList + graphNum)->curveList[ind].pointListx.end()) &&
679 (vec_iter_pointListy[ind] != (graphList + graphNum)->curveList[ind].pointListy.end()) &&
680 (vec_iter_pointListz[ind] != (graphList + graphNum)->curveList[ind].pointListz.end())) {
681 p[0] = *vec_iter_pointListx[ind];
682 p[1] = *vec_iter_pointListy[ind];
683 p[2] = *vec_iter_pointListz[ind];
691 fichier << p[0] <<
"\t" << p[1] <<
"\t" << p[2] <<
"\t";
692 ++vec_iter_pointListx[ind];
693 ++vec_iter_pointListy[ind];
694 ++vec_iter_pointListz[ind];
703 if ((vec_iter_pointListx[ind] != (graphList + graphNum)->curveList[ind].pointListx.end()) &&
704 (vec_iter_pointListy[ind] != (graphList + graphNum)->curveList[ind].pointListy.end()) &&
705 (vec_iter_pointListz[ind] != (graphList + graphNum)->curveList[ind].pointListz.end()))
714 p[0] = (graphList + graphNum)->curveList[ind].pointListx.back();
715 p[1] = (graphList + graphNum)->curveList[ind].pointListy.back();
716 p[2] = (graphList + graphNum)->curveList[ind].pointListz.back();
717 fichier << p[0] <<
"\t" << p[1] <<
"\t" << p[2] <<
"\t";
720 fichier << std::endl;
727 #elif !defined(VISP_BUILD_SHARED_LIBS) 729 void dummy_vpPlot(){};
Implementation of a generic rotation vector.
bool inRectangle(const vpRect &rect) const
static bool getPointerPosition(const vpImage< unsigned char > &I, vpImagePoint &ip)
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
vpImage< unsigned char > I
void getPixelValue(bool block)
Implementation of row vector and the associated operations.
void init(unsigned int nbGraph, unsigned int height=700, unsigned int width=700, int x=-1, int y=-1, const std::string &title="")
Display for windows using GDI (available on any windows 32 platform).
Class to define RGB colors available for display functionnalities.
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
error that can be emited by ViSP classes.
unsigned int size() const
Return the number of elements of the 2D array.
void setUnitX(unsigned int graphNum, const std::string &unitx)
void setLegend(unsigned int graphNum, unsigned int curveNum, const std::string &legend)
void initRange(unsigned int graphNum, double xmin, double xmax, double ymin, double ymax)
void setThickness(unsigned int graphNum, unsigned int curveNum, unsigned int thickness)
Display for windows using Direct3D 3rd party. Thus to enable this class Direct3D should be installed...
void saveData(unsigned int graphNum, const std::string &dataFile, const std::string &title_prefix="")
static void display(const vpImage< unsigned char > &I)
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
VISP_EXPORT void sleepMs(double t)
void setTitle(unsigned int graphNum, const std::string &title)
The vpDisplayGTK allows to display image using the GTK 3rd party library. Thus to enable this class G...
void setUnitZ(unsigned int graphNum, const std::string &unitz)
void init(unsigned int height, unsigned int width)
Set the size of the image.
void plot(unsigned int graphNum, unsigned int curveNum, double x, double y)
unsigned int getRows() const
void setGridThickness(unsigned int graphNum, unsigned int thickness)
void setUnitY(unsigned int graphNum, const std::string &unity)
void initGraph(unsigned int graphNum, unsigned int curveNbr)
Implementation of column vector and the associated operations.
Implementation of a pose vector and operations on poses.
void setGraphThickness(unsigned int graphNum, unsigned int thickness)
void resetPointList(unsigned int graphNum)
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
void setColor(unsigned int graphNum, unsigned int curveNum, vpColor color)
Class that consider the case of a translation vector.