Visual Servoing Platform  version 3.2.0 under development (2019-01-22)
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:134
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:104
void initRange(const unsigned int graphNum, double xmin, double xmax, double ymin, double ymax)
Definition: vpPlot.cpp:228
void setColor(const unsigned int graphNum, const unsigned int curveNum, vpColor color)
Definition: vpPlot.cpp:261
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
void plot(const unsigned int graphNum, const unsigned int curveNum, const double x, const double y)
Definition: vpPlot.cpp:286
Definition: qp_plot.h:66
void setUnitY(const unsigned int graphNum, const std::string &unity)
Definition: vpPlot.cpp:522
void setTitle(const unsigned int graphNum, const std::string &title)
Definition: vpPlot.cpp:498
VISP_EXPORT double measureTimeMs()
Definition: vpTime.cpp:88
static const vpColor red
Definition: vpColor.h:180
void plot(int g, int c, int i, double t)
Definition: qp_plot.h:88
void setLegend(const unsigned int graphNum, const unsigned int curveNum, const std::string &legend)
Definition: vpPlot.cpp:547
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:72
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 setGraphThickness(const unsigned int graphNum, const unsigned int thickness)
Definition: vpPlot.cpp:587
static const vpColor blue
Definition: vpColor.h:186