The Add State Property GUI example demonstrates the following:
- How to build a plugin module for the VR-Forces Gui
- How to add custom state properties to entities that can be used locally and published to the network
- How to add new items to the entity Information dialog
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.
using namespace makVrv;
using namespace makVrf;
{
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"));
makVrfGuiObjectInformationQt::DtInformationDialogManager::instance(*de).informationPageAssembler().
makVrfGuiObjectInformationQt::DtInformationDialogManager::instance(*de).informationPageAssembler().
return true;
}
{
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.";
}
using namespace makVrf;
{
}
{
return "DtHitStats";
}
{
if (objDataView)
{
boost::optional<int> numHits =
if (numHits)
{
return QString::number(*numHits);
}
}
return "";
}
{
return QObject::tr("Hits");
}
{
}
{
return "DtMissStats";
}
{
if (objDataView)
{
boost::optional<int> numMisses =
if (numMisses)
{
return QString::number(*numMisses);
}
}
return "";
}
{
return QObject::tr("Misses");
}