44 #include <visp/vpConfig.h>
46 #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV)
47 #include <visp/vpPlot.h>
48 #include <visp/vpDisplayOpenCV.h>
49 #include <visp/vpDisplayX.h>
50 #include <visp/vpDisplayGDI.h>
51 #include <visp/vpMath.h>
52 #include <visp/vpMeterPixelConversion.h>
53 #include <visp/vpPixelMeterConversion.h>
54 #include <visp/vpPose.h>
90 const unsigned int height,
const unsigned int width,
91 const int x,
const int y,
const char *title)
99 init(graphNbr, height, width, x, y, title);
115 const unsigned int height,
const unsigned int width,
116 const int x,
const int y,
const char *title)
118 I.
init(height,width,255);
120 #if defined VISP_HAVE_X11
122 #elif defined VISP_HAVE_GDI
124 #elif defined VISP_HAVE_OPENCV
128 display->
init(
I, x, y, title);
132 factori = height/700.0f;
133 factorj = width/700.0f;
135 initNbGraph(graphNbr);
143 if (graphList != NULL)
164 vpPlot::initNbGraph (
unsigned int nbGraph)
169 graphList =
new vpPlotGraph[nbGraph];
175 graphList[0].initSize(
vpImagePoint(0,0), (
unsigned int)(700*factorj),(
unsigned int)(700*factori),margei,margej);
178 graphList[0].initSize(
vpImagePoint(0,0),(
unsigned int)(700*factorj),(
unsigned int)(350*factori),margei,margej);
179 graphList[1].initSize(
vpImagePoint((
unsigned int)(350*factori),0),(
unsigned int)(700*factorj),(
unsigned int)(350*factori),margei,margej);
182 graphList[0].initSize(
vpImagePoint(0,0),(
unsigned int)(350*factorj),(
unsigned int)(350*factori),margei,margej);
183 graphList[1].initSize(
vpImagePoint(0,(
unsigned int)(350*factorj)),(
unsigned int)(350*factorj),(
unsigned int)(350*factori),margei,margej);
184 graphList[2].initSize(
vpImagePoint((
unsigned int)(350*factori),0),(
unsigned int)(700*factorj),(
unsigned int)(350*factori),margei,margej);
187 graphList[0].initSize(
vpImagePoint(0,0),(
unsigned int)(350*factorj),(
unsigned int)(350*factori),margei,margej);
188 graphList[1].initSize(
vpImagePoint(0,(
unsigned int)(350*factorj)),(
unsigned int)(350*factorj),(
unsigned int)(350*factori),margei,margej);
189 graphList[2].initSize(
vpImagePoint((
unsigned int)(350*factori),0),(
unsigned int)(350*factorj),(
unsigned int)(350*factori),margei,margej);
190 graphList[3].initSize(
vpImagePoint((
unsigned int)(350*factori),(
unsigned int)(350*factorj)),(
unsigned int)(350*factorj),(
unsigned int)(350*factori),margei,margej);
194 for (
unsigned int i = 0; i < graphNbr; i++)
196 strcpy(graphList[i].title,
"");
197 strcpy(graphList[i].unitx,
"");
198 strcpy(graphList[i].unity,
"");
199 strcpy(graphList[i].unitz,
"");
200 graphList[i].textdispayed=
false;
213 (graphList+graphNum)->
initGraph(curveNbr);
237 double xmin,
double xmax,
238 double ymin,
double ymax)
240 (graphList+graphNum)->initScale(
I,xmin,xmax,10,ymin,ymax,10,
true,
true);
256 double xmin,
double xmax,
double ymin,
257 double ymax,
double zmin,
double zmax)
259 (graphList+graphNum)->initScale(
I,xmin,xmax,10,ymin,ymax,10,zmin,zmax,10,
true,
true);
272 (graphList+graphNum)->setCurveColor(curveNum, color);
279 vpPlot::displayGrid()
281 for (
unsigned int i = 0; i < graphNbr; i++)
282 graphList[i].displayGrid(
I);
294 vpPlot::plot (
const unsigned int graphNum,
const unsigned int curveNum,
const double x,
const double y)
296 (graphList+graphNum)->
plot(
I,curveNum,x,y);
309 if((graphList+graphNum)->curveNbr == v_y.
getRows())
311 for(
unsigned int i = 0;i < v_y.
getRows();++i)
312 this->
plot(graphNum, i, x, v_y[i]);
315 vpTRACE(
"error in plot vector : not the right dimension");
328 vpPlot::plot (
const unsigned int graphNum,
const unsigned int curveNum,
const double x,
const double y,
const double z)
330 (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 this->
plot(graphNum, i, x, v_y[i], v_z[i]);
349 vpTRACE(
"error in plot vector : not the right dimension");
361 bool blocked =
false;
362 unsigned int iblocked = 0;
370 for (
unsigned int i = 0; i < graphNbr ; i++)
378 if ((graphList+iblocked)->move(
I))
380 (graphList+iblocked)->replot3D(
I);
383 blocked = (graphList+iblocked)->blocked;
387 if ((graphList+iblocked)->move(
I))
389 (graphList+iblocked)->replot3D(
I);
391 blocked = (graphList+iblocked)->blocked;
411 for (
unsigned int i = 0; i < graphNbr; i++)
426 (graphList+graphNum)->
setTitle(title);
438 (graphList+graphNum)->
setUnitX(unitx);
450 (graphList+graphNum)->
setUnitY(unity);
462 (graphList+graphNum)->
setUnitZ(unitz);
473 vpPlot::setLegend (
const unsigned int graphNum,
const unsigned int curveNum,
const char *legend)
475 (graphList+graphNum)->
setLegend(curveNum, legend);
486 for (
unsigned int i = 0; i < (graphList+graphNum)->curveNbr; i++)
487 (graphList+graphNum)->resetPointList(i);
500 (graphList+graphNum)->setCurveThickness(curveNum, thickness);
533 std::ofstream fichier;
534 fichier.open(dataFile);
537 double *p =
new double[3];
540 std::vector< std::list<double>::const_iterator > vec_iter_pointListx((graphList+graphNum)->curveNbr);
541 std::vector< std::list<double>::const_iterator > vec_iter_pointListy((graphList+graphNum)->curveNbr);
542 std::vector< std::list<double>::const_iterator > vec_iter_pointListz((graphList+graphNum)->curveNbr);
544 fichier << (graphList+graphNum)->title << std::endl;
546 for(ind=0;ind<(graphList+graphNum)->curveNbr;ind++)
548 vec_iter_pointListx[ind] = (graphList+graphNum)->curveList[ind].pointListx.begin();
549 vec_iter_pointListy[ind] = (graphList+graphNum)->curveList[ind].pointListy.begin();
550 vec_iter_pointListz[ind] = (graphList+graphNum)->curveList[ind].pointListz.begin();
559 for(ind=0;ind<(graphList+graphNum)->curveNbr;ind++)
564 if((vec_iter_pointListx[ind] != (graphList+graphNum)->curveList[ind].pointListx.end())
565 && (vec_iter_pointListy[ind] != (graphList+graphNum)->curveList[ind].pointListy.end())
566 && (vec_iter_pointListz[ind] != (graphList+graphNum)->curveList[ind].pointListz.end()))
568 p[0] = *vec_iter_pointListx[ind];
569 p[1] = *vec_iter_pointListy[ind];
570 p[2] = *vec_iter_pointListz[ind];
575 fichier << p[0] <<
"\t" << p[1] <<
"\t" << p[2] <<
"\t";
576 ++vec_iter_pointListx[ind];
577 ++vec_iter_pointListy[ind];
578 ++vec_iter_pointListz[ind];
585 if((vec_iter_pointListx[ind] != (graphList+graphNum)->curveList[ind].pointListx.end())
586 && (vec_iter_pointListy[ind] != (graphList+graphNum)->curveList[ind].pointListy.end())
587 && (vec_iter_pointListz[ind] != (graphList+graphNum)->curveList[ind].pointListz.end()))
595 p[0] = (graphList+graphNum)->curveList[ind].pointListx.back();
596 p[1] = (graphList+graphNum)->curveList[ind].pointListy.back();
597 p[2] = (graphList+graphNum)->curveList[ind].pointListz.back();
598 fichier << p[0] <<
"\t" << p[1] <<
"\t" << p[2] <<
"\t";
601 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.
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)
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.
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)
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)