ShortcutController.cpp
Go to the documentation of this file.
2
3#include "qapplication.h"
4
5namespace armarx
6{
7 void
9 {
10 deactivateSetWaypoint = new QShortcut(QKeySequence(Qt::LeftButton), this->parent);
11 setWaypoint = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_S), this->parent);
12 deleteWaypoint = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_D), this->parent);
13 changeWaypointShortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this->parent);
14 playPreview = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_R), this->parent);
15 playPreviewAll = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_A), this->parent);
16 stopPreview = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_F), this->parent);
17 undoShortcut = new QShortcut(QKeySequence::Undo, this->parent);
18 redoShortcut = new QShortcut(QKeySequence::Redo, this->parent);
19 setPerspectiveHighAngle = new QShortcut(QKeySequence(Qt::Key_1), this->parent);
20 setPerspectiveTop = new QShortcut(QKeySequence(Qt::Key_2), this->parent);
21 setPerspectiveFront = new QShortcut(QKeySequence(Qt::Key_3), this->parent);
22 setPerspectiveBack = new QShortcut(QKeySequence(Qt::Key_4), this->parent);
23 setPerspectiveLeft = new QShortcut(QKeySequence(Qt::Key_5), this->parent);
24 setPerspectiveRight = new QShortcut(QKeySequence(Qt::Key_6), this->parent);
25 setWaypoint->setEnabled(false);
26 deleteWaypoint->setEnabled(false);
27 changeWaypointShortcut->setEnabled(false);
28 playPreview->setEnabled(false);
29 playPreviewAll->setEnabled(false);
30 stopPreview->setEnabled(false);
31 shortcutDialog = new QDialog;
32 ui.setupUi(shortcutDialog);
33 ARMARX_INFO << "RobotTrajectoryDesigner: ShortcutController on init";
34 }
35
36 void
38 {
39 //Connects Gui
40 QObject::connect(ui.okButton, SIGNAL(clicked()), shortcutDialog, SLOT(accept()));
41 //Connects Shortcuts
42 QObject::connect(deactivateSetWaypoint, SIGNAL(activated()), this, SLOT(disableSet()));
43 QObject::connect(setWaypoint, SIGNAL(activated()), this, SLOT(addedWaypointSlot()));
44 QObject::connect(deleteWaypoint, SIGNAL(activated()), this, SLOT(deletedWaypointSlot()));
45 QObject::connect(
46 changeWaypointShortcut, SIGNAL(activated()), this, SLOT(changeWaypointSlot()));
47 QObject::connect(playPreview, SIGNAL(activated()), this, SLOT(playPreviewSlot()));
48 QObject::connect(playPreviewAll, SIGNAL(activated()), this, SLOT(playPreviewAllSlot()));
49 QObject::connect(stopPreview, SIGNAL(activated()), this, SLOT(stopPreviewSlot()));
50 QObject::connect(
51 setPerspectiveTop, SIGNAL(activated()), this, SLOT(changedPerspectiveTopSlot()));
52 QObject::connect(
53 setPerspectiveFront, SIGNAL(activated()), this, SLOT(changedPerspectiveFrontSlot()));
54 QObject::connect(
55 setPerspectiveBack, SIGNAL(activated()), this, SLOT(changedPerspectiveBackSlot()));
56 QObject::connect(
57 setPerspectiveLeft, SIGNAL(activated()), this, SLOT(changedPerspectiveLeftSlot()));
58 QObject::connect(
59 setPerspectiveRight, SIGNAL(activated()), this, SLOT(changedPerspectiveRightSlot()));
60 QObject::connect(setPerspectiveHighAngle,
61 SIGNAL(activated()),
62 this,
63 SLOT(changedPerspectiveHighAngleSlot()));
64 QObject::connect(undoShortcut, SIGNAL(activated()), this, SLOT(undoOperation()));
65 QObject::connect(redoShortcut, SIGNAL(activated()), this, SLOT(redoOperation()));
66 ARMARX_INFO << "RobotTrajectoryDesigner: ShortcutController on connect";
67 }
68
69 void
71 {
72 ARMARX_INFO << "RobotTrajectoryDesigner: ShortcutController on disconnect";
73 }
74
75 void
77 {
78 ARMARX_INFO << "RobotTrajectoryDesigner: ShortcutController on exit";
79 }
80
82 {
83 currentWaypoint = 0;
84 this->parent = parent;
87 }
88
89 int
91 {
92 return currentWaypoint;
93 }
94
95 void
97 {
98 if (currentWaypoint >= 0)
99 {
100 this->currentWaypoint = currentWaypoint;
101 }
102 }
103
104 void
106 {
107 shortcutDialog->setModal(true);
108 shortcutDialog->exec();
109 }
110
111 void
113 {
114 playPreviewAll->setEnabled(enable);
115 }
116
117 void
119 {
120 stopPreview->setEnabled(enable);
121 }
122
123 void
125 {
126 redoShortcut->setEnabled(enable);
127 }
128
129 void
131 {
132 undoShortcut->setEnabled(enable);
133 }
134
135 void
137 {
138 deleteWaypoint->setEnabled(enable);
139 changeWaypointShortcut->setEnabled(enable);
140 }
141
142 void
144 {
145 setWaypoint->setEnabled(enable);
146 }
147
148 void
150 {
151 playPreview->setEnabled(enable);
152 }
153
154 void
155 ShortcutController::addedWaypointSlot()
156 {
157 //cannot add a waypoint while mouse is held, as programm crashes when manipulator is moved while adding waypoints
158 if (QApplication::mouseButtons() == Qt::NoButton)
159 {
160 emit addedWaypoint(currentWaypoint);
161 }
162 else
163 {
164 ARMARX_ERROR << "MOUSE HELD";
165 }
166 }
167
168 void
169 ShortcutController::deletedWaypointSlot()
170 {
171 emit deletedWaypoint(currentWaypoint);
172 }
173
174 void
175 ShortcutController::changeWaypointSlot()
176 {
177 emit changeWaypoint(currentWaypoint);
178 }
179
180 void
181 ShortcutController::playPreviewSlot()
182 {
183 emit playPreviewSignal();
184 }
185
186 void
187 ShortcutController::playPreviewAllSlot()
188 {
190 }
191
192 void
193 ShortcutController::stopPreviewSlot()
194 {
195 emit stopPreviewSignal();
196 }
197
198 void
199 ShortcutController::changedPerspectiveHighAngleSlot()
200 {
201 emit changedPerspective(0);
202 }
203
204 void
205 ShortcutController::changedPerspectiveTopSlot()
206 {
207 emit changedPerspective(1);
208 }
209
210 void
211 ShortcutController::changedPerspectiveFrontSlot()
212 {
213 emit changedPerspective(2);
214 }
215
216 void
217 ShortcutController::changedPerspectiveBackSlot()
218 {
219 emit changedPerspective(3);
220 }
221
222 void
223 ShortcutController::changedPerspectiveLeftSlot()
224 {
225 emit changedPerspective(4);
226 }
227
228 void
229 ShortcutController::changedPerspectiveRightSlot()
230 {
231 emit changedPerspective(5);
232 }
233
234 void
235 ShortcutController::undoOperation()
236 {
237 emit undo();
238 }
239
240 void
241 ShortcutController::redoOperation()
242 {
243 emit redo();
244 }
245
246 void
247 ShortcutController::enableSet()
248 {
249 this->enableAddShortcut(true);
250 }
251
252 void
253 ShortcutController::disableSet()
254 {
255 this->enableAddShortcut(false);
256 }
257} // namespace armarx
void stopPreviewSignal()
Stop the preview of all trajectories.
void playPreviewSignal()
Starts a simulation of the current Trajectory.
ShortcutController(QWidget *parent)
Creates a new ShortcutController.
void undo()
Notifies other controllers about undoing the lastly executed operation.
void addedWaypoint(int index, bool insertAfter=true)
Add a waypoint at the waypointIndex.
void changedPerspective(int perspective)
Change the perspective in the robot visualization.
void changeWaypoint(int index)
Notifies other controllers about the change of the currently selected waypoint.
void enableDeleteChangeShortcut(bool enable)
Enables or disables the delete and change shortcut.
void enableRedoShortcut(bool enable)
Enables or disables the redo shortcut.
void deletedWaypoint(int index)
Delete a waypoint at the waypointIndex.
void playPreviewAllSignal()
Plays the preview of all trajectories.
void redo()
Notifies other controllers about redoing the lastly undone operation.
void enablePreviewAllShortcut(bool enable)
Enables or disables the prview all shortcut.
void open()
Open the shortcutDialog.
void enableUndoShortcut(bool enable)
Enables or disables the undo shortcut.
void setCurrentWaypoint(int currentWaypoint)
Setter for the index of the currently selected waypoint.
int getCurrentWaypoint()
Getter for the index of the currently selected waypoint.
void enablePreviewShortcut(bool enable)
Enables or disables the prview shortcut.
void enableAddShortcut(bool enable)
Enables or disables the add shortcut.
void enableStopPreviewShortcut(bool enable)
Enables or disables the stop preview shortcut.
#define ARMARX_INFO
The normal logging level.
Definition Logging.h:181
#define ARMARX_ERROR
The logging level for unexpected behaviour, that must be fixed.
Definition Logging.h:196
This file offers overloads of toIce() and fromIce() functions for STL container types.