Visual Servoing Platform  version 3.3.0 under development (2020-02-17)
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 vpMatrix randM(int n, int m)
49 {
50  vpMatrix M(n,m);
51  for(int i = 0; i < n; ++i)
52  for(int j = 0; j < m; ++j)
53  M[i][j] = (2.*rand())/RAND_MAX -1;
54  return M;
55 }
56 
57 vpColVector randV(int n)
58 {
59  vpColVector M(n);
60  for(int i = 0; i < n; ++i)
61  M[i] = (2.*rand())/RAND_MAX -1;
62  return M;
63 }
64 
65 #ifdef VISP_HAVE_DISPLAY
66 class QPlot
67 {
68 public:
69  virtual ~QPlot() { delete P; }
70  QPlot(int graphNum, int total, std::vector<std::string> legend)
71  {
72  P = new vpPlot(graphNum, 700, 700, 100, 200, "Resolution time");
73 
74  for(int i = 0; i < graphNum; ++i)
75  {
76  P->initGraph(i,2);
77  P->setColor(i,0,vpColor::red);
78  P->setColor(i,1,vpColor::blue);
79  P->setGraphThickness(i,2);
80  P->initRange(i, 0, total, 0, 0.1);
81  P->setUnitY(i,"ms");
82  P->setTitle(i, legend[2*i]);
83  P->setLegend(i, 0, "without " + legend[2*i+1]);
84  P->setLegend(i, 1, legend[2*i+1]);
85  }
86  }
87 
88  void plot(int g, int c, int i, double t)
89  {
90  P->plot(g,c,i,vpTime::measureTimeMs() - t);
91  }
92 
93  void wait()
94  {
95  P->I.display->getClick();
96  }
98 
99 private:
100  // Copy constructor not allowed.
101  QPlot(const QPlot &qplot);
102 };
103 #else
104 class VISP_EXPORT QPPlot
105 {
106 public:
107  QPPlot(int, int , std::vector<std::string> ) {}
108  void plot(int , int , int , double ) {}
109  void wait() {}
110 };
111 #endif
vpDisplay * display
Definition: vpImage.h:142
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:164
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
QPlot(int graphNum, int total, std::vector< std::string > legend)
Definition: qp_plot.h:70
vpImage< unsigned char > I
Definition: vpPlot.h:118
void wait()
Definition: qp_plot.h:93
virtual ~QPlot()
Definition: qp_plot.h:69
Definition: qp_plot.h:66
void setLegend(unsigned int graphNum, unsigned int curveNum, const std::string &legend)
Definition: vpPlot.cpp:547
VISP_EXPORT double measureTimeMs()
Definition: vpTime.cpp:126
void initRange(unsigned int graphNum, double xmin, double xmax, double ymin, double ymax)
Definition: vpPlot.cpp:228
static const vpColor red
Definition: vpColor.h:179
void setTitle(unsigned int graphNum, const std::string &title)
Definition: vpPlot.cpp:498
void plot(unsigned int graphNum, unsigned int curveNum, double x, double y)
Definition: vpPlot.cpp:286
void plot(int g, int c, int i, double t)
Definition: qp_plot.h:88
void setUnitY(unsigned int graphNum, const std::string &unity)
Definition: vpPlot.cpp:522
vpPlot * P
Definition: qp_plot.h:97
void initGraph(unsigned int graphNum, unsigned int curveNbr)
Definition: vpPlot.cpp:206
Implementation of column vector and the associated operations.
Definition: vpColVector.h:130
void setGraphThickness(unsigned int graphNum, unsigned int thickness)
Definition: vpPlot.cpp:587
This class enables real time drawing of 2D or 3D graphics. An instance of the class open a window whi...
Definition: vpPlot.h:115
void setColor(unsigned int graphNum, unsigned int curveNum, vpColor color)
Definition: vpPlot.cpp:261
static const vpColor blue
Definition: vpColor.h:185