VR-Engage  2.2
Loading...
Searching...
No Matches
vreChooseRolePage.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file vreChooseRolePage.h
7//! \brief Defines UI components for selecting observer views (roles) in VR-Engage
8//!
9//! This file contains classes that implement the role selection screen in VR-Engage,
10//! allowing users to select different observer views, such as driver, gunner, or commander.
11//! It includes models for representing observer views and a UI controller for managing
12//! the selection screen.
13
14#pragma once
15
19
20#include <QObject>
21#include <QAbstractListModel>
22
23//! Forward declaration of Qt Quick Item class
24class QQuickItem;
25
26namespace makArchives
27{
28//! Forward declaration of observer state records list
29class DtObserverStateRecordsList;
30
31//! Forward declaration of observer state record
32class DtObserverStateRecord;
33} // namespace makArchives
34
35namespace makVre
36{
37//! Forward declaration of the player station application
39
40//! \brief Data structure representing an observer view entry
41//!
42//! This class stores information about an observer view, including its name,
43//! whether it uses 2D projection, and whether it's the default view.
45{
46public:
47 //! \brief Default constructor
48 //!
49 //! Creates an empty observer view entry.
51
52 //! \brief Parameterized constructor
53 //! \param observerName The name of the observer view
54 //! \param projection2D Flag indicating if the view uses 2D projection
55 //! \param defaultView Flag indicating if this is the default view
56 //!
57 //! Creates an observer view entry with the specified parameters.
58 DtObserverViewEntry(const QString& observerName, const bool projection2D, const bool defaultView);
59
60 //! \brief Gets the observer view name
61 //! \return The name of the observer view
62 QString getObserverName() const;
63
64 //! \brief Sets the observer view name
65 //! \param name The new name to set
66 void setObserverName(const QString& name);
67
68 //! \brief Checks if the view uses 2D projection
69 //! \return True if the view uses 2D projection, false otherwise
70 bool getProjectionIs2D() const;
71
72 //! \brief Sets whether the view uses 2D projection
73 //! \param is2D True if the view should use 2D projection, false otherwise
74 void setProjectionIs2D(const bool is2D);
75
76 //! \brief Checks if this is the default view
77 //! \return True if this is the default view, false otherwise
78 bool getDefaultView() const;
79
80 //! \brief Sets whether this is the default view
81 //! \param isDefaultView True if this should be the default view, false otherwise
82 void setDefaultView(const bool isDefaultView);
83
84protected:
85 //! \brief The name of the observer view
87
88 //! \brief Flag indicating if the view uses 2D projection
90
91 //! \brief Flag indicating if this is the default view
93};
94
95//! \brief Model class for observer views to be used with QML views
96//!
97//! This class implements a Qt list model for observer view entries that can be
98//! bound to QML list views. It provides methods for adding, removing, and accessing
99//! observer view entries, as well as the required Qt model/view API implementation.
100class PLAYERSTATION_DLL DtObserverViewsQmlModel : public QAbstractListModel
101{
102 Q_OBJECT;
103
104public:
105 //! \brief Enum defining custom roles for the model data
107 {
108 ObserverNameRole = Qt::UserRole + 1, //!< Role for accessing the observer name
109 ProjectionRole, //!< Role for accessing the projection type
110 DefaultViewRole //!< Role for accessing the default view flag
111 };
112
113 //! \brief Constructor
114 //! \param parent The parent QObject (optional)
115 //!
116 //! Creates an empty observer views model.
117 DtObserverViewsQmlModel(QObject* parent = 0);
118
119 //! \brief Adds an observer view to the model
120 //! \param entry The observer view entry to add
121 virtual void addObserverView(const DtObserverViewEntry& entry);
122
123 //! \brief Clears all observer views from the model
124 virtual void clear();
125
126 //! \brief Finds the index of an observer view by name
127 //! \param observerName The name of the observer view to find
128 //! \return The index of the observer view, or -1 if not found
129 virtual int getIndexOfName(const QString& observerName);
130
131 //! \brief Gets the observer name at the specified index
132 //! \param idx The index to get the observer name for
133 //! \return The observer name at the specified index
134 virtual QString getObserverName(const int idx);
135
136 //! \brief Sorts the model data
137 //! \param column The column to sort by
138 //! \param order The sort order
139 //! \note Must be implemented in subclasses
140 virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
141
142 //! \brief Removes rows from the model
143 //! \param row The starting row to remove
144 //! \param column The column (unused, defaults to 0)
145 //! \param parent The parent index (unused for list models)
146 //! \return True if rows were successfully removed, false otherwise
147 virtual bool removeRows(int row, int column = 0, const QModelIndex& parent = QModelIndex()) override;
148
149 //! \brief Gets the number of rows in the model
150 //! \param parent The parent index (unused for list models)
151 //! \return The number of observer views in the model
152 virtual int rowCount(const QModelIndex& parent = QModelIndex()) const override;
153
154 //! \brief Gets data for a specific index and role
155 //! \param index The model index to get data for
156 //! \param role The role to get data for
157 //! \return The requested data as a QVariant
158 virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
159
160 //! \brief Sets data for a specific index and role
161 //! \param index The model index to set data for
162 //! \param value The value to set
163 //! \param role The role to set data for
164 //! \return True if data was successfully set, false otherwise
165 virtual bool setData(const QModelIndex& index, const QVariant& value, int role) override;
166
167protected:
168 //! \brief Gets the role names mapping for QML integration
169 //! \return A hash mapping role IDs to role names
170 virtual QHash<int, QByteArray> roleNames() const override;
171
172 //! \brief The list of observer view entries in the model
173 QList<DtObserverViewEntry> myObserverViews;
174};
175
176
177//! \brief UI controller for the role selection screen
178//!
179//! This class manages the UI for selecting observer views (roles) in VR-Engage.
180//! It displays a list of available roles, handles user selection, and provides
181//! mechanisms for filtering and navigating the available views.
183{
184 Q_OBJECT
185
186public:
187 //! \brief Constructor
188 //! \param app Reference to the player station application
189 //! \param target_window The target window name (optional)
190 //!
191 //! Creates a new choose role page for the specified application and window.
192 DtVreChooseRolePage(DtPlayerStationApp& app, const std::string& target_window = "");
193
194 //! \brief Destructor
195 //!
196 //! Cleans up resources used by the choose role page.
197 virtual ~DtVreChooseRolePage() override;
198
199 //! \brief Updates the page state
200 //! \param dt The time elapsed since the last update in seconds
201 //!
202 //! Performs periodic updates of the page state and components.
203 virtual void tick(double dt) override;
204
205 //! \brief Initializes the main UI components
206 //!
207 //! Sets up the initial state of the page and its components.
208 virtual void initMain() override;
209
210 //! \brief Sets the visibility of the role selection background
211 //! \param visible True to show the background, false to hide it
212 virtual void setChooseRoleBackgroundVisibility(bool visible);
213
214 //! \brief Sets the visibility of the observer views list
215 //! \param visible True to show the observer views, false to hide them
216 virtual void setObserverViewsVisibility(bool visible);
217
218 //! \brief Sets the visibility of the lockdown mode indicator
219 //! \param visible True to show the indicator, false to hide it
220 //! \param overrideLockdown If true, shows the indicator even if not in lockdown mode
221 virtual void setLockdownModeIndicatorVisibility(bool visible, bool overrideLockdown = false);
222
223 //! \brief Sets the text of the lockdown mode indicator
224 //! \param text The text to display in the lockdown mode indicator
225 virtual void setLockdownModeIndicatorText(const QString& text);
226
227 //! \brief Handles a click on an observer view
228 //! \param observerName The name of the observer view that was clicked
229 //! \param animated Whether to animate the transition (default: false)
230 //!
231 //! This method is invokable from QML and handles selection of an observer view.
232 Q_INVOKABLE virtual void observerViewClicked(QString observerName, bool animated = false);
233
234 //! \brief Sets the visibility of the page
235 //! \param visible True to show the page, false to hide it
236 //! \override Override of the base class method with additional functionality
237 virtual void setVisibility(bool visible) override;
238
239 //! \brief Handles application mode changes
240 //! \param newAppMode The new application mode
241 //! \param oldAppMode The previous application mode
242 //! \override Override of the base class method to update UI based on app mode
243 virtual void appModeUpdated(const std::string& newAppMode, const std::string& oldAppMode) override;
244
245public slots:
246 //! \brief Handles the exit dialog being opened
247 //! \override Override of the base class method
248 virtual void slot_exitOpened() override;
249
250 //! \brief Handles the exit dialog being closed
251 //! \override Override of the base class method
252 virtual void slot_exitClosed() override;
253
254 //! \brief Handles the help dialog being opened
255 //! \override Override of the base class method
256 virtual void slot_helpOpened() override;
257
258 //! \brief Handles the help dialog being closed
259 //! \override Override of the base class method
260 virtual void slot_helpClosed() override;
261
262 //! \brief Handles the settings dialog being opened
263 //! \override Override of the base class method
264 virtual void slot_settingsOpened() override;
265
266 //! \brief Handles the settings dialog being closed
267 //! \override Override of the base class method
268 virtual void slot_settingsClosed() override;
269
270 //! \brief Handles the connection button being clicked
271 //! \override Override of the base class method
272 virtual void slot_connectionClicked() override;
273
274protected:
275 //! \brief Handles back button clicks
276 //! \param msg The message containing back button click information
277 //! \return Message handling result (HANDLED or IGNORED)
279
280 //! \brief Handles changes to the observer views list
281 //! \param observerViewList The updated list of observer views
282 virtual void slot_observerViewsChanged(const makArchives::DtObserverStateRecordsList& observerViewList);
283
284 //! \brief Handles clearing of all observer views
286
287 //! \brief Handles addition of a new observer view
288 //! \param observerView The observer view that was added
289 virtual void slot_observerViewAdded(const makArchives::DtObserverStateRecord& observerView);
290
291 //! \brief Handles removal of an observer view
292 //! \param observerView The observer view that was removed
293 virtual void slot_observerViewRemoved(const makArchives::DtObserverStateRecord& observerView);
294
295 //! \brief Handles renaming of an observer view
296 //! \param oldName The previous name of the observer view
297 //! \param observerView The observer view with its new name
299 const std::string& oldName, const makArchives::DtObserverStateRecord& observerView);
300
301protected:
302 //! \brief Model containing the observer views to display
304
305 //! \brief Reference to the manager of observer views
306 makVrv::DtObserverViewsManager& myObserverViewsManager;
307};
308} // namespace makVre
Main singleton responsible for managing QML files in the VREngage system.
Data structure representing an observer view entry.
Definition vreChooseRolePage.h:45
bool myProjectionIs2D
Flag indicating if the view uses 2D projection.
Definition vreChooseRolePage.h:89
bool getProjectionIs2D() const
Checks if the view uses 2D projection.
DtObserverViewEntry()
Default constructor.
void setDefaultView(const bool isDefaultView)
Sets whether this is the default view.
bool myDefaultView
Flag indicating if this is the default view.
Definition vreChooseRolePage.h:92
void setObserverName(const QString &name)
Sets the observer view name.
QString getObserverName() const
Gets the observer view name.
QString myObserverName
The name of the observer view.
Definition vreChooseRolePage.h:86
void setProjectionIs2D(const bool is2D)
Sets whether the view uses 2D projection.
bool getDefaultView() const
Checks if this is the default view.
DtObserverViewEntry(const QString &observerName, const bool projection2D, const bool defaultView)
Parameterized constructor.
Model class for observer views to be used with QML views.
Definition vreChooseRolePage.h:101
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const override
Gets the number of rows in the model.
virtual QString getObserverName(const int idx)
Gets the observer name at the specified index.
DtObserverViewsQmlModel(QObject *parent=0)
Constructor.
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Gets data for a specific index and role.
QList< DtObserverViewEntry > myObserverViews
The list of observer view entries in the model.
Definition vreChooseRolePage.h:173
ObserverViewsRoles
Enum defining custom roles for the model data.
Definition vreChooseRolePage.h:107
@ ObserverNameRole
Role for accessing the observer name.
Definition vreChooseRolePage.h:108
@ DefaultViewRole
Role for accessing the default view flag.
Definition vreChooseRolePage.h:110
@ ProjectionRole
Role for accessing the projection type.
Definition vreChooseRolePage.h:109
virtual void clear()
Clears all observer views from the model.
virtual int getIndexOfName(const QString &observerName)
Finds the index of an observer view by name.
virtual bool setData(const QModelIndex &index, const QVariant &value, int role) override
Sets data for a specific index and role.
virtual bool removeRows(int row, int column=0, const QModelIndex &parent=QModelIndex()) override
Removes rows from the model.
virtual void sort(int column, Qt::SortOrder order=Qt::AscendingOrder) override
Sorts the model data.
virtual void addObserverView(const DtObserverViewEntry &entry)
Adds an observer view to the model.
virtual QHash< int, QByteArray > roleNames() const override
Gets the role names mapping for QML integration.
Top-level class representing the VR-Engage application.
Definition playerStationApp.h:163
virtual void appModeUpdated(const std::string &newAppMode, const std::string &oldAppMode) override
Handles application mode changes.
virtual void slot_settingsOpened() override
Handles the settings dialog being opened \override Override of the base class method.
virtual void slot_helpOpened() override
Handles the help dialog being opened \override Override of the base class method.
virtual void setVisibility(bool visible) override
Sets the visibility of the page.
makVrv::DtObserverViewsManager & myObserverViewsManager
Reference to the manager of observer views.
Definition vreChooseRolePage.h:306
virtual void slot_observerViewAdded(const makArchives::DtObserverStateRecord &observerView)
Handles addition of a new observer view.
virtual void slot_connectionClicked() override
Handles the connection button being clicked \override Override of the base class method.
virtual void tick(double dt) override
Updates the page state.
virtual void slot_exitOpened() override
Handles the exit dialog being opened \override Override of the base class method.
virtual Q_INVOKABLE void observerViewClicked(QString observerName, bool animated=false)
Handles a click on an observer view.
DtObserverViewsQmlModel myObserverViewsModel
Model containing the observer views to display.
Definition vreChooseRolePage.h:303
virtual void slot_helpClosed() override
Handles the help dialog being closed \override Override of the base class method.
virtual void slot_observerViewRenamed(const std::string &oldName, const makArchives::DtObserverStateRecord &observerView)
Handles renaming of an observer view.
DtVreChooseRolePage(DtPlayerStationApp &app, const std::string &target_window="")
Constructor.
virtual ~DtVreChooseRolePage() override
Destructor.
virtual void slot_settingsClosed() override
Handles the settings dialog being closed \override Override of the base class method.
virtual void slot_observerViewsCleared()
Handles clearing of all observer views.
virtual void setObserverViewsVisibility(bool visible)
Sets the visibility of the observer views list.
virtual void slot_observerViewRemoved(const makArchives::DtObserverStateRecord &observerView)
Handles removal of an observer view.
virtual void slot_observerViewsChanged(const makArchives::DtObserverStateRecordsList &observerViewList)
Handles changes to the observer views list.
DtVreMessageResult handleBackButtonClicked(DtVreMessage *msg)
Handles back button clicks.
virtual void initMain() override
Initializes the main UI components.
virtual void setChooseRoleBackgroundVisibility(bool visible)
Sets the visibility of the role selection background.
virtual void setLockdownModeIndicatorVisibility(bool visible, bool overrideLockdown=false)
Sets the visibility of the lockdown mode indicator.
virtual void setLockdownModeIndicatorText(const QString &text)
Sets the text of the lockdown mode indicator.
virtual void slot_exitClosed() override
Handles the exit dialog being closed \override Override of the base class method.
Abstract base class for all VREngage messages.
Definition vreMessage.h:50
Defines export macros for the VR-Engage Player Station library.
#define PLAYERSTATION_DLL
Definition export.h:24
Definition loadingState.h:25
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
DtVreMessageResult
Enumeration of possible message handling results.
Definition vreMessage.h:33