MIRA
TapeRecorderWidget.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_TAPERECORDERWIDGET_H_
48 #define _MIRA_TAPERECORDERWIDGET_H_
49 
50 #include <QTimer>
51 #include <QDialog>
52 #include <QDialogButtonBox>
53 #include <QLabel>
54 #include <QPushButton>
55 #include <QToolButton>
56 #include <QTableWidget>
57 #include <QTimeEdit>
58 #include <QWidget>
59 #include <QCheckBox>
60 
61 #include <serialization/adapters/std/list>
62 
63 #include <fw/TapeRecorder.h>
64 
65 #include <widgets/PropertyEditor.h>
66 
67 namespace mira {
68 
70 
74 class CodecDialog : public QDialog
75 {
76  Q_OBJECT
77 
78 public:
79 
80  CodecDialog(QWidget* parent = NULL);
81  ~CodecDialog();
82 
83  void setCodecs(std::list<BinarySerializerCodecPtr>& codecs);
84  std::list<BinarySerializerCodecPtr> getCodecs();
85 
86 public slots:
87 
88  void addRemove();
89 
90 protected:
91 
93 
94  std::map<std::string, std::pair<BinarySerializerCodecPtr, boost::shared_ptr<PropertyNode>>> mCodecs;
96  QDialogButtonBox* mButtonBox;
97 };
98 
100 
104 class CodecWidget : public QWidget
105 {
106  Q_OBJECT
107 public:
108 
109  CodecWidget(QWidget* parent=NULL);
110 
111  void setCodecs(const std::list<BinarySerializerCodecPtr>& codecs);
112  std::list<BinarySerializerCodecPtr> getCodecs();
113 
114 public slots:
115 
116  void selectCodecs();
117 
118 protected:
119 
120  std::list<BinarySerializerCodecPtr> mCodecs;
121  QLabel* mTextLbl;
122 };
123 
125 
129 class DurationDialog : public QDialog
130 {
131  Q_OBJECT
132 
133 public:
134 
135  DurationDialog(QWidget* parent = NULL);
136 
137  void setDuration(const Duration& duration);
139 
140 protected:
141 
142  QTimeEdit* mTimeEdit;
143  QDialogButtonBox* mButtonBox;
144 };
145 
146 
148 
152 class TapeRecorderWidget : public QWidget
153 {
154  Q_OBJECT
155 
156 public:
157 
159 
160  template <typename Reflector>
161  void reflect(Reflector& r)
162  {
163  r.member("Channels", mChannels,
164  "Channels to record", std::map<std::string, RecordedChannelInfo>());
165  r.member("RecordTransforms", mRecordTransforms,
166  "Record transform frames to tape", true);
167  r.member("SaveTransformsFile", mSaveTransformsFile,
168  "Save transform tree to extra file", true);
169  }
170 
171  std::map<std::string, RecordedChannelInfo> mChannels;
174  };
175 
176 public:
177 
178  TapeRecorderWidget(QWidget* parent = NULL);
179 
180  void addChannel(const std::string& channelID, const RecordedChannelInfo& codecs=RecordedChannelInfo());
181  void recordTransforms(bool recordTransformChannels = true, bool saveTransformsFile = true);
183 
184 signals:
185  void recordingStarted();
186 
187 public slots:
188 
189  void record();
190  void recordDuration();
191  void stop();
192  void check();
193  void saveTransformsToggled(bool on);
194  void add();
195  void remove();
196  void removeAll();
197  void updateStats();
198 
199 protected:
200 
201  int findButton(int column);
202  virtual void dragEnterEvent(QDragEnterEvent *event);
203  virtual void dropEvent(QDropEvent *event);
204  void saveTransformTree(const Path& file);
205 
206 protected:
207 
208  boost::shared_ptr<TapeRecorder> mRecorder;
209  std::set<std::string> mRecordedChannels;
210 
211  QTableWidget* mChannels;
213  QLabel* mInfo;
214  QPushButton* mBtAdd;
215  QPushButton* mBtRemove;
216  QToolButton* mBtRecord;
217  QToolButton* mBtRecordDuration;
218  QToolButton* mBtStop;
221 
222  QTimer mCheckTimer;
223  QTimer mStatsTimer;
225 
227 };
228 
230 
231 }
232 
233 #endif
void addCodec(BinarySerializerCodecPtr codec)
QDialogButtonBox * mButtonBox
Definition: TapeRecorderWidget.h:96
int findButton(int column)
QTimer mStatsTimer
Definition: TapeRecorderWidget.h:223
void saveTransformTree(const Path &file)
The recorder widget.
Definition: TapeRecorderWidget.h:152
void addChannel(const std::string &channelID, const RecordedChannelInfo &codecs=RecordedChannelInfo())
std::list< BinarySerializerCodecPtr > getCodecs()
Duration getDuration()
void setCodecs(const std::list< BinarySerializerCodecPtr > &codecs)
PropertyHint file(const std::string &filters=std::string(), bool save=false)
Tells the property editor that the path is for a file, and that it should show a "File Open"/"File Sa...
Definition: Path.h:230
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
boost::filesystem::path Path
Typedef of a Path (shorter version for boost::filesystem::path)
Definition: Path.h:69
QToolButton * mBtRecordDuration
Definition: TapeRecorderWidget.h:217
void recordTransforms(bool recordTransformChannels=true, bool saveTransformsFile=true)
QTimer mAutoStopTimer
Definition: TapeRecorderWidget.h:224
void reflect(Reflector &r)
Definition: TapeRecorderWidget.h:161
void setDuration(const Duration &duration)
QTimeEdit * mTimeEdit
Definition: TapeRecorderWidget.h:142
bool mSaveTransformsFile
Definition: TapeRecorderWidget.h:173
void setCodecs(std::list< BinarySerializerCodecPtr > &codecs)
QTimer mCheckTimer
Definition: TapeRecorderWidget.h:222
QTableWidget * mChannels
Definition: TapeRecorderWidget.h:211
A dialog for selecting a duration.
Definition: TapeRecorderWidget.h:129
bool mRecordTransforms
Definition: TapeRecorderWidget.h:172
CodecDialog(QWidget *parent=NULL)
boost::shared_ptr< TapeRecorder > mRecorder
Definition: TapeRecorderWidget.h:208
Wrapper class for boost::posix_time::ptime for adding more functionality to it.
Definition: Time.h:418
TapeRecorderWidget(QWidget *parent=NULL)
virtual void dropEvent(QDropEvent *event)
QLabel * mTextLbl
Definition: TapeRecorderWidget.h:121
Class for recording data to tape.
DurationDialog(QWidget *parent=NULL)
QToolButton * mBtStop
Definition: TapeRecorderWidget.h:218
Duration mRecordDuration
Definition: TapeRecorderWidget.h:226
RecordingConfig getRecordingConfig()
QCheckBox * mChkRecTransformsChans
Definition: TapeRecorderWidget.h:220
QToolButton * mBtRecord
Definition: TapeRecorderWidget.h:216
Use this class to represent time durations.
Definition: Time.h:106
std::list< BinarySerializerCodecPtr > getCodecs()
QPushButton * mBtAdd
Definition: TapeRecorderWidget.h:214
virtual void dragEnterEvent(QDragEnterEvent *event)
QPushButton * mBtRemove
Definition: TapeRecorderWidget.h:215
QCheckBox * mChkSvTransformsFile
Definition: TapeRecorderWidget.h:219
QLabel * mInfo
Definition: TapeRecorderWidget.h:213
Time mStartTime
Definition: TapeRecorderWidget.h:212
Contains all settings for a recorded channel like compression, codecs,...
Definition: TapeRecorder.h:62
void saveTransformsToggled(bool on)
std::list< BinarySerializerCodecPtr > mCodecs
Definition: TapeRecorderWidget.h:120
Declaration of PropertyEditor.
Definition: PropertyEditor.h:73
std::map< std::string, RecordedChannelInfo > mChannels
Definition: TapeRecorderWidget.h:171
Definition: TapeRecorderWidget.h:158
std::set< std::string > mRecordedChannels
Definition: TapeRecorderWidget.h:209
QDialogButtonBox * mButtonBox
Definition: TapeRecorderWidget.h:143
std::map< std::string, std::pair< BinarySerializerCodecPtr, boost::shared_ptr< PropertyNode > > > mCodecs
Definition: TapeRecorderWidget.h:94
CodecWidget(QWidget *parent=NULL)
PropertyEditor * mEditor
Definition: TapeRecorderWidget.h:95
A dialog for adding, removing and editing codecs.
Definition: TapeRecorderWidget.h:74
Widget for displaying used codecs and changing them via a dialog.
Definition: TapeRecorderWidget.h:104
boost::shared_ptr< BinarySerializerCodec > BinarySerializerCodecPtr
Shared pointer of BinarySerializerCodec.
Definition: BinarySerializerCodec.h:64