Visual Servoing Platform  version 3.1.0
vpPlotGraph.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2017 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  * Define a graph for the vpPlot class.
33  *
34  * Authors:
35  * Nicolas Melchior
36  *
37  *****************************************************************************/
38 
39 #ifndef DOXYGEN_SHOULD_SKIP_THIS
40 
41 #ifndef vpPlotGraph_H
42 #define vpPlotGraph_H
43 
44 #include <visp3/core/vpColor.h>
45 #include <visp3/core/vpImage.h>
46 
47 #include <visp3/core/vpMouseButton.h>
48 #include <visp3/gui/vpPlotCurve.h>
49 
50 #include <visp3/core/vpHomogeneousMatrix.h>
51 #include <visp3/core/vpRect.h>
52 
53 #include <visp3/core/vpCameraParameters.h>
54 #include <visp3/core/vpPoint.h>
55 
56 #if defined(VISP_HAVE_DISPLAY)
57 
58 class vpPlotGraph
59 {
60 public:
61  double xorg;
62  double yorg;
63  double zoomx;
64  double zoomy;
65  double xmax;
66  double ymax;
67  double xmin;
68  double ymin;
69  double xdelt;
70  double ydelt;
71  bool gridx;
72  bool gridy;
73  vpColor gridColor;
74  std::string title;
75  std::string unitx;
76  std::string unity;
77  unsigned int curveNbr;
78  vpPlotCurve *curveList;
79  bool scaleInitialized;
80  bool firstPoint;
81 
82  int nbDivisionx;
83  int nbDivisiony;
84 
85  // Graph complet
86  vpImagePoint topLeft;
87  unsigned int width;
88  unsigned int height;
89  vpRect graphZone;
90 
91  // Zone d'affichage
92  vpImagePoint dTopLeft;
93  unsigned int dWidth;
94  unsigned int dHeight;
95  vpRect dGraphZone;
96 
97  // Zone d'affichage
98  vpImagePoint dTopLeft3D;
99  // int dWidth;
100  // int dHeight;
101  vpRect dGraphZone3D;
102 
103  // 3D part
104  vpCameraParameters cam;
107  double w_xval;
108  double w_xsize;
109  double w_yval;
110  double w_ysize;
111  double w_zval;
112  double w_zsize;
113  double ptXorg;
114  double ptYorg;
115  double ptZorg;
116  double zoomx_3D;
117  double zoomy_3D;
118  double zoomz_3D;
119 
120  int nbDivisionz;
121 
122  double zorg;
123  double zoomz;
124  double zmax;
125  double zmin;
126  double zdelt;
127  std::string unitz;
128  vpImagePoint old_iPr;
129  vpImagePoint old_iPz;
130  bool blockedr;
131  bool blockedz;
132  bool blocked;
133 
134  unsigned int epsi;
135  unsigned int epsj;
136 
137  bool dispUnit;
138  bool dispTitle;
139  bool dispLegend;
140 
141  unsigned int gridThickness;
142 
143  // private:
144  //#ifndef DOXYGEN_SHOULD_SKIP_THIS
145  // vpPlotGraph(const vpPlotGraph &)
146  // : xorg(0.), yorg(0.), zoomx(1.), zoomy(1.), xmax(10), ymax(10),
147  // xmin(0), ymin(-10),
148  // xdelt(1), ydelt(1), gridx(true), gridy(true), gridColor(),
149  // curveNbr(1), curveList(NULL), scaleInitialized(false),
150  // firstPoint(true), nbDivisionx(10), nbDivisiony(10), topLeft(),
151  // width(0), height(0), graphZone(), dTopLeft(), dWidth(0),
152  // dHeight(0), dGraphZone(), dTopLeft3D(), dGraphZone3D(), cam(),
153  // cMo(), cMf(), w_xval(0), w_xsize(0), w_yval(0), w_ysize(0),
154  // w_zval(0), w_zsize(0), ptXorg(0), ptYorg(0), ptZorg(0),
155  // zoomx_3D(1.), zoomy_3D(1.), zoomz_3D(1.), nbDivisionz(10),
156  // zorg(1.), zoomz(1.), zmax(10), zmin(-10), zdelt(1), old_iPr(),
157  // old_iPz(), blockedr(false), blockedz(false), blocked(false),
158  // epsi(5), epsj(6), dispUnit(false), dispTitle(false),
159  // dispLegend(false), gridThickness(1)
160  // {
161  // throw vpException(vpException::functionNotImplementedError, "Not
162  // implemented!");
163  // }
164  // vpPlotGraph &operator=(const vpPlotGraph &){
165  // throw vpException(vpException::functionNotImplementedError, "Not
166  // implemented!"); return *this;
167  // }
168  //#endif
169 
170 public:
171  vpPlotGraph();
172  ~vpPlotGraph();
173 
174  bool check3Dline(vpImagePoint &iP1, vpImagePoint &iP2);
175  bool check3Dpoint(vpImagePoint &iP);
176  void clearGraphZone(vpImage<unsigned char> &I);
177  void computeGraphParameters();
178  void computeGraphParameters3D();
179 
180  void initGraph(unsigned int nbCurve);
181  void initSize(vpImagePoint topLeft, unsigned int width, unsigned int height, unsigned int margei,
182  unsigned int margej);
183  void initScale(vpImage<unsigned char> &I, const double xmin, const double xmax, const int nbDivx, const double ymin,
184  const double ymax, const int nbDivy, const bool gx, const bool gy);
185  void initScale(vpImage<unsigned char> &I, const double xmin, const double xmax, const int nbDivx, const double ymin,
186  const double ymax, const int nbDivy, const double zmin, const double zmax, const int nbDivz,
187  const bool gx, const bool gy);
188 
189  void displayGrid(vpImage<unsigned char> &I);
190  void displayUnit(vpImage<unsigned char> &I);
191  void displayTitle(vpImage<unsigned char> &I);
192  void displayLegend(vpImage<unsigned char> &I);
193  void displayGrid3D(vpImage<unsigned char> &I);
194 
195  void findPose();
196 
197  bool getPixelValue(vpImage<unsigned char> &I, vpImagePoint &iP);
198 
199  bool move(const vpImage<unsigned char> &I, vpMouseButton::vpMouseButtonType &button);
200  vpHomogeneousMatrix navigation(const vpImage<unsigned char> &I, bool &changed, vpMouseButton::vpMouseButtonType &b);
201 
202  void plot(vpImage<unsigned char> &I, const unsigned int curveNb, const double x, const double y);
203  vpMouseButton::vpMouseButtonType plot(vpImage<unsigned char> &I, const unsigned int curveNb, const double x,
204  const double y, const double z);
205  void replot(vpImage<unsigned char> &I);
206  void replot3D(vpImage<unsigned char> &I);
207 
208  void rescalex(unsigned int side, double extremity);
209  void rescaley(unsigned int side, double extremity);
210  void rescalez(unsigned int side, double extremity);
211  // void rescale(double &min, double &max, double &delta, const int nbDiv,
212  // int side);
213  void resetPointList(const unsigned int curveNum);
214 
215  void setCurveColor(const unsigned int curveNum, const vpColor &color);
216  void setCurveThickness(const unsigned int curveNum, const unsigned int thickness);
217  void setGridThickness(const unsigned int thickness) { this->gridThickness = thickness; };
218  void setLegend(const unsigned int curveNum, const std::string &legend);
219  void setTitle(const std::string &title);
220  void setUnitX(const std::string &unitx);
221  void setUnitY(const std::string &unity);
222  void setUnitZ(const std::string &unitz);
223 };
224 
225 #endif
226 #endif
227 #endif
Implementation of an homogeneous matrix and operations on such kind of matrices.
Class to define colors available for display functionnalities.
Definition: vpColor.h:120
Generic class defining intrinsic camera parameters.
Defines a rectangle in the plane.
Definition: vpRect.h:78
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:88