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; }
175 virtual void addWidget(
const QPointer<QWidget>& button)
override;
519 Ui::PhysicalCameraViewUI *
ui;
589 DESIGN_WIDGETS_T_API
template class DESIGN_WIDGETS_API StringStream<PhysicalCameraView::OutputMux>;
590 DESIGN_WIDGETS_T_API
template class DESIGN_WIDGETS_API StringStream<PhysicalCameraView::OutputCodec>;
The default object to store data of any type that should persist through sessions of the application.
The equivelent of std::vector but with a bit more control.
Provides a constant, unmodifiable pointer that has shared ownership of a dynamically allocated object...
A hash-based key-value store, useful for quick associative lookups.
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Logic for reading or writing to a file as well as navigating filesystems or other common file operati...
A light-weight base class for Log that allows processes to update, without the need for additional in...
A light-weight wrapper that will be a no-op if there is not a valid log reference,...
Factory for creating PhysicalCameraView instances and querying supported output formats.
virtual Buffer< PhysicalCameraView::OutputCodec > supportedOutputCodecs()
Returns the list of video codecs supported by this factory.
virtual Buffer< PhysicalCameraView::OutputMux > supportedOutputMuxes()
Returns the list of container/muxer formats supported by this factory.
virtual QImage grabFramebuffer()
Captures the current frame as a QImage.
bool m_is_inverted_color
Whether the display colors are inverted.
static ApplicationOption< uint04 > default_output_bitrate
Default video output bitrate.
String m_output_codec
The active video codec identifier.
virtual void setTouchTheme(bool touch_theme) override
Enables or disables the touch-optimized theme.
void setSettingsVisible(bool visible, PopupInfo info)
Shows or hides the settings widget.
TranslatedString m_connecting_message
The message displayed while connecting.
bool m_show_top_ruler
Whether the top ruler is visible.
void keyPressEvent(QKeyEvent *event) override
Handles key press events for camera shortcuts.
virtual void stopAndSaveRecording()
Stops the current recording and saves the video file.
Button * takeImageButton() const
Returns the screenshot capture button.
void requestLightBrightness(fltp04 percent)
Emitted to request a specific light brightness level.
File screenshotPath() const
Returns the configured screenshot output path.
static ApplicationOption< bool > write_video_to_memory
Whether to buffer video in memory before writing to disk.
QPointer< CameraRulerMenu > m_ruler_combo
The ruler configuration menu widget.
static ApplicationOption< Angle< fltp08 > > default_camera_angle_offset
Default camera rotation angle offset.
void mouseReleaseEvent(QMouseEvent *releaseEvent) override
Handles mouse release events for the camera view.
static ApplicationOption< TimeSpan > default_buffer_time
Default video buffer duration.
StringView activeCodec() const
Returns the currently active codec identifier.
void stop()
Stops the camera stream completely.
void setErrorState(bool is_in_error_state)
Sets whether the camera is in an error state, updating the display accordingly.
bool m_settings_popup
Whether the settings widget displays as a popup.
virtual ConstPointer< Camera > camera() const override
Returns a read-only pointer to the Camera.
void setVideoOutputPath(const File &file)
Sets the file path used for saving recorded video.
virtual void updateView() override
Refreshes the camera view display.
void startCamera()
Starts the camera stream.
bool m_tool_temp_showing
Whether the toolbar is temporarily shown on hover.
static ApplicationOption< String > default_output_mux
Default video container/muxer format.
virtual bool pauseRecord(bool paused, const File &file)
Pauses or resumes the current recording.
void displayFinder(QCustomStackedWidget::StackAnimationDirection=QCustomStackedWidget::e_automatic)
Displays the connection/finder panel.
Button * invertImageButton() const
Returns the invert colors button.
String m_output_mux
The active video container/muxer identifier.
void sourceChanged()
Handles a change in the camera source.
virtual void init()
Initializes the UI, toolbar, and internal state after construction.
String m_screenshot_file_name
Base file name template for screenshots.
void setupRulers()
Creates and configures the measurement ruler overlays.
bool m_is_capturing_image
Whether an image capture is in progress.
virtual bool startRecord(const File &file)
Begins recording video to the specified file.
ToolButtonSettings m_tool_button_settings
Current toolbar button visibility configuration.
virtual bool setCameraSource(const StringView &camera_info)
Sets the camera source by connection string or identifier.
File videoPath() const
Returns the configured video output path.
ToolButtonSettings buttonSettings() const
Returns the current toolbar button visibility settings.
virtual QPointer< QWidget > settingsWidget()
Returns the settings widget for this camera view.
LogPtr log() const
Returns the current logger.
virtual QPointer< QWidget > lightingSliderWidget()
Returns the lighting brightness slider widget.
QPointer< QWidget > m_brightness_slider_widget
Container widget for the brightness slider.
Toolbar * m_toolbar
The camera toolbar widget.
void setScreenshotFileName(const StringView &file_name)
Sets the base file name used for screenshot files.
String m_connecting_icon
Resource identifier for the connecting state icon.
virtual void handleError()
Handles a camera error by updating the display and notifying the user.
LogPtr m_log
Logger for camera events and errors.
bool m_application_exiting
Whether the application is shutting down.
static Resource< File > default_screenshot_folder
Default folder for saving screenshots.
Button * m_ruler_button
The button to toggle ruler visibility.
virtual DynamicPointer< Camera > camera() override
Returns a mutable pointer to the Camera.
QWidget * activeWidget() const
Returns the currently active widget in the stacked display.
void mediaEnd()
Slot called when media playback reaches the end.
virtual void displayCurrentViewTab(QCustomStackedWidget::StackAnimationDirection=QCustomStackedWidget::e_automatic)
Switches to the appropriate view tab based on the current view mode.
void stopCamera()
Stops the camera stream.
virtual QSize sizeHint() const override
Returns the recommended size for this widget.
void updateRulers()
Updates the ruler display to match the current zoom and position.
void setMuted(bool)
Mutes or unmutes the audio from the camera stream.
virtual void setRecordingState(RecordingState recording_state)
Sets the video recording state and updates the UI accordingly.
void mediaError()
Slot called when a media playback error occurs.
TranslatedString m_last_error
The most recent error message.
bool m_is_black_and_white
Whether the display is in black and white mode.
static Buffer< PhysicalCameraView::OutputMux > SupportedOutputMuxes()
Returns a list of all container/muxer formats supported by the current backend.
void setupForCaptureMode(bool capture_mode)
Configures the view for image capture mode, adjusting UI elements.
void updateCameraRotation()
Updates the camera rotation based on device orientation or user settings.
virtual void addWidget(const QPointer< QWidget > &button) override
Adds an overlay widget to the camera view.
QTimer * m_timeout_timer
Timer for connection timeout detection.
virtual void cleanup()
Performs cleanup of camera resources before destruction.
bool event(QEvent *event) override
Processes a Qt event.
virtual QWidget * cameraToolbar() override
Returns the camera toolbar widget.
void leaveEvent(QEvent *leave) override
Handles the mouse leaving the widget area.
void takeImage()
Captures a screenshot from the current camera frame.
PhysicalCameraView()
Default constructor for subclass use only.
virtual bool finishRecord(File file)
Finalizes a recording and saves the output file.
bool m_lock_controls
Whether the camera controls are locked.
String m_error_icon
Resource identifier for the error state icon.
static void ResetSettingsToDefaults()
Resets all camera-related application settings to their defaults.
virtual ToolButtonSettings defaultButtonSettings() const
Returns the default toolbar button visibility settings for this camera type.
virtual void refreshInstance()
Refreshes the camera instance, reconnecting if needed.
virtual void startNewRecording(StringView file_name=StringView())
Begins a new video recording session.
Ruler * m_side_ruler
The side measurement ruler overlay.
void displayCamera(QCustomStackedWidget::StackAnimationDirection=QCustomStackedWidget::e_automatic)
Displays the live camera panel.
void mediaStopped()
Slot called when media playback is stopped.
static Resource< File > default_video_folder
Default folder for saving recorded videos.
void setReadyForImageCapture(bool ready)
Sets whether the camera is ready to capture an image.
void tryToConnect()
Attempts to establish a connection to the camera source.
DynamicPointer< Camera > m_camera
The camera being displayed.
virtual bool takeImage(const File &file)
Captures a single image and saves it to the specified file.
void networkRequestReady()
Handles a completed network request for the camera stream.
void setButtonSettings(const ToolButtonSettings &settings)
Applies new toolbar button visibility settings.
void setErrorIcon(const StringView &image)
Sets the icon shown when the camera is in an error state.
static Buffer< PhysicalCameraView::OutputCodec > SupportedOutputCodecs()
Returns a list of all video codecs supported by the current backend.
Button * refreshButton() const
Returns the refresh/reconnect button.
ViewMode
Describes the current display mode of the camera view.
@ e_loading
The camera is loading or connecting.
@ e_error
An error occurred with the camera stream.
@ e_camera
The camera stream is actively displayed.
void requestLight(bool light_on)
Emitted to request turning the camera light on or off.
void displayError(const TranslatedString &error, QCustomStackedWidget::StackAnimationDirection=QCustomStackedWidget::e_automatic)
Displays the error panel with a message.
virtual void setIconSizeMultiplier(fltp04 multiplier) override
Sets a multiplier for toolbar icon sizes.
static Dictionary< UUID, PhysicalCameraView * > s_active_logging
Registry of camera views with active logging.
QCustomStackedWidget * stackedWidget() const
Returns the stacked widget used for switching between view panels.
void mediaOpening()
Slot called when media is opening/buffering.
ViewMode m_view_mode
The current display mode of the view.
bool m_is_in_error_state
Whether the camera is in an error state.
void closeEvent(QCloseEvent *event) override
Handles the widget close event, performing cleanup.
virtual void showToolRibbon(bool show_ribbon) override
Shows or hides the tool ribbon overlay.
QPointer< QCustomSlider > m_brightness_slider
The slider controlling light brightness.
void pause()
Pauses the camera stream playback.
static ApplicationOption< uint04 > default_output_fps
Default video output frames per second.
virtual File recordPath(StringView name, bool is_finished_recording) const
Computes the file path for a recording.
void toggleLock()
Toggles the lock state of the camera controls.
QPointer< QWidget > m_settings_widget
The optional settings widget for camera configuration.
virtual void setSwapMode(SwapMode mode) override
Sets the buffer swap mode for rendering.
virtual int heightForWidth(int w) const override
Returns the preferred height for the given width, maintaining aspect ratio.
String m_file_name
The current recording file name.
virtual void removeWidget(const QPointer< QWidget > &button) override
Removes an overlay widget from the camera view.
fltp08 maxZoomOut() const
Returns the maximum zoom-out factor for this camera.
void mediaPlayingSlot()
Slot called when media playback begins.
void windowCapturedEvent(QEvent *event)
Handles events forwarded from the embedded window container.
void setLightBrightness(fltp04 percent)
Sets the brightness level of the camera light.
virtual void resetToolRibbon() override
Resets the tool ribbon to its default configuration.
void setConnectingIcon(const StringView &image)
Sets the icon shown while the camera is connecting.
static ApplicationOption< String > default_camera_server_location
Default camera server URL or address.
virtual UUID id() const override
Returns the unique identifier for this camera view.
void setRecordingElapsedTime(const TimeSpan &span)
Updates the displayed recording elapsed time.
WindowContainer * m_view_panel
The container holding the camera rendering surface.
File m_video_path
The directory path for saving videos.
static ApplicationOption< String > default_camera_server_password
Default camera server password.
PhysicalCameraView(const DynamicPointer< Camera > &camera, QWidget *parent=nullptr)
Constructs a PhysicalCameraView for the given camera.
void processCapturedImage(const QPixmap &img)
Processes a captured image for saving or display.
RecordingState recordingState() const override
Returns the current recording state.
void updateCameraWindowSize()
Resizes the camera rendering surface to match the widget dimensions.
RecordingState m_recording_state
The current video recording state.
bool m_show_edge_ruler
Whether the side ruler is visible.
File m_screenshot_path
The directory path for saving screenshots.
void mediaStateChanged()
Slot called when the media player state changes.
Button * lightButton() const
Returns the light toggle button.
QWidget * stack() const
Returns the stacked widget used for switching between view modes.
bool m_is_playing
Whether the camera stream is currently playing.
virtual void invertScreenColors(bool invert)
Inverts the screen colors for the camera display.
void setConnectingMessage(const TranslatedString &message)
Sets the message displayed while the camera is connecting.
Ui::PhysicalCameraViewUI * ui
The auto-generated UI form.
void setAutoRotateCamera(bool auto_rotate)
Enables or disables automatic camera rotation based on device orientation.
StringView activeVideoMux() const
Returns the currently active video muxer identifier.
void setExposureCompensation(int index)
Sets the exposure compensation level.
Ruler * m_top_ruler
The top measurement ruler overlay.
void setLog(LogPtr log)
Sets the logger for this camera view.
File m_active_record_path
The file path of the active recording.
WindowContainer * windowContainer() const
Returns the window container holding the camera rendering surface.
void setSettingsWidget(QWidget *settings_widget, bool is_popup=false)
Sets a custom settings widget for camera configuration.
void keyReleaseEvent(QKeyEvent *event) override
Handles key release events.
static ApplicationOption< String > default_output_extension
Default video file extension.
static ApplicationOption< String > default_output_codec
Default video codec.
void setScreenshotPath(const File &file)
Sets the file path used for saving screenshots.
The slider is the classic widget for controlling a bounded value.
A core part of the engine, stores variables that can be listened to with ResourceListener which will ...
A widget meant to be placed beside a camera view showing either directional or measurement markings d...
The core String View class for the NDEVR API.
The core String class for the NDEVR API.
Stores a time span, or difference between two times, with an optional start time.
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
A service which can generate Viewports based on Camera data.
A (hacky) class for storing a window into a container.
The primary namespace for the NDEVR SDK.
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
double fltp08
Defines an alias representing an 8 byte floating-point number.
@ guid
A 128-bit globally unique identifier for the object.
@ file
The source file path associated with this object.
Describes a video output codec with an identifier and display name.
TranslatedString name
The user-facing display name of the codec.
String id
The internal codec identifier string.
Describes a video output muxer/container format with an identifier and display name.
String id
The internal muxer identifier string.
TranslatedString name
The user-facing display name of the muxer.