34#include <visp3/core/vpConfig.h>
36#if defined(VISP_HAVE_DISPLAY)
40#include <visp3/core/vpMath.h>
41#include <visp3/core/vpMeterPixelConversion.h>
42#include <visp3/core/vpPixelMeterConversion.h>
43#include <visp3/gui/vpDisplayD3D.h>
44#include <visp3/gui/vpDisplayGDI.h>
45#include <visp3/gui/vpDisplayGTK.h>
46#include <visp3/gui/vpDisplayOpenCV.h>
47#include <visp3/gui/vpDisplayX.h>
48#include <visp3/gui/vpPlot.h>
58vpPlot::vpPlot() :
I(), display(nullptr), graphNbr(1), graphList(nullptr), margei(30), margej(40), factori(1.f), factorj(1.)
78vpPlot::vpPlot(
unsigned int graph_nbr,
unsigned int height,
unsigned int width,
int x,
int y,
const std::string &title)
79 :
I(), display(nullptr), graphNbr(1), graphList(nullptr), margei(30), margej(40), factori(1.f), factorj(1.)
81 init(graph_nbr, height, width, x, y, title);
97void vpPlot::init(
unsigned int graph_nbr,
unsigned int height,
unsigned int width,
int x,
int y,
98 const std::string &title)
100 I.init(height, width, 255);
102#if defined(VISP_HAVE_X11)
104#elif defined(VISP_HAVE_GDI)
106#elif defined(HAVE_OPENCV_HIGHGUI)
108#elif defined(VISP_HAVE_GTK)
110#elif defined(VISP_HAVE_D3D9)
114 display->
init(
I, x, y, title);
118 factori = height / 700.0f;
119 factorj = width / 700.0f;
121 initNbGraph(graph_nbr);
129 if (graphList !=
nullptr) {
133 if (display !=
nullptr) {
156void vpPlot::initNbGraph(
unsigned int nbGraph)
161 graphList =
new vpPlotGraph[nbGraph];
166 graphList[0].initSize(vpImagePoint(0, 0),
static_cast<unsigned int>(700 * factorj),
static_cast<unsigned int>(700 * factori), margei,
170 graphList[0].initSize(vpImagePoint(0, 0),
static_cast<unsigned int>(700 * factorj),
static_cast<unsigned int>(350 * factori), margei,
172 graphList[1].initSize(vpImagePoint(
static_cast<unsigned int>(350 * factori), 0),
static_cast<unsigned int>(700 * factorj),
173 static_cast<unsigned int>(350 * factori), margei, margej);
176 graphList[0].initSize(vpImagePoint(0, 0),
static_cast<unsigned int>(350 * factorj),
static_cast<unsigned int>(350 * factori), margei,
178 graphList[1].initSize(vpImagePoint(0,
static_cast<unsigned int>(350 * factorj)),
static_cast<unsigned int>(350 * factorj),
179 static_cast<unsigned int>(350 * factori), margei, margej);
180 graphList[2].initSize(vpImagePoint(
static_cast<unsigned int>(350 * factori), 0),
static_cast<unsigned int>(700 * factorj),
181 static_cast<unsigned int>(350 * factori), margei, margej);
184 graphList[0].initSize(vpImagePoint(0, 0),
static_cast<unsigned int>(350 * factorj),
static_cast<unsigned int>(350 * factori), margei,
186 graphList[1].initSize(vpImagePoint(0,
static_cast<unsigned int>(350 * factorj)),
static_cast<unsigned int>(350 * factorj),
187 static_cast<unsigned int>(350 * factori), margei, margej);
188 graphList[2].initSize(vpImagePoint(
static_cast<unsigned int>(350 * factori), 0),
static_cast<unsigned int>(350 * factorj),
189 static_cast<unsigned int>(350 * factori), margei, margej);
190 graphList[3].initSize(vpImagePoint(
static_cast<unsigned int>(350 * factori),
static_cast<unsigned int>(350 * factorj)),
191 static_cast<unsigned int>(350 * factorj),
static_cast<unsigned int>(350 * factori), margei, margej);
195 for (
unsigned int i = 0;
i < graphNbr; ++
i) {
196 graphList[
i].title.clear();
197 graphList[
i].unitx.clear();
198 graphList[
i].unity.clear();
199 graphList[
i].unitz.clear();
224void vpPlot::initRange(
unsigned int graphNum,
double xmin,
double xmax,
double ymin,
double ymax)
226 (graphList + graphNum)->initScale(
I, xmin, xmax, 10, ymin, ymax, 10,
true,
true);
241void vpPlot::initRange(
unsigned int graphNum,
double xmin,
double xmax,
double ymin,
double ymax,
double zmin,
244 (graphList + graphNum)->initScale(
I, xmin, xmax, 10, ymin, ymax, 10, zmin, zmax, 10,
true,
true);
257 (graphList + graphNum)->setCurveColor(curveNum, color);
263void vpPlot::displayGrid()
265 for (
unsigned int i = 0; i < graphNbr; ++i)
266 graphList[i].displayGrid(I);
279void vpPlot::plot(
unsigned int graphNum,
unsigned int curveNum,
double x,
double y)
281 (graphList + graphNum)->
plot(
I, curveNum, x, y);
297 if ((graphList + graphNum)->curveNbr == v_y.
getRows()) {
298 for (
unsigned int i = 0; i < v_y.
getRows(); ++i)
299 this->
plot(graphNum, i, x, v_y[i]);
319 if ((graphList + graphNum)->curveNbr == v_y.
getRows()) {
320 for (
unsigned int i = 0; i < v_y.
getRows(); ++i)
321 this->
plot(graphNum, i, x, v_y[i]);
343 if ((graphList + graphNum)->curveNbr == v_y.
getRows()) {
344 for (
unsigned int i = 0; i < v_y.
getRows(); ++i)
345 this->
plot(graphNum, i, x, v_y[i]);
366 if ((graphList + graphNum)->curveNbr == v_y.
getRows()) {
367 for (
unsigned int i = 0; i < v_y.
getRows(); ++i)
368 this->
plot(graphNum, i, x, v_y[i]);
390 if ((graphList + graphNum)->curveNbr == v_y.
size()) {
391 for (
unsigned int i = 0; i < v_y.
size(); ++i)
392 this->
plot(graphNum, i, x, v_y[i]);
419 return (graphList + graphNum)->plot(
I, curveNum, x, y, z);
441 if ((graphList + graphNum)->curveNbr == v_y.
getRows() && (graphList + graphNum)->curveNbr == v_z.
getRows()) {
442 for (
unsigned int i = 0; i < v_y.
getRows(); ++i)
443 button = this->
plot(graphNum, i, x, v_y[i], v_z[i]);
462 bool blocked =
false;
463 unsigned int iblocked = 0;
469 for (
unsigned int i = 0; i < graphNbr; ++i) {
475 if ((graphList + iblocked)->move(
I, b)) {
476 (graphList + iblocked)->replot3D(
I);
478 blocked = (graphList + iblocked)->blocked;
481 if ((graphList + iblocked)->move(
I, b)) {
482 (graphList + iblocked)->replot3D(
I);
484 blocked = (graphList + iblocked)->blocked;
505 for (
unsigned int i = 0; i < graphNbr; ++i) {
563 (graphList + graphNum)->
setLegend(curveNum, legend);
576 for (
unsigned int i = 0; i < (graphList + graphNum)->curveNbr; ++i)
577 (graphList + graphNum)->resetPointList(i);
591 (graphList + graphNum)->setCurveThickness(curveNum, thickness);
604 for (
unsigned int curveNum = 0; curveNum < (graphList + graphNum)->curveNbr; ++curveNum)
605 (graphList + graphNum)->setCurveThickness(curveNum, thickness);
664void vpPlot::saveData(
unsigned int graphNum,
const std::string &dataFile,
const std::string &title_prefix)
666 std::ofstream fichier;
667 fichier.open(dataFile.c_str());
670 double *p =
new double[3];
673 std::vector<std::list<double>::const_iterator> vec_iter_pointListx((graphList + graphNum)->curveNbr);
674 std::vector<std::list<double>::const_iterator> vec_iter_pointListy((graphList + graphNum)->curveNbr);
675 std::vector<std::list<double>::const_iterator> vec_iter_pointListz((graphList + graphNum)->curveNbr);
677 fichier << title_prefix << (graphList + graphNum)->title << std::endl;
679 for (ind = 0; ind < (graphList + graphNum)->curveNbr; ++ind) {
680 vec_iter_pointListx[ind] = (graphList + graphNum)->curveList[ind].pointListx.begin();
681 vec_iter_pointListy[ind] = (graphList + graphNum)->curveList[ind].pointListy.begin();
682 vec_iter_pointListz[ind] = (graphList + graphNum)->curveList[ind].pointListz.begin();
688 while (end ==
false) {
690 for (ind = 0; ind < (graphList + graphNum)->curveNbr; ++ind) {
696 if ((vec_iter_pointListx[ind] != (graphList + graphNum)->curveList[ind].pointListx.end()) &&
697 (vec_iter_pointListy[ind] != (graphList + graphNum)->curveList[ind].pointListy.end()) &&
698 (vec_iter_pointListz[ind] != (graphList + graphNum)->curveList[ind].pointListz.end())) {
699 p[0] = *vec_iter_pointListx[ind];
700 p[1] = *vec_iter_pointListy[ind];
701 p[2] = *vec_iter_pointListz[ind];
709 fichier << p[0] <<
"\t" << p[1] <<
"\t" << p[2] <<
"\t";
710 ++vec_iter_pointListx[ind];
711 ++vec_iter_pointListy[ind];
712 ++vec_iter_pointListz[ind];
721 if ((vec_iter_pointListx[ind] != (graphList + graphNum)->curveList[ind].pointListx.end()) &&
722 (vec_iter_pointListy[ind] != (graphList + graphNum)->curveList[ind].pointListy.end()) &&
723 (vec_iter_pointListz[ind] != (graphList + graphNum)->curveList[ind].pointListz.end()))
733 p[0] = (graphList + graphNum)->curveList[ind].pointListx.back();
734 p[1] = (graphList + graphNum)->curveList[ind].pointListy.back();
735 p[2] = (graphList + graphNum)->curveList[ind].pointListz.back();
736 fichier << p[0] <<
"\t" << p[1] <<
"\t" << p[2] <<
"\t";
739 fichier << std::endl;
748#elif !defined(VISP_BUILD_SHARED_LIBS)
750void dummy_vpPlot() { }
unsigned int size() const
Return the number of elements of the 2D array.
unsigned int getRows() const
Implementation of column vector and the associated operations.
Class to define RGB colors available for display functionalities.
Display for windows using Direct3D 3rd party. Thus to enable this class Direct3D should be installed....
Display for windows using GDI (available on any windows 32 platform).
The vpDisplayGTK allows to display image using the GTK 3rd party library. Thus to enable this class G...
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const std::string &title="") VP_OVERRIDE
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static void display(const vpImage< unsigned char > &I)
static bool getPointerPosition(const vpImage< unsigned char > &I, vpImagePoint &ip)
error that can be emitted by ViSP classes.
@ dimensionError
Bad dimension.
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
bool inRectangle(const vpRect &rect) const
void initGraph(unsigned int graphNum, unsigned int curveNbr)
vpImage< unsigned char > I
void setUnitY(unsigned int graphNum, const std::string &unity)
void init(unsigned int nbGraph, unsigned int height=700, unsigned int width=700, int x=-1, int y=-1, const std::string &title="")
void initRange(unsigned int graphNum, double xmin, double xmax, double ymin, double ymax)
void setGridThickness(unsigned int graphNum, unsigned int thickness)
void setLegend(unsigned int graphNum, unsigned int curveNum, const std::string &legend)
void plot(unsigned int graphNum, unsigned int curveNum, double x, double y)
void setUnitX(unsigned int graphNum, const std::string &unitx)
void setColor(unsigned int graphNum, unsigned int curveNum, vpColor color)
void setThickness(unsigned int graphNum, unsigned int curveNum, unsigned int thickness)
void setGraphThickness(unsigned int graphNum, unsigned int thickness)
void setUnitZ(unsigned int graphNum, const std::string &unitz)
void setTitle(unsigned int graphNum, const std::string &title)
void saveData(unsigned int graphNum, const std::string &dataFile, const std::string &title_prefix="")
void resetPointList(unsigned int graphNum)
void getPixelValue(bool block)
Implementation of a pose vector and operations on poses.
Implementation of a generic rotation vector.
Implementation of row vector and the associated operations.
Class that consider the case of a translation vector.
VISP_EXPORT void sleepMs(double t)