laserscanwidget.cpp
Go to the documentation of this file.
1 
19 #include <iostream>
20 
21 #include <QtGui/QApplication>
22 #include <QtConcurrentRun>
23 
24 #include <qapplication.h>
25 #ifndef Q_MOC_RUN
26 #include <sensor_msgs/LaserScan.h>
27 #include <ros/ros.h>
28 #include <ros/init.h>
29 #include <qwt_series_data.h>
30 #include <qwt_symbol.h>
31 #endif
32 #include <QLayout>
33 
34 using namespace std;
35  LaserScanWidget::LaserScanWidget(QWidget *parent, int appearance, unsigned int showData, LaserScanThread *currentThread) :
36  QWidget(parent)
37  {
38  this->currentThread = currentThread;
39  connect(currentThread, SIGNAL(valueChanged()),this, SLOT(replot()));
40  //plot_polar = 0;
41  plot_flat = 0;
42  this->appearance = -1;
43  setGraph(appearance, showData);
44  }
45 
46  void LaserScanWidget::setGraph(int appearance, unsigned int showData)
47  {
48  QPen pen1(Qt::gray, 1, Qt::SolidLine);
49  QPen pen2(Qt::red, 1, Qt::SolidLine);
50  QPen pen3(Qt::green, 1, Qt::SolidLine);
51  QPen pen4(Qt::red, 3, Qt::SolidLine);
52  QPen pen5(Qt::red, 3, Qt::SolidLine);
53 
54  if (this->appearance != appearance)
55  {
56  /*if (plot_polar != 0)
57  {
58  plot_polar->setVisible(false);
59  //layout()->removeWidget(plot_polar);
60  delete plot_polar;
61  plot_polar = 0;
62  }*/
63  if (plot_flat != 0)
64  {
65  plot_flat->setVisible(false);
66  //layout()->removeWidget(plot_flat);
67  delete plot_flat;
68  plot_flat = 0;
69  }
70 
71  this->appearance = appearance;
72 
73  if (appearance == APPEARENCE_POLAR)
74  {
75  /*int value_count;
76  value_count = currentThread->data_field_size*(360/currentThread->angle_spread);
77  plot_polar = new QwtPolarPlot(this);
78  plot_polar->setAzimuthOrigin(0);
79 
80  plot_polar->setScale(QwtPolar::Azimuth, 0, value_count);
81  plot_polar->setAzimuthOrigin(currentThread->starting_angle*(M_PI/180));
82  plot_polar->setScale(QwtPolar::Radius, 0, 4.0);
83  curve_roh_polar = new QwtPolarCurve();
84  curve_roh_polar->setPen(pen1);
85  curve_roh_polar->setSymbol(new QwtSymbol(QwtSymbol::Ellipse,QBrush(Qt::blue),QPen (Qt::blue),QSize(1,1)));
86  seriesData_raw = new PolarPointSeriesData(&(currentThread->dx[0]), &(currentThread->data_raw[0]), currentThread->data_field_size);
87  curve_roh_polar->setData(seriesData_raw);
88 
89  curve_gemittelt_polar = new QwtPolarCurve();
90  curve_gemittelt_polar->setPen(pen2);
91  curve_gemittelt_polar->setSymbol(new QwtSymbol(QwtSymbol::Ellipse,QBrush(Qt::blue),QPen (Qt::blue),QSize(1,1)));
92  seriesData_avg = new PolarPointSeriesData(&(currentThread->dx[0]), &(currentThread->data_avg[0]), currentThread->data_field_size);
93  curve_gemittelt_polar->setData(seriesData_avg);
94 
95  curve_gauss_polar = new QwtPolarCurve();
96  curve_gauss_polar->setPen(pen3);
97  curve_gauss_polar->setSymbol(new QwtSymbol(QwtSymbol::Ellipse,QBrush(Qt::blue),QPen (Qt::blue),QSize(1,1)));
98  seriesData_filtered = new PolarPointSeriesData(&(currentThread->dx[0]), &(currentThread->data_filtered[0]), currentThread->data_field_size);
99  curve_gauss_polar->setData(seriesData_filtered);
100 
101  curve_erkannt_polar = new QwtPolarCurve();
102  curve_erkannt_polar->setPen(pen4);
103  curve_erkannt_polar->setSymbol(new QwtSymbol(QwtSymbol::Ellipse,QBrush(Qt::blue),QPen (Qt::blue),QSize(1,1)));
104  seriesData_segments = new PolarPointSeriesData(&(currentThread->dx[0]), &(currentThread->data_segments[0]), currentThread->data_field_size);
105  curve_erkannt_polar->setData(seriesData_segments);
106 
107  curve_ecke_polar = new QwtPolarCurve();
108  curve_ecke_polar->setPen(pen5);
109  curve_ecke_polar->setSymbol(new QwtSymbol(QwtSymbol::Ellipse,QBrush(Qt::blue),QPen (Qt::blue),QSize(1,1)));
110  seriesData_edges = new PolarPointSeriesData(&(currentThread->dx[0]), &(currentThread->data_edges[0]), currentThread->data_field_size);
111  curve_ecke_polar->setData(seriesData_edges);
112 
113  plot_polar->setAutoReplot(true);
114  plot_polar->show();
115  plot_polar->resize(this->width(),this->height());*/
116  }
117  else if (appearance == APPEARENCE_FLAT)
118  {
119  plot_flat = new QwtPlot(this);
120  plot_flat->setAxisScale(QwtPlot::yLeft, 0,6);
122  //plot_flat->setAxisScale(QwtPlot::xBottom, currentThread->starting_angle,currentThread->starting_angle + currentThread->data_field_size * currentThread->angle_spread);
123  curve_roh_flat = new QwtPlotCurve();
124  curve_roh_flat->setPen(pen1);
126 
127  curve_gemittelt_flat = new QwtPlotCurve();
128  curve_gemittelt_flat->setPen(pen2);
130 
131  curve_gauss_flat = new QwtPlotCurve();
132  curve_gauss_flat->setPen(pen3);
134 
135  curve_erkannt_flat = new QwtPlotCurve();
136  curve_erkannt_flat->setPen(pen4);
138 
139  curve_ecke_flat = new QwtPlotCurve();
140  curve_ecke_flat->setPen(pen5);
142 
143  plot_flat->setAutoReplot(true);
144  plot_flat->show();
145  plot_flat->resize(this->width(),this->height());
146  }
147  setCurves(showData);
148  }
149  }
150 
152  {
153  if (this->appearance == APPEARENCE_POLAR)
154  {
155  /*seriesData_raw->update(&(currentThread->dx[0]), &(currentThread->data_raw[0]), currentThread->data_field_size);
156  seriesData_avg->update(&(currentThread->dx[0]), &(currentThread->data_avg[0]), currentThread->data_field_size);
157  seriesData_filtered->update(&(currentThread->dx[0]), &(currentThread->data_filtered[0]),currentThread->data_field_size);
158  seriesData_segments->update(&(currentThread->dx[0]), &(currentThread->data_segments[0]), currentThread->data_field_size);
159  seriesData_edges->update(&(currentThread->dx[0]), &(currentThread->data_edges[0]), currentThread->data_field_size);
160  plot_polar->replot();*/
161  }
162  else if (appearance == APPEARENCE_FLAT)
163  {
164  plot_flat->replot();
165  }
166  }
167 
168 
169  void LaserScanWidget::setCurves(unsigned int showData)
170  {
171  if (this->appearance == APPEARENCE_POLAR)
172  {
173  /*if ((showData & 1) != 0)
174  {
175  curve_roh_polar->attach(plot_polar);
176  curve_roh_polar->show();
177  }
178  else
179  {
180  curve_roh_polar->detach();
181  }
182  if ((showData & 2) != 0)
183  {
184  curve_gemittelt_polar->attach(plot_polar);
185  curve_gemittelt_polar->show();
186  }
187  else
188  {
189  curve_gemittelt_polar->detach();
190  }
191  if ((showData & 4) != 0)
192  {
193  curve_gauss_polar->attach(plot_polar);
194  curve_gauss_polar->show();
195  }
196  else
197  {
198  curve_gauss_polar->detach();
199  }
200  if ((showData & 8) != 0)
201  {
202  curve_erkannt_polar->attach(plot_polar);
203  curve_erkannt_polar->show();
204  }
205  else
206  {
207  curve_erkannt_polar->detach();
208  }
209  if ((showData & 16) != 0)
210  {
211  curve_ecke_polar->attach(plot_polar);
212  curve_ecke_polar->show();
213  }
214  else
215  {
216  curve_ecke_polar->detach();
217  }
218  plot_polar->replot();*/
219  }
220  else if (appearance == APPEARENCE_FLAT)
221  {
222  if ((showData & 1) != 0)
223  {
224  curve_roh_flat->attach(plot_flat);
225  curve_roh_flat->show();
226  }
227  else
228  {
229  curve_roh_flat->detach();
230  }
231  if ((showData & 2) != 0)
232  {
234  curve_gemittelt_flat->show();
235  }
236  else
237  {
238  curve_gemittelt_flat->detach();
239  }
240  if ((showData & 4) != 0)
241  {
242  curve_gauss_flat->attach(plot_flat);
243  curve_gauss_flat->show();
244  }
245  else
246  {
247  curve_gauss_flat->detach();
248  }
249  if ((showData & 8) != 0)
250  {
251  curve_erkannt_flat->attach(plot_flat);
252  curve_erkannt_flat->show();
253  }
254  else
255  {
256  curve_erkannt_flat->detach();
257  }
258  if ((showData & 16) != 0)
259  {
260  curve_ecke_flat->attach(plot_flat);
261  curve_ecke_flat->show();
262  }
263  else
264  {
265  curve_ecke_flat->detach();
266  }
267  plot_flat->replot();
268  }
269  }
270 
271  void LaserScanWidget::resizeEvent(QResizeEvent * event)
272  {
273  if (this->appearance == APPEARENCE_POLAR)
274  {
275  //plot_polar->resize(this->width(),this->height());
276  }
277  else
278  {
279  plot_flat->resize(this->width(),this->height());
280  }
281  QWidget::resizeEvent(event);
282  }
283 
284 
285 
QwtPlotCurve * curve_roh_flat
LaserScanWidget(QWidget *parent=0, int appearance=APPEARENCE_FLAT, unsigned int showData=1, LaserScanThread *currentThread=0)
void setGraph(int appearance, unsigned int showData)
LaserScanThread * currentThread
QwtPlotCurve * curve_gauss_flat
void resizeEvent(QResizeEvent *event)
QwtPlotCurve * curve_ecke_flat
static const int APPEARENCE_POLAR
QwtPlot * plot_flat
double * data_segments
QwtPlotCurve * curve_erkannt_flat
void setCurves(unsigned int showData)
double * data_filtered
unsigned int data_field_size
static const int APPEARENCE_FLAT
QwtPlotCurve * curve_gemittelt_flat


asr_mild_calibration_tool
Author(s): Aumann Florian, Heller Florian, Meißner Pascal
autogenerated on Mon Dec 2 2019 03:11:43