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 <QDoubleValidator>
25 #include <QListWidget>
26 #include <QMetaType>
27 #include <QVariant>
28 
29 #include "../Util/WheelEventFilter.h"
30 #include "../View/WaypointTab.h"
31 #include "AbstractController.h"
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,
112  std::vector<double> values,
113  int cartesianSelection,
114  bool isBreakpoint);
115 
116  /**
117  * @brief Removes the waypoint at a given index
118  * @param index Index of the waypoint
119  */
120  void removeWaypoint(int index);
121 
122  /**
123  * @brief Updates the currently selected waypoint
124  * @param index Index of the currently selected waypoint
125  */
126  void updateSelectedWaypoint(int index);
127 
128  /**
129  * @brief Connected with signals from other controllers, sets all
130  * values of the waypoint at a given index
131  * @param index Index of the waypoint
132  * @param values Array containing the x, y, z coordinates and the
133  * roll, pitch, yaw euler angles
134  * @param constraints Constraints of the waypoint: isBreakpoint, ikConstraints
135  */
136  void setWaypointData(int index,
137  std::vector<double> values,
138  int cartesianSelection,
139  bool isBreakpoint);
140 
141  /**
142  * @brief Retranslates the guiWaypointTab
143  */
144  void retranslateGui();
145 
146  /**
147  * @brief Removes all items of the waypoint list
148  */
149  void clearWaypointList();
150 
151  /**
152  * @brief Enables or disables the delete button
153  * @param enable Determines whether to enable or disable the delete button
154  */
155  void enableDeleteButton(bool enable);
156 
157  /**
158  * @brief Enables or disables the add button
159  * @param enable Determines whether to enable or disable the add button
160  */
161  void enableAddButton(bool enable);
162 
163  /**
164  * @brief Enables or disables the waypoint list and line edit
165  * @param enable Determines whether to enable or disable the waypoint list and line edit
166  */
167  void enableWaypointListLineEdit(bool enable);
168 
169  private slots:
170  /**
171  * @brief Updates the currently selected waypoint
172  * @param item Currently selected waypoint in as list widget item
173  */
174  void updateSelectedWaypoint(QListWidgetItem* item);
175 
176  /**
177  * @brief Sets the x-coordinate of the currently selected waypoint
178  */
179  void setXCoordinate();
180 
181  /**
182  * @brief Sets the y-coordinate of the currently selected waypoint
183  */
184  void setYCoordinate();
185 
186  /**
187  * @brief Sets the z-coordinate of the currently selected waypoint
188  */
189  void setZCoordinate();
190 
191  /**
192  * @brief Sets the roll euler angle of the currently selected waypoint
193  */
194  void setEulerAngleR();
195 
196  /**
197  * @brief Sets the pitch euler angle of the currently selected waypoint
198  */
199  void setEulerAngleP();
200 
201  /**
202  * @brief Sets the yaw euler angle of the currently selected waypoint
203  */
204  void setEulerAngleY();
205 
206  /**
207  * @brief Sets the cartesian selection of the currently selected waypoint
208  * @param cs Index of the cartesian selection
209  */
210  void setCartesianSelection(int cs);
211 
212  /**
213  * @brief Sets whether the waypoint is a breakpoint
214  * @param isBreakpoint Boolean value determining whether the waypoint
215  * is a breakpoint
216  */
217  void setBreakpoint(bool isBreakpoint);
218 
219  /**
220  * @brief Adds a new waypoint relative to the currently selected waypoint
221  */
222  void addWaypoint();
223 
224  /**
225  * @brief Removes the currently selected waypoint
226  */
227  void removeWaypoint();
228 
229  signals:
230  /**
231  * @brief Notifies other controllers about changes of the given waypoint
232  * @param waypoint Index of the waypoint
233  * @param values Vector containing the x, y, z coordinates and the
234  * roll, pitch, yaw euler angles
235  */
236  void changedWaypoint(int waypoint, std::vector<double> values);
237 
238  /**
239  * @brief Notifies other controllers about changes of the given waypoint
240  * @param waypoint Index of the waypoint
241  * @param cartesianSelection Integer representing the cartesian selection
242  */
243  void changedWaypoint(int waypoint, int cartesianSelection);
244 
245  /**
246  * @brief Notifies other controllers about changes of the given waypoint
247  * @param waypoint Index of the waypoint
248  * @param isBreakpoint Boolean determining whether the waypoint is a breakpoint
249  */
250  void changedWaypoint(int waypoint, bool isBreakpoint);
251 
252  /**
253  * @brief Notifies other controllers about the addition of a new waypoint
254  * with given constraints
255  * @param waypoint Index of the waypoint
256  * @param insertAfter Boolean determining whether to insert after the waypoint
257  * or before
258  */
259  void addedWaypoint(int waypoint, bool insertAfter);
260 
261  /**
262  * @brief Notifies other controllers about the deletion of a given waypoint
263  * @param waypoint Index of the deleted waypoint
264  */
265  void deletedWaypoint(int waypoint);
266 
267  /**
268  * @brief Notifies other controllers whether to enable or disable the button for
269  * a new IK solution
270  * @param enable Determines whether to enable or disable the IK solution button
271  */
272  void enableIKSolutionButton(bool enable);
273 
274  /**
275  * @brief Notifies other controllers about changes of the current waypoint
276  * @param index Index of the current waypoint
277  */
278  void setCurrentIndex(int index);
279 
280  /**
281  * @brief Notifies RobotVisualizationController about changes of the current waypoint
282  * @param index Index of the current waypoint
283  */
285 
286  private:
287  WaypointTabPtr guiWaypointTab;
288 
289  /**
290  * @brief Initializes the cartesian selection combo box
291  */
292  void initCSComboBox();
293 
294  /**
295  * @brief Initializes and sets the validator for each line edit
296  * @param bottom Smallest number accepted by the validator
297  * @param top Greatest number accepted by the validator
298  * @param decimals Number of digits behind the decimal point
299  */
300  void initValidator(double bottom, double top, int decimals);
301 
302  /**
303  * @brief Updates all Gui elements corresponding to waypoint data
304  * @param waypoint GuiWaypoint providing waypoint data
305  */
306  void updateWaypointElements(GuiWaypoint waypoint);
307 
308  //@Max eingefügt von @Tim dadurch: Reihenfolge Item == Text Item
309  void changeTextListWidgetItems();
310  };
311 
312  using WaypointControllerPtr = std::shared_ptr<WaypointController>;
313 } // namespace armarx
314 
315 Q_DECLARE_METATYPE(armarx::GuiWaypoint)
316 
317 #endif // WAYPOINTCONTROLLER_H
armarx::WaypointController::enableDeleteButton
void enableDeleteButton(bool enable)
Enables or disables the delete button.
Definition: WaypointController.cpp:549
armarx::WaypointControllerPtr
std::shared_ptr< WaypointController > WaypointControllerPtr
Definition: WaypointController.h:312
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:520
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:29
armarx::WaypointController::enableWaypointListLineEdit
void enableWaypointListLineEdit(bool enable)
Enables or disables the waypoint list and line edit.
Definition: WaypointController.cpp:565
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:128
WaypointTabPtr
std::shared_ptr< WaypointTab > WaypointTabPtr
Definition: WaypointTab.h:52
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:151
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:458
armarx::WaypointController::setGuiWaypointTab
void setGuiWaypointTab(WaypointTabPtr guiWaypointTab)
Setter for the WaypointTab pointer to guiWaypointTab.
Definition: WaypointController.cpp:142
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:557
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:123
armarx::WaypointController::clearWaypointList
void clearWaypointList()
Removes all items of the waypoint list.
Definition: WaypointController.cpp:526
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:117
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:187
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:27
armarx::WaypointController::updateSelectedWaypoint
void updateSelectedWaypoint(int index)
Updates the currently selected waypoint.
Definition: WaypointController.cpp:222
armarx::AbstractController
Abstract controller providing a set of methods which must be implemented by every controller.
Definition: AbstractController.h:37
armarx::WaypointController::getGuiWaypointTab
WaypointTabPtr getGuiWaypointTab()
Getter for the WaypointTab pointer to guiWaypointTab.
Definition: WaypointController.cpp:136
armarx::WaypointController::onConnectComponent
void onConnectComponent() override
Definition: WaypointController.cpp:45