VR-Engage  2.3
Loading...
Searching...
No Matches
vreManagerWidget.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file vreManagerWidget.h
7//! \ingroup vreManager
8//! \brief VREngage Manager widget for configuring and managing VREngage applications
9//!
10//! This file defines the DtVreManagerWidget class, which provides the main user
11//! interface for managing VREngage applications, including role assignments,
12//! entity control, and status monitoring.
13
14#pragma once
15
16#include "vreManager/export.h"
18
19#include <vrvUtil/signalslib.h>
20#include <vrfGuiCore/guiSimObject.h>
21
22#include "vreManager/vreManagerWidgetNew.hpp"
23
24#include <QtCore/QStringList>
25#include <vrfutil/uuid.h>
26
27#include <map>
28#include <set>
29#include <string>
30
31#include <vrvCoreQt/DtPage.h>
32#include <QtWidgets/QWidget>
33
34class QModelIndex;
36class QTimer;
37class QToolButton;
38class QButtonGroup;
39class QWidget;
40
41
42namespace makVre
43{
49
50//! \brief Main widget for the VREngage Manager interface
51//!
52//! This class provides the main user interface for managing VREngage applications,
53//! including monitoring application status, assigning roles and entities to
54//! applications, and controlling spectator mode settings. It integrates with
55//! the VREngage status listener to maintain real-time status information.
56class VREMANAGER_DLL DtVreManagerWidget : public makVrv::DtPage
57{
58 Q_OBJECT
59
60public:
61 //! \brief Virtual destructor
62 //!
63 //! Cleans up resources used by the manager widget, including the table model,
64 //! entity selection dialog, and VREngage listener.
65 virtual ~DtVreManagerWidget() override;
66
67 //! \brief Gets the icon for this page
68 //! \return Icon to display for this page in the application
69 //!
70 //! Returns the icon representing the VREngage Manager in the application UI.
71 virtual QIcon icon() override;
72
73 //! \brief Gets the title for this page
74 //! \return Title to display for this page in the application
75 //!
76 //! Returns the human-readable title for the VREngage Manager page.
77 virtual QString title() override;
78
79 //! \brief Gets the class name of the page
80 //! \return Reference to the unique class name string
81 //!
82 //! Returns the unique identifier for this page class type. This name is used
83 //! for page identification and persistence purposes.
84 virtual const std::string& pageClassName() const override;
85
86 //! \brief Called when the page is displayed
87 //!
88 //! Activates the manager widget, setting up the necessary connections, initializing
89 //! the table model, and refreshing the display. This is called whenever the
90 //! page becomes visible to the user.
91 virtual void activate() override;
92
93 //! \brief Called when the page is hidden
94 //!
95 //! Deactivates the manager widget, cleaning up resources and disconnecting
96 //! signals. This is called whenever the page becomes invisible to the user.
97 virtual void deactivate() override;
98
99 //! \brief Gets the icon configurations for the page
100 //! \return The icon configuration settings
101 //!
102 //! Returns the configuration settings used to style the page's icon
103 //! based on application settings and theme.
104 virtual makVrv::DtQIconConfigurations qIconConfigurations() const override;
105
106 //! \brief Returns preferred initial size for dock sizing
107 //! \return Preferred initial size of the manager dock
108 //!
109 //! Sized so that, when first opened in the right dock area, the panel
110 //! shows roughly two station cards plus the entire bottom button row
111 //! without requiring a manual resize.
112 virtual QSize sizeHint() const override;
113
114 //! \brief Returns the smallest sensible size for the dock
115 //! \return Minimum size that still keeps the bottom button row visible
116 //!
117 //! The dock can be shrunk down to this size but no further, so the
118 //! Submit / Submit-with-Conflicts / Revert button row is never clipped.
119 virtual QSize minimumSizeHint() const override;
120
121 //! \brief Static callback for VREngage application discovery
122 //! \param id The unique identifier of the discovered application
123 //! \param usr User-defined data (pointer to the manager widget instance)
124 //!
125 //! Static callback function invoked when a new VREngage application is discovered.
126 //! Routes the callback to the appropriate instance method.
127 static void vreAppAddedCallback(const std::string& id, void* usr);
128
129 //! \brief Static callback for VREngage application removal
130 //! \param id The unique identifier of the removed application
131 //! \param usr User-defined data (pointer to the manager widget instance)
132 //!
133 //! Static callback function invoked when a VREngage application is removed.
134 //! Routes the callback to the appropriate instance method.
135 static void vreAppRemovedCallback(const std::string& id, void* usr);
136
137 //! \brief Static callback for VREngage application status changes
138 //! \param id The unique identifier of the changed application
139 //! \param usr User-defined data (pointer to the manager widget instance)
140 //!
141 //! Static callback function invoked when a VREngage application's status changes.
142 //! Routes the callback to the appropriate instance method.
143 static void vreAppChangedCallback(const std::string& id, void* usr);
144
145signals:
146 //! \brief Emitted when a known entity's force type changes at runtime
147 //! \param entityUUID UUID of the entity whose force type changed
148 //! \param newRawForceType New SISO force-type value (0=Other, 1=Friendly, 2=Opposing, 3=Neutral)
149 //!
150 //! Fired inside tryAddEntityToTree() whenever the force type reported by
151 //! the sim object reference differs from the last-observed value. The tree
152 //! model slot DtVreEntityRoleTreeModel::moveEntityToForce() is connected to
153 //! this signal via Qt::QueuedConnection so the move always executes on the
154 //! GUI thread, even if the sim object manager fires its update callback from
155 //! a different thread.
156 void entityForceTypeChanged(const QString& entityUUID, int newRawForceType);
157
158public slots:
159 //! \brief Handles submission of changes
160 //!
161 //! Called when the user submits changes to VREngage application settings.
162 //! Applies the changes to the affected applications.
163 virtual void onSubmit();
164
165 //! \brief Handles submission of changes even when conflicts exist
166 //!
167 //! Called when the user forcefully submits changes despite unresolved
168 //! conflicts. Uses the same send path as onSubmit().
169 virtual void onSubmitWithConflicts();
170
171 //! \brief Handles reverting of changes
172 //!
173 //! Called when the user cancels changes to VREngage application settings.
174 //! Reverts any pending changes and refreshes the display.
175 virtual void onRevert();
176
177 //! \brief Handles completion of user edits
178 //!
179 //! Called when the user completes an edit operation in the manager.
180 //! Updates internal state and enables/disables UI elements accordingly.
181 virtual void onUserEditComplete();
182
183 //! \brief Handles data changes in the table model
184 //!
185 //! Called when data in the table model changes. Updates the Submit button
186 //! state based on whether conflicts exist in the current assignments.
187 virtual void onDataChanged();
188
189 //! \brief Handles assignment tracker state changes
190 //!
191 //! Called when the assignment tracker's state changes (station added/removed,
192 //! pending assignments changed, etc.). Used for testing Phase 1 integration.
194
195 //! \brief Handles VREngage application addition
196 //! \param id The unique identifier of the added application
197 //!
198 //! Called when a new VREngage application is discovered. Updates the
199 //! table model and refreshes the display to show the new application.
200 virtual void handleVreAppAdded(const std::string& id);
201
202 //! \brief Handles VREngage application removal
203 //! \param id The unique identifier of the removed application
204 //!
205 //! Called when a VREngage application is removed or times out. Updates the
206 //! table model and refreshes the display to remove the application.
207 virtual void handleVreAppRemoved(const std::string& id);
208
209 //! \brief Handles VREngage application status changes
210 //! \param id The unique identifier of the changed application
211 //!
212 //! Called when a VREngage application's status changes. Updates the
213 //! table model and refreshes the display to show the updated status.
214 virtual void handleVreAppChanged(const std::string& id);
215
216 // -------------------------------------------------------------------------
217 //! @name Phase 3: New UI Interaction Slots
218 //! Slots for the two-panel splitter-based layout.
219 //! @{
220 // -------------------------------------------------------------------------
221
222 //! \brief Handles entity search text changes
223 //! \param text The current search text
224 //!
225 //! Filters the entity/role tree to show only entities whose display
226 //! name contains the search text (case-insensitive).
227 virtual void onEntitySearchChanged(const QString& text);
228
229 //! \brief Handles station search text changes
230 //! \param text The current search text
231 //!
232 //! Filters the station list to show only stations whose name
233 //! contains the search text (case-insensitive).
234 virtual void onStationSearchChanged(const QString& text);
235
236 //! \brief Toggles between expanding and collapsing all entity nodes in the tree
238
239 //! \brief Handles clicks on the entity/role tree
240 //! \param index The model index of the clicked item
241 //!
242 //! Entity clicks toggle expand/collapse. Role clicks set the
243 //! selected entity UUID and role name for the assignment workflow.
244 virtual void onEntityRoleTreeClicked(const QModelIndex& index);
245
246 //! \brief Handles clicks on the station list
247 //! \param index The model index of the clicked item
248 //!
249 //! If a role is armed (selected in the entity/role tree), clicking a
250 //! station creates a pending assignment for that station to the armed
251 //! role. Otherwise, records the selected station ID.
252 virtual void onStationListClicked(const QModelIndex& index);
253
254 //! \brief Handles right-click context menu on the station list
255 //! \param pos The position of the right-click in widget coordinates
256 //!
257 //! Shows a context menu with options to clear pending assignments
258 //! for the clicked station.
259 virtual void onStationListContextMenu(const QPoint& pos);
260
261 //! \brief Handles a click on the spectator mode toggle button
262 //! \param stationId The ID of the station whose spectator mode should be toggled
263 //!
264 //! Toggles spectator mode for the pending assignment on the given station.
265 //! Called when the user clicks the spectator mode button embedded in a station card.
266 virtual void onSpectatorToggleClicked(const QString& stationId);
267
268 //! \brief Handles a click on the status indicator circle
269 //! \param stationId The ID of the station to unassign or clear pending
270 virtual void onStatusIndicatorClicked(const QString& stationId);
271
272 //! \brief Handles clicks on the assignment-status sort button
274
275 //! \brief Handles clicks on the station-name sort button
277
278 //! \brief Applies entity/role tree ordering when the header sort indicator changes
279 //! \param section The logical column index owning the active sort indicator
280 //! \param order The active Qt sort order (ascending/descending)
281 //!
282 //! Connected to QHeaderView::sortIndicatorChanged so the built-in
283 //! header indicator drives the existing custom tree-model ordering
284 //! exactly once (avoids section-click double-sort wiring).
285 virtual void onEntityRoleHeaderSortIndicatorChanged(int section, Qt::SortOrder order);
286
287 //! \brief Pops the entity/role tree header context menu
288 //! \param pos Position of the right-click within the header viewport
289 //!
290 //! Builds a small QMenu with one checkable action per toggleable column
291 //! (currently just "Show Sim Engine column"). Designed so future
292 //! optional columns can register themselves the same way without
293 //! restructuring the slot.
294 virtual void onTreeHeaderContextMenu(const QPoint& pos);
295
296 //! @}
297
298 // -------------------------------------------------------------------------
299 //! @name Phase 8: Assignment Persistence
300 //! Slots for save and load assignment file operations.
301 //! @{
302 // -------------------------------------------------------------------------
303
304 //! \brief Opens a file dialog and saves the current assignment layout to JSON.
305 virtual void onSaveAssignments();
306
307 //! \brief Opens a file dialog and loads an assignment layout from JSON.
308 //!
309 //! If pending changes exist, prompts the operator to confirm replacement
310 //! before importing. On parse errors shows a critical dialog. On partial
311 //! success shows a warning summary.
312 virtual void onLoadAssignments();
313
314 //! @}
315
316protected:
317 //! \brief Handles model set changes
318 //!
319 //! Populates the model sets that could possibly contain VREngage-controllable entities.
320 //! This includes any SMS (Simulation Model Set) that derives from VR-Engage.sms
321 //! somewhere in its ancestry. Called when the available model sets change.
322 virtual void onModelSetChanged();
323
324protected:
325 //! Allows the creator class to create page instances
327
328 //! \brief Responds to palette changes so toolbar icons repaint in the correct colour
329 //!
330 //! Catches QEvent::PaletteChange to rebuild the expand/collapse and sort button
331 //! icons using the updated QPalette::Text colour (important for dark-mode switches).
332 virtual void changeEvent(QEvent* event) override;
333
334 //! \brief Repaints toolbar icons on first show
335 //!
336 //! The palette may not be fully resolved during setupNewUi() (before the widget
337 //! is parented into the main window), so icons are also refreshed here to ensure
338 //! they use the correct colour from the first visible frame.
339 virtual void showEvent(QShowEvent* event) override;
340
341 //! \brief Filters mouse events on the entity/role tree viewport
342 //!
343 //! Clears the tree selection when the user clicks empty space.
344 bool eventFilter(QObject* watched, QEvent* event) override;
345
346 //! \brief Rebuilds the expand/collapse toggle button icon from the current palette
348
349 //! \brief Syncs the expand/collapse toggle button to reflect the tree's actual state
350 //!
351 //! Computes whether every visible root entity node is expanded and updates
352 //! myTreeExpanded and the button icon/tooltip accordingly. Call this after
353 //! any operation that may change the expanded state without going through
354 //! onToggleExpandCollapse (filter changes, model reset, entity add/remove,
355 //! individual node expand/collapse by the user).
357
358 //! \brief Mirrors header-hover visual state to the embedded expand/collapse button
359 //!
360 //! When active, the button receives the same subtle neutral overlay used by
361 //! tree header hover so the two controls read as one continuous affordance.
363
364 //! \brief Rebuilds the assignment-status sort button icon from the current palette
366
367 //! \brief Refreshes the station-name sort button presentation
369
370 //! \brief Applies station-list sort state to proxy and updates button visuals
372
373 //! \brief Internal activation handler
374 //!
375 //! Implementation of the activation logic. Called by activate().
376 virtual void handleActivate();
377
378 //! \brief Internal deactivation handler
379 //!
380 //! Implementation of the deactivation logic. Called by deactivate().
381 virtual void handleDeactivate();
382
383 //! \brief Constructor
384 //! \param de The distributed environment reference
385 //! \param parent The parent widget
386 //! \param f Window flags to apply to the widget
387 //!
388 //! Initializes a new VREngage manager widget. This constructor is private
389 //! and can only be called by the DtVreManagerWidgetCreator.
390 DtVreManagerWidget(makVrv::DtDe& de, QWidget* parent = 0, Qt::WindowFlags f = 0);
391
392 //! \brief Sets up the UI components
393 //! \param p The parent widget to set up UI on
394 //!
395 //! Initializes and configures the user interface components of the manager widget.
396 //! Creates the table, buttons, and other controls, and connects signals and slots.
397 void setupUi(QWidget* p);
398
399 //! \brief Sets up the new two-panel splitter UI (Phase 3)
400 //!
401 //! Creates the new UI layout with entity/role tree on the left,
402 //! station list on the right, search boxes, station sort controls,
403 //! toolbar buttons, and status labels. Wires the Phase 2 models
404 //! to the new views and connects all signals.
406
407 //! \brief Populates the entity/role tree with all VRE-engageable entities
408 //!
409 //! Enumerates all sim objects in the exercise, filters to VRE-engageable
410 //! entities via DtVreModelSetDb (those exposing non-empty engage roles),
411 //! retrieves available roles, and adds each entity to the tree model.
412 //! Also connects to sim object added/deleted signals for dynamic updates.
414
415 //! \brief Attempts to add a single sim object to the tree if VRE-engageable
416 //! \param uuid The entity UUID to evaluate and potentially add
417 void tryAddEntityToTree(const DtUUID& uuid);
418
419 //! \brief Refreshes the cached Sim Engine address for every tracked entity
420 //!
421 //! Iterates over all entities in \c myEntityForceTypes, looks up their
422 //! current \c simEngineAddress(), and calls \c setEntitySimEngine() on the
423 //! tree model. Because \c setEntitySimEngine() short-circuits when the
424 //! cached value is unchanged, this is cheap to call periodically.
425 //! Driven by \c mySimEngineRefreshTimer so ownership transfers that change
426 //! an entity's simulating engine are reflected in the Sim Engine column.
428
429 //! \brief Walk the aggregate parent chain for a sim-object reference (Phase 8)
430 //! \param[in] ref Sim-object reference whose aggregate ancestry to walk
431 //! \param[out] chainUUIDs Aggregate ancestor UUIDs, root-most first
432 //! \param[out] chainNames Display names parallel to \c chainUUIDs
433 //! \param[out] chainIcons Pre-rendered icons parallel to \c chainUUIDs
434 //! \param[out] chainForces SISO force-type per aggregate (parallel)
435 //!
436 //! Empties the output vectors first, then descends from \c ref using
437 //! \c DtSimObject::parent() until the chain ends. \c chainNames /
438 //! \c chainIcons / \c chainForces are resolved via
439 //! \c DtVrfGuiSimObjectManager / \c DtVrfGuiSymbolMapper. Each aggregate
440 //! UUID encountered is also inserted into \c myKnownAggregates so a later
441 //! \c signal_objectDeleted can be routed correctly.
442 void resolveAggregateChain(const makVrf::DtSimObjectReference& ref,
443 std::vector<DtUUID>& chainUUIDs,
444 std::vector<std::string>& chainNames,
445 std::vector<QIcon>& chainIcons,
446 std::vector<int>& chainForces);
447
448 //! \brief Removes a sim object from the tree by UUID
449 //! \param uuid The entity UUID to remove
450 void removeEntityFromTree(const DtUUID& uuid);
451
452 //! \brief Updates the status labels with current counts
453 //!
454 //! Refreshes the entity and station status labels in the new UI
455 //! with current entity count, station count, and unassigned count.
457
458 //! \brief Updates the submit button text and enabled state
459 //!
460 //! Enables the submit button when pending changes exist and updates
461 //! the button text to show pending and reassignment counts.
463
464 //! \brief Saves assignment file data to the given file path.
465 //! \return true on success; shows a critical dialog and returns false on error.
466 bool saveAssignmentsToFile(const QString& filePath);
467
468 //! \brief Loads and imports assignments from the given file path.
469 //! \return true on (possibly partial) success; shows dialogs for errors and warnings.
470 bool loadAssignmentsFromFile(const QString& filePath);
471
472public:
473 //! \brief Sets the assignment file to load automatically on first activation.
474 //! \param filePath Path to a JSON assignment file, or empty to disable.
475 //!
476 //! When non-empty, the file is loaded once the first time activate() is called
477 //! (i.e. when the Manager Panel first becomes visible). The stored path is
478 //! cleared immediately after the load attempt so subsequent show/hide cycles
479 //! do not re-trigger the load.
480 void setStartupAssignmentFile(const QString& filePath);
481
482 //! \brief Returns true if the given entity UUID exists in the current exercise.
483 bool entityExistsInCurrentExercise(const DtUUID& entityUUID) const;
484
485 //! \brief Shows a QMessageBox warning listing the given warnings under \p title.
486 void showPersistenceWarnings(const QStringList& warnings, const QString& title);
487
488 //! \brief Shared submit implementation
489 //!
490 //! \param allowConflicts If true, the submit proceeds even when conflicts exist
491 void submitChanges(bool allowConflicts);
492
493protected:
494 //! \brief Class name for this page type
495 //!
496 //! Unique string identifier for this page class.
497 std::string myClassName;
498
499 //! \brief UI components for the new two-panel splitter layout (Phase 3)
500 //!
501 //! Contains the tree view, list view, search boxes, sort controls,
502 //! toolbar buttons, and status labels for the redesigned Manager Panel.
503 Ui::DtVreManagerWidgetNew myNewUI;
504
505 //! \brief Sort/filter proxy wrapping the station list model
506 //!
507 //! Provides alphabetical sorting of the station list display while
508 //! leaving the source model's own filter logic intact.
510
511 //! \brief VREngage status listener
512 //!
513 //! Tracks status information for VREngage applications.
515
516 //! \brief Assignment tracker for managing pending and confirmed assignments
517 //!
518 //! Provides a unified view of station assignments, combining confirmed
519 //! state from the status listener with pending user edits.
521
522 //! \brief Tree model for entity/role hierarchy display (Phase 2)
523 //!
524 //! Provides a two-level tree model where entities are at level 0 and
525 //! roles are at level 1. Used for the left panel in the new UI design.
527
528 //! \brief List model for station display (Phase 2)
529 //!
530 //! Provides a flat list of all VR-Engage stations with assignment status.
531 //! Used for the right panel in the new UI design.
533
534 //! \brief Signal connection manager
535 //!
536 //! Manages Qt signal/slot connections for cleanup.
537 makVrv::DtSignalConnectionManager myConnectionManager;
538
539 //! \brief Guards against re-connecting the sim-object manager signals.
540 //!
541 //! activate() may be called on every show; the sim-object manager signal
542 //! connections must be made only once or each cycle would add a duplicate.
544
545 //! \brief Assignment file to load automatically on the first activation.
546 //!
547 //! Set via setStartupAssignmentFile() before the panel is first shown.
548 //! Consumed and cleared in activate() after the first successful load attempt.
550
551 // -------------------------------------------------------------------------
552 //! @name Phase 3: Selection State
553 //! State tracking for the assignment workflow in the new UI.
554 //! @{
555 // -------------------------------------------------------------------------
556
557 //! \brief Currently selected (armed) entity UUID for assignment
558 //!
559 //! Set when the user clicks a role node in the entity/role tree.
560 //! Cleared after an assignment is made or the selection is cancelled.
562
563 //! \brief Currently selected (armed) role name for assignment
564 //!
565 //! Set together with mySelectedEntityUUID when a role node is clicked.
567
568 //! \brief Currently selected station ID in the station list
569 //!
570 //! Set when the user clicks a station in the station list.
572
573 //! \brief Tracks whether the entity/role tree is fully expanded
574 //!
575 //! Used by the toggle button to alternate between expand-all and collapse-all.
576 bool myTreeExpanded = false;
577
578 //! \brief True when the assignment-status key is the active station sort key
580
581 //! \brief Active sort direction for the station list
582 Qt::SortOrder myStationSortOrder = Qt::AscendingOrder;
583
584 //! \brief Exclusive group owning the two station sort buttons
585 QButtonGroup* myStationSortButtonGroup = nullptr;
586
587 //! \brief Overlay child widgets that draw active and hover-hint sort
588 //! indicator arrows on top of the two station sort buttons. Stored as
589 //! QWidget* because the concrete type lives in an anonymous namespace
590 //! in the implementation file.
591 QWidget* myStatusSortOverlay = nullptr;
592 QWidget* myStationNameSortOverlay = nullptr;
593
594 //! \brief Expand/collapse toggle button embedded in the entity/role tree header
595 //!
596 //! Created programmatically and parented to the tree's QHeaderView.
597 //! Positioned so it aligns with force-level disclosure triangles.
598 QToolButton* myExpandCollapseBtn = nullptr;
599
600 //! \brief Tracks whether the entity/role header is currently hovered
602
603 //! \brief Tracks whether the embedded expand/collapse button is currently hovered
605
606 //! \brief Custom delegate installed on column 1 of the entity/role tree
607 //!
608 //! Renders the assignment-status column: entity icon + station name for role
609 //! leaves; "<assigned>/<total>" count text for force / entity branching nodes.
611
612 //! @}
613
614 //! \brief Currently loaded SMS filename
615 //!
616 //! The filename of the currently loaded Simulation Model Set.
618
619 //! \brief Save assignments toolbar button (new UI path)
620 QToolButton* mySaveButton = nullptr;
621
622 //! \brief Load assignments toolbar button (new UI path)
623 QToolButton* myLoadButton = nullptr;
624
625 //! \brief Cache of the last-observed force type for each entity in the tree
626 //!
627 //! Maps entity UUID to its last-known SISO force-type value.
628 //! Updated in tryAddEntityToTree() whenever an entity is added or refreshed,
629 //! and erased in removeEntityFromTree(). Used to detect force-type changes
630 //! so that entityForceTypeChanged() can be emitted when the value differs.
631 std::map<DtUUID, int> myEntityForceTypes;
632
633 //! \brief Set of aggregate UUIDs currently mirrored into the tree (Phase 8)
634 //!
635 //! Populated as we walk \c DtSimObject::parent() chains during
636 //! \c tryAddEntityToTree(). Lets \c signal_objectDeleted distinguish
637 //! aggregate sim-object deletions (which prune via \c removeAggregateNode())
638 //! from entity deletions (which prune via \c removeEntityFromTree()).
639 std::set<DtUUID> myKnownAggregates;
640
641 //! \brief Whether the optional Sim Engine column (column 2) is currently visible
642 //!
643 //! Toggled at runtime via the entity/role tree header context menu
644 //! (onTreeHeaderContextMenu). Kept purely in-memory — the column resets
645 //! to hidden on every launch.
647
648 //! \brief Periodic timer that refreshes the Sim Engine column
649 //!
650 //! Fires every 2 seconds and calls refreshSimEngineAddresses() to pick up
651 //! ownership transfers that change an entity's simulating engine address.
652 //! Owned as a QObject child — cleaned up automatically.
653 QTimer* mySimEngineRefreshTimer = nullptr;
654
655 //! \brief Re-entrancy guard for the per-column floor enforcement slot
656 //!
657 //! `QHeaderView::minimumSectionSize` is global, so per-column floors are
658 //! enforced in `setupNewUi()` via a `sectionResized` lambda that calls
659 //! `resizeSection()` back when a column drops below its floor. That nested
660 //! `resizeSection()` re-enters the same signal; this flag short-circuits
661 //! the second pass to avoid infinite recursion. See Phase 5a.
663
664};
665
666
667//! \brief Factory class for creating VREngage manager widgets
668//!
669//! This creator class is responsible for instantiating DtVreManagerWidget
670//! objects for the application. It implements the DtPageCreator interface
671//! to allow the manager to be added to the application's page system.
672class VREMANAGER_DLL DtVreManagerWidgetCreator : public makVrv::DtPageCreator
673{
674public:
675 //! \brief Constructor
676 //! \param de The distributed environment reference
677 //! \param startupAssignmentFile Optional path to an assignment file to load
678 //! automatically the first time the Manager Panel becomes visible. Pass an
679 //! empty QString (the default) to disable automatic loading.
680 //!
681 //! Initializes a new creator for VREngage manager widgets.
683 const QString& startupAssignmentFile = QString());
684
685 //! \brief Virtual destructor
686 //!
687 //! Allows for proper cleanup of derived classes.
688 virtual ~DtVreManagerWidgetCreator() override;
689
690 //! \brief Gets the page class name
691 //! \return The unique class name string
692 //!
693 //! Returns the unique identifier for the page class this creator instantiates.
694 //! This name should be unique across all pages. This is not the human-readable
695 //! title of the page. When replacing a page, this class name should remain the same.
696 virtual std::string pageClassName() const override;
697
698 //! \brief Creates a new page instance
699 //! \param parent The parent widget
700 //! \param f Window flags to apply to the widget
701 //! \return Pointer to the newly created page
702 //!
703 //! Creates a new instance of the DtVreManagerWidget class.
704 virtual makVrv::DtPage* create(QWidget* parent = 0, Qt::WindowFlags f = 0) override;
705
706protected:
707 //! \brief Optional path to an assignment file to load on first activation.
709};
710} // namespace makVre
Tracks the status of VREngage applications.
Definition vreListener.h:105
Custom delegate for column 1 of the entity/role tree.
Definition entityRoleTreeDelegate.h:46
Centralized tracking of confirmed and pending station assignments.
Definition vreAssignmentTracker.h:187
Tree model for entity/role hierarchy display.
Definition vreEntityRoleTreeModel.h:253
virtual makVrv::DtPage * create(QWidget *parent=0, Qt::WindowFlags f=0) override
Creates a new page instance.
QString myStartupAssignmentFile
Optional path to an assignment file to load on first activation.
Definition vreManagerWidget.h:708
virtual std::string pageClassName() const override
Gets the page class name.
virtual ~DtVreManagerWidgetCreator() override
Virtual destructor.
DtVreManagerWidgetCreator(makVrv::DtDe &de, const QString &startupAssignmentFile=QString())
Constructor.
virtual void onStationSearchChanged(const QString &text)
Handles station search text changes.
QTimer * mySimEngineRefreshTimer
Periodic timer that refreshes the Sim Engine column.
Definition vreManagerWidget.h:653
bool mySimEngineColumnVisible
Whether the optional Sim Engine column (column 2) is currently visible.
Definition vreManagerWidget.h:646
std::string myClassName
Class name for this page type.
Definition vreManagerWidget.h:497
void refreshSimEngineAddresses()
Refreshes the cached Sim Engine address for every tracked entity.
void setEntityRoleHeaderHoverActive(bool active)
Mirrors header-hover visual state to the embedded expand/collapse button.
QString mySelectedRoleName
Currently selected (armed) role name for assignment.
Definition vreManagerWidget.h:566
void resolveAggregateChain(const makVrf::DtSimObjectReference &ref, std::vector< DtUUID > &chainUUIDs, std::vector< std::string > &chainNames, std::vector< QIcon > &chainIcons, std::vector< int > &chainForces)
Walk the aggregate parent chain for a sim-object reference (Phase 8)
void refreshExpandButtonIcon()
Rebuilds the expand/collapse toggle button icon from the current palette.
bool entityExistsInCurrentExercise(const DtUUID &entityUUID) const
Returns true if the given entity UUID exists in the current exercise.
QToolButton * mySaveButton
Save assignments toolbar button (new UI path)
Definition vreManagerWidget.h:620
QWidget * myStationNameSortOverlay
Currently selected (armed) entity UUID for assignment.
Definition vreManagerWidget.h:592
virtual QSize minimumSizeHint() const override
Returns the smallest sensible size for the dock.
DtVreManagerWidget(makVrv::DtDe &de, QWidget *parent=0, Qt::WindowFlags f=0)
Constructor.
virtual void onLoadAssignments()
Opens a file dialog and loads an assignment layout from JSON.
virtual void onEntityRoleTreeClicked(const QModelIndex &index)
Handles clicks on the entity/role tree.
bool myInSectionResizeGuard
Re-entrancy guard for the per-column floor enforcement slot.
Definition vreManagerWidget.h:662
virtual void onToggleExpandCollapse()
Toggles between expanding and collapsing all entity nodes in the tree.
virtual QString title() override
Gets the title for this page.
static void vreAppRemovedCallback(const std::string &id, void *usr)
Static callback for VREngage application removal.
virtual void onStationNameSortButtonClicked()
Handles clicks on the station-name sort button.
virtual void onDataChanged()
Handles data changes in the table model.
virtual void onRevert()
Handles reverting of changes.
DtVreStationSortProxyModel * mySortProxy
Sort/filter proxy wrapping the station list model.
Definition vreManagerWidget.h:509
virtual makVrv::DtQIconConfigurations qIconConfigurations() const override
Gets the icon configurations for the page.
DtVreStationListModel * myStationListModel
List model for station display (Phase 2)
Definition vreManagerWidget.h:532
DtEntityRoleTreeDelegate * myTreeColDelegate
Custom delegate installed on column 1 of the entity/role tree.
Definition vreManagerWidget.h:610
QToolButton * myLoadButton
Load assignments toolbar button (new UI path)
Definition vreManagerWidget.h:623
QWidget * myStatusSortOverlay
Overlay child widgets that draw active and hover-hint sort indicator arrows on top of the two station...
Definition vreManagerWidget.h:591
DtFilename myLoadedSMSFileName
Currently loaded SMS filename.
Definition vreManagerWidget.h:617
bool eventFilter(QObject *watched, QEvent *event) override
Filters mouse events on the entity/role tree viewport.
virtual void handleDeactivate()
Internal deactivation handler.
virtual void handleActivate()
Internal activation handler.
bool myExpandCollapseButtonHovered
Tracks whether the embedded expand/collapse button is currently hovered.
Definition vreManagerWidget.h:604
virtual void onStationListContextMenu(const QPoint &pos)
Handles right-click context menu on the station list.
std::set< DtUUID > myKnownAggregates
Set of aggregate UUIDs currently mirrored into the tree (Phase 8)
Definition vreManagerWidget.h:639
bool mySimObjectSignalsConnected
Guards against re-connecting the sim-object manager signals.
Definition vreManagerWidget.h:543
std::string mySelectedStationId
Currently selected station ID in the station list.
Definition vreManagerWidget.h:571
virtual void onAssignmentStateChanged()
Handles assignment tracker state changes.
bool saveAssignmentsToFile(const QString &filePath)
Saves assignment file data to the given file path.
DtVreEntityRoleTreeModel * myTreeModel
Tree model for entity/role hierarchy display (Phase 2)
Definition vreManagerWidget.h:526
virtual void onStatusIndicatorClicked(const QString &stationId)
Handles a click on the status indicator circle.
virtual void onModelSetChanged()
Handles model set changes.
virtual void onEntityRoleHeaderSortIndicatorChanged(int section, Qt::SortOrder order)
Applies entity/role tree ordering when the header sort indicator changes.
virtual void handleVreAppChanged(const std::string &id)
Handles VREngage application status changes.
DtVreAssignmentTracker * myAssignmentTracker
Assignment tracker for managing pending and confirmed assignments.
Definition vreManagerWidget.h:520
DtUUID mySelectedEntityUUID
Currently selected (armed) entity UUID for assignment.
Definition vreManagerWidget.h:561
virtual void handleVreAppAdded(const std::string &id)
Handles VREngage application addition.
void showPersistenceWarnings(const QStringList &warnings, const QString &title)
Shows a QMessageBox warning listing the given warnings under title.
QString myStartupAssignmentFile
Assignment file to load automatically on the first activation.
Definition vreManagerWidget.h:549
void submitChanges(bool allowConflicts)
Shared submit implementation.
virtual void activate() override
Called when the page is displayed.
virtual void onSubmit()
Handles submission of changes.
virtual void changeEvent(QEvent *event) override
Responds to palette changes so toolbar icons repaint in the correct colour.
virtual void onUserEditComplete()
Handles completion of user edits.
static void vreAppChangedCallback(const std::string &id, void *usr)
Static callback for VREngage application status changes.
makVrv::DtSignalConnectionManager myConnectionManager
Signal connection manager.
Definition vreManagerWidget.h:537
void setupNewUi()
Sets up the new two-panel splitter UI (Phase 3)
static void vreAppAddedCallback(const std::string &id, void *usr)
Static callback for VREngage application discovery.
bool myStationSortByStatus
True when the assignment-status key is the active station sort key.
Definition vreManagerWidget.h:579
DtVreStatusListener * myVreListener
VREngage status listener.
Definition vreManagerWidget.h:514
bool myEntityRoleHeaderHovered
Tracks whether the entity/role header is currently hovered.
Definition vreManagerWidget.h:601
void tryAddEntityToTree(const DtUUID &uuid)
Attempts to add a single sim object to the tree if VRE-engageable.
void refreshStationNameSortButtonIcon()
Refreshes the station-name sort button presentation.
virtual QIcon icon() override
Gets the icon for this page.
void removeEntityFromTree(const DtUUID &uuid)
Removes a sim object from the tree by UUID.
bool loadAssignmentsFromFile(const QString &filePath)
Loads and imports assignments from the given file path.
void populateEntitiesFromExercise()
Populates the entity/role tree with all VRE-engageable entities.
std::map< DtUUID, int > myEntityForceTypes
Cache of the last-observed force type for each entity in the tree.
Definition vreManagerWidget.h:631
virtual void onSaveAssignments()
Opens a file dialog and saves the current assignment layout to JSON.
Ui::DtVreManagerWidgetNew myNewUI
UI components for the new two-panel splitter layout (Phase 3)
Definition vreManagerWidget.h:503
virtual void handleVreAppRemoved(const std::string &id)
Handles VREngage application removal.
virtual void onTreeHeaderContextMenu(const QPoint &pos)
Pops the entity/role tree header context menu.
void syncExpandButtonState()
Syncs the expand/collapse toggle button to reflect the tree's actual state.
void setupUi(QWidget *p)
Sets up the UI components.
virtual ~DtVreManagerWidget() override
Virtual destructor.
virtual QSize sizeHint() const override
Returns preferred initial size for dock sizing.
friend class DtVreManagerWidgetCreator
Allows the creator class to create page instances.
Definition vreManagerWidget.h:326
virtual void onStationListClicked(const QModelIndex &index)
Handles clicks on the station list.
void applyStationSortState()
Applies station-list sort state to proxy and updates button visuals.
virtual void deactivate() override
Called when the page is hidden.
void entityForceTypeChanged(const QString &entityUUID, int newRawForceType)
Emitted when a known entity's force type changes at runtime.
virtual void onSpectatorToggleClicked(const QString &stationId)
Handles a click on the spectator mode toggle button.
virtual void onEntitySearchChanged(const QString &text)
Handles entity search text changes.
void updateStatusLabels()
Updates the status labels with current counts.
Qt::SortOrder myStationSortOrder
Active sort direction for the station list.
Definition vreManagerWidget.h:582
virtual void onSubmitWithConflicts()
Handles submission of changes even when conflicts exist.
void updateSubmitButtonState()
Updates the submit button text and enabled state.
QToolButton * myExpandCollapseBtn
Expand/collapse toggle button embedded in the entity/role tree header.
Definition vreManagerWidget.h:598
bool myTreeExpanded
Tracks whether the entity/role tree is fully expanded.
Definition vreManagerWidget.h:576
virtual void onStatusSortButtonClicked()
Handles clicks on the assignment-status sort button.
void refreshStatusSortButtonIcon()
Rebuilds the assignment-status sort button icon from the current palette.
virtual const std::string & pageClassName() const override
Gets the class name of the page.
void setStartupAssignmentFile(const QString &filePath)
Sets the assignment file to load automatically on first activation.
QButtonGroup * myStationSortButtonGroup
Exclusive group owning the two station sort buttons.
Definition vreManagerWidget.h:585
virtual void showEvent(QShowEvent *event) override
Repaints toolbar icons on first show.
List model for VR-Engage station display.
Definition vreStationListModel.h:136
Two-key sort proxy for the VR-Engage station list.
Definition vreStationSortProxyModel.h:36
Custom delegate for column 1 of the entity/role tree.
Export macros for the VREngage Manager library.
#define VREMANAGER_DLL
Platform-specific export/import macro for VREngage Manager library.
Definition export.h:28
!
Definition glsVreMessageUtil.h:50
makVrv::DtDe * de()
Gets the display element pointer used by the plugin.