VR-Engage  2.3
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 DtVreChooseRolePage(DtPlayerStationApp& app, const std::string& target_window = "");
191
192 //! \brief Destructor
193 virtual ~DtVreChooseRolePage() override;
194
195 //! \brief Updates the page state
196 //! \param dt The time elapsed since the last update in seconds
197 virtual void tick(double dt) override;
198
199 //! \brief Initializes the main UI components
200 virtual void initMain() override;
201
202 //! \brief Sets the visibility of the role selection background
203 //! \param visible True to show the background, false to hide it
204 virtual void setChooseRoleBackgroundVisibility(bool visible);
205
206 //! \brief Sets the visibility of the observer views list
207 //! \param visible True to show the observer views, false to hide them
208 virtual void setObserverViewsVisibility(bool visible);
209
210 //! \brief Sets the visibility of the lockdown mode indicator
211 //! \param visible True to show the indicator, false to hide it
212 //! \param overrideLockdown If true, shows the indicator even if not in lockdown mode
213 virtual void setLockdownModeIndicatorVisibility(bool visible, bool overrideLockdown = false);
214
215 //! \brief Sets the text of the lockdown mode indicator
216 //! \param text The text to display in the lockdown mode indicator
217 virtual void setLockdownModeIndicatorText(const QString& text);
218
219 //! \brief Handles a click on an observer view
220 //! \param observerName The name of the observer view that was clicked
221 //! \param animated Whether to animate the transition (default: false)
222 Q_INVOKABLE virtual void observerViewClicked(QString observerName, bool animated = false);
223
224 //! \brief Sets the visibility of the page
225 //! \param visible True to show the page, false to hide it
226 virtual void setVisibility(bool visible) override;
227
228protected:
229 //! \brief Hides the choose-role panel and main content when a popup opens
230 virtual void onPopupOpened() override;
231
232 //! \brief Restores the choose-role panel and main content when a popup closes
233 virtual void onPopupClosed() override;
234
235 //! \brief Hides the panel before navigating to the connection page
236 virtual void onConnectionClicked() override;
237
238 //! \brief Updates UI based on application mode changes
239 //! \param newAppMode The new application mode
240 //! \param oldAppMode The previous application mode
241 virtual void onAppModeChanged(const std::string& newAppMode, const std::string& oldAppMode) override;
242
243 //! \brief Handles back button clicks from the choose role panel
244 //! \param msg The UIBackButtonClickedMessage
245 //! \return EATEN if handled, IGNORED otherwise
247
248 //! \brief Handles changes to the observer views list
249 //! \param observerViewList The updated list of observer views
250 virtual void slot_observerViewsChanged(const makArchives::DtObserverStateRecordsList& observerViewList);
251
252 //! \brief Handles clearing of all observer views
254
255 //! \brief Handles addition of a new observer view
256 //! \param observerView The observer view that was added
257 virtual void slot_observerViewAdded(const makArchives::DtObserverStateRecord& observerView);
258
259 //! \brief Handles removal of an observer view
260 //! \param observerView The observer view that was removed
261 virtual void slot_observerViewRemoved(const makArchives::DtObserverStateRecord& observerView);
262
263 //! \brief Handles renaming of an observer view
264 //! \param oldName The previous name of the observer view
265 //! \param observerView The observer view with its new name
267 const std::string& oldName, const makArchives::DtObserverStateRecord& observerView);
268
269protected:
270 //! \brief Model containing the observer views to display
272
273 //! \brief Reference to the manager of observer views
274 makVrv::DtObserverViewsManager& myObserverViewsManager;
275};
276} // 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:155
DtVreBaseUI(DtPlayerStationApp &app, const std::string &file, const std::string &target_window="")
Constructor.
virtual void onPopupOpened() override
Hides the choose-role panel and main content when a popup opens.
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:274
virtual void slot_observerViewAdded(const makArchives::DtObserverStateRecord &observerView)
Handles addition of a new observer view.
virtual void tick(double dt) override
Updates the page state.
virtual void onAppModeChanged(const std::string &newAppMode, const std::string &oldAppMode) override
Updates UI based on application mode changes.
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:271
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_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 from the choose role panel.
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 onPopupClosed() override
Restores the choose-role panel and main content when a popup closes.
virtual void onConnectionClicked() override
Hides the panel before navigating to the connection page.
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
!
Definition glsVreMessageUtil.h:50
DtVreMessageResult
Enumeration of possible message handling results.
Definition vreMessage.h:33
Defines the thin base class for VR-Engage QML page components.