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 std::string &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 std::string &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
121 display->init(
I, x, y, title.c_str());
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 graphList[i].title.clear();
190 graphList[i].unitx.clear();
191 graphList[i].unity.clear();
192 graphList[i].unitz.clear();
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 std::string &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);
634 void vpPlot::saveData(
const unsigned int graphNum,
const std::string &dataFile,
const std::string &title_prefix)
636 std::ofstream fichier;
637 fichier.open(dataFile.c_str());
640 double *p =
new double[3];
643 std::vector< std::list<double>::const_iterator > vec_iter_pointListx((graphList+graphNum)->curveNbr);
644 std::vector< std::list<double>::const_iterator > vec_iter_pointListy((graphList+graphNum)->curveNbr);
645 std::vector< std::list<double>::const_iterator > vec_iter_pointListz((graphList+graphNum)->curveNbr);
647 fichier << title_prefix << (graphList+graphNum)->title << std::endl;
649 for(ind=0;ind<(graphList+graphNum)->curveNbr;ind++)
651 vec_iter_pointListx[ind] = (graphList+graphNum)->curveList[ind].pointListx.begin();
652 vec_iter_pointListy[ind] = (graphList+graphNum)->curveList[ind].pointListy.begin();
653 vec_iter_pointListz[ind] = (graphList+graphNum)->curveList[ind].pointListz.begin();
662 for(ind=0;ind<(graphList+graphNum)->curveNbr;ind++)
667 if((vec_iter_pointListx[ind] != (graphList+graphNum)->curveList[ind].pointListx.end())
668 && (vec_iter_pointListy[ind] != (graphList+graphNum)->curveList[ind].pointListy.end())
669 && (vec_iter_pointListz[ind] != (graphList+graphNum)->curveList[ind].pointListz.end()))
671 p[0] = *vec_iter_pointListx[ind];
672 p[1] = *vec_iter_pointListy[ind];
673 p[2] = *vec_iter_pointListz[ind];
678 fichier << p[0] <<
"\t" << p[1] <<
"\t" << p[2] <<
"\t";
679 ++vec_iter_pointListx[ind];
680 ++vec_iter_pointListy[ind];
681 ++vec_iter_pointListz[ind];
688 if((vec_iter_pointListx[ind] != (graphList+graphNum)->curveList[ind].pointListx.end())
689 && (vec_iter_pointListy[ind] != (graphList+graphNum)->curveList[ind].pointListy.end())
690 && (vec_iter_pointListz[ind] != (graphList+graphNum)->curveList[ind].pointListz.end()))
698 p[0] = (graphList+graphNum)->curveList[ind].pointListx.back();
699 p[1] = (graphList+graphNum)->curveList[ind].pointListy.back();
700 p[2] = (graphList+graphNum)->curveList[ind].pointListz.back();
701 fichier << p[0] <<
"\t" << p[1] <<
"\t" << p[2] <<
"\t";
704 fichier << std::endl;
711 #elif !defined(VISP_BUILD_SHARED_LIBS)
713 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)
static bool getPointerPosition(const vpImage< unsigned char > &I, vpImagePoint &ip)
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
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.
Class to define colors available for display functionnalities.
vpDisplayGDI()
Basic constructor.
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
void setUnitX(const unsigned int graphNum, const std::string &unitx)
error that can be emited by ViSP classes.
void saveData(const unsigned int graphNum, const std::string &dataFile, const std::string &title_prefix="")
unsigned int size() const
Return the number of elements of the 2D array.
void plot(const unsigned int graphNum, const unsigned int curveNum, const double x, const double y)
void setUnitY(const unsigned int graphNum, const std::string &unity)
void setTitle(const unsigned int graphNum, const std::string &title)
Display for windows using Direct3D 3rd party. Thus to enable this class Direct3D should be installed...
void setGridThickness(const unsigned int graphNum, const unsigned int thickness)
static void display(const vpImage< unsigned char > &I)
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
VISP_EXPORT void sleepMs(double t)
The vpDisplayGTK allows to display image using the GTK 3rd party library. Thus to enable this class G...
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 std::string &title="")
unsigned int getRows() const
Return the number of rows of the 2D array.
void getPixelValue(const bool block)
void setLegend(const unsigned int graphNum, const unsigned int curveNum, const std::string &legend)
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)
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.
void setUnitZ(const unsigned int graphNum, const std::string &unitz)