Visual Servoing Platform version 3.5.0
qp_plot.h
1/****************************************************************************
2 *
3 * ViSP, open source Visual Servoing Platform software.
4 * Copyright (C) 2005 - 2019 by Inria. All rights reserved.
5 *
6 * This software is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 * See the file LICENSE.txt at the root directory of this source
11 * distribution for additional information about the GNU GPL.
12 *
13 * For using ViSP with software that can not be combined with the GNU
14 * GPL, please contact Inria about acquiring a ViSP Professional
15 * Edition License.
16 *
17 * See http://visp.inria.fr for more information.
18 *
19 * This software was developed at:
20 * Inria Rennes - Bretagne Atlantique
21 * Campus Universitaire de Beaulieu
22 * 35042 Rennes Cedex
23 * France
24 *
25 * If you have questions regarding the use of this file, please contact
26 * Inria at visp@inria.fr
27 *
28 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30 *
31 * Description:
32 * Example of sequential calls to QP solver
33 *
34 * Authors:
35 * Olivier Kermorgant
36 *
37 *****************************************************************************/
44#include <visp3/core/vpConfig.h>
45#include <visp3/core/vpTime.h>
46#include <visp3/gui/vpPlot.h>
47
48#ifndef DOXYGEN_SHOULD_SKIP_THIS
49vpMatrix randM(int n, int m)
50{
51 vpMatrix M(n,m);
52 for(int i = 0; i < n; ++i)
53 for(int j = 0; j < m; ++j)
54 M[i][j] = (2.*rand())/RAND_MAX -1;
55 return M;
56}
57
58vpColVector randV(int n)
59{
60 vpColVector M(n);
61 for(int i = 0; i < n; ++i)
62 M[i] = (2.*rand())/RAND_MAX -1;
63 return M;
64}
65
66#ifdef VISP_HAVE_DISPLAY
67class QPlot
68{
69public:
70 virtual ~QPlot() { delete P; }
71 QPlot(int graphNum, int total, std::vector<std::string> legend)
72 {
73 P = new vpPlot(graphNum, 700, 700, 100, 200, "Resolution time");
74
75 for(int i = 0; i < graphNum; ++i)
76 {
77 P->initGraph(i,2);
78 P->setColor(i,0,vpColor::red);
79 P->setColor(i,1,vpColor::blue);
80 P->setGraphThickness(i,2);
81 P->initRange(i, 0, total, 0, 0.1);
82 P->setUnitY(i,"ms");
83 P->setTitle(i, legend[2*i]);
84 P->setLegend(i, 0, "without " + legend[2*i+1]);
85 P->setLegend(i, 1, legend[2*i+1]);
86 }
87 }
88
89 void plot(int g, int c, int i, double t)
90 {
91 P->plot(g,c,i,vpTime::measureTimeMs() - t);
92 }
93
94 void wait()
95 {
96 P->I.display->getClick();
97 }
98 vpPlot* P;
99
100private:
101 // Copy constructor not allowed.
102 QPlot(const QPlot &qplot);
103};
104#else
105class VISP_EXPORT QPPlot
106{
107public:
108 QPPlot(int, int , std::vector<std::string> ) {}
109 void plot(int , int , int , double ) {}
110 void wait() {}
111};
112#endif
113#endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
Implementation of column vector and the associated operations.
Definition: vpColVector.h:131
static const vpColor red
Definition: vpColor.h:217
static const vpColor blue
Definition: vpColor.h:223
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:154
This class enables real time drawing of 2D or 3D graphics. An instance of the class open a window whi...
Definition: vpPlot.h:116
VISP_EXPORT int wait(double t0, double t)
VISP_EXPORT double measureTimeMs()