SettingController.h
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::SettingController
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 #ifndef SETTINGCONTROLLER_H
23 #define SETTINGCONTROLLER_H
24 #include <memory>
25 
26 #include <QComboBox>
27 #include <QVariant>
28 
29 #include "../Environment.h"
30 #include "../Util/WheelEventFilter.h"
31 #include "../View/SettingTab.h"
32 #include "AbstractController.h"
33 #include "VirtualRobot/RobotNodeSet.h"
34 
35 namespace armarx
36 {
37  /**
38  * @class SettingController
39  * @brief Subcontroller which handles all user interaction with the setting
40  * tab in the GUI, communicates with other controllers via signals
41  * and slots
42  */
44  {
45  Q_OBJECT
46 
47  public:
48  /**
49  * @brief @see AbstractController
50  */
51  void onInitComponent() override;
52 
53  /**
54  * @brief @see AbstractController
55  */
56  void onConnectComponent() override;
57 
58  /**
59  * @brief @see AbstractController
60  */
61  void onDisconnectComponent() override;
62 
63  /**
64  * @brief @see AbstractController
65  */
66  void onExitComponent() override;
67 
68  /**
69  * @brief Creates a new SettingController and assigns a SettingTab to handle
70  * @param guiSettingTab Pointer to the SettingTab whose user interaction
71  * is handled by the TransitionController
72  */
73  SettingController(SettingTabPtr guiSettingTab);
74 
75  /**
76  * @brief Getter for the SettingTab pointer to guiSettingTab
77  * @return A Pointer to the guiSettingTab
78  */
80 
81  /**
82  * @brief Setter for the SettingTab pointer to guiSettingTab
83  * @param guiSettingTab Pointer to the SettingTab whose user interaction
84  * is handled by the SettingController
85  */
86  void setGuiSettingTab(SettingTabPtr guiSettingTab);
87 
88  public slots:
89  /**
90  * @brief Changes the currently selected TCP
91  * @param index Index of the current TCP
92  */
93  void selectTCP(int index);
94 
95  /**
96  * @brief Changes the currently selected TCP
97  * @param tcp String identifier of the current TCP
98  */
99  void selectTCP(QString tcp);
100 
101  /*
102  *
103  * Check with waypoint controller how many waypoints there are to disable or
104  * enable the ik solution button. (Signal is emitted from waypoint controller)
105  *
106  */
107  /**
108  * @brief Enables or disables the new IK solution button
109  * @param enable Determines whether to enable or disable the ik solution button
110  */
111  void enableIKSolutionButton(bool enable);
112 
113  /**
114  * @brief Enables or disables the export buttons
115  * @param enable Determines whether to enable or disable the export buttons
116  */
117  void enableExportButtons(bool enable);
118 
119  /**
120  * @brief Enables or disables the import, tcp and collision buttons
121  * @param enable Determines whether to enable or disable the import, tcp and collision buttons
122  */
123  void enableImportTCPCollision(bool enable);
124 
125  /**
126  * @brief Retranslates the guiSettingTab
127  */
128  void retranslateGui();
129 
130 
131  void enableSelectRobotButton(bool enable);
132  /**
133  * @brief Set the enviroment
134  * @param The new enviroment
135  */
136  void environmentChanged(EnvironmentPtr environment);
137 
138  private slots:
139  /**
140  * @brief Opens a dialog to select which robot to use in the application
141  */
142  void openRobotSelectionDialog();
143 
144  /**
145  * @brief Opens a dialog to access all keyboard shortcuts provided by
146  * the RobotTrajectoryDesigner
147  */
148  void openShortcutDialog();
149 
150  /*
151  *
152  * Calculates a new IK solution for the first waypoint of the selected kinematic
153  * chain by calling the kinematic solver.
154  * Then add joint angles to current robot node set and send signal to visualization
155  *
156  */
157  /**
158  * @brief Calculates a new IK solution for the first waypoint of the selected
159  * kinematic chain and applies it to the robot
160  */
161  void newIKSolution();
162 
163  /**
164  * @brief Changes the active collision model for the selected TCP
165  * @param index Index of the active collision model
166  */
167  void selectActiveCM(int index);
168 
169  /**
170  * @brief Checks if the checkstate of the given item has changed. In that case,
171  * all used collision models are updated internally.
172  * @param item List widget item whose checkstate might have changed
173  */
174  void setCollisionModelList(QListWidgetItem* item);
175 
176  /**
177  * @brief Export all trajectory to Trajectory
178  */
179  void exportTrajectorySlot();
180 
181  /**
182  * @brief Convert all trajectory to MMM
183  */
184  void convertToMMMSlot();
185 
186  /**
187  * @brief Opens a dialog to import an existing trajectory
188  */
189  void openImportDialog();
190 
191  /**
192  * @brief Sets the display language that is to be used in the GUI
193  * @param index Index of the language
194  */
195  void setLanguage(int index);
196 
197  signals:
198  /**
199  * @brief Notifies other controllers about a change of the language
200  * @param index Index of the language
201  */
202  void changedLanguage(QString language);
203 
204  /**
205  * @brief Notifies other controllers about a change of the current TCP
206  * @param index Index of the TCP
207  */
208  void changedTCP(QString tcp);
209 
210  /**
211  * @brief Sets the active collision model name
212  * @param activeColModelName Active collision model name
213  */
214  void setActiveColModelName(QString activeColModelName);
215 
216  /**
217  * @brief Sets the body collision models names
218  * @param activeColModelName Body collision models names
219  */
220  void setBodyColModelsNames(QStringList bodyColModelsNames);
221 
222  /**
223  * @brief Notifies other controllers to open a robot selection dialog
224  */
225  void openRobotSelection();
226 
227  /**
228  * @brief Notifies other controllers to open a shortcut dialog
229  */
230  void openShortcut();
231 
232  /**
233  * @brief Notifies other controllers to export all trajectories to Trajectory
234  */
235  void exportTrajectory();
236 
237  /**
238  * @brief Notifies other controllers to convert all trajectories to MMM
239  */
240  void convertToMMM();
241 
242  /**
243  * @brief Notifies other controllers to open an import dialog
244  */
245  void openImport();
246 
247  /*
248  *
249  * Notify other controllers about a new ik solution. (visualization, trajectory)
250  *
251  */
252  /**
253  * @brief Notifies other controllers about the availability of a new IK
254  * solution for the first waypoint
255  */
256  void changedIKSolution();
257 
258  private:
259  SettingTabPtr guiSettingTab;
260  EnvironmentPtr environment;
261 
262  /**
263  * @brief Enables or Disables the collision model combo box and list, export and
264  * import buttons
265  * @param enable Determines whether to enable or disable the widgets
266  */
267  void enableWidgets(bool enable);
268 
269  /**
270  * @brief Initializes the contents of the TCP combo box with robot
271  * node sets from a given robot
272  * @param robot Pointer to the used robot
273  */
274  void initTCPComboBox(VirtualRobot::RobotPtr robot);
275 
276  /**
277  * @brief Initializes the contents of the active collision model combo
278  * box with collision models from a given robot
279  * @param robot Pointer to the used robot
280  */
281  void initCMComboBox(VirtualRobot::RobotPtr robot);
282 
283  /**
284  * @brief Initializes the contents of the collision model list with
285  * collision models from a given robot
286  * @param robot Pointer to the used robot
287  */
288  void initCMList(VirtualRobot::RobotPtr robot);
289  };
290 
291  using SettingControllerPtr = std::shared_ptr<SettingController>;
292 } // namespace armarx
293 
294 
295 #endif // SETTINGCONTROLLER_H
armarx::SettingController::SettingController
SettingController(SettingTabPtr guiSettingTab)
Creates a new SettingController and assigns a SettingTab to handle.
Definition: SettingController.cpp:109
armarx::SettingController::onDisconnectComponent
void onDisconnectComponent() override
Definition: SettingController.cpp:98
armarx::SettingController::changedTCP
void changedTCP(QString tcp)
Notifies other controllers about a change of the current TCP.
armarx::SettingControllerPtr
std::shared_ptr< SettingController > SettingControllerPtr
Definition: SettingController.h:291
armarx::SettingController::convertToMMM
void convertToMMM()
Notifies other controllers to convert all trajectories to MMM.
index
uint8_t index
Definition: EtherCATFrame.h:59
armarx::SettingController::onExitComponent
void onExitComponent() override
Definition: SettingController.cpp:104
armarx::SettingController::retranslateGui
void retranslateGui()
Retranslates the guiSettingTab.
Definition: SettingController.cpp:301
armarx::SettingController::changedIKSolution
void changedIKSolution()
Notifies other controllers about the availability of a new IK solution for the first waypoint.
armarx::SettingController::enableImportTCPCollision
void enableImportTCPCollision(bool enable)
Enables or disables the import, tcp and collision buttons.
Definition: SettingController.cpp:274
armarx::SettingController::setGuiSettingTab
void setGuiSettingTab(SettingTabPtr guiSettingTab)
Setter for the SettingTab pointer to guiSettingTab.
Definition: SettingController.cpp:122
armarx::SettingController::exportTrajectory
void exportTrajectory()
Notifies other controllers to export all trajectories to Trajectory.
armarx::EnvironmentPtr
std::shared_ptr< Environment > EnvironmentPtr
Definition: Environment.h:29
armarx::SettingController
Subcontroller which handles all user interaction with the setting tab in the GUI, communicates with o...
Definition: SettingController.h:43
armarx::SettingController::openShortcut
void openShortcut()
Notifies other controllers to open a shortcut dialog.
AbstractController.h
armarx::SettingController::enableIKSolutionButton
void enableIKSolutionButton(bool enable)
Enables or disables the new IK solution button.
Definition: SettingController.cpp:261
armarx::SettingController::getGuiSettingTab
SettingTabPtr getGuiSettingTab()
Getter for the SettingTab pointer to guiSettingTab.
Definition: SettingController.cpp:116
armarx::SettingController::changedLanguage
void changedLanguage(QString language)
Notifies other controllers about a change of the language.
armarx::SettingController::openRobotSelection
void openRobotSelection()
Notifies other controllers to open a robot selection dialog.
armarx::SettingController::onInitComponent
void onInitComponent() override
Definition: SettingController.cpp:33
armarx::SettingController::setBodyColModelsNames
void setBodyColModelsNames(QStringList bodyColModelsNames)
Sets the body collision models names.
SettingTabPtr
std::shared_ptr< SettingTab > SettingTabPtr
Definition: SettingTab.h:54
armarx::SettingController::enableSelectRobotButton
void enableSelectRobotButton(bool enable)
Definition: SettingController.cpp:307
armarx::SettingController::environmentChanged
void environmentChanged(EnvironmentPtr environment)
Set the enviroment.
Definition: SettingController.cpp:313
armarx::SettingController::selectTCP
void selectTCP(int index)
Changes the currently selected TCP.
Definition: SettingController.cpp:143
armarx::SettingController::onConnectComponent
void onConnectComponent() override
Definition: SettingController.cpp:44
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::SettingController::openImport
void openImport()
Notifies other controllers to open an import dialog.
armarx::AbstractController
Abstract controller providing a set of methods which must be implemented by every controller.
Definition: AbstractController.h:37
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:19
armarx::SettingController::enableExportButtons
void enableExportButtons(bool enable)
Enables or disables the export buttons.
Definition: SettingController.cpp:267
armarx::SettingController::setActiveColModelName
void setActiveColModelName(QString activeColModelName)
Sets the active collision model name.