From 2a6e82571ced24d6b571e7d30a848154d19786b8 Mon Sep 17 00:00:00 2001
From: beuchatp <beuchatp@control.ee.ethz.ch>
Date: Tue, 21 May 2019 23:14:18 +0200
Subject: [PATCH] Added remote controller to GUI menu, enable and yaml buttons,
 and a tab. Compiles but needs testing. The tab itself still needs to be added

---
 .../flyingAgentGUI/forms/controllertabs.ui    |   7 +-
 .../forms/enablecontrollerloadyamlbar.ui      | 182 +++++++++++-------
 .../GUI_Qt/flyingAgentGUI/forms/mainwindow.ui |  12 ++
 .../flyingAgentGUI/include/controllertabs.h   |   1 +
 .../include/enablecontrollerloadyamlbar.h     |   3 +
 .../flyingAgentGUI/include/mainwindow.h       |   1 +
 .../flyingAgentGUI/src/controllertabs.cpp     |   8 +-
 .../src/enablecontrollerloadyamlbar.cpp       |  33 ++++
 .../GUI_Qt/flyingAgentGUI/src/mainwindow.cpp  |   9 +
 9 files changed, 188 insertions(+), 68 deletions(-)

diff --git a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/forms/controllertabs.ui b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/forms/controllertabs.ui
index 471a55f3..f580f731 100644
--- a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/forms/controllertabs.ui
+++ b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/forms/controllertabs.ui
@@ -28,7 +28,7 @@
    <item row="0" column="0">
     <widget class="QTabWidget" name="controller_tabs_widget">
      <property name="currentIndex">
-      <number>4</number>
+      <number>5</number>
      </property>
      <property name="movable">
       <bool>true</bool>
@@ -73,6 +73,11 @@
        </item>
       </layout>
      </widget>
+     <widget class="QWidget" name="remote_tab">
+      <attribute name="title">
+       <string>Remote</string>
+      </attribute>
+     </widget>
      <widget class="QWidget" name="template_tab">
       <attribute name="title">
        <string>Template</string>
diff --git a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/forms/enablecontrollerloadyamlbar.ui b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/forms/enablecontrollerloadyamlbar.ui
index c358d8be..7bafd6f4 100644
--- a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/forms/enablecontrollerloadyamlbar.ui
+++ b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/forms/enablecontrollerloadyamlbar.ui
@@ -30,8 +30,8 @@
      <property name="spacing">
       <number>12</number>
      </property>
-     <item row="0" column="2">
-      <widget class="QPushButton" name="enable_student_button">
+     <item row="1" column="1">
+      <widget class="QPushButton" name="load_yaml_default_button">
        <property name="sizePolicy">
         <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
          <horstretch>0</horstretch>
@@ -50,19 +50,38 @@
          <height>50</height>
         </size>
        </property>
-       <property name="font">
-        <font>
-         <weight>50</weight>
-         <bold>false</bold>
-        </font>
+       <property name="text">
+        <string>Default</string>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="3">
+      <widget class="QPushButton" name="load_yaml_picker_button">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="minimumSize">
+        <size>
+         <width>60</width>
+         <height>50</height>
+        </size>
+       </property>
+       <property name="maximumSize">
+        <size>
+         <width>180</width>
+         <height>50</height>
+        </size>
        </property>
        <property name="text">
-        <string>Student</string>
+        <string>Picker</string>
        </property>
       </widget>
      </item>
-     <item row="1" column="0">
-      <widget class="QLabel" name="load_yaml_label">
+     <item row="0" column="0">
+      <widget class="QLabel" name="enable_controller_label">
        <property name="sizePolicy">
         <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
          <horstretch>0</horstretch>
@@ -88,59 +107,74 @@
         </font>
        </property>
        <property name="text">
-        <string>Load YAML</string>
+        <string>Enable</string>
        </property>
        <property name="alignment">
         <set>Qt::AlignCenter</set>
        </property>
       </widget>
      </item>
-     <item row="0" column="6">
-      <spacer name="horizontalSpacer">
-       <property name="orientation">
-        <enum>Qt::Horizontal</enum>
+     <item row="1" column="4">
+      <widget class="QPushButton" name="load_yaml_tuning_button">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
        </property>
-       <property name="sizeHint" stdset="0">
+       <property name="minimumSize">
         <size>
-         <width>40</width>
-         <height>20</height>
+         <width>60</width>
+         <height>50</height>
         </size>
        </property>
-      </spacer>
+       <property name="maximumSize">
+        <size>
+         <width>180</width>
+         <height>50</height>
+        </size>
+       </property>
+       <property name="text">
+        <string>Tuning</string>
+       </property>
+      </widget>
      </item>
-     <item row="0" column="5">
-      <widget class="QPushButton" name="enable_template_button">
+     <item row="1" column="0">
+      <widget class="QLabel" name="load_yaml_label">
        <property name="sizePolicy">
-        <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+        <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
          <horstretch>0</horstretch>
          <verstretch>0</verstretch>
         </sizepolicy>
        </property>
        <property name="minimumSize">
         <size>
-         <width>60</width>
+         <width>0</width>
          <height>50</height>
         </size>
        </property>
        <property name="maximumSize">
         <size>
-         <width>180</width>
+         <width>16777215</width>
          <height>50</height>
         </size>
        </property>
        <property name="font">
         <font>
-         <weight>50</weight>
-         <bold>false</bold>
+         <weight>75</weight>
+         <bold>true</bold>
         </font>
        </property>
        <property name="text">
-        <string>Template</string>
+        <string>Load YAML</string>
+       </property>
+       <property name="alignment">
+        <set>Qt::AlignCenter</set>
        </property>
       </widget>
      </item>
-     <item row="1" column="3">
-      <widget class="QPushButton" name="load_yaml_picker_button">
+     <item row="1" column="2">
+      <widget class="QPushButton" name="load_yaml_student_button">
        <property name="sizePolicy">
         <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
          <horstretch>0</horstretch>
@@ -160,12 +194,12 @@
         </size>
        </property>
        <property name="text">
-        <string>Picker</string>
+        <string>Student</string>
        </property>
       </widget>
      </item>
-     <item row="1" column="2">
-      <widget class="QPushButton" name="load_yaml_student_button">
+     <item row="1" column="6">
+      <widget class="QPushButton" name="load_yaml_template_button">
        <property name="sizePolicy">
         <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
          <horstretch>0</horstretch>
@@ -185,12 +219,12 @@
         </size>
        </property>
        <property name="text">
-        <string>Student</string>
+        <string>Template</string>
        </property>
       </widget>
      </item>
-     <item row="0" column="1">
-      <widget class="QPushButton" name="enable_default_button">
+     <item row="0" column="2">
+      <widget class="QPushButton" name="enable_student_button">
        <property name="sizePolicy">
         <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
          <horstretch>0</horstretch>
@@ -216,46 +250,37 @@
         </font>
        </property>
        <property name="text">
-        <string>Default</string>
+        <string>Student</string>
        </property>
       </widget>
      </item>
-     <item row="0" column="0">
-      <widget class="QLabel" name="enable_controller_label">
+     <item row="0" column="4">
+      <widget class="QPushButton" name="enable_tuning_button">
        <property name="sizePolicy">
-        <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+        <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
          <horstretch>0</horstretch>
          <verstretch>0</verstretch>
         </sizepolicy>
        </property>
        <property name="minimumSize">
         <size>
-         <width>0</width>
+         <width>60</width>
          <height>50</height>
         </size>
        </property>
        <property name="maximumSize">
         <size>
-         <width>16777215</width>
+         <width>180</width>
          <height>50</height>
         </size>
        </property>
-       <property name="font">
-        <font>
-         <weight>75</weight>
-         <bold>true</bold>
-        </font>
-       </property>
        <property name="text">
-        <string>Enable</string>
-       </property>
-       <property name="alignment">
-        <set>Qt::AlignCenter</set>
+        <string>Tuning</string>
        </property>
       </widget>
      </item>
-     <item row="1" column="5">
-      <widget class="QPushButton" name="load_yaml_template_button">
+     <item row="0" column="1">
+      <widget class="QPushButton" name="enable_default_button">
        <property name="sizePolicy">
         <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
          <horstretch>0</horstretch>
@@ -274,13 +299,19 @@
          <height>50</height>
         </size>
        </property>
+       <property name="font">
+        <font>
+         <weight>50</weight>
+         <bold>false</bold>
+        </font>
+       </property>
        <property name="text">
-        <string>Template</string>
+        <string>Default</string>
        </property>
       </widget>
      </item>
-     <item row="1" column="1">
-      <widget class="QPushButton" name="load_yaml_default_button">
+     <item row="0" column="3">
+      <widget class="QPushButton" name="enable_picker_button">
        <property name="sizePolicy">
         <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
          <horstretch>0</horstretch>
@@ -299,13 +330,19 @@
          <height>50</height>
         </size>
        </property>
+       <property name="font">
+        <font>
+         <weight>50</weight>
+         <bold>false</bold>
+        </font>
+       </property>
        <property name="text">
-        <string>Default</string>
+        <string>Picker</string>
        </property>
       </widget>
      </item>
-     <item row="0" column="3">
-      <widget class="QPushButton" name="enable_picker_button">
+     <item row="0" column="6">
+      <widget class="QPushButton" name="enable_template_button">
        <property name="sizePolicy">
         <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
          <horstretch>0</horstretch>
@@ -331,12 +368,25 @@
         </font>
        </property>
        <property name="text">
-        <string>Picker</string>
+        <string>Template</string>
        </property>
       </widget>
      </item>
-     <item row="0" column="4">
-      <widget class="QPushButton" name="enable_tuning_button">
+     <item row="0" column="7">
+      <spacer name="horizontalSpacer">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item row="0" column="5">
+      <widget class="QPushButton" name="enable_remote_button">
        <property name="sizePolicy">
         <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
          <horstretch>0</horstretch>
@@ -356,12 +406,12 @@
         </size>
        </property>
        <property name="text">
-        <string>Tuning</string>
+        <string>Remote</string>
        </property>
       </widget>
      </item>
-     <item row="1" column="4">
-      <widget class="QPushButton" name="load_yaml_tuning_button">
+     <item row="1" column="5">
+      <widget class="QPushButton" name="load_yaml_remote_button">
        <property name="sizePolicy">
         <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
          <horstretch>0</horstretch>
@@ -381,7 +431,7 @@
         </size>
        </property>
        <property name="text">
-        <string>Tuning</string>
+        <string>Remote</string>
        </property>
       </widget>
      </item>
diff --git a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/forms/mainwindow.ui b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/forms/mainwindow.ui
index faec75cb..e6f37426 100644
--- a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/forms/mainwindow.ui
+++ b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/forms/mainwindow.ui
@@ -214,6 +214,7 @@
     <addaction name="action_showHideController_student"/>
     <addaction name="action_showHideController_picker"/>
     <addaction name="action_showHideController_tuning"/>
+    <addaction name="action_showHideController_remote"/>
     <addaction name="action_showHideController_template"/>
     <addaction name="separator"/>
     <addaction name="action_testMotors"/>
@@ -320,6 +321,17 @@
     <string>TestMotors</string>
    </property>
   </action>
+  <action name="action_showHideController_remote">
+   <property name="checkable">
+    <bool>true</bool>
+   </property>
+   <property name="checked">
+    <bool>true</bool>
+   </property>
+   <property name="text">
+    <string>Remote</string>
+   </property>
+  </action>
  </widget>
  <layoutdefault spacing="6" margin="11"/>
  <customwidgets>
diff --git a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/include/controllertabs.h b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/include/controllertabs.h
index eca925ea..74f0e5b0 100644
--- a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/include/controllertabs.h
+++ b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/include/controllertabs.h
@@ -93,6 +93,7 @@ public:
     void showHideController_student_changed();
     void showHideController_picker_changed();
     void showHideController_tuning_changed();
+    void showHideController_remote_changed();
     void showHideController_template_changed();
 
 
diff --git a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/include/enablecontrollerloadyamlbar.h b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/include/enablecontrollerloadyamlbar.h
index ff4cb22e..c48d711f 100644
--- a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/include/enablecontrollerloadyamlbar.h
+++ b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/include/enablecontrollerloadyamlbar.h
@@ -92,6 +92,7 @@ public:
     void showHideController_student_changed();
     void showHideController_picker_changed();
     void showHideController_tuning_changed();
+    void showHideController_remote_changed();
     void showHideController_template_changed();
 
     void testMotors_triggered();
@@ -108,6 +109,7 @@ private slots:
     void on_enable_student_button_clicked();
     void on_enable_picker_button_clicked();
     void on_enable_tuning_button_clicked();
+    void on_enable_remote_button_clicked();
     void on_enable_template_button_clicked();
 
     // LOAD YAML BUTTONS ON-CLICK CALLBACK
@@ -115,6 +117,7 @@ private slots:
     void on_load_yaml_student_button_clicked();
     void on_load_yaml_picker_button_clicked();
     void on_load_yaml_tuning_button_clicked();
+    void on_load_yaml_remote_button_clicked();
     void on_load_yaml_template_button_clicked();
 
 
diff --git a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/include/mainwindow.h b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/include/mainwindow.h
index 17da92a8..ed4c43b6 100644
--- a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/include/mainwindow.h
+++ b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/include/mainwindow.h
@@ -131,6 +131,7 @@ private slots:
     void on_action_showHideController_student_changed();
     void on_action_showHideController_picker_changed();
     void on_action_showHideController_tuning_changed();
+    void on_action_showHideController_remote_changed();
     void on_action_showHideController_template_changed();
 
     void on_action_testMotors_triggered();
diff --git a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/src/controllertabs.cpp b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/src/controllertabs.cpp
index 3ee513c9..f53bba09 100644
--- a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/src/controllertabs.cpp
+++ b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/src/controllertabs.cpp
@@ -247,6 +247,11 @@ void ControllerTabs::showHideController_tuning_changed()
     showHideController_toggle("Tuning",ui->tuning_tab);
 }
 
+void ControllerTabs::showHideController_remote_changed()
+{
+    showHideController_toggle("Remote",ui->remote_tab);
+}
+
 void ControllerTabs::showHideController_template_changed()
 {
     showHideController_toggle("Template",ui->template_tab);
@@ -419,7 +424,7 @@ void ControllerTabs::setControllerEnabled(int new_controller)
         }
         case REMOTE_CONTROLLER:
         {
-            //ui->controller_enabled_label->setText("Remote");
+            setTextColourOfTabLabel( m_tab_text_colour_highlight , ui->remote_tab );
             break;
         }
         case TUNING_CONTROLLER:
@@ -452,6 +457,7 @@ void ControllerTabs::setAllTabLabelsToNormalColouring()
     setTextColourOfTabLabel( m_tab_text_colour_normal , ui->student_tab );
     setTextColourOfTabLabel( m_tab_text_colour_normal , ui->picker_tab );
     setTextColourOfTabLabel( m_tab_text_colour_normal , ui->tuning_tab );
+    setTextColourOfTabLabel( m_tab_text_colour_normal , ui->remote_tab );
     setTextColourOfTabLabel( m_tab_text_colour_normal , ui->template_tab );
 }
 
diff --git a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/src/enablecontrollerloadyamlbar.cpp b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/src/enablecontrollerloadyamlbar.cpp
index 43cc94a3..6a1e88f1 100644
--- a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/src/enablecontrollerloadyamlbar.cpp
+++ b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/src/enablecontrollerloadyamlbar.cpp
@@ -108,6 +108,12 @@ void EnableControllerLoadYamlBar::showHideController_tuning_changed()
     ui->load_yaml_tuning_button->setHidden( !(ui->load_yaml_tuning_button->isHidden()) );
 }
 
+void EnableControllerLoadYamlBar::showHideController_remote_changed()
+{
+    ui->enable_remote_button   ->setHidden( !(ui->enable_remote_button->isHidden()) );
+    ui->load_yaml_remote_button->setHidden( !(ui->load_yaml_remote_button->isHidden()) );
+}
+
 void EnableControllerLoadYamlBar::showHideController_template_changed()
 {
     ui->enable_template_button   ->setHidden( !(ui->enable_template_button->isHidden()) );
@@ -178,6 +184,17 @@ void EnableControllerLoadYamlBar::on_enable_tuning_button_clicked()
 #endif
 }
 
+void EnableControllerLoadYamlBar::on_enable_remote_button_clicked()
+{
+#ifdef CATKIN_MAKE
+    dfall_pkg::IntWithHeader msg;
+    fillIntMessageHeader(msg);
+    msg.data = CMD_USE_REMOTE_CONTROLLER;
+    this->commandPublisher.publish(msg);
+    ROS_INFO("[ENABLE CONTROLLER LOAD YAML GUI BAR] Enable Remote Controller");
+#endif
+}
+
 void EnableControllerLoadYamlBar::on_enable_template_button_clicked()
 {
 #ifdef CATKIN_MAKE
@@ -261,6 +278,22 @@ void EnableControllerLoadYamlBar::on_load_yaml_tuning_button_clicked()
 #endif
 }
 
+void EnableControllerLoadYamlBar::on_load_yaml_remote_button_clicked()
+{
+#ifdef CATKIN_MAKE
+    // Create a local variable for the message
+    dfall_pkg::StringWithHeader yaml_filename_msg;
+    // Set for whom this applies to
+    fillStringMessageHeader(yaml_filename_msg);
+    // Specify the data
+    yaml_filename_msg.data = "RemoteController";
+    // Send the message
+    m_requestLoadYamlFilenamePublisher.publish(yaml_filename_msg);
+    // Inform the user that the menu item was selected
+    ROS_INFO("[ENABLE CONTROLLER LOAD YAML GUI BAR] Load Remote Controller YAML was clicked.");
+#endif
+}
+
 void EnableControllerLoadYamlBar::on_load_yaml_template_button_clicked()
 {
 #ifdef CATKIN_MAKE
diff --git a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/src/mainwindow.cpp b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/src/mainwindow.cpp
index 8129239a..d6fc815a 100644
--- a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/src/mainwindow.cpp
+++ b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/src/mainwindow.cpp
@@ -145,6 +145,8 @@ MainWindow::MainWindow(int argc, char **argv, QWidget *parent) :
     ui->action_showHideController_picker->trigger();
     // > For the tuning controller
     ui->action_showHideController_tuning->trigger();
+    // > For the remote controller
+    ui->action_showHideController_remote->trigger();
     // > For the template controller
     ui->action_showHideController_template->trigger();
 
@@ -245,6 +247,13 @@ void MainWindow::on_action_showHideController_tuning_changed()
     ui->customWidget_controller_tabs->showHideController_tuning_changed();
 }
 
+void MainWindow::on_action_showHideController_remote_changed()
+{
+    // Notify the UI elements of this change
+    ui->customWidget_enableControllerLoadYamlBar->showHideController_remote_changed();
+    ui->customWidget_controller_tabs->showHideController_remote_changed();
+}
+
 void MainWindow::on_action_showHideController_template_changed()
 {
     // Notify the UI elements of this change
-- 
GitLab