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;
71 TranslatedString name;
76 TranslatedString name;
78 struct ToolButtonSettings
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;
94 PhysicalCameraView(
const DynamicPointer<Camera>& camera, QWidget* parent =
nullptr);
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;
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);
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();
144 static void ResetSettingsToDefaults();
145 static Buffer<PhysicalCameraView::OutputCodec> SupportedOutputCodecs();
146 static Buffer<PhysicalCameraView::OutputMux> SupportedOutputMuxes();
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;
169 void updateCameraWindowSize();
173 void sourceChanged();
174 void networkRequestReady();
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;
188 void requestLight(
bool light_on);
189 void requestLightBrightness(fltp04 percent);
191 void windowCapturedEvent(QEvent* event);
192 void setReadyForImageCapture(
bool ready);
193 void mediaPlayingSlot();
196 void mediaStateChanged();
200 DynamicPointer<Camera> m_camera;
201 Ui::PhysicalCameraViewUI *ui;
202 WindowContainer* m_view_panel;
203 TranslatedString m_last_error;
205 String m_connecting_icon;
206 String m_screenshot_file_name;
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;
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;
238 static Dictionary<UUID, PhysicalCameraView*> s_active_logging;
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;
252 class PhysicalCameraViewFactory :
public ViewportFactory
255 virtual Buffer<PhysicalCameraView::OutputCodec> supportedOutputCodecs() {
return Buffer<PhysicalCameraView::OutputCodec>(); };
256 virtual Buffer<PhysicalCameraView::OutputMux> supportedOutputMuxes() {
return Buffer<PhysicalCameraView::OutputMux>(); };
Definition FontEditor.h:6