VR-Engage  2.3
Loading...
Searching...
No Matches
minimapUpdater.h
Go to the documentation of this file.
1/******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4******************************************************************************/
5
6//! \file minimapUpdater.h
7//! \brief Component that provides minimap functionality in a separate channel
8//! \ingroup vreCommonComponents
9
10#pragma once
11
14
16
17#include <vreUtil/color.h>
19
20namespace makVrv
21{
22class DtOsgChannel;
23class DtWindowConfiguration;
24class DtLineSegment;
25class DtCameraNode;
26} // namespace makVrv
27
28namespace makVre
29{
30class DtVrvOverlay;
31
32//! \brief Type identifier for DtMinimapUpdater component
33constexpr const char* DtMinimapUpdaterType = "DtMinimapUpdater";
34
35//! \brief Component that creates, updates, and manages a minimap display
36//!
37//! Creates, updates, and destroys a new channel, "Minimap", to display a 2D map in the main window.
38//! The minimap can be configured with multiple view modes, ownship indicators, compass overlays,
39//! and can be toggled on and off. It also adjusts visibility when binoculars, external launchers,
40//! or shoulder-mounted launchers are in use.
42{
43public:
44 //! \brief Constructor for DtMinimapUpdater
45 //!
46 //! Initializes component state with default values
48
49 //! \brief Virtual destructor for DtMinimapUpdater
50 virtual ~DtMinimapUpdater() override;
51
52 //! \brief Initializes the minimap updater component
53 //! \param player Pointer to the player station this component belongs to
54 //! \param config Configuration table containing minimap settings
55 //! \return True if initialization succeeded, false otherwise
56 //!
57 //! Processes configuration data and sets up the minimap channel based on the specified
58 //! view modes. Configures position, size, frame properties, and ownship indicators.
60
61 //! \brief Performs post-initialization tasks after all components are initialized
62 //! \return True if post-initialization succeeded, false otherwise
63 //!
64 //! Adds callbacks to monitor binocular, launcher, and aiming state so the minimap
65 //! can be hidden while an active launcher or binocular view requires it.
66 virtual bool postInitialize() override;
67
68 //! \brief Called every frame to update the minimap
69 //! \param dt Delta time since the last frame in seconds
70 //!
71 //! Updates the heading of the compass overlay to match the player's current heading
72 //! when the minimap is displayed
73 virtual void tick(double dt) override;
74
75 //! \brief Shuts down the minimap updater component
76 //!
77 //! Destroys the minimap channel, cleans up resources, and removes callbacks
78 //! and message handlers. Restores the original icon scale setting.
79 virtual void shutdown() override;
80
81 //! \brief Returns the type identifier for this component
82 //! \return The type string for DtMinimapUpdater
83 virtual const char* type() const override;
84
85protected:
86 //! \brief Creates the overlay for displaying ownship indicators
87 //!
88 //! Sets up the VRV overlay that will contain the ownship dot and compass indicators
89 //! on top of the minimap display
90 virtual void createOverlay();
91
92 //! \brief Handles changes to the usingBinoculars attribute
93 //! \param usingBinoculars New value of the usingBinoculars attribute
94 //!
95 //! Shows or hides the minimap when the binoculars state changes,
96 //! hiding the minimap when binoculars are in use
97 virtual void handleUsingBinocularsChanged(bool usingBinoculars);
98
99 //! \brief Handles changes to the external launcher state
100 //! \param launcherElementId Attribute handle containing the external launcher element ID
101 //!
102 //! Updates minimap suppression while an external launcher is in use.
103 virtual void handleLauncherElementIdChanged(const DtAttributeHandle& launcherElementId);
104
105 //! \brief Handles changes to shoulder-launcher aim state
106 //! \param attribute Attribute handle for the aiming or current-equipment state
107 //!
108 //! Updates minimap suppression while a shoulder-mounted launcher is being aimed.
109 virtual void handleAimingOrEquipmentChanged(const DtAttributeHandle& attribute);
110
111 //! \brief Updates minimap visibility for binocular or launcher use
112 //!
113 //! Temporarily hides an otherwise visible minimap while binoculars, an external launcher,
114 //! or an aimed shoulder-mounted launcher is active and restores its selected view mode
115 //! after all are inactive.
117
118 //! \brief Structure defining a minimap view mode configuration
119 struct ViewMode
120 {
121 //! \brief Name of the view mode for identification
122 std::string name;
123
124 //! \brief Left edge position (0.0-1.0 in normalized screen coordinates)
125 double left;
126
127 //! \brief Right edge position (0.0-1.0 in normalized screen coordinates)
128 double right;
129
130 //! \brief Bottom edge position (0.0-1.0 in normalized screen coordinates)
131 double bottom;
132
133 //! \brief Top edge position (0.0-1.0 in normalized screen coordinates)
134 double top;
135
136 //! \brief Flag indicating if the minimap should maintain a square aspect ratio
137 bool square;
138
139 //! \brief Flag indicating if this view mode is visible or off-screen
141 };
142
143 //! \brief Switches to the next minimap view mode
144 //!
145 //! Cycles through the view modes defined in the configuration,
146 //! updating the minimap's position, size, and visibility
147 virtual void cycleMinimapMode();
148
149 //! \brief Handles window creation messages
150 //! \param msg The window created message
151 //! \return Message handling result indicating if the message was handled
152 //!
153 //! Captures the minimap channel when it's created and sets up node masks and observer settings
155
156 //! \brief Handles window destruction messages
157 //! \param msg The window destroyed message
158 //! \return Message handling result indicating if the message was handled
159 //!
160 //! Clears references to the destroyed minimap channel
162
163 //! \brief Handles minimap-specific messages
164 //! \param msg The minimap message (cycle or reset zoom)
165 //! \return Message handling result indicating if the message was handled
166 //!
167 //! Processes messages to cycle minimap view modes or reset the zoom level
169
170 //! \brief Callback for window configuration change events
171 //! \param deName Name of the distributed environment
172 //! \param windowName Name of the window that changed
173 //! \param windowConfig New window configuration
174 //!
175 //! Updates the minimap channel's viewport when the window is resized
176 //! to maintain the correct position and proportions
178 const std::string& deName, const std::string& windowName, const makVrv::DtWindowConfiguration& windowConfig);
179
180 //! \brief Creates the minimap channel using the specified view mode
181 //! \param mode The view mode configuration to use for the minimap
182 //!
183 //! Creates a new minimap channel with the appropriate position and size
184 virtual void createMinimap(const ViewMode& mode);
185
186 //! \brief Modifies an existing minimap channel using the specified view mode
187 //! \param mode The view mode configuration to apply to the minimap
188 //!
189 //! Updates the position, size, and visibility of the minimap channel
190 virtual void modifyMinimap(const ViewMode& mode);
191
192 //! \brief Destroys the minimap channel
193 //!
194 //! Removes the minimap channel from the window manager
195 virtual void destroyMinimap();
196
197 //! \brief Registers message handlers for minimap-related messages
198 //!
199 //! Sets up handlers for window creation/destruction and minimap control messages
200 virtual void registerHandlers();
201
202 //! \brief Unregisters message handlers
203 //!
204 //! Removes all handlers for minimap-related messages
205 virtual void unregisterHandlers();
206
207 //! \brief Adds channel event processor association
208 //!
209 //! Associates the minimap channel with a target channel for event processing
211
212 //! \brief Removes channel event processor association
213 //!
214 //! Removes the association between the minimap channel and the target channel
216
217 //! \brief Builds frame elements around the minimap
218 //! \param elements Configuration table containing element definitions
219 //!
220 //! Overrides the base class function to programmatically create a frame
221 //! around the minimap based on the current view mode
222 virtual void buildElements(DtInitTable& elements) override;
223
224 //! \brief Calculates screen coordinates for a minimap view mode
225 //! \param mode The view mode to calculate coordinates for
226 //! \param left Output parameter for the left coordinate
227 //! \param right Output parameter for the right coordinate
228 //! \param bottom Output parameter for the bottom coordinate
229 //! \param top Output parameter for the top coordinate
230 //!
231 //! Calculates the actual screen coordinates for the minimap based on the view mode settings.
232 //! If square is true, the right coordinate is adjusted to maintain a square aspect ratio.
233 //! If visible is false, coordinates are set to place the channel off-screen.
235 const ViewMode& mode, double& left, double& right, double& bottom, double& top);
236
237 //! \brief Updates the minimap visibility based on current state
238 //!
239 //! Shows or hides the minimap only when the visibility state changes,
240 //! avoiding redundant calls to showMinimap or hideMinimap
242
243 //! \brief Shows the minimap by enabling rendering
244 //!
245 //! Restores the node masks for the minimap cameras to make the minimap visible
246 virtual void showMinimap();
247
248 //! \brief Hides the minimap by disabling rendering
249 //!
250 //! Sets the node masks for the minimap cameras to zero to hide the minimap
251 virtual void hideMinimap();
252
253 //! \brief Handles resizing of the map overlay
254 //!
255 //! Adjusts the position and size of the ownship indicators
256 //! when the map overlay is resized
258
259 //! \brief Sets the node mask on a camera node
260 //! \param node The camera node to modify
261 //! \param newMode The new node mask to apply
262 //! \param currentExpected The expected current node mask
263 //! \param setIfUnexpected Whether to set the mask if the current value is unexpected
264 //!
265 //! Sets the node mask on the specified camera node, with validation to detect
266 //! if the node mask has been changed by another component
267 virtual void setNodeMask(
268 makVrv::DtCameraNode* node, unsigned int newMode, unsigned int currentExpected, bool setIfUnexpected = true);
269
270 //! \brief Collection of available minimap view modes
271 std::vector<ViewMode> myModes;
272
273 //! \brief Index of the currently active view mode
274 unsigned int myCurrentMode;
275
276 //! \brief Initial map scale to restore on shutdown
278
279 //! \brief Color of the frame around the minimap
281
282 //! \brief Width of the frame around the minimap in pixels
284
285 //! \brief Name of the minimap channel
287
288 //! \brief Name of the window containing the minimap
289 std::string myWindowName;
290
291 //! \brief Name of the channel that will receive events from the minimap
293
294 //! \brief Flag indicating if the minimap is currently visible
296
297 //! Flag indicating that binoculars or an active launcher are hiding the minimap
299
300 //! \brief Flag indicating if the minimap is disabled
302
303 //! \brief Flag indicating if the minimap should be created at engagement
305
306 //! \brief Pointer to the OSG channel used for the minimap
307 makVrv::DtOsgChannel* myMinimapChannel;
308
309 //! \brief Width of the map in screen coordinates
311
312 //! \brief Height of the map in screen coordinates
314
315 //! \brief Reference height for sizing ownship indicators
317
318 //! \brief Filename of the texture for the ownship dot indicator
320
321 //! \brief Filename of the texture for the ownship compass indicator
323
324 //! \brief Size of the ownship dot indicator as a fraction of map height
326
327 //! \brief Size of the ownship compass indicator as a fraction of map height
329
330 //! \brief Color of the ownship dot indicator
332
333 //! \brief Overlay for displaying ownship indicators on the minimap
335
336 //! \brief Quad proxy for the ownship dot indicator
337 makVrv::DtQuadProxy* myOwnshipDotQuadProxy;
338
339 //! \brief Quad proxy for the ownship compass indicator
340 makVrv::DtQuadProxy* myOwnshipCompassQuadProxy;
341
342 //! \brief Tracks the temporary entity icon scale override.
344
345 //! \brief Cached node mask for the scene camera
346 unsigned int mySceneNodeMask;
347
348 //! \brief Cached node mask for the RTT camera
349 unsigned int myRttNodeMask;
350
351 //! \brief Cached node mask for the overlay camera
352 unsigned int myOverlayNodeMask;
353
354 //! \brief Cached node mask for the normalized overlay camera
356
357 //! \brief Attribute handle providing access to the main VR-Vantage channel from the application attribute store.
358 //! \vreAttrKey{DtChannel}
360};
361} // namespace makVre
Handle class for safe access to attributes.
Definition attributeHandle.h:30
Type-specific handle class for attributes.
Definition attributeHandle.h:229
Class for representing and manipulating RGBA colors.
Definition color.h:22
Table-based access to Lua state for configuration data.
Definition initializer.h:38
virtual void destroyMinimap()
Destroys the minimap channel.
bool myDisableMinimap
Flag indicating if the minimap is disabled.
Definition minimapUpdater.h:301
double myFrameWidth
Width of the frame around the minimap in pixels.
Definition minimapUpdater.h:283
virtual void handleMapOverlayResized()
Handles resizing of the map overlay.
double myMapHeight
Height of the map in screen coordinates.
Definition minimapUpdater.h:313
virtual void getViewModeScreenCoordinates(const ViewMode &mode, double &left, double &right, double &bottom, double &top)
Calculates screen coordinates for a minimap view mode.
virtual void cycleMinimapMode()
Switches to the next minimap view mode.
virtual void registerHandlers()
Registers message handlers for minimap-related messages.
virtual void handleAimingOrEquipmentChanged(const DtAttributeHandle &attribute)
Handles changes to shoulder-launcher aim state.
makVrv::DtOsgChannel * myMinimapChannel
Pointer to the OSG channel used for the minimap.
Definition minimapUpdater.h:307
double myOwnshipDotSize
Size of the ownship dot indicator as a fraction of map height.
Definition minimapUpdater.h:325
virtual void updateMinimapVisibility()
Updates the minimap visibility based on current state.
virtual const char * type() const override
Returns the type identifier for this component.
virtual void hideMinimap()
Hides the minimap by disabling rendering.
virtual bool initialize(makVre::DtPlayerStation *player, makVre::DtInitTable &config) override
Initializes the minimap updater component.
unsigned int myCurrentMode
Index of the currently active view mode.
Definition minimapUpdater.h:274
virtual DtVreMessageResult handleMinimapMessage(DtVreMessage *msg)
Handles minimap-specific messages.
virtual void handleUsingBinocularsChanged(bool usingBinoculars)
Handles changes to the usingBinoculars attribute.
virtual void addChannelEventProcessorAssociation()
Adds channel event processor association.
std::string myWindowName
Name of the window containing the minimap.
Definition minimapUpdater.h:289
double myReferenceHeight
Reference height for sizing ownship indicators.
Definition minimapUpdater.h:316
virtual void setNodeMask(makVrv::DtCameraNode *node, unsigned int newMode, unsigned int currentExpected, bool setIfUnexpected=true)
Sets the node mask on a camera node.
makVrv::DtQuadProxy * myOwnshipCompassQuadProxy
Quad proxy for the ownship compass indicator.
Definition minimapUpdater.h:340
DtColor myOwnshipDotColor
Color of the ownship dot indicator.
Definition minimapUpdater.h:331
bool myMinimapSuppressed
Flag indicating that binoculars or an active launcher are hiding the minimap.
Definition minimapUpdater.h:298
virtual void tick(double dt) override
Called every frame to update the minimap.
double myMapWidth
Width of the map in screen coordinates.
Definition minimapUpdater.h:310
virtual void createMinimap(const ViewMode &mode)
Creates the minimap channel using the specified view mode.
DtMinimapUpdater()
Constructor for DtMinimapUpdater.
virtual void slot_onWindowConfigurationChanged(const std::string &deName, const std::string &windowName, const makVrv::DtWindowConfiguration &windowConfig)
Callback for window configuration change events.
virtual bool postInitialize() override
Performs post-initialization tasks after all components are initialized.
bool myInitializeMinimapOnEngage
Flag indicating if the minimap should be created at engagement.
Definition minimapUpdater.h:304
unsigned int myNormalizedOverlayNodeMask
Cached node mask for the normalized overlay camera.
Definition minimapUpdater.h:355
virtual void updateMinimapSuppression()
Updates minimap visibility for binocular or launcher use.
virtual DtVreMessageResult handleWindowCreated(DtVreMessage *msg)
Handles window creation messages.
virtual void buildElements(DtInitTable &elements) override
Builds frame elements around the minimap.
int myInitialMapScale
Initial map scale to restore on shutdown.
Definition minimapUpdater.h:277
DtAttributeHandleType< makVrv::DtChannel * > myMinimapChannelAttr
Attribute handle providing access to the main VR-Vantage channel from the application attribute store...
Definition minimapUpdater.h:359
std::string myOwnshipDotTextureFilename
Filename of the texture for the ownship dot indicator.
Definition minimapUpdater.h:319
virtual void shutdown() override
Shuts down the minimap updater component.
DtSettingsOverrideGuard mySettingsOverrideGuard
Tracks the temporary entity icon scale override.
Definition minimapUpdater.h:343
virtual void modifyMinimap(const ViewMode &mode)
Modifies an existing minimap channel using the specified view mode.
virtual void removeChannelEventProcessorAssociation()
Removes channel event processor association.
virtual void createOverlay()
Creates the overlay for displaying ownship indicators.
unsigned int myOverlayNodeMask
Cached node mask for the overlay camera.
Definition minimapUpdater.h:352
bool myIsMinimapVisible
Flag indicating if the minimap is currently visible.
Definition minimapUpdater.h:295
unsigned int mySceneNodeMask
Cached node mask for the scene camera.
Definition minimapUpdater.h:346
virtual void showMinimap()
Shows the minimap by enabling rendering.
DtVrvOverlay * myMapOverlay
Overlay for displaying ownship indicators on the minimap.
Definition minimapUpdater.h:334
virtual void handleLauncherElementIdChanged(const DtAttributeHandle &launcherElementId)
Handles changes to the external launcher state.
unsigned int myRttNodeMask
Cached node mask for the RTT camera.
Definition minimapUpdater.h:349
std::string myMinimapChannelName
Name of the minimap channel.
Definition minimapUpdater.h:286
virtual DtVreMessageResult handleWindowDestroyed(DtVreMessage *msg)
Handles window destruction messages.
double myOwnshipCompassSize
Size of the ownship compass indicator as a fraction of map height.
Definition minimapUpdater.h:328
virtual void unregisterHandlers()
Unregisters message handlers.
std::vector< ViewMode > myModes
Collection of available minimap view modes.
Definition minimapUpdater.h:271
DtColor myFrameColor
Color of the frame around the minimap.
Definition minimapUpdater.h:280
makVrv::DtQuadProxy * myOwnshipDotQuadProxy
Quad proxy for the ownship dot indicator.
Definition minimapUpdater.h:337
virtual ~DtMinimapUpdater() override
Virtual destructor for DtMinimapUpdater.
std::string myOwnshipCompassTextureFilename
Filename of the texture for the ownship compass indicator.
Definition minimapUpdater.h:322
std::string myEventProcessorTargetChannel
Name of the channel that will receive events from the minimap.
Definition minimapUpdater.h:292
DtOverlayComponent()
Constructor for DtOverlayComponent.
virtual DtPlayerStation & player()
Gets the player station.
Class for managing the user interface for engaged roles.
Definition playerStation.h:51
Tracks temporary settings overrides and conditionally restores them.
Definition settingsOverrideGuard.h:180
Abstract base class for all VREngage messages.
Definition vreMessage.h:50
Class for creating and managing 2D overlays on a 3D scene.
Definition vrvOverlay.h:79
Provides color representation and manipulation functionality.
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 * DtMinimapUpdaterType
Type identifier for DtMinimapUpdater component.
Definition minimapUpdater.h:33
DtVreMessageResult
Enumeration of possible message handling results.
Definition vreMessage.h:33
Definition appLauncherComponent.h:28
Component for creating and managing HUD elements in overlay channels.
Defines a guard for temporary, non-persistent settings overrides.
Structure defining a minimap view mode configuration.
Definition minimapUpdater.h:120
double left
Left edge position (0.0-1.0 in normalized screen coordinates)
Definition minimapUpdater.h:125
double right
Right edge position (0.0-1.0 in normalized screen coordinates)
Definition minimapUpdater.h:128
std::string name
Name of the view mode for identification.
Definition minimapUpdater.h:122
double bottom
Bottom edge position (0.0-1.0 in normalized screen coordinates)
Definition minimapUpdater.h:131
bool square
Flag indicating if the minimap should maintain a square aspect ratio.
Definition minimapUpdater.h:137
double top
Top edge position (0.0-1.0 in normalized screen coordinates)
Definition minimapUpdater.h:134
bool visible
Flag indicating if this view mode is visible or off-screen.
Definition minimapUpdater.h:140
Defines the base class for all VREngage messages.