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