ShortcutController.cpp
Go to the documentation of this file.
1 #include "ShortcutController.h"
2 
3 #include "qapplication.h"
4 
5 namespace 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  {
189  emit playPreviewAllSignal();
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
armarx::ShortcutController::undo
void undo()
Notifies other controllers about undoing the lastly executed operation.
armarx::ShortcutController::stopPreviewSignal
void stopPreviewSignal()
Stop the preview of all trajectories.
armarx::ShortcutController::ShortcutController
ShortcutController(QWidget *parent)
Creates a new ShortcutController.
Definition: ShortcutController.cpp:81
armarx::ShortcutController::changedPerspective
void changedPerspective(int perspective)
Change the perspective in the robot visualization.
armarx::ShortcutController::getCurrentWaypoint
int getCurrentWaypoint()
Getter for the index of the currently selected waypoint.
Definition: ShortcutController.cpp:90
armarx::ShortcutController::onConnectComponent
void onConnectComponent() override
Definition: ShortcutController.cpp:37
armarx::ShortcutController::enableAddShortcut
void enableAddShortcut(bool enable)
Enables or disables the add shortcut.
Definition: ShortcutController.cpp:143
armarx::ShortcutController::enableDeleteChangeShortcut
void enableDeleteChangeShortcut(bool enable)
Enables or disables the delete and change shortcut.
Definition: ShortcutController.cpp:136
armarx::ShortcutController::onExitComponent
void onExitComponent() override
Definition: ShortcutController.cpp:76
armarx::ShortcutController::setCurrentWaypoint
void setCurrentWaypoint(int currentWaypoint)
Setter for the index of the currently selected waypoint.
Definition: ShortcutController.cpp:96
armarx::ShortcutController::playPreviewAllSignal
void playPreviewAllSignal()
Plays the preview of all trajectories.
ARMARX_ERROR
#define ARMARX_ERROR
Definition: Logging.h:196
armarx::ShortcutController::redo
void redo()
Notifies other controllers about redoing the lastly undone operation.
armarx::ShortcutController::onInitComponent
void onInitComponent() override
Definition: ShortcutController.cpp:8
armarx::ShortcutController::deletedWaypoint
void deletedWaypoint(int index)
Delete a waypoint at the waypointIndex.
armarx::ShortcutController::enableStopPreviewShortcut
void enableStopPreviewShortcut(bool enable)
Enables or disables the stop preview shortcut.
Definition: ShortcutController.cpp:118
armarx::ShortcutController::enableRedoShortcut
void enableRedoShortcut(bool enable)
Enables or disables the redo shortcut.
Definition: ShortcutController.cpp:124
armarx::ShortcutController::addedWaypoint
void addedWaypoint(int index, bool insertAfter=true)
Add a waypoint at the waypointIndex.
armarx::ShortcutController::enablePreviewShortcut
void enablePreviewShortcut(bool enable)
Enables or disables the prview shortcut.
Definition: ShortcutController.cpp:149
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:181
armarx::ShortcutController::playPreviewSignal
void playPreviewSignal()
Starts a simulation of the current Trajectory.
armarx::ShortcutController::open
void open()
Open the shortcutDialog.
Definition: ShortcutController.cpp:105
armarx::ShortcutController::changeWaypoint
void changeWaypoint(int index)
Notifies other controllers about the change of the currently selected waypoint.
armarx::ShortcutController::onDisconnectComponent
void onDisconnectComponent() override
Definition: ShortcutController.cpp:70
armarx::ShortcutController::enablePreviewAllShortcut
void enablePreviewAllShortcut(bool enable)
Enables or disables the prview all shortcut.
Definition: ShortcutController.cpp:112
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::ShortcutController::enableUndoShortcut
void enableUndoShortcut(bool enable)
Enables or disables the undo shortcut.
Definition: ShortcutController.cpp:130
ShortcutController.h