stdr_info_connector.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  STDR Simulator - Simple Two DImensional Robot Simulator
3  Copyright (C) 2013 STDR Simulator
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 3 of the License, or
7  (at your option) any later version.
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12  You should have received a copy of the GNU General Public License
13  along with this program; if not, write to the Free Software Foundation,
14  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15 
16  Authors :
17  * Manos Tsardoulias, etsardou@gmail.com
18  * Aris Thallas, aris.thallas@gmail.com
19  * Chris Zalidis, zalidis@gmail.com
20 ******************************************************************************/
21 
23 
24 namespace stdr_gui
25 {
32  CInfoConnector::CInfoConnector(int argc, char **argv):
33  QObject(),
34  loader(argc,argv),
35  argc_(argc),
36  argv_(argv)
37  {
38  QObject::connect(
39  loader.stdrInformationTree,
40  SIGNAL(itemClicked(QTreeWidgetItem*, int)),
41  this,
42  SLOT(treeItemClicked(QTreeWidgetItem*, int)));
43 
44  QObject::connect(
45  this,
46  SIGNAL(adaptSignal()),
47  this,
48  SLOT(adaptSlot()));
49 
50  QObject::connect(
51  loader.stdrInformationTree,
52  SIGNAL(itemCollapsed(QTreeWidgetItem *)),
53  this,
54  SLOT(adaptColumns(QTreeWidgetItem *)));
55 
56  QObject::connect(
57  loader.stdrInformationTree,
58  SIGNAL(itemExpanded(QTreeWidgetItem *)),
59  this,
60  SLOT(adaptColumns(QTreeWidgetItem *)));
61  }
62 
69  void CInfoConnector::adaptColumns(QTreeWidgetItem *item, int column)
70  {
71  loader.stdrInformationTree->resizeColumnToContents(0);
72  loader.stdrInformationTree->resizeColumnToContents(1);
73  loader.stdrInformationTree->resizeColumnToContents(2);
74  loader.stdrInformationTree->resizeColumnToContents(3);
75  }
76 
82  void CInfoConnector::adaptColumns(QTreeWidgetItem *item)
83  {
84  loader.stdrInformationTree->resizeColumnToContents(0);
85  loader.stdrInformationTree->resizeColumnToContents(1);
86  loader.stdrInformationTree->resizeColumnToContents(2);
87  loader.stdrInformationTree->resizeColumnToContents(3);
88  }
89 
95  {
96  loader.stdrInformationTree->resizeColumnToContents(0);
97  loader.stdrInformationTree->resizeColumnToContents(1);
98  loader.stdrInformationTree->resizeColumnToContents(2);
99  loader.stdrInformationTree->resizeColumnToContents(3);
100  }
101 
109  void CInfoConnector::updateMapInfo(float width,float height,float ocgd)
110  {
111  loader.updateMapInfo(width,height,ocgd);
112  Q_EMIT adaptSignal();
113  }
114 
121  const stdr_msgs::RobotIndexedVectorMsg& msg)
122  {
123 
124  loader.deleteTree();
125  loader.updateRobots(msg);
126 
127  Q_EMIT adaptSignal();
128  }
129 
136  void CInfoConnector::treeItemClicked ( QTreeWidgetItem * item, int column )
137  {
138  adaptColumns(item, column);
139  if(item == &loader.robotsInfo || item == &loader.generalInfo)
140  {
141  return;
142  }
143  else if(item->parent()->text(0) == QString("Lasers") && column == 3)
144  {
145  Q_EMIT laserVisualizerClicked(
146  item->parent()->parent()->text(0), item->text(0));
147  }
148  else if(item->parent()->text(0) == QString("Lasers") && column == 2)
149  {
150  Q_EMIT laserVisibilityClicked(
151  item->parent()->parent()->text(0), item->text(0));
152  }
153  else if(item->parent()->text(0) == QString("Sonars") && column == 3)
154  {
155  Q_EMIT sonarVisualizerClicked(
156  item->parent()->parent()->text(0),item->text(0));
157  }
158  else if(item->parent()->text(0) == QString("Sonars") && column == 2)
159  {
160  Q_EMIT sonarVisibilityClicked(
161  item->parent()->parent()->text(0),item->text(0));
162  }
163  else if(item->parent()->text(0) == QString("RFID readers") && column == 2)
164  {
166  item->parent()->parent()->text(0), item->text(0));
167  }
168  else if(item->parent()->text(0) == QString("CO2 sensors") && column == 2)
169  {
171  item->parent()->parent()->text(0), item->text(0));
172  }
173  else if(item->parent()->text(0) == QString("Thermal sensors") && column == 2)
174  {
176  item->parent()->parent()->text(0), item->text(0));
177  }
178  else if(item->parent()->text(0) == QString("Sound sensors") && column == 2)
179  {
181  item->parent()->parent()->text(0), item->text(0));
182  }
183  else if(item->parent() == &loader.robotsInfo && column == 3)
184  {
185  Q_EMIT robotVisualizerClicked(
186  item->text(0));
187  }
188  else if(item->parent() == &loader.robotsInfo && column == 2)
189  {
190  Q_EMIT robotVisibilityClicked(
191  item->text(0));
192  }
193  }
194 
200  {
201  return static_cast<QWidget *>(&loader);
202  }
203 
212  QString robotName,QString laserName,char vs)
213  {
214  for(int i = 0 ; i < loader.robotsInfo.childCount() ; i++)
215  {
216  QString text = loader.robotsInfo.child(i)->text(0);
217  if(text == robotName)
218  {
219  QTreeWidgetItem *it = loader.robotsInfo.child(i);
220  for(int j = 0 ; j < it->childCount() ; j++)
221  {
222  if(it->child(j)->text(0) == QString("Lasers"))
223  {
224  for(int k = 0 ; k < it->child(j)->childCount() ; k++)
225  {
226  if(it->child(j)->child(k)->text(0) == laserName)
227  {
228  QTreeWidgetItem *inIt = it->child(j)->child(k);
229  switch(vs)
230  {
231  case 0:
232  {
233  inIt->setIcon(2,loader.visible_icon_on_);
234  break;
235  }
236  case 1:
237  {
238  inIt->setIcon(2,loader.visible_icon_trans_);
239  break;
240  }
241  case 2:
242  {
243  inIt->setIcon(2,loader.visible_icon_off_);
244  break;
245  }
246  }
247  return;
248  }
249  }
250  }
251  }
252  }
253  }
254  }
255 
264  QString robotName,QString sonarName,char vs)
265  {
266  for(int i = 0 ; i < loader.robotsInfo.childCount() ; i++)
267  {
268  QString text = loader.robotsInfo.child(i)->text(0);
269  if(text == robotName)
270  {
271  QTreeWidgetItem *it = loader.robotsInfo.child(i);
272  for(int j = 0 ; j < it->childCount() ; j++)
273  {
274  if(it->child(j)->text(0) == QString("Sonars"))
275  {
276  for(int k = 0 ; k < it->child(j)->childCount() ; k++)
277  {
278  if(it->child(j)->child(k)->text(0) == sonarName)
279  {
280  QTreeWidgetItem *inIt = it->child(j)->child(k);
281  switch(vs)
282  {
283  case 0:
284  {
285  inIt->setIcon(2,loader.visible_icon_on_);
286  break;
287  }
288  case 1:
289  {
290  inIt->setIcon(2,loader.visible_icon_trans_);
291  break;
292  }
293  case 2:
294  {
295  inIt->setIcon(2,loader.visible_icon_off_);
296  break;
297  }
298  }
299  return;
300  }
301  }
302  }
303  }
304  }
305  }
306  }
307 
316  QString robotName,QString rfidReaderName,char vs)
317  {
318  for(int i = 0 ; i < loader.robotsInfo.childCount() ; i++)
319  {
320  QString text = loader.robotsInfo.child(i)->text(0);
321  if(text == robotName)
322  {
323  QTreeWidgetItem *it = loader.robotsInfo.child(i);
324  for(int j = 0 ; j < it->childCount() ; j++)
325  {
326  if(it->child(j)->text(0) == QString("RFID readers"))
327  {
328  for(int k = 0 ; k < it->child(j)->childCount() ; k++)
329  {
330  if(it->child(j)->child(k)->text(0) == rfidReaderName)
331  {
332  QTreeWidgetItem *inIt = it->child(j)->child(k);
333  switch(vs)
334  {
335  case 0:
336  {
337  inIt->setIcon(2,loader.visible_icon_on_);
338  break;
339  }
340  case 1:
341  {
342  inIt->setIcon(2,loader.visible_icon_trans_);
343  break;
344  }
345  case 2:
346  {
347  inIt->setIcon(2,loader.visible_icon_off_);
348  break;
349  }
350  }
351  return;
352  }
353  }
354  }
355  }
356  }
357  }
358  }
367  QString robotName,QString sensorName,char vs)
368  {
369  for(int i = 0 ; i < loader.robotsInfo.childCount() ; i++)
370  {
371  QString text = loader.robotsInfo.child(i)->text(0);
372  if(text == robotName)
373  {
374  QTreeWidgetItem *it = loader.robotsInfo.child(i);
375  for(int j = 0 ; j < it->childCount() ; j++)
376  {
377  if(it->child(j)->text(0) == QString("CO2 sensors"))
378  {
379  for(int k = 0 ; k < it->child(j)->childCount() ; k++)
380  {
381  if(it->child(j)->child(k)->text(0) == sensorName)
382  {
383  QTreeWidgetItem *inIt = it->child(j)->child(k);
384  switch(vs)
385  {
386  case 0:
387  {
388  inIt->setIcon(2,loader.visible_icon_on_);
389  break;
390  }
391  case 1:
392  {
393  inIt->setIcon(2,loader.visible_icon_trans_);
394  break;
395  }
396  case 2:
397  {
398  inIt->setIcon(2,loader.visible_icon_off_);
399  break;
400  }
401  }
402  return;
403  }
404  }
405  }
406  }
407  }
408  }
409  }
418  QString robotName,QString sensorName,char vs)
419  {
420  for(int i = 0 ; i < loader.robotsInfo.childCount() ; i++)
421  {
422  QString text = loader.robotsInfo.child(i)->text(0);
423  if(text == robotName)
424  {
425  QTreeWidgetItem *it = loader.robotsInfo.child(i);
426  for(int j = 0 ; j < it->childCount() ; j++)
427  {
428  if(it->child(j)->text(0) == QString("Thermal sensors"))
429  {
430  for(int k = 0 ; k < it->child(j)->childCount() ; k++)
431  {
432  if(it->child(j)->child(k)->text(0) == sensorName)
433  {
434  QTreeWidgetItem *inIt = it->child(j)->child(k);
435  switch(vs)
436  {
437  case 0:
438  {
439  inIt->setIcon(2,loader.visible_icon_on_);
440  break;
441  }
442  case 1:
443  {
444  inIt->setIcon(2,loader.visible_icon_trans_);
445  break;
446  }
447  case 2:
448  {
449  inIt->setIcon(2,loader.visible_icon_off_);
450  break;
451  }
452  }
453  return;
454  }
455  }
456  }
457  }
458  }
459  }
460  }
469  QString robotName,QString sensorName,char vs)
470  {
471  for(int i = 0 ; i < loader.robotsInfo.childCount() ; i++)
472  {
473  QString text = loader.robotsInfo.child(i)->text(0);
474  if(text == robotName)
475  {
476  QTreeWidgetItem *it = loader.robotsInfo.child(i);
477  for(int j = 0 ; j < it->childCount() ; j++)
478  {
479  if(it->child(j)->text(0) == QString("Sound sensors"))
480  {
481  for(int k = 0 ; k < it->child(j)->childCount() ; k++)
482  {
483  if(it->child(j)->child(k)->text(0) == sensorName)
484  {
485  QTreeWidgetItem *inIt = it->child(j)->child(k);
486  switch(vs)
487  {
488  case 0:
489  {
490  inIt->setIcon(2,loader.visible_icon_on_);
491  break;
492  }
493  case 1:
494  {
495  inIt->setIcon(2,loader.visible_icon_trans_);
496  break;
497  }
498  case 2:
499  {
500  inIt->setIcon(2,loader.visible_icon_off_);
501  break;
502  }
503  }
504  return;
505  }
506  }
507  }
508  }
509  }
510  }
511  }
512 
519  void CInfoConnector::setRobotVisibility(QString robotName,char vs)
520  {
521  for(int i = 0 ; i < loader.robotsInfo.childCount() ; i++)
522  {
523  QString text = loader.robotsInfo.child(i)->text(0);
524  if(text == robotName)
525  {
526  switch(vs)
527  {
528  case 0:
529  {
530  loader.robotsInfo.child(i)->setIcon(2,loader.visible_icon_on_);
531  break;
532  }
533  case 1:
534  {
535  loader.robotsInfo.child(i)->setIcon(2,loader.visible_icon_trans_);
536  break;
537  }
538  case 2:
539  {
540  loader.robotsInfo.child(i)->setIcon(2,loader.visible_icon_off_);
541  break;
542  }
543  }
544  QTreeWidgetItem *it = loader.robotsInfo.child(i);
545  for(int j = 0 ; j < it->childCount() ; j++)
546  {
547  if(it->child(j)->text(0) == QString("Sonars"))
548  {
549  for(int k = 0 ; k < it->child(j)->childCount() ; k++)
550  {
551  QTreeWidgetItem *inIt = it->child(j)->child(k);
552  switch(vs)
553  {
554  case 0:
555  {
556  inIt->setIcon(2,loader.visible_icon_on_);
557  break;
558  }
559  case 1:
560  {
561  inIt->setIcon(2,loader.visible_icon_trans_);
562  break;
563  }
564  case 2:
565  {
566  inIt->setIcon(2,loader.visible_icon_off_);
567  break;
568  }
569  }
570  }
571  }
572  if(it->child(j)->text(0) == QString("Lasers"))
573  {
574  for(int k = 0 ; k < it->child(j)->childCount() ; k++)
575  {
576  QTreeWidgetItem *inIt = it->child(j)->child(k);
577  switch(vs)
578  {
579  case 0:
580  {
581  inIt->setIcon(2,loader.visible_icon_on_);
582  break;
583  }
584  case 1:
585  {
586  inIt->setIcon(2,loader.visible_icon_trans_);
587  break;
588  }
589  case 2:
590  {
591  inIt->setIcon(2,loader.visible_icon_off_);
592  break;
593  }
594  }
595  }
596  }
597  }
598  return;
599  }
600  }
601  }
602 }
void setLaserVisibility(QString robotName, QString laserName, char vs)
Changes a laser visibility icon.
QIcon visible_icon_off_
Icon of visibility medium (orange)
void laserVisualizerClicked(QString robotName, QString laserName)
Emmited when a laser visualizer is clicked.
QIcon visible_icon_on_
< Icon of visibility on (green)
void co2SensorVisibilityClicked(QString robotName, QString co2SensorName)
Emmited when a co2 sensor visibility icon is clicked.
void setCO2SensorVisibility(QString robotName, QString co2SensorName, char vs)
Changes a co2 sensor visibility icon.
QWidget * getLoader(void)
Returns the CInfoLoader object.
void adaptSignal(void)
Emmited when resize of columns according to whats visible is needed.
void robotVisualizerClicked(QString robotName)
Emmited when a robot visualizer is clicked.
void deleteTree(void)
Deletes the information tree.
QTreeWidgetItem robotsInfo
Tree item : Map height.
void robotVisibilityClicked(QString robotName)
Emmited when a robot visibility icon is clicked.
void updateTree(const stdr_msgs::RobotIndexedVectorMsg &msg)
Updates the information tree according to the ensemble of robots.
void sonarVisibilityClicked(QString robotName, QString sonarName)
Emmited when a sonar visibility icon is clicked.
void updateMapInfo(float width, float height, float ocgd)
Updates the information tree according to the specific map.
void sonarVisualizerClicked(QString robotName, QString sonarName)
Emmited when a sonar visualizer is clicked.
CInfoLoader loader
< Object of CInfoLoader
void laserVisibilityClicked(QString robotName, QString laserName)
Emmited when a laser visibility icon is clicked.
void setSonarVisibility(QString robotName, QString sonarName, char vs)
Changes a sonar visibility icon.
void updateRobots(const stdr_msgs::RobotIndexedVectorMsg &msg)
Updates the information tree according to the ensemble of robots.
The main namespace for STDR GUI.
QIcon visible_icon_trans_
Tree item : Root.
void adaptColumns(QTreeWidgetItem *item, int column)
Adapts the columns width according to what is visible when an item is clicked.
void treeItemClicked(QTreeWidgetItem *item, int column)
Called when a click occurs in the tree.
void thermalSensorVisibilityClicked(QString robotName, QString thermalSensorName)
Emmited when a thermal sensor visibility icon is clicked.
void setRfidReaderVisibility(QString robotName, QString rfidReaderName, char vs)
Changes a rfid reader visibility icon.
void adaptSlot(void)
Adapts the columns width according to what is visible. Called when adaptSignal is emmited...
void setRobotVisibility(QString robotName, char vs)
Changes a robot visibility icon.
QTreeWidgetItem generalInfo
Tree item : Robot root.
void setThermalSensorVisibility(QString robotName, QString thermalSensorName, char vs)
Changes a thermal sensor visibility icon.
void rfidReaderVisibilityClicked(QString robotName, QString rfidReaderName)
Emmited when a rfid reader visibility icon is clicked.
CInfoConnector(int argc, char **argv)
Default contructor.
void setSoundSensorVisibility(QString robotName, QString soundSensorName, char vs)
Changes a sound sensor visibility icon.
void updateMapInfo(float width, float height, float ocgd)
Updates the information tree according to the specific map.
void soundSensorVisibilityClicked(QString robotName, QString soundSensorName)
Emmited when a sound sensor visibility icon is clicked.


stdr_gui
Author(s): Manos Tsardoulias
autogenerated on Mon Jun 10 2019 15:15:16