VR-Engage  2.3
Loading...
Searching...
No Matches
vreBinocularsLasingOverlay.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file vreBinocularsLasingOverlay.h
7//! \brief Component for binoculars with laser ranging functionality
8//! \ingroup vreCommonComponents
9
10#pragma once
11
13
16
18
20
21#include <makArchives/DtDisplayUnitsSettingsRecord.h>
22
23// #include <vrvUtil/DtUnicode.h>
24
25namespace makVrv
26{
27class DtIntersector;
28}
29
30namespace makVre
31{
32//! \brief Type identifier for DtBinocularsLasingOverlay component
33constexpr const char* DtBinocularsLasingOverlayType = "DtBinocularsLasingOverlay";
34
35//! \brief Component that extends binoculars with laser target designation and ranging functionality
36//!
37//! DtBinocularsLasingOverlay extends the basic binoculars overlay with laser ranging capabilities,
38//! providing measurement and display of target location, elevation, azimuth, and range information.
39//! It updates formatted display values for sensor location, target data, and north reference
40//! settings. The overlay maintains target data for a configurable period after lasing stops.
42{
43public:
44 //! \brief Constructor for DtBinocularsLasingOverlay
45 //!
46 //! Initializes the component with default settings
48
49 //! \brief Virtual destructor for DtBinocularsLasingOverlay
50 //!
51 //! Cleans up resources including the intersector object
52 virtual ~DtBinocularsLasingOverlay() override;
53
54 //! \brief Initializes the binoculars lasing 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 //! Sets up the intersector, initializes attribute state values, and registers message handlers
61 //! \brief Shuts down the binoculars lasing overlay component
62 //!
63 //! Removes message handlers and performs base class shutdown
64 virtual void shutdown() override;
65
66 //! \brief Returns the type identifier for this component
67 //! \return The type string for DtBinocularsLasingOverlay
68 virtual const char* type() const override;
69
70 //! \brief Performs post-initialization after all components are initialized
71 //! \return True if post-initialization succeeded, false otherwise
72 //!
73 //! Configures VR-specific settings if necessary
74 virtual bool postInitialize() override;
75 //! \brief Called every frame to update the overlay state
76 //! \param dt Delta time since the last frame in seconds
77 //!
78 //! Updates current time, sensor data, north reference, target data,
79 //! and handles target data expiration if necessary
80 virtual void tick(double dt) override;
81
82 //! \brief Determines if the overlay should be visible
83 //! \return True if the overlay should be visible, false otherwise
84 //!
85 //! Checks menu state, base overlay visibility, and laser availability
86 //! to determine if the overlay should be displayed
87 virtual bool isOverlayVisible() override;
88
89protected:
90 //! \brief Handles stop lasing messages
91 //! \param msg Stop lasing message
92 //! \return Message handling result indicating if the message was handled
93 //!
94 //! Sets target data to expire 30 seconds after lasing stops
96
97 //! \brief Updates sensor location and elevation attributes
98 //!
99 //! Updates the following attributes:
100 //! - lasing.sensorLocation.formatted: MGRS ten-digit grid (e.g. "11S GN 01234 56789")
101 //! - lasing.sensorElevation.formatted: Elevation in meters MSL (e.g. "EL 01234 m MSL")
102 virtual void updateSensorData();
103
104 //! \brief Updates the north reference attribute
105 //!
106 //! Updates lasing.northReference.formatted attribute with current north
107 //! reference setting ("MAG", "TRUE", or "GRID")
108 virtual void updateNorthReference();
109
110 //! \brief Updates the time of target location attribute
111 //!
112 //! Updates lasing.timeOfTargetLocation.formatted attribute with current time in HH:MM:SS format
114
115 //! \brief Updates all target-related attributes based on current lasing state
116 //!
117 //! Updates the following attributes when lasing is active:
118 //! - lasing.targetLocation.formatted: MGRS ten-digit grid (e.g. "11S GN 01234 56789")
119 //! - lasing.targetElevationMSL.formatted: Elevation in meters MSL (e.g. "EL 01234 m MSL")
120 //! - lasing.targetRange.formatted: Range in meters (e.g. "RNG 01234 m")
121 //! - lasing.targetElevation.formatted: Elevation in NATO MILS (e.g. "ELA 0123 MIL")
122 //! - lasing.targetAzimuth.formatted: Azimuth in NATO MILS (e.g. "AZ 0123 MIL")
123 //! - lasing.elrfStatus.formatted: "ELRF IDLE" or "GET TGT LOCATION" based on lasing state
124 virtual void updateTargetData();
125
126 //! \brief Generates a formatted time string for the current time
127 //! \return String containing the current time in HH:MM:SS format
128 virtual std::string timeString();
129
130 //! \brief Sets all target data attributes to null or default values
131 //!
132 //! Resets all target-related attributes to their default state when
133 //! target data expires or becomes invalid
134 virtual void clearTargetData();
135
136 //! \brief Calculates elevation and azimuth from observer to target
137 //! \param geocentricObserverLocation Observer position in geocentric coordinates
138 //! \param geocentricIntersectionPoint Target position in geocentric coordinates
139 //! \param targetElevation Pointer to store calculated elevation angle in radians
140 //! \param targetAzimuth Pointer to store calculated azimuth angle in radians
141 //!
142 //! Transforms positions to topocentric coordinates and calculates
143 //! elevation and azimuth angles, considering the current north reference setting
144 virtual void calculateElevationAndAzimuthToTarget(const DtVector& geocentricObserverLocation,
145 const DtVector& geocentricIntersectionPoint, double* targetElevation, double* targetAzimuth);
146
147protected:
148 //! \brief Current simulation time in seconds
150
151 //! \brief Time when observer-to-target distance was last calculated
153
154 //! \brief Time when target data will expire
156
157 //! \brief Intersector for performing raycasting to determine target position
158 makVrv::DtIntersector* myIntersector;
159
160 //! \brief Last known north units setting for detecting changes
161 makArchives::DtDisplayUnitsSettingsRecord::NorthUnits myLastNorthUnits;
162
163 //! \brief Last known local ownship position for detecting changes
165
166 //! \brief Last known geocentric position of laser intersection point
168
169 //! \brief Handle for formatted binocular time text.
170 //! \vreAttrKey{binoculars.timeString}
172 //! \brief Handle for formatted lasing sensor location text.
173 //! \vreAttrKey{lasing.sensorLocation}
175 //! \brief Handle for formatted lasing sensor elevation text.
176 //! \vreAttrKey{lasing.sensorElevation}
178 //! \brief Handle for the lasing north reference text.
179 //! \vreAttrKey{lasing.northReference}
181 //! \brief Handle for the ELRF status text.
182 //! \vreAttrKey{lasing.elrfStatus}
184 //! \brief Handle for formatted lasing target location text.
185 //! \vreAttrKey{lasing.targetLocation}
187 //! \brief Handle for formatted lasing target MSL elevation text.
188 //! \vreAttrKey{lasing.targetElevationMSL}
190 //! \brief Handle for formatted lasing target range text.
191 //! \vreAttrKey{lasing.targetRange}
193 //! \brief Handle for formatted lasing target elevation text.
194 //! \vreAttrKey{lasing.targetElevation}
196 //! \brief Handle for formatted lasing target azimuth text.
197 //! \vreAttrKey{lasing.targetAzimuth}
199 //! \brief Handle for time-of-target-location text.
200 //! \vreAttrKey{lasing.timeOfTargetLocation}
202 //! \brief Handle for laser active state.
203 //! \vreAttrKey{laserOn}
205 //! \brief Handle for observer location in geocentric coordinates.
206 //! \vreAttrKey{observerLocation}
208 //! \brief Handle indicating whether the observer currently has a laser.
209 //! \vreAttrKey{HasLaser}
211 //! \brief Handle for the global entity resolver attribute.
212 //! \vreAttrKey{DtEntityResolver}
214};
215} // namespace makVre
Provides handle classes for safe access to attributes.
Type-specific handle class for attributes.
Definition attributeHandle.h:229
DtAttributeHandleType< std::string > myLasingTargetElevationMSLAttr
Handle for formatted lasing target MSL elevation text.
Definition vreBinocularsLasingOverlay.h:189
virtual void updateSensorData()
Updates sensor location and elevation attributes.
virtual void updateTimeOfTargetLocation()
Updates the time of target location attribute.
double myTimeLastObserverToTargetDistanceCalculated
Time when observer-to-target distance was last calculated.
Definition vreBinocularsLasingOverlay.h:152
DtAttributeHandleType< std::string > myLasingSensorLocationAttr
Handle for formatted lasing sensor location text.
Definition vreBinocularsLasingOverlay.h:174
DtAttributeHandleType< bool > myHasLaserAttr
Handle indicating whether the observer currently has a laser.
Definition vreBinocularsLasingOverlay.h:210
DtAttributeHandleType< std::string > myLasingNorthReferenceAttr
Handle for the lasing north reference text.
Definition vreBinocularsLasingOverlay.h:180
DtAttributeHandleType< bool > myLaserOnAttr
Handle for laser active state.
Definition vreBinocularsLasingOverlay.h:204
DtAttributeHandleType< std::string > myLasingElrfStatusAttr
Handle for the ELRF status text.
Definition vreBinocularsLasingOverlay.h:183
virtual void tick(double dt) override
Called every frame to update the overlay state.
DtAttributeHandleType< std::string > myBinocularsTimeStringAttr
Handle for formatted binocular time text.
Definition vreBinocularsLasingOverlay.h:171
virtual makVre::DtVreMessageResult handleStopLasingMessage(makVre::DtVreMessage *msg)
Handles stop lasing messages.
virtual bool initialize(makVre::DtPlayerStation *player, makVre::DtInitTable &config) override
Initializes the binoculars lasing overlay component.
DtBinocularsLasingOverlay()
Constructor for DtBinocularsLasingOverlay.
virtual std::string timeString()
Generates a formatted time string for the current time.
makVrv::DtIntersector * myIntersector
Intersector for performing raycasting to determine target position.
Definition vreBinocularsLasingOverlay.h:158
virtual void shutdown() override
Shuts down the binoculars lasing overlay component.
DtVector myLastLocalOwnshipPosition
Last known local ownship position for detecting changes.
Definition vreBinocularsLasingOverlay.h:164
makArchives::DtDisplayUnitsSettingsRecord::NorthUnits myLastNorthUnits
Last known north units setting for detecting changes.
Definition vreBinocularsLasingOverlay.h:161
DtAttributeHandleType< std::string > myLasingTargetLocationAttr
Handle for formatted lasing target location text.
Definition vreBinocularsLasingOverlay.h:186
virtual const char * type() const override
Returns the type identifier for this component.
virtual void updateTargetData()
Updates all target-related attributes based on current lasing state.
virtual void clearTargetData()
Sets all target data attributes to null or default values.
DtAttributeHandleType< std::string > myLasingSensorElevationAttr
Handle for formatted lasing sensor elevation text.
Definition vreBinocularsLasingOverlay.h:177
virtual bool isOverlayVisible() override
Determines if the overlay should be visible.
DtAttributeHandleType< std::string > myLasingTimeOfTargetLocationAttr
Handle for time-of-target-location text.
Definition vreBinocularsLasingOverlay.h:201
DtAttributeHandleType< std::string > myLasingTargetRangeAttr
Handle for formatted lasing target range text.
Definition vreBinocularsLasingOverlay.h:192
virtual void calculateElevationAndAzimuthToTarget(const DtVector &geocentricObserverLocation, const DtVector &geocentricIntersectionPoint, double *targetElevation, double *targetAzimuth)
Calculates elevation and azimuth from observer to target.
double myCurrentTime
Current simulation time in seconds.
Definition vreBinocularsLasingOverlay.h:149
virtual bool postInitialize() override
Performs post-initialization after all components are initialized.
DtAttributeHandleType< DtVector > myObserverLocationAttr
Handle for observer location in geocentric coordinates.
Definition vreBinocularsLasingOverlay.h:207
virtual ~DtBinocularsLasingOverlay() override
Virtual destructor for DtBinocularsLasingOverlay.
virtual void updateNorthReference()
Updates the north reference attribute.
DtAttributeHandleType< std::string > myLasingTargetAzimuthAttr
Handle for formatted lasing target azimuth text.
Definition vreBinocularsLasingOverlay.h:198
DtAttributeHandleType< makVre::DtEntityResolver * > myEntityResolverAttr
Handle for the global entity resolver attribute.
Definition vreBinocularsLasingOverlay.h:213
double myTargetDataExpirationTime
Time when target data will expire.
Definition vreBinocularsLasingOverlay.h:155
DtVector myLastGeocentricIntersectionPoint
Last known geocentric position of laser intersection point.
Definition vreBinocularsLasingOverlay.h:167
DtAttributeHandleType< std::string > myLasingTargetElevationAttr
Handle for formatted lasing target elevation text.
Definition vreBinocularsLasingOverlay.h:195
DtBinocularsOverlay(const std::string &className="DtBinocularsOverlay")
Constructor for DtBinocularsOverlay.
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
Abstract base class for all VREngage messages.
Definition vreMessage.h:50
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 * DtBinocularsLasingOverlayType
Type identifier for DtBinocularsLasingOverlay component.
Definition vreBinocularsLasingOverlay.h:33
DtVreMessageResult
Enumeration of possible message handling results.
Definition vreMessage.h:33
Definition appLauncherComponent.h:28
Defines the DtPlayerComponent base class for VR-Engage role components.
Component for displaying binoculars reticle overlay.
Defines the base class for all VREngage messages.