ToolBarController.cpp
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::ToolBarController
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 #include "ToolBarController.h"
23 
24 namespace armarx
25 {
26  void
28  {
29  ARMARX_INFO << "RobotTrajectoryDesigner: ToolBarController on init";
31  enableAddButton(false);
32  enablePreviewButton(false);
34  enableStopButton(false);
35  }
36 
37  void
39  {
40  ARMARX_INFO << "RobotTrajectoryDesigner: ToolBarController on connect";
41 
42  // Set waypoint: clicked
43  QObject::connect(guiToolbar.get()->getToolBar()->setWaypointButton,
44  SIGNAL(clicked()),
45  this,
46  SLOT(setWaypoint()));
47 
48  // Delete waypoint: clicked
49  QObject::connect(guiToolbar.get()->getToolBar()->deleteWaypointButton,
50  SIGNAL(clicked()),
51  this,
52  SLOT(deleteWaypoint()));
53 
54  // Change Waypoint: clicked
55  QObject::connect(guiToolbar.get()->getToolBar()->changeWaypointButton,
56  SIGNAL(clicked()),
57  this,
58  SLOT(changeWaypoint()));
59 
60  // Play preview: clicked
61  QObject::connect(guiToolbar.get()->getToolBar()->playPreviewButton,
62  SIGNAL(clicked()),
63  this,
64  SLOT(playPreview()));
65 
66  // Play all preview: clicked
67  QObject::connect(guiToolbar.get()->getToolBar()->playPreviewAllButton,
68  SIGNAL(clicked()),
69  this,
70  SLOT(playAllPreview()));
71 
72  // Stop preview: clicked
73  QObject::connect(guiToolbar.get()->getToolBar()->stopPreviewButton,
74  SIGNAL(clicked()),
75  this,
76  SLOT(stopPreview()));
77  }
78 
79  void
81  {
82  ARMARX_INFO << "RobotTrajectoryDesigner: ToolBarController on disconnect";
83  }
84 
85  void
87  {
88  ARMARX_INFO << "RobotTrajectoryDesigner: ToolBarController on exit";
89  }
90 
92  guiToolbar(guiToolbar), currentWaypoint(0)
93  {
96  }
97 
100  {
101  return this->guiToolbar;
102  }
103 
104  void
106  {
107  this->guiToolbar = guiToolbar;
108  }
109 
110  int
112  {
113  return this->currentWaypoint;
114  }
115 
116  void
118  {
119  if (currentWaypoint >= 0)
120  {
121  this->currentWaypoint = currentWaypoint;
122  }
123  }
124 
125  void
126  ToolBarController::setWaypoint()
127  {
128  emit addedWaypoint(this->currentWaypoint);
129  }
130 
131  void
132  ToolBarController::deleteWaypoint()
133  {
134  emit deletedWaypoint(this->currentWaypoint);
135  }
136 
137  void
138  ToolBarController::changeWaypoint()
139  {
140  emit changeWaypoint(this->currentWaypoint);
141  }
142 
143  void
144  ToolBarController::playAllPreview()
145  {
146  emit notifyAllPreview();
147  }
148 
149  void
150  ToolBarController::playPreview()
151  {
152  emit notifyPreview();
153  }
154 
155  void
156  ToolBarController::stopPreview()
157  {
158  emit notifyStopPreview();
159  }
160 
161  void
163  {
164  throw("not yet implemented");
165  }
166 
167  void
169  {
170  guiToolbar->getToolBar()->changeWaypointButton->setEnabled(enable);
171  guiToolbar->getToolBar()->deleteWaypointButton->setEnabled(enable);
172  }
173 
174  void
176  {
177  guiToolbar->getToolBar()->setWaypointButton->setEnabled(enable);
178  }
179 
180  void
182  {
183  guiToolbar->getToolBar()->playPreviewAllButton->setEnabled(enable);
184  }
185 
186  void
188  {
189  guiToolbar->getToolBar()->playPreviewButton->setEnabled(enable);
190  }
191 
192  void
194  {
195  guiToolbar->getToolBar()->stopPreviewButton->setEnabled(enable);
196  }
197 
198 } // namespace armarx
armarx::ToolBarController::retranslateGui
void retranslateGui()
Retranslates the guiToolbar.
Definition: ToolBarController.cpp:162
armarx::ToolBarController::onExitComponent
void onExitComponent() override
Definition: ToolBarController.cpp:86
ToolBarController.h
armarx::ToolBarController::enableDeleteChangeButton
void enableDeleteChangeButton(bool enable)
Enables or disables the delete and change button.
Definition: ToolBarController.cpp:168
armarx::ToolBarController::addedWaypoint
void addedWaypoint(int index, bool insertAfter=true)
Notifies other controllers about the addition of a waypoint at the current position of the TCP contro...
armarx::ToolBarController::onDisconnectComponent
void onDisconnectComponent() override
Definition: ToolBarController.cpp:80
armarx::ToolBarController::deletedWaypoint
void deletedWaypoint(int index)
Notifies other controllers about the deletion of the currently selected waypoint.
armarx::ToolBarController::setCurrentWaypoint
void setCurrentWaypoint(int currentWaypoint)
Setter for the index of the currently selected waypoint.
Definition: ToolBarController.cpp:117
armarx::ToolBarController::getCurrentWaypoint
int getCurrentWaypoint()
Getter for the index of the currently selected waypoint.
Definition: ToolBarController.cpp:111
armarx::ToolBarController::enablePreviewAllButton
void enablePreviewAllButton(bool enable)
Enables or disables the prview all button.
Definition: ToolBarController.cpp:181
armarx::ToolBarController::setGuiToolbar
void setGuiToolbar(ToolBarPtr guiToolbar)
Setter for the ToolBar pointer to guiToolbar.
Definition: ToolBarController.cpp:105
armarx::ToolBarController::enableStopButton
void enableStopButton(bool enable)
Enables or disables the prview all button.
Definition: ToolBarController.cpp:193
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:181
armarx::ToolBarController::onConnectComponent
void onConnectComponent() override
Definition: ToolBarController.cpp:38
armarx::ToolBarController::notifyStopPreview
void notifyStopPreview()
stop the preview of the trajectories
armarx::ToolBarController::enableAddButton
void enableAddButton(bool enable)
Enables or disables the add button.
Definition: ToolBarController.cpp:175
armarx::ToolBarController::onInitComponent
void onInitComponent() override
Definition: ToolBarController.cpp:27
armarx::ToolBarController::enablePreviewButton
void enablePreviewButton(bool enable)
Enables or disables the prview button.
Definition: ToolBarController.cpp:187
armarx::ToolBarController::getGuiToolbar
ToolBarPtr getGuiToolbar()
Getter for the ToolBar pointer to guiToolbar.
Definition: ToolBarController.cpp:99
armarx::ToolBarController::notifyAllPreview
void notifyAllPreview()
Plays the preview of all trajectories.
armarx::ToolBarController::ToolBarController
ToolBarController(ToolBarPtr guiToolbar)
Creates a new ToolBarController and assigns a ToolBar to handle.
Definition: ToolBarController.cpp:91
ToolBarPtr
std::shared_ptr< ToolBar > ToolBarPtr
Definition: ToolBar.h:52
armarx::ToolBarController::notifyPreview
void notifyPreview()
Plays the preview of the current trajectory.
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27