direcs  2012-09-30
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
gui.cpp
Go to the documentation of this file.
1 /*************************************************************************
2  * Copyright (C) Markus Knapp *
3  * www.direcs.de *
4  * *
5  * This file is part of direcs. *
6  * *
7  * direcs is free software: you can redistribute it and/or modify it *
8  * under the terms of the GNU General Public License as published *
9  * by the Free Software Foundation, version 3 of the License. *
10  * *
11  * direcs is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU General Public License *
17  * along with direcs. If not, see <http://www.gnu.org/licenses/>. *
18  * *
19  *************************************************************************/
20 
21 #include "gui.h"
22 
23 
24 Gui::Gui(bool useSmallGUI, SettingsDialog *s, JoystickDialog *j, AboutDialog *a, QMainWindow *parent) : QMainWindow(parent)
25 {
26  // copy the pointer from the original SensorThread object
27  settingsDialog = s;
28  joystickDialog = j;
29  aboutDialog = a;
30 
31  robotIsOn = false;
32  consoleMode = false;
33  useLargeGUI = true;
34 
35 #ifdef ACTIVELASERVIEW
36  laserXPos = 0; // correct value is set in the initLaserView()!!
37  laserYPos = 0; // correct value is set in the initLaserView()!!
38 #endif
39 
48 
49  // define some nice green and red colors
50  labelFillColorGreen = QColor(64, 255, 64);
51  labelFillColorRed = QColor(255, 64, 64);
52  labelFillColorBlue = QColor(64, 64, 255);
53  gridColor = QColor(Qt::black);
54 
55  // store which GUI to use
56  // the robot GUI is the small one
57  useLargeGUI = !useSmallGUI;
58 
59 
60  // do the rest of my init stuff
61  init();
62 }
63 
64 
65 void Gui::init()
66 {
67  //-----------------
68  // startup the GUI
69  //-----------------
70  if (useLargeGUI)
71  ui.setupUi(this);
72  else
73  uiSmall.setupUi(this);
74 
75 
76  // get background color for compass widget
77 // QColor compassBackground = this->palette().window().color();
78 // QColor compassBackground = this->palette().light().color();
79 
80  // change background color of compass gl object to background color from the main window
81 // ui.frameCompass->setBackgroundColor(compassBackground); // doesn't work. Qt Bug?
82 
83 /*
84  QPalette pal = ui.mainWindow->palette();
85  pal.setColor(QPalette::Base, pal.color(QPalette::Window));
86  ui.frameCompass->setPalette(pal);
87 */
88 
89  // remote control is enabled by default. @sa Direcs::init()
90  if (useLargeGUI)
91  ui.actionRemote->setChecked(true);
92  else
93  uiSmall.actionRemote->setChecked(true);
94 
95  //----------------------------------------------------------------------------
96  // Voltage stuff (progressBars)
97  //----------------------------------------------------------------------------
98 // ui.progressBarVoltage1->setRange(0, MAXIMUMVOLTAGE1);
99 // ui.progressBarVoltage2->setRange(0, MAXIMUMVOLTAGE2);
100 
101  // set maximum in cm AND raise the widget (make it topmost)!
102  /*
103  ui.progressBarSensor1->setMaximum(SENSORPROGRESSBARMAXIR);
104  ui.progressBarSensor2->setMaximum(SENSORPROGRESSBARMAXIR);
105  ui.progressBarSensor3->setMaximum(SENSORPROGRESSBARMAXIR);
106  ui.progressBarSensor4->setMaximum(SENSORPROGRESSBARMAXIR);
107  ui.progressBarSensor5->setMaximum(SENSORPROGRESSBARMAXIR);
108  ui.progressBarSensor6->setMaximum(SENSORPROGRESSBARMAXIR);
109  ui.progressBarSensor7->setMaximum(SENSORPROGRESSBARMAXIR);
110  ui.progressBarSensor8->setMaximum(SENSORPROGRESSBARMAXIR);
111  ui.progressBarSensor16->setMaximum(SENSORPROGRESSBARMAXUS);
112  */
113 /*
114 infrared Sensors temporarily removed from robot!!
115  ui.progressBarSensor1->raise();
116  ui.progressBarSensor2->raise();
117  ui.progressBarSensor3->raise();
118  ui.progressBarSensor4->raise();
119  ui.progressBarSensor5->raise();
120  ui.progressBarSensor6->raise();
121  ui.progressBarSensor7->raise();
122  ui.progressBarSensor8->raise();
123 */
124 
125 
126  //----------------------------------------------------------------------------------
127  // Whenever the state of the face detect check box changes, set the detection mode
128  //----------------------------------------------------------------------------------
129  if (useLargeGUI)
130  connect(ui.checkBoxFaceDetection, SIGNAL( stateChanged(int) ), SIGNAL( enableFaceDetection(int) ));
131  else
132  connect(uiSmall.checkBoxFaceDetection, SIGNAL( stateChanged(int) ), SIGNAL( enableFaceDetection(int) ));
133 
134  //----------------------------------------------------------------------------------
135  // Whenever the state of the face tracking check box changes, set the tracking mode
136  //----------------------------------------------------------------------------------
137  if (useLargeGUI)
138  connect(ui.checkBoxFaceTracking, SIGNAL( stateChanged(int) ), SIGNAL( enableFaceTracking(int) ));
139  else
140  connect(uiSmall.checkBoxFaceTracking, SIGNAL( stateChanged(int) ), SIGNAL( enableFaceTracking(int) ));
141 
142 
143 #ifndef BUILDFORROBOT
144  //----------------------------------------------------------------------------
145  // Plot stuff
146  //----------------------------------------------------------------------------
147  initPlots();
148 #endif
149 
150  //----------------------------------------------------------------------------
151  // Laser Scanner graphics Stuff (scene, view, lines, OpenGL etc.)
152  //----------------------------------------------------------------------------
153  // -> the laser lines and pixmap init stuff is now done AFTER the laser settings are read in the direcs main class!
154 
155 
156  //----------------------------------
157  // change text of buttons
158  //----------------------------------
159  if (useLargeGUI)
160  {
161  ui.actionDrive->setText("&Drive");
162  ui.actionDrive->setToolTip("Start driving");
163  ui.actionDrive->setStatusTip("Start driving");
164  }
165  else
166  {
167  uiSmall.actionDrive->setText("&Drive");
168  uiSmall.actionDrive->setToolTip("Start driving");
169  uiSmall.actionDrive->setStatusTip("Start driving");
170  }
171 }
172 
173 
175 {
176 #ifdef ACTIVELASERVIEW
177  delete pixmapBot2;
178  delete pixmapBot1;
179 
180  delete widthLeftCircleFront;
181  delete widthRightCircleFront;
182  delete widthLineFront;
183  delete widthTextFront;
184 
185  delete widthLeftCircleRear;
186  delete widthRightCircleRear;
187  delete widthLineRear;
188  delete widthTextRear;
189 
190  // empty QList
191  while (!laserDistanceTextFront->isEmpty())
192  {
193  delete laserDistanceTextFront->takeFirst();
194  }
195  delete laserDistanceTextFront;
196 
197  // empty QList
198  while (!laserDistanceLineListFront->isEmpty())
199  {
200  delete laserDistanceLineListFront->takeFirst();
201  }
202  delete laserDistanceLineListFront;
203 
204  // empty QList
205  while (!laserLineListFront->isEmpty())
206  {
207  delete laserLineListFront->takeFirst();
208  }
209  delete laserLineListFront;
210 
211 
212  // empty QList
213  while (!laserDistanceTextRear->isEmpty())
214  {
215  delete laserDistanceTextRear->takeFirst();
216  }
217  delete laserDistanceTextRear;
218 
219  // empty QList
220  while (!laserDistanceLineListRear->isEmpty())
221  {
222  delete laserDistanceLineListRear->takeFirst();
223  }
224  delete laserDistanceLineListRear;
225 
226  // empty QList
227  while (!laserLineListRear->isEmpty())
228  {
229  delete laserLineListRear->takeFirst();
230  }
231  delete laserLineListRear;
232 
233  delete scene;
234 #endif
235 
236 /*
237  if (cameraOpened)
238  {
239  cvReleaseCapture( &capture );
240  cameraOpened = false;
241  }
242 */
243 }
244 
245 
246 void Gui::closeEvent(QCloseEvent *event)
247 {
248  // no compiler warning "unused"
249  Q_UNUSED(event);
250 
251 
252  //qDebug("closeEvent");
253  emit shutdown();
254 }
255 
256 
258 {
259  close();
260 }
261 
262 
263 void Gui::setRobotControls(bool state)
264 {
265  // store the state
266  robotIsOn = state;
267 
268  // set the controls
269  if (useLargeGUI)
270  {
271  ui.actionDrive->setEnabled(state);
272  ui.actionReset->setEnabled(state);
273  /*
274  ui.btnResetMovement1->setEnabled(state);
275  ui.btnResetMovement2->setEnabled(state);
276  ui.btnResetMovement3->setEnabled(state);
277  ui.btnResetMovement4->setEnabled(state);
278  */
279  }
280  else
281  {
282  uiSmall.actionDrive->setEnabled(state);
283  uiSmall.actionReset->setEnabled(state);
284  /*
285  uiSmall.btnResetMovement1->setEnabled(state);
286  uiSmall.btnResetMovement2->setEnabled(state);
287  uiSmall.btnResetMovement3->setEnabled(state);
288  uiSmall.btnResetMovement4->setEnabled(state);
289  */
290  }
291 
292  if (!robotIsOn)
293  {
295  // set the state LED to red
297  }
298 
300  /*
301  ui.btnPower1->setEnabled(state);
302  ui.btnPower2->setEnabled(state);
303  ui.btnPower3->setEnabled(state);
304  ui.btnPower4->setEnabled(state);
305  */
306 }
307 
308 
309 void Gui::appendLog(QString text, bool CR, bool sayIt, bool addTimestamp)
310 {
311  if (addTimestamp == true)
312  {
313  // get the current date and time for a timestimp in the log
314  now = QDateTime::currentDateTime();
315 
316  // prepend timestamp
317  text = QString("%1:%2:%3 %4").arg(now.toString("hh")).arg(now.toString("mm")).arg(now.toString("ss")).arg(text);
318  }
319 
320  // insert the new text in the GUI
321  if (useLargeGUI)
322  {
323  ui.textEditGlobalLog->insertHtml(text);
324  }
325  else
326  {
327  uiSmall.textEditGlobalLog->insertHtml(text);
328  }
329 
330  if (CR == true) // default!
331  {
332  if (useLargeGUI)
333  {
334  ui.textEditGlobalLog->insertHtml("<br>");
335  }
336  else
337  {
338  uiSmall.textEditGlobalLog->insertHtml("<br>");
339  }
340  }
341 
342  // Ensures that the cursor is visible by scrolling the text edit if necessary.
343  if (useLargeGUI)
344  {
345  ui.textEditGlobalLog->ensureCursorVisible();
346  }
347  else
348  {
349  uiSmall.textEditGlobalLog->ensureCursorVisible();
350  }
351 
352 
353  if (consoleMode)
354  {
355  // remove HTML code
356  text = removeHtml(text);
357  // print text to console
358  // qDebug() << text; is NOT used, because it adds quotation marks to all strings
359  QByteArray textForConsole = text.toLatin1();
360  qDebug("%s", textForConsole.data());
361  }
362 
363 
364  // say the message via Linux espeak
365  if (sayIt == true)
366  {
367  emit speak(text);
368  }
369 }
370 
371 
372 void Gui::appendNetworkLog(QString text, bool CR, bool sayIt)
373 {
374  QString newText;
375 
376 
377  // get the current date and time for a timestamp in the log
378  now = QDateTime::currentDateTime();
379  // with DATE: newText = QString("%1-%2-%3 %4:%5:%6 %7").arg(now.toString("yyyy")).arg(now.toString("MM")).arg(now.toString("dd")).arg(now.toString("hh")).arg(now.toString("mm")).arg(now.toString("ss")).arg(text);
380  newText = QString("%1:%2:%3 %4").arg(now.toString("hh")).arg(now.toString("mm")).arg(now.toString("ss")).arg(text);
381 
382  // insert the text
383  if (useLargeGUI)
384  {
385  ui.textEditNetworkLog->insertHtml(newText);
386  }
387  else
388  {
389  uiSmall.textEditNetworkLog->insertHtml(newText);
390  }
391 
392  if (CR == true) // default!
393  {
394  // insert a line break
395  if (useLargeGUI)
396  {
397  ui.textEditNetworkLog->insertHtml("<br>");
398  }
399  else
400  {
401  uiSmall.textEditNetworkLog->insertHtml("<br>");
402  }
403  }
404 
405  // Ensures that the cursor is visible by scrolling the text edit if necessary.
406  if (useLargeGUI)
407  {
408  ui.textEditNetworkLog->ensureCursorVisible();
409  }
410  else
411  {
412  uiSmall.textEditNetworkLog->ensureCursorVisible();
413  }
414 
415 
416  if (consoleMode)
417  {
418  // remove HTML code
419  text = removeHtml(newText);
420  // print text to console
421  // qDebug() << text; is NOT used, because it adds quotation marks to all strings
422  QByteArray textForConsole = text.toLatin1();
423  qDebug("%s", textForConsole.data());
424  }
425 
426 
427  // say the message via Linux espeak
428  if (sayIt == true)
429  {
430  emit speak(text);
431  }
432 }
433 
434 
435 void Gui::appendSerialLog(QString text, bool CR)
436 {
437  QString newText;
438 
439 
440  // get the current date and time for a timestimp in the log
441  now = QDateTime::currentDateTime();
442  // with DATE: newText = QString("%1-%2-%3 %4:%5:%6 %7").arg(now.toString("yyyy")).arg(now.toString("MM")).arg(now.toString("dd")).arg(now.toString("hh")).arg(now.toString("mm")).arg(now.toString("ss")).arg(text);
443  newText = QString("%1:%2:%3 %4").arg(now.toString("hh")).arg(now.toString("mm")).arg(now.toString("ss")).arg(text);
444 
445  // insert the text
446  if (useLargeGUI)
447  {
448  ui.textEditSerialLog->insertHtml(newText);
449  }
450  else
451  {
452  uiSmall.textEditSerialLog->insertHtml(newText);
453  }
454 
455  if (CR == true) // default!
456  {
457  // insert a line break
458  if (useLargeGUI)
459  {
460  ui.textEditSerialLog->insertHtml("<br>");
461  }
462  else
463  {
464  uiSmall.textEditSerialLog->insertHtml("<br>");
465  }
466  }
467 
468  // Ensures that the cursor is visible by scrolling the text edit if necessary.
469  if (useLargeGUI)
470  {
471  ui.textEditSerialLog->ensureCursorVisible();
472  }
473  else
474  {
475  uiSmall.textEditSerialLog->ensureCursorVisible();
476  }
477 
478 
479  if (consoleMode)
480  {
481  // remove HTML code
482  text = removeHtml(newText);
483  // print text to console
484  // qDebug() << text; is NOT used, because it adds quotation marks to all strings
485  QByteArray textForConsole = text.toLatin1();
486  qDebug("%s", textForConsole.data());
487  }
488 }
489 
490 
492 {
493  static bool toggle = false;
494 
495 
496  if (toggle == false)
497  {
498  appendLog("Start driving...");
499  toggle = true;
500 
501  // change text of "drive button"
502  if (useLargeGUI)
503  {
504  ui.actionDrive->setText("Stop &driving");
505  ui.actionDrive->setToolTip("Stop driving");
506  ui.actionDrive->setStatusTip("Stop driving");
507  }
508  else
509  {
510  uiSmall.actionDrive->setText("Stop &driving");
511  uiSmall.actionDrive->setToolTip("Stop driving");
512  uiSmall.actionDrive->setStatusTip("Stop driving");
513  }
514 
515  //----------------
516  // start driving
517  //----------------
518  emit drive(START);
519  }
520  else
521  {
522  toggle = false;
523  appendLog("Stop driving...");
524 
525  // change text of "drive button"
526  if (useLargeGUI)
527  {
528  ui.actionDrive->setText("&Drive");
529  ui.actionDrive->setToolTip("Start driving");
530  ui.actionDrive->setStatusTip("Start driving");
531  }
532  else
533  {
534  uiSmall.actionDrive->setText("&Drive");
535  uiSmall.actionDrive->setToolTip("Start driving");
536  uiSmall.actionDrive->setStatusTip("Start driving");
537  }
538 
539  //****************
540  // stop driving
541  //****************
542  emit drive(STOP);
543  }
544 }
545 
546 
548 {
549  // reset the circuit (motors off etc.)
550  emit initCircuit();
551 
552  // reset the servos
553  emit initServos();
554 
555  // stop driving
556  emit drive(STOP);
557 
558  appendLog("Reseted.");
559 
560  // reset progressBars
561  /*
562  if (useLargeGUI)
563  {
564  ui.progressBarSensor1->setValue(0);
565  ui.progressBarSensor2->setValue(0);
566  ui.progressBarSensor3->setValue(0);
567  ui.progressBarSensor4->setValue(0);
568  ui.progressBarSensor5->setValue(0);
569  ui.progressBarSensor6->setValue(0);
570  ui.progressBarSensor7->setValue(0);
571  ui.progressBarSensor8->setValue(0);
572  ui.progressBarSensor16->setValue(0);
573  }
574  else
575  {
576  uiSmall.progressBarSensor1->setValue(0);
577  uiSmall.progressBarSensor2->setValue(0);
578  uiSmall.progressBarSensor3->setValue(0);
579  uiSmall.progressBarSensor4->setValue(0);
580  uiSmall.progressBarSensor5->setValue(0);
581  uiSmall.progressBarSensor6->setValue(0);
582  uiSmall.progressBarSensor7->setValue(0);
583  uiSmall.progressBarSensor8->setValue(0);
584  uiSmall.progressBarSensor16->setValue(0);
585  }
586  */
587 
588  // reset labels
589 /*
590  if (useLargeGUI)
591  {
592  ui.btnDirection1->setText("FORWARD");
593  ui.btnDirection2->setText("FORWARD");
594  ui.btnDirection3->setText("FORWARD");
595  ui.btnDirection4->setText("FORWARD");
596  }
597  else
598  {
599  uiSmall.btnDirection1->setText("FORWARD");
600  uiSmall.btnDirection2->setText("FORWARD");
601  uiSmall.btnDirection3->setText("FORWARD");
602  uiSmall.btnDirection4->setText("FORWARD");
603  }
604 */
605 }
606 
607 
609 {
610  // reset counter
612  // reset labels
613  if (useLargeGUI)
614  {
615  ui.labelDrivenDistance1->setText("0 cm");
616  ui.labelRevolutions1->setText("0");
617  }
618  else
619  {
620  uiSmall.labelDrivenDistance1->setText("0 cm");
621  uiSmall.labelRevolutions1->setText("0");
622  }
623 
624  // reset counter
626  // reset labels
627  if (useLargeGUI)
628  {
629  ui.labelDrivenDistance2->setText("0 cm");
630  ui.labelRevolutions2->setText("0");
631  }
632  else
633  {
634  uiSmall.labelDrivenDistance2->setText("0 cm");
635  uiSmall.labelRevolutions2->setText("0");
636  }
637 
638  // reset counter
640  // reset labels
641  if (useLargeGUI)
642  {
643  ui.labelDrivenDistance3->setText("0 cm");
644  ui.labelRevolutions3->setText("0");
645  }
646  else
647  {
648  uiSmall.labelDrivenDistance3->setText("0 cm");
649  uiSmall.labelRevolutions3->setText("0");
650  }
651 
652  // reset counter
654  // reset labels
655  if (useLargeGUI)
656  {
657  ui.labelDrivenDistance4->setText("0 cm");
658  ui.labelRevolutions4->setText("0");
659  }
660  else
661  {
662  uiSmall.labelDrivenDistance4->setText("0 cm");
663  uiSmall.labelRevolutions4->setText("0");
664  }
665 }
666 
667 
668 /*
669 void Gui::on_btnResetMovement1_clicked()
670 {
671  // reset counter
672  emit resetDrivenDistance(MOTORSENSOR1);
673 
674  // reset labels
675  if (useLargeGUI)
676  {
677  ui.labelDrivenDistance1->setText("0 cm");
678  ui.labelRevolutions1->setText("0");
679  }
680  else
681  {
682  uiSmall.labelDrivenDistance1->setText("0 cm");
683  uiSmall.labelRevolutions1->setText("0");
684  }
685 }
686 
687 
688 void Gui::on_btnResetMovement2_clicked()
689 {
690  // reset counter
691  emit resetDrivenDistance(MOTORSENSOR2);
692 
693  // reset labels
694  if (useLargeGUI)
695  {
696  ui.labelDrivenDistance2->setText("0 cm");
697  ui.labelRevolutions2->setText("0");
698  }
699  else
700  {
701  uiSmall.labelDrivenDistance2->setText("0 cm");
702  uiSmall.labelRevolutions2->setText("0");
703  }
704 }
705 
706 
707 void Gui::on_btnResetMovement3_clicked()
708 {
709  // reset counter
710  emit resetDrivenDistance(MOTORSENSOR3);
711 
712  // reset labels
713  if (useLargeGUI)
714  {
715  ui.labelDrivenDistance3->setText("0 cm");
716  ui.labelRevolutions3->setText("0");
717  }
718  else
719  {
720  uiSmall.labelDrivenDistance3->setText("0 cm");
721  uiSmall.labelRevolutions3->setText("0");
722  }
723 }
724 
725 
726 void Gui::on_btnResetMovement4_clicked()
727 {
728  // reset counter
729  emit resetDrivenDistance(MOTORSENSOR4);
730 
731  // reset labels
732  if (useLargeGUI)
733  {
734  ui.labelDrivenDistance4->setText("0 cm");
735  ui.labelRevolutions4->setText("0");
736  }
737  else
738  {
739  uiSmall.labelDrivenDistance4->setText("0 cm");
740  uiSmall.labelRevolutions4->setText("0");
741  }
742 }
743 */
744 
746 {
747  emit test();
748 
749 /*
750  capture = cvCreateCameraCapture(0);
751  cameraOpened = true;
752 
753  this->processCam();
754 */
755 
756  //
757  // OpenCV tests
758  //
759 
760 /*
761  kinect->getRGB(m_rgb);
762 // kinect->getDepth(m_rgb);
763 
764  glBindTexture(GL_TEXTURE_2D, m_rgbTexture);
765  glTexImage2D(GL_TEXTURE_2D, 0, 3, 640, 480, 0, GL_RGB, GL_UNSIGNED_BYTE, &m_rgb[0]);
766 */
767 
768 
769 // ui.frameOpenCV->processOpenCV();
770 
771 
772 /*
773  // grab image from the kinect frame in the GUI
774  QImage qimage = ui.frameDepth->grabFrameBuffer();
775 
776  // convert QImage to OpeneCV's cv::Mat
777  //
778  // http://permalink.gmane.org/gmane.comp.lib.opencv/37800
779  //
780  //Mat qimage2mat(const QImage& qimage) {
781 
782  cv::Mat mat = cv::Mat(qimage.height(), qimage.width(), CV_8UC4, (uchar*)qimage.bits(), qimage.bytesPerLine());
783  cv::Mat mat2 = cv::Mat(mat.rows, mat.cols, CV_8UC3 );
784  int from_to[] = { 0,0, 1,1, 2,2 };
785  cv::mixChannels( &mat, 1, &mat2, 1, from_to, 3 );
786 
787  // result is now in 'mat2'
788 
789 // -- - -- --
790 
791 
792  mImage.release(); // reset picture
793 
794  // load JPEG from disc
795 // cv::Mat tmpImg = cv::imread( "puzzle.jpg" );
796 // cv::cvtColor( tmpImg, mImage, CV_BGR2RGB);
797 
798  // depth image from Kinect now! (mat2)
799  cv::cvtColor( mat2, mImage, CV_BGR2RGB);
800 
801  QImage tmp( (uchar*)mImage.data, mImage.cols, mImage.rows, mImage.step, QImage::Format_RGB888 );
802  ui.lblOpenCV->setPixmap( QPixmap::fromImage( tmp ) );
803 
804 
805  if (mImage.data)
806  {
807  cv::Mat gray;
808  cv::cvtColor( mImage, gray, CV_RGB2GRAY );
809  cv::Canny( gray, gray, 10, 30, 3 );
810 
811  QImage tmp( (uchar*)gray.data, gray.cols, gray.rows, gray.step, QImage::Format_Indexed8 );
812  ui.lblOpenCV->setPixmap( QPixmap::fromImage( tmp ) );
813  }
814 */
815 }
816 
817 
818 #ifndef USEROBOTGUI
820 {
821  if (useLargeGUI)
822  {
823  ui.dockVoltage->show();
824  // ui.dockCurrent->show();
825  ui.dockState->show();
826  ui.dockLog->show();
827 
828  // settingsDialog->show();
829  // joystickDialog->show();
830 
831  // only show the cam window, if the cam usage is enabled
832  if (ui.dockCamera->isEnabled())
833  {
834  ui.dockCamera->show();
835  }
836  }
837  else
838  {
839  // no dock widgets in the small GUI
840  }
841 }
842 #endif
843 
844 
845 #ifndef USEROBOTGUI
847 {
848 // if (ui.dockCamera->isEnabled())
849 // {
850  if (useLargeGUI)
851  {
852  if (ui.dockCamera->isVisible())
853  {
854  ui.dockCamera->hide();
855  }
856  else
857  {
858  ui.dockCamera->show();
859  }
860  }
861  else
862  {
863  // no dock widgets in the small GUI
864  }
865 // }
866 }
867 #endif
868 
869 
870 #ifndef USEROBOTGUI
872 {
873  if (useLargeGUI)
874  {
875  if (ui.dockVoltage->isVisible())
876  {
877  ui.dockVoltage->hide();
878  }
879  else
880  {
881  ui.dockVoltage->show();
882  }
883  }
884  else
885  {
886  // no dock widgets in the small GUI
887  }
888 }
889 #endif
890 
891 
892 /*
893 #ifndef USEROBOTGUI
894 void Gui::on_actionCurrent_activated()
895 {
896  if (useLargeGUI)
897  {
898  if (ui.dockCurrent->isVisible())
899  {
900  ui.dockCurrent->hide();
901  }
902  else
903  {
904  ui.dockCurrent->show();
905  }
906  }
907  else
908  {
909  if (uiSmall.dockCurrent->isVisible())
910  {
911  uiSmall.dockCurrent->hide();
912  }
913  else
914  {
915  uiSmall.dockCurrent->show();
916  }
917  }
918 }
919 #endif
920 */
921 
922 
923 #ifndef USEROBOTGUI
925 {
926  if (useLargeGUI)
927  {
928  if (ui.dockState->isVisible())
929  {
930  ui.dockState->hide();
931  }
932  else
933  {
934  ui.dockState->show();
935  }
936  }
937  else
938  {
939  // no dock widgets in the small GUI
940  }
941 }
942 #endif
943 
944 
946 {
947  if (settingsDialog->isVisible())
948  {
949  settingsDialog->hide();
950  }
951  else
952  {
953  settingsDialog->show();
954  }
955 }
956 
957 
958 #ifndef USEROBOTGUI
960 {
961  if (useLargeGUI)
962  {
963  if (ui.dockLog->isVisible())
964  {
965  ui.dockLog->hide();
966  }
967  else
968  {
969  ui.dockLog->show();
970  }
971  }
972  else
973  {
974  // no dock widgets in the small GUI
975  }
976 }
977 #endif
978 
979 
981 {
982  if (joystickDialog->isVisible())
983  {
984  joystickDialog->hide();
985  }
986  else
987  {
988  joystickDialog->show();
989  }
990 }
991 
992 
994 {
995  if (aboutDialog->isVisible())
996  {
997  aboutDialog->hide();
998  }
999  else
1000  {
1001  aboutDialog->show();
1002  }
1003 }
1004 
1005 
1006 /*
1007 void Gui::showDistance(int sensor, int distance)
1008 {
1009  if ((sensor < SENSOR1) || (sensor > SENSOR16))
1010  {
1011  qDebug("ERROR gui, showDistance: wrong IR sensor number");
1012  return;
1013  }
1014 
1015 
1016  switch (sensor)
1017  {
1018  case SENSOR1:
1019  ui.labelSensorDistance1->setText(QString("%1").arg(distance));
1020  return;
1021  break;
1022  case SENSOR2:
1023  ui.labelSensorDistance2->setText(QString("%1").arg(distance));
1024  return;
1025  break;
1026  case SENSOR3:
1027  ui.labelSensorDistance3->setText(QString("%1").arg(distance));
1028  return;
1029  break;
1030  case SENSOR4:
1031  ui.labelSensorDistance4->setText(QString("%1").arg(distance));
1032  return;
1033  break;
1034  case SENSOR5:
1035  ui.labelSensorDistance5->setText(QString("%1").arg(distance));
1036  return;
1037  break;
1038  case SENSOR6:
1039  ui.labelSensorDistance6->setText(QString("%1").arg(distance));
1040  return;
1041  break;
1042  case SENSOR7:
1043  ui.labelSensorDistance7->setText(QString("%1").arg(distance));
1044  return;
1045  break;
1046  case SENSOR8:
1047  ui.labelSensorDistance8->setText(QString("%1").arg(distance));
1048  return;
1049  break;
1050  case SENSOR16:
1051  // super sonic sensor
1052  ui.labelSensorDistance16->setText(QString("%1 cm").arg(distance));
1053  return;
1054  break;
1055  }
1056 }
1057 */
1058 
1059 
1060 void Gui::showDistanceGraphical(int sensor, int distance)
1061 {
1062  Q_UNUSED(sensor);
1063  Q_UNUSED(distance);
1064 
1065 /*
1066  if ((sensor < SENSOR1) || (sensor > SENSOR16))
1067  {
1068  qDebug("ERROR gui, showDistanceGraphical: wrong IR sensor number");
1069  return;
1070  }
1071 
1072 
1073  switch (sensor)
1074  {
1075  case SENSOR1:
1076  ui.progressBarSensor1->setValue(distance);
1077  return;
1078  break;
1079  case SENSOR2:
1080  ui.progressBarSensor2->setValue(distance);
1081  return;
1082  break;
1083  case SENSOR3:
1084  ui.progressBarSensor3->setValue(distance);
1085  return;
1086  break;
1087  case SENSOR4:
1088  ui.progressBarSensor4->setValue(distance);
1089  return;
1090  break;
1091  case SENSOR5:
1092  ui.progressBarSensor5->setValue(distance);
1093  return;
1094  break;
1095  case SENSOR6:
1096  ui.progressBarSensor6->setValue(distance);
1097  return;
1098  break;
1099  case SENSOR7:
1100  ui.progressBarSensor7->setValue(distance);
1101  return;
1102  break;
1103  case SENSOR8:
1104  ui.progressBarSensor8->setValue(distance);
1105  return;
1106  break;
1107  case SENSOR16:
1108  ui.progressBarSensor16->setValue(distance);
1109  return;
1110  break;
1111  }
1112 */
1113 }
1114 
1115 
1116 void Gui::showDrivenDistance(int sensor, int distance)
1117 {
1118  // show distance value in centimeters in a text label
1119  // erwartet den value als distance (z.B. in cm)!
1120  if ((sensor < MOTORSENSOR1) || (sensor > MOTORSENSOR4))
1121  {
1122  qDebug("ERROR gui, showDrivenDistance: wrong motor sensor number");
1123  return;
1124  }
1125 
1126 
1127  switch (sensor)
1128  {
1129  case MOTORSENSOR1:
1130  if (useLargeGUI)
1131  {
1132  ui.labelDrivenDistance1->setText(QString("%1 cm").arg(distance));
1133  }
1134  else
1135  {
1136  uiSmall.labelDrivenDistance1->setText(QString("%1 cm").arg(distance));
1137  }
1138  return;
1139  break;
1140  case MOTORSENSOR2:
1141  if (useLargeGUI)
1142  {
1143  ui.labelDrivenDistance2->setText(QString("%1 cm").arg(distance));
1144  }
1145  else
1146  {
1147  uiSmall.labelDrivenDistance2->setText(QString("%1 cm").arg(distance));
1148  }
1149  return;
1150  break;
1151  case MOTORSENSOR3:
1152  if (useLargeGUI)
1153  {
1154  ui.labelDrivenDistance3->setText(QString("%1 cm").arg(distance));
1155  }
1156  else
1157  {
1158  uiSmall.labelDrivenDistance3->setText(QString("%1 cm").arg(distance));
1159  }
1160  return;
1161  break;
1162  case MOTORSENSOR4:
1163  if (useLargeGUI)
1164  {
1165  ui.labelDrivenDistance4->setText(QString("%1 cm").arg(distance));
1166  }
1167  else
1168  {
1169  uiSmall.labelDrivenDistance4->setText(QString("%1 cm").arg(distance));
1170  }
1171  return;
1172  break;
1173  }
1174 }
1175 
1176 
1177 void Gui::showVoltage(int sensor, float voltage)
1178 {
1179  if ((sensor < VOLTAGESENSOR1) || (sensor > VOLTAGESENSOR2))
1180  {
1181  qDebug("ERROR gui, showVoltage: wrong voltage sensor number");
1182  return;
1183  }
1184 
1185 // qDebug("voltage %d=%f / MINIMUMVOLTAGE1=%f / MINIMUMVOLTAGE2=%f", sensor, voltage, MINIMUMVOLTAGE1, MINIMUMVOLTAGE2);
1186 
1187  switch (sensor)
1188  {
1189  case VOLTAGESENSOR1:
1190  if (useLargeGUI)
1191  {
1192  ui.lblVoltage1->setText(QString("%1").setNum(voltage, 'f', 1).append(" V"));
1193 // ui.progressBarVoltage1->setValue(voltage);
1194  }
1195  else
1196  {
1197  uiSmall.lblVoltage1->setText(QString("%1").setNum(voltage, 'f', 1).append(" V"));
1198 // uiSmall.progressBarVoltage1->setValue(voltage);
1199  }
1200 
1201  // change color of the label depending on the voltage
1202  if (voltage < MINIMUMVOLTAGE1)
1203  {
1204  // change icon
1205  if (voltage > 0.0)
1206  {
1207  if (useLargeGUI)
1208  {
1209  ui.lblBattery1->setPixmap(QPixmap(":/images/images/battery-060.png"));
1210  }
1211  else
1212  {
1213  uiSmall.lblBattery1->setPixmap(QPixmap(":/images/images/battery-060.png"));
1214  }
1215  }
1216  else
1217  {
1218  if (useLargeGUI)
1219  {
1220  ui.lblBattery1->setPixmap(QPixmap(":/images/images/battery-missing.png"));
1221  }
1222  else
1223  {
1224  uiSmall.lblBattery1->setPixmap(QPixmap(":/images/images/battery-missing.png"));
1225  }
1226  }
1227  }
1228  else
1229  {
1230  // change icon
1231  if (useLargeGUI)
1232  {
1233  ui.lblBattery1->setPixmap(QPixmap(":/images/images/battery-100.png"));
1234  }
1235  else
1236  {
1237  uiSmall.lblBattery1->setPixmap(QPixmap(":/images/images/battery-100.png"));
1238  }
1239  }
1240 
1241  return;
1242  break;
1243  case VOLTAGESENSOR2:
1244  if (useLargeGUI)
1245  {
1246  ui.lblVoltage2->setText(QString("%1").setNum(voltage, 'f', 1).append(" V"));
1247 // ui.progressBarVoltage2->setValue(voltage);
1248  }
1249  else
1250  {
1251  uiSmall.lblVoltage2->setText(QString("%1").setNum(voltage, 'f', 1).append(" V"));
1252 // uiSmall.progressBarVoltage2->setValue(voltage);
1253  }
1254 
1255  // change color of the label depending on the voltage
1256  if (voltage < MINIMUMVOLTAGE2)
1257  {
1258  // change icon
1259  if (voltage > 0.0)
1260  {
1261  if (useLargeGUI)
1262  {
1263  ui.lblBattery2->setPixmap(QPixmap(":/images/images/battery-060.png"));
1264  }
1265  else
1266  {
1267  uiSmall.lblBattery2->setPixmap(QPixmap(":/images/images/battery-060.png"));
1268  }
1269  }
1270  else
1271  {
1272  if (useLargeGUI)
1273  {
1274  ui.lblBattery2->setPixmap(QPixmap(":/images/images/battery-missing.png"));
1275  }
1276  else
1277  {
1278  uiSmall.lblBattery2->setPixmap(QPixmap(":/images/images/battery-missing.png"));
1279  }
1280  }
1281  }
1282  else
1283  {
1284  // change icon
1285  if (useLargeGUI)
1286  {
1287  ui.lblBattery2->setPixmap(QPixmap(":/images/images/battery-100.png"));
1288  }
1289  else
1290  {
1291  uiSmall.lblBattery2->setPixmap(QPixmap(":/images/images/battery-100.png"));
1292  }
1293  }
1294 
1295  return;
1296  break;
1297  }
1298 }
1299 
1300 
1301 void Gui::showAlarm(short int sensor, bool state)
1302 {
1303  Q_UNUSED(sensor);
1304  Q_UNUSED(state);
1305 
1306 /*
1307  if ((sensor < SENSOR1) || (sensor > SENSOR16))
1308  {
1309  qDebug("error in showAlarm! sensorValue=%d", sensor);
1310  return;
1311  }
1312 
1313 
1314  switch (sensor)
1315  {
1316  case SENSOR1:
1317  if (state == ON)
1318  {
1319  // change sensor-pixmap color to red [blue = 0, 70, 213]
1320  //ui.labelSensorPic1->setPalette(QPalette(labelFillColorRed));
1321  //ui.labelSensorAlarm1->setEnabled(true);
1322  //ui.frameSensorAlarm1->setPalette(QPalette(labelFillColorRed));
1323  // red progressBar background
1324  ui.progressBarSensor1->setPalette(QPalette(labelFillColorRed));
1325  }
1326  else
1327  {
1328  // change sensor-pixmap color to white
1329  //ui.labelSensorPic1->setPalette(QPalette(QColor(255,255,255)));
1330  //ui.labelSensorAlarm1->setEnabled(false);
1331  //ui.frameSensorAlarm1->setPalette(QPalette(QColor(255,255,255)));
1332  // progressBar background white
1333  ui.progressBarSensor1->setPalette(QPalette(QColor(255, 255, 255)));
1334  }
1335  return;
1336  break;
1337  case SENSOR2:
1338  if (state == ON)
1339  {
1340  // change sensor-pixmap color to red [blue = 0, 70, 213]
1341  //ui.labelSensorPic2->setPalette(QPalette(labelFillColorRed));
1342  //ui.labelSensorAlarm2->setEnabled(true);
1343  //ui.frameSensorAlarm2->setPalette(QPalette(labelFillColorRed));
1344  // red progressBar background
1345  ui.progressBarSensor2->setPalette(QPalette(labelFillColorRed));
1346  }
1347  else
1348  {
1349  // change sensor-pixmap color to white
1350  //ui.labelSensorPic2->setPalette(QPalette(QColor(255,255,255)));
1351  //ui.labelSensorAlarm2->setEnabled(false);
1352  //ui.frameSensorAlarm2->setPalette(QPalette(QColor(255,255,255)));
1353  // progressBar background white
1354  ui.progressBarSensor2->setPalette(QPalette(QColor(255, 255, 255)));
1355  }
1356  return;
1357  break;
1358  case SENSOR3:
1359  if (state == ON)
1360  {
1361  // change sensor-pixmap color to red [blue = 0, 70, 213]
1362  //ui.labelSensorPic3->setPalette(QPalette(labelFillColorRed));
1363  //ui.labelSensorAlarm3->setEnabled(true);
1364  //ui.frameSensorAlarm3->setPalette(QPalette(labelFillColorRed));
1365  // red progressBar background
1366  ui.progressBarSensor3->setPalette(QPalette(labelFillColorRed));
1367  }
1368  else
1369  {
1370  // change sensor-pixmap color to white
1371  //ui.labelSensorPic3->setPalette(QPalette(QColor(255,255,255)));
1372  //ui.labelSensorAlarm3->setEnabled(false);
1373  //ui.frameSensorAlarm3->setPalette(QPalette(QColor(255,255,255)));
1374  // progressBar background white
1375  ui.progressBarSensor3->setPalette(QPalette(QColor(255, 255, 255)));
1376  }
1377  return;
1378  break;
1379  case SENSOR4:
1380  if (state == ON)
1381  {
1382  // change sensor-pixmap color to red [blue = 0, 70, 213]
1383  //ui.labelSensorPic4->setPalette(QPalette(labelFillColorRed));
1384  //ui.labelSensorAlarm4->setEnabled(true);
1385  //ui.frameSensorAlarm4->setPalette(QPalette(labelFillColorRed));
1386  // red progressBar background
1387  ui.progressBarSensor4->setPalette(QPalette(labelFillColorRed));
1388  }
1389  else
1390  {
1391  // change sensor-pixmap color to white
1392  //ui.labelSensorPic4->setPalette(QPalette(QColor(255,255,255)));
1393  //ui.labelSensorAlarm4->setEnabled(false);
1394  //ui.frameSensorAlarm4->setPalette(QPalette(QColor(255,255,255)));
1395  // progressBar background white
1396  ui.progressBarSensor4->setPalette(QPalette(QColor(255, 255, 255)));
1397  }
1398  return;
1399  break;
1400  case SENSOR5:
1401  if (state == ON)
1402  {
1403  // change sensor-pixmap color to red [blue = 0, 70, 213]
1404  //ui.labelSensorPic5->setPalette(QPalette(labelFillColorRed));
1405  //ui.labelSensorAlarm5->setEnabled(true);
1406  //ui.frameSensorAlarm5->setPalette(QPalette(labelFillColorRed));
1407  // red progressBar background
1408  ui.progressBarSensor5->setPalette(QPalette(labelFillColorRed));
1409  }
1410  else
1411  {
1412  // change sensor-pixmap color to white
1413  //ui.labelSensorPic5->setPalette(QPalette(QColor(255,255,255)));
1414  //ui.labelSensorAlarm5->setEnabled(false);
1415  //ui.frameSensorAlarm5->setPalette(QPalette(QColor(255,255,255)));
1416  // progressBar background white
1417  ui.progressBarSensor5->setPalette(QPalette(QColor(255, 255, 255)));
1418  }
1419  return;
1420  break;
1421  case SENSOR6:
1422  if (state == ON)
1423  {
1424  // change sensor-pixmap color to red [blue = 0, 70, 213]
1425  //ui.labelSensorPic6->setPalette(QPalette(labelFillColorRed));
1426  //ui.labelSensorAlarm6->setEnabled(true);
1427  //ui.frameSensorAlarm6->setPalette(QPalette(labelFillColorRed));
1428  // red progressBar background
1429  ui.progressBarSensor6->setPalette(QPalette(labelFillColorRed));
1430  }
1431  else
1432  {
1433  // change sensor-pixmap color to white
1434  //ui.labelSensorPic6->setPalette(QPalette(QColor(255,255,255)));
1435  //ui.labelSensorAlarm6->setEnabled(false);
1436  //ui.frameSensorAlarm6->setPalette(QPalette(QColor(255,255,255)));
1437  // progressBar background white
1438  ui.progressBarSensor6->setPalette(QPalette(QColor(255, 255, 255)));
1439  }
1440  return;
1441  break;
1442  case SENSOR7:
1443  if (state == ON)
1444  {
1445  // change sensor-pixmap color to red [blue = 0, 70, 213]
1446  //ui.labelSensorPic7->setPalette(QPalette(labelFillColorRed));
1447  //ui.labelSensorAlarm7->setEnabled(true);
1448  //ui.frameSensorAlarm7->setPalette(QPalette(labelFillColorRed));
1449  // red progressBar background
1450  ui.progressBarSensor7->setPalette(QPalette(labelFillColorRed));
1451  }
1452  else
1453  {
1454  // change sensor-pixmap color to white
1455  //ui.labelSensorPic7->setPalette(QPalette(QColor(255,255,255)));
1456  //ui.labelSensorAlarm7->setEnabled(false);
1457  //ui.frameSensorAlarm7->setPalette(QPalette(QColor(255,255,255)));
1458  // progressBar background white
1459  ui.progressBarSensor7->setPalette(QPalette(QColor(255, 255, 255)));
1460  }
1461  return;
1462  break;
1463  case SENSOR8:
1464  if (state == ON)
1465  {
1466  // change sensor-pixmap color to red [blue = 0, 70, 213]
1467  //ui.labelSensorPic8->setPalette(QPalette(labelFillColorRed));
1468  //ui.labelSensorAlarm8->setEnabled(true);
1469  //ui.frameSensorAlarm8->setPalette(QPalette(labelFillColorRed));
1470  // red progressBot background
1471  ui.progressBarSensor8->setPalette(QPalette(labelFillColorRed));
1472  }
1473  else
1474  {
1475  // change sensor-pixmap color to white
1476  //ui.labelSensorPic8->setPalette(QPalette(QColor(255,255,255)));
1477  //ui.labelSensorAlarm8->setEnabled(false);
1478  //ui.frameSensorAlarm8->setPalette(QPalette(QColor(255,255,255)));
1479  // progressBar background white
1480  ui.progressBarSensor8->setPalette(QPalette(QColor(255, 255, 255)));
1481  }
1482  return;
1483  break;
1484  case SENSOR16:
1485  if (state == ON)
1486  {
1487  // change sensor-pixmap color to red [blue = 0, 70, 213]
1488  //ui.labelSensorPic16->setPalette(QPalette(labelFillColorRed));
1489  //ui.labelSensorAlarm16->setEnabled(true);
1490  //ui.frameSensorAlarm16->setPalette(QPalette(labelFillColorRed));
1491  ui.progressBarSensor16->setPalette(QPalette(labelFillColorRed));
1492  }
1493  else
1494  {
1495  // change sensor-pixmap color to white
1496  //ui.labelSensorPic16->setPalette(QPalette(QColor(255,255,255)));
1497  //ui.labelSensorAlarm16->setEnabled(false);
1498  //ui.frameSensorAlarm16->setPalette(QPalette(QColor(255,255,255)));
1499  ui.progressBarSensor16->setPalette(QPalette(QColor(255, 255, 255)));
1500  }
1501  return;
1502  break;
1503  }
1504 */
1505 }
1506 
1507 
1508 void Gui::showMotorStatus(int motor, bool power, int direction)
1509 {
1510  switch (motor)
1511  {
1512  //-------------
1513  case MOTOR1:
1514  //-------------
1515  switch (power)
1516  {
1517  case ON:
1518 // ui.btnPower1->setPalette(QPalette(labelFillColorGreen));
1519 // ui.btnDirection1->setPalette(QPalette(labelFillColorGreen));
1520  break;
1521  case OFF:
1522 // ui.btnPower1->setPalette( QApplication::palette() );
1523 // ui.btnDirection1->setPalette( QApplication::palette() );
1524  if (useLargeGUI)
1525  {
1526  ui.lblLEDBackRight1->setPixmap(QPixmap(":/images/images/led_gray.gif"));
1527  }
1528  else
1529  {
1530  uiSmall.lblLEDBackRight1->setPixmap(QPixmap(":/images/images/led_gray.gif"));
1531  }
1532  break;
1533  }
1534 
1535  switch (direction)
1536  {
1537  case FORWARD:
1538 // ui.btnDirection1->setText("BACKWARD");
1539 // ui.btnDirection1->setPalette(QPalette(labelFillColorGreen));
1540  if (useLargeGUI)
1541  {
1542  ui.lblLEDBackRight1->setPixmap(QPixmap(":/images/images/led_green.gif"));
1543  }
1544  else
1545  {
1546  uiSmall.lblLEDBackRight1->setPixmap(QPixmap(":/images/images/led_green.gif"));
1547  }
1548  break;
1549  case BACKWARD:
1550 // ui.btnDirection1->setText("FORWARD");
1551 // ui.btnDirection1->setPalette(QPalette(labelFillColorGreen));
1552  if (useLargeGUI)
1553  {
1554  ui.lblLEDBackRight1->setPixmap(QPixmap(":/images/images/led_red.gif"));
1555  }
1556  else
1557  {
1558  uiSmall.lblLEDBackRight1->setPixmap(QPixmap(":/images/images/led_red.gif"));
1559  }
1560  break;
1561  case SAME:
1562  break;
1563  }
1564  break;
1565 
1566  //-------------
1567  case MOTOR2:
1568  //-------------
1569  switch (power)
1570  {
1571  case ON:
1572 // ui.btnPower2->setPalette(QPalette(labelFillColorGreen));
1573 // ui.btnDirection2->setPalette(QPalette(labelFillColorGreen));
1574  break;
1575  case OFF:
1576 // ui.btnPower2->setPalette( QApplication::palette() );
1577 // ui.btnDirection2->setPalette( QApplication::palette() );
1578  if (useLargeGUI)
1579  {
1580  ui.lblLEDBackLeft2->setPixmap(QPixmap(":/images/images/led_gray.gif"));
1581  }
1582  else
1583  {
1584  uiSmall.lblLEDBackLeft2->setPixmap(QPixmap(":/images/images/led_gray.gif"));
1585  }
1586  break;
1587  }
1588 
1589  switch (direction)
1590  {
1591  case FORWARD:
1592 // ui.btnDirection2->setText("BACKWARD");
1593 // ui.btnDirection2->setPalette(QPalette(labelFillColorGreen));
1594  if (useLargeGUI)
1595  {
1596  ui.lblLEDBackLeft2->setPixmap(QPixmap(":/images/images/led_green.gif"));
1597  }
1598  else
1599  {
1600  uiSmall.lblLEDBackLeft2->setPixmap(QPixmap(":/images/images/led_green.gif"));
1601  }
1602  break;
1603  case BACKWARD:
1604 // ui.btnDirection2->setText("FORWARD");
1605 // ui.btnDirection2->setPalette(QPalette(labelFillColorGreen));
1606  if (useLargeGUI)
1607  {
1608  ui.lblLEDBackLeft2->setPixmap(QPixmap(":/images/images/led_red.gif"));
1609  }
1610  else
1611  {
1612  uiSmall.lblLEDBackLeft2->setPixmap(QPixmap(":/images/images/led_red.gif"));
1613  }
1614  break;
1615  case SAME:
1616  break;
1617  }
1618  break;
1619 
1620  //-------------
1621  case MOTOR3:
1622  //-------------
1623  switch (power)
1624  {
1625  case ON:
1626 // ui.btnPower3->setPalette(QPalette(labelFillColorGreen));
1627 // ui.btnDirection3->setPalette(QPalette(labelFillColorGreen));
1628  break;
1629  case OFF:
1630 // ui.btnPower3->setPalette( QApplication::palette() );
1631 // ui.btnDirection3->setPalette( QApplication::palette() );
1632  if (useLargeGUI)
1633  {
1634  ui.lblLEDFrontRight3->setPixmap(QPixmap(":/images/images/led_gray.gif"));
1635  }
1636  else
1637  {
1638  uiSmall.lblLEDFrontRight3->setPixmap(QPixmap(":/images/images/led_gray.gif"));
1639  }
1640  break;
1641  }
1642 
1643  switch (direction)
1644  {
1645  case FORWARD:
1646 // ui.btnDirection3->setText("BACKWARD");
1647 // ui.btnDirection3->setPalette(QPalette(labelFillColorGreen));
1648  if (useLargeGUI)
1649  {
1650  ui.lblLEDFrontRight3->setPixmap(QPixmap(":/images/images/led_green.gif"));
1651  }
1652  else
1653  {
1654  uiSmall.lblLEDFrontRight3->setPixmap(QPixmap(":/images/images/led_green.gif"));
1655  }
1656  break;
1657  case BACKWARD:
1658 // ui.btnDirection3->setText("FORWARD");
1659 // ui.btnDirection3->setPalette(QPalette(labelFillColorGreen));
1660  if (useLargeGUI)
1661  {
1662  ui.lblLEDFrontRight3->setPixmap(QPixmap(":/images/images/led_red.gif"));
1663  }
1664  else
1665  {
1666  uiSmall.lblLEDFrontRight3->setPixmap(QPixmap(":/images/images/led_red.gif"));
1667  }
1668  break;
1669  case SAME:
1670  break;
1671  }
1672  break;
1673 
1674  //-------------
1675  case MOTOR4:
1676  //-------------
1677  switch (power)
1678  {
1679  case ON:
1680 // ui.btnPower4->setPalette(QPalette(labelFillColorGreen));
1681 // ui.btnDirection4->setPalette(QPalette(labelFillColorGreen));
1682  break;
1683  case OFF:
1684 // ui.btnPower4->setPalette( QApplication::palette() );
1685 // ui.btnDirection4->setPalette( QApplication::palette() );
1686  if (useLargeGUI)
1687  {
1688  ui.lblLEDFrontLeft4->setPixmap(QPixmap(":/images/images/led_gray.gif"));
1689  }
1690  else
1691  {
1692  uiSmall.lblLEDFrontLeft4->setPixmap(QPixmap(":/images/images/led_gray.gif"));
1693  }
1694  break;
1695  }
1696 
1697  switch (direction)
1698  {
1699  case FORWARD:
1700 // ui.btnDirection4->setText("BACKWARD");
1701 // ui.btnDirection4->setPalette(QPalette(labelFillColorGreen));
1702  if (useLargeGUI)
1703  {
1704  ui.lblLEDFrontLeft4->setPixmap(QPixmap(":/images/images/led_green.gif"));
1705  }
1706  else
1707  {
1708  uiSmall.lblLEDFrontLeft4->setPixmap(QPixmap(":/images/images/led_green.gif"));
1709  }
1710  break;
1711  case BACKWARD:
1712 // ui.btnDirection4->setText("FORWARD");
1713 // ui.btnDirection4->setPalette(QPalette(labelFillColorGreen));
1714  if (useLargeGUI)
1715  {
1716  ui.lblLEDFrontLeft4->setPixmap(QPixmap(":/images/images/led_red.gif"));
1717  }
1718  else
1719  {
1720  uiSmall.lblLEDFrontLeft4->setPixmap(QPixmap(":/images/images/led_red.gif"));
1721  }
1722  break;
1723  case SAME:
1724  break;
1725  }
1726  break;
1727  } // switch
1728 }
1729 
1730 
1731 void Gui::showLaserFrontAngles(int largestFreeAreaStart, int largestFreeAreaEnd, int centerOfFreeWay, float width)
1732 {
1733  int configuredPassageWidth = settingsDialog->getSliderPassageWidth();
1735 
1736  // store the values in the class local for refreshLaserView()
1737  if (largestFreeAreaStart == -1)
1738  {
1740  }
1741  else
1742  {
1743  mLargestFreeAreaStartFront = largestFreeAreaStart;
1744  }
1745 
1746  if (largestFreeAreaEnd == -1)
1747  {
1749  }
1750  else
1751  {
1752  mLargestFreeAreaEndFront = largestFreeAreaEnd;
1753  }
1754 
1755 
1756  if (useLargeGUI)
1757  {
1758  ui.lblLaserFrontFreeArea->setText(QString("%1 - %2 deg").arg(largestFreeAreaStart).arg(largestFreeAreaEnd));
1759  // ui.lblLaserFrontFreeEnd->setText(QString("%1 deg").arg(largestFreeAreaEnd));
1760  ui.lblLaserFrontFreeCenter->setText(QString("%1 deg").arg(centerOfFreeWay));
1761  }
1762  else
1763  {
1764  uiSmall.lblLaserFrontFreeArea->setText(QString("%1 - %2 deg").arg(largestFreeAreaStart).arg(largestFreeAreaEnd));
1765  // uiSmall.lblLaserFrontFreeEnd->setText(QString("%1 deg").arg(largestFreeAreaEnd));
1766  uiSmall.lblLaserFrontFreeCenter->setText(QString("%1 deg").arg(centerOfFreeWay));
1767  }
1768 
1769 
1770  // show width in cm with one decimal place (Nachkommastelle)
1771  if (width != -1)
1772  {
1773 // // CONVERT the WIDTH to METERS!!
1774 // width /= 100;
1775 // // show the text with 2 decimals (Nachkommastellen)
1776 // ui.lblLaserFrontFreeWidth->setText(QString("%1").setNum(width, 'f', 2).append(" m"));
1777 
1778  // show the text with 0 decimals (Nachkommastellen)
1779  if (useLargeGUI)
1780  {
1781  ui.lblLaserFrontFreeWidth->setText(QString("%1").setNum(width, 'f', 0).append(" cm"));
1782  }
1783  else
1784  {
1785  uiSmall.lblLaserFrontFreeWidth->setText(QString("%1").setNum(width, 'f', 0).append(" cm"));
1786  }
1787 
1788  // show the currently configured robot slot with with a prepended '>' or '<'
1789  if ( width > configuredPassageWidth)
1790  {
1791  if (useLargeGUI)
1792  {
1793  ui.lblPassageWidth->setText( QString("> %1 cm").arg(configuredPassageWidth) );
1794  }
1795  else
1796  {
1797  uiSmall.lblPassageWidth->setText( QString("> %1 cm").arg(configuredPassageWidth) );
1798  }
1799  }
1800  else
1801  {
1802  if (useLargeGUI)
1803  {
1804  ui.lblPassageWidth->setText( QString("< %1 cm").arg(configuredPassageWidth) );
1805  }
1806  else
1807  {
1808  uiSmall.lblPassageWidth->setText( QString("< %1 cm").arg(configuredPassageWidth) );
1809  }
1810  }
1811  }
1812  else
1813  {
1814  if (useLargeGUI)
1815  {
1816  ui.lblLaserFrontFreeWidth->setText("oo");
1817  }
1818  else
1819  {
1820  uiSmall.lblLaserFrontFreeWidth->setText("oo");
1821  }
1822 
1823  // show the currently configured robot slot with with a prepended '>' or '<'
1824  if (useLargeGUI)
1825  {
1826  ui.lblPassageWidth->setText( QString("> %1 cm").arg(configuredPassageWidth) );
1827  }
1828  else
1829  {
1830  uiSmall.lblPassageWidth->setText( QString("> %1 cm").arg(configuredPassageWidth) );
1831  }
1832  }
1833 
1834 
1835 #ifdef ACTIVELASERVIEW
1836  // show the same width in the scene
1837  if (useLargeGUI)
1838  {
1839  widthTextFront->setText( ui.lblLaserFrontFreeWidth->text() );
1840  }
1841  else
1842  {
1843  widthTextFront->setText( uiSmall.lblLaserFrontFreeWidth->text() );
1844  }
1845 #endif
1846 }
1847 
1848 
1849 void Gui::showPreferredDirection(QString direction)
1850 {
1851  if (direction == "FORWARD")
1852  {
1853  if (useLargeGUI)
1854  {
1855  ui.lblPreferredDirection->setPixmap(QPixmap(":/images/images/up.png"));
1856  }
1857  else
1858  {
1859  uiSmall.lblPreferredDirection->setPixmap(QPixmap(":/images/images/up.png"));
1860  }
1861  return;
1862  }
1863 
1864  if (direction == "LEFT")
1865  {
1866  if (useLargeGUI)
1867  {
1868  ui.lblPreferredDirection->setPixmap(QPixmap(":/images/images/left.png"));
1869  }
1870  else
1871  {
1872  uiSmall.lblPreferredDirection->setPixmap(QPixmap(":/images/images/left.png"));
1873  }
1874  return;
1875  }
1876 
1877  if (direction == "RIGHT")
1878  {
1879  if (useLargeGUI)
1880  {
1881  ui.lblPreferredDirection->setPixmap(QPixmap(":/images/images/right.png"));
1882  }
1883  else
1884  {
1885  uiSmall.lblPreferredDirection->setPixmap(QPixmap(":/images/images/right.png"));
1886  }
1887  return;
1888  }
1889 
1890  if (direction == "NONE")
1891  {
1892  if (useLargeGUI)
1893  {
1894  ui.lblPreferredDirection->setPixmap(QPixmap(":/images/images/middle.png"));
1895  }
1896  else
1897  {
1898  uiSmall.lblPreferredDirection->setPixmap(QPixmap(":/images/images/middle.png"));
1899  }
1900  return;
1901  }
1902 
1903  appendLog(QString("ERROR: direction '%1' not supported in showPreferredDirection::Gui").arg(direction));
1904 }
1905 
1906 
1907 void Gui::showFaceTrackDirection(QString direction)
1908 {
1909  if (direction == "UP")
1910  {
1911  if (useLargeGUI)
1912  {
1913  ui.lblFaceTrackTo->setPixmap(QPixmap(":/images/images/up.png"));
1914  }
1915  else
1916  {
1917  uiSmall.lblFaceTrackTo->setPixmap(QPixmap(":/images/images/up.png"));
1918  }
1919  return;
1920  }
1921 
1922  if (direction == "UPLEFT")
1923  {
1924  if (useLargeGUI)
1925  {
1926  ui.lblFaceTrackTo->setPixmap(QPixmap(":/images/images/upleft.png"));
1927  }
1928  else
1929  {
1930  uiSmall.lblFaceTrackTo->setPixmap(QPixmap(":/images/images/upleft.png"));
1931  }
1932  return;
1933  }
1934 
1935  if (direction == "UPRIGHT")
1936  {
1937  if (useLargeGUI)
1938  {
1939  ui.lblFaceTrackTo->setPixmap(QPixmap(":/images/images/upright.png"));
1940  }
1941  else
1942  {
1943  uiSmall.lblFaceTrackTo->setPixmap(QPixmap(":/images/images/upright.png"));
1944  }
1945  return;
1946  }
1947 
1948  if (direction == "DOWN")
1949  {
1950  if (useLargeGUI)
1951  {
1952  ui.lblFaceTrackTo->setPixmap(QPixmap(":/images/images/down.png"));
1953  }
1954  else
1955  {
1956  uiSmall.lblFaceTrackTo->setPixmap(QPixmap(":/images/images/down.png"));
1957  }
1958  return;
1959  }
1960 
1961  if (direction == "DOWNLEFT")
1962  {
1963  if (useLargeGUI)
1964  {
1965  ui.lblFaceTrackTo->setPixmap(QPixmap(":/images/images/downleft.png"));
1966  }
1967  else
1968  {
1969  uiSmall.lblFaceTrackTo->setPixmap(QPixmap(":/images/images/downleft.png"));
1970  }
1971  return;
1972  }
1973 
1974  if (direction == "DOWNRIGHT")
1975  {
1976  if (useLargeGUI)
1977  {
1978  ui.lblFaceTrackTo->setPixmap(QPixmap(":/images/images/downright.png"));
1979  }
1980  else
1981  {
1982  uiSmall.lblFaceTrackTo->setPixmap(QPixmap(":/images/images/downright.png"));
1983  }
1984  return;
1985  }
1986 
1987  if (direction == "LEFT")
1988  {
1989  if (useLargeGUI)
1990  {
1991  ui.lblFaceTrackTo->setPixmap(QPixmap(":/images/images/left.png"));
1992  }
1993  else
1994  {
1995  uiSmall.lblFaceTrackTo->setPixmap(QPixmap(":/images/images/left.png"));
1996  }
1997  return;
1998  }
1999 
2000  if (direction == "RIGHT")
2001  {
2002  if (useLargeGUI)
2003  {
2004  ui.lblFaceTrackTo->setPixmap(QPixmap(":/images/images/right.png"));
2005  }
2006  else
2007  {
2008  uiSmall.lblFaceTrackTo->setPixmap(QPixmap(":/images/images/right.png"));
2009  }
2010  return;
2011  }
2012 
2013  if (direction == "NONE")
2014  {
2015  if (useLargeGUI)
2016  {
2017  ui.lblFaceTrackTo->setPixmap(QPixmap(":/images/images/middle.png"));
2018  }
2019  else
2020  {
2021  uiSmall.lblFaceTrackTo->setPixmap(QPixmap(":/images/images/middle.png"));
2022  }
2023  return;
2024  }
2025 }
2026 
2027 
2029 {
2030  saveCamImage();
2031  appendLog("Picture saved");
2032 }
2033 
2034 
2035 void Gui::showFaceTrackData(int faces, int faceX, int faceY, int faceRadius, int lastFaceX, int lastFaceY)
2036 {
2037 /*
2038 
2039  currently not in use...
2040 
2041  // show coordinates of the first detected face
2042  ui.lblFaces->setNum(faces);
2043 
2044  ui.lblFaceX->setNum(faceX);
2045  ui.lblFaceY->setNum(faceY);
2046  ui.lblFaceRadius->setNum(faceRadius);
2047 
2048  ui.lblLastFaceX->setNum(lastFaceX);
2049  ui.lblLastFaceY->setNum(lastFaceY);
2050 */
2051 
2052  Q_UNUSED(faces);
2053  Q_UNUSED(faceX);
2054  Q_UNUSED(faceY);
2055  Q_UNUSED(faceRadius);
2056  Q_UNUSED(lastFaceX);
2057  Q_UNUSED(lastFaceY);
2058 }
2059 
2060 
2062 {
2063  appendLog("Face detection disabled!");
2064  if (useLargeGUI)
2065  {
2066  ui.checkBoxFaceDetection->setEnabled(false);
2067  ui.checkBoxFaceTracking->setEnabled(false);
2068  }
2069  else
2070  {
2071  uiSmall.checkBoxFaceDetection->setEnabled(false);
2072  uiSmall.checkBoxFaceTracking->setEnabled(false);
2073  }
2074 }
2075 
2076 
2078 {
2079 #ifndef USEROBOTGUI
2080  if (useLargeGUI)
2081  {
2082  ui.dockCamera->hide();
2083  }
2084  else
2085  {
2086  // no dock widgets in the small GUI
2087  }
2088 #endif
2089 }
2090 
2091 
2093 {
2094  appendLog("to do");
2095 }
2096 
2097 
2098 void Gui::setCamImage(QImage* image)
2099 {
2100 
2101  if (useLargeGUI)
2102  {
2103  ui.lblCamera->setPixmap(pixmap.fromImage(*(image)));
2104  //ui.imageFrame->setPixmap( QPixmap::fromImage( tmp ) );
2105  }
2106  else
2107  {
2108  uiSmall.lblCamera->setPixmap(pixmap.fromImage(*(image)));
2109  //uiSmall.imageFrame->setPixmap( QPixmap::fromImage( tmp ) );
2110  }
2111 
2112 /*
2113  // save pic, when ckecked in GUI
2114  if ( ui.checkBoxAutoSave->isChecked() )
2115  {
2116  saveCamImage();
2117  }
2118 */
2119 }
2120 
2121 
2122 void Gui::setCamImageDepth(QImage* image)
2123 {
2124 
2125  if (useLargeGUI)
2126  {
2127  ui.lblCameraDepth->setPixmap(pixmap.fromImage(*(image)));
2128  }
2129  else
2130  {
2131  uiSmall.lblCameraDepth->setPixmap(pixmap.fromImage(*(image)));
2132  }
2133 }
2134 
2135 
2136 void Gui::setCamImageOpenCV(QImage* image)
2137 {
2138  if (useLargeGUI)
2139  {
2140  ui.lblCameraOpenCV->setPixmap(pixmap.fromImage(*(image)));
2141  }
2142  else
2143  {
2144  uiSmall.lblCameraOpenCV->setPixmap(pixmap.fromImage(*(image)));
2145  }
2146 }
2147 
2148 
2149 /*
2150 void Gui::on_btnKinectVideoRGB_clicked(bool checked)
2151 {
2152  if (checked)
2153  emit setVideoMode(0);
2154 }
2155 
2156 
2157 void Gui::on_btnKinectVideoYUVRGB_clicked(bool checked)
2158 {
2159  if (checked)
2160  emit setVideoMode(1);
2161 }
2162 
2163 
2164 void Gui::on_btnKinectVideoIR8Bit_clicked(bool checked)
2165 {
2166  if (checked)
2167  emit setVideoMode(2);
2168 }
2169 */
2170 
2172 {
2173  emit setKinectAngle(i);
2174 }
2175 
2176 
2178 {
2179  if (useLargeGUI)
2180  {
2181  ui.spinBoxKinectAngle->setValue(0);
2182  }
2183  else
2184  {
2185  uiSmall.spinBoxKinectAngle->setValue(0);
2186  }
2187 
2188  emit resetKinectAngle();
2189 }
2190 
2192 {
2193  emit setThreshold(value);
2194 }
2195 
2196 
2198 {
2199 /*
2200  //---------------------------
2201  // grab cam pic from Qt-GUI
2202  //---------------------------
2203  static QDateTime timestamp;
2204 
2205 
2206  cameraPicToSave = QPixmap::grabWindow(QWidget::winId(), ui.dockCamera->x()+ui.frameCamera->x()+9, ui.dockCamera->y()+ui.frameCamera->y()+95, ui.frameCamera->width(), ui.frameCamera->height());
2207  //cameraPicToSave = QPixmap::grabWidget(ui.frameCamera); //doesnt work
2208  //cameraPicToSave = QPixmap::grabWidget(ui.dockCamera); //doesnt work
2209 
2210  //--------------------------------------------------------------------------------------
2211  // save image to disk, but not within the same seond (same timestamp like last picture)
2212  //--------------------------------------------------------------------------------------
2213  if (QDateTime::currentDateTime() != timestamp)
2214  {
2215  // get the actual date and time
2216  timestamp = QDateTime::currentDateTime();
2217  QString filename = timestamp.toString("yyyy-MM-dd_hh-mm-ss");
2218  filename += ".png";
2219 
2220  // save
2221  cameraPicToSave.save(filename.toAscii(), "PNG");
2222  //appendLog(tr("Picture \"%1\" saved.").arg(filename));
2223  }
2224 */
2225 }
2226 
2227 
2228 /*
2229 #ifndef BUILDFORROBOT
2230 void Gui::setPlotData1(double *xval, double *yval, int size)
2231 {
2232  //---------------
2233  // curveCurrent1
2234  //---------------
2235 
2236  // set curve with data
2237  curveCurrent1.setData(xval, yval, size);
2238 
2239  // attach data to curve
2240  curveCurrent1.attach(&qwtPlotCurrent1);
2241 
2242  // after changing the values, replot the curve
2243  qwtPlotCurrent1.replot();
2244 }
2245 #endif
2246 
2247 
2248 #ifndef BUILDFORROBOT
2249 void Gui::setPlotData2(double *xval, double *yval, int size)
2250 {
2251  //---------------
2252  // curveCurrent2
2253  //---------------
2254 
2255  // set curve with data
2256  curveCurrent2.setData(xval, yval, size);
2257 
2258  // attach data to curve
2259  curveCurrent2.attach(&qwtPlotCurrent1); // add curve to qwtPlot 1 !!
2260 
2261  // after changing the values, replot the curve
2262  qwtPlotCurrent1.replot(); // replot qwtPlot 1 !!
2263 }
2264 #endif
2265 
2266 
2267 #ifndef BUILDFORROBOT
2268 void Gui::setPlotData3(double *xval, double *yval, int size)
2269 {
2270  //---------------
2271  // curveCurrent3
2272  //---------------
2273 
2274  // set curve with data
2275  curveCurrent3.setData(xval, yval, size);
2276 
2277  // attach data to curve
2278  curveCurrent3.attach(&qwtPlotCurrent2); // curve 3 to qwtPlot 2
2279 
2280  // after changing the values, replot the curve
2281  qwtPlotCurrent2.replot();
2282 }
2283 #endif
2284 
2285 
2286 #ifndef BUILDFORROBOT
2287 void Gui::setPlotData4(double *xval, double *yval, int size)
2288 {
2289  //---------------
2290  // curveCurrent4
2291  //---------------
2292 
2293  // set curve with data
2294  curveCurrent4.setData(xval, yval, size);
2295 
2296  // attach data to curve
2297  curveCurrent4.attach(&qwtPlotCurrent2); // curve 4 to qwtPlot 2
2298 
2299  // after changing the values, replot the curve
2300  qwtPlotCurrent2.replot(); // replot qwtPlot 2 !!
2301 }
2302 #endif
2303 */
2304 
2305 
2306 #ifndef BUILDFORROBOT
2307 void Gui::setPlotData5(double *xval, double *yval, int size)
2308 {
2309  //---------------
2310  // curveVoltage1
2311  //---------------
2312 
2313  // set curve with data
2314  curveVoltage1.setData(xval, yval, size);
2315 
2316  // attach data to curve
2317  curveVoltage1.attach(&qwtPlotVoltage1);
2318 
2319  // after changing the values, replot the curve
2320  qwtPlotVoltage1.replot();
2321 }
2322 #endif
2323 
2324 
2325 #ifndef BUILDFORROBOT
2326 void Gui::setPlotData6(double *xval, double *yval, int size)
2327 {
2328  //---------------
2329  // curveVoltage2
2330  //---------------
2331 
2332  // set curve with data
2333  curveVoltage2.setData(xval, yval, size);
2334 
2335  // attach data to curve
2336  curveVoltage2.attach(&qwtPlotVoltage2);
2337 
2338  // after changing the values, replot the curve
2339  qwtPlotVoltage2.replot();
2340 }
2341 #endif
2342 
2343 
2344 #ifndef BUILDFORROBOT
2345 void Gui::setPlotDataHeartbeat(double *xval, double *yval, int size)
2346 {
2347  //---------------
2348  // Heartbeat
2349  //---------------
2350 
2351  // set curve with data
2352  curveHeartbeat.setData(xval, yval, size);
2353 
2354  // attach data to curve
2356 
2357  // after changing the values, replot the curve
2358  qwtPlotHeartbeat.replot();
2359 }
2360 #endif
2361 
2362 /*
2363 void Gui::on_btnPower1_toggled(bool checked)
2364 {
2365  if (checked)
2366  {
2367  // motor on
2368  if (ui.btnDirection1->isChecked())
2369  {
2370  emit drive(MOTOR1BW);
2371  }
2372  else
2373  {
2374  emit drive(MOTOR1FW);
2375  }
2376  }
2377  else
2378  {
2379  // motor off
2380  emit drive(MOTOR1OFF);
2381  }
2382 }
2383 
2384 
2385 void Gui::on_btnPower2_toggled(bool checked)
2386 {
2387  if (checked)
2388  {
2389  // motor on
2390  if (ui.btnDirection2->isChecked())
2391  {
2392  emit drive(MOTOR2BW);
2393  }
2394  else
2395  {
2396  emit drive(MOTOR2FW);
2397  }
2398  }
2399  else
2400  {
2401  // motor off
2402  emit drive(MOTOR2OFF);
2403  }
2404 }
2405 
2406 
2407 void Gui::on_btnPower3_toggled(bool checked)
2408 {
2409  if (checked)
2410  {
2411  // motor on
2412  if (ui.btnDirection3->isChecked())
2413  {
2414  emit drive(MOTOR3BW);
2415  }
2416  else
2417  {
2418  emit drive(MOTOR3FW);
2419  }
2420  }
2421  else
2422  {
2423  // motor off
2424  emit drive(MOTOR3OFF);
2425  }
2426 }
2427 
2428 
2429 void Gui::on_btnPower4_toggled(bool checked)
2430 {
2431  if (checked)
2432  {
2433  // motor on
2434  if (ui.btnDirection4->isChecked())
2435  {
2436  emit drive(MOTOR4BW);
2437  }
2438  else
2439  {
2440  emit drive(MOTOR4FW);
2441  }
2442  }
2443  else
2444  {
2445  // motor off
2446  emit drive(MOTOR4OFF);
2447  }
2448 }
2449 
2450 
2451 void Gui::on_btnDirection1_toggled(bool checked)
2452 {
2453  if (checked)
2454  {
2455  // backward
2456  ui.btnDirection1->setText("BACKWARD");
2457  if (ui.btnPower1->isChecked())
2458  {
2459  emit drive(MOTOR1BW);
2460  }
2461  }
2462  else
2463  {
2464  // forward
2465  ui.btnDirection1->setText("FORWARD");
2466  if (ui.btnPower1->isChecked())
2467  {
2468  emit drive(MOTOR1FW);
2469  }
2470  }
2471 }
2472 
2473 
2474 void Gui::on_btnDirection2_toggled(bool checked)
2475 {
2476  if (checked)
2477  {
2478  // backward
2479  ui.btnDirection2->setText("BACKWARD");
2480  if (ui.btnPower2->isChecked())
2481  {
2482  emit drive(MOTOR2BW);
2483  }
2484  }
2485  else
2486  {
2487  // forward
2488  ui.btnDirection2->setText("FORWARD");
2489  if (ui.btnPower2->isChecked())
2490  {
2491  emit drive(MOTOR2FW);
2492  }
2493  }
2494 }
2495 
2496 
2497 void Gui::on_btnDirection3_toggled(bool checked)
2498 {
2499  if (checked)
2500  {
2501  // backward
2502  ui.btnDirection3->setText("BACKWARD");
2503  if (ui.btnPower3->isChecked())
2504  {
2505  emit drive(MOTOR3BW);
2506  }
2507  }
2508  else
2509  {
2510  // forward
2511  ui.btnDirection3->setText("FORWARD");
2512  if (ui.btnPower3->isChecked())
2513  {
2514  emit drive(MOTOR3FW);
2515  }
2516  }
2517 }
2518 
2519 
2520 void Gui::on_btnDirection4_toggled(bool checked)
2521 {
2522  if (checked)
2523  {
2524  // backward
2525  ui.btnDirection4->setText("BACKWARD");
2526  if (ui.btnPower4->isChecked())
2527  {
2528  emit drive(MOTOR4BW);
2529  }
2530  }
2531  else
2532  {
2533  // forward
2534  ui.btnDirection4->setText("FORWARD");
2535  if (ui.btnPower4->isChecked())
2536  {
2537  emit drive(MOTOR4FW);
2538  }
2539  }
2540 }
2541 */
2542 
2544 {
2545  // if remote control is enabled, disable some controls in the GUI
2546  if (useLargeGUI)
2547  {
2548  if (ui.actionRemote->isChecked())
2549  {
2550  ui.actionDrive->setEnabled(false);
2551  emit enableRemoteControlListening(true);
2552  }
2553  else
2554  {
2555  if (robotIsOn)
2556  {
2557  ui.actionDrive->setEnabled(true);
2558  }
2559  emit enableRemoteControlListening(false);
2560  }
2561  }
2562  else
2563  {
2564  if (uiSmall.actionRemote->isChecked())
2565  {
2566  uiSmall.actionDrive->setEnabled(false);
2567  emit enableRemoteControlListening(true);
2568  }
2569  else
2570  {
2571  if (robotIsOn)
2572  {
2573  uiSmall.actionDrive->setEnabled(true);
2574  }
2575  emit enableRemoteControlListening(false);
2576  }
2577  }
2578 }
2579 
2580 
2582 {
2583  if (useLargeGUI)
2584  {
2585  if (ui.actionSimulate->isChecked())
2586  {
2587  ui.actionSimulate->setStatusTip("Disable simulation");
2588  ui.actionSimulate->setToolTip("Disable simulation");
2589  emit simulate(true);
2590  }
2591  else
2592  {
2593  ui.actionSimulate->setStatusTip("Simulate");
2594  ui.actionSimulate->setToolTip("Simulate");
2595  emit simulate(false);
2596  }
2597  }
2598  else
2599  {
2600  if (uiSmall.actionSimulate->isChecked())
2601  {
2602  uiSmall.actionSimulate->setStatusTip("Disable simulation");
2603  uiSmall.actionSimulate->setToolTip("Disable simulation");
2604  emit simulate(true);
2605  }
2606  else
2607  {
2608  uiSmall.actionSimulate->setStatusTip("Simulate");
2609  uiSmall.actionSimulate->setToolTip("Simulate");
2610  emit simulate(false);
2611  }
2612  }
2613 }
2614 
2615 
2617 {
2618  emit writeLaserData();
2619 }
2620 
2621 
2623 {
2624  if (useLargeGUI)
2625  {
2626  if (ui.actionDemo->isChecked())
2627  {
2628  emit demo(true);
2629  }
2630  else
2631  {
2632  emit demo(false);
2633  }
2634  }
2635  else
2636  {
2637  if (uiSmall.actionDemo->isChecked())
2638  {
2639  emit demo(true);
2640  }
2641  else
2642  {
2643  emit demo(false);
2644  }
2645  }
2646 }
2647 
2648 
2650 {
2651  emit mediaSkip();
2652 }
2653 
2654 
2655 #ifdef ACTIVELASERVIEW
2656 void Gui::on_sliderZoom_valueChanged(int value)
2657 {
2658  qreal x = 0;
2659  qreal y = 0;
2660  qreal newSize = 0;
2661  QString text;
2662 
2663 
2664  // show the zoom value in a label /// @todo put his in a signal slot in qt desginer
2665  // ui.labelLaserTop->setText(tr("%1").arg(value));
2666 
2667 
2668  // rescale the robot pixmap to the last scale
2669  // (the laser lines are rescaled automatically by in the slot)
2670  pixmapBot1->scale( (1 / (qreal)lastZoom), (1 / (qreal)lastZoom) );
2671  pixmapBot2->scale( (1 / (qreal)lastZoom), (1 / (qreal)lastZoom) );
2672 
2673  // scale to the actual slider value
2674  pixmapBot1->scale(value, value);
2675  pixmapBot2->scale(value, value);
2676 
2677  //--------------------------
2678  // store the current scale
2679  // ('lastZoom' is also used in calculateLaserFrontYpos!!)
2680  //--------------------------
2681  lastZoom = value;
2682 
2683  //------------------------------
2684  // set the position of the bot
2685  //------------------------------
2686  // recalculate the middle position of the bot pixmap!
2687  x = laserXPos - ( pixmapBot1->pixmap().width() / 2 / startScale * lastZoom);
2688  y = laserYPos - ( pixmapBot1->pixmap().height() / 2 / startScale * lastZoom);
2689 
2690  // horizontal center
2691  pixmapBot1->setPos(x, y);
2692  pixmapBot2->setPos(x, y);
2693 
2694 
2695  //------------------------------------------------------
2696  // change the x and y position of the FRONT laser lines
2697  //------------------------------------------------------
2698  x = laserXPos;
2699  y = laserYPos - (INITIALLASERYPOSFRONT / startScale * lastZoom);
2700 
2701  for (int i=0; i<laserLineListFront->size(); i++)
2702  {
2703  // horizontal center:
2704  // x = middle of the bot pixmap in the view
2705  // y = set manually
2706  laserLineListFront->at(i)->setPos(x, y);
2707  }
2708 
2709 
2710  //------------------------------------------------
2711  // change the y position of the REAR laser lines
2712  //------------------------------------------------
2713  x = laserXPos;
2714  y = laserYPos + (INITIALLASERYPOSREAR / startScale * lastZoom);
2715 
2716  for (int i=0; i<laserLineListRear->size(); i++)
2717  {
2718  // horizontal center:
2719  // x = middle of the bot pixmap in the view
2720  // y = set manually
2721  laserLineListRear->at(i)->setPos(x, y);
2722  }
2723 
2724 
2725  //------------------------------------------------------------------
2726  // change the y position of the FRONT laser distance lines and text
2727  //------------------------------------------------------------------
2728  for (int i=0; i<laserDistanceLineListFront->size(); i++)
2729  {
2730  // (LASERDISTANCEFIRSTCIRCLE/STARTZOOMLEVEL) is the 'factor'
2731  // value is the zoomSlider value
2732  newSize = (LASERDISTANCEFIRSTCIRCLE / STARTZOOMLEVEL * value) + (i * LASERDISTANCEDISTANCE);
2733 
2734  // recalculate the new position (put the middle of the circle in the middle of the graphics view)
2735  x = laserXPos - (newSize / 2);
2736  y = laserYPos - (newSize / 2) + (INITIALLASERYPOSFRONT / startScale * lastZoom);
2737 
2738  // change the width and height
2739  laserDistanceLineListFront->at(i)->setRect(0, 0, newSize, newSize);
2740  // set the circle position!
2741  laserDistanceLineListFront->at(i)->setPos(x, y);
2742 
2743 
2744  // recalculate the new text position
2745  x = laserXPos;
2746  y = laserYPos + (newSize/2);
2747 
2748  // set the text position!
2749  laserDistanceTextFront->at(i)->setPos(x, y);
2750 
2751  // set the text
2752  text = QString("%1").arg(newSize/(FITTOFRAMEFACTOR*value*2));
2753  // only show 2 digits after the ','
2754  laserDistanceTextFront->at(i)->setText(text.left(text.indexOf(".") + 3) + "m");
2755  }
2756 
2757 
2758  //------------------------------------------------------------------
2759  // change the y position of the REAR laser distance lines and text
2760  //------------------------------------------------------------------
2761  for (int i=0; i<laserDistanceLineListRear->size(); i++)
2762  {
2763  // (LASERDISTANCEFIRSTCIRCLE/STARTZOOMLEVEL) is the 'factor'
2764  // value is the zoomSlider value
2765  newSize = (LASERDISTANCEFIRSTCIRCLE / STARTZOOMLEVEL * value) + (i * LASERDISTANCEDISTANCE);
2766 
2767  // recalculate the new position (put the middle of the circle in the middle of the graphics view)
2768  x = laserXPos - (newSize / 2);
2769  y = laserYPos - (newSize / 2) - (INITIALLASERYPOSREAR / startScale * lastZoom);
2770 
2771  // change the width and height
2772  laserDistanceLineListRear->at(i)->setRect(0, 0, newSize, newSize);
2773  // set the circle position!
2774  laserDistanceLineListRear->at(i)->setPos(x, y);
2775 
2776 
2777  // recalculate the new text position
2778  x = laserXPos;
2779  y = laserYPos - (newSize/2);
2780 
2781  // set the text position!
2782  laserDistanceTextRear->at(i)->setPos(x, y);
2783 
2784  // set the text
2785  text = QString("%1").arg(newSize/(FITTOFRAMEFACTOR*value*2));
2786  // only show 2 digits after the ','
2787  laserDistanceTextRear->at(i)->setText(text.left(text.indexOf(".") + 3) + "m");
2788  }
2789 }
2790 #endif
2791 
2792 
2794 {
2795  Q_UNUSED(state);
2796 
2797  // QtGL class!!
2798  // ui.frameCamera->enableMirrorMode(state);
2799  // uiSmall.frameCamera->enableMirrorMode(state);
2800 }
2801 
2802 
2804 {
2805  // en/disable face *tracking* checkbox
2806  if (state == Qt::Checked)
2807  {
2808  if (useLargeGUI)
2809  {
2810  ui.checkBoxFaceTracking->setEnabled(true);
2811  }
2812  else
2813  {
2814  uiSmall.checkBoxFaceTracking->setEnabled(true);
2815  }
2816  }
2817  else
2818  {
2819  if (useLargeGUI)
2820  {
2821  ui.checkBoxFaceTracking->setEnabled(false);
2822  }
2823  else
2824  {
2825  uiSmall.checkBoxFaceTracking->setEnabled(false);
2826  }
2827  }
2828 }
2829 
2830 
2832 {
2833  //
2834  // This slot is only for changing the label!
2835  // Not for enabling face detection!
2836  // This is done via signal slot!
2837  //
2838 
2839  // change face tracking direction icon to middle
2840  if (state == Qt::Unchecked)
2841  {
2842  if (useLargeGUI)
2843  {
2844  ui.lblFaceTrackTo->setPixmap(QPixmap(":/images/images/middle.png"));
2845  }
2846  else
2847  {
2848  uiSmall.lblFaceTrackTo->setPixmap(QPixmap(":/images/images/middle.png"));
2849  }
2850  }
2851 }
2852 
2853 
2854 #ifdef ACTIVELASERVIEW
2855 void Gui::initLaserView()
2856 {
2857  int i = 0;
2858  qreal angle = 0;
2859  // for getting nice x and y position
2860  qreal x = 0;
2861  qreal y = 0;
2862 
2863 
2864  //--------------
2865  // window init
2866  //--------------
2868  //ui.splitLaserView->setSizes(QList<int>() << 1000 << 100);
2869  // make dockLaserView wider
2870  //ui.dockLaserView->resize(ui.graphicsViewLaser->width(), ui.dockLaserView->height());
2871  //ui.centralWidget->resize(ui.graphicsViewLaser->width(), ui.dockLaserView->height());
2872  //ui.centralWidget->resize(400, ui.dockLaserView->height());
2873 
2874 
2875  //==================================================
2876  // move the laser lines to their x and y positions
2877  //==================================================
2878 
2879  // init the reference spot pos at startup!
2880  // (horicontal and vertical middle of the view)
2881  if (useLargeGUI)
2882  {
2883  laserXPos = (ui.graphicsViewLaser->width() / 2);
2884  laserYPos = (ui.graphicsViewLaser->height() / 2);
2885  }
2886  else
2887  {
2888  laserXPos = (uiSmall.graphicsViewLaser->width() / 2);
2889  laserYPos = (uiSmall.graphicsViewLaser->height() / 2);
2890  }
2891 
2892 
2893  // init laser y pos at startup!
2894  x = laserXPos;
2895  y = laserYPos; // INITIALLASERYPOSFRONT has no effect here, only in on_sliderZoom_valueChanged !!
2896 
2897 
2898  //--------------
2899  // REAR laser
2900  //--------------
2901  // rotate every laser line by 'resolution' degree (e.g. 0.1 or 0.5 or 1.0)
2902  // Be sure to rotate that the middle of the laserAngle is always at a vertical 90 degree in the scene!
2903  // (Rotate laser line counterclockwise by the half of the laserAngle)
2904  i = 0;
2905  angle = -(laserscannerAngleRear/2);
2906 
2907  while (i<laserLineListRear->size())
2908  {
2909  laserLineListRear->at(i)->rotate(angle);
2910 
2911  i++;
2912  angle += laserscannerResolutionRear;
2913  }
2914 
2915 
2916  y = laserYPos;// INITIALLASERYPOSREAR has no effect here, only in on_sliderZoom_valueChanged !!
2917 
2918 
2919  //--------------
2920  // FRONT laser
2921  //--------------
2922  // rotate every laser line by one degree
2923  // Be sure to rotate that the middle of the laserAngle is always at a vertical 90 degree in the scene!
2924  // (Rotate laser line counterclockwise by 180 degrees and further by the half of the laserAngle)
2925  i = 0;
2926  angle = ( 180 - (laserscannerAngleFront/2) );
2927 
2928  while (i<laserLineListFront->size())
2929  {
2930  laserLineListFront->at(i)->rotate(angle);
2931 
2932  i++;
2933  angle += laserscannerResolutionFront;
2934  }
2935 
2936  //==========================================================
2937  // refresh the view with the actual zoom (after gui came up)
2938  //==========================================================
2939  on_sliderZoom_valueChanged(lastZoom);
2940 
2941 
2942  //=============================================================================
2943  // move the FRONT distance lines to their x and y positions
2944  // has to be *after* sliderZoom_valueChanged for correct 'distance' positions!
2945  //=============================================================================
2946  // in the middle of the front of bot, minus a half of the innerst circle (no. 0)
2947  x = laserXPos - (laserDistanceLineListFront->at(0)->rect().width() / 2);
2948  y = laserYPos - (laserDistanceLineListFront->at(0)->rect().height() / 2);
2949 
2950  //-----------------
2951  // FRONT distances
2952  //-----------------
2953  for (int i=0; i<laserDistanceLineListFront->size(); i++)
2954  {
2955  laserDistanceLineListFront->at(i)->setPos( (x - (i*LASERDISTANCEDISTANCE/2)), y - (i*LASERDISTANCEDISTANCE/2) );
2956  }
2957 
2958 
2959  //=============================================================================
2960  // move the REAR distance lines to their x and y positions
2961  // has to be *after* sliderZoom_valueChanged for correct 'distance' positions!
2962  //=============================================================================
2963  // in the middle of the front of bot, minus a half of the innerst circle (no. 0)
2964  x = laserXPos - (laserDistanceLineListRear->at(0)->rect().width() / 2);
2965  y = laserYPos - (laserDistanceLineListRear->at(0)->rect().height() / 2);
2966 
2967  //-----------------
2968  // REAR distances
2969  //-----------------
2970  for (int i=0; i<laserDistanceLineListRear->size(); i++)
2971  {
2972  laserDistanceLineListRear->at(i)->setPos( (x - (i*LASERDISTANCEDISTANCE/2)), y - (i*LASERDISTANCEDISTANCE/2) );
2973  }
2974 
2975 
2976  // zoom into the laser lines by default factor
2977  if (useLargeGUI)
2978  {
2979  ui.sliderZoom->setValue(STARTZOOMLEVEL);
2980  }
2981  else
2982  {
2983  uiSmall.sliderZoom->setValue(STARTZOOMLEVEL);
2984  }
2985 }
2986 #endif
2987 
2988 
2989 #ifdef ACTIVELASERVIEW
2990 void Gui::refreshLaserViewFront(QList <float> laserScannerValues, QList <int> laserScannerFlags)
2991 {
2992  qreal x = 0.0;
2993  qreal y = 0.0;
2994  /*
2995  int r = 0;
2996  qreal xKart;
2997  qreal yKart;
2998  int angle = 0;
2999  static qreal widthLineFrontPosX1 = 0.0;
3000  static qreal widthLineFrontPosX2 = 0.0;
3001  static qreal widthLineFrontPosY1 = 0.0;
3002  static qreal widthLineFrontPosY2 = 0.0;
3003  */
3004  int laserLineLength = 0;
3005  int zoomView = 0;
3006  if (useLargeGUI)
3007  {
3008  zoomView = ui.sliderZoom->value(); // get a scale to fit the beams into the window
3009  }
3010  else
3011  {
3012  zoomView = uiSmall.sliderZoom->value(); // get a scale to fit the beams into the window
3013  }
3014 
3015 
3016  //----------------------------------------------------------------------------------------
3017  // Change the laser lines (color and length)
3018  //----------------------------------------------------------------------------------------
3019  // First: set/change the color of each line, depending on the flag set in the laserThread
3020  //----------------------------------------------------------------------------------------
3021  for (int i=0; i<laserLineListFront->size(); i++)
3022  {
3023  // check if there was an obstacle
3024  if (laserScannerFlags[i] == OBSTACLE)
3025  {
3026  // obstacle detected!
3027  laserLineListFront->at(i)->setPen(QPen(colorLaserObstacle));
3028  }
3029  else
3030  {
3031  if (laserScannerFlags[i] == LARGESTFREEWAY)
3032  {
3033  // l a r g e s t f r e e w a y
3034  // laserLineListFront->at(i)->setPen(QPen(colorLaserPreferredDrivingDirection, 4));
3035  laserLineListFront->at(i)->setPen(QPen(colorLaserPreferredDrivingDirection));
3036  }
3037  else
3038  {
3039  if (laserScannerFlags[i] == CENTEROFLARGESTFREEWAY)
3040  {
3041  // center of free way (only one line)
3042  laserLineListFront->at(i)->setPen(QPen(colorLaserCenterDrivingDirection));
3043  }
3044  else
3045  {
3046  if (laserScannerFlags[i] == IGNORETHIS)
3047  {
3048  // mark the ignored areas
3049  laserLineListFront->at(i)->setPen(QPen(colorLaserIgnoreArea));
3050  }
3051  else
3052  {
3053  // n o o b s t a c l e
3054  laserLineListFront->at(i)->setPen(QPen(colorLaserFreeWay));
3055  }
3056  }
3057  }
3058  }
3059  }
3060 
3061 
3062  //---------------------------------------------------------------------------
3063  // Second: change the *length* of each line!
3064  //---------------------------------------------------------------------------
3065  // /get the data from 180 to 0 (right to left!!)
3066  for (int i=0; i<laserLineListFront->size(); i++)
3067  {
3068  // get value from laser and
3069  // draw the lines at every 1
3070  laserLineLength = qRound(laserScannerValues[i]*FITTOFRAMEFACTOR*zoomView); // length in Pixel!!!
3071 
3072  laserLineListFront->at(i)->setLine(0, 0, 0, laserLineLength);
3073 
3074 
3075  // set tool tip of the line to the distance
3076  int flag = laserScannerFlags[i];
3077 
3078  if (flag == FREEWAY)
3079  {
3080  string = "FREEWAY";
3081  } else if (flag == OBSTACLE)
3082  {
3083  string = "OBSTACLE";
3084  } else if (flag == LARGESTFREEWAY)
3085  {
3086  string = "LARGESTFREEWAY";
3087  } else if (flag == CENTEROFLARGESTFREEWAY)
3088  {
3089  string = "CENTEROFLARGESTFREEWAY";
3090  } else if (flag == IGNORETHIS)
3091  {
3092  string = "IGNORETHIS";
3093  }
3094 
3095  laserLineListFront->at(i)->setToolTip( QString("FRONT: %1 m, %2, %3 deg, %4 Pixel").arg(laserScannerValues[i]).arg(string).arg(i).arg(laserLineLength) );
3096 
3097 
3098  // get the current scene positions of the laser line
3099  x = laserLineListFront->at(i)->scenePos().x();
3100  y = laserLineListFront->at(i)->scenePos().y();
3101 /*
3102  // draw the first (left) width circle / get the firt coordinate for the width line
3103  if (i == mLargestFreeAreaStartFront)
3104  {
3105  angle = 270 - qRound(laserscannerAngleFront / 2) + i; // we're not starting at 0 degrees; we have an offset! (s.a. initLaserView (rotate loop)
3106  r = laserLineListFront->at(i)->line().length(); // here we have use 'i' instead of 'angle'. i is the current 'original angle'!
3107 
3108  // check which line of the free area is longer and store the positions for the drive trough line!
3109  if (laserLineListFront->at(mLargestFreeAreaStartFront)->line().length() < laserLineListFront->at(mLargestFreeAreaEndFront)->line().length())
3110  {
3111  // lenth of both lines is the same or the other one is shorter
3112  r = laserLineListFront->at(mLargestFreeAreaStartFront)->line().length();
3113  }
3114  else
3115  {
3116  // lenth of both lines is the same or the other one is shorter
3117  r = laserLineListFront->at(mLargestFreeAreaEndFront)->line().length();
3118  }
3119 
3120  // convert from polar to kartesic coordinates
3121  // WARNING: "cos" functions use radians!! so we convert the degrees to radions here!
3122  // sin and cos are swapped here because of a different x, y and angle orientation than in a normal kartesic coordination system!
3123  xKart = r * cos( angle * M_PI / 180 );
3124  yKart = r * sin( angle * M_PI / 180 );
3125 
3126  if ( (i < 90) && (laserscannerAngleFront > 180) )
3127  {
3128  // here we are in the quadrant where x is negative and y is postive
3129  // so we have to change the leading sign
3130  xKart *= -1;
3131  }
3132 
3133  // add the "start coordinates" (the laser line origin)
3134  xKart += x - (widthCirclesWidth/2);
3135  yKart += y - (widthCirclesWidth/2);
3136 
3137  //------------------------------------------------------------------
3138  // store this positions for the width line
3139  //------------------------------------------------------------------
3140  // corrected by the circle radius, to get the middle of the circle
3141  widthLineFrontPosX1 = xKart + (widthCirclesWidth/2);
3142  widthLineFrontPosY1 = yKart + (widthCirclesWidth/2);
3143 
3144  // set the circle position!
3145  widthLeftCircleFront->setPos(xKart, yKart);
3146 
3147  // set the width text to this circle
3148  // place it a bit above the circle
3149  widthTextFront->setPos(xKart, yKart - widthCirclesWidth * 2 );
3150  }
3151  else
3152  {
3153  // in all other cases
3154  // draw the next (right) width circle
3155  angle = 270 - qRound(laserscannerAngleFront / 2) + i; // we're not starting at 0 degrees; we have an offset! (s.a. initLaserView (rotate loop)
3156  r = laserLineListFront->at(i)->line().length(); // here we have use 'i' instead of 'angle'. i is the current 'original angle'!
3157 
3158  //--------------------------------------------------------------------
3159  // draw the width line
3160  //--------------------------------------------------------------------
3161  // check which line of the free area is longer and store the positions for the drive trough line!
3162  if (laserLineListFront->at(mLargestFreeAreaStartFront)->line().length() < laserLineListFront->at(mLargestFreeAreaEndFront)->line().length())
3163  {
3164  // lenth of both lines is the same or the other one is shorter
3165  r = laserLineListFront->at(mLargestFreeAreaStartFront)->line().length();
3166  }
3167  else
3168  {
3169  // lenth of both lines is the same or the other one is shorter
3170  r = laserLineListFront->at(mLargestFreeAreaEndFront)->line().length();
3171  }
3172 
3173  // convert from polar to kartesic coordinates
3174  // WARNING: "cos" functions use radians!! so we convert the degrees to radions here!
3175  // sin and cos are swapped here because of a different x, y and angle orientation than in a normal kartesic coordination system!
3176  xKart = r * cos( angle * M_PI / 180 );
3177  yKart = r * sin( angle * M_PI / 180 );
3178 
3179  if ( (i < 90) && (laserscannerAngleFront > 180) )
3180  {
3181  // here we are in the quadrant where x is negative and y is postive
3182  // so we have to change the leading sign
3183  xKart *= -1;
3184  }
3185 
3186  // add the "start coordinates" (the laser line origin)
3187  xKart += x - (widthCirclesWidth/2);
3188  yKart += y - (widthCirclesWidth/2);
3189 
3190  //------------------------------------------------------------------
3191  // store this positions for the width line
3192  //------------------------------------------------------------------
3193  // corrected by the circle radius, to get the middle of the circle
3194  widthLineFrontPosX2 = xKart + (widthCirclesWidth/2);
3195  widthLineFrontPosY2 = yKart + (widthCirclesWidth/2);
3196 
3197  // draw it
3198  widthLineFront->setLine(widthLineFrontPosX1, widthLineFrontPosY1, widthLineFrontPosX2, widthLineFrontPosY2);
3199 
3200  // set the circle position!
3201  widthRightCircleFront->setPos( widthLineFrontPosX2 - (widthCirclesWidth/2), widthLineFrontPosY2 - (widthCirclesWidth/2) );
3202  }
3203 */
3204  }
3205 
3206  // make the width objects visible
3207  widthLeftCircleFront->setVisible(true);
3208  widthRightCircleFront->setVisible(true);
3209  widthLineFront->setVisible(true);
3210 }
3211 #endif
3212 
3213 
3214 #ifdef ACTIVELASERVIEW
3215 void Gui::refreshLaserViewRear(QList <float> laserScannerValues, QList <int> laserScannerFlags)
3216 {
3217  qreal x = 0.0;
3218  qreal y = 0.0;
3219  int r = 0;
3220  qreal xKart;
3221  qreal yKart;
3222  int angle = 0;
3223  static qreal widthLineRearPosX1 = 0.0;
3224  static qreal widthLineRearPosX2 = 0.0;
3225  static qreal widthLineRearPosY1 = 0.0;
3226  static qreal widthLineRearPosY2 = 0.0;
3227  int laserLineLength = 0;
3228  int zoomView = 0;
3229  if (useLargeGUI)
3230  {
3231  zoomView = ui.sliderZoom->value(); // get a scale to fit the beams into the window
3232  }
3233  else
3234  {
3235  zoomView = uiSmall.sliderZoom->value(); // get a scale to fit the beams into the window
3236  }
3237 
3238 
3239  //----------------------------------------------------------------------------------------
3240  // Change the laser lines (color and length)
3241  //----------------------------------------------------------------------------------------
3242  // First: set/change the color of each line, depending on the flag set in the laserThread
3243  //----------------------------------------------------------------------------------------
3244  for (int i=0; i<laserLineListRear->size(); i++)
3245  {
3246  if (laserScannerFlags[i] == IGNORETHIS)
3247  {
3248  // i g n o r e d a r e a s
3249  laserLineListRear->at(i)->setPen(QPen(colorLaserIgnoreArea));
3250  }
3251  else
3252  {
3253  // check if there was an obstacle
3254  if (laserScannerFlags[i] == OBSTACLE)
3255  {
3256  // obstacle detected!
3257  laserLineListRear->at(i)->setPen(QPen(colorLaserObstacle));
3258  }
3259  else
3260  {
3261  if (laserScannerFlags[i] == LARGESTFREEWAY)
3262  {
3263  // l a r g e s t f r e e w a y
3264  laserLineListRear->at(i)->setPen(QPen(colorLaserPreferredDrivingDirection));
3265  }
3266  else
3267  {
3268  if (laserScannerFlags[i] == CENTEROFLARGESTFREEWAY)
3269  {
3270  // center of free way (only one line)
3271  laserLineListRear->at(i)->setPen(QPen(colorLaserCenterDrivingDirection));
3272  }
3273  else
3274  {
3275  // n o o b s t a c l e
3276  laserLineListRear->at(i)->setPen(QPen(colorLaserFreeWay));
3277  }
3278  }
3279  }
3280  }
3281  }
3282 
3283 
3284  //---------------------------------------------------------------------------
3285  // Second: change the *length* of each line!
3286  //---------------------------------------------------------------------------
3287  // /get the data from 180° to 0° (right to left!!)
3288  for (int i=0; i<laserLineListRear->size(); i++)
3289  {
3290  // get value from laser and
3291  // draw the lines at every 1°
3292  laserLineLength = qRound(laserScannerValues[i]*FITTOFRAMEFACTOR*zoomView); // length in Pixel!!!
3293 
3294  laserLineListRear->at(i)->setLine(0, 0, 0, laserLineLength);
3295 
3296  // set tool tip of the line to the distance
3297  laserLineListRear->at(i)->setToolTip( QString("REAR: %1 m / %2 deg / Flag=%3 / %4 Pixel").arg(laserScannerValues[i]).arg(i).arg(laserScannerFlags[i]).arg(laserLineLength) );
3298 
3299  // get the current scene positions of the laser line
3300  x = laserLineListRear->at(i)->scenePos().x();
3301  y = laserLineListRear->at(i)->scenePos().y();
3302 
3303  // draw the first (left) width circle / get the firt coordinate for the width line
3304  if (i == mLargestFreeAreaStartRear)
3305  {
3306  angle = i - qRound(laserscannerAngleRear/2); // we're not starting at 0 degrees; we have an offset! (s.a. initLaserView (rotate loop)
3307  r = laserLineListRear->at(i)->line().length(); // here we have use 'i' instead of 'angle'. i is the current 'original angle'!
3308 
3309  // check which line of the free area is longer and store the positions for the drive trough line!
3310  if (laserLineListRear->at(mLargestFreeAreaStartRear)->line().length() < laserLineListRear->at(mLargestFreeAreaEndRear)->line().length())
3311  {
3312  // lenth of both lines is the same or the other one is shorter
3313  r = laserLineListRear->at(mLargestFreeAreaStartRear)->line().length();
3314  }
3315  else
3316  {
3317  // lenth of both lines is the same or the other one is shorter
3318  r = laserLineListRear->at(mLargestFreeAreaEndRear)->line().length();
3319  }
3320 
3321  // convert from polar to kartesic coordinates
3322  // WARNING: "cos" functions use radians!! so we convert the degrees to radions here!
3323  // sin and cos are swapped here because of a different x, y and angle orientation than in a normal kartesic coordination system!
3324  xKart = r * sin( angle * M_PI / 180 );
3325  yKart = r * cos( angle * M_PI / 180 );
3326 
3327  // bring it to the correct quadrant in the coord. system
3328  xKart *= -1;
3329 
3330  // add the "start coordinates" (the laser line origin)
3331  xKart += x - (widthCirclesWidth/2);
3332  yKart += y - (widthCirclesWidth/2);
3333 
3334  //------------------------------------------------------------------
3335  // store this positions for the width line
3336  //------------------------------------------------------------------
3337  // corrected by the circle radius, to get the middle of the circle
3338  widthLineRearPosX1 = xKart + (widthCirclesWidth/2);
3339  widthLineRearPosY1 = yKart + (widthCirclesWidth/2);
3340 
3341  // set the circle position!
3342  widthLeftCircleRear->setPos(xKart, yKart);
3343  }
3344  else
3345  {
3346  // in all other cases
3347  // draw the next (right) width circle
3348  angle = i - qRound(laserscannerAngleRear/2); // we're not starting at 0 degrees; we have an offset! (s.a. initLaserView (rotate loop)
3349  r = laserLineListRear->at(i)->line().length(); // here we have use 'i' instead of 'angle'. i is the current 'original angle'!
3350 
3351  //--------------------------------------------------------------------
3352  // draw the width line
3353  //--------------------------------------------------------------------
3354  // check which line of the free area is longer and store the positions for the drive trough line!
3355  if (laserLineListRear->at(mLargestFreeAreaStartRear)->line().length() < laserLineListRear->at(mLargestFreeAreaEndRear)->line().length())
3356  {
3357  // lenth of both lines is the same or the other one is shorter
3358  r = laserLineListRear->at(mLargestFreeAreaStartRear)->line().length();
3359  }
3360  else
3361  {
3362  // lenth of both lines is the same or the other one is shorter
3363  r = laserLineListRear->at(mLargestFreeAreaEndRear)->line().length();
3364  }
3365 
3366  // convert from polar to kartesic coordinates
3367  // WARNING: "cos" functions use radians!! so we convert the degrees to radions here!
3368  // sin and cos are swapped here because of a different x, y and angle orientation than in a normal kartesic coordination system!
3369  xKart = r * sin( angle * M_PI / 180 );
3370  yKart = r * cos( angle * M_PI / 180 );
3371 
3372  // bring it to the correct quadrant in the coord. system
3373  xKart *= -1;
3374 
3375  // add the "start coordinates" (the laser line origin)
3376  xKart += x - (widthCirclesWidth/2);
3377  yKart += y - (widthCirclesWidth/2);
3378 
3379  //------------------------------------------------------------------
3380  // store this positions for the width line
3381  //------------------------------------------------------------------
3382  // corrected by the circle radius, to get the middle of the circle
3383  widthLineRearPosX2 = xKart + (widthCirclesWidth/2);
3384  widthLineRearPosY2 = yKart + (widthCirclesWidth/2);
3385 
3386  // draw it
3387  widthLineRear->setLine(widthLineRearPosX1, widthLineRearPosY1, widthLineRearPosX2, widthLineRearPosY2);
3388 
3389  // set the circle position!
3390  widthRightCircleRear->setPos( widthLineRearPosX2 - (widthCirclesWidth/2), widthLineRearPosY2 - (widthCirclesWidth/2) );
3391  }
3392  } // for i
3393 
3394  // make the width objects visible
3395  widthLeftCircleRear->setVisible(true);
3396  widthRightCircleRear->setVisible(true);
3397  widthLineRear->setVisible(true);
3398 }
3399 #endif
3400 
3401 
3402 #ifdef ACTIVELASERVIEW
3403 void Gui::setRobotPosition(QGraphicsSceneMouseEvent* mouseEvent)
3404 {
3405  //qreal diff = laserFrontYPos - laserRearYPos;
3406 
3407  // new y pos
3408  laserYPos = mouseEvent->scenePos().y();
3409  //laserRearYPos = laserFrontYPos - diff;
3410 
3411  // new x pos
3412  laserXPos = mouseEvent->scenePos().x();
3413 
3414  // refresh laserView
3415  if (useLargeGUI)
3416  {
3417  on_sliderZoom_valueChanged(ui.sliderZoom->value());
3418  }
3419  else
3420  {
3421  on_sliderZoom_valueChanged(uiSmall.sliderZoom->value());
3422  }
3423 }
3424 #endif
3425 
3426 
3427 void Gui::setLaserscannerAngle(short int laserscanner, int angle)
3428 {
3429  switch (laserscanner)
3430  {
3431  case LASER1:
3432  laserscannerAngleFront = angle;
3433  return;
3434  break;
3435  case LASER2:
3436  laserscannerAngleRear = angle;
3437  return;
3438  break;
3439  }
3440 
3441  qDebug("laser number not yet supported (Gui::setLaserscannerAngle");
3442 }
3443 
3444 
3445 void Gui::setLaserscannerResolution(short int laserscanner, float resolution)
3446 {
3447  switch (laserscanner)
3448  {
3449  case LASER1:
3450  laserscannerResolutionFront = resolution;
3451  return;
3452  break;
3453  case LASER2:
3454  laserscannerResolutionRear = resolution;
3455  return;
3456  break;
3457  }
3458 
3459  qDebug("laser number not yet supported (Gui::setLaserscannerResolution");
3460 }
3461 
3462 
3463 #ifdef ACTIVELASERVIEW
3464 void Gui::zoomLaserView(QGraphicsSceneWheelEvent* wheelEvent)
3465 {
3466  int zoomValue = 0;
3467 
3468 
3469  if (useLargeGUI)
3470  {
3471  zoomValue = ui.sliderZoom->value();
3472  }
3473  else
3474  {
3475  zoomValue = uiSmall.sliderZoom->value();
3476  }
3477 
3478 
3479  if (wheelEvent->delta() > 0)
3480  {
3481  zoomValue++;
3482  }
3483  else
3484  {
3485  zoomValue--;
3486  }
3487 
3488  // refresh laserView (set zoom slider)
3489  if (useLargeGUI)
3490  {
3491  ui.sliderZoom->setValue(zoomValue);
3492  }
3493  else
3494  {
3495  uiSmall.sliderZoom->setValue(zoomValue);
3496  }
3497 }
3498 #endif
3499 
3500 
3501 #ifdef ACTIVELASERVIEW
3502 void Gui::createLaserScannerObjects()
3503 {
3504  // the start position for the pos. calculation
3505  laserXPos = 0;
3506  laserYPos = 0;
3507  //laserFrontYPos = INITIALLASERYPOSFRONT;
3508  //laserRearYPos = INITIALLASERYPOSREAR;
3509 
3510  // set some nice colors for some widgets
3511  colorLaserObstacle = Qt::red;
3512  colorLaserFreeWay = Qt::darkRed;
3513  colorLaserPreferredDrivingDirection = Qt::darkGreen;
3514  colorLaserCenterDrivingDirection = Qt::yellow;
3515  colorLaserIgnoreArea = Qt::darkYellow;
3516  colorGraphicsSceneBackground = Qt::black;
3517 
3518 
3519  // the graphicsScene for the laser scanner
3520  scene = new LaserScene();
3521 
3522  // set some colors
3523  scene->setBackgroundBrush(colorGraphicsSceneBackground);
3524 
3525  // turn off moving of scene, when objects extend the scene -> DISABLED to enable dragging the robot in the laserView!!
3526  // (set scene rect to size of GUI element) -> DISABLED to enable dragging the robot in the laserView!!
3527  //scene->setSceneRect(0, 0, ui.graphicsViewLaser->width(), ui.graphicsViewLaser->height()); -> DISABLED to enable dragging the robot in the laserView!!
3528 
3529  // set scene to the GUI
3530  if (useLargeGUI)
3531  {
3532  ui.graphicsViewLaser->setScene(scene);
3533  }
3534  else
3535  {
3536  uiSmall.graphicsViewLaser->setScene(scene);
3537  }
3538 
3539  // enable OpenGL rendering with antialiasing (and direct hardware rendering (if supportet by the hardware))
3540  if (useLargeGUI)
3541  {
3542  ui.graphicsViewLaser->setViewport(new QGLWidget(QGLFormat(QGL::DoubleBuffer | QGL::DirectRendering)));
3543  }
3544  else
3545  {
3546  uiSmall.graphicsViewLaser->setViewport(new QGLWidget(QGLFormat(QGL::DoubleBuffer | QGL::DirectRendering)));
3547  }
3548 
3549  //=======================================================
3550  // add robot picture1
3551  //=======================================================
3552  // add items to the scene
3553  pixmapBot1 = new QGraphicsPixmapItem(QPixmap(":/images/images/bot_from_above.png"));
3554 
3555  // init the scale for the laser line / distances drawing stuff
3556  if (useLargeGUI)
3557  {
3558  lastZoom = ui.sliderZoom->value();
3559  }
3560  else
3561  {
3562  lastZoom = uiSmall.sliderZoom->value();
3563  }
3564 
3565  //--------------------------------------------------------------
3566  // set the start scale
3567  //--------------------------------------------------------------
3568  startScale = 10;
3569 
3570  // change scale of the robot pic to 1/10 to fit in the window and to fit on the size of the laser lines
3571  pixmapBot1->scale( (1.0 / startScale), (1.0 / startScale));
3572 
3573  // horizontal center
3574  pixmapBot1->setPos(laserXPos, laserYPos);
3575 
3576  // add the pixmap
3577  scene->addItem(pixmapBot1);
3578 
3579  // put one layer up (layer 2).
3580  pixmapBot1->setZValue(2);
3581 
3582 
3583  //=====================================================
3584  // create the laser line lists
3585  //=====================================================
3586  laserLineListFront = new QList <QGraphicsLineItem*>();
3587  laserLineListRear = new QList <QGraphicsLineItem*>();
3588 
3589 
3590  //-------------------------------------
3591  // create the FRONT laser line list
3592  //-------------------------------------
3593  // create all laser lines(e.g.180 or 270, one for each degree or half-degree)
3594  // the rotation will be done in the initLaserView() !
3595  for (int i=0; i<(laserscannerAngleFront/laserscannerResolutionFront); i++)
3596  {
3597  QGraphicsLineItem *line = new QGraphicsLineItem();
3598 
3599  // the length (and position) of the laser line in pixel
3600  line->setLine(0,0,0,0);
3601 
3602  // set the laser line color
3603  //line->setPen(QPen(colorLaserFreeWay, 3));
3604  line->setPen(QPen(colorLaserFreeWay));
3605 
3606  // put one layer up (layer 3).
3607  line->setZValue(3);
3608 
3609  // add line to QList
3610  laserLineListFront->append(line);
3611 
3612  // add line to scene
3613  scene->addItem(line);
3614  }
3615 
3616  //-------------------------------------
3617  // create the REAR laser line list
3618  //-------------------------------------
3619  // create all laser lines(e.g.180 or 270, one for each degree)
3620  // the rotation will be done in the initLaserView() !
3621  for (int i=0; i<(laserscannerAngleRear/laserscannerResolutionRear); i++)
3622  {
3623  QGraphicsLineItem *line = new QGraphicsLineItem();
3624 
3625  // set the laser line color
3626  // line->setPen(QPen(colorLaserFreeWay, 3));
3627  line->setPen(QPen(colorLaserFreeWay));
3628 
3629  // the length (and position) of the laser line in pixel
3630  line->setLine(0,0,0,0);
3631 
3632  // put one layer up (layer 3).
3633  line->setZValue(3);
3634 
3635  // add line to QList
3636  laserLineListRear->append(line);
3637 
3638  // add line to scene
3639  scene->addItem(line);
3640  }
3641 
3642  //=======================================================
3643  // add robot picture2
3644  //=======================================================
3645  // add items to the scene
3646  pixmapBot2 = new QGraphicsPixmapItem(QPixmap(":/images/images/bot_from_above_TOP2.png"));
3647 
3648  // change scale of the robot pic to 1/10 to fit in the window and to fit on the size of the laser lines
3649  pixmapBot2->scale( (1.0 / startScale), (1.0 / startScale));
3650 
3651  // horizontal center
3652  pixmapBot2->setPos(laserXPos, laserYPos);
3653 
3654  // add the pixmap
3655  scene->addItem(pixmapBot2);
3656 
3657  // put one layer up (layer 4).
3658  pixmapBot2->setZValue(4);
3659 // pixmapBot1->setVisible(false); // just for testing
3660 // pixmapBot2->setVisible(false); // just for testing
3661 }
3662 #endif
3663 
3664 
3665 #ifdef ACTIVELASERVIEW
3666 void Gui::createLaserDistanceObjects()
3667 {
3668  // set colors
3669  colorHelpLine = Qt::gray;
3670  colorHelpLineText = Qt::gray;
3671 
3672 
3673  //--------------------------------------------------------------
3674  // create the FRONT laser line distances with text
3675  //--------------------------------------------------------------
3676  laserDistanceLineListFront = new QList <QGraphicsEllipseItem*>();
3677  laserDistanceTextFront = new QList <QGraphicsSimpleTextItem*>();
3678 
3679  // create and add twelve semi circles and text
3680  for (int i=0; i<LASERDISTANCECIRCLES; i++)
3681  {
3682  // create semi circles
3683  // position doesn't matter, because of moving circles in setLaserDistancePosition()! So we just take 0,0 here.
3684  QGraphicsEllipseItem *semiCircle = new QGraphicsEllipseItem(0, 0, LASERDISTANCEFIRSTCIRCLE + (i*LASERDISTANCEDISTANCE), LASERDISTANCEFIRSTCIRCLE + (i*LASERDISTANCEDISTANCE));
3685 
3686  // create an (empty) text
3687  QGraphicsSimpleTextItem *text = new QGraphicsSimpleTextItem();
3688 
3689  // set the start angle of the circle
3690  semiCircle->setStartAngle(180*16);
3691  // set the span angle of the circle
3692  semiCircle->setSpanAngle(180*16);
3693 
3694  // set semiCircle color
3695  semiCircle->setPen(QPen(colorHelpLine));
3696 
3697  // set text color
3698  text->setBrush(QBrush(colorHelpLine));
3699 
3700  // setting to the lowest layer level
3701  semiCircle->setZValue(1);
3702  text->setZValue(1);
3703 
3704  // add semiCircle to QList
3705  laserDistanceLineListFront->append(semiCircle);
3706  laserDistanceTextFront->append(text);
3707 
3708  // add semiCircle to scene
3709  scene->addItem(semiCircle);
3710 
3711  // add text to scene
3712  scene->addItem(text);
3713  }
3714 
3715 
3716  //--------------------------------------------------------------
3717  // create the REAR laser line distances with text
3718  //--------------------------------------------------------------
3719  laserDistanceLineListRear = new QList <QGraphicsEllipseItem*>();
3720  laserDistanceTextRear = new QList <QGraphicsSimpleTextItem*>();
3721 
3722  // create and add twelve semi circles and text
3723  for (int i=0; i<LASERDISTANCECIRCLES; i++)
3724  {
3725  // create semi circles
3726  // position doesn't matter, because of moving circles in setLaserDistancePosition()! So we just take 0,0 here.
3727  QGraphicsEllipseItem *semiCircle = new QGraphicsEllipseItem(0, 0, LASERDISTANCEFIRSTCIRCLE + (i*LASERDISTANCEDISTANCE), LASERDISTANCEFIRSTCIRCLE + (i*LASERDISTANCEDISTANCE));
3728 
3729  // create an (empty) text
3730  QGraphicsSimpleTextItem *text = new QGraphicsSimpleTextItem();
3731 
3732  // set the start angle of the circle
3733  semiCircle->setStartAngle(0);
3734  // set the span angle of the circle
3735  semiCircle->setSpanAngle(180*16);
3736 
3737  // set semiCircle color
3738  semiCircle->setPen(QPen(colorHelpLine));
3739 
3740  // set text color
3741  text->setBrush(QBrush(colorHelpLine));
3742 
3743  // setting to the lowest layer level!
3744  semiCircle->setZValue(1);
3745  text->setZValue(1);
3746 
3747  // add semiCircle to QList
3748  laserDistanceLineListRear->append(semiCircle);
3749  laserDistanceTextRear->append(text);
3750 
3751  // add semiCircle to scene
3752  scene->addItem(semiCircle);
3753 
3754  // add text to scene
3755  scene->addItem(text);
3756  }
3757 }
3758 #endif
3759 
3760 
3761 #ifdef ACTIVELASERVIEW
3762 void Gui::createLaserWidthObjects()
3763 {
3764  widthCirclesWidth = 10;
3765 
3766  // create the objects
3767  widthLeftCircleFront = new QGraphicsEllipseItem();
3768  widthRightCircleFront = new QGraphicsEllipseItem();
3769  widthLineFront = new QGraphicsLineItem();
3770  widthTextFront = new QGraphicsSimpleTextItem();
3771 
3772  widthLeftCircleRear = new QGraphicsEllipseItem();
3773  widthRightCircleRear = new QGraphicsEllipseItem();
3774  widthLineRear = new QGraphicsLineItem();
3775  widthTextRear = new QGraphicsSimpleTextItem();
3776 
3777  // set the start angle of the front laser circle
3778  widthLeftCircleFront->setStartAngle(0*16);
3779  widthRightCircleFront->setStartAngle(0*16);
3780  // set the span angle of the circle
3781  widthLeftCircleFront->setSpanAngle(360*16);
3782  widthRightCircleFront->setSpanAngle(360*16);
3783 
3784  // set the start angle of the rear laser circle
3785  widthLeftCircleRear->setStartAngle(0*16);
3786  widthRightCircleRear->setStartAngle(0*16);
3787  // set the span angle of the circle
3788  widthLeftCircleRear->setSpanAngle(360*16);
3789  widthRightCircleRear->setSpanAngle(360*16);
3790 
3791  // set the color
3792  widthLeftCircleFront->setPen(QPen(Qt::blue));
3793  widthRightCircleFront->setPen(QPen(Qt::blue));
3794  widthLineFront->setPen(QPen(Qt::blue));
3795  widthTextFront->setPen(QPen(Qt::blue));
3796 
3797  widthLeftCircleRear->setPen(QPen(Qt::blue));
3798  widthRightCircleRear->setPen(QPen(Qt::blue));
3799  widthLineRear->setPen(QPen(Qt::blue));
3800  widthTextRear->setPen(QPen(Qt::blue));
3801 
3802  // setting to the lowest layer level
3803  widthLeftCircleFront->setZValue(1);
3804  widthRightCircleFront->setZValue(1);
3805  widthLineFront->setZValue(1);
3806  widthTextFront->setZValue(1);
3807 
3808  widthLeftCircleRear->setZValue(1);
3809  widthRightCircleRear->setZValue(1);
3810  widthLineRear->setZValue(1);
3811  widthTextRear->setZValue(1);
3812 
3813  // draw a circle to see the coordinates for the 'drive-tru width'
3814  // change the width and height
3815  widthLeftCircleFront->setRect(0, 0, widthCirclesWidth, widthCirclesWidth);
3816  widthRightCircleFront->setRect(0, 0, widthCirclesWidth, widthCirclesWidth);
3817 
3818  widthLeftCircleRear->setRect(0, 0, widthCirclesWidth, widthCirclesWidth);
3819  widthRightCircleRear->setRect(0, 0, widthCirclesWidth, widthCirclesWidth);
3820 
3821  // make them unvisible untill we have a change in thre laser line length (other method of this class)
3822  widthLeftCircleFront->setVisible(false);
3823  widthRightCircleFront->setVisible(false);
3824  widthLineFront->setVisible(false);
3825 
3826  widthLeftCircleRear->setVisible(false);
3827  widthRightCircleRear->setVisible(false);
3828  widthLineRear->setVisible(false);
3829 
3830  // add the item to the scene
3831  scene->addItem(widthLeftCircleFront);
3832  scene->addItem(widthRightCircleFront);
3833  scene->addItem(widthLineFront);
3834  scene->addItem(widthTextFront);
3835 
3836  scene->addItem(widthLeftCircleRear);
3837  scene->addItem(widthRightCircleRear);
3838  scene->addItem(widthLineRear);
3839  scene->addItem(widthTextRear);
3840 }
3841 #endif
3842 
3843 
3844 #ifdef ACTIVELASERVIEW
3845 void Gui::initLaserStuff()
3846 {
3847  // called after all the laser settings have been read in the direcs mail class!
3848  createLaserScannerObjects();
3849  createLaserDistanceObjects();
3850  createLaserWidthObjects();
3851 
3852  //----------------------------------------------------------------------------------
3853  // get the mouse position, when the robot position is to be changed
3854  //----------------------------------------------------------------------------------
3855  connect(scene, SIGNAL( robotPositionChanged(QGraphicsSceneMouseEvent *) ), this, SLOT( setRobotPosition(QGraphicsSceneMouseEvent *) ));
3856  connect(scene, SIGNAL( wheelZoom(QGraphicsSceneWheelEvent *) ), this, SLOT( zoomLaserView(QGraphicsSceneWheelEvent *) ));
3857 }
3858 #endif
3859 
3860 
3861 #ifndef BUILDFORROBOT
3863 {
3864  // create to qwt plot objects and place them in the GUI
3865  if (useLargeGUI)
3866  {
3867  qwtPlotVoltage1.setParent(ui.widgetVoltage1);
3868  qwtPlotVoltage2.setParent(ui.widgetVoltage2);
3869  }
3870  else
3871  {
3872  qwtPlotVoltage1.setParent(uiSmall.widgetVoltage1);
3873  qwtPlotVoltage2.setParent(uiSmall.widgetVoltage2);
3874  }
3875 
3876  // qwtPlotCurrent1.setParent(ui.widgetCurrent1and2);
3877  // qwtPlotCurrent2.setParent(ui.widgetCurrent3and4); or
3878  // qwtPlotCurrent1.setParent(uiSmall.widgetCurrent1and2);
3879  // qwtPlotCurrent2.setParent(uiSmall.widgetCurrent3and4);
3880 
3881  if (useLargeGUI)
3882  {
3883  qwtPlotHeartbeat.setParent(ui.widgetHeartbeat);
3884  // ui.widgetHeartbeat->resize(205, 100); // 305 x 161
3885  // qwtPlotHeartbeat.resize(205, 100);
3886  }
3887  else
3888  {
3889  qwtPlotHeartbeat.setParent(uiSmall.widgetHeartbeat);
3890  // uiSmall.widgetHeartbeat->resize(205, 100); // 305 x 161
3891  // qwtPlotHeartbeat.resize(205, 100);
3892  }
3893 
3894  // get the current application font
3895  QFont applicationFont = QApplication::font();
3896 
3897 
3898  //--------------------------------------
3899  // plot curve "MOTOR CURRENT" 1
3900  //--------------------------------------
3901  // set the font for the plot widget
3902  qwtPlotCurrent1.setAxisFont(QwtPlot::xBottom, applicationFont);
3903  qwtPlotCurrent1.setAxisFont(QwtPlot::yLeft, applicationFont);
3904  qwtPlotCurrent1.setAxisFont(QwtPlot::axisCnt, applicationFont);
3905 
3906  // add a grid
3907  gridCurrent1.attach(&qwtPlotCurrent1);
3908  gridCurrent1.setPen( QPen(QColor(gridColor), 0.0, Qt::DotLine) );
3909 
3910  // set title
3911  qwtPlotCurrent1.setTitle("Motor 1 + 2");
3912 
3913  // Set axis scale (instead of using autoscale, which is default)
3914  // min (0.0), time (60.0 sec)
3915  qwtPlotCurrent1.setAxisScale(QwtPlot::xBottom, 0.0, 60.0);
3916 
3917  curveCurrent1.setRenderHint(QwtPlotItem::RenderAntialiased);
3918  // set curve color
3919  curveCurrent1.setPen(QPen(labelFillColorBlue));
3920  // fill the area below the curve
3921  // curveCurrent1.setBrush(labelFillColorBlue);
3922 
3923 
3924  //--------------------------------------
3925  // plot curve "MOTOR CURRENT" 2
3926  //--------------------------------------
3927  // get the current application font again
3928  applicationFont = QApplication::font();
3929 
3930  // set the font for the plot widget
3931  qwtPlotCurrent2.setAxisFont(QwtPlot::xBottom, applicationFont);
3932  qwtPlotCurrent2.setAxisFont(QwtPlot::yLeft, applicationFont);
3933  qwtPlotCurrent2.setAxisFont(QwtPlot::axisCnt, applicationFont);
3934 
3935  // add a grid
3936  gridCurrent2.attach(&qwtPlotCurrent2);
3937  gridCurrent2.setPen( QPen(QColor(gridColor), 0.0, Qt::DotLine) );
3938 
3939  // set title
3940  qwtPlotCurrent2.setTitle("Motor 3 + 4");
3941 
3942  // Set axis scale (instead of using autoscale, which is default)
3943  // time (60 sec)
3944  qwtPlotCurrent2.setAxisScale(QwtPlot::xBottom, 0.0, 60.0);
3945 
3946  curveCurrent2.setRenderHint(QwtPlotItem::RenderAntialiased);
3947  // set curve color
3948  curveCurrent2.setPen(QPen(labelFillColorRed));
3949  // fill the area below the curve
3950  // curveCurrent2.setBrush(labelFillColorRed);
3951 
3952 
3953  //--------------------------------------
3954  // plot curve "MOTOR CURRENT" 3
3955  //--------------------------------------
3956  curveCurrent3.setRenderHint(QwtPlotItem::RenderAntialiased);
3957  // set curve color
3958  curveCurrent3.setPen(QPen(labelFillColorBlue));
3959  // fill the area below the curve
3960  // curveCurrent3.setBrush(labelFillColorBlue);
3961 
3962  //--------------------------------------
3963  // plot curve "MOTOR CURRENT" 4
3964  //--------------------------------------
3965  curveCurrent4.setRenderHint(QwtPlotItem::RenderAntialiased);
3966  // set curve color
3967  curveCurrent4.setPen(QPen(labelFillColorRed));
3968  // fill the area below the curve
3969  // curveCurrent4.setBrush(labelFillColorRed);
3970 
3971 
3972  //--------------------------------------
3973  // plot curve "VOLTAGE 1"
3974  //--------------------------------------
3975  // get the current application font
3976  applicationFont = QApplication::font();
3977  // set this font for the plot widget
3978  qwtPlotVoltage1.setAxisFont(QwtPlot::xBottom, applicationFont);
3979  qwtPlotVoltage1.setAxisFont(QwtPlot::yLeft, applicationFont);
3980  qwtPlotVoltage1.setAxisFont(QwtPlot::axisCnt, applicationFont);
3981 
3982  // add a grid
3983  gridVoltage1.attach(&qwtPlotVoltage1);
3984  gridVoltage1.setPen( QPen(QColor(gridColor), 0.0, Qt::DotLine) );
3985 
3986  // set background color
3987  //qwtPlotVoltage1.setCanvasBackground(QColor(Qt::black));
3988 
3989  // on the smal GUI there is no space for a title
3990  if (useLargeGUI)
3991  {
3992  // set title
3993  qwtPlotVoltage1.setTitle("12 V Battery [16.8 V]");
3994  }
3995 
3996  // Set axis scale (instead of using autoscale, which is default)
3997  // maximum voltage value at which the axis should and, and the steps between each divider
3998  qwtPlotVoltage1.setAxisScale(QwtPlot::yLeft, 0.0, MAXIMUMPLOTVOLTAGE1);
3999 
4000  // Set axis scale (instead of using autoscale, which is default)
4001  // time (60 sec)
4002  qwtPlotVoltage1.setAxisScale(QwtPlot::xBottom, 0.0, 60.0);
4003 
4004  curveVoltage1.setRenderHint(QwtPlotItem::RenderAntialiased);
4005  // set curve color
4006  curveVoltage1.setPen(QPen(labelFillColorBlue));
4007  // fill the area below the curve
4008  // curveVoltage1.setBrush(labelFillColorBlue);
4009 
4010 
4011  //--------------------------------------
4012  // plot curve "VOLTAGE 2"
4013  //--------------------------------------
4014  // get the current application font
4015  applicationFont = QApplication::font();
4016  // set this font for the plot widget
4017  qwtPlotVoltage2.setAxisFont(QwtPlot::xBottom, applicationFont);
4018  qwtPlotVoltage2.setAxisFont(QwtPlot::yLeft, applicationFont);
4019  qwtPlotVoltage2.setAxisFont(QwtPlot::axisCnt, applicationFont);
4020 
4021  // add a grid
4022  gridVoltage2.attach(&qwtPlotVoltage2);
4023  gridVoltage2.setPen( QPen(QColor(gridColor), 0.0, Qt::DotLine) );
4024 
4025  // set background color
4026  //qwtPlotVoltage2.setCanvasBackground(QColor(Qt::black));
4027 
4028  // on the smal GUI there is no space for a title
4029  if (useLargeGUI)
4030  {
4031  // set title
4032  qwtPlotVoltage2.setTitle("24 V Battery [25.2 V]");
4033  }
4034 
4035  // Set axis scale (instead of using autoscale, which is default)
4036  // maximum voltage value at which the axis should and, and the steps between each divider
4037  qwtPlotVoltage2.setAxisScale(QwtPlot::yLeft, 0.0, MAXIMUMPLOTVOLTAGE2);
4038 
4039  // Set axis scale (instead of using autoscale, which is default)
4040  // time (60 sec)
4041  qwtPlotVoltage2.setAxisScale(QwtPlot::xBottom, 0.0, 60.0);
4042 
4043  curveVoltage2.setRenderHint(QwtPlotItem::RenderAntialiased);
4044  // set curve color
4045  curveVoltage2.setPen(QPen(labelFillColorBlue));
4046  // fill the area below the curve
4047  // curveVoltage2.setBrush(labelFillColorBlue);
4048 
4049 
4050  //--------------------------------------
4051  // plot curve "HEARTBEAT"
4052  //--------------------------------------
4053  // get the current application font
4054  applicationFont = QApplication::font();
4055  qwtPlotHeartbeat.setAxisFont(QwtPlot::xBottom, applicationFont);
4056  qwtPlotHeartbeat.setAxisFont(QwtPlot::yLeft, applicationFont);
4057  qwtPlotHeartbeat.setAxisFont(QwtPlot::axisCnt, applicationFont);
4058 
4059  // add a grid
4061  gridHeartbeat.setPen( QPen(QColor(gridColor), 0.0, Qt::DotLine) );
4062 
4063  // set background color
4064  // qwtPlotHeartbeat.setCanvasBackground(QColor(Qt::black));
4065 
4066  // set title
4067  qwtPlotHeartbeat.setTitle("Heartbeat");
4068 
4069  // Set axis scale (instead of using autoscale, which is default)
4070  // maximum voltage value at which the axis should and, and the steps between each divider
4071  qwtPlotHeartbeat.setAxisScale(QwtPlot::yLeft, 0.0, MAXIMUMPLOTHEARTBEAT);
4072 
4073  // Set axis scale (instead of using autoscale, which is default)
4074  // time (60 sec)
4075  qwtPlotHeartbeat.setAxisScale(QwtPlot::xBottom, 0.0, 60.0);
4076 
4077  curveHeartbeat.setRenderHint(QwtPlotItem::RenderAntialiased);
4078  // set curve color
4079  curveHeartbeat.setPen(QPen(labelFillColorRed));
4080  // fill the area below the curve
4081  // curveHeartbeat.setBrush(labelFillColorBlue);
4082 
4083 
4084  //------------------------------------------------------------
4085  // resize qwt plot items to the correct underlying frame size
4086  //------------------------------------------------------------
4087  if (useLargeGUI)
4088  {
4089  qwtPlotVoltage1.setGeometry( ui.widgetVoltage1->rect() );
4090  qwtPlotVoltage2.setGeometry( ui.widgetVoltage2->rect() );
4091 
4092  // qwtPlotCurrent1.setGeometry( ui.widgetCurrent1and2->rect() );
4093  // qwtPlotCurrent2.setGeometry( ui.widgetCurrent1and2->rect() );
4094 
4095  qwtPlotHeartbeat.setGeometry( ui.widgetHeartbeat->rect() );
4096  }
4097  else
4098  {
4099  qwtPlotVoltage1.setGeometry( uiSmall.widgetVoltage1->rect() );
4100  qwtPlotVoltage2.setGeometry( uiSmall.widgetVoltage2->rect() );
4101 
4102  // qwtPlotCurrent1.setGeometry( uiSmall.widgetCurrent1and2->rect() );
4103  // qwtPlotCurrent2.setGeometry( uiSmall.widgetCurrent1and2->rect() );
4104 
4105  qwtPlotHeartbeat.setGeometry( uiSmall.widgetHeartbeat->rect() );
4106  }
4107 }
4108 #endif
4109 
4110 
4111 /*
4112 void Gui::initCompass()
4113 {
4114  int c;
4115 
4116  QPalette colorGroup;
4117  for ( c = 0; c < QPalette::NColorRoles; c++ )
4118  {
4119  colorGroup.setColor((QPalette::ColorRole)c, QColor());
4120  }
4121 
4122 #if QT_VERSION < 0x040000
4123  colorGroup.setColor(QPalette::Base, backgroundColor().light(120));
4124 #else
4125  colorGroup.setColor(QPalette::Base, palette().color(backgroundRole()).light(120));
4126 #endif
4127  colorGroup.setColor(QPalette::Foreground, colorGroup.color(QPalette::Base));
4128 
4129 
4130  // A 2D compass showing another needle. No. 4
4131  ui.qwtCompass->setScaleOptions(QwtDial::ScaleTicks | QwtDial::ScaleLabel);
4132  ui.qwtCompass->setScaleTicks(0, 0, 3);
4133 
4134  ui.qwtCompass->setNeedle(new QwtCompassMagnetNeedle( QwtCompassMagnetNeedle::TriangleStyle, Qt::white, Qt::red));
4135  ui.qwtCompass->setValue(0.0);
4136 
4137 
4138  // get palette
4139  QPalette newPalette = ui.qwtCompass->palette();
4140 
4141  for ( c = 0; c < QPalette::NColorRoles; c++ )
4142  {
4143  if ( colorGroup.color((QPalette::ColorRole)c).isValid() )
4144  {
4145  for ( int cg = 0; cg < QPalette::NColorGroups; cg++ )
4146  {
4147  newPalette.setColor( (QPalette::ColorGroup)cg, (QPalette::ColorRole)c, colorGroup.color((QPalette::ColorRole)c));
4148  }
4149  }
4150  }
4151 
4152  for ( int i = 0; i < QPalette::NColorGroups; i++ )
4153  {
4154  QPalette::ColorGroup cg = (QPalette::ColorGroup)i;
4155 
4156  const QColor light = newPalette.color(cg, QPalette::Base).light(170);
4157  const QColor dark = newPalette.color(cg, QPalette::Base).dark(170);
4158  const QColor mid = ui.qwtCompass->frameShadow() == QwtDial::Raised ? newPalette.color(cg, QPalette::Base).dark(110) : newPalette.color(cg, QPalette::Base).light(110);
4159  newPalette.setColor(cg, QPalette::Dark, dark);
4160  newPalette.setColor(cg, QPalette::Mid, mid);
4161  newPalette.setColor(cg, QPalette::Light, light);
4162  }
4163 
4164  // set new palette
4165  ui.qwtCompass->setPalette(newPalette);
4166 }
4167 */
4168 
4169 
4170 void Gui::showCompassData(float x, float y, float z, float heading)
4171 {
4172 /*
4173  // also formats the string to 1 digits precision!
4174  if (useLargeGUI)
4175  {
4176  ui.lblCompassX->setText( QString("%1").setNum(x, 'f', 1).append(" deg") );
4177  ui.lblCompassY->setText( QString("%1").setNum(y, 'f', 1).append(" deg") );
4178  ui.lblCompassZ->setText( QString("%1").setNum(z, 'f', 1).append(" deg") );
4179  ui.lblCompassHeading->setText( QString("%1").setNum(heading, 'f', 1).append(" deg") );
4180 
4181  // ui.qwtCompass->setValue(x);
4182 
4183  // set the 3D OpenGL compass!
4184  ui.frameCompass->setAllRotations(x, y, z); /// \todo and what to do with the 'heading'?
4185  }
4186  else
4187  {
4188  uiSmall.lblCompassX->setText( QString("%1").setNum(x, 'f', 1).append(" deg") );
4189  uiSmall.lblCompassY->setText( QString("%1").setNum(y, 'f', 1).append(" deg") );
4190  uiSmall.lblCompassZ->setText( QString("%1").setNum(z, 'f', 1).append(" deg") );
4191  uiSmall.lblCompassHeading->setText( QString("%1").setNum(heading, 'f', 1).append(" deg") );
4192 
4193  // uiSmall.qwtCompass->setValue(x);
4194 
4195  // set the 3D OpenGL compass!
4196  uiSmall.frameCompass->setAllRotations(x, y, z); /// \todo and what to do with the 'heading'?
4197  }
4198 */
4199 }
4200 
4201 
4202 void Gui::setLEDHeartbeat(unsigned char state)
4203 {
4204  switch (state)
4205  {
4206  case RED:
4207  if (useLargeGUI)
4208  {
4209  ui.lblLEDHeartbeat->setPixmap(QPixmap(":/images/images/led_red.gif"));
4210  }
4211  else
4212  {
4213  uiSmall.lblLEDHeartbeat->setPixmap(QPixmap(":/images/images/led_red.gif"));
4214  }
4215  break;
4216  case GREEN:
4217  if (useLargeGUI)
4218  {
4219  ui.lblLEDHeartbeat->setPixmap(QPixmap(":/images/images/led_green.gif"));
4220  }
4221  else
4222  {
4223  uiSmall.lblLEDHeartbeat->setPixmap(QPixmap(":/images/images/led_green.gif"));
4224  }
4225  break;
4226  case LEDOFF:
4227  if (useLargeGUI)
4228  {
4229  ui.lblLEDHeartbeat->setPixmap(QPixmap(":/images/images/led_gray.gif"));
4230  }
4231  else
4232  {
4233  uiSmall.lblLEDHeartbeat->setPixmap(QPixmap(":/images/images/led_gray.gif"));
4234  }
4235  break;
4236  }
4237 }
4238 
4239 
4240 void Gui::setLEDCompass(unsigned char state)
4241 {
4242  switch (state)
4243  {
4244  case RED:
4245  if (useLargeGUI)
4246  {
4247  ui.lblLEDCompass->setPixmap(QPixmap(":/images/images/led_red.gif"));
4248  }
4249  else
4250  {
4251  uiSmall.lblLEDCompass->setPixmap(QPixmap(":/images/images/led_red.gif"));
4252  }
4253  break;
4254  case GREEN:
4255  if (useLargeGUI)
4256  {
4257  ui.lblLEDCompass->setPixmap(QPixmap(":/images/images/led_green.gif"));
4258  }
4259  else
4260  {
4261  uiSmall.lblLEDCompass->setPixmap(QPixmap(":/images/images/led_green.gif"));
4262  }
4263  break;
4264  case LEDOFF:
4265  if (useLargeGUI)
4266  {
4267  ui.lblLEDCompass->setPixmap(QPixmap(":/images/images/led_gray.gif"));
4268  }
4269  else
4270  {
4271  uiSmall.lblLEDCompass->setPixmap(QPixmap(":/images/images/led_gray.gif"));
4272  }
4273  break;
4274  }
4275 }
4276 
4277 
4278 void Gui::setLEDJoystick(unsigned char state)
4279 {
4280  switch (state)
4281  {
4282  case RED:
4283  if (useLargeGUI)
4284  {
4285  ui.lblLEDJoystick->setPixmap(QPixmap(":/images/images/led_red.gif"));
4286  }
4287  else
4288  {
4289  uiSmall.lblLEDJoystick->setPixmap(QPixmap(":/images/images/led_red.gif"));
4290  }
4291  break;
4292  case GREEN:
4293  if (useLargeGUI)
4294  {
4295  ui.lblLEDJoystick->setPixmap(QPixmap(":/images/images/led_green.gif"));
4296  }
4297  else
4298  {
4299  uiSmall.lblLEDJoystick->setPixmap(QPixmap(":/images/images/led_green.gif"));
4300  }
4301  break;
4302  case LEDOFF:
4303  if (useLargeGUI)
4304  {
4305  ui.lblLEDJoystick->setPixmap(QPixmap(":/images/images/led_gray.gif"));
4306  }
4307  else
4308  {
4309  uiSmall.lblLEDJoystick->setPixmap(QPixmap(":/images/images/led_gray.gif"));
4310  }
4311  break;
4312  }
4313 }
4314 
4315 
4316 void Gui::setLEDCamera(unsigned char state)
4317 {
4318  switch (state)
4319  {
4320  case RED:
4321  if (useLargeGUI)
4322  {
4323  ui.lblLEDCamera->setPixmap(QPixmap(":/images/images/led_red.gif"));
4324  }
4325  else
4326  {
4327  uiSmall.lblLEDCamera->setPixmap(QPixmap(":/images/images/led_red.gif"));
4328  }
4329  break;
4330  case GREEN:
4331  if (useLargeGUI)
4332  {
4333  ui.lblLEDCamera->setPixmap(QPixmap(":/images/images/led_green.gif"));
4334  }
4335  else
4336  {
4337  uiSmall.lblLEDCamera->setPixmap(QPixmap(":/images/images/led_green.gif"));
4338  }
4339  break;
4340  case LEDOFF:
4341  if (useLargeGUI)
4342  {
4343  ui.lblLEDCamera->setPixmap(QPixmap(":/images/images/led_gray.gif"));
4344  }
4345  else
4346  {
4347  uiSmall.lblLEDCamera->setPixmap(QPixmap(":/images/images/led_gray.gif"));
4348  }
4349  break;
4350  }
4351 }
4352 
4353 
4354 void Gui::setLEDNetwork(unsigned char state)
4355 {
4356  switch (state)
4357  {
4358  case RED:
4359  if (useLargeGUI)
4360  {
4361  ui.lblLEDNetwork->setPixmap(QPixmap(":/images/images/led_red.gif"));
4362  }
4363  else
4364  {
4365  uiSmall.lblLEDNetwork->setPixmap(QPixmap(":/images/images/led_red.gif"));
4366  }
4367  break;
4368  case GREEN:
4369  if (useLargeGUI)
4370  {
4371  ui.lblLEDNetwork->setPixmap(QPixmap(":/images/images/led_green.gif"));
4372  }
4373  else
4374  {
4375  uiSmall.lblLEDNetwork->setPixmap(QPixmap(":/images/images/led_green.gif"));
4376  }
4377  break;
4378  case LEDOFF:
4379  if (useLargeGUI)
4380  {
4381  ui.lblLEDNetwork->setPixmap(QPixmap(":/images/images/led_gray.gif"));
4382  }
4383  else
4384  {
4385  uiSmall.lblLEDNetwork->setPixmap(QPixmap(":/images/images/led_gray.gif"));
4386  }
4387  break;
4388  }
4389 }
4390 
4391 
4392 void Gui::setLEDMasterSlave(unsigned char state)
4393 {
4394  switch (state)
4395  {
4396  case RED:
4397  if (useLargeGUI)
4398  {
4399  ui.lblLEDMasterSlave->setPixmap(QPixmap(":/images/images/led_red.gif"));
4400  }
4401  else
4402  {
4403  uiSmall.lblLEDMasterSlave->setPixmap(QPixmap(":/images/images/led_red.gif"));
4404  }
4405  break;
4406  case GREEN:
4407  if (useLargeGUI)
4408  {
4409  ui.lblLEDMasterSlave->setPixmap(QPixmap(":/images/images/led_green.gif"));
4410  }
4411  else
4412  {
4413  uiSmall.lblLEDMasterSlave->setPixmap(QPixmap(":/images/images/led_green.gif"));
4414  }
4415  break;
4416  case LEDOFF:
4417  if (useLargeGUI)
4418  {
4419  ui.lblLEDMasterSlave->setPixmap(QPixmap(":/images/images/led_gray.gif"));
4420  }
4421  else
4422  {
4423  uiSmall.lblLEDMasterSlave->setPixmap(QPixmap(":/images/images/led_gray.gif"));
4424  }
4425  break;
4426  }
4427 }
4428 
4429 
4430 void Gui::setLEDLaser(unsigned char state)
4431 {
4432  switch (state)
4433  {
4434  case RED:
4435  if (useLargeGUI)
4436  {
4437  ui.lblLEDLaser->setPixmap(QPixmap(":/images/images/led_red.gif"));
4438  }
4439  else
4440  {
4441  uiSmall.lblLEDLaser->setPixmap(QPixmap(":/images/images/led_red.gif"));
4442  }
4443  break;
4444  case GREEN:
4445  if (useLargeGUI)
4446  {
4447  ui.lblLEDLaser->setPixmap(QPixmap(":/images/images/led_green.gif"));
4448  }
4449  else
4450  {
4451  uiSmall.lblLEDLaser->setPixmap(QPixmap(":/images/images/led_green.gif"));
4452  }
4453  break;
4454  case LEDOFF:
4455  if (useLargeGUI)
4456  {
4457  ui.lblLEDLaser->setPixmap(QPixmap(":/images/images/led_gray.gif"));
4458  }
4459  else
4460  {
4461  uiSmall.lblLEDLaser->setPixmap(QPixmap(":/images/images/led_gray.gif"));
4462  }
4463  break;
4464  }
4465 }
4466 
4467 
4468 void Gui::setLabelMasterSlave(QString text)
4469 {
4470  if (useLargeGUI)
4471  {
4472  ui.lblMasterSlave->setText(text);
4473  }
4474  else
4475  {
4476  uiSmall.lblMasterSlave->setText(text);
4477  }
4478 }
4479 
4480 
4481 void Gui::showKinectAngle(double angle)
4482 {
4483  // we do a type cast here since the original Kinect method uses 'double'.
4484  if (useLargeGUI)
4485  {
4486  ui.spinBoxKinectAngle->setValue((int) angle);
4487  }
4488  else
4489  {
4490  uiSmall.spinBoxKinectAngle->setValue((int) angle);
4491  }
4492 }
4493 
4494 
4495 void Gui::showThreshold(int threshold)
4496 {
4497  if (useLargeGUI)
4498  {
4499  ui.sliderThreshold->setValue(threshold);
4500  }
4501  else
4502  {
4503  uiSmall.sliderThreshold->setValue(threshold);
4504  }
4505 }
4506 
4507 
4508 void Gui::setConsoleMode(bool state)
4509 {
4510  consoleMode = state;
4511 }
4512 
4513 
4514 QString Gui::removeHtml(QString text)
4515 {
4516  //------------------------------
4517  // remove HTML tags from string
4518  //------------------------------
4519  int start= -1;
4520  do
4521  {
4522  // search for the first HTML "<"
4523  start = text.indexOf("<");
4524  text.remove(start, text.indexOf(">") - start + 1);
4525  } while (text.contains(">"));
4526  // till the last HTML ">" is found
4527 
4528  return text;
4529 }
4530 
4531 
4532 void Gui::systemerrorcatcher(int errorlevel)
4533 {
4534  if (errorlevel == -1)
4535  {
4536  // turn GUI LED laser to red
4537  setLEDLaser(RED);
4538  }
4539 }
4540 
4541 
4543 {
4544 /*
4545  if (cameraOpened)
4546  {
4547  timer.restart();
4548 
4549  frame = cvQueryFrame( capture );
4550 
4551  if (frame.data)
4552  {
4553  // add brightness and contrast
4554 // this->processFrame(frame);
4555 
4556  if (useLargeGUI)
4557  {
4558  }
4559  else
4560  {
4561  }
4562  ui.frameOpenCV->sendImage( &frame );
4563 
4564  QTimer::singleShot(25, this, SLOT(processCam()));
4565  }
4566  }
4567  return;
4568 */
4569 }