MIRA
TapePlayerWidget.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 by
3  * MetraLabs GmbH (MLAB), GERMANY
4  * and
5  * Neuroinformatics and Cognitive Robotics Labs (NICR) at TU Ilmenau, GERMANY
6  * All rights reserved.
7  *
8  * Contact: info@mira-project.org
9  *
10  * Commercial Usage:
11  * Licensees holding valid commercial licenses may use this file in
12  * accordance with the commercial license agreement provided with the
13  * software or, alternatively, in accordance with the terms contained in
14  * a written agreement between you and MLAB or NICR.
15  *
16  * GNU General Public License Usage:
17  * Alternatively, this file may be used under the terms of the GNU
18  * General Public License version 3.0 as published by the Free Software
19  * Foundation and appearing in the file LICENSE.GPL3 included in the
20  * packaging of this file. Please review the following information to
21  * ensure the GNU General Public License version 3.0 requirements will be
22  * met: http://www.gnu.org/copyleft/gpl.html.
23  * Alternatively you may (at your option) use any later version of the GNU
24  * General Public License if such license has been publicly approved by
25  * MLAB and NICR (or its successors, if any).
26  *
27  * IN NO EVENT SHALL "MLAB" OR "NICR" BE LIABLE TO ANY PARTY FOR DIRECT,
28  * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
29  * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF "MLAB" OR
30  * "NICR" HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  * "MLAB" AND "NICR" SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
33  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
34  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
35  * ON AN "AS IS" BASIS, AND "MLAB" AND "NICR" HAVE NO OBLIGATION TO
36  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR MODIFICATIONS.
37  */
38 
47 #ifndef _MIRA_TAPEPLAYERWIDGET_H_
48 #define _MIRA_TAPEPLAYERWIDGET_H_
49 
50 #include <QTimer>
51 #include <QCheckBox>
52 #include <QPushButton>
53 #include <QToolButton>
54 #include <QLabel>
55 #include <QSlider>
56 #include <QWidget>
57 
58 #include <fw/Framework.h>
59 #include <fw/TapeVisitor.h>
60 
61 #include <fw/GuiFwExports.h>
62 
63 namespace mira {
64 
66 
67 class TapePlayer;
68 
69 class MIRA_GUI_FW_EXPORT TapePlayerWidget : public QWidget
70 {
71  Q_OBJECT
72 public:
73 
74  TapePlayerWidget(QWidget* parent);
75  void setupUi();
76 
77  void openTapes(const QStringList& tapeFiles, boost::optional<std::vector<std::string>> channelsToPlay = boost::optional<std::vector<std::string>>());
78  void closeTapes();
79 
80 public slots:
81 
82  void open();
83  void stop();
84  void play();
85  void step();
86  void check();
87  void startJump();
88  void autoStep();
89  void pause(bool pause);
90  void moveJump(int time);
91  void jump();
92  void jumpToTime(Duration time);
93  void setSpeed(int speed);
94  void stepToChanged(bool state);
95  void autoStepToChanged(bool state);
96  void loopChanged(bool state);
97  void pauseControlChanged(bool state);
98  void selectChannels();
99 
100 signals:
101 
102  void onOpen(const QStringList& files, bool useOriginalTimestamp, const QString& namespacePrefix);
103  void onStop();
104  void onAutoStep();
105  void onPauseControl(bool pause);
106 
107 protected:
108 
109  int32 getLoopCount() const;
110  void onAutoStep(ChannelRead<void> data);
111  void onPauseControl(ChannelRead<bool> data);
112 
113 public:
114 
115  boost::shared_ptr<TapePlayer> player;
117  std::map<QString, Tape*> tapes;
118  QSlider* slider;
119  QLabel* info;
120  QToolButton* btOpen;
121  QToolButton* btStop;
122  QToolButton* btPlay;
123  QToolButton* btStep;
124  QToolButton* cbLoop;
125  QToolButton* btChannels;
126  QAction* actStep;
127  QAction* actAutoStep;
128  QAction* actPauseControl;
129  QMenu* loopMenu;
130  std::vector<QAction*> actLoopCount;
131  int32 loopCount;
132  QLabel* lblSpeed;
133  QSlider* speed;
134  QTimer checkTimer;
135 
136  QStringList lastTapes;
137  boost::optional<std::vector<std::string>> lastChannelsToPlay;
138 
139  std::string mStepToChannel;
140  std::string mAutoStepChannel;
141  std::string mPauseControlChannel;
143  std::string namespacePrefix;
145 };
146 
148 
149 }
150 
151 #endif
QToolButton * btStep
Definition: TapePlayerWidget.h:123
std::string mAutoStepChannel
Definition: TapePlayerWidget.h:140
int32 loopCount
Definition: TapePlayerWidget.h:131
std::string mStepToChannel
Definition: TapePlayerWidget.h:139
std::map< QString, Tape * > tapes
Definition: TapePlayerWidget.h:117
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
An object that allows read access to data of a channel.
Definition: ChannelReadWrite.h:435
QAction * actStep
Definition: TapePlayerWidget.h:126
Wrapper class for boost::posix_time::ptime for adding more functionality to it.
Definition: Time.h:421
TapeVisitor visitor
Definition: TapePlayerWidget.h:116
QLabel * info
Definition: TapePlayerWidget.h:119
QLabel * lblSpeed
Definition: TapePlayerWidget.h:132
boost::shared_ptr< TapePlayer > player
Definition: TapePlayerWidget.h:115
Use this class to represent time durations.
Definition: Time.h:104
std::string namespacePrefix
Definition: TapePlayerWidget.h:143
Time lastTime
Definition: TapePlayerWidget.h:144
QMenu * loopMenu
Definition: TapePlayerWidget.h:129
QAction * actAutoStep
Definition: TapePlayerWidget.h:127
Definition: TapePlayerWidget.h:69
QTimer checkTimer
Definition: TapePlayerWidget.h:134
QToolButton * btOpen
Definition: TapePlayerWidget.h:120
std::string mPauseControlChannel
Definition: TapePlayerWidget.h:141
std::vector< QAction * > actLoopCount
Definition: TapePlayerWidget.h:130
QToolButton * cbLoop
Definition: TapePlayerWidget.h:124
QSlider * speed
Definition: TapePlayerWidget.h:133
Visitor class to inspect tapes by channels and/or time interval.
Definition: TapeVisitor.h:66
#define MIRA_GUI_FW_EXPORT
Definition: GuiFwExports.h:61
QToolButton * btChannels
Definition: TapePlayerWidget.h:125
PropertyHint step(const T &step)
Sets the attribute "step" to the specified value.
Definition: PropertyHint.h:265
QSlider * slider
Definition: TapePlayerWidget.h:118
boost::optional< std::vector< std::string > > lastChannelsToPlay
Definition: TapePlayerWidget.h:137
QToolButton * btPlay
Definition: TapePlayerWidget.h:122
QStringList lastTapes
Definition: TapePlayerWidget.h:136
QToolButton * btStop
Definition: TapePlayerWidget.h:121
Class implementing a visitor concept for tapes.
The framework that holds all manager classes and provides startup and shutdown of all framework relat...
QAction * actPauseControl
Definition: TapePlayerWidget.h:128
bool useOriginalTimestamp
Definition: TapePlayerWidget.h:142