VR-Engage  2.3
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
19
20namespace makVrv
21{
22class DtDe;
23class DtQuadProxy;
24class DtChannelConfiguration;
25class DtOsgChannel;
26class DtChannel;
27class DtChannelManager;
28} // namespace makVrv
29
30namespace makVre
31{
32//! \brief Type identifier for DtBinocularsOverlay component
33constexpr const char* DtBinocularsOverlayType = "DtBinocularsOverlay";
34
35//! \brief Component for rendering binoculars reticle overlay on the screen
36//!
37//! DtBinocularsOverlay provides a specialized overlay for binoculars view,
38//! displaying reticle markings and managing post-processing effects.
39//! It handles display visibility based on player state, equipment, and view mode.
40//! The component supports both standard and VR viewing modes, automatically
41//! adjusting reticle dimensions based on viewport and zoom settings.
43{
44public:
45 //! \brief Constructor for DtBinocularsOverlay
46 //! \param className Class name for identification, defaults to "DtBinocularsOverlay"
47 //!
48 //! Initializes the component with default reticle settings
49 DtBinocularsOverlay(const std::string& className = "DtBinocularsOverlay");
50
51 //! \brief Virtual destructor for DtBinocularsOverlay
52 virtual ~DtBinocularsOverlay() override;
53
54 //! \brief Initializes the binoculars overlay component
55 //! \param player Pointer to the player station this component belongs to
56 //! \param config Configuration table containing overlay settings
57 //! \return True if initialization succeeded, false otherwise
58 //!
59 //! Reads configuration values for reticle dimensions and sets up
60 //! channel configuration change signals
62 //! \brief Performs post-initialization after all components are initialized
63 //! \return True if post-initialization succeeded, false otherwise
64 //!
65 //! Sets up VR-specific configurations if applicable and initializes
66 //! post-processing effect settings
67 virtual bool postInitialize() override;
68 //! \brief Called every frame to update the overlay state
69 //! \param dt Delta time since the last frame in seconds
70 //!
71 //! Updates visibility and manages post-processing effects
72 //! based on current overlay visibility state
73 virtual void tick(double dt) override;
74 //! \brief Shuts down the binoculars overlay component
75 //!
76 //! Disconnects signals and removes any post-processing effects
77 virtual void shutdown() override;
78
79 //! \brief Returns the type identifier for this component
80 //! \return The type string for DtBinocularsOverlay
81 virtual const char* type() const override;
82
83 //! \brief Determines if the overlay should be visible
84 //! \return True if the overlay should be visible, false otherwise
85 //!
86 //! Checks player status, health, posture, and equipment to decide
87 //! if the binoculars overlay should be shown
88 virtual bool isOverlayVisible();
89
90 //! \brief Sets the height of the binoculars reticle
91 //! \param height Height value for the reticle in screen units
92 //!
93 //! Updates the reticle height property in the QML overlay
94 void setReticleHeight(float height);
95
96protected:
97 //! \brief Calculates the dimensions of the reticle based on current view settings
98 //!
99 //! Computes reticle size based on channel projection, viewport dimensions,
100 //! and zoom settings, with special handling for VR mode
102
103 //! \brief Slot called when a channel configuration is modified
104 //! \param deName Name of the display engine
105 //! \param winName Name of the window containing the channel
106 //! \param oldChannelName Previous name of the channel
107 //! \param config New channel configuration
108 //!
109 //! Recalculates reticle dimensions when channel configuration changes
110 virtual void slot_channelConfigurationModified(const std::string& deName, const std::string& winName,
111 const std::string& oldChannelName, const makVrv::DtChannelConfiguration& config);
112
113 //! \brief Slot called when a channel is about to be destroyed
114 //! \param channelManager Pointer to the channel manager
115 //! \param channel Pointer to the channel being destroyed
116 //!
117 //! Clears the channel reference if our tracked channel is being destroyed
118 virtual void slot_channelDestroyed(makVrv::DtChannelManager* channelManager, makVrv::DtChannel* channel);
119
120 //! \brief Total size of the reticle in mils
122
123 //! \brief Flag indicating whether post-processing effects should be used
125
126 //! \brief Pointer to the channel used for rendering
127 makVrv::DtOsgChannel* myChannel;
128
129 //! \brief Cached configuration table for accessing settings during runtime
131
132 //! \brief Handle for ownship health state.
133 //! \vreAttrKey{health}
135 //! \brief Handle for observer attach mode.
136 //! \vreAttrKey{observerAttachMode}
138 //! \brief Handle for current human posture.
139 //! \vreAttrKey{posture}
141 //! \brief Handle for currently selected equipment.
142 //! \vreAttrKey{currentEquipment}
144 //! \brief Handle for launcher state.
145 //! \vreAttrKey{launcherState}
147 //! \brief Handle for aiming state.
148 //! \vreAttrKey{aiming}
150};
151} // namespace makVre
Provides handle classes for safe access to attributes.
Type-specific handle class for attributes.
Definition attributeHandle.h:229
virtual bool initialize(makVre::DtPlayerStation *player, makVre::DtInitTable &config) override
Initializes the binoculars overlay component.
DtAttributeHandleType< bool > myAimingAttr
Handle for aiming state.
Definition vreBinocularsOverlay.h:149
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.
DtAttributeHandleType< HumanPosture > myPostureAttr
Handle for current human posture.
Definition vreBinocularsOverlay.h:140
virtual void slot_channelDestroyed(makVrv::DtChannelManager *channelManager, makVrv::DtChannel *channel)
Slot called when a channel is about to be destroyed.
DtAttributeHandleType< LauncherState > myLauncherStateAttr
Handle for launcher state.
Definition vreBinocularsOverlay.h:146
DtAttributeHandleType< Equipment > myCurrentEquipmentAttr
Handle for currently selected equipment.
Definition vreBinocularsOverlay.h:143
virtual ~DtBinocularsOverlay() override
Virtual destructor for DtBinocularsOverlay.
float myReticleTotalMils
Total size of the reticle in mils.
Definition vreBinocularsOverlay.h:121
makVre::DtInitTable myConfig
Cached configuration table for accessing settings during runtime.
Definition vreBinocularsOverlay.h:130
makVrv::DtOsgChannel * myChannel
Pointer to the channel used for rendering.
Definition vreBinocularsOverlay.h:127
DtAttributeHandleType< ObserverAttachMode > myObserverAttachModeAttr
Handle for observer attach mode.
Definition vreBinocularsOverlay.h:137
DtAttributeHandleType< double > myHealthAttr
Handle for ownship health state.
Definition vreBinocularsOverlay.h:134
bool myUsePostEffect
Flag indicating whether post-processing effects should be used.
Definition vreBinocularsOverlay.h:124
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
!
Definition glsVreMessageUtil.h:50
constexpr const char * DtBinocularsOverlayType
Type identifier for DtBinocularsOverlay component.
Definition vreBinocularsOverlay.h:33
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 ...
Common enumeration definitions used throughout the VREngage system.