Plot 2D curves example.
#include <visp3/core/vpConfig.h>
#include <visp3/core/vpDebug.h>
#include <visp3/core/vpMath.h>
#include <visp3/gui/vpPlot.h>
int main()
{
#if defined(VISP_HAVE_DISPLAY)
#ifdef ENABLE_VISP_NAMESPACE
#endif
try {
vpPlot plot(2, 700, 700, 100, 200,
"Curves...");
char title[40];
strncpy(title, "cos function", 40);
strncpy(title, "sin function", 40);
char legend[40];
strncpy(legend, "cos x", 40);
strncpy(legend, "sin x", 40);
char unit[40];
strncpy(unit, "x", 40);
strncpy(unit, "x", 40);
strncpy(unit, "y", 40);
strncpy(unit, "y", 40);
double i = 0;
while (i <= 20 * 2 * M_PI) {
double co = cos(i);
double si = sin(i);
i += 0.1;
}
return EXIT_SUCCESS;
}
std::cout << "Catch an exception: " << e << std::endl;
return EXIT_FAILURE;
}
#else
std::cout << "Plot functionalities are not avalaible since no display is "
"available."
<< std::endl;
return EXIT_SUCCESS;
#endif
}
static const vpColor green
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
error that can be emitted by ViSP classes.
This class enables real time drawing of 2D or 3D graphics. An instance of the class open a window whi...
void initGraph(unsigned int graphNum, unsigned int curveNbr)
vpImage< unsigned char > I
void setUnitY(unsigned int graphNum, const std::string &unity)
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 setTitle(unsigned int graphNum, const std::string &title)
void saveData(unsigned int graphNum, const std::string &dataFile, const std::string &title_prefix="")