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 return (graphList+graphNum)->plot(
I,curveNum,x,y,z);
343 if((graphList+graphNum)->curveNbr == v_y.
getRows() && (graphList+graphNum)->curveNbr == v_z.
getRows())
345 for(
unsigned int i = 0;i < v_y.
getRows();++i)
346 button = this->
plot(graphNum, i, x, v_y[i], v_z[i]);
349 vpTRACE(
"error in plot vector : not the right dimension");
365 bool blocked =
false;
366 unsigned int iblocked = 0;
374 for (
unsigned int i = 0; i < graphNbr ; i++)
382 if ((graphList+iblocked)->move(
I, b))
384 (graphList+iblocked)->replot3D(
I);
386 blocked = (graphList+iblocked)->blocked;
390 if ((graphList+iblocked)->move(
I, b))
392 (graphList+iblocked)->replot3D(
I);
394 blocked = (graphList+iblocked)->blocked;
415 for (
unsigned int i = 0; i < graphNbr; i++)
430 (graphList+graphNum)->
setTitle(title);
442 (graphList+graphNum)->
setUnitX(unitx);
454 (graphList+graphNum)->
setUnitY(unity);
466 (graphList+graphNum)->
setUnitZ(unitz);
477 vpPlot::setLegend (
const unsigned int graphNum,
const unsigned int curveNum,
const char *legend)
479 (graphList+graphNum)->
setLegend(curveNum, legend);
490 for (
unsigned int i = 0; i < (graphList+graphNum)->curveNbr; i++)
491 (graphList+graphNum)->resetPointList(i);
504 (graphList+graphNum)->setCurveThickness(curveNum, thickness);
516 for (
unsigned int curveNum=0; curveNum < (graphList+graphNum)->curveNbr; curveNum++)
517 (graphList+graphNum)->setCurveThickness(curveNum, thickness);
562 std::ofstream fichier;
563 fichier.open(dataFile);
566 double *p =
new double[3];
569 std::vector< std::list<double>::const_iterator > vec_iter_pointListx((graphList+graphNum)->curveNbr);
570 std::vector< std::list<double>::const_iterator > vec_iter_pointListy((graphList+graphNum)->curveNbr);
571 std::vector< std::list<double>::const_iterator > vec_iter_pointListz((graphList+graphNum)->curveNbr);
573 fichier << (graphList+graphNum)->title << std::endl;
575 for(ind=0;ind<(graphList+graphNum)->curveNbr;ind++)
577 vec_iter_pointListx[ind] = (graphList+graphNum)->curveList[ind].pointListx.begin();
578 vec_iter_pointListy[ind] = (graphList+graphNum)->curveList[ind].pointListy.begin();
579 vec_iter_pointListz[ind] = (graphList+graphNum)->curveList[ind].pointListz.begin();
588 for(ind=0;ind<(graphList+graphNum)->curveNbr;ind++)
593 if((vec_iter_pointListx[ind] != (graphList+graphNum)->curveList[ind].pointListx.end())
594 && (vec_iter_pointListy[ind] != (graphList+graphNum)->curveList[ind].pointListy.end())
595 && (vec_iter_pointListz[ind] != (graphList+graphNum)->curveList[ind].pointListz.end()))
597 p[0] = *vec_iter_pointListx[ind];
598 p[1] = *vec_iter_pointListy[ind];
599 p[2] = *vec_iter_pointListz[ind];
604 fichier << p[0] <<
"\t" << p[1] <<
"\t" << p[2] <<
"\t";
605 ++vec_iter_pointListx[ind];
606 ++vec_iter_pointListy[ind];
607 ++vec_iter_pointListz[ind];
614 if((vec_iter_pointListx[ind] != (graphList+graphNum)->curveList[ind].pointListx.end())
615 && (vec_iter_pointListy[ind] != (graphList+graphNum)->curveList[ind].pointListy.end())
616 && (vec_iter_pointListz[ind] != (graphList+graphNum)->curveList[ind].pointListz.end()))
624 p[0] = (graphList+graphNum)->curveList[ind].pointListx.back();
625 p[1] = (graphList+graphNum)->curveList[ind].pointListy.back();
626 p[2] = (graphList+graphNum)->curveList[ind].pointListz.back();
627 fichier << p[0] <<
"\t" << p[1] <<
"\t" << p[2] <<
"\t";
630 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.
static void sleepMs(double t)
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)