TCPSelectionController.cpp
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * \package RobotTrajectoryDesigner::gui-plugins::Controller::TCPSelectionController
17 * \author Max Beddies
18 * \date 2018
19 * \copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 #include "TCPSelectionController.h"
23 #include "../Environment.h"
24 
25 namespace armarx
26 {
28  {
29  ARMARX_INFO << "RobotTrajectoryDesigner: TCPSelectionController on init";
30 
31  currentTCPCombobox->clear();
32  currentTCPCombobox->setEnabled(false);
33 
34  // Set strong focus and add wheel event filter
35  currentTCPCombobox->setFocusPolicy(Qt::StrongFocus);
36  currentTCPCombobox->installEventFilter(new WheelEventFilter(this));
37  }
38 
40  {
41  ARMARX_INFO << "RobotTrajectoryDesigner: TCPSelectionController on connect";
42 
43  // Select trajectory: update selected trajectory
44  QObject::connect(currentTCPCombobox, SIGNAL(activated(int)),
45  this, SLOT(updateSelectedTCP(int)));
46  }
47 
49  {
50  ARMARX_INFO << "RobotTrajectoryDesigner: TCPSelectionController on disconnect";
51  }
52 
54  {
55  ARMARX_INFO << "RobotTrajectoryDesigner: TCPSelectionController on exit";
56  }
57 
58  TCPSelectionController::TCPSelectionController(QComboBox* currentTCPCombobox) :
59  currentTCPCombobox(currentTCPCombobox)
60  {
63  }
64 
66  {
67  return this->currentTCPCombobox;
68  }
69 
70  void TCPSelectionController::setCurrentTCPCombobox(QComboBox* currentTCPCombobox)
71  {
72  if (currentTCPCombobox != NULL)
73  {
74  this->currentTCPCombobox = currentTCPCombobox;
75  }
76  }
77 
79  {
80  if (index >= 0)
81  {
82  emit changedSelectedTCP(this->currentTCPCombobox->currentText());
83  }
84  }
85 
87  {
88  int index = currentTCPCombobox->findText(trajectory);
89  if (index != -1)
90  {
91  currentTCPCombobox->setCurrentIndex(index);
92  emit changedSelectedTCP(trajectory);
93  }
94  }
95 
96  void TCPSelectionController::addTrajectory(QString trajectory)
97  {
98  if (trajectory != NULL)
99  {
100  if (this->currentTCPCombobox->findText(trajectory) == -1)
101  {
102  this->currentTCPCombobox->addItem(trajectory);
103  if (this->currentTCPCombobox->count() == 1)
104  {
105  this->currentTCPCombobox->setEnabled(true);
106  }
107  }
108  }
109  }
110 
112  {
113  int index = currentTCPCombobox->findText(trajectory);
114 
115  if (index != -1)
116  {
117  currentTCPCombobox->removeItem(index);
118  }
119  if (currentTCPCombobox->count() == 0)
120  {
121  currentTCPCombobox->setEnabled(false);
122  }
123  }
124 
126  {
127  this->currentTCPCombobox->setEnabled(enable);
128  }
129 
131  {
132  currentTCPCombobox->clear();
133  currentTCPCombobox->setEnabled(false);
134  }
135 }
armarx::TCPSelectionController::onExitComponent
void onExitComponent() override
Definition: TCPSelectionController.cpp:53
index
uint8_t index
Definition: EtherCATFrame.h:59
armarx::TCPSelectionController::removeAllTrajectories
void removeAllTrajectories()
Removes all trajectorie is tcpComboBox.
Definition: TCPSelectionController.cpp:130
armarx::TCPSelectionController::onDisconnectComponent
void onDisconnectComponent() override
Definition: TCPSelectionController.cpp:48
armarx::TCPSelectionController::addTrajectory
void addTrajectory(QString trajectory)
Adds a new trajectory to the combobox of available trajectories.
Definition: TCPSelectionController.cpp:96
armarx::WheelEventFilter
Definition: WheelEventFilter.h:31
armarx::TCPSelectionController::onConnectComponent
void onConnectComponent() override
Definition: TCPSelectionController.cpp:39
armarx::TCPSelectionController::onInitComponent
void onInitComponent() override
Definition: TCPSelectionController.cpp:27
armarx::TCPSelectionController::setCurrentTCPCombobox
void setCurrentTCPCombobox(QComboBox *currentTCPCombobox)
Setter for the QComboBox pointer to currentTCPCombobox.
Definition: TCPSelectionController.cpp:70
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
armarx::TCPSelectionController::changedSelectedTCP
void changedSelectedTCP(QString trajectory)
Notifies other controllers about changes of the currently displayed trajectory.
armarx::TCPSelectionController::getCurrentTCPCombobox
QComboBox * getCurrentTCPCombobox()
Getter for the QComboBox pointer to currentTCPCombobox.
Definition: TCPSelectionController.cpp:65
TCPSelectionController.h
armarx::TCPSelectionController::enableSelectedTCP
void enableSelectedTCP(bool enable)
Enables or disables the selected tcp combobox.
Definition: TCPSelectionController.cpp:125
armarx::TCPSelectionController::updateSelectedTCP
void updateSelectedTCP(QString trajectory)
Updates the currently displayed trajectory of the corresponding TCP.
Definition: TCPSelectionController.cpp:86
armarx::TCPSelectionController::TCPSelectionController
TCPSelectionController(QComboBox *currentTCPCombobox)
Creates a new TCPSelectionController and assigns a QWidget to handle.
Definition: TCPSelectionController.cpp:58
armarx::TCPSelectionController::removeTrajectory
void removeTrajectory(QString trajectory)
Removes the given trajectory from the TCP selection combo box.
Definition: TCPSelectionController.cpp:111
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28