WaypointController.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::WaypointController
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 WAYPOINTCONTROLLER_H
23 #define WAYPOINTCONTROLLER_H
24 #include "AbstractController.h"
25 #include "../View/WaypointTab.h"
26 #include "../Util/WheelEventFilter.h"
27 
28 #include <QListWidget>
29 #include <QMetaType>
30 #include <QVariant>
31 #include <QDoubleValidator>
32 
33 namespace armarx
34 {
35 
36  /*
37  * TODO: Change method signatures to support start time identifier
38  */
39  /**
40  * @brief Struct which allows storing relevant data to display within
41  * a list widget item as QVariant
42  */
43  typedef struct GuiWaypoint
44  {
45  std::vector<double> values;
48  } GuiWaypoint;
49 
50  /**
51  * @class WaypointController
52  * @brief Subcontroller which handles all user interaction with the waypoint
53  * tab in the GUI, communicates with other controllers via signals
54  * and slots
55  */
57  {
58  Q_OBJECT
59 
60  public:
61  /**
62  * @brief @see AbstractController
63  */
64  void onInitComponent() override;
65 
66  /**
67  * @brief @see AbstractController
68  */
69  void onConnectComponent() override;
70 
71  /**
72  * @brief @see AbstractController
73  */
74  void onDisconnectComponent() override;
75 
76  /**
77  * @brief @see AbstractController
78  */
79  void onExitComponent() override;
80 
81  /**
82  * @brief Creates a new WaypointController and assigns a WaypointTab to handle
83  * @param guiWaypointTab Pointer to the WaypointTab whose user interaction
84  * is handled by the WaypointController
85  */
86  WaypointController(WaypointTabPtr guiWaypointTab);
87 
88  /**
89  * @brief Getter for the WaypointTab pointer to guiWaypointTab
90  * @return A Pointer to the guiWayointTab
91  */
93 
94  /**
95  * @brief Setter for the WaypointTab pointer to guiWaypointTab
96  * @param guiWaypointTab Pointer to the WaypointTab whose user interaction
97  * is handled by the WaypointController
98  */
99  void setGuiWaypointTab(WaypointTabPtr guiWaypointTab);
100 
101  public slots:
102  /**
103  * @brief Adds a new waypoint to the list widget
104  * @param values Array containting x, y, z, coordinates as well as a, b, g
105  * euler angles of the waypoint
106  * @param index Index of the waypoint
107  * @param values x, y, z coordinate and roll, pitch, yaw euler angles of a waypoint
108  * @param cartesianSelection Integer representing the cartesian selection
109  * @param isBreakpoint Boolean determining whether the waypoint is a breakpoint
110  */
111  void addWaypoint(int index, std::vector<double> values, int cartesianSelection,
112  bool isBreakpoint);
113 
114  /**
115  * @brief Removes the waypoint at a given index
116  * @param index Index of the waypoint
117  */
118  void removeWaypoint(int index);
119 
120  /**
121  * @brief Updates the currently selected waypoint
122  * @param index Index of the currently selected waypoint
123  */
124  void updateSelectedWaypoint(int index);
125 
126  /**
127  * @brief Connected with signals from other controllers, sets all
128  * values of the waypoint at a given index
129  * @param index Index of the waypoint
130  * @param values Array containing the x, y, z coordinates and the
131  * roll, pitch, yaw euler angles
132  * @param constraints Constraints of the waypoint: isBreakpoint, ikConstraints
133  */
134  void setWaypointData(int index, std::vector<double> values, int cartesianSelection,
135  bool isBreakpoint);
136 
137  /**
138  * @brief Retranslates the guiWaypointTab
139  */
140  void retranslateGui();
141 
142  /**
143  * @brief Removes all items of the waypoint list
144  */
145  void clearWaypointList();
146 
147  /**
148  * @brief Enables or disables the delete button
149  * @param enable Determines whether to enable or disable the delete button
150  */
151  void enableDeleteButton(bool enable);
152 
153  /**
154  * @brief Enables or disables the add button
155  * @param enable Determines whether to enable or disable the add button
156  */
157  void enableAddButton(bool enable);
158 
159  /**
160  * @brief Enables or disables the waypoint list and line edit
161  * @param enable Determines whether to enable or disable the waypoint list and line edit
162  */
163  void enableWaypointListLineEdit(bool enable);
164 
165  private slots:
166  /**
167  * @brief Updates the currently selected waypoint
168  * @param item Currently selected waypoint in as list widget item
169  */
170  void updateSelectedWaypoint(QListWidgetItem* item);
171 
172  /**
173  * @brief Sets the x-coordinate of the currently selected waypoint
174  */
175  void setXCoordinate();
176 
177  /**
178  * @brief Sets the y-coordinate of the currently selected waypoint
179  */
180  void setYCoordinate();
181 
182  /**
183  * @brief Sets the z-coordinate of the currently selected waypoint
184  */
185  void setZCoordinate();
186 
187  /**
188  * @brief Sets the roll euler angle of the currently selected waypoint
189  */
190  void setEulerAngleR();
191 
192  /**
193  * @brief Sets the pitch euler angle of the currently selected waypoint
194  */
195  void setEulerAngleP();
196 
197  /**
198  * @brief Sets the yaw euler angle of the currently selected waypoint
199  */
200  void setEulerAngleY();
201 
202  /**
203  * @brief Sets the cartesian selection of the currently selected waypoint
204  * @param cs Index of the cartesian selection
205  */
206  void setCartesianSelection(int cs);
207 
208  /**
209  * @brief Sets whether the waypoint is a breakpoint
210  * @param isBreakpoint Boolean value determining whether the waypoint
211  * is a breakpoint
212  */
213  void setBreakpoint(bool isBreakpoint);
214 
215  /**
216  * @brief Adds a new waypoint relative to the currently selected waypoint
217  */
218  void addWaypoint();
219 
220  /**
221  * @brief Removes the currently selected waypoint
222  */
223  void removeWaypoint();
224 
225  signals:
226  /**
227  * @brief Notifies other controllers about changes of the given waypoint
228  * @param waypoint Index of the waypoint
229  * @param values Vector containing the x, y, z coordinates and the
230  * roll, pitch, yaw euler angles
231  */
232  void changedWaypoint(int waypoint, std::vector<double> values);
233 
234  /**
235  * @brief Notifies other controllers about changes of the given waypoint
236  * @param waypoint Index of the waypoint
237  * @param cartesianSelection Integer representing the cartesian selection
238  */
239  void changedWaypoint(int waypoint, int cartesianSelection);
240 
241  /**
242  * @brief Notifies other controllers about changes of the given waypoint
243  * @param waypoint Index of the waypoint
244  * @param isBreakpoint Boolean determining whether the waypoint is a breakpoint
245  */
246  void changedWaypoint(int waypoint, bool isBreakpoint);
247 
248  /**
249  * @brief Notifies other controllers about the addition of a new waypoint
250  * with given constraints
251  * @param waypoint Index of the waypoint
252  * @param insertAfter Boolean determining whether to insert after the waypoint
253  * or before
254  */
255  void addedWaypoint(int waypoint, bool insertAfter);
256 
257  /**
258  * @brief Notifies other controllers about the deletion of a given waypoint
259  * @param waypoint Index of the deleted waypoint
260  */
261  void deletedWaypoint(int waypoint);
262 
263  /**
264  * @brief Notifies other controllers whether to enable or disable the button for
265  * a new IK solution
266  * @param enable Determines whether to enable or disable the IK solution button
267  */
268  void enableIKSolutionButton(bool enable);
269 
270  /**
271  * @brief Notifies other controllers about changes of the current waypoint
272  * @param index Index of the current waypoint
273  */
274  void setCurrentIndex(int index);
275 
276  /**
277  * @brief Notifies RobotVisualizationController about changes of the current waypoint
278  * @param index Index of the current waypoint
279  */
281 
282  private:
283  WaypointTabPtr guiWaypointTab;
284 
285  /**
286  * @brief Initializes the cartesian selection combo box
287  */
288  void initCSComboBox();
289 
290  /**
291  * @brief Initializes and sets the validator for each line edit
292  * @param bottom Smallest number accepted by the validator
293  * @param top Greatest number accepted by the validator
294  * @param decimals Number of digits behind the decimal point
295  */
296  void initValidator(double bottom, double top, int decimals);
297 
298  /**
299  * @brief Updates all Gui elements corresponding to waypoint data
300  * @param waypoint GuiWaypoint providing waypoint data
301  */
302  void updateWaypointElements(GuiWaypoint waypoint);
303 
304  //@Max eingefügt von @Tim dadurch: Reihenfolge Item == Text Item
305  void changeTextListWidgetItems();
306  };
307 
308  using WaypointControllerPtr = std::shared_ptr<WaypointController>;
309 }
310 
311 Q_DECLARE_METATYPE(armarx::GuiWaypoint)
312 
313 #endif // WAYPOINTCONTROLLER_H
armarx::WaypointController::enableDeleteButton
void enableDeleteButton(bool enable)
Enables or disables the delete button.
Definition: WaypointController.cpp:530
armarx::WaypointControllerPtr
std::shared_ptr< WaypointController > WaypointControllerPtr
Definition: WaypointController.h:308
armarx::GuiWaypoint::cartesianSelection
int cartesianSelection
Definition: WaypointController.h:46
armarx::WaypointController::setCurrentIndexRobotVisualization
void setCurrentIndexRobotVisualization(int index)
Notifies RobotVisualizationController about changes of the current waypoint.
index
uint8_t index
Definition: EtherCATFrame.h:59
armarx::WaypointController::retranslateGui
void retranslateGui()
Retranslates the guiWaypointTab.
Definition: WaypointController.cpp:503
ProsthesisInterface.values
values
Definition: ProsthesisInterface.py:190
armarx::WaypointController::addedWaypoint
void addedWaypoint(int waypoint, bool insertAfter)
Notifies other controllers about the addition of a new waypoint with given constraints.
armarx::GuiWaypoint::isBreakpoint
bool isBreakpoint
Definition: WaypointController.h:47
armarx::WaypointController::onInitComponent
void onInitComponent() override
Definition: WaypointController.cpp:27
armarx::WaypointController::enableWaypointListLineEdit
void enableWaypointListLineEdit(bool enable)
Enables or disables the waypoint list and line edit.
Definition: WaypointController.cpp:544
armarx::WaypointController::changedWaypoint
void changedWaypoint(int waypoint, std::vector< double > values)
Notifies other controllers about changes of the given waypoint.
armarx::WaypointController::enableIKSolutionButton
void enableIKSolutionButton(bool enable)
Notifies other controllers whether to enable or disable the button for a new IK solution.
armarx::WaypointController::WaypointController
WaypointController(WaypointTabPtr guiWaypointTab)
Creates a new WaypointController and assigns a WaypointTab to handle.
Definition: WaypointController.cpp:112
WaypointTabPtr
std::shared_ptr< WaypointTab > WaypointTabPtr
Definition: WaypointTab.h:50
armarx::WaypointController::addWaypoint
void addWaypoint(int index, std::vector< double > values, int cartesianSelection, bool isBreakpoint)
Adds a new waypoint to the list widget.
Definition: WaypointController.cpp:132
armarx::GuiWaypoint::values
std::vector< double > values
Definition: WaypointController.h:45
AbstractController.h
armarx::WaypointController::setWaypointData
void setWaypointData(int index, std::vector< double > values, int cartesianSelection, bool isBreakpoint)
Connected with signals from other controllers, sets all values of the waypoint at a given index.
Definition: WaypointController.cpp:438
armarx::WaypointController::setGuiWaypointTab
void setGuiWaypointTab(WaypointTabPtr guiWaypointTab)
Setter for the WaypointTab pointer to guiWaypointTab.
Definition: WaypointController.cpp:124
armarx::WaypointController::deletedWaypoint
void deletedWaypoint(int waypoint)
Notifies other controllers about the deletion of a given waypoint.
armarx::WaypointController::enableAddButton
void enableAddButton(bool enable)
Enables or disables the add button.
Definition: WaypointController.cpp:537
armarx::WaypointController
Subcontroller which handles all user interaction with the waypoint tab in the GUI,...
Definition: WaypointController.h:56
armarx::WaypointController::onExitComponent
void onExitComponent() override
Definition: WaypointController.cpp:107
armarx::WaypointController::clearWaypointList
void clearWaypointList()
Removes all items of the waypoint list.
Definition: WaypointController.cpp:508
armarx::WaypointController::setCurrentIndex
void setCurrentIndex(int index)
Notifies other controllers about changes of the current waypoint.
armarx::WaypointController::onDisconnectComponent
void onDisconnectComponent() override
Definition: WaypointController.cpp:102
armarx::GuiWaypoint
struct armarx::GuiWaypoint GuiWaypoint
Struct which allows storing relevant data to display within a list widget item as QVariant.
armarx::WaypointController::removeWaypoint
void removeWaypoint(int index)
Removes the waypoint at a given index.
Definition: WaypointController.cpp:167
armarx::GuiWaypoint
Struct which allows storing relevant data to display within a list widget item as QVariant.
Definition: WaypointController.h:43
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::WaypointController::updateSelectedWaypoint
void updateSelectedWaypoint(int index)
Updates the currently selected waypoint.
Definition: WaypointController.cpp:200
armarx::AbstractController
Abstract controller providing a set of methods which must be implemented by every controller.
Definition: AbstractController.h:35
armarx::WaypointController::getGuiWaypointTab
WaypointTabPtr getGuiWaypointTab()
Getter for the WaypointTab pointer to guiWaypointTab.
Definition: WaypointController.cpp:119
armarx::WaypointController::onConnectComponent
void onConnectComponent() override
Definition: WaypointController.cpp:42