CAVAPA-GUI  30.5.2014
 All Classes Namespaces Functions Variables Typedefs Enumerations Pages
scenewidget.h
1 /****************************************************************************
2  * Copyright (c) 2014, Joel Kivelä, Erkki Koskenkorva, Oskari Leppäaho,
3  * Mika Lehtinen and Petri Partanen.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  * * Neither the name of the copyright holders nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
22  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 ****************************************************************************/
30 #ifndef SCENEWIDGET_H
31 #define SCENEWIDGET_H
32 
33 #include <QWidget>
34 
35 #include "ui_scenewidget.h"
36 #include "../common.h"
37 #include "../sourcesettings.h"
38 
39 namespace Ui {
40 class SceneWidget;
41 }
42 
43 namespace cavapa_gui
44 {
53 class SceneWidget : public QWidget
54 {
55  Q_OBJECT
56 public:
64  SceneWidget(SourceID sid, SourceType type, const QString& description,
65  QWidget *parent = 0);
66 
67  ~SceneWidget();
68 
74  int getCameraXRot(){ return(int)( ui->scene->getCameraXRot() * 10.0); }
75 
81  int getCameraYRot(){ return (int)(ui->scene->getCameraYRot() * 10.0); }
82 
88  int getCameraZRot(){ return (int)(ui->scene->getCameraZRot() * 10.0); }
89 
96  return (int)(ui->scene->getCameraHeight() * 100.0f);
97  }
98 
104  int getCameraFov(){ return (int)(ui->scene->getCameraFov() * 10.0); }
105 
110  SourceID getSourceID() const { return source_id; }
111 
116  void updateFrame(const FrameCapture &frame);
117 
122  void updateSettings(const SourceSettings &settings);
123 
128  cavapa::camera getCameraSettings();
129 
134  std::vector<cavapa::calibration_point> getCalibrationPoints();
135 
140  void setCalibrationPoints(std::vector<cavapa::calibration_point> points);
141 
150  {
151  ui->scene->setAddCalibrationPointsEnabled(enabled);
152  }
153 
158  void setSeekBarValue(FrameTime value);
159 
164  void showPlayButton();
165 
170  void showPauseButton();
171 
176  void setVideoLength(FrameTime frameTime);
177 
178 public slots:
179 
186  void setCameraXRot(int value);
187 
194  void setCameraYRot(int value);
195 
202  void setCameraZRot(int value);
203 
208  void setCameraHeight(int value);
209 
215  void setCameraFov(int value);
216 
221  void setDrawGridEnabled(bool enabled)
222  {
223  ui->scene->setDrawGridEnabled(enabled);
224  }
225 
231  {
232  ui->scene->setDrawCalibrationPointsEnabled(enabled);
233  }
234 
240 
245  void activateForConfiguration();
246 
247 private:
248 
249  SourceID source_id = UNDEFINED_SOURCE; // ID-number of the source
250  QString description; // Path of the source
251  Ui::SceneWidget *ui;
252  bool isPlayButtonDisplayed = true; // If false, a pause icon is
253  // displayed.
254  bool seekBarGuard1 = false ; // To avoid infinite loops
255  bool seekBarGuard2 = false ; // with the seek bar.
256 
257 signals:
263  void closeRequested(SourceID sender);
264 
270  void requestedActivation(SceneWidget* sender);
271 
276  void playRequested(SourceID sender);
277 
282  void pauseRequested(SourceID sender);
283 
289  void seekBarValueChanged(SourceID sender, FrameTime value);
290 
291 private slots:
292  void on_buttonClose_clicked();
293  void on_pushButtonSetActive_clicked();
294  void on_toolButtonPlayPause_clicked();
295  void on_horizontalSlider_valueChanged(int value);
296 };
297 } // namespace
298 
299 #endif // SCENEWIDGET_H
A widget that holds the output and media controls of a video source.
Definition: scenewidget.h:53
void setSeekBarValue(FrameTime value)
Sets the seek bar to a new value.
Definition: scenewidget.cpp:111
void setDrawCalibrationPointsEnabled(bool enabled)
Sets whether the calibration points are drawn or not.
Definition: scenewidget.h:230
void setCameraHeight(int value)
Sets the camera height.
Definition: scenewidget.cpp:138
void closeRequested(SourceID sender)
The signal is emitted when the user want's to close this source widget.
int getCameraXRot()
Returns the camera rotation around X axis.
Definition: scenewidget.h:74
unsigned int SourceID
Used to indicate unique source ID-numbers.
Definition: common.h:229
void disableForConfiguration()
Changes the frame shadow to raised and enables the "Set active" button.
Definition: scenewidget.cpp:163
void setCameraXRot(int value)
Sets the camera rotation around X axis.
Definition: scenewidget.cpp:143
const SourceID UNDEFINED_SOURCE
Used to indicate unknown sources.
Definition: common.h:234
void setCameraYRot(int value)
Sets the camera rotation around Y axis.
Definition: scenewidget.cpp:148
void requestedActivation(SceneWidget *sender)
The signal is emitted when user wants to activate this source widget for calibration.
void setVideoLength(FrameTime frameTime)
Sets video length for the seek bar.
Definition: scenewidget.cpp:133
int getCameraYRot()
Returns the camera rotation around Y axis.
Definition: scenewidget.h:81
void updateFrame(const FrameCapture &frame)
Updates the scene image.
Definition: scenewidget.cpp:59
int getCameraZRot()
Returns the camera rotation around Z axis.
Definition: scenewidget.h:88
void setCalibrationPoints(std::vector< cavapa::calibration_point > points)
Sets the calibration points.
Definition: scenewidget.cpp:95
int getCameraHeight()
Returns the camera height.
Definition: scenewidget.h:95
void pauseRequested(SourceID sender)
The signal is emitted when the user wants to pause the video.
void setCameraZRot(int value)
Sets the camera rotation around Z axis.
Definition: scenewidget.cpp:153
Represents the settings for a video source.
Definition: sourcesettings.h:46
SourceType
Available source types are the following ones: CAMERA = hardware or network camera, NOTHING = not a working source, STREAM = network stream, VIDEO = video file and VIDEOSET = set of multiple files.
Definition: common.h:68
void setDrawGridEnabled(bool enabled)
Sets whether the grid is drawn or not.
Definition: scenewidget.h:221
void updateSettings(const SourceSettings &settings)
Updates the scene settings.
Definition: scenewidget.cpp:69
std::uint64_t FrameTime
Used to store milliseconds interval in frame times.
Definition: common.h:138
cavapa::camera getCameraSettings()
Gets the camera settings.
Definition: scenewidget.cpp:64
The structure is used for storing a single source frame.
Definition: common.h:241
void setCameraFov(int value)
Sets the field of view of the camera.
Definition: scenewidget.cpp:158
void activateForConfiguration()
Changes the frame shadow to Sunken and disables the "Set active" button.
Definition: scenewidget.cpp:169
int getCameraFov()
Returns the field of view of the camera.
Definition: scenewidget.h:104
void showPlayButton()
Shows the play video button (pause button is hidden).
Definition: scenewidget.cpp:121
void showPauseButton()
Shows the pause video button (play button is hidden).
Definition: scenewidget.cpp:127
std::vector< cavapa::calibration_point > getCalibrationPoints()
Gets the calibration points.
Definition: scenewidget.cpp:74
void playRequested(SourceID sender)
The signal is emitted when the user wants to play the video.
void setAddCalibrationPointsEnabled(bool enabled)
Tells the SceneWidget whether adding calibration points is possible.
Definition: scenewidget.h:149
SceneWidget(SourceID sid, SourceType type, const QString &description, QWidget *parent=0)
Constructs a new SceneWidget with the specified information.
Definition: scenewidget.cpp:39
void seekBarValueChanged(SourceID sender, FrameTime value)
The signal is emitted when video seek bar value has changed.
SourceID getSourceID() const
Returns the ID number of the source that the scene represents.
Definition: scenewidget.h:110