44 #include <visp/vpConfig.h>
46 #if defined(VISP_HAVE_DISPLAY)
47 #include <visp/vpPlot.h>
48 #include <visp/vpDisplayOpenCV.h>
49 #include <visp/vpDisplayX.h>
50 #include <visp/vpDisplayGDI.h>
51 #include <visp/vpDisplayGTK.h>
52 #include <visp/vpDisplayD3D.h>
53 #include <visp/vpMath.h>
54 #include <visp/vpMeterPixelConversion.h>
55 #include <visp/vpPixelMeterConversion.h>
56 #include <visp/vpPose.h>
67 vpPlot::vpPlot() : I(), display(NULL), graphNbr(1), graphList(NULL), margei(30), margej(40),
68 factori(1.f), factorj(1.)
88 const unsigned int height,
const unsigned int width,
89 const int x,
const int y,
const char *title)
90 : I(), display(NULL), graphNbr(1), graphList(NULL), margei(30), margej(40),
91 factori(1.f), factorj(1.)
93 init(graph_nbr, height, width, x, y, title);
109 const unsigned int height,
const unsigned int width,
110 const int x,
const int y,
const char *title)
112 I.
init(height,width,255);
114 #if defined VISP_HAVE_X11
116 #elif defined VISP_HAVE_GDI
118 #elif defined VISP_HAVE_OPENCV
120 #elif defined VISP_HAVE_GTK
122 #elif defined VISP_HAVE_D3D9
126 display->
init(
I, x, y, title);
130 factori = height/700.0f;
131 factorj = width/700.0f;
133 initNbGraph(graph_nbr);
141 if (graphList != NULL)
162 vpPlot::initNbGraph (
unsigned int nbGraph)
167 graphList =
new vpPlotGraph[nbGraph];
173 graphList[0].initSize(
vpImagePoint(0,0), (
unsigned int)(700*factorj),(
unsigned int)(700*factori),margei,margej);
176 graphList[0].initSize(
vpImagePoint(0,0),(
unsigned int)(700*factorj),(
unsigned int)(350*factori),margei,margej);
177 graphList[1].initSize(
vpImagePoint((
unsigned int)(350*factori),0),(
unsigned int)(700*factorj),(
unsigned int)(350*factori),margei,margej);
180 graphList[0].initSize(
vpImagePoint(0,0),(
unsigned int)(350*factorj),(
unsigned int)(350*factori),margei,margej);
181 graphList[1].initSize(
vpImagePoint(0,(
unsigned int)(350*factorj)),(
unsigned int)(350*factorj),(
unsigned int)(350*factori),margei,margej);
182 graphList[2].initSize(
vpImagePoint((
unsigned int)(350*factori),0),(
unsigned int)(700*factorj),(
unsigned int)(350*factori),margei,margej);
185 graphList[0].initSize(
vpImagePoint(0,0),(
unsigned int)(350*factorj),(
unsigned int)(350*factori),margei,margej);
186 graphList[1].initSize(
vpImagePoint(0,(
unsigned int)(350*factorj)),(
unsigned int)(350*factorj),(
unsigned int)(350*factori),margei,margej);
187 graphList[2].initSize(
vpImagePoint((
unsigned int)(350*factori),0),(
unsigned int)(350*factorj),(
unsigned int)(350*factori),margei,margej);
188 graphList[3].initSize(
vpImagePoint((
unsigned int)(350*factori),(
unsigned int)(350*factorj)),(
unsigned int)(350*factorj),(
unsigned int)(350*factori),margei,margej);
192 for (
unsigned int i = 0; i < graphNbr; i++)
194 strcpy(graphList[i].title,
"");
195 strcpy(graphList[i].unitx,
"");
196 strcpy(graphList[i].unity,
"");
197 strcpy(graphList[i].unitz,
"");
210 (graphList+graphNum)->
initGraph(curveNbr);
234 double xmin,
double xmax,
235 double ymin,
double ymax)
237 (graphList+graphNum)->initScale(
I,xmin,xmax,10,ymin,ymax,10,
true,
true);
253 double xmin,
double xmax,
double ymin,
254 double ymax,
double zmin,
double zmax)
256 (graphList+graphNum)->initScale(
I,xmin,xmax,10,ymin,ymax,10,zmin,zmax,10,
true,
true);
269 (graphList+graphNum)->setCurveColor(curveNum, color);
276 vpPlot::displayGrid()
278 for (
unsigned int i = 0; i < graphNbr; i++)
279 graphList[i].displayGrid(
I);
291 vpPlot::plot (
const unsigned int graphNum,
const unsigned int curveNum,
const double x,
const double y)
293 (graphList+graphNum)->
plot(
I,curveNum,x,y);
306 if((graphList+graphNum)->curveNbr == v_y.
getRows())
308 for(
unsigned int i = 0;i < v_y.
getRows();++i)
309 this->
plot(graphNum, i, x, v_y[i]);
312 vpTRACE(
"error in plot vector : not the right dimension");
326 vpPlot::plot (
const unsigned int graphNum,
const unsigned int curveNum,
const double x,
const double y,
const double z)
328 (graphList+graphNum)->
plot(
I,curveNum,x,y,z);
341 if((graphList+graphNum)->curveNbr == v_y.
getRows() && (graphList+graphNum)->curveNbr == v_z.
getRows())
343 for(
unsigned int i = 0;i < v_y.
getRows();++i)
344 this->
plot(graphNum, i, x, v_y[i], v_z[i]);
347 vpTRACE(
"error in plot vector : not the right dimension");
358 bool blocked =
false;
359 unsigned int iblocked = 0;
367 for (
unsigned int i = 0; i < graphNbr ; i++)
375 if ((graphList+iblocked)->move(
I))
377 (graphList+iblocked)->replot3D(
I);
380 blocked = (graphList+iblocked)->blocked;
384 if ((graphList+iblocked)->move(
I))
386 (graphList+iblocked)->replot3D(
I);
388 blocked = (graphList+iblocked)->blocked;
408 for (
unsigned int i = 0; i < graphNbr; i++)
423 (graphList+graphNum)->
setTitle(title);
435 (graphList+graphNum)->
setUnitX(unitx);
447 (graphList+graphNum)->
setUnitY(unity);
459 (graphList+graphNum)->
setUnitZ(unitz);
470 vpPlot::setLegend (
const unsigned int graphNum,
const unsigned int curveNum,
const char *legend)
472 (graphList+graphNum)->
setLegend(curveNum, legend);
483 for (
unsigned int i = 0; i < (graphList+graphNum)->curveNbr; i++)
484 (graphList+graphNum)->resetPointList(i);
497 (graphList+graphNum)->setCurveThickness(curveNum, thickness);
509 for (
unsigned int curveNum=0; curveNum < (graphList+graphNum)->curveNbr; curveNum++)
510 (graphList+graphNum)->setCurveThickness(curveNum, thickness);
555 std::ofstream fichier;
556 fichier.open(dataFile);
559 double *p =
new double[3];
562 std::vector< std::list<double>::const_iterator > vec_iter_pointListx((graphList+graphNum)->curveNbr);
563 std::vector< std::list<double>::const_iterator > vec_iter_pointListy((graphList+graphNum)->curveNbr);
564 std::vector< std::list<double>::const_iterator > vec_iter_pointListz((graphList+graphNum)->curveNbr);
566 fichier << (graphList+graphNum)->title << std::endl;
568 for(ind=0;ind<(graphList+graphNum)->curveNbr;ind++)
570 vec_iter_pointListx[ind] = (graphList+graphNum)->curveList[ind].pointListx.begin();
571 vec_iter_pointListy[ind] = (graphList+graphNum)->curveList[ind].pointListy.begin();
572 vec_iter_pointListz[ind] = (graphList+graphNum)->curveList[ind].pointListz.begin();
581 for(ind=0;ind<(graphList+graphNum)->curveNbr;ind++)
586 if((vec_iter_pointListx[ind] != (graphList+graphNum)->curveList[ind].pointListx.end())
587 && (vec_iter_pointListy[ind] != (graphList+graphNum)->curveList[ind].pointListy.end())
588 && (vec_iter_pointListz[ind] != (graphList+graphNum)->curveList[ind].pointListz.end()))
590 p[0] = *vec_iter_pointListx[ind];
591 p[1] = *vec_iter_pointListy[ind];
592 p[2] = *vec_iter_pointListz[ind];
597 fichier << p[0] <<
"\t" << p[1] <<
"\t" << p[2] <<
"\t";
598 ++vec_iter_pointListx[ind];
599 ++vec_iter_pointListy[ind];
600 ++vec_iter_pointListz[ind];
607 if((vec_iter_pointListx[ind] != (graphList+graphNum)->curveList[ind].pointListx.end())
608 && (vec_iter_pointListy[ind] != (graphList+graphNum)->curveList[ind].pointListy.end())
609 && (vec_iter_pointListz[ind] != (graphList+graphNum)->curveList[ind].pointListz.end()))
617 p[0] = (graphList+graphNum)->curveList[ind].pointListx.back();
618 p[1] = (graphList+graphNum)->curveList[ind].pointListy.back();
619 p[2] = (graphList+graphNum)->curveList[ind].pointListz.back();
620 fichier << p[0] <<
"\t" << p[1] <<
"\t" << p[2] <<
"\t";
623 fichier << std::endl;
void initRange(const unsigned int graphNum, double xmin, double xmax, double ymin, double ymax)
bool inRectangle(const vpRect &rect) const
virtual void init(vpImage< unsigned char > &I, int x=-1, int y=-1, const char *title=NULL)=0
void setColor(const unsigned int graphNum, const unsigned int curveNum, vpColor color)
vpImage< unsigned char > I
void init(unsigned int height, unsigned int width)
set the size of the image
void setUnitY(const unsigned int graphNum, const char *unity)
Display for windows using GDI (available on any windows 32 platform).
Class to define colors available for display functionnalities.
Define the X11 console to display images.
error that can be emited by ViSP classes.
void setLegend(const unsigned int graphNum, const unsigned int curveNum, const char *legend)
void plot(const unsigned int graphNum, const unsigned int curveNum, const double x, const double y)
void setTitle(const unsigned int graphNum, const char *title)
void setUnitZ(const unsigned int graphNum, const char *unitz)
void setUnitX(const unsigned int graphNum, const char *unitx)
Display for windows using Direct3D.
void setGridThickness(const unsigned int graphNum, const unsigned int thickness)
virtual bool getPointerPosition(vpImagePoint &ip)=0
void saveData(const unsigned int graphNum, const char *dataFile)
static void display(const vpImage< unsigned char > &I)
The vpDisplayOpenCV allows to display image using the opencv library.
The vpDisplayGTK allows to display image using the GTK+ library version 1.2.
void init(const unsigned int nbGraph, const unsigned int height=700, const unsigned int width=700, const int x=-1, const int y=-1, const char *title=NULL)
void getPixelValue(const bool block)
void initGraph(unsigned int graphNum, unsigned int curveNbr)
Class that provides a data structure for the column vectors as well as a set of operations on these v...
void resetPointList(const unsigned int graphNum)
void setGraphThickness(const unsigned int graphNum, const unsigned int thickness)
virtual bool getClick(bool blocking=true)=0
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
unsigned int getRows() const
Return the number of rows of the matrix.
void setThickness(const unsigned int graphNum, const unsigned int curveNum, const unsigned int thickness)