Visual Servoing Platform  version 3.6.1 under development (2024-07-27)

#include <visp3/gui/vpPlot.h>

Public Member Functions

 vpPlot ()
 
 vpPlot (unsigned int nbGraph, unsigned int height=700, unsigned int width=700, int x=-1, int y=-1, const std::string &title="")
 
virtual ~vpPlot ()
 
void getPixelValue (bool block)
 
void init (unsigned int nbGraph, unsigned int height=700, unsigned int width=700, int x=-1, int y=-1, const std::string &title="")
 
void initGraph (unsigned int graphNum, unsigned int curveNbr)
 
void initRange (unsigned int graphNum, double xmin, double xmax, double ymin, double ymax)
 
void initRange (unsigned int graphNum, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
 
void navigate (void)
 
void plot (unsigned int graphNum, unsigned int curveNum, double x, double y)
 
void plot (unsigned int graphNum, double x, const vpColVector &v_y)
 
void plot (unsigned int graphNum, double x, const vpRowVector &v_y)
 
void plot (unsigned int graphNum, double x, const vpPoseVector &v_y)
 
void plot (unsigned int graphNum, double x, const vpTranslationVector &v_y)
 
void plot (unsigned int graphNum, double x, const vpRotationVector &v_y)
 
vpMouseButton::vpMouseButtonType plot (unsigned int graphNum, unsigned int curveNum, double x, double y, double z)
 
vpMouseButton::vpMouseButtonType plot (unsigned int graphNum, double x, const vpColVector &v_y, const vpColVector &v_z)
 
void resetPointList (unsigned int graphNum)
 
void resetPointList (unsigned int graphNum, unsigned int curveNum)
 
void saveData (unsigned int graphNum, const std::string &dataFile, const std::string &title_prefix="")
 
void setColor (unsigned int graphNum, unsigned int curveNum, vpColor color)
 
void setGraphThickness (unsigned int graphNum, unsigned int thickness)
 
void setGridThickness (unsigned int graphNum, unsigned int thickness)
 
void setFont (const std::string &font)
 
void setLegend (unsigned int graphNum, unsigned int curveNum, const std::string &legend)
 
void setTitle (unsigned int graphNum, const std::string &title)
 
void setUnitX (unsigned int graphNum, const std::string &unitx)
 
void setUnitY (unsigned int graphNum, const std::string &unity)
 
void setUnitZ (unsigned int graphNum, const std::string &unitz)
 
void setThickness (unsigned int graphNum, unsigned int curveNum, unsigned int thickness)
 

Public Attributes

vpImage< unsigned char > I
 

Detailed Description

This class enables real time drawing of 2D or 3D graphics. An instance of the class open a window which contains between 1 and 4 graphics. Each one contains a desired number of curves.

Warning
This class is only available if one of the display functionalities (X11, GDI, GTK, OpenCV or Direct3D) is available. In visp3/core/vpConfig.h header file, you should have VISP_HAVE_DISPLAY define.

The example below shows how to use the vpPlot class. An other example provided in tutorial-ibvs-plotter.cpp and described in Tutorial: Real-time curves plotter tool shows how to use this class to plot in real-time some curves during an image-based visual servo.

#include <visp3/gui/vpPlot.h>
int main ()
{
#if defined(VISP_HAVE_DISPLAY)
// Create a window (700 by 700) at position (100, 200) with two graphics
vpPlot A(2, 700, 700, 100, 200, "Curves...");
// The first graphic contains 1 curve and the second graphic contains 2 curves
A.initGraph(0,1); A.initGraph(1,2);
// The color of the curve in the first graphic is red
A.setColor(0,0,vpColor::red);
// The first curve in the second graphic is green
A.setColor(1,0,vpColor::green);
// The second curve in the second graphic is blue
A.setColor(1,1,vpColor::blue);
// Add the point (0,0) in the first graphic
A.plot(0,0,0,0);
// Add the point (0,1) to the first curve of the second graphic
A.plot(1,0,0,1);
// Add the point (0,2) to the second curve of the second graphic
A.plot(1,1,0,2);
for (int i = 0; i < 50; ++i) {
// Add the point (i,sin(i*pi/10) in the first graphic
A.plot(0,0,i,sin(i*M_PI/10));
// Add the point (i,1) to the first curve of the second graphic
A.plot(1,0,i,1);
// Add the point (i,2) to the second curve of the second graphic
A.plot(1,1,i,2);
}
return 0;
#endif
}
static const vpColor red
Definition: vpColor.h:217
static const vpColor blue
Definition: vpColor.h:223
static const vpColor green
Definition: vpColor.h:220
This class enables real time drawing of 2D or 3D graphics. An instance of the class open a window whi...
Definition: vpPlot.h:112
Examples
pf-nonlinear-example.cpp, plot2d.cpp, plot3d.cpp, servoAfma6AprilTagIBVS.cpp, servoAfma6AprilTagPBVS.cpp, servoAfma6MegaposePBVS.cpp, servoBebop2.cpp, servoFlirPtuIBVS.cpp, servoFrankaIBVS.cpp, servoFrankaPBVS.cpp, servoMomentImage.cpp, servoMomentPoints.cpp, servoMomentPolygon.cpp, servoPioneerPanSegment3D.cpp, servoPixhawkDroneIBVS.cpp, servoSimu4Points.cpp, servoSimuCylinder.cpp, servoSimuSphere.cpp, servoUniversalRobotsIBVS.cpp, servoUniversalRobotsPBVS.cpp, servoViper850Point2DArtVelocity-jointAvoidance-basic.cpp, servoViper850Point2DArtVelocity-jointAvoidance-gpa.cpp, servoViper850Point2DArtVelocity-jointAvoidance-large.cpp, testComedi.cpp, testFeatureSegment.cpp, testForceTorqueAti.cpp, testForceTorqueAtiNetFTSensor.cpp, testForceTorqueIitSensor.cpp, testOccipitalStructure_Core_imu.cpp, tutorial-ibvs-4pts-plotter-continuous-gain-adaptive.cpp, tutorial-ibvs-4pts-plotter-gain-adaptive.cpp, tutorial-ibvs-4pts-plotter.cpp, tutorial-meandrift.cpp, tutorial-simu-pioneer-continuous-gain-adaptive.cpp, tutorial-simu-pioneer-continuous-gain-constant.cpp, tutorial-simu-pioneer-pan.cpp, tutorial-simu-pioneer.cpp, tutorial-ukf.cpp, ukf-linear-example.cpp, ukf-nonlinear-complex-example.cpp, and ukf-nonlinear-example.cpp.

Definition at line 111 of file vpPlot.h.

Constructor & Destructor Documentation

◆ vpPlot() [1/2]

BEGIN_VISP_NAMESPACE vpPlot::vpPlot ( )

Default constructor.

Needs then a call to init().

Definition at line 59 of file vpPlot.cpp.

◆ vpPlot() [2/2]

vpPlot::vpPlot ( unsigned int  graph_nbr,
unsigned int  height = 700,
unsigned int  width = 700,
int  x = -1,
int  y = -1,
const std::string &  title = "" 
)

This constructor creates a new window where the curves will be drawn. The number of graphics in the window must be set.

Warning
You can modify the default window size, but this is not advised.
Under Unix, when X11 is used to display the curves, the default font is set to "-adobe-times-medium-i-normal--10-100-75-75-p-52-iso8859-*". Note that you can chose an other one using "xfontsel".
Parameters
graph_nbr: The number of graph in the window.
height: Height of the window.
width: Width of the window.
x,y: The window is set at position x,y (column index, row index).
title: Window title.

Definition at line 78 of file vpPlot.cpp.

References init().

◆ ~vpPlot()

vpPlot::~vpPlot ( )
virtual

Basic destructor

Definition at line 126 of file vpPlot.cpp.

Member Function Documentation

◆ getPixelValue()

void vpPlot::getPixelValue ( bool  block)

This method displays the coordinates of the point pointed by the mouse pointer.

Parameters
block: If true, this method waits a click.

Definition at line 487 of file vpPlot.cpp.

References vpDisplay::getClick(), vpDisplay::getPointerPosition(), and I.

◆ init()

void vpPlot::init ( unsigned int  graph_nbr,
unsigned int  height = 700,
unsigned int  width = 700,
int  x = -1,
int  y = -1,
const std::string &  title = "" 
)

Creates a new window where the curves will be drawn. The number of graphics in the window must be set.

Warning
You can modify the default window size, but this is not advised.
Parameters
graph_nbr: The number of graph in the window.
height: Height of the window.
width: Width of the window.
x,y: The window is set at position x,y (column index, row index).
title: Window title.
Examples
servoMomentImage.cpp, servoMomentPoints.cpp, and servoMomentPolygon.cpp.

Definition at line 96 of file vpPlot.cpp.

References vpDisplay::display(), I, and vpImage< Type >::init().

Referenced by vpPlot().

◆ initGraph()

void vpPlot::initGraph ( unsigned int  graphNum,
unsigned int  curveNbr 
)

◆ initRange() [1/2]

void vpPlot::initRange ( unsigned int  graphNum,
double  xmin,
double  xmax,
double  ymin,
double  ymax 
)

This method enables to set the initial range of the selected graphic.

Parameters
graphNum: The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.
xmin: The initial minimum value along the x axis given in the user coordinates.
xmax: The initial maximum value along the x axis given in the user coordinates.
ymin: The initial minimum value along the y axis given in the user coordinates.
ymax: The initial maximum value along the y axis given in the user coordinates.
Examples
pf-nonlinear-example.cpp, servoViper850Point2DArtVelocity-jointAvoidance-basic.cpp, servoViper850Point2DArtVelocity-jointAvoidance-gpa.cpp, and servoViper850Point2DArtVelocity-jointAvoidance-large.cpp.

Definition at line 215 of file vpPlot.cpp.

References I.

◆ initRange() [2/2]

void vpPlot::initRange ( unsigned int  graphNum,
double  xmin,
double  xmax,
double  ymin,
double  ymax,
double  zmin,
double  zmax 
)

This method enables to set the initial range of the selected graphic.

Parameters
graphNum: The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.
xmin: The initial minimum value along the x axis given in the user coordinates.
xmax: The initial maximum value along the x axis given in the user coordinates.
ymin: The initial minimum value along the y axis given in the user coordinates.
ymax: The initial maximum value along the y axis given in the user coordinates.
zmin: The initial minimum value along the z axis given in the user coordinates.
zmax: The initial maximum value along the z axis given in the user coordinates.

Definition at line 232 of file vpPlot.cpp.

References I.

◆ navigate()

void vpPlot::navigate ( void  )

This method allows to change the point of view with the mouse if you have a 3D graphic. The navigation is performed using the mouse.

  • A click on left mouse button allows rotations
  • A click on middle mouse button allows zoom
  • A click on right mouse button quit the infinite navigation loop.

Definition at line 449 of file vpPlot.cpp.

References vpMouseButton::button3, vpDisplay::getPointerPosition(), I, vpImagePoint::inRectangle(), vpMouseButton::none, and vpTime::sleepMs().

◆ plot() [1/8]

void vpPlot::plot ( unsigned int  graphNum,
double  x,
const vpColVector v_y 
)

This function enables you to add new points in all curves of a plot. These points are drawn with the parameters of the curves.

Parameters
graphNum: The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.
x: The coordinate of the new points along the x axis and given in the user unit system.
v_y: y coordinates vector. The coordinates of the new points along the y axis and given in the user unit system.

Definition at line 286 of file vpPlot.cpp.

References vpException::dimensionError, vpArray2D< Type >::getRows(), and plot().

◆ plot() [2/8]

vpMouseButton::vpMouseButtonType vpPlot::plot ( unsigned int  graphNum,
double  x,
const vpColVector v_y,
const vpColVector v_z 
)

This function enables you to add new points in all curves of a plot. These points are drawn with the parameters of the curves.

Parameters
graphNum: The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.
x: The coordinate of the new points along the x axis and given in the user unit system.
v_y: y coordinates vector. The coordinates of the new points along the y axis and given in the user unit system.
v_z: z coordinates vector. The coordinates of the new points along the z axis and given in the user unit system.

Definition at line 428 of file vpPlot.cpp.

References vpException::dimensionError, vpArray2D< Type >::getRows(), vpMouseButton::none, and plot().

◆ plot() [3/8]

void vpPlot::plot ( unsigned int  graphNum,
double  x,
const vpPoseVector v_y 
)

This function enables you to add new points in all curves of a plot. These points are drawn with the parameters of the curves.

Parameters
graphNum: The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.
x: The coordinate of the new points along the x axis and given in the user unit system.
v_y: y coordinates vector. The coordinates of the new points along the y axis and given in the user unit system.

Definition at line 332 of file vpPlot.cpp.

References vpException::dimensionError, vpArray2D< Type >::getRows(), and plot().

◆ plot() [4/8]

void vpPlot::plot ( unsigned int  graphNum,
double  x,
const vpRotationVector v_y 
)

This function enables you to add new points in all curves of a plot. These points are drawn with the parameters of the curves.

Parameters
graphNum: The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.
x: The coordinate of the new points along the x axis and given in the user unit system.
v_y: y coordinates vector. The coordinates of the new points along the y axis and given in the user unit system.

Definition at line 379 of file vpPlot.cpp.

References vpException::dimensionError, plot(), and vpArray2D< Type >::size().

◆ plot() [5/8]

void vpPlot::plot ( unsigned int  graphNum,
double  x,
const vpRowVector v_y 
)

This function enables you to add new points in all curves of a plot. These points are drawn with the parameters of the curves.

Parameters
graphNum: The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.
x: The coordinate of the new points along the x axis and given in the user unit system.
v_y: y coordinates vector. The coordinates of the new points along the y axis and given in the user unit system.

Definition at line 308 of file vpPlot.cpp.

References vpException::dimensionError, vpArray2D< Type >::getRows(), and plot().

◆ plot() [6/8]

void vpPlot::plot ( unsigned int  graphNum,
double  x,
const vpTranslationVector v_y 
)

This function enables you to add new points in all curves of a plot. These points are drawn with the parameters of the curves.

Parameters
graphNum: The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.
x: The coordinate of the new points along the x axis and given in the user unit system.
v_y: y coordinates vector. The coordinates of the new points along the y axis and given in the user unit system.

Definition at line 355 of file vpPlot.cpp.

References vpException::dimensionError, vpArray2D< Type >::getRows(), and plot().

◆ plot() [7/8]

void vpPlot::plot ( unsigned int  graphNum,
unsigned int  curveNum,
double  x,
double  y 
)

This function enables you to add a new point in the curve. This point is drawn with the parameters of the curve.

Parameters
graphNum: The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.
curveNum: The index of the curve in the list of the curves belonging to the graphic.
x: The coordinate of the new point along the x axis and given in the user unit system.
y: The coordinate of the new point along the y axis and given in the user unit system.
Examples
pf-nonlinear-example.cpp, plot2d.cpp, plot3d.cpp, servoAfma6AprilTagIBVS.cpp, servoAfma6AprilTagPBVS.cpp, servoAfma6MegaposePBVS.cpp, servoFlirPtuIBVS.cpp, servoFrankaIBVS.cpp, servoFrankaPBVS.cpp, servoMomentImage.cpp, servoMomentPoints.cpp, servoMomentPolygon.cpp, servoPioneerPanSegment3D.cpp, servoSimu4Points.cpp, servoSimuCylinder.cpp, servoSimuSphere.cpp, servoUniversalRobotsIBVS.cpp, servoUniversalRobotsPBVS.cpp, servoViper850Point2DArtVelocity-jointAvoidance-basic.cpp, servoViper850Point2DArtVelocity-jointAvoidance-gpa.cpp, servoViper850Point2DArtVelocity-jointAvoidance-large.cpp, testComedi.cpp, testFeatureSegment.cpp, testForceTorqueAtiNetFTSensor.cpp, testForceTorqueIitSensor.cpp, testOccipitalStructure_Core_imu.cpp, tutorial-ibvs-4pts-plotter-continuous-gain-adaptive.cpp, tutorial-ibvs-4pts-plotter-gain-adaptive.cpp, tutorial-ibvs-4pts-plotter.cpp, tutorial-simu-pioneer-continuous-gain-adaptive.cpp, tutorial-simu-pioneer-continuous-gain-constant.cpp, tutorial-simu-pioneer-pan.cpp, tutorial-simu-pioneer.cpp, ukf-linear-example.cpp, ukf-nonlinear-complex-example.cpp, and ukf-nonlinear-example.cpp.

Definition at line 270 of file vpPlot.cpp.

References I.

Referenced by plot().

◆ plot() [8/8]

vpMouseButton::vpMouseButtonType vpPlot::plot ( unsigned int  graphNum,
unsigned int  curveNum,
double  x,
double  y,
double  z 
)

This function enables you to add a new point in the curve. This point is drawn with the parameters of the curve.

Parameters
graphNum: The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.
curveNum: The index of the curve in the list of the curves belonging to the graphic.
x: The coordinate of the new point along the x axis and given in the user unit system.
y: The coordinate of the new point along the y axis and given in the user unit system.
z: The coordinate of the new point along the z axis and given in the user unit system.

Definition at line 407 of file vpPlot.cpp.

References I.

◆ resetPointList() [1/2]

void vpPlot::resetPointList ( unsigned int  graphNum)

This method enables to erase the list of points stored for the graphic number $ graphNum $.

Parameters
graphNum: The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.

Definition at line 565 of file vpPlot.cpp.

Referenced by resetPointList().

◆ resetPointList() [2/2]

void vpPlot::resetPointList ( unsigned int  graphNum,
unsigned int  curveNum 
)

This method enables to erase the list of points stored for the curve number $ curveNum $ contained in the graphic number $ graphNum $.

Parameters
graphNum: The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.
curveNum: The index of the curve in the list of the curves belonging to the graphic.

Definition at line 623 of file vpPlot.cpp.

References resetPointList().

◆ saveData()

void vpPlot::saveData ( unsigned int  graphNum,
const std::string &  dataFile,
const std::string &  title_prefix = "" 
)

This function enables to save in a text file all the plotted points of a graphic.

The content of the file is the following:

  • The first line of the text file is the graphic title prefixed by title_prefix.
  • Then the successive points coordinates (x, y, z) are given for each curve. If the graphic has two curves:
    • the first column corresponds to the x axis of the first curve
    • the second column corresponds to the y axis of the first curve
    • the third column corresponds to the z axis of the first curve
    • the fourth column corresponds to the x axis of the second curve
    • the fifth column corresponds to the y axis of the second curve
    • the sixth column corresponds to the z axis of the second curve

The columns are delimited thanks to tabulations.

Parameters
title_prefix: Prefix introduced in the first line of the saved file. To exploit a posteriori the resulting curves:
  • with gnuplot, set title_prefix to "# ".
  • with Matlab, set title_prefix to "% ".
graphNum: The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.
dataFile: Name of the text file.
Examples
plot2d.cpp, tutorial-ibvs-4pts-plotter-continuous-gain-adaptive.cpp, tutorial-ibvs-4pts-plotter-gain-adaptive.cpp, tutorial-ibvs-4pts-plotter.cpp, tutorial-simu-pioneer-continuous-gain-adaptive.cpp, tutorial-simu-pioneer-continuous-gain-constant.cpp, and tutorial-simu-pioneer.cpp.

Definition at line 655 of file vpPlot.cpp.

◆ setColor()

void vpPlot::setColor ( unsigned int  graphNum,
unsigned int  curveNum,
vpColor  color 
)

This function enables you to choose the color used to draw a given curve.

Parameters
graphNum: The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.
curveNum: The index of the curve in the list of the curves belonging to the graphic.
color: The color you want to use
Examples
pf-nonlinear-example.cpp, plot2d.cpp, plot3d.cpp, servoMomentImage.cpp, servoMomentPoints.cpp, servoMomentPolygon.cpp, servoViper850Point2DArtVelocity-jointAvoidance-basic.cpp, servoViper850Point2DArtVelocity-jointAvoidance-gpa.cpp, servoViper850Point2DArtVelocity-jointAvoidance-large.cpp, and testOccipitalStructure_Core_imu.cpp.

Definition at line 246 of file vpPlot.cpp.

◆ setFont()

void vpPlot::setFont ( const std::string &  font)
inline

Set the font of the characters. The display should be initialized before.

To know which font are available, on Unix you can use xfontsel or xlsfonts utilities.

Definition at line 182 of file vpPlot.h.

References vpDisplay::setFont().

◆ setGraphThickness()

void vpPlot::setGraphThickness ( unsigned int  graphNum,
unsigned int  thickness 
)

This function enables you to choose the thickness used to draw all the curves belonging to a given graphic.

Parameters
graphNum: The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.
thickness: The thickness you want to use

Definition at line 593 of file vpPlot.cpp.

◆ setGridThickness()

void vpPlot::setGridThickness ( unsigned int  graphNum,
unsigned int  thickness 
)

This function enables you to choose the thickness used to draw the grid and the axis of a given graphic.

Parameters
graphNum: The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.
thickness: The thickness you want to use

Definition at line 608 of file vpPlot.cpp.

◆ setLegend()

void vpPlot::setLegend ( unsigned int  graphNum,
unsigned int  curveNum,
const std::string &  legend 
)

◆ setThickness()

void vpPlot::setThickness ( unsigned int  graphNum,
unsigned int  curveNum,
unsigned int  thickness 
)

This function enables you to choose the thickness used to draw a given curve.

Parameters
graphNum: The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.
curveNum: The index of the curve in the list of the curves belonging to the graphic.
thickness: The thickness you want to use

Definition at line 580 of file vpPlot.cpp.

◆ setTitle()

◆ setUnitX()

void vpPlot::setUnitX ( unsigned int  graphNum,
const std::string &  unitx 
)

Sets the unit system of the x axis.

Parameters
graphNum: The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.
unitx: The name of the unit of the x axis.
Examples
pf-nonlinear-example.cpp, plot2d.cpp, plot3d.cpp, ukf-linear-example.cpp, ukf-nonlinear-complex-example.cpp, and ukf-nonlinear-example.cpp.

Definition at line 520 of file vpPlot.cpp.

◆ setUnitY()

void vpPlot::setUnitY ( unsigned int  graphNum,
const std::string &  unity 
)

Sets the unit system of the y axis.

Parameters
graphNum: The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.
unity: The name of the unit of the y axis.
Examples
pf-nonlinear-example.cpp, plot2d.cpp, plot3d.cpp, ukf-linear-example.cpp, ukf-nonlinear-complex-example.cpp, and ukf-nonlinear-example.cpp.

Definition at line 530 of file vpPlot.cpp.

◆ setUnitZ()

void vpPlot::setUnitZ ( unsigned int  graphNum,
const std::string &  unitz 
)

Sets the unit system of the z axis.

Parameters
graphNum: The index of the graph in the window. As the number of graphic in a window is less or equal to 4, this parameter is between 0 and 3.
unitz: The name of the unit of the z axis.
Examples
plot3d.cpp.

Definition at line 540 of file vpPlot.cpp.

Member Data Documentation

◆ I