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 
24 #include "../Environment.h"
25 
26 namespace armarx
27 {
28  void
30  {
31  ARMARX_INFO << "RobotTrajectoryDesigner: TCPSelectionController on init";
32 
33  currentTCPCombobox->clear();
34  currentTCPCombobox->setEnabled(false);
35 
36  // Set strong focus and add wheel event filter
37  currentTCPCombobox->setFocusPolicy(Qt::StrongFocus);
38  currentTCPCombobox->installEventFilter(new WheelEventFilter(this));
39  }
40 
41  void
43  {
44  ARMARX_INFO << "RobotTrajectoryDesigner: TCPSelectionController on connect";
45 
46  // Select trajectory: update selected trajectory
47  QObject::connect(
48  currentTCPCombobox, SIGNAL(activated(int)), this, SLOT(updateSelectedTCP(int)));
49  }
50 
51  void
53  {
54  ARMARX_INFO << "RobotTrajectoryDesigner: TCPSelectionController on disconnect";
55  }
56 
57  void
59  {
60  ARMARX_INFO << "RobotTrajectoryDesigner: TCPSelectionController on exit";
61  }
62 
63  TCPSelectionController::TCPSelectionController(QComboBox* currentTCPCombobox) :
64  currentTCPCombobox(currentTCPCombobox)
65  {
68  }
69 
70  QComboBox*
72  {
73  return this->currentTCPCombobox;
74  }
75 
76  void
77  TCPSelectionController::setCurrentTCPCombobox(QComboBox* currentTCPCombobox)
78  {
79  if (currentTCPCombobox != NULL)
80  {
81  this->currentTCPCombobox = currentTCPCombobox;
82  }
83  }
84 
85  void
87  {
88  if (index >= 0)
89  {
90  emit changedSelectedTCP(this->currentTCPCombobox->currentText());
91  }
92  }
93 
94  void
96  {
97  int index = currentTCPCombobox->findText(trajectory);
98  if (index != -1)
99  {
100  currentTCPCombobox->setCurrentIndex(index);
101  emit changedSelectedTCP(trajectory);
102  }
103  }
104 
105  void
107  {
108  if (trajectory != NULL)
109  {
110  if (this->currentTCPCombobox->findText(trajectory) == -1)
111  {
112  this->currentTCPCombobox->addItem(trajectory);
113  if (this->currentTCPCombobox->count() == 1)
114  {
115  this->currentTCPCombobox->setEnabled(true);
116  }
117  }
118  }
119  }
120 
121  void
123  {
124  int index = currentTCPCombobox->findText(trajectory);
125 
126  if (index != -1)
127  {
128  currentTCPCombobox->removeItem(index);
129  }
130  if (currentTCPCombobox->count() == 0)
131  {
132  currentTCPCombobox->setEnabled(false);
133  }
134  }
135 
136  void
138  {
139  this->currentTCPCombobox->setEnabled(enable);
140  }
141 
142  void
144  {
145  currentTCPCombobox->clear();
146  currentTCPCombobox->setEnabled(false);
147  }
148 } // namespace armarx
armarx::TCPSelectionController::onExitComponent
void onExitComponent() override
Definition: TCPSelectionController.cpp:58
index
uint8_t index
Definition: EtherCATFrame.h:59
armarx::TCPSelectionController::removeAllTrajectories
void removeAllTrajectories()
Removes all trajectorie is tcpComboBox.
Definition: TCPSelectionController.cpp:143
armarx::TCPSelectionController::onDisconnectComponent
void onDisconnectComponent() override
Definition: TCPSelectionController.cpp:52
armarx::TCPSelectionController::addTrajectory
void addTrajectory(QString trajectory)
Adds a new trajectory to the combobox of available trajectories.
Definition: TCPSelectionController.cpp:106
armarx::WheelEventFilter
Definition: WheelEventFilter.h:31
armarx::TCPSelectionController::onConnectComponent
void onConnectComponent() override
Definition: TCPSelectionController.cpp:42
armarx::TCPSelectionController::onInitComponent
void onInitComponent() override
Definition: TCPSelectionController.cpp:29
armarx::TCPSelectionController::setCurrentTCPCombobox
void setCurrentTCPCombobox(QComboBox *currentTCPCombobox)
Setter for the QComboBox pointer to currentTCPCombobox.
Definition: TCPSelectionController.cpp:77
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:181
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:71
TCPSelectionController.h
armarx::TCPSelectionController::enableSelectedTCP
void enableSelectedTCP(bool enable)
Enables or disables the selected tcp combobox.
Definition: TCPSelectionController.cpp:137
armarx::TCPSelectionController::updateSelectedTCP
void updateSelectedTCP(QString trajectory)
Updates the currently displayed trajectory of the corresponding TCP.
Definition: TCPSelectionController.cpp:95
armarx::TCPSelectionController::TCPSelectionController
TCPSelectionController(QComboBox *currentTCPCombobox)
Creates a new TCPSelectionController and assigns a QWidget to handle.
Definition: TCPSelectionController.cpp:63
armarx::TCPSelectionController::removeTrajectory
void removeTrajectory(QString trajectory)
Removes the given trajectory from the TCP selection combo box.
Definition: TCPSelectionController.cpp:122
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27