API Documentation
Loading...
Searching...
No Matches
PhysicalCameraView.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Widgets
28File: PhysicalCameraView
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#if NDEVR_VIEWPORT
35#include <NDEVR/CameraView.h>
36#include <NDEVR/ViewportFactory.h>
37#include <NDEVR/QCustomStackedWidget.h>
38#include <NDEVR/Camera.h>
39#include <NDEVR/Pointer.h>
40#include <NDEVR/ApplicationOptions.h>
41#include <NDEVR/TranslatedString.h>
42#include <NDEVR/File.h>
43QT_BEGIN_NAMESPACE
44namespace Ui { class PhysicalCameraViewUI; }
45QT_END_NAMESPACE
46namespace NDEVR
47{
48 class Toolbar;
49 class Button;
50 class Ruler;
51 class ProgressInfo;
52 class WindowContainer;
53 class QCustomStackedWidget;
54 class TimeSpan;
55 class PhysicalCameraViewFactory;
56 class CameraRulerMenu;
57 class QCustomSlider;
58 class DESIGN_WIDGETS_API PhysicalCameraView : public CameraView
59 {
60 Q_OBJECT
61 public:
62 enum ViewMode
63 {
64 e_loading
65 , e_error
66 , e_camera
67 };
68 struct OutputCodec
69 {
70 String id;
71 TranslatedString name;
72 };
73 struct OutputMux
74 {
75 String id;
76 TranslatedString name;
77 };
78 struct ToolButtonSettings
79 {
80 bool show_refresh_button = false;
81 bool show_take_image_button = true;
82 bool show_record_button = true;
83 bool show_pause_record_button = true;
84 bool show_invert_image_button = false;
85 bool show_orient_camera_button = true;
86 bool show_swap_camera_button = false;
87 bool show_moveable_button = false;
88 bool show_light_button = false;
89 bool show_light_brightness_slider = true;
90 bool show_zoom_button = true;
91 };
92 protected:
93 PhysicalCameraView();
94 PhysicalCameraView(const DynamicPointer<Camera>& camera, QWidget* parent = nullptr);
95 public:
96 virtual ~PhysicalCameraView();
97 virtual void updateView() override;
98 virtual void setTouchTheme(bool touch_theme) override;
99 virtual void setSwapMode(SwapMode mode) override;
100 void setScreenshotPath(const File& file) { m_screenshot_path = file; }
101 void setVideoOutputPath(const File& file);
102 virtual void showToolRibbon(bool show_ribbon) override;
103 virtual void resetToolRibbon() override;
104 virtual void startNewRecording(String file_name = String());
105 virtual void stopAndSaveRecording();
106 void mouseReleaseEvent(QMouseEvent *releaseEvent) override;
107 void leaveEvent(QEvent* leave) override;
108 bool event(QEvent* event) override;
109 virtual void setIconSizeMultiplier(fltp04 multiplier) override;
110 virtual void addWidget(const QPointer<QWidget>& button) override;
111 virtual void removeWidget(const QPointer<QWidget>& button) override;
112 void setErrorState(bool is_in_error_state);
113 void setupForCaptureMode(bool capture_mode);
114 void setAutoRotateCamera(bool auto_rotate);
115 Button* lightButton() const;
116 Button* refreshButton() const;
117 Button* takeImageButton() const;
118 Button* invertImageButton() const;
119 void takeImage();
120 void setLog(ProgressInfo* log);
121 ProgressInfo* log() const { return m_log; }
122 void setConnectingMessage(const TranslatedString& message);
123 void setConnectingIcon(const String& image);
124 void setErrorIcon(const String& image);
125 void setScreenshotFileName(const String& file_name);
126 virtual void setRecordingState(RecordingState recording_state);
127 RecordingState recordingState() const override { return m_recording_state; }
128 virtual QImage grabFramebuffer();
129 virtual UUID id() const override { return m_camera->uuid(); }
130 virtual ConstPointer<Camera> camera() const override { return m_camera; };
131 virtual DynamicPointer<Camera> camera() override { return m_camera; };
132 ToolButtonSettings buttonSettings() const { return m_tool_button_settings; };
133 void setButtonSettings(const ToolButtonSettings& settings);
134 void setSettingsWidget(QWidget* settings_widget);
135 void setRecordingElapsedTime(const TimeSpan& span);
136 void tryToConnect();
137 File screenshotPath() const;
138 File videoPath() const;
139 String activeVideoMux() const;
140 String activeCodec() const;
141 void setLightBrightness(fltp04 percent);
142 virtual QPointer<QWidget> lightingSliderWidget();
143 public:
144 static void ResetSettingsToDefaults();
145 static Buffer<PhysicalCameraView::OutputCodec> SupportedOutputCodecs();
146 static Buffer<PhysicalCameraView::OutputMux> SupportedOutputMuxes();
147 protected:
148 void init();
149 void updateCameraRotation();
150 virtual ToolButtonSettings defaultButtonSettings() const;
151 virtual bool startRecord(const File& file);
152 virtual bool finishRecord(File file);
153 virtual bool pauseRecord(bool paused, const File& file);
154 virtual bool takeImage(const File& file);
155 virtual void refreshInstance() {}
156 virtual File recordPath(String name, bool is_finished_recording) const;
157 WindowContainer* windowContainer();
158 virtual void cleanup();
159 virtual int heightForWidth(int w) const override;
160 virtual QSize sizeHint() const override;
161 virtual QWidget* cameraToolbar() override;
162 virtual bool setCameraSource(const String& camera_info);
163 virtual void handleError();
164 QCustomStackedWidget* stackedWidget() const;
165 void startCamera();
166 void stopCamera();
167 void setupRulers();
168 void updateRulers();
169 void updateCameraWindowSize();
170 void pause();
171 void stop();
172 void setMuted(bool);
173 void sourceChanged();
174 void networkRequestReady();
175 void toggleLock();
176 virtual void invertScreenColors(bool invert);
177 void setExposureCompensation(int index);
178 void processCapturedImage(const QPixmap& img);
179 virtual void displayCurrentViewTab(QCustomStackedWidget::t_direction = QCustomStackedWidget::AUTOMATIC);
180 void displayFinder(QCustomStackedWidget::t_direction = QCustomStackedWidget::AUTOMATIC);
181 void displayCamera(QCustomStackedWidget::t_direction = QCustomStackedWidget::AUTOMATIC);
182 void displayError(const TranslatedString& error, QCustomStackedWidget::t_direction = QCustomStackedWidget::AUTOMATIC);
183 virtual QPointer<QWidget> settingsWidget();
184 void keyPressEvent(QKeyEvent* event) override;
185 void keyReleaseEvent(QKeyEvent* event) override;
186 void closeEvent(QCloseEvent* event) override;
187 signals:
188 void requestLight(bool light_on);
189 void requestLightBrightness(fltp04 percent);
190 public slots:
191 void windowCapturedEvent(QEvent* event);
192 void setReadyForImageCapture(bool ready);
193 void mediaPlayingSlot();
194 void mediaEnd();
195 void mediaOpening();
196 void mediaStateChanged();
197 void mediaStopped();
198 void mediaError();
199 protected:
200 DynamicPointer<Camera> m_camera;
201 Ui::PhysicalCameraViewUI *ui;
202 WindowContainer* m_view_panel;
203 TranslatedString m_last_error;
204 String m_error_icon;
205 String m_connecting_icon;
206 String m_screenshot_file_name;
207 String m_output_mux;
208 String m_output_codec;
209 TranslatedString m_connecting_message;
210 ToolButtonSettings m_tool_button_settings;
211 QPointer<QWidget> m_settings_widget;
212 QPointer<QWidget> m_brightness_slider_widget;
213 QPointer<QCustomSlider> m_brightness_slider;
214 RecordingState m_recording_state = RecordingState::e_stopped;
215 ViewMode m_view_mode = e_loading;
216 File m_active_record_path;
217 File m_screenshot_path;
218 File m_video_path;
219 String m_file_name;
220 Toolbar* m_toolbar = nullptr;
221 QTimer* m_timeout_timer = nullptr;
222 ProgressInfo* m_log = nullptr;
223 Ruler* m_side_ruler = nullptr;
224 Ruler* m_top_ruler = nullptr;
225 Button* m_ruler_button = nullptr;
226 QPointer<CameraRulerMenu> m_ruler_combo;
227 bool m_is_capturing_image = false;
228 bool m_application_exiting = false;
229 bool m_is_black_and_white = false;
230 bool m_is_inverted_color = false;
231 bool m_lock_controls = false;
232 bool m_show_edge_ruler = false;
233 bool m_show_top_ruler = false;
234 bool m_tool_temp_showing = false;
235 bool m_is_in_error_state = false;
236 bool m_is_playing = false;
237 public:
238 static Dictionary<UUID, PhysicalCameraView*> s_active_logging;
239 public:
240 static ApplicationOption<bool> write_video_to_memory;
241 static Resource<File> default_screenshot_folder;
242 static Resource<File> default_video_folder;
243 static ApplicationOption<String> default_output_mux;
244 static ApplicationOption<String> default_output_codec;
245 static ApplicationOption<uint04> default_output_fps;
246 static ApplicationOption<uint04> default_output_bitrate;
247 static ApplicationOption<String> default_output_extension;
248 static ApplicationOption<String> default_camera_server_location;
249 static ApplicationOption<String> default_camera_server_password;
250 static ApplicationOption<Angle<fltp08>> default_camera_angle_offset;
251 };
252 class PhysicalCameraViewFactory : public ViewportFactory
253 {
254 public:
255 virtual Buffer<PhysicalCameraView::OutputCodec> supportedOutputCodecs() { return Buffer<PhysicalCameraView::OutputCodec>(); };
256 virtual Buffer<PhysicalCameraView::OutputMux> supportedOutputMuxes() { return Buffer<PhysicalCameraView::OutputMux>(); };
257 };
258 DESIGN_WIDGETS_T_API template class DESIGN_WIDGETS_API StringStream<PhysicalCameraView::OutputMux>;
259 DESIGN_WIDGETS_T_API template class DESIGN_WIDGETS_API StringStream<PhysicalCameraView::OutputCodec>;
260}
261#endif
262
#define DESIGN_WIDGETS_API
Definition DLLInfo.h:74
#define DESIGN_WIDGETS_T_API
Definition DLLInfo.h:75
Definition ACIColor.h:37
Definition FontEditor.h:6