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