VR-Engage  2.2
Loading...
Searching...
No Matches
vreBinocularsOverlay.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file vreBinocularsOverlay.h
7//! \brief Component for displaying binoculars reticle overlay
8//! \ingroup vreCommonComponents
9
10#pragma once
11
14
16
17namespace makVrv
18{
19class DtDe;
20class DtQuadProxy;
21class DtChannelConfiguration;
22class DtOsgChannel;
23class DtChannel;
24class DtChannelManager;
25} // namespace makVrv
26
27namespace makVre
28{
29//! \brief Type identifier for DtBinocularsOverlay component
30constexpr const char* DtBinocularsOverlayType = "DtBinocularsOverlay";
31
32//! \brief Component for rendering binoculars reticle overlay on the screen
33//!
34//! DtBinocularsOverlay provides a specialized overlay for binoculars view,
35//! displaying reticle markings and managing post-processing effects.
36//! It handles display visibility based on player state, equipment, and view mode.
37//! The component supports both standard and VR viewing modes, automatically
38//! adjusting reticle dimensions based on viewport and zoom settings.
40{
41public:
42 //! \brief Constructor for DtBinocularsOverlay
43 //! \param className Class name for identification, defaults to "DtBinocularsOverlay"
44 //!
45 //! Initializes the component with default reticle settings
46 DtBinocularsOverlay(const std::string& className = "DtBinocularsOverlay");
47
48 //! \brief Virtual destructor for DtBinocularsOverlay
49 virtual ~DtBinocularsOverlay() override;
50
51 //! \brief Initializes the binoculars overlay component
52 //! \param player Pointer to the player station this component belongs to
53 //! \param config Configuration table containing overlay settings
54 //! \return True if initialization succeeded, false otherwise
55 //!
56 //! Reads configuration values for reticle dimensions and sets up
57 //! channel configuration change signals
59 //! \brief Performs post-initialization after all components are initialized
60 //! \return True if post-initialization succeeded, false otherwise
61 //!
62 //! Sets up VR-specific configurations if applicable and initializes
63 //! post-processing effect settings
64 virtual bool postInitialize() override;
65 //! \brief Called every frame to update the overlay state
66 //! \param dt Delta time since the last frame in seconds
67 //!
68 //! Updates visibility and manages post-processing effects
69 //! based on current overlay visibility state
70 virtual void tick(double dt) override;
71 //! \brief Shuts down the binoculars overlay component
72 //!
73 //! Disconnects signals and removes any post-processing effects
74 virtual void shutdown() override;
75
76 //! \brief Returns the type identifier for this component
77 //! \return The type string for DtBinocularsOverlay
78 virtual const char* type() const override;
79
80 //! \brief Determines if the overlay should be visible
81 //! \return True if the overlay should be visible, false otherwise
82 //!
83 //! Checks player status, health, posture, and equipment to decide
84 //! if the binoculars overlay should be shown
85 virtual bool isOverlayVisible();
86
87 //! \brief Sets the height of the binoculars reticle
88 //! \param height Height value for the reticle in screen units
89 //!
90 //! Updates the reticle height property in the QML overlay
91 void setReticleHeight(float height);
92
93 //! \brief Sets the visibility state of the overlay
94 //! \param visible True to show the overlay, false to hide it
95 //!
96 //! Updates the visible property in the QML overlay
97 void setVisible(bool visible);
98
99protected:
100 //! \brief Calculates the dimensions of the reticle based on current view settings
101 //!
102 //! Computes reticle size based on channel projection, viewport dimensions,
103 //! and zoom settings, with special handling for VR mode
105
106 //! \brief Slot called when a channel configuration is modified
107 //! \param deName Name of the display engine
108 //! \param winName Name of the window containing the channel
109 //! \param oldChannelName Previous name of the channel
110 //! \param config New channel configuration
111 //!
112 //! Recalculates reticle dimensions when channel configuration changes
113 virtual void slot_channelConfigurationModified(const std::string& deName, const std::string& winName,
114 const std::string& oldChannelName, const makVrv::DtChannelConfiguration& config);
115
116 //! \brief Slot called when a channel is about to be destroyed
117 //! \param channelManager Pointer to the channel manager
118 //! \param channel Pointer to the channel being destroyed
119 //!
120 //! Clears the channel reference if our tracked channel is being destroyed
121 virtual void slot_channelDestroyed(makVrv::DtChannelManager* channelManager, makVrv::DtChannel* channel);
122
123 //! \brief Total size of the reticle in mils
125
126 //! \brief Flag indicating whether post-processing effects should be used
128
129 //! \brief Pointer to the channel used for rendering
130 makVrv::DtOsgChannel* myChannel;
131
132 //! \brief Cached configuration table for accessing settings during runtime
134};
135} // namespace makVre
virtual bool initialize(makVre::DtPlayerStation *player, makVre::DtInitTable &config) override
Initializes the binoculars overlay component.
virtual void slot_channelConfigurationModified(const std::string &deName, const std::string &winName, const std::string &oldChannelName, const makVrv::DtChannelConfiguration &config)
Slot called when a channel configuration is modified.
virtual void computeReticleDimensions()
Calculates the dimensions of the reticle based on current view settings.
virtual void tick(double dt) override
Called every frame to update the overlay state.
virtual bool postInitialize() override
Performs post-initialization after all components are initialized.
virtual const char * type() const override
Returns the type identifier for this component.
void setReticleHeight(float height)
Sets the height of the binoculars reticle.
virtual void slot_channelDestroyed(makVrv::DtChannelManager *channelManager, makVrv::DtChannel *channel)
Slot called when a channel is about to be destroyed.
virtual ~DtBinocularsOverlay() override
Virtual destructor for DtBinocularsOverlay.
float myReticleTotalMils
Total size of the reticle in mils.
Definition vreBinocularsOverlay.h:124
makVre::DtInitTable myConfig
Cached configuration table for accessing settings during runtime.
Definition vreBinocularsOverlay.h:133
void setVisible(bool visible)
Sets the visibility state of the overlay.
makVrv::DtOsgChannel * myChannel
Pointer to the channel used for rendering.
Definition vreBinocularsOverlay.h:130
bool myUsePostEffect
Flag indicating whether post-processing effects should be used.
Definition vreBinocularsOverlay.h:127
virtual bool isOverlayVisible()
Determines if the overlay should be visible.
DtBinocularsOverlay(const std::string &className="DtBinocularsOverlay")
Constructor for DtBinocularsOverlay.
virtual void shutdown() override
Shuts down the binoculars overlay component.
Table-based access to Lua state for configuration data.
Definition initializer.h:38
virtual DtPlayerStation & player()
Gets the player station.
Class for managing the user interface for engaged roles.
Definition playerStation.h:51
DtQtQuickOverlay()
Constructor for DtQtQuickOverlay.
Defines export/import macros for the vreCommonComponents library.
#define VRECOMMONCOMPONENTS_DLL
DLL export/import macro for the vreCommonComponents library.
Definition export.h:28
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
constexpr const char * DtBinocularsOverlayType
Type identifier for DtBinocularsOverlay component.
Definition vreBinocularsOverlay.h:30
Definition appLauncherComponent.h:28
Defines the DtPlayerComponent base class for VR-Engage role components.
Contains DtQtQuickOverlay class which provides a Qt Quick overlay component for rendering 2D UI over ...