VR-Forces 4.10 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Add Set (Front-End) (addSetGui)

Table of Contents

The Add Set example creates a new "Set" command that allows a user to set an entity's current speed and heading.

When the command is selected from the Set menu, a dialog box that allows entry of desired speed/ heading is created. The larger architecture of GUI and Menus in the VR Forces Front End is described in VR-Vantage Architecture Walkthrough - The GUI Layer and GUI Architecture.

The front-end example demonstrates the following:

Adding an Item to the Set Menu

Most of the work in placing, registering and associating a menu item in this example is done in addSet/addSetGui/addSetPlugin.cxx. Adding an item to the set menu involves establishing a menu item object derived from the makVrf::DtVrfTaskSetMenuItem class. This example creates a menu item called vrfAddSetExample::DtSetSpeedAndHeadingMenuItem. A string called the menuItemIdName linking this entry to its menu item object must be inserted into the makVrf::DtSetMenu relative to another menuItemIdName:

//Inserts the DtSetSpeedAndHeadingMenuItem object name as the menu item into a specific point of the Set Menu with the masterModeMenuConfiguration
//The set entry is placed after the menu entry corresponding to the "DtVrfSetResponsibilityAction" object
DtVrfScenarioManager::instance(*de).initialSetMenuConfiguration().addMenuItemAfter(DtSetSpeedAndHeadingMenuItemIdName, DtVrfSetLocationActionId);

Now the actual menu item object vrfAddSetExample::DtSetSpeedAndHeadingMenuItem must be instantiated and registered with the set menu assembler:

The menu item inserted in the first quoted bit of code is associated in the Set Menu by the common text string vrfAddSetExample::DtSetSpeedAndHeadingMenuItemIdName. A string like this one is central to the identification of all menu items and our vrfAddSetExample::DtSetSpeedAndHeadingMenuItem object is initialized with this string.

Creating and Linking a GUI Dialog Box

In this example, the dialog box object is derived from DtSetSpeedAndHeadingDialog - a Qt object ultimately derived from QWidget. The actual layout and definition of the interface is entirely specified in the contents() method, and the accessors and mutators are also contained in this object. There is an associated creator object deriving from DtVrfTaskSetDialogCreator - in our case, DtSetSpeedAndHeadingDialogCreator - that is registered with the DtVrfTaskSetDialogManager in the constructor of the menu item (DtSetSpeedAndHeadingMenuItem).

Sending the Set Command From the Front-end to the Back-end

The back-end set-creator function, DtSetSpeedAndHeadingRequest.creator(), is registered with the DtVrfSimMessager in the front-end plugin initialization, initDeModule. It links the back-end creator with the front-end via the common string DtSetSpeedAndHeadingString. In the back-end, the creator function is registered with the factory in DtInitializeVrfPlugin in addSetSim\plugin.cxx. The message sent through the DtSetSpeedAndHeadingRequest is passed on to the entity-specific controllers generated in the back-end.

Since this example is loaded as a plugin, it can be used in conjunction with the released VR-Forces application

a scripted set

This example also shows how to create a scripted set. A scripted set contains a dialog plus a lua script to implement the actual set. The scenario "addScriptedSet" in the developer toolkit examples directory, when loaded, will show how the set dialog is added and the lua code needed to execute the set. In order to run this scenario you must have build the back-end portion of the example plugin and have that loaded. If you do not you will get a lua script error in running this sample

How to Run the Example

This example demonstrates how to add a new kind of set data request (set heading and ordered speed).

To view the new behavior:

  1. Open a database or create a new scenario.
  2. Create a lifeform entity (e.g. 'Friendly Dismounted Infantry). Any ground vehicle, air vehicle, and/or lifeform will work with this example.
  3. Right-click on entity and select the new entry 'Set->Speed and Heading...".
  4. In the 'Set Heading and Speed' dialog, select the desired heading and ordered speed for the entity.
  5. Click OK to exit the dialog. The entity will snap to the new heading.
  6. Give the entity a movement task. It will move at the speed specified in the 'Set Heading and Speed' request.

Classes

DtSetSpeedAndHeadingMenuItemThe menu item that will register the dialog to be shown when this set is requested.
DtSetSpeedAndHeadingDialogThe Qt widget that generates the dialog box used to enter the speed and heading information.
DtSetSpeedAndHeadingRequestThe subclass of DtSetDataRequest that is used to communicate the new set request between the front-end and the back-end.

Plugin Entry Points

/*******************************************************************************
** Copyright (c) 2011 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
//\file addSetPlugin.cxx
//\brief Contains plugin function
//This file defines the generic DT_DLL_VRF_PLUGIN_EXPORT_MACRO. Use that macro when
//you want to export symbols. Also, in your CMakeLists.txt file, make sure to
//define the VRFPLUGIN_EXPORTS define to tell the compiler to define the macro as an
//export
#include "../addSetSim/setSpeedAndHeading.h"
#include <vrvCore/DtDe.h>
using namespace vrfAddSetExample;
using namespace makVrf;
void DtSetMenuConfigurationLoaded(makVrv::DtDe* de)
{
//[insert menu item string into set menu]
//Inserts the DtSetSpeedAndHeadingMenuItem object name as the menu item into a specific point of the Set Menu with the masterModeMenuConfiguration
//The set entry is placed after the menu entry corresponding to the "DtVrfSetResponsibilityAction" object
DtVrfScenarioManager::instance(*de).initialSetMenuConfiguration().addMenuItemAfter(DtSetSpeedAndHeadingMenuItemIdName, DtVrfSetLocationActionId);
//[insert menu item string into set menu]
}
{
//[register menu item with set menu]
//Registers the DtSSetSpeedAndHeadingMenuItem object with the makVrf::DtSetMenu assembler
//[register menu item with set menu assembler]
//Registers the set creator in the back-end, linking it with the front-end by the common string DtSetSpeedAndHeadingString
DtGuiThreadVrfRemoteController::instance(*de).addSetCreatorFcn(
//Register callback to be notified when initial set menu configuration has changed. This will always allow the plugin
//to correctly add in the new set command
DtScenarioSignaler::instance(*de).signal_setMenuConfigurationLoaded.connect
(boost::bind(&DtSetMenuConfigurationLoaded, de));
return true;
}
{
info.pluginName = "Add Set Gui";
info.pluginVersion = "1.00";
info.pluginDescription = "Front-end plugin addition to add new Set Speed and Heading... command";
info.pluginCreator = "MAK Technologies";
info.pluginCreatorEmail = "sales@mak.com";
info.pluginContactWebPage = "www.mak.com";
info.pluginContactMailingAddress = "10 Fawcett Street, Suite 204, Cambridge, MA 02138 USA";
info.pluginContactPhone = "(617) 876 8085";
}

Document ID: Generated on Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)