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>
92 const unsigned int height,
const unsigned int width,
93 const int x,
const int y,
const char *title)
101 init(graphNbr, height, width, x, y, title);
117 const unsigned int height,
const unsigned int width,
118 const int x,
const int y,
const char *title)
120 I.
init(height,width,255);
122 #if defined VISP_HAVE_X11
124 #elif defined VISP_HAVE_GDI
126 #elif defined VISP_HAVE_OPENCV
128 #elif defined VISP_HAVE_GTK
130 #elif defined VISP_HAVE_D3D9
134 display->
init(
I, x, y, title);
138 factori = height/700.0f;
139 factorj = width/700.0f;
141 initNbGraph(graphNbr);
149 if (graphList != NULL)
170 vpPlot::initNbGraph (
unsigned int nbGraph)
175 graphList =
new vpPlotGraph[nbGraph];
181 graphList[0].initSize(
vpImagePoint(0,0), (
unsigned int)(700*factorj),(
unsigned int)(700*factori),margei,margej);
184 graphList[0].initSize(
vpImagePoint(0,0),(
unsigned int)(700*factorj),(
unsigned int)(350*factori),margei,margej);
185 graphList[1].initSize(
vpImagePoint((
unsigned int)(350*factori),0),(
unsigned int)(700*factorj),(
unsigned int)(350*factori),margei,margej);
188 graphList[0].initSize(
vpImagePoint(0,0),(
unsigned int)(350*factorj),(
unsigned int)(350*factori),margei,margej);
189 graphList[1].initSize(
vpImagePoint(0,(
unsigned int)(350*factorj)),(
unsigned int)(350*factorj),(
unsigned int)(350*factori),margei,margej);
190 graphList[2].initSize(
vpImagePoint((
unsigned int)(350*factori),0),(
unsigned int)(700*factorj),(
unsigned int)(350*factori),margei,margej);
193 graphList[0].initSize(
vpImagePoint(0,0),(
unsigned int)(350*factorj),(
unsigned int)(350*factori),margei,margej);
194 graphList[1].initSize(
vpImagePoint(0,(
unsigned int)(350*factorj)),(
unsigned int)(350*factorj),(
unsigned int)(350*factori),margei,margej);
195 graphList[2].initSize(
vpImagePoint((
unsigned int)(350*factori),0),(
unsigned int)(350*factorj),(
unsigned int)(350*factori),margei,margej);
196 graphList[3].initSize(
vpImagePoint((
unsigned int)(350*factori),(
unsigned int)(350*factorj)),(
unsigned int)(350*factorj),(
unsigned int)(350*factori),margei,margej);
200 for (
unsigned int i = 0; i < graphNbr; i++)
202 strcpy(graphList[i].title,
"");
203 strcpy(graphList[i].unitx,
"");
204 strcpy(graphList[i].unity,
"");
205 strcpy(graphList[i].unitz,
"");
206 graphList[i].textdispayed=
false;
219 (graphList+graphNum)->
initGraph(curveNbr);
243 double xmin,
double xmax,
244 double ymin,
double ymax)
246 (graphList+graphNum)->initScale(
I,xmin,xmax,10,ymin,ymax,10,
true,
true);
262 double xmin,
double xmax,
double ymin,
263 double ymax,
double zmin,
double zmax)
265 (graphList+graphNum)->initScale(
I,xmin,xmax,10,ymin,ymax,10,zmin,zmax,10,
true,
true);
278 (graphList+graphNum)->setCurveColor(curveNum, color);
285 vpPlot::displayGrid()
287 for (
unsigned int i = 0; i < graphNbr; i++)
288 graphList[i].displayGrid(
I);
300 vpPlot::plot (
const unsigned int graphNum,
const unsigned int curveNum,
const double x,
const double y)
302 (graphList+graphNum)->
plot(
I,curveNum,x,y);
315 if((graphList+graphNum)->curveNbr == v_y.
getRows())
317 for(
unsigned int i = 0;i < v_y.
getRows();++i)
318 this->
plot(graphNum, i, x, v_y[i]);
321 vpTRACE(
"error in plot vector : not the right dimension");
335 vpPlot::plot (
const unsigned int graphNum,
const unsigned int curveNum,
const double x,
const double y,
const double z)
337 (graphList+graphNum)->
plot(
I,curveNum,x,y,z);
350 if((graphList+graphNum)->curveNbr == v_y.
getRows() && (graphList+graphNum)->curveNbr == v_z.
getRows())
352 for(
unsigned int i = 0;i < v_y.
getRows();++i)
353 this->
plot(graphNum, i, x, v_y[i], v_z[i]);
356 vpTRACE(
"error in plot vector : not the right dimension");
368 bool blocked =
false;
369 unsigned int iblocked = 0;
377 for (
unsigned int i = 0; i < graphNbr ; i++)
385 if ((graphList+iblocked)->move(
I))
387 (graphList+iblocked)->replot3D(
I);
390 blocked = (graphList+iblocked)->blocked;
394 if ((graphList+iblocked)->move(
I))
396 (graphList+iblocked)->replot3D(
I);
398 blocked = (graphList+iblocked)->blocked;
418 for (
unsigned int i = 0; i < graphNbr; i++)
433 (graphList+graphNum)->
setTitle(title);
445 (graphList+graphNum)->
setUnitX(unitx);
457 (graphList+graphNum)->
setUnitY(unity);
469 (graphList+graphNum)->
setUnitZ(unitz);
480 vpPlot::setLegend (
const unsigned int graphNum,
const unsigned int curveNum,
const char *legend)
482 (graphList+graphNum)->
setLegend(curveNum, legend);
493 for (
unsigned int i = 0; i < (graphList+graphNum)->curveNbr; i++)
494 (graphList+graphNum)->resetPointList(i);
507 (graphList+graphNum)->setCurveThickness(curveNum, thickness);
519 for (
unsigned int curveNum=0; curveNum < (graphList+graphNum)->curveNbr; curveNum++)
520 (graphList+graphNum)->setCurveThickness(curveNum, thickness);
565 std::ofstream fichier;
566 fichier.open(dataFile);
569 double *p =
new double[3];
572 std::vector< std::list<double>::const_iterator > vec_iter_pointListx((graphList+graphNum)->curveNbr);
573 std::vector< std::list<double>::const_iterator > vec_iter_pointListy((graphList+graphNum)->curveNbr);
574 std::vector< std::list<double>::const_iterator > vec_iter_pointListz((graphList+graphNum)->curveNbr);
576 fichier << (graphList+graphNum)->title << std::endl;
578 for(ind=0;ind<(graphList+graphNum)->curveNbr;ind++)
580 vec_iter_pointListx[ind] = (graphList+graphNum)->curveList[ind].pointListx.begin();
581 vec_iter_pointListy[ind] = (graphList+graphNum)->curveList[ind].pointListy.begin();
582 vec_iter_pointListz[ind] = (graphList+graphNum)->curveList[ind].pointListz.begin();
591 for(ind=0;ind<(graphList+graphNum)->curveNbr;ind++)
596 if((vec_iter_pointListx[ind] != (graphList+graphNum)->curveList[ind].pointListx.end())
597 && (vec_iter_pointListy[ind] != (graphList+graphNum)->curveList[ind].pointListy.end())
598 && (vec_iter_pointListz[ind] != (graphList+graphNum)->curveList[ind].pointListz.end()))
600 p[0] = *vec_iter_pointListx[ind];
601 p[1] = *vec_iter_pointListy[ind];
602 p[2] = *vec_iter_pointListz[ind];
607 fichier << p[0] <<
"\t" << p[1] <<
"\t" << p[2] <<
"\t";
608 ++vec_iter_pointListx[ind];
609 ++vec_iter_pointListy[ind];
610 ++vec_iter_pointListz[ind];
617 if((vec_iter_pointListx[ind] != (graphList+graphNum)->curveList[ind].pointListx.end())
618 && (vec_iter_pointListy[ind] != (graphList+graphNum)->curveList[ind].pointListy.end())
619 && (vec_iter_pointListz[ind] != (graphList+graphNum)->curveList[ind].pointListz.end()))
627 p[0] = (graphList+graphNum)->curveList[ind].pointListx.back();
628 p[1] = (graphList+graphNum)->curveList[ind].pointListy.back();
629 p[2] = (graphList+graphNum)->curveList[ind].pointListz.back();
630 fichier << p[0] <<
"\t" << p[1] <<
"\t" << p[2] <<
"\t";
633 fichier << std::endl;