Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ViSP with software that can not be combined with the GNU
13  * GPL, please contact Inria about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * See http://visp.inria.fr for more information.
17  *
18  * This software was developed at:
19  * Inria Rennes - Bretagne Atlantique
20  * Campus Universitaire de Beaulieu
21  * 35042 Rennes Cedex
22  * France
23  *
24  * If you have questions regarding the use of this file, please contact
25  * Inria at visp@inria.fr
26  *
27  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29  *
30  * Description:
31  * Define a graph for the vpPlot class.
32  *
33  * Authors:
34  * Nicolas Melchior
35  *
36  *****************************************************************************/
37 
38 #ifndef DOXYGEN_SHOULD_SKIP_THIS
39 
40 #ifndef vpPlotGraph_H
41 #define vpPlotGraph_H
42 
43 #include <visp3/core/vpColor.h>
44 #include <visp3/core/vpImage.h>
45 
46 #include <visp3/gui/vpPlotCurve.h>
47 #include <visp3/core/vpMouseButton.h>
48 
49 #include <visp3/core/vpHomogeneousMatrix.h>
50 #include <visp3/core/vpRect.h>
51 
52 #include <visp3/core/vpCameraParameters.h>
53 #include <visp3/core/vpPoint.h>
54 
55 #if defined(VISP_HAVE_DISPLAY)
56 
57 class vpPlotGraph
58 {
59  public:
60  double xorg;
61  double yorg;
62  double zoomx;
63  double zoomy;
64  double xmax;
65  double ymax;
66  double xmin;
67  double ymin;
68  double xdelt;
69  double ydelt;
70  bool gridx;
71  bool gridy;
72  vpColor gridColor;
73  std::string title;
74  std::string unitx;
75  std::string unity;
76  unsigned int curveNbr;
77  vpPlotCurve* curveList;
78  bool scaleInitialized;
79  bool firstPoint;
80 
81  int nbDivisionx;
82  int nbDivisiony;
83 
84  //Graph complet
85  vpImagePoint topLeft;
86  unsigned int width;
87  unsigned int height;
88  vpRect graphZone;
89 
90  //Zone d'affichage
91  vpImagePoint dTopLeft;
92  unsigned int dWidth;
93  unsigned int dHeight;
94  vpRect dGraphZone;
95 
96  //Zone d'affichage
97  vpImagePoint dTopLeft3D;
98 // int dWidth;
99 // int dHeight;
100  vpRect dGraphZone3D;
101 
102  //3D part
103  vpCameraParameters cam;
106  double w_xval;
107  double w_xsize;
108  double w_yval;
109  double w_ysize;
110  double w_zval;
111  double w_zsize;
112  double ptXorg;
113  double ptYorg;
114  double ptZorg;
115  double zoomx_3D;
116  double zoomy_3D;
117  double zoomz_3D;
118 
119  int nbDivisionz;
120 
121  double zorg;
122  double zoomz;
123  double zmax;
124  double zmin;
125  double zdelt;
126  std::string unitz;
127  vpImagePoint old_iPr;
128  vpImagePoint old_iPz;
129  bool blockedr;
130  bool blockedz;
131  bool blocked;
132 
133  unsigned int epsi;
134  unsigned int epsj;
135 
136  bool dispUnit;
137  bool dispTitle;
138  bool dispLegend;
139 
140  unsigned int gridThickness;
141 
142 //private:
143 //#ifndef DOXYGEN_SHOULD_SKIP_THIS
144 // vpPlotGraph(const vpPlotGraph &)
145 // : xorg(0.), yorg(0.), zoomx(1.), zoomy(1.), xmax(10), ymax(10), xmin(0), ymin(-10),
146 // xdelt(1), ydelt(1), gridx(true), gridy(true), gridColor(), curveNbr(1), curveList(NULL),
147 // scaleInitialized(false), firstPoint(true), nbDivisionx(10), nbDivisiony(10), topLeft(),
148 // width(0), height(0), graphZone(), dTopLeft(), dWidth(0), dHeight(0), dGraphZone(),
149 // dTopLeft3D(), dGraphZone3D(), cam(), cMo(), cMf(), w_xval(0), w_xsize(0), w_yval(0), w_ysize(0),
150 // w_zval(0), w_zsize(0), ptXorg(0), ptYorg(0), ptZorg(0), zoomx_3D(1.), zoomy_3D(1.), zoomz_3D(1.),
151 // nbDivisionz(10), zorg(1.), zoomz(1.), zmax(10), zmin(-10), zdelt(1), old_iPr(), old_iPz(),
152 // blockedr(false), blockedz(false), blocked(false), epsi(5), epsj(6),
153 // dispUnit(false), dispTitle(false), dispLegend(false), gridThickness(1)
154 // {
155 // throw vpException(vpException::functionNotImplementedError, "Not implemented!");
156 // }
157 // vpPlotGraph &operator=(const vpPlotGraph &){
158 // throw vpException(vpException::functionNotImplementedError, "Not implemented!");
159 // return *this;
160 // }
161 //#endif
162 
163 public:
164  vpPlotGraph();
165  ~vpPlotGraph();
166 
167  bool check3Dline(vpImagePoint &iP1, vpImagePoint &iP2);
168  bool check3Dpoint(vpImagePoint &iP);
169  void clearGraphZone(vpImage<unsigned char> &I);
170  void computeGraphParameters();
171  void computeGraphParameters3D();
172 
173  void initGraph (unsigned int nbCurve);
174  void initSize (vpImagePoint topLeft, unsigned int width, unsigned int height, unsigned int margei, unsigned int margej);
175  void initScale(vpImage<unsigned char> &I, const double xmin, const double xmax, const int nbDivx, const double ymin, const double ymax, const int nbDivy, const bool gx, const bool gy);
176  void initScale(vpImage<unsigned char> &I, const double xmin, const double xmax, const int nbDivx, const double ymin, const double ymax, const int nbDivy, const double zmin, const double zmax, const int nbDivz, const bool gx, const bool gy);
177 
178  void displayGrid (vpImage<unsigned char> &I);
179  void displayUnit (vpImage<unsigned char> &I);
180  void displayTitle (vpImage<unsigned char> &I);
181  void displayLegend (vpImage<unsigned char> &I);
182  void displayGrid3D (vpImage<unsigned char> &I);
183 
184  void findPose();
185 
186  bool getPixelValue(vpImage<unsigned char> &I, vpImagePoint &iP);
187 
188  bool move(const vpImage<unsigned char> &I, vpMouseButton::vpMouseButtonType &button);
189  vpHomogeneousMatrix navigation(const vpImage<unsigned char> &I, bool &changed, vpMouseButton::vpMouseButtonType &b);
190 
191  void plot (vpImage<unsigned char> &I, const unsigned int curveNb, const double x, const double y);
192  vpMouseButton::vpMouseButtonType plot (vpImage<unsigned char> &I, const unsigned int curveNb, const double x, const double y, const double z);
193  void replot (vpImage<unsigned char> &I);
194  void replot3D (vpImage<unsigned char> &I);
195 
196  void rescalex(unsigned int side, double extremity);
197  void rescaley(unsigned int side, double extremity);
198  void rescalez(unsigned int side, double extremity);
199  //void rescale(double &min, double &max, double &delta, const int nbDiv, int side);
200  void resetPointList(const unsigned int curveNum);
201 
202  void setCurveColor(const unsigned int curveNum, const vpColor color);
203  void setCurveThickness(const unsigned int curveNum, const unsigned int thickness);
204  void setGridThickness (const unsigned int thickness) {
205  this->gridThickness = thickness;
206  };
207  void setLegend (const unsigned int curveNum, const std::string &legend);
208  void setTitle (const std::string &title);
209  void setUnitX (const std::string &unitx);
210  void setUnitY (const std::string &unity);
211  void setUnitZ (const std::string &unitz);
212 };
213 
214 #endif
215 #endif
216 #endif
217 
Implementation of an homogeneous matrix and operations on such kind of matrices.
Class to define colors available for display functionnalities.
Definition: vpColor.h:121
Generic class defining intrinsic camera parameters.
Defines a rectangle in the plane.
Definition: vpRect.h:82
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:88