MMMPlayerGuiPlugin.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 Lesser General Public License as
6 * published by the Free Software Foundation; either version 2 of
7 * the License, or (at your option) any later version.
8 *
9 * ArmarX is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * @package ArmarX::Component::ObjectExaminerGuiPlugin
18 * @author Nikolaus Vahrenkamp ( vahrenkamp at kit dot edu)
19 * @copyright 2012
20 * @license http://www.gnu.org/licenses/gpl.txt
21 * GNU General Public License
22 
23 */
24 
25 #pragma once
26 
27 /* ArmarX headers */
28 #include <RobotComponents/gui-plugins/MMMPlayerPlugin/ui_MMMPlayerGuiPlugin.h>
29 
30 #include "MMMPlayerConfigDialog.h"
37 
39 
40 /* Qt headers */
41 #include <QMainWindow>
42 #include <QTimer>
43 #include <RobotComponents/interface/components/MMMPlayerInterface.h>
44 
45 
46 #include <RobotAPI/interface/components/TrajectoryPlayerInterface.h>
48 
49 #include <string>
50 #include <QLayout>
51 #include <QFileDialog>
52 #include <QListWidget>
53 
54 
55 
56 namespace armarx
57 {
58  class MMMPlayerConfigDialog;
59 
60  /*!
61  \class MMMPlayerGuiPlugin
62  \brief This plugin provides a widget with which the MMMPlayer can be controlled.
63 
64  \see MMMPlayerWidget
65  */
67  public ArmarXGuiPlugin
68  {
69  Q_OBJECT
70  Q_INTERFACES(ArmarXGuiInterface)
71  Q_PLUGIN_METADATA(IID "ArmarXGuiInterface/1.00")
72  public:
74  QString getPluginName() override
75  {
76  return "MMMPlayerGuiPlugin";
77  }
78  };
79 
80  /*!
81  \class MMMPlayerWidget
82  \brief With this widget the MMMPlayer can be controlled.
83 
84  \ingroup RobotAPI-ArmarXGuiPlugins ArmarXGuiPlugins
85  \see MMMPlayerGuiPlugin
86  */
88  public ArmarXComponentWidgetControllerTemplate<MMMPlayerWidget>
89  {
90  Q_OBJECT
91  public:
94  {}
95 
96  // inherited from Component
97  void onInitComponent() override;
98  void onConnectComponent() override;
99  void onExitComponent() override;
100  void onDisconnectComponent() override;
101 
102  // inherited of ArmarXWidget
103  static QString GetWidgetName()
104  {
105  return "RobotControl.MMMPlayerGUI";
106  }
107  static QIcon GetWidgetIcon()
108  {
109  return QIcon(":icons/MMM.png");
110  }
111 
112  QPointer<QDialog> getConfigDialog(QWidget* parent = 0) override
113  {
114  if (!dialog)
115  {
116  dialog = new MMMPlayerConfigDialog(parent);
117  }
118 
119  return qobject_cast<MMMPlayerConfigDialog*>(dialog);
120 
121  }
122 
123  bool onClose() override;
124 
125 
126 
127  void loadSettings(QSettings* settings) override;
128  void saveSettings(QSettings* settings) override;
129  // void configured();
130 
131  void startComponent();
132  void loadTrajPlayer();
133  void setSpeed(double value);
134  signals:
135 
136  private slots:
137 
138  void on_initializeButton_clicked();
139 
140  void on_startButton_clicked();
141 
142  void on_previewButton_clicked();
143 
144  void on_pauseButton_clicked();
145 
146  void on_stopButton_clicked();
147 
148  void configFileSelected();
149 
150  void updateSlider();
151 
152  void setupJointList();
153 
154  void setupMotionList();
155 
156  void on_loopPlayback_toggled(bool state);
157 
158  void jointListChanged(QListWidgetItem* joint);
159 
160  void motionChanged(int);
161 
162  void on_spinBoxFPS_valueChanged(double value);
163 
164  void on_controlMode_changed(int controlMode);
165 
166  void on_enableRobotPoseUnit_toggled(bool state);
167 
168  protected:
169  void connectSlots();
170 
171  std::string configFile;
172  Ui::MMMPlayerGuiPlugin ui;
173  MMMPlayerInterfacePrx MMMLoader;
174  TrajectoryPlayerInterfacePrx trajPlayer;
175  private:
176  QPointer<QWidget> __widget;
177  QPointer<MMMPlayerConfigDialog> dialog;
178  QFileDialog* fileDialog2;
179  QListWidget* jointList;
180 
181  QTimer* updateTimer;
182  bool isComponentCreated;
183  };
184  //using MMMPlayerGuiPluginPtr = boost::shared_ptr<MMMPlayerWidget>;
185 }
186 
armarx::MMMPlayerWidget::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: MMMPlayerGuiPlugin.cpp:100
armarx::MMMPlayerWidget::onExitComponent
void onExitComponent() override
Hook for subclass.
Definition: MMMPlayerGuiPlugin.cpp:165
armarx::MMMPlayerWidget::getConfigDialog
QPointer< QDialog > getConfigDialog(QWidget *parent=0) override
getConfigDialog returns a pointer to the a configuration widget of this controller.
Definition: MMMPlayerGuiPlugin.h:112
armarx::MMMPlayerWidget::startComponent
void startComponent()
armarx::MMMPlayerWidget::setSpeed
void setSpeed(double value)
Definition: MMMPlayerGuiPlugin.cpp:246
armarx::MMMPlayerWidget::~MMMPlayerWidget
~MMMPlayerWidget()
Definition: MMMPlayerGuiPlugin.h:93
armarx::ArmarXGuiPlugin
Definition: ArmarXGuiPlugin.h:46
armarx::MMMPlayerWidget::onClose
bool onClose() override
If you overwrite this method, make sure to call this implementation at the end of your implementation...
Definition: MMMPlayerGuiPlugin.cpp:173
MMMPlayerConfigDialog.h
armarx::MMMPlayerWidget::onDisconnectComponent
void onDisconnectComponent() override
Hook for subclass.
Definition: MMMPlayerGuiPlugin.cpp:169
armarx::MMMPlayerWidget::MMMLoader
MMMPlayerInterfacePrx MMMLoader
Definition: MMMPlayerGuiPlugin.h:173
armarx::ArmarXComponentWidgetControllerTemplate
Definition: ArmarXComponentWidgetController.h:69
Observer.h
RobotAPIObjectFactories.h
armarx::MMMPlayerWidget::ui
Ui::MMMPlayerGuiPlugin ui
Definition: MMMPlayerGuiPlugin.h:172
ArmarXGuiInterface
The main gui interface.
Definition: ArmarXGuiInterface.h:74
ArmarXGuiPlugin.h
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
ArmarXComponentWidgetController.h
armarx::MMMPlayerWidget::configFile
std::string configFile
Definition: MMMPlayerGuiPlugin.h:171
armarx::MMMPlayerGuiPlugin
This plugin provides a widget with which the MMMPlayer can be controlled.
Definition: MMMPlayerGuiPlugin.h:66
armarx::MMMPlayerWidget::connectSlots
void connectSlots()
Definition: MMMPlayerGuiPlugin.cpp:214
armarx::MMMPlayerWidget::MMMPlayerWidget
MMMPlayerWidget()
Definition: MMMPlayerGuiPlugin.cpp:61
armarx::MMMPlayerWidget::loadTrajPlayer
void loadTrajPlayer()
Definition: MMMPlayerGuiPlugin.cpp:202
Component.h
armarx::MMMPlayerGuiPlugin::MMMPlayerGuiPlugin
MMMPlayerGuiPlugin()
Definition: MMMPlayerGuiPlugin.cpp:56
armarx::MMMPlayerWidget::saveSettings
void saveSettings(QSettings *settings) override
Implement to save the settings as part of the GUI configuration.
Definition: MMMPlayerGuiPlugin.cpp:198
Trajectory.h
armarx::MMMPlayerWidget::loadSettings
void loadSettings(QSettings *settings) override
Implement to load the settings that are part of the GUI configuration.
Definition: MMMPlayerGuiPlugin.cpp:193
armarx::MMMPlayerWidget::trajPlayer
TrajectoryPlayerInterfacePrx trajPlayer
Definition: MMMPlayerGuiPlugin.h:174
armarx::MMMPlayerGuiPlugin::getPluginName
QString getPluginName() override
Definition: MMMPlayerGuiPlugin.h:74
armarx::MMMPlayerWidget::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: MMMPlayerGuiPlugin.cpp:142
armarx::MMMPlayerWidget::GetWidgetIcon
static QIcon GetWidgetIcon()
Definition: MMMPlayerGuiPlugin.h:107
Logging.h
armarx::MMMPlayerWidget::GetWidgetName
static QString GetWidgetName()
Definition: MMMPlayerGuiPlugin.h:103
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::MMMPlayerWidget
With this widget the MMMPlayer can be controlled.
Definition: MMMPlayerGuiPlugin.h:87
Application.h
armarx::MMMPlayerConfigDialog
Definition: MMMPlayerConfigDialog.h:39