ShortcutController.cpp
Go to the documentation of this file.
1 #include "ShortcutController.h"
2 #include "qapplication.h"
3 namespace armarx
4 {
6  {
7  deactivateSetWaypoint = new QShortcut(QKeySequence(Qt::LeftButton), this->parent);
8  setWaypoint = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_S), this->parent);
9  deleteWaypoint = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_D), this->parent);
10  changeWaypointShortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this->parent);
11  playPreview = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_R), this->parent);
12  playPreviewAll = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_A), this->parent);
13  stopPreview = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_F), this->parent);
14  undoShortcut = new QShortcut(QKeySequence::Undo, this->parent);
15  redoShortcut = new QShortcut(QKeySequence::Redo, this->parent);
16  setPerspectiveHighAngle = new QShortcut(QKeySequence(Qt::Key_1), this->parent);
17  setPerspectiveTop = new QShortcut(QKeySequence(Qt::Key_2), this->parent);
18  setPerspectiveFront = new QShortcut(QKeySequence(Qt::Key_3), this->parent);
19  setPerspectiveBack = new QShortcut(QKeySequence(Qt::Key_4), this->parent);
20  setPerspectiveLeft = new QShortcut(QKeySequence(Qt::Key_5), this->parent);
21  setPerspectiveRight = new QShortcut(QKeySequence(Qt::Key_6), this->parent);
22  setWaypoint->setEnabled(false);
23  deleteWaypoint->setEnabled(false);
24  changeWaypointShortcut->setEnabled(false);
25  playPreview->setEnabled(false);
26  playPreviewAll->setEnabled(false);
27  stopPreview->setEnabled(false);
28  shortcutDialog = new QDialog;
29  ui.setupUi(shortcutDialog);
30  ARMARX_INFO << "RobotTrajectoryDesigner: ShortcutController on init";
31  }
32 
34  {
35  //Connects Gui
36  QObject::connect(ui.okButton, SIGNAL(clicked()), shortcutDialog, SLOT(accept()));
37  //Connects Shortcuts
38  QObject::connect(deactivateSetWaypoint, SIGNAL(activated()), this, SLOT(disableSet()));
39  QObject::connect(setWaypoint, SIGNAL(activated()), this, SLOT(addedWaypointSlot()));
40  QObject::connect(deleteWaypoint, SIGNAL(activated()), this, SLOT(deletedWaypointSlot()));
41  QObject::connect(changeWaypointShortcut, SIGNAL(activated()), this, SLOT(changeWaypointSlot()));
42  QObject::connect(playPreview, SIGNAL(activated()), this, SLOT(playPreviewSlot()));
43  QObject::connect(playPreviewAll, SIGNAL(activated()), this, SLOT(playPreviewAllSlot()));
44  QObject::connect(stopPreview, SIGNAL(activated()), this, SLOT(stopPreviewSlot()));
45  QObject::connect(setPerspectiveTop, SIGNAL(activated()), this, SLOT(changedPerspectiveTopSlot()));
46  QObject::connect(setPerspectiveFront, SIGNAL(activated()), this, SLOT(changedPerspectiveFrontSlot()));
47  QObject::connect(setPerspectiveBack, SIGNAL(activated()), this, SLOT(changedPerspectiveBackSlot()));
48  QObject::connect(setPerspectiveLeft, SIGNAL(activated()), this, SLOT(changedPerspectiveLeftSlot()));
49  QObject::connect(setPerspectiveRight, SIGNAL(activated()), this, SLOT(changedPerspectiveRightSlot()));
50  QObject::connect(setPerspectiveHighAngle, SIGNAL(activated()), this, SLOT(changedPerspectiveHighAngleSlot()));
51  QObject::connect(undoShortcut, SIGNAL(activated()), this, SLOT(undoOperation()));
52  QObject::connect(redoShortcut, SIGNAL(activated()), this, SLOT(redoOperation()));
53  ARMARX_INFO << "RobotTrajectoryDesigner: ShortcutController on connect";
54  }
55 
57  {
58  ARMARX_INFO << "RobotTrajectoryDesigner: ShortcutController on disconnect";
59  }
60 
62  {
63  ARMARX_INFO << "RobotTrajectoryDesigner: ShortcutController on exit";
64  }
65 
67  {
68  currentWaypoint = 0;
69  this->parent = parent;
72  }
73 
75  {
76  return currentWaypoint;
77  }
78 
79  void ShortcutController::setCurrentWaypoint(int currentWaypoint)
80  {
81  if (currentWaypoint >= 0)
82  {
83  this->currentWaypoint = currentWaypoint;
84  }
85  }
86 
88  {
89  shortcutDialog->setModal(true);
90  shortcutDialog->exec();
91  }
92 
94  {
95  playPreviewAll->setEnabled(enable);
96  }
97 
99  {
100  stopPreview->setEnabled(enable);
101  }
102 
104  {
105  redoShortcut->setEnabled(enable);
106  }
107 
109  {
110  undoShortcut->setEnabled(enable);
111  }
112 
114  {
115  deleteWaypoint->setEnabled(enable);
116  changeWaypointShortcut->setEnabled(enable);
117  }
118 
120  {
121  setWaypoint->setEnabled(enable);
122  }
123 
125  {
126  playPreview->setEnabled(enable);
127  }
128 
129  void ShortcutController::addedWaypointSlot()
130  {
131  //cannot add a waypoint while mouse is held, as programm crashes when manipulator is moved while adding waypoints
132  if (QApplication::mouseButtons() == Qt::NoButton)
133  {
134  emit addedWaypoint(currentWaypoint);
135  }
136  else
137  {
138  ARMARX_ERROR << "MOUSE HELD";
139  }
140  }
141 
142  void ShortcutController::deletedWaypointSlot()
143  {
144  emit deletedWaypoint(currentWaypoint);
145  }
146 
147  void ShortcutController::changeWaypointSlot()
148  {
149  emit changeWaypoint(currentWaypoint);
150  }
151 
152  void ShortcutController::playPreviewSlot()
153  {
154  emit playPreviewSignal();
155  }
156 
157  void ShortcutController::playPreviewAllSlot()
158  {
159  emit playPreviewAllSignal();
160  }
161 
162  void ShortcutController::stopPreviewSlot()
163  {
164  emit stopPreviewSignal();
165  }
166 
167  void ShortcutController::changedPerspectiveHighAngleSlot()
168  {
169  emit changedPerspective(0);
170  }
171 
172  void ShortcutController::changedPerspectiveTopSlot()
173  {
174  emit changedPerspective(1);
175  }
176 
177  void ShortcutController::changedPerspectiveFrontSlot()
178  {
179  emit changedPerspective(2);
180  }
181 
182  void ShortcutController::changedPerspectiveBackSlot()
183  {
184  emit changedPerspective(3);
185  }
186 
187  void ShortcutController::changedPerspectiveLeftSlot()
188  {
189  emit changedPerspective(4);
190  }
191 
192  void ShortcutController::changedPerspectiveRightSlot()
193  {
194  emit changedPerspective(5);
195  }
196 
197  void ShortcutController::undoOperation()
198  {
199  emit undo();
200  }
201 
202  void ShortcutController::redoOperation()
203  {
204  emit redo();
205  }
206 
207  void ShortcutController::enableSet()
208  {
209  this->enableAddShortcut(true);
210  }
211 
212  void ShortcutController::disableSet()
213  {
214  this->enableAddShortcut(false);
215  }
216 }
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:66
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:74
armarx::ShortcutController::onConnectComponent
void onConnectComponent() override
Definition: ShortcutController.cpp:33
armarx::ShortcutController::enableAddShortcut
void enableAddShortcut(bool enable)
Enables or disables the add shortcut.
Definition: ShortcutController.cpp:119
armarx::ShortcutController::enableDeleteChangeShortcut
void enableDeleteChangeShortcut(bool enable)
Enables or disables the delete and change shortcut.
Definition: ShortcutController.cpp:113
armarx::ShortcutController::onExitComponent
void onExitComponent() override
Definition: ShortcutController.cpp:61
armarx::ShortcutController::setCurrentWaypoint
void setCurrentWaypoint(int currentWaypoint)
Setter for the index of the currently selected waypoint.
Definition: ShortcutController.cpp:79
armarx::ShortcutController::playPreviewAllSignal
void playPreviewAllSignal()
Plays the preview of all trajectories.
ARMARX_ERROR
#define ARMARX_ERROR
Definition: Logging.h:189
armarx::ShortcutController::redo
void redo()
Notifies other controllers about redoing the lastly undone operation.
armarx::ShortcutController::onInitComponent
void onInitComponent() override
Definition: ShortcutController.cpp:5
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:98
armarx::ShortcutController::enableRedoShortcut
void enableRedoShortcut(bool enable)
Enables or disables the redo shortcut.
Definition: ShortcutController.cpp:103
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:124
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
armarx::ShortcutController::playPreviewSignal
void playPreviewSignal()
Starts a simulation of the current Trajectory.
armarx::ShortcutController::open
void open()
Open the shortcutDialog.
Definition: ShortcutController.cpp:87
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:56
armarx::ShortcutController::enablePreviewAllShortcut
void enablePreviewAllShortcut(bool enable)
Enables or disables the prview all shortcut.
Definition: ShortcutController.cpp:93
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::ShortcutController::enableUndoShortcut
void enableUndoShortcut(bool enable)
Enables or disables the undo shortcut.
Definition: ShortcutController.cpp:108
ShortcutController.h