VR-Engage  2.2
Loading...
Searching...
No Matches
observerUpdater.h
Go to the documentation of this file.
1/******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4******************************************************************************/
5
6//! \file observerUpdater.h
7//! \brief Base component for managing observer parameters and view settings
8//! \ingroup vreCommonComponents
9
10#pragma once
11
13
15
16#include <string>
17#include <map>
18
19namespace makVrv
20{
21class DtChannelConfiguration;
22class DtWindow;
23} // namespace makVrv
24
26{
27//! \ingroup RoleConfigParams
28//! \defgroup ObserverUpdaterRoleParams Observer Updater Role Parameters
29//! \roleInherits{PlayerComponentRoleParams}
30//! Configuration Options for observer updater role.
31//! @{
32
33//! \vreRoleParam{horizontalFOV,double,45.0,observerUpdater,Horizontal field of view setting in degrees.}
34constexpr const char* horizontalFOV = "horizontalFOV";
35
36//! \vreRoleParam{verticalFOV,double,45.0,observerUpdater,Vertical field of view setting in degrees.}
37constexpr const char* verticalFOV = "verticalFOV";
38
39//! @}
40} // namespace ObserverUpdaterConfig
41
42//! \brief Structure representing a range of rotation values for observer movement
43//!
44//! Used to define the valid range of yaw and pitch angles for the observer,
45//! stored in radians but typically configured in degrees
47{
48 //! \brief Default constructor
49 ObserverRange() = default;
50
51 //! \brief Sets the maximum value in the range, converting from degrees to radians
52 //! \param m Maximum value in degrees
53 void setMax(double m) { max = DtDeg2Rad(m); }
54
55 //! \brief Sets the minimum value in the range, converting from degrees to radians
56 //! \param m Minimum value in degrees
57 void setMin(double m) { min = DtDeg2Rad(m); }
58
59 //! \brief Maximum value of the range in radians
60 double max;
61
62 //! \brief Minimum value of the range in radians
63 double min;
64};
65
66namespace makVre
67{
68class DtInitTable;
69class DtPlayerStation;
70class DtEntityResolver;
71class DtInstrumentPanelManager;
72
73//! \brief Type identifier for DtObserverUpdater component
74constexpr const char* DtObserverUpdaterType = "DtObserverUpdater";
75
76//! \brief Base component for managing observer view parameters and display settings
77//!
78//! DtObserverUpdater provides common functionality for managing observer view settings,
79//! including field of view and view modes. It manages channel configurations
80//! for windows and synchronizes sensor modes between VR-Engage and VR-Vantage.
81//! This class serves as a base for more specialized observer updater components.
83{
84public:
85 //! \brief Default constructor for DtObserverUpdater
86 //!
87 //! Initializes the component with the default name "DtObserverUpdater"
89
90 //! \brief Virtual destructor for DtObserverUpdater
91 virtual ~DtObserverUpdater() override;
92
93 //! \brief Initializes the observer updater component
94 //! \param station Pointer to the player station this component belongs to
95 //! \param config Configuration table containing observer settings
96 //! \return True if initialization succeeded, false otherwise
97 //!
98 //! Sets up field of view parameters, and adds
99 //! default channels to be managed by this component
100 virtual bool initialize(DtPlayerStation* station, DtInitTable& config) override;
101
102 //! \brief Performs post-initialization after all components are initialized
103 //! \return True if post-initialization succeeded, false otherwise
104 //!
105 //! Sets up callbacks for sensor mode and observer mode changes
106 virtual bool postInitialize() override;
107
108 //! \brief Called every frame to update observer parameters
109 //! \param dt Delta time since the last frame in seconds
110 //!
111 //! Updates all managed channels and player state attributes
112 virtual void tick(double dt) override;
113 //! \brief Shuts down the observer updater component
114 //!
115 //! Removes attribute callbacks and restores original channel settings
116 virtual void shutdown() override;
117
118 //! \brief Returns the component type identifier
119 //! \return The component type string
120 virtual const char* type() const override;
121
122 //! \brief Adds a channel to be managed by this updater
123 //! \param windowName Name of the window containing the channel
124 //! \param channelName Name of the channel to add
125 //!
126 //! Stores the initial configuration of the channel and marks it for updates
127 virtual void addChannelToUpdate(const std::string& windowName, const std::string& channelName);
128
129 //! \brief Removes a channel from being managed by this updater
130 //! \param windowName Name of the window containing the channel
131 //! \param channelName Name of the channel to remove
132 //! \param restoreInitialSettings If true, restores the channel's initial configuration
133 //!
134 //! Stops managing the specified channel and optionally restores its initial settings
136 const std::string& windowName, const std::string& channelName, bool restoreInitialSettings = true);
137
138protected:
139 //! \brief Initializes player state attributes related to observer settings
140 //!
141 //! Sets up field of view attributes and configures the initial channel projection
142 virtual void initializeStateAttributes() override;
143
144 //! \brief Handles changes to the sensor mode state attribute
145 //! \param sensorMode New sensor mode value
146 //!
147 //! Updates the observer's sensor mode in VR-Vantage when the sensorMode attribute changes
148 virtual void onSensorModeChanged(std::string sensorMode);
149
150 //! \brief Handles changes to the observer mode state attribute
151 //! \param observerMode New observer mode value
152 //!
153 //! Updates the observer's view mode in VR-Vantage when the observerMode attribute changes
154 virtual void onObserverModeChanged(std::string observerMode);
155
156 //! \brief Adds the default channel (Window 1, Channel 1) to be managed
157 //!
158 //! Adds the first window's Channel 1 to configurations to monitor.
159 //! Derived classes can override this function to change this behavior.
160 virtual void addDefaultChannels();
161
162 //! \brief Adds VR-specific channels to be managed
163 //!
164 //! Adds HMD window channels for left and right eyes to be managed by this updater
165 virtual void addVrChannels();
166
167 //! \brief Finds the configuration for a specific channel
168 //! \param windowName Name of the window containing the channel
169 //! \param channelName Name of the channel to find
170 //! \param config Output parameter that will receive the channel configuration
171 //! \return True if the channel configuration was found, false otherwise
172 //!
173 //! Retrieves the current configuration of the specified channel
175 const std::string& windowName, const std::string& channelName, makVrv::DtChannelConfiguration& config);
176
177 //! \brief Updates all managed channels with current settings
178 //!
179 //! Applies appropriate settings to all managed channels based on
180 //! the display layout
181 virtual void updateAllChannels();
182
183 //! \brief Sets the showCockpits keyword on all managed channels
184 //! \param show True to show cockpits, false to hide them
185 //!
186 //! Adds or removes the "showCockpits" keyword from channel configurations
187 virtual void setShowCockpits(bool show);
188
189 //! \brief Applies a configuration to a specific channel
190 //! \param windowName Name of the window containing the channel
191 //! \param channelName Name of the channel to configure
192 //! \param newConfig New configuration to apply to the channel
193 //! \return True if the configuration was successfully applied, false otherwise
194 //!
195 //! Modifies a channel's configuration through the window manager
197 const std::string& windowName, const std::string& channelName, const makVrv::DtChannelConfiguration& newConfig);
198
199 //! \brief Gets the names of the first window and channel
200 //! \param windowName Output parameter that will receive the window name
201 //! \param channelName Output parameter that will receive the channel name
202 //! \return True if a window and channel were found, false otherwise
203 //!
204 //! Finds and returns the names of the first window and its first channel
205 bool firstWindowAndChannelNames(std::string& windowName, std::string& channelName);
206
207 //! \brief Updates player state attributes with current observer data
208 //!
209 //! Updates position, orientation, and view attributes based on the current observer state
210 virtual void updateStateAttributes();
211
212 //! \brief Pointer to the instrument panel manager
214
215 //! \brief Type definition for window and channel name pairs
216 using WindowAndChannelName = std::pair<std::string, std::string>;
217
218 //! \brief Type definition for mapping window/channel pairs to configurations
219 using ChannelConfigMap = std::map<WindowAndChannelName, makVrv::DtChannelConfiguration>;
220
221 //! \brief Map of channel configurations to be updated
222 //!
223 //! Stores the initial configuration of each managed channel,
224 //! keyed by window name and channel name pairs
226
227 //! \brief Flag indicating if channel updates should be forced
229
230 //! \brief Vertical field of view in degrees
232
233 //! \brief Horizontal field of view in degrees
235
236 //! \brief Pointer to the main window
237 makVrv::DtWindow* myWindow;
238};
239
240} // namespace makVre
Table-based access to Lua state for configuration data.
Definition initializer.h:38
Manager for instrument panels, gimbal sensors, and specialized views.
Definition instrumentPanelManager.h:44
virtual bool applyConfigurationToChannel(const std::string &windowName, const std::string &channelName, const makVrv::DtChannelConfiguration &newConfig)
Applies a configuration to a specific channel.
makVrv::DtWindow * myWindow
Pointer to the main window.
Definition observerUpdater.h:237
virtual void setShowCockpits(bool show)
Sets the showCockpits keyword on all managed channels.
virtual void shutdown() override
Shuts down the observer updater component.
bool firstWindowAndChannelNames(std::string &windowName, std::string &channelName)
Gets the names of the first window and channel.
virtual void removeChannelToUpdate(const std::string &windowName, const std::string &channelName, bool restoreInitialSettings=true)
Removes a channel from being managed by this updater.
virtual bool initialize(DtPlayerStation *station, DtInitTable &config) override
Initializes the observer updater component.
virtual void initializeStateAttributes() override
Initializes player state attributes related to observer settings.
std::pair< std::string, std::string > WindowAndChannelName
Type definition for window and channel name pairs.
Definition observerUpdater.h:216
virtual ~DtObserverUpdater() override
Virtual destructor for DtObserverUpdater.
ChannelConfigMap myChannelsToUpdate
Map of channel configurations to be updated.
Definition observerUpdater.h:225
virtual void addChannelToUpdate(const std::string &windowName, const std::string &channelName)
Adds a channel to be managed by this updater.
virtual void tick(double dt) override
Called every frame to update observer parameters.
virtual bool findChannelConfiguration(const std::string &windowName, const std::string &channelName, makVrv::DtChannelConfiguration &config)
Finds the configuration for a specific channel.
virtual void onObserverModeChanged(std::string observerMode)
Handles changes to the observer mode state attribute.
bool myForceChannelUpdate
Flag indicating if channel updates should be forced.
Definition observerUpdater.h:228
std::map< WindowAndChannelName, makVrv::DtChannelConfiguration > ChannelConfigMap
Type definition for mapping window/channel pairs to configurations.
Definition observerUpdater.h:219
virtual void updateStateAttributes()
Updates player state attributes with current observer data.
virtual void onSensorModeChanged(std::string sensorMode)
Handles changes to the sensor mode state attribute.
double myVerticalFOV
Vertical field of view in degrees.
Definition observerUpdater.h:231
virtual void updateAllChannels()
Updates all managed channels with current settings.
virtual void addVrChannels()
Adds VR-specific channels to be managed.
double myHorizontalFOV
Horizontal field of view in degrees.
Definition observerUpdater.h:234
virtual void addDefaultChannels()
Adds the default channel (Window 1, Channel 1) to be managed.
DtObserverUpdater()
Default constructor for DtObserverUpdater.
virtual const char * type() const override
Returns the component type identifier.
makVre::DtInstrumentPanelManager * myInstrumentPanelManager
Pointer to the instrument panel manager.
Definition observerUpdater.h:213
virtual bool postInitialize() override
Performs post-initialization after all components are initialized.
DtPlayerComponent()
Constructor.
Class for managing the user interface for engaged roles.
Definition playerStation.h:51
constexpr const char * horizontalFOV
Definition observerUpdater.h:34
constexpr const char * verticalFOV
Definition observerUpdater.h:37
Defines export/import macros for the vreCommonComponents library.
#define VRECOMMONCOMPONENTS_DLL
DLL export/import macro for the vreCommonComponents library.
Definition export.h:28
Definition observerUpdater.h:26
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
constexpr const char * DtObserverUpdaterType
Type identifier for DtObserverUpdater component.
Definition observerUpdater.h:74
Definition appLauncherComponent.h:28
Defines the DtPlayerComponent base class for VR-Engage role components.
void setMax(double m)
Sets the maximum value in the range, converting from degrees to radians.
Definition observerUpdater.h:53
ObserverRange()=default
Default constructor.
void setMin(double m)
Sets the minimum value in the range, converting from degrees to radians.
Definition observerUpdater.h:57
double min
Minimum value of the range in radians.
Definition observerUpdater.h:63
double max
Maximum value of the range in radians.
Definition observerUpdater.h:60