![]() |
VR-Forces 4.7 Class Documentation
|
The Custom Control Object example adds a new control object to the create menus and creates and associates a new dialog box to use during creation and editing of this new control object.
The new control object and its dialog boxes are area-type objects and its classes are derived from the Area control object. Two custom numeric parameters are associated with the new control object.
The front-end example demonstrates the following:
Objects get assigned to the object creation palettes based on information in their .entity file. The information comes from the settings chosen in the Simulation Object Editor. Specifically, objects get placed on a palette based on the gui-on-palettes parameter. If this parameter is not specified, objects get placed on a palette based on their entity type enumeration. Objects with a kind value >= 16 get placed on the Tactical Graphics palette. The custom control object has a kind value of 18. Within a particular palette, objects get organized based on the gui-categories parameter. An object can be in more than one category.
The Custom Control Object example inherits the dialog class structure used by Area control objects (DtShapeObjectDefinitionDialog, DtShapeObjectDefinitionDialogLogic and DtShapeObjectDefinitionDialogCreator), makes certain modifications and additions, and then registers the new dialog creator with the appropriate dialog manager (DtVrfObjectModifierDialogManager), associating it with the specific entity ID associated with the new control object.
DtCustomControlObjectDefinitionDialog, derived from DtShapeObjectDefinitionDialog, is ultimately derived from the Qt class QDockWidget. As such, it must be registered with Qt as a Q_OBJECT during compilation. Its specific role is to handle the placement and registration of GUI elements and transportation of data to and from these GUI elements. The Dialog class intantiates its own Logic class, DtCustomControlObjectDefinitionDialogLogic upon intialization.
DtCustomControlObjectDefinitionDialogLogic, derived from DtShapeObjectDefinitionDialogLogic, mostly acts as the interface between data from the DtCustomControlObjectDefinitionDialog and data in the rest of VR-Forces. In particular in this example, the Logic class translates betwen Parameter One and Parameter Two (an int and double, respectively) and userData, the std::string that they are stored in.
DtCustomControlObjectDefinitionDialogCreator is a class consisting only of a simple creator and initialization function that is registered with the Dialog Manager and called when the user invokes the creation or edit of the custom control object.
Adding an attribute to an entity is a fairly involved process (described and demonstrated in detail in the AddAttribute example). In order to expedite the process of adding attributes or parameters to control objects in VR-Forces, all control objects have a field of string type referred to as userData. This field is fully implemented but not used by stock VR-Forces.
The custom control object example introduces two custom parameters to the control object type, an int and a double (labeled as "Integer" and "Double" respectively). These parameters are transformed to and from a token-separated string by the Logic class and sent on to be stored in the control object's userdata field.
Naturally, extensive use of userdata must be carefully monitored to ensure that different implementations of userdata do not interfere with each other.
To view the new behavior:
The code for the three classes referenced in the table are here: Custom Control Object Dialog.
| DtCustomControlObjectDefinitionDialog | The Qt-derived dialog class. |
| DtCustomControlObjectDefinitionDialogLogic | The logic class providing processing and transport of data to and from the dialog class. |
| DtCustomControlObjectDefinitionDialogCreator | The creator function for the dialog class, registered with the entity modification manager (DtVrfObjectModifierDialogManager). |