VR-Engage  2.2
Loading...
Searching...
No Matches
vreModelSetEntry.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file vreModelSetEntry.h
7//! \ingroup vreUtil
8//! \brief Extends model set entries with VR-Engage specific role data
9//!
10//! This file defines the DtVreModelSetEntry class which extends VR-Forces' DtModelSetEntry
11//! with the ability to read and write VR-Engage-specific role data in entity files.
12//! It manages role descriptors, parameters, and display configurations for entities.
13
14#pragma once
15
16#include "vreUtil/export.h"
19
20#include <vrfobjparam/modelSetEntry.h>
21
22namespace vreXml
23{
24//! \brief XML tag for VR-Engage roles container
25static const char* EngageRolesTag = "vrEngageRoles";
26//! \brief XML tag for individual VR-Engage role
27static const char* EngageRoleTag = "role";
28//! \brief XML tag for role slot name attribute
29static const char* EngageRoleSlotNameTag = "slotName";
30//! \brief XML tag for unlisted role attribute
31static const char* EngageRoleUnlistedTag = "unlisted";
32//! \brief XML tag for default display layout attribute
33static const char* EngageRoleDefaultDisplayConfigTag = "defaultDisplayLayout";
34//! \brief XML tag for parameter override element
35static const char* EngageParameterOverrideTag = "parameterOverride";
36//! \brief XML tag for display configuration element
37static const char* EngageDisplayConfigurationTag = "displayConfiguration";
38} // namespace vreXml
39
40namespace makVre
41{
42//! \brief Default display layout name for entity roles
43//!
44//! It is expected that there will always be a default display layout available
45//! for all entity roles. This is the name of that expected display layout.
46static const char* DtDefaultDisplayLayout = "1 Screen Horizontal";
47
48//! \brief Default value for the unlisted attribute of roles
49//!
50//! By default, role configurations should be listed in the Choose Role panel.
51//! Setting this to true would hide the role from the panel.
52static bool DtDefaultUnlistedValue = false;
53
54//! \brief VR-Engage specific model set entry with role information
55//!
56//! This class extends the base VR-Forces model set entry to provide VR-Engage
57//! specific functionality for managing entity roles, role parameters, and display
58//! configurations. It handles reading and writing role data to/from entity files.
59class UTIL_DLL DtVreModelSetEntry : public DtModelSetEntry
60{
61public:
62 //! \brief Default constructor
63 //!
64 //! Creates an empty model set entry with no name or registry
66
67 //! \brief Named constructor with optional registry
68 //! \param name The name of the model set entry
69 //! \param parentRegistry Optional parent registry for resource loading
70 DtVreModelSetEntry(const DtString& name, DtReaderWriterRegistry* const parentRegistry = NULL);
71
72 //! \brief Copy constructor
73 //! \param orig The model set entry to copy
74 //! \param parentRegistry Optional parent registry for resource loading
75 DtVreModelSetEntry(const DtVreModelSetEntry& orig, DtReaderWriterRegistry* const parentRegistry = NULL);
76
77 //! \brief Assignment operator for VR-Engage model set entries
78 //! \param orig The model set entry to copy from
79 //! \return Reference to this object
80 //!
81 //! Performs a deep copy of the VR-Engage specific data
83
84 //! \brief Assignment operator for base model set entries
85 //! \param orig The base model set entry to copy from
86 //! \return Reference to this object
87 //!
88 //! The override allows us to eventually call the derived assignment operator
89 virtual DtVreModelSetEntry& operator=(const DtModelSetEntry& orig) override;
90
91 //! \brief Virtual destructor
92 //!
93 //! Cleans up resources owned by the model set entry
94 virtual ~DtVreModelSetEntry() override;
95
96 //! \brief Creates a copy of this model set entry
97 //! \return Pointer to the newly created copy
98 virtual DtModelSetEntry* clone() override;
99
100 //! \brief Checks if this entity can be controlled in VR-Engage
101 //! \return True if the entity is controllable in VR-Engage, false otherwise
102 virtual bool engageControllable() const;
103
104 //! \brief Gets the list of available roles for this entity
105 //! \return Vector of role names
106 virtual std::vector<std::string> roles();
107
108 //! \brief Finds a role descriptor by name
109 //! \param role The name of the role to find
110 //! \return Pointer to the role descriptor if found, nullptr otherwise
111 virtual const DtEntityRoleDescriptor* findRoleDescriptor(const std::string& role);
112
113 //! \brief Adds a new role to the entity
114 //! \param role The name of the role to add
115 //! \param rolePath Path to the role configuration file
116 //! \param unlisted Whether the role should be hidden from role selection panels
117 virtual void addRole(const std::string& role, const std::string& rolePath, bool unlisted = false);
118
119 //! \brief Adds a parameter to an existing role
120 //! \param role The name of the role to add the parameter to
121 //! \param roleParameter The name of the parameter to add
122 //! \param paramValue The value of the parameter
123 virtual void addRoleParameter(
124 const std::string& role, const std::string& roleParameter, const std::string& paramValue);
125
126 //! \brief Loads model set entry information from the specified environment
127 //! \param e The environment to read from
128 //! \param objectNode The object node to read from
129 //! \param keepCurrentData Whether to retain existing data when reading
130 //!
131 //! Looks for a variable in the environment called guiInformation and extracts
132 //! attributes and role information from that node. VR-Engage specific data is
133 //! read from the vrEngageRoles section if present.
134 virtual void readFromEnvironment(DtEnvironmentSP e, DtEnvValueSP objectNode, bool keepCurrentData = false) override;
135
136 //! \brief Writes entry contents to the specified environment
137 //! \param e The environment to write to
138 //! \param objectNode The object node to write to
139 //! \param vec Optional vector to track modified attributes
140 //! \param mse Optional model set entry for reference
141 //!
142 //! Writes the model set entry information to the guiInformation section of the
143 //! environment. VR-Engage specific role data is written to the vrEngageRoles section.
144 virtual void writeToEnvironment(DtEnvironmentSP e,
145 DtEnvValueSP objectNode,
146 std::vector<DtString>* vec = nullptr,
147 DtModelSetEntry* mse = nullptr) const override;
148
149 //! \brief Gets the filename associated with this entry
150 //! \return The filename of the entity file that created this entry
151 virtual std::string filename() const;
152
153 //! \brief Factory method for creating model set entry instances
154 //! \param name The name of the model set entry to create
155 //! \param parentRegistry Optional parent registry for resource loading
156 //! \return Pointer to the newly created model set entry
157 //!
158 //! This static method creates a new instance of DtVreModelSetEntry. Used by the factory system.
159 static DtModelSetEntry* Create(
160 const DtString& name = "model-set-entry", DtReaderWriterRegistry* const parentRegistry = nullptr);
161
162protected:
163 //! \brief Gets parameter overrides from an environment node
164 //! \param e The environment to read from
165 //! \param node The node to read parameters from
166 //! \param parameterOverrides Output map to store parameter name/value pairs
167 //!
168 //! Extracts parameter overrides from the given node, only including parameters
169 //! that are immediate children of that node.
171 DtEnvironmentSP e, DtEnvValueSP node, std::map<std::string, std::string>& parameterOverrides);
172
173 //! \brief Resolves path variables in a string
174 //! \param path The path string to resolve
175 //! \return The resolved path with variables expanded
176 //!
177 //! Replaces instances of '@' with '$' (as '@' is used instead of '$' in XML files)
178 //! and then resolves any $DATA_DIR or $SHARED_DATA_DIR variables in the path.
179 virtual std::string resolvePath(const std::string& path) const;
180
181 //! \brief Marks up a path with variables for XML storage
182 //! \param path The path string to mark up
183 //! \return The marked up path with variables and XML-safe characters
184 //!
185 //! Substitutes in $DATA_DIR or $SHARED_DATA_DIR variables for specific path prefixes,
186 //! and replaces '$' with '@' (needed for XML files which cannot tolerate '$').
187 virtual std::string markupPath(const std::string& path) const;
188
189protected:
190 //! \brief Map of role names to role descriptors
191 //!
192 //! Contains all the roles supported by this entity and their associated configuration
193 std::map<std::string, DtEntityRoleDescriptor> myRoleDescriptors;
194
195 //! \brief Cache of the filename used to create this entry
196 //!
197 //! Stores the path to the entity file that was loaded to create this entry
198 std::string myFilename;
199};
200} // namespace makVre
virtual DtModelSetEntry * clone() override
Creates a copy of this model set entry.
virtual DtVreModelSetEntry & operator=(const DtModelSetEntry &orig) override
Assignment operator for base model set entries.
virtual std::string markupPath(const std::string &path) const
Marks up a path with variables for XML storage.
DtVreModelSetEntry(const DtVreModelSetEntry &orig, DtReaderWriterRegistry *const parentRegistry=NULL)
Copy constructor.
virtual std::string resolvePath(const std::string &path) const
Resolves path variables in a string.
virtual const DtEntityRoleDescriptor * findRoleDescriptor(const std::string &role)
Finds a role descriptor by name.
virtual ~DtVreModelSetEntry() override
Virtual destructor.
virtual std::vector< std::string > roles()
Gets the list of available roles for this entity.
virtual void addRole(const std::string &role, const std::string &rolePath, bool unlisted=false)
Adds a new role to the entity.
std::string myFilename
Cache of the filename used to create this entry.
Definition vreModelSetEntry.h:198
DtVreModelSetEntry()
Default constructor.
DtVreModelSetEntry(const DtString &name, DtReaderWriterRegistry *const parentRegistry=NULL)
Named constructor with optional registry.
virtual void writeToEnvironment(DtEnvironmentSP e, DtEnvValueSP objectNode, std::vector< DtString > *vec=nullptr, DtModelSetEntry *mse=nullptr) const override
Writes entry contents to the specified environment.
virtual void getParameterOverrides(DtEnvironmentSP e, DtEnvValueSP node, std::map< std::string, std::string > &parameterOverrides)
Gets parameter overrides from an environment node.
virtual std::string filename() const
Gets the filename associated with this entry.
virtual DtVreModelSetEntry & operator=(const DtVreModelSetEntry &orig)
Assignment operator for VR-Engage model set entries.
virtual void readFromEnvironment(DtEnvironmentSP e, DtEnvValueSP objectNode, bool keepCurrentData=false) override
Loads model set entry information from the specified environment.
std::map< std::string, DtEntityRoleDescriptor > myRoleDescriptors
Map of role names to role descriptors.
Definition vreModelSetEntry.h:193
static DtModelSetEntry * Create(const DtString &name="model-set-entry", DtReaderWriterRegistry *const parentRegistry=nullptr)
Factory method for creating model set entry instances.
virtual bool engageControllable() const
Checks if this entity can be controlled in VR-Engage.
virtual void addRoleParameter(const std::string &role, const std::string &roleParameter, const std::string &paramValue)
Adds a parameter to an existing role.
Defines data structures for entity role configurations.
Defines export macros for the VREngage Utility library.
#define UTIL_DLL
Export/import macro for non-Windows platforms.
Definition export.h:39
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
static bool DtDefaultUnlistedValue
Default value for the unlisted attribute of roles.
Definition vreModelSetEntry.h:52
static const char * DtDefaultDisplayLayout
Default display layout name for entity roles.
Definition vreModelSetEntry.h:46
Definition vreModelSetEntry.h:23
static const char * EngageParameterOverrideTag
XML tag for parameter override element.
Definition vreModelSetEntry.h:35
static const char * EngageRoleUnlistedTag
XML tag for unlisted role attribute.
Definition vreModelSetEntry.h:31
static const char * EngageRoleTag
XML tag for individual VR-Engage role.
Definition vreModelSetEntry.h:27
static const char * EngageRolesTag
XML tag for VR-Engage roles container.
Definition vreModelSetEntry.h:25
static const char * EngageDisplayConfigurationTag
XML tag for display configuration element.
Definition vreModelSetEntry.h:37
static const char * EngageRoleDefaultDisplayConfigTag
XML tag for default display layout attribute.
Definition vreModelSetEntry.h:33
static const char * EngageRoleSlotNameTag
XML tag for role slot name attribute.
Definition vreModelSetEntry.h:29
Descriptor for an entity role.
Definition entityRoleDescriptorStructs.h:46
Extends model set entries with VR-Engage specific role data.