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