VR-Engage  2.2
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
19#include <makArchives/DtDisplayUnitsSettingsRecord.h>
20
21// #include <vrvUtil/DtUnicode.h>
22
23namespace makVrv
24{
25class DtIntersector;
26}
27
28namespace makVre
29{
30//! \brief Type identifier for DtBinocularsLasingOverlay component
31constexpr const char* DtBinocularsLasingOverlayType = "DtBinocularsLasingOverlay";
32
33//! \brief Component that extends binoculars with laser target designation and ranging functionality
34//!
35//! DtBinocularsLasingOverlay extends the basic binoculars overlay with laser ranging capabilities,
36//! providing measurement and display of target location, elevation, azimuth, and range information.
37//! It updates formatted display values for sensor location, target data, and north reference
38//! settings. The overlay maintains target data for a configurable period after lasing stops.
40{
41public:
42 //! \brief Constructor for DtBinocularsLasingOverlay
43 //!
44 //! Initializes the component with default settings
46
47 //! \brief Virtual destructor for DtBinocularsLasingOverlay
48 //!
49 //! Cleans up resources including the intersector object
50 virtual ~DtBinocularsLasingOverlay() override;
51
52 //! \brief Initializes the binoculars lasing overlay component
53 //! \param player Pointer to the player station this component belongs to
54 //! \param config Configuration table containing overlay settings
55 //! \return True if initialization succeeded, false otherwise
56 //!
57 //! Sets up the intersector, initializes attribute state values, and registers message handlers
59 //! \brief Shuts down the binoculars lasing overlay component
60 //!
61 //! Removes message handlers and performs base class shutdown
62 virtual void shutdown() override;
63
64 //! \brief Returns the type identifier for this component
65 //! \return The type string for DtBinocularsLasingOverlay
66 virtual const char* type() const override;
67
68 //! \brief Performs post-initialization after all components are initialized
69 //! \return True if post-initialization succeeded, false otherwise
70 //!
71 //! Configures VR-specific settings if necessary
72 virtual bool postInitialize() override;
73 //! \brief Called every frame to update the overlay state
74 //! \param dt Delta time since the last frame in seconds
75 //!
76 //! Updates current time, sensor data, north reference, target data,
77 //! and handles target data expiration if necessary
78 virtual void tick(double dt) 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 menu state, base overlay visibility, and laser availability
84 //! to determine if the overlay should be displayed
85 virtual bool isOverlayVisible() override;
86
87protected:
88 //! \brief Handles stop lasing messages
89 //! \param msg Stop lasing message
90 //! \return Message handling result indicating if the message was handled
91 //!
92 //! Sets target data to expire 30 seconds after lasing stops
94
95 //! \brief Updates sensor location and elevation attributes
96 //!
97 //! Updates the following attributes:
98 //! - lasing.sensorLocation.formatted: MGRS ten-digit grid (e.g. "11S GN 01234 56789")
99 //! - lasing.sensorElevation.formatted: Elevation in meters MSL (e.g. "EL 01234 m MSL")
100 virtual void updateSensorData();
101
102 //! \brief Updates the north reference attribute
103 //!
104 //! Updates lasing.northReference.formatted attribute with current north
105 //! reference setting ("MAG", "TRUE", or "GRID")
106 virtual void updateNorthReference();
107
108 //! \brief Updates the time of target location attribute
109 //!
110 //! Updates lasing.timeOfTargetLocation.formatted attribute with current time in HH:MM:SS format
112
113 //! \brief Updates all target-related attributes based on current lasing state
114 //!
115 //! Updates the following attributes when lasing is active:
116 //! - lasing.targetLocation.formatted: MGRS ten-digit grid (e.g. "11S GN 01234 56789")
117 //! - lasing.targetElevationMSL.formatted: Elevation in meters MSL (e.g. "EL 01234 m MSL")
118 //! - lasing.targetRange.formatted: Range in meters (e.g. "RNG 01234 m")
119 //! - lasing.targetElevation.formatted: Elevation in NATO MILS (e.g. "ELA 0123 MIL")
120 //! - lasing.targetAzimuth.formatted: Azimuth in NATO MILS (e.g. "AZ 0123 MIL")
121 //! - lasing.elrfStatus.formatted: "ELRF IDLE" or "GET TGT LOCATION" based on lasing state
122 virtual void updateTargetData();
123
124 //! \brief Generates a formatted time string for the current time
125 //! \return String containing the current time in HH:MM:SS format
126 virtual std::string timeString();
127
128 //! \brief Sets all target data attributes to null or default values
129 //!
130 //! Resets all target-related attributes to their default state when
131 //! target data expires or becomes invalid
132 virtual void clearTargetData();
133
134 //! \brief Calculates elevation and azimuth from observer to target
135 //! \param geocentricObserverLocation Observer position in geocentric coordinates
136 //! \param geocentricIntersectionPoint Target position in geocentric coordinates
137 //! \param targetElevation Pointer to store calculated elevation angle in radians
138 //! \param targetAzimuth Pointer to store calculated azimuth angle in radians
139 //!
140 //! Transforms positions to topocentric coordinates and calculates
141 //! elevation and azimuth angles, considering the current north reference setting
142 virtual void calculateElevationAndAzimuthToTarget(const DtVector& geocentricObserverLocation,
143 const DtVector& geocentricIntersectionPoint, double* targetElevation, double* targetAzimuth);
144
145protected:
146 //! \brief Current simulation time in seconds
148
149 //! \brief Time when observer-to-target distance was last calculated
151
152 //! \brief Time when target data will expire
154
155 //! \brief Intersector for performing raycasting to determine target position
156 makVrv::DtIntersector* myIntersector;
157
158 //! \brief Last known north units setting for detecting changes
159 makArchives::DtDisplayUnitsSettingsRecord::NorthUnits myLastNorthUnits;
160
161 //! \brief Last known local ownship position for detecting changes
163
164 //! \brief Last known geocentric position of laser intersection point
166
168};
169} // namespace makVre
Handle class for safe access to attributes.
Definition attributeHandle.h:30
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:150
virtual void tick(double dt) override
Called every frame to update the overlay state.
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:156
virtual void shutdown() override
Shuts down the binoculars lasing overlay component.
DtVector myLastLocalOwnshipPosition
Last known local ownship position for detecting changes.
Definition vreBinocularsLasingOverlay.h:162
makArchives::DtDisplayUnitsSettingsRecord::NorthUnits myLastNorthUnits
Last known north units setting for detecting changes.
Definition vreBinocularsLasingOverlay.h:159
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.
virtual bool isOverlayVisible() override
Determines if the overlay should be visible.
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:147
virtual bool postInitialize() override
Performs post-initialization after all components are initialized.
virtual ~DtBinocularsLasingOverlay() override
Virtual destructor for DtBinocularsLasingOverlay.
virtual void updateNorthReference()
Updates the north reference attribute.
DtAttributeHandle myLasingHandle
Definition vreBinocularsLasingOverlay.h:167
double myTargetDataExpirationTime
Time when target data will expire.
Definition vreBinocularsLasingOverlay.h:153
DtVector myLastGeocentricIntersectionPoint
Last known geocentric position of laser intersection point.
Definition vreBinocularsLasingOverlay.h:165
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
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
constexpr const char * DtBinocularsLasingOverlayType
Type identifier for DtBinocularsLasingOverlay component.
Definition vreBinocularsLasingOverlay.h:31
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.