40 #include <visp3/core/vpConfig.h>
42 #if defined(VISP_HAVE_DISPLAY)
43 #include <visp3/gui/vpPlot.h>
44 #include <visp3/gui/vpDisplayOpenCV.h>
45 #include <visp3/gui/vpDisplayX.h>
46 #include <visp3/gui/vpDisplayGDI.h>
47 #include <visp3/gui/vpDisplayGTK.h>
48 #include <visp3/gui/vpDisplayD3D.h>
49 #include <visp3/core/vpMath.h>
50 #include <visp3/core/vpMeterPixelConversion.h>
51 #include <visp3/core/vpPixelMeterConversion.h>
63 factori(1.f), factorj(1.)
83 const unsigned int height,
const unsigned int width,
84 const int x,
const int y,
const char *title)
85 : I(),
display(NULL), graphNbr(1), graphList(NULL), margei(30), margej(40),
86 factori(1.f), factorj(1.)
88 init(graph_nbr, height, width, x, y, title);
104 const unsigned int height,
const unsigned int width,
105 const int x,
const int y,
const char *title)
107 I.
init(height,width,255);
109 #if defined VISP_HAVE_X11
111 #elif defined VISP_HAVE_GDI
113 #elif defined VISP_HAVE_OPENCV
115 #elif defined VISP_HAVE_GTK
117 #elif defined VISP_HAVE_D3D9
125 factori = height/700.0f;
126 factorj = width/700.0f;
128 initNbGraph(graph_nbr);
136 if (graphList != NULL)
157 vpPlot::initNbGraph (
unsigned int nbGraph)
162 graphList =
new vpPlotGraph[nbGraph];
168 graphList[0].initSize(
vpImagePoint(0,0), (
unsigned int)(700*factorj),(
unsigned int)(700*factori),margei,margej);
171 graphList[0].initSize(
vpImagePoint(0,0),(
unsigned int)(700*factorj),(
unsigned int)(350*factori),margei,margej);
172 graphList[1].initSize(
vpImagePoint((
unsigned int)(350*factori),0),(
unsigned int)(700*factorj),(
unsigned int)(350*factori),margei,margej);
175 graphList[0].initSize(
vpImagePoint(0,0),(
unsigned int)(350*factorj),(
unsigned int)(350*factori),margei,margej);
176 graphList[1].initSize(
vpImagePoint(0,(
unsigned int)(350*factorj)),(
unsigned int)(350*factorj),(
unsigned int)(350*factori),margei,margej);
177 graphList[2].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)(350*factorj),(
unsigned int)(350*factori),margei,margej);
183 graphList[3].initSize(
vpImagePoint((
unsigned int)(350*factori),(
unsigned int)(350*factorj)),(
unsigned int)(350*factorj),(
unsigned int)(350*factori),margei,margej);
187 for (
unsigned int i = 0; i < graphNbr; i++)
189 strcpy(graphList[i].title,
"");
190 strcpy(graphList[i].unitx,
"");
191 strcpy(graphList[i].unity,
"");
192 strcpy(graphList[i].unitz,
"");
205 (graphList+graphNum)->
initGraph(curveNbr);
229 double xmin,
double xmax,
230 double ymin,
double ymax)
232 (graphList+graphNum)->initScale(
I,xmin,xmax,10,ymin,ymax,10,
true,
true);
248 double xmin,
double xmax,
double ymin,
249 double ymax,
double zmin,
double zmax)
251 (graphList+graphNum)->initScale(
I,xmin,xmax,10,ymin,ymax,10,zmin,zmax,10,
true,
true);
264 (graphList+graphNum)->setCurveColor(curveNum, color);
271 vpPlot::displayGrid()
273 for (
unsigned int i = 0; i < graphNbr; i++)
274 graphList[i].displayGrid(
I);
286 vpPlot::plot (
const unsigned int graphNum,
const unsigned int curveNum,
const double x,
const double y)
288 (graphList+graphNum)->
plot(
I,curveNum,x,y);
301 if((graphList+graphNum)->curveNbr == v_y.
getRows())
303 for(
unsigned int i = 0;i < v_y.
getRows();++i)
304 this->
plot(graphNum, i, x, v_y[i]);
307 vpTRACE(
"error in plot vector : not the right dimension");
319 if((graphList+graphNum)->curveNbr == v_y.
getRows())
321 for(
unsigned int i = 0;i < v_y.
getRows();++i)
322 this->
plot(graphNum, i, x, v_y[i]);
325 vpTRACE(
"error in plot vector : not the right dimension");
338 if((graphList+graphNum)->curveNbr == v_y.
getRows())
340 for(
unsigned int i = 0;i < v_y.
getRows();++i)
341 this->
plot(graphNum, i, x, v_y[i]);
344 vpTRACE(
"error in plot vector : not the right dimension");
356 if((graphList+graphNum)->curveNbr == v_y.
getRows())
358 for(
unsigned int i = 0;i < v_y.
getRows();++i)
359 this->
plot(graphNum, i, x, v_y[i]);
362 vpTRACE(
"error in plot vector : not the right dimension");
375 if((graphList+graphNum)->curveNbr == v_y.
size())
377 for(
unsigned int i = 0;i < v_y.
size();++i)
378 this->
plot(graphNum, i, x, v_y[i]);
381 vpTRACE(
"error in plot vector : not the right dimension");
395 vpPlot::plot (
const unsigned int graphNum,
const unsigned int curveNum,
const double x,
const double y,
const double z)
397 return (graphList+graphNum)->plot(
I,curveNum,x,y,z);
412 if((graphList+graphNum)->curveNbr == v_y.
getRows() && (graphList+graphNum)->curveNbr == v_z.
getRows())
414 for(
unsigned int i = 0;i < v_y.
getRows();++i)
415 button = this->
plot(graphNum, i, x, v_y[i], v_z[i]);
418 vpTRACE(
"error in plot vector : not the right dimension");
434 bool blocked =
false;
435 unsigned int iblocked = 0;
443 for (
unsigned int i = 0; i < graphNbr ; i++)
451 if ((graphList+iblocked)->move(
I, b))
453 (graphList+iblocked)->replot3D(
I);
455 blocked = (graphList+iblocked)->blocked;
459 if ((graphList+iblocked)->move(
I, b))
461 (graphList+iblocked)->replot3D(
I);
463 blocked = (graphList+iblocked)->blocked;
484 for (
unsigned int i = 0; i < graphNbr; i++)
499 (graphList+graphNum)->
setTitle(title);
511 (graphList+graphNum)->
setUnitX(unitx);
523 (graphList+graphNum)->
setUnitY(unity);
535 (graphList+graphNum)->
setUnitZ(unitz);
546 vpPlot::setLegend (
const unsigned int graphNum,
const unsigned int curveNum,
const char *legend)
548 (graphList+graphNum)->
setLegend(curveNum, legend);
559 for (
unsigned int i = 0; i < (graphList+graphNum)->curveNbr; i++)
560 (graphList+graphNum)->resetPointList(i);
573 (graphList+graphNum)->setCurveThickness(curveNum, thickness);
585 for (
unsigned int curveNum=0; curveNum < (graphList+graphNum)->curveNbr; curveNum++)
586 (graphList+graphNum)->setCurveThickness(curveNum, thickness);
631 std::ofstream fichier;
632 fichier.open(dataFile);
635 double *p =
new double[3];
638 std::vector< std::list<double>::const_iterator > vec_iter_pointListx((graphList+graphNum)->curveNbr);
639 std::vector< std::list<double>::const_iterator > vec_iter_pointListy((graphList+graphNum)->curveNbr);
640 std::vector< std::list<double>::const_iterator > vec_iter_pointListz((graphList+graphNum)->curveNbr);
642 fichier << (graphList+graphNum)->title << std::endl;
644 for(ind=0;ind<(graphList+graphNum)->curveNbr;ind++)
646 vec_iter_pointListx[ind] = (graphList+graphNum)->curveList[ind].pointListx.begin();
647 vec_iter_pointListy[ind] = (graphList+graphNum)->curveList[ind].pointListy.begin();
648 vec_iter_pointListz[ind] = (graphList+graphNum)->curveList[ind].pointListz.begin();
657 for(ind=0;ind<(graphList+graphNum)->curveNbr;ind++)
662 if((vec_iter_pointListx[ind] != (graphList+graphNum)->curveList[ind].pointListx.end())
663 && (vec_iter_pointListy[ind] != (graphList+graphNum)->curveList[ind].pointListy.end())
664 && (vec_iter_pointListz[ind] != (graphList+graphNum)->curveList[ind].pointListz.end()))
666 p[0] = *vec_iter_pointListx[ind];
667 p[1] = *vec_iter_pointListy[ind];
668 p[2] = *vec_iter_pointListz[ind];
673 fichier << p[0] <<
"\t" << p[1] <<
"\t" << p[2] <<
"\t";
674 ++vec_iter_pointListx[ind];
675 ++vec_iter_pointListy[ind];
676 ++vec_iter_pointListz[ind];
683 if((vec_iter_pointListx[ind] != (graphList+graphNum)->curveList[ind].pointListx.end())
684 && (vec_iter_pointListy[ind] != (graphList+graphNum)->curveList[ind].pointListy.end())
685 && (vec_iter_pointListz[ind] != (graphList+graphNum)->curveList[ind].pointListz.end()))
693 p[0] = (graphList+graphNum)->curveList[ind].pointListx.back();
694 p[1] = (graphList+graphNum)->curveList[ind].pointListy.back();
695 p[2] = (graphList+graphNum)->curveList[ind].pointListz.back();
696 fichier << p[0] <<
"\t" << p[1] <<
"\t" << p[2] <<
"\t";
699 fichier << std::endl;
706 #elif !defined(VISP_BUILD_SHARED_LIBS)
708 void dummy_vpPlot() {};
Implementation of a generic rotation vector.
void initRange(const unsigned int graphNum, double xmin, double xmax, double ymin, double ymax)
bool inRectangle(const vpRect &rect) const
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
Implementation of row vector and the associated operations.
void setUnitY(const unsigned int graphNum, const char *unity)
Class to define colors available for display functionnalities.
vpDisplayGDI()
Basic constructor.
Define the X11 console to display images.
error that can be emited by ViSP classes.
unsigned int size() const
Return the number of elements of the 2D array.
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.
VISP_EXPORT void sleepMs(double t)
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)
unsigned int getRows() const
Return the number of rows of the 2D array.
void getPixelValue(const bool block)
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 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 ...
void setThickness(const unsigned int graphNum, const unsigned int curveNum, const unsigned int thickness)
Class that consider the case of a translation vector.