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*/
23
24#include "../Environment.h"
25
26namespace 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);
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
uint8_t index
void setCurrentTCPCombobox(QComboBox *currentTCPCombobox)
Setter for the QComboBox pointer to currentTCPCombobox.
void changedSelectedTCP(QString trajectory)
Notifies other controllers about changes of the currently displayed trajectory.
void removeAllTrajectories()
Removes all trajectorie is tcpComboBox.
void addTrajectory(QString trajectory)
Adds a new trajectory to the combobox of available trajectories.
void updateSelectedTCP(QString trajectory)
Updates the currently displayed trajectory of the corresponding TCP.
void enableSelectedTCP(bool enable)
Enables or disables the selected tcp combobox.
TCPSelectionController(QComboBox *currentTCPCombobox)
Creates a new TCPSelectionController and assigns a QWidget to handle.
QComboBox * getCurrentTCPCombobox()
Getter for the QComboBox pointer to currentTCPCombobox.
void removeTrajectory(QString trajectory)
Removes the given trajectory from the TCP selection combo box.
#define ARMARX_INFO
The normal logging level.
Definition Logging.h:181
This file offers overloads of toIce() and fromIce() functions for STL container types.