From bdbbf781ff97d2bb04aba7c274e33f213f29d057 Mon Sep 17 00:00:00 2001
From: Jan Hausberg <jan.hausberg@kit.edu>
Date: Mon, 20 Jun 2022 15:22:23 +0200
Subject: [PATCH] Implement HandUnitConfigDialog supporting both hands

---
 .../HandUnitPlugin/HandUnitConfigDialog.cpp   |  13 +-
 .../HandUnitPlugin/HandUnitConfigDialog.h     |   3 +-
 .../HandUnitPlugin/HandUnitConfigDialog.ui    | 142 +++++++++++++-----
 .../HandUnitPlugin/HandUnitGuiPlugin.cpp      |   4 +-
 4 files changed, 118 insertions(+), 44 deletions(-)

diff --git a/source/RobotAPI/gui-plugins/HandUnitPlugin/HandUnitConfigDialog.cpp b/source/RobotAPI/gui-plugins/HandUnitPlugin/HandUnitConfigDialog.cpp
index 0a4d7031a..2e4c5851c 100644
--- a/source/RobotAPI/gui-plugins/HandUnitPlugin/HandUnitConfigDialog.cpp
+++ b/source/RobotAPI/gui-plugins/HandUnitPlugin/HandUnitConfigDialog.cpp
@@ -35,9 +35,13 @@ armarx::HandUnitConfigDialog::HandUnitConfigDialog(QWidget* parent) :
     setName(getDefaultName()); // @@@ This is necessary for more than 1 widget or even reopening the widget.
 
 
-    proxyFinder = new IceProxyFinder<HandUnitInterfacePrx>(this);
-    proxyFinder->setSearchMask("*Unit");
-    ui->proxyFinderContainer->addWidget(proxyFinder, 0, 0, 1, 1);
+    proxyFinderLeftHand = new IceProxyFinder<HandUnitInterfacePrx>(this);
+    proxyFinderLeftHand->setSearchMask("*Unit");
+    ui->proxyFinderContainerLeftHand->addWidget(proxyFinderLeftHand, 0, 0, 1, 1);
+
+    proxyFinderRightHand = new IceProxyFinder<HandUnitInterfacePrx>(this);
+    proxyFinderRightHand->setSearchMask("*Unit");
+    ui->proxyFinderContainerRightHand->addWidget(proxyFinderRightHand, 0, 0, 1, 1);
 }
 
 armarx::HandUnitConfigDialog::~HandUnitConfigDialog()
@@ -49,7 +53,8 @@ armarx::HandUnitConfigDialog::~HandUnitConfigDialog()
 
 void armarx::HandUnitConfigDialog::onInitComponent()
 {
-    proxyFinder->setIceManager(getIceManager());
+    proxyFinderLeftHand->setIceManager(getIceManager());
+    proxyFinderRightHand->setIceManager(getIceManager());
 }
 
 void armarx::HandUnitConfigDialog::onConnectComponent()
diff --git a/source/RobotAPI/gui-plugins/HandUnitPlugin/HandUnitConfigDialog.h b/source/RobotAPI/gui-plugins/HandUnitPlugin/HandUnitConfigDialog.h
index 1ed61c68c..149d8ce61 100644
--- a/source/RobotAPI/gui-plugins/HandUnitPlugin/HandUnitConfigDialog.h
+++ b/source/RobotAPI/gui-plugins/HandUnitPlugin/HandUnitConfigDialog.h
@@ -58,7 +58,8 @@ namespace armarx
     private:
         Ui::HandUnitConfigDialog* ui;
 
-        IceProxyFinderBase* proxyFinder;
+        IceProxyFinderBase* proxyFinderLeftHand;
+        IceProxyFinderBase* proxyFinderRightHand;
         std::string uuid;
 
         friend class HandUnitWidget;
diff --git a/source/RobotAPI/gui-plugins/HandUnitPlugin/HandUnitConfigDialog.ui b/source/RobotAPI/gui-plugins/HandUnitPlugin/HandUnitConfigDialog.ui
index 844cc1788..3197505fa 100644
--- a/source/RobotAPI/gui-plugins/HandUnitPlugin/HandUnitConfigDialog.ui
+++ b/source/RobotAPI/gui-plugins/HandUnitPlugin/HandUnitConfigDialog.ui
@@ -7,48 +7,116 @@
     <x>0</x>
     <y>0</y>
     <width>527</width>
-    <height>113</height>
+    <height>179</height>
    </rect>
   </property>
   <property name="windowTitle">
    <string>Dialog</string>
   </property>
-  <layout class="QGridLayout" name="gridLayout_2">
-   <item row="3" column="0">
-    <widget class="QDialogButtonBox" name="buttonBox">
-     <property name="orientation">
-      <enum>Qt::Horizontal</enum>
-     </property>
-     <property name="standardButtons">
-      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
-     </property>
-    </widget>
-   </item>
-   <item row="0" column="0">
-    <layout class="QGridLayout" name="gridLayout">
-     <item row="1" column="1">
-      <widget class="QLineEdit" name="editHandName">
-       <property name="readOnly">
-        <bool>true</bool>
-       </property>
-       <property name="placeholderText">
-        <string>will be retrieved from HandUnit</string>
-       </property>
-      </widget>
-     </item>
-     <item row="1" column="0">
-      <widget class="QLabel" name="labelHandName">
-       <property name="text">
-        <string>Hand Name</string>
-       </property>
-      </widget>
-     </item>
-     <item row="0" column="0" colspan="2">
-      <layout class="QGridLayout" name="proxyFinderContainer"/>
-     </item>
-    </layout>
-   </item>
-  </layout>
+  <widget class="QDialogButtonBox" name="buttonBox">
+   <property name="geometry">
+    <rect>
+     <x>350</x>
+     <y>150</y>
+     <width>166</width>
+     <height>25</height>
+    </rect>
+   </property>
+   <property name="orientation">
+    <enum>Qt::Horizontal</enum>
+   </property>
+   <property name="standardButtons">
+    <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+   </property>
+  </widget>
+  <widget class="QLabel" name="labelLeftHandName">
+   <property name="geometry">
+    <rect>
+     <x>20</x>
+     <y>50</y>
+     <width>111</width>
+     <height>25</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Left Hand Name</string>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="editLeftHandName">
+   <property name="geometry">
+    <rect>
+     <x>166</x>
+     <y>50</y>
+     <width>351</width>
+     <height>25</height>
+    </rect>
+   </property>
+   <property name="readOnly">
+    <bool>true</bool>
+   </property>
+   <property name="placeholderText">
+    <string>will be retrieved from HandUnit</string>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="editRightHandName">
+   <property name="geometry">
+    <rect>
+     <x>166</x>
+     <y>120</y>
+     <width>351</width>
+     <height>25</height>
+    </rect>
+   </property>
+   <property name="readOnly">
+    <bool>true</bool>
+   </property>
+   <property name="placeholderText">
+    <string>will be retrieved from HandUnit</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="labelRightHandName">
+   <property name="geometry">
+    <rect>
+     <x>20</x>
+     <y>120</y>
+     <width>121</width>
+     <height>25</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Right Hand Name</string>
+   </property>
+  </widget>
+  <widget class="QWidget" name="layoutWidget">
+   <property name="geometry">
+    <rect>
+     <x>10</x>
+     <y>80</y>
+     <width>511</width>
+     <height>35</height>
+    </rect>
+   </property>
+   <layout class="QGridLayout" name="gridLayoutRightHand">
+    <item row="0" column="0">
+     <layout class="QGridLayout" name="proxyFinderContainerRightHand"/>
+    </item>
+   </layout>
+  </widget>
+  <widget class="QWidget" name="">
+   <property name="geometry">
+    <rect>
+     <x>9</x>
+     <y>9</y>
+     <width>511</width>
+     <height>35</height>
+    </rect>
+   </property>
+   <layout class="QGridLayout" name="gridLayoutLeftHand">
+    <item row="0" column="0" colspan="2">
+     <layout class="QGridLayout" name="proxyFinderContainerLeftHand"/>
+    </item>
+   </layout>
+  </widget>
  </widget>
  <tabstops>
   <tabstop>buttonBox</tabstop>
diff --git a/source/RobotAPI/gui-plugins/HandUnitPlugin/HandUnitGuiPlugin.cpp b/source/RobotAPI/gui-plugins/HandUnitPlugin/HandUnitGuiPlugin.cpp
index d4d51872d..438e65788 100644
--- a/source/RobotAPI/gui-plugins/HandUnitPlugin/HandUnitGuiPlugin.cpp
+++ b/source/RobotAPI/gui-plugins/HandUnitPlugin/HandUnitGuiPlugin.cpp
@@ -157,8 +157,8 @@ namespace armarx
 
     void HandUnitWidget::configured()
     {
-        leftHandUnitProxyName = dialog->proxyFinder->getSelectedProxyName().toStdString();
-        rightHandUnitProxyName = dialog->proxyFinder->getSelectedProxyName().toStdString();
+        leftHandUnitProxyName = dialog->proxyFinderLeftHand->getSelectedProxyName().toStdString();
+        rightHandUnitProxyName = dialog->proxyFinderRightHand->getSelectedProxyName().toStdString();
     }
 
     void HandUnitWidget::preshapeLeftHand()
-- 
GitLab