VR-Forces 4.6.1 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Add State Property (addStatePropertyGui)

The Add State Property GUI example demonstrates the following:

The Add State Property example shows how to add new state properties to entities, receive these properties in the GUI, and then display them in the Information dialog. For more details on state properties, please see the Add State Property Sim example plugin which publishes this data to the network.

In the GUI, this example registers new page data items to display the TargetsHit and TargetsMissed state properties. These page data items query the state view of the DtVrfObjectDataState to get the latest state property values.

/*******************************************************************************
** Copyright (c) 2017 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
//\file examplePlugin.cxx
//\brief Loads the plugin and initializes menu items
// 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 "accuracyStats.h"
#include <vrvCore/DtDe.h>
using namespace makVrv;
using namespace makVrf;
// Entry point that must be defined by all plugins, this is called as part of the
// process that loads the plugin, before the de is fully initialized
bool initDeModule(DtDe* de)
{
// Add the new menu items into the state page path of the entity information page.
// Pages are now prefaced by the section they are in (if they are in a section)
// so must reference the page as <section name>.<page name>
makVrfGuiObjectInformationQt:: DtInformationDialogManager::instance(*de).informationPageConfiguration().
addPagePathBefore(DtInformationPagePath::page("DtEntityExpandedData.DtEntityInformationPage").informationItem("DtMissStats"),
DtInformationPagePath::page("DtEntityExpandedData.DtEntityInformationPage").informationItem("DtEntityAcceleration"));
makVrfGuiObjectInformationQt::DtInformationDialogManager::instance(*de).informationPageConfiguration().
addPagePathBefore(DtInformationPagePath::page("DtEntityExpandedData.DtEntityInformationPage").informationItem("DtHitStats"),
DtInformationPagePath::page("DtEntityExpandedData.DtEntityInformationPage").informationItem("DtMissStats"));
// And now add the information item creators to be created when these items want to be displayed
makVrfGuiObjectInformationQt::DtInformationDialogManager::instance(*de).informationPageAssembler().
registerPageDataItemCreator(new DtHitStatsCreator);
makVrfGuiObjectInformationQt::DtInformationDialogManager::instance(*de).informationPageAssembler().
registerPageDataItemCreator(new DtMissStatsCreator);
return true;
}
{
info.pluginName = "Add State Property Gui";
info.pluginDescription = "This is an example of how to add an attribute to an entity as a state property and publish that attribute to the network.";
info.pluginVersion = "1.00";
info.pluginCreator = "MAK Technologies";
info.pluginCreatorEmail = "sales@mak.com";
info.pluginContactWebPage = "www.mak.com";
info.pluginContactMailingAddress = "150 Cambridge Park Drive 3rd Floor - Cambridge, MA 02140 USA";
info.pluginContactPhone = "(617) 876 8085";
}
/******************************************************************************
** Copyright (c) 2017 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#include "accuracyStats.h"
using namespace makVrf;
{
}
{
return "DtHitStats";
}
{
objectDataStateViewCollection()->findStateView(state->id());
if (objDataView)
{
boost::optional<int> numHits =
findPropertyValue<int>(objDataView->state().myStateProperties, "TargetsHit");
if (numHits)
{
return QString::number(*numHits);
}
}
return "";
}
{
return QObject::tr("Hits");
}
{
}
{
return "DtMissStats";
}
{
objectDataStateViewCollection()->findStateView(state->id());
if (objDataView)
{
boost::optional<int> numMisses =
findPropertyValue<int>(objDataView->state().myStateProperties, "TargetsMissed");
if (numMisses)
{
return QString::number(*numMisses);
}
}
return "";
}
{
return QObject::tr("Misses");
}

Document ID: Generated on Wed Jul 25 16:57:45 EDT 2018 from SVN revision 190790
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)