VR-Forces 4.0.4 Class Documentation
Unit Status Example

The Unit Status example demonstrates the following:

The Unit Status example demonstrates how to add a new panel to the application and to display information in that panel about an item that is selected on the terrain map.

The example supplies a .ui file that shows how to create a dialog box using Qt Designer and how that .ui file translates itself into a .cpp and .h file that can be subclassed and extended for use in the VR-Forces GUI.

Using the Qt connection call, the panel connects to functions that send out updates when an entity is updated. This shows how user interface objects can have their states change when some aspect of an entity changes.

Usage

Since this example is loaded as a plugin Select Settings, Plugins... and on the Plugins Editor page, use the combo box at the top of the page to select the plug-in. Then enable the Load Plugin checkbox and re-start VR-Forces.

  1. Start vrfGui.
  2. Start vrfSim.
  3. Create a new scenario.
  4. Create a tank.
  5. Click on tank to select it.

The 'Unit Status' panel will display information about the currently selected entity.

Classes

DtUnitStatusThe toolbar widget that displays information about the currently selected unit.
DtUnitStatusLogicThe logic for setting the information into the widget.

Plugin Entry Points

/*******************************************************************************
** Copyright (c) 2011 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/

//\file unitStatusPlugin.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 <vrfGuiCore/vrfGuiExportPlugin.h>
#include "DtUnitStatus.h"

//VR-Vantage includes
#include <vrvCore/DtVrvApplication.h>
#include <vrvCoreQt/DtQtPageAssembler.h>
#include <vrvUtil/DtDeInitializer.h>
#include <vrfGuiCoreQt/vrfMainMenu.h>
#include <vrfGuiConstants/vrfMenuIds.h>

using namespace makVrf;

bool initDeModule(makVrv::DtDe* de)
{
   //Register new widget with the system so that it can be created. 
   //NOTE: This does not actually display the widget anywhere.
   makVrv::DtQtPageAssembler& qtPageAssembler = makVrv::DtQtPageAssembler::instance(*de);
   qtPageAssembler.registerPageCreator(new makVrfUnitStatusExample::DtUnitStatusWidgetCreator(*de));

   //Add the widget to the display configuration so that it will be displayed.
   //Each page must be on a panel, so in this case we add a panel that will
   //contain only this page.
   makVrv::DtVrvApplication* igApp = makVrv::DtVrvApplication::findFromDe(*de);
   if(igApp)
   {
      //If the configuration for the panel already exists, this means that the
      //display configuration file was saved with this plugin active.  In this case,
      //leave the panel where the display configuration file says.  This will be
      //where the user had it when they closed the app.
      if (!igApp->masterModePageConfiguration().findPageCollectionTitle(
         "DtUnitStatusPanel"))
      {
         //If it was not in the configuration, make a new dockable panel, and start it on
         //the left side dock area.
         igApp->masterModePageConfiguration().addPageCollection("DtUnitStatusPanel",
            makVrv::DtUnicode::fromAscii("Unit Status"), makVrv::DtPageConfiguration::DockLeft, true, "DtUnitStatus");
         //Add the widget to that panel.
         igApp->masterModePageConfiguration().addPagePath(
            makVrv::DtPagePath::collection("DtUnitStatusPanel").page("DtUnitStatus"));
      }

      DtVrfMainMenu::instance(*de).menuConfiguration().addMenuPathBefore(
         makVrv::DtMenuPath::mainMenu(DtViewMenuId).item("DtUnitStatusPanel"),
         makVrv::DtMenuPath::mainMenu(DtViewMenuId).separator("1"));
   }   

   return true;
}

void DtPluginInformation(DtVrfPluginInformation& info)
{
   info.pluginName = "unitStatus";
   info.pluginDescription = "This example shows how to add a new panel";
   info.pluginVersion = "1.00";
   info.pluginCreator = "MAK Technologies";
   info.pluginCreatorEmail = "sales@mak.com";
   info.pluginContactWebPage = "www.mak.com";
   info.pluginContactMailingAddress = "68 Moulton Street - Cambridge, MA 02138";
   info.pluginContactPhone = "(617) 876 8085";
}

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)