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>
44namespace Ui {
class PhysicalCameraViewUI; }
52 class WindowContainer;
53 class QCustomStackedWidget;
55 class PhysicalCameraViewFactory;
56 class CameraRulerMenu;
74 TranslatedString name;
79 TranslatedString name;
81 struct ToolButtonSettings
83 bool show_refresh_button =
false;
84 bool show_take_image_button =
true;
85 bool show_record_button =
true;
86 bool show_pause_record_button =
true;
87 bool show_invert_image_button =
false;
88 bool show_orient_camera_button =
true;
89 bool show_swap_camera_button =
false;
90 bool show_moveable_button =
false;
91 bool show_light_button =
false;
92 bool show_light_brightness_slider =
true;
93 bool show_zoom_button =
true;
97 PhysicalCameraView(
const DynamicPointer<Camera>& camera, QWidget* parent =
nullptr);
99 virtual ~PhysicalCameraView();
100 virtual void updateView()
override;
101 virtual void setTouchTheme(
bool touch_theme)
override;
102 virtual void setSwapMode(SwapMode mode)
override;
103 void setScreenshotPath(
const File& file) { m_screenshot_path = file; }
104 void setVideoOutputPath(
const File& file);
105 virtual void showToolRibbon(
bool show_ribbon)
override;
106 virtual void resetToolRibbon()
override;
107 virtual void startNewRecording(String file_name = String());
108 virtual void stopAndSaveRecording();
109 void mouseReleaseEvent(QMouseEvent *releaseEvent)
override;
110 void leaveEvent(QEvent* leave)
override;
111 bool event(QEvent* event)
override;
112 virtual void setIconSizeMultiplier(fltp04 multiplier)
override;
113 virtual void addWidget(
const QPointer<QWidget>& button)
override;
114 virtual void removeWidget(
const QPointer<QWidget>& button)
override;
115 void setErrorState(
bool is_in_error_state);
116 void setupForCaptureMode(
bool capture_mode);
117 void setAutoRotateCamera(
bool auto_rotate);
118 Button* lightButton()
const;
119 Button* refreshButton()
const;
120 Button* takeImageButton()
const;
121 Button* invertImageButton()
const;
123 void setLog(ProgressInfo* log);
124 ProgressInfo* log()
const {
return m_log; }
125 void setConnectingMessage(
const TranslatedString& message);
126 void setConnectingIcon(
const String& image);
127 void setErrorIcon(
const String& image);
128 void setScreenshotFileName(
const String& file_name);
129 virtual void setRecordingState(RecordingState recording_state);
130 RecordingState recordingState()
const override {
return m_recording_state; }
131 virtual QImage grabFramebuffer();
132 virtual UUID id()
const override {
return m_camera->uuid(); }
133 virtual ConstPointer<Camera> camera()
const override {
return m_camera; };
134 virtual DynamicPointer<Camera> camera()
override {
return m_camera; };
135 ToolButtonSettings buttonSettings()
const {
return m_tool_button_settings; };
136 void setButtonSettings(
const ToolButtonSettings& settings);
137 void setSettingsWidget(QWidget* settings_widget);
138 void setRecordingElapsedTime(
const TimeSpan& span);
140 File screenshotPath()
const;
141 File videoPath()
const;
142 String activeVideoMux()
const;
143 String activeCodec()
const;
144 void setLightBrightness(fltp04 percent);
145 virtual QPointer<QWidget> lightingSliderWidget();
147 static void ResetSettingsToDefaults();
148 static Buffer<PhysicalCameraView::OutputCodec> SupportedOutputCodecs();
149 static Buffer<PhysicalCameraView::OutputMux> SupportedOutputMuxes();
152 void updateCameraRotation();
153 virtual ToolButtonSettings defaultButtonSettings()
const;
154 virtual bool startRecord(
const File& file);
155 virtual bool finishRecord(File file);
156 virtual bool pauseRecord(
bool paused,
const File& file);
157 virtual bool takeImage(
const File& file);
158 virtual void refreshInstance() {}
159 virtual File recordPath(String name,
bool is_finished_recording)
const;
160 WindowContainer* windowContainer();
161 virtual void cleanup();
162 virtual int heightForWidth(
int w)
const override;
163 virtual QSize sizeHint()
const override;
164 virtual QWidget* cameraToolbar()
override;
165 virtual bool setCameraSource(
const String& camera_info);
166 virtual void handleError();
167 QCustomStackedWidget* stackedWidget()
const;
172 void updateCameraWindowSize();
176 void sourceChanged();
177 void networkRequestReady();
179 virtual void invertScreenColors(
bool invert);
180 void setExposureCompensation(
int index);
181 void processCapturedImage(
const QPixmap& img);
182 virtual void displayCurrentViewTab(QCustomStackedWidget::StackAnimationDirection = QCustomStackedWidget::e_automatic);
183 void displayFinder(QCustomStackedWidget::StackAnimationDirection = QCustomStackedWidget::e_automatic);
184 void displayCamera(QCustomStackedWidget::StackAnimationDirection = QCustomStackedWidget::e_automatic);
185 void displayError(
const TranslatedString& error, QCustomStackedWidget::StackAnimationDirection = QCustomStackedWidget::e_automatic);
186 virtual QPointer<QWidget> settingsWidget();
187 void keyPressEvent(QKeyEvent* event)
override;
188 void keyReleaseEvent(QKeyEvent* event)
override;
189 void closeEvent(QCloseEvent* event)
override;
191 void requestLight(
bool light_on);
192 void requestLightBrightness(fltp04 percent);
194 void windowCapturedEvent(QEvent* event);
195 void setReadyForImageCapture(
bool ready);
196 void mediaPlayingSlot();
199 void mediaStateChanged();
203 DynamicPointer<Camera> m_camera;
204 Ui::PhysicalCameraViewUI *ui;
205 WindowContainer* m_view_panel;
206 TranslatedString m_last_error;
208 String m_connecting_icon;
209 String m_screenshot_file_name;
211 String m_output_codec;
212 TranslatedString m_connecting_message;
213 ToolButtonSettings m_tool_button_settings;
214 QPointer<QWidget> m_settings_widget;
215 QPointer<QWidget> m_brightness_slider_widget;
216 QPointer<QCustomSlider> m_brightness_slider;
217 RecordingState m_recording_state = RecordingState::e_stopped;
218 ViewMode m_view_mode = e_loading;
219 File m_active_record_path;
220 File m_screenshot_path;
223 Toolbar* m_toolbar =
nullptr;
224 QTimer* m_timeout_timer =
nullptr;
225 ProgressInfo* m_log =
nullptr;
226 Ruler* m_side_ruler =
nullptr;
227 Ruler* m_top_ruler =
nullptr;
228 Button* m_ruler_button =
nullptr;
229 QPointer<CameraRulerMenu> m_ruler_combo;
230 bool m_is_capturing_image =
false;
231 bool m_application_exiting =
false;
232 bool m_is_black_and_white =
false;
233 bool m_is_inverted_color =
false;
234 bool m_lock_controls =
false;
235 bool m_show_edge_ruler =
false;
236 bool m_show_top_ruler =
false;
237 bool m_tool_temp_showing =
false;
238 bool m_is_in_error_state =
false;
239 bool m_is_playing =
false;
241 static Dictionary<UUID, PhysicalCameraView*> s_active_logging;
243 static ApplicationOption<bool> write_video_to_memory;
244 static Resource<File> default_screenshot_folder;
245 static Resource<File> default_video_folder;
246 static ApplicationOption<String> default_output_mux;
247 static ApplicationOption<String> default_output_codec;
248 static ApplicationOption<uint04> default_output_fps;
249 static ApplicationOption<uint04> default_output_bitrate;
250 static ApplicationOption<String> default_output_extension;
251 static ApplicationOption<String> default_camera_server_location;
252 static ApplicationOption<String> default_camera_server_password;
253 static ApplicationOption<Angle<fltp08>> default_camera_angle_offset;
255 class PhysicalCameraViewFactory :
public ViewportFactory
258 virtual Buffer<PhysicalCameraView::OutputCodec> supportedOutputCodecs() {
return Buffer<PhysicalCameraView::OutputCodec>(); };
259 virtual Buffer<PhysicalCameraView::OutputMux> supportedOutputMuxes() {
return Buffer<PhysicalCameraView::OutputMux>(); };
Definition FontEditor.h:6