VR-Engage  2.2
Loading...
Searching...
No Matches
osgSensorViewDisplayLaserOverlaySection.h
Go to the documentation of this file.
1/******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4******************************************************************************/
5
6//! \file osgSensorViewDisplayLaserOverlaySection.h
7//! \brief Defines the laser display overlay section for sensor views
8//!
9//! This file contains the DtOsgSensorViewDisplayLaserOverlaySection class which
10//! provides a sensor view overlay that displays information about the current
11//! laser designator settings, including laser code, tracking code, and laser status.
12//! \ingroup vrvOsg
13
14#pragma once
15
17
18#include "vreUtil/attribute.h"
19
20#include <vrvOsg/DtOsgSensorViewOverlaySection.h>
21
22
23namespace makVrv
24{
25//! \brief Forward declaration of the text proxy class
26class DtTextProxy;
27} // namespace makVrv
28
29namespace makVre
30{
31//! \brief Overlay section that displays laser designator information in sensor views
32//!
33//! DtOsgSensorViewDisplayLaserOverlaySection provides a sensor view overlay that
34//! displays information about the current laser designator settings, including the
35//! active laser code, tracking code, and laser on/off status. The information is
36//! displayed as text in the lower left corner of the sensor view, with visual
37//! indicators for the laser status (blinking when active).
38class PLAYERSTATION_DLL DtOsgSensorViewDisplayLaserOverlaySection : public makVrv::DtOsgSensorViewOverlaySection
39{
40public:
41 //! \brief Friend declaration for creator class
42 //!
43 //! Only the creator class can construct instances of this section.
45
46 //! \brief Destructor
47 //!
48 //! Cleans up resources used by the laser display overlay section,
49 //! particularly the text display objects and state callbacks.
51
52 //! \brief Initializes the overlay section
53 //! \param overlayRenderer Renderer for creating overlay elements
54 //! \param channelWidth Width of the channel in pixels
55 //! \param channelHeight Height of the channel in pixels
56 //! \param channelXOffset X offset of the channel in pixels
57 //! \param channelYOffset Y offset of the channel in pixels
58 //!
59 //! Initializes the overlay section by creating the text element that displays
60 //! the laser information and setting up state attribute callbacks. This must
61 //! be called prior to any update calls. The position of the text is calculated
62 //! based on the channel dimensions and offsets.
63 virtual void initialize(makVrv::DtOverlayRenderer& overlayRenderer, unsigned int channelWidth,
64 unsigned int channelHeight, unsigned int channelXOffset, unsigned int channelYOffset) override;
65
66 //! \brief Updates the overlay when the channel size changes
67 //! \param channelWidth New width of the channel in pixels
68 //! \param channelHeight New height of the channel in pixels
69 //! \param channelXOffset New X offset of the channel in pixels
70 //! \param channelYOffset New Y offset of the channel in pixels
71 //!
72 //! Adjusts the position and size of the text element when the channel
73 //! dimensions or position change. This ensures the laser information display
74 //! maintains its relative position in the view.
75 virtual void setChannelSize(unsigned int channelWidth, unsigned int channelHeight, unsigned int channelXOffset,
76 unsigned int channelYOffset) override;
77
78 //! \brief Updates the laser information display
79 //! \param observer Observer object representing the viewer's position and orientation
80 //! \param state Current state of the sensor field of view
81 //!
82 //! Updates the overlay text with the current laser settings during each frame update.
83 //! Handles the blinking of the laser indicator when the laser is active.
84 virtual void update(const makVrv::DtOsgObserverObject& observer,
85 const makVrv::DtSensorFieldOfViewData& state) override;
86
87 //! \brief Gets the unique name of this overlay section
88 //! \return Reference to the section name string
89 //!
90 //! Returns the name of this section with which it may be retrieved from
91 //! the DtOsgSensorViewOverlay. Each section type has a unique name.
92 virtual const std::string& sectionName() const override;
93
94public:
95 //! \brief Static constant defining the section name
96 //!
97 //! This string identifier is used to register and retrieve this overlay section.
98 static const std::string SectionName;
99
100protected:
101 //! \brief Protected constructor
102 //! \param de Reference to the display engine
103 //!
104 //! Creates a new laser display overlay section. This constructor is protected
105 //! because instances should only be created through the creator class.
107
108 //! \brief Handles changes to the laser code setting
109 //! \param code New laser code value
110 //!
111 //! Callback triggered when the "laserCode" state attribute changes.
112 //! Updates the stored laser code and refreshes the display text.
113 virtual void handleLaserCodeChanged(int code);
114
115 //! \brief Handles changes to the tracking code setting
116 //! \param code New tracking code value
117 //!
118 //! Callback triggered when the "trackingCode" state attribute changes.
119 //! Updates the stored tracking code and refreshes the display text.
120 virtual void handleTrackCodeChanged(int code);
121
122 //! \brief Handles changes to the laser on/off state
123 //! \param laserOn New laser state (true = on, false = off)
124 //!
125 //! Callback triggered when the "LaserOn" state attribute changes.
126 //! Updates the stored laser state and refreshes the display text.
127 //! When the laser is on, the display will blink to indicate active status.
128 virtual void handleLaserOnChanged(bool laserOn);
129
130private:
131 //! \brief Updates the displayed text based on current laser settings
132 //!
133 //! Updates the text content to reflect the current laser code, tracking code,
134 //! and laser status. Formats the text with appropriate indicators and manages
135 //! the blinking effect when the laser is active.
137
138protected:
139 //! \brief Text element displaying the laser information
140 //!
141 //! Pointer to the text proxy object that renders the laser information text.
142 //! This is created during initialization and updated during each update call.
143 makVrv::DtTextProxy* myText;
144
145 //! \brief Currently selected laser code
146 //!
147 //! The code number currently set for the laser designator.
149
150 //! \brief Currently selected tracking code
151 //!
152 //! The code number currently being tracked by the laser designator.
154
155 //! \brief Flag indicating whether the laser is currently on
156 //!
157 //! True when the laser is active, false when inactive.
159
160 //! \brief Timestamp of the last display update
161 //!
162 //! Used to control the blink rate of the laser indicator.
164
165 //! \brief Current visibility state for blinking text
166 //!
167 //! Toggles between true and false to create the blinking effect
168 //! when the laser is active.
169 bool myShow;
170
171 //! \brief Member-scope instance of Attribute callback manager
172 //!
173 //! Used to manage Attribute change callback connections and ensure that all
174 //! callbacks are unregistered when this class instance is destroyed.
176};
177
178//! \brief Factory class for creating laser display overlay sections
179//!
180//! DtOsgSensorViewDisplayLaserOverlaySectionCreator is responsible for creating
181//! instances of DtOsgSensorViewDisplayLaserOverlaySection. It implements the
182//! factory pattern, allowing the overlay system to create specialized sections
183//! without knowing their implementation details.
184//! \ingroup vrvOsg
186 : public makVrv::DtOsgSensorViewOverlaySectionCreator
187{
188public:
189 //! \brief Creates a new laser display overlay section
190 //! \param de Reference to the display engine
191 //! \return Pointer to the newly created overlay section
192 //!
193 //! Factory method that creates a new DtOsgSensorViewDisplayLaserOverlaySection
194 //! instance with the specified display engine.
195 virtual makVrv::DtOsgSensorViewOverlaySection* create(makVrv::DtDe& de) override;
196
197 //! \brief Creates a clone of this creator
198 //! \return Pointer to a new instance of this creator
199 //!
200 //! Creates and returns a new instance of this creator class. This is used
201 //! by the overlay system for creator registration and management.
202 virtual makVrv::DtOsgSensorViewOverlaySectionCreator* clone() const override;
203};
204
205} // namespace makVre
Provides attribute handling system for hierarchical data storage and manipulation.
Definition attributeCallback.h:166
Factory class for creating laser display overlay sections.
Definition osgSensorViewDisplayLaserOverlaySection.h:187
virtual makVrv::DtOsgSensorViewOverlaySectionCreator * clone() const override
Creates a clone of this creator.
virtual makVrv::DtOsgSensorViewOverlaySection * create(makVrv::DtDe &de) override
Creates a new laser display overlay section.
makVrv::DtTextProxy * myText
Text element displaying the laser information.
Definition osgSensorViewDisplayLaserOverlaySection.h:143
virtual void handleLaserCodeChanged(int code)
Handles changes to the laser code setting.
void updateText()
Updates the displayed text based on current laser settings.
virtual ~DtOsgSensorViewDisplayLaserOverlaySection() override
Destructor.
DtOsgSensorViewDisplayLaserOverlaySection(makVrv::DtDe &de)
Protected constructor.
virtual void initialize(makVrv::DtOverlayRenderer &overlayRenderer, unsigned int channelWidth, unsigned int channelHeight, unsigned int channelXOffset, unsigned int channelYOffset) override
Initializes the overlay section.
virtual void handleLaserOnChanged(bool laserOn)
Handles changes to the laser on/off state.
virtual void handleTrackCodeChanged(int code)
Handles changes to the tracking code setting.
static const std::string SectionName
Static constant defining the section name.
Definition osgSensorViewDisplayLaserOverlaySection.h:98
friend class DtOsgSensorViewDisplayLaserOverlaySectionCreator
Friend declaration for creator class.
Definition osgSensorViewDisplayLaserOverlaySection.h:44
DtAttributeCallbackManager myAttributeCallbacks
Member-scope instance of Attribute callback manager.
Definition osgSensorViewDisplayLaserOverlaySection.h:175
bool myShow
Current visibility state for blinking text.
Definition osgSensorViewDisplayLaserOverlaySection.h:169
virtual void update(const makVrv::DtOsgObserverObject &observer, const makVrv::DtSensorFieldOfViewData &state) override
Updates the laser information display.
virtual void setChannelSize(unsigned int channelWidth, unsigned int channelHeight, unsigned int channelXOffset, unsigned int channelYOffset) override
Updates the overlay when the channel size changes.
double myLastTime
Timestamp of the last display update.
Definition osgSensorViewDisplayLaserOverlaySection.h:163
int myTargetCode
Currently selected tracking code.
Definition osgSensorViewDisplayLaserOverlaySection.h:153
virtual const std::string & sectionName() const override
Gets the unique name of this overlay section.
int myLaserCode
Currently selected laser code.
Definition osgSensorViewDisplayLaserOverlaySection.h:148
bool myLaserOn
Flag indicating whether the laser is currently on.
Definition osgSensorViewDisplayLaserOverlaySection.h:158
Defines export macros for the VR-Engage Player Station library.
#define PLAYERSTATION_DLL
Definition export.h:24
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
Definition appLauncherComponent.h:28
makVrv::DtDe * de()
Gets the display element pointer used by the plugin.