Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vpPlotGraph.h
1/*
2 * ViSP, open source Visual Servoing Platform software.
3 * Copyright (C) 2005 - 2024 by Inria. All rights reserved.
4 *
5 * This software is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
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 https://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
34#ifndef VP_PLOT_GRAPH_H
35#define VP_PLOT_GRAPH_H
36
37#include <visp3/core/vpConfig.h>
38
39#ifndef DOXYGEN_SHOULD_SKIP_THIS
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
56
57class vpPlotGraph
58{
59public:
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;
104 vpHomogeneousMatrix cMo;
105 vpHomogeneousMatrix cMf;
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),
146 // xmin(0), ymin(-10),
147 // xdelt(1), ydelt(1), gridx(true), gridy(true), gridColor(),
148 // curveNbr(1), curveList(nullptr), scaleInitialized(false),
149 // firstPoint(true), nbDivisionx(10), nbDivisiony(10), topLeft(),
150 // width(0), height(0), graphZone(), dTopLeft(), dWidth(0),
151 // dHeight(0), dGraphZone(), dTopLeft3D(), dGraphZone3D(), cam(),
152 // cMo(), cMf(), w_xval(0), w_xsize(0), w_yval(0), w_ysize(0),
153 // w_zval(0), w_zsize(0), ptXorg(0), ptYorg(0), ptZorg(0),
154 // zoomx_3D(1.), zoomy_3D(1.), zoomz_3D(1.), nbDivisionz(10),
155 // zorg(1.), zoomz(1.), zmax(10), zmin(-10), zdelt(1), old_iPr(),
156 // old_iPz(), blockedr(false), blockedz(false), blocked(false),
157 // epsi(5), epsj(6), dispUnit(false), dispTitle(false),
158 // dispLegend(false), gridThickness(1)
159 // {
160 // throw vpException(vpException::functionNotImplementedError, "Not
161 // implemented!");
162 // }
163 // vpPlotGraph &operator=(const vpPlotGraph &){
164 // throw vpException(vpException::functionNotImplementedError, "Not
165 // implemented!"); return *this;
166 // }
167 //#endif
168
169public:
170 vpPlotGraph();
171 virtual ~vpPlotGraph();
172
173 bool check3Dline(vpImagePoint &iP1, vpImagePoint &iP2);
174 bool check3Dpoint(vpImagePoint &iP);
175 void clearGraphZone(vpImage<unsigned char> &I);
176 void computeGraphParameters();
177 void computeGraphParameters3D();
178
179 void initGraph(unsigned int nbCurve);
180 void initSize(vpImagePoint topLeft, unsigned int width, unsigned int height, unsigned int margei,
181 unsigned int margej);
182 void initScale(vpImage<unsigned char> &I, double xmin, double xmax, int nbDivx, double ymin, double ymax, int nbDivy,
183 bool gx, bool gy);
184 void initScale(vpImage<unsigned char> &I, double xmin, double xmax, int nbDivx, double ymin, double ymax, int nbDivy,
185 double zmin, double zmax, int nbDivz, bool gx, bool gy);
186
187 void displayGrid(vpImage<unsigned char> &I);
188 void displayUnit(vpImage<unsigned char> &I);
189 void displayTitle(vpImage<unsigned char> &I);
190 void displayLegend(vpImage<unsigned char> &I);
191 void displayGrid3D(vpImage<unsigned char> &I);
192
193 void findPose();
194
195 bool getPixelValue(vpImage<unsigned char> &I, vpImagePoint &iP);
196
197 bool move(const vpImage<unsigned char> &I, vpMouseButton::vpMouseButtonType &button);
198 vpHomogeneousMatrix navigation(const vpImage<unsigned char> &I, bool &changed, vpMouseButton::vpMouseButtonType &b);
199
200 void plot(vpImage<unsigned char> &I, unsigned int curveNb, double x, double y);
201 vpMouseButton::vpMouseButtonType plot(vpImage<unsigned char> &I, unsigned int curveNb, double x, double y, double z);
202 void replot(vpImage<unsigned char> &I);
203 void replot3D(vpImage<unsigned char> &I);
204
205 void rescalex(unsigned int side, double extremity);
206 void rescaley(unsigned int side, double extremity);
207 void rescalez(unsigned int side, double extremity);
208 // void rescale(double &min, double &max, double &delta, int nbDiv, int side);
209 void resetPointList(unsigned int curveNum);
210
211 void setCurveColor(unsigned int curveNum, const vpColor &color);
212 void setCurveThickness(unsigned int curveNum, unsigned int thickness);
213 void setGridThickness(unsigned int thickness) { this->gridThickness = thickness; }
214 void setLegend(unsigned int curveNum, const std::string &legend);
215 void setTitle(const std::string &title);
216 void setUnitX(const std::string &unitx);
217 void setUnitY(const std::string &unity);
218 void setUnitZ(const std::string &unitz);
219};
220
221
222END_VISP_NAMESPACE
223#endif
224#endif
225#endif