The GUI Object Data Interface example demonstrates how to access data for entities, aggregates and environmental objects.
The front-end has been worked to allow access to objects with a similar API as the back-end, the DtSimObjectReference class. This class will encapsulate a DtGuiSimObject and can be accessed via the DtVrfGuiSimObjectManager. The API for this class is similar to the API of the back-end class of the same name. These objects are thread safe in the context that they can be accessed in a pre or post DtDe tick and do not need to have an update rate set to them. All usage of the the DtStateView, DtStateData and DtVrfStateViewCollectionManager have been removed.
This example creates a console that allows for entering of simple commands to retrieve information by name of object or by unique ID and then displays information for that object in the console.
In the Launcher, click the Plug-ins button to bring up the Plug-ins Selection dialog. Enable the plugin.
#include <QtWidgets/QTextEdit>
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QLayout>
#include <QtWidgets/QLabel>
#include <QtWidgets/QRadioButton>
using namespace makVrv;
using namespace makVrf;
, myDe(de)
{
myMainLayout = new QVBoxLayout(this);
myMainLayout->setContentsMargins(2, 2, 2, 2);
QHBoxLayout* hLay = new QHBoxLayout;
hLay->setContentsMargins(2, 2, 2, 2);
myLocal = new QRadioButton(tr("Local"), this);
myLocal->setChecked(true);
myGeocentric = new QRadioButton(tr("World"), this);
hLay->addWidget(myLocal);
hLay->addWidget(myGeocentric);
myMainLayout->addLayout(hLay);
myMainLayout->addWidget(label);
myConsole = new QTextEdit(this);
myConsole->setReadOnly(true);
myMainLayout->addWidget(myConsole);
label =
new QLabel(tr(
"Object"),
this);
myMainLayout->addWidget(label);
myMainLayout->addWidget(myObject);
connect(myObject, SIGNAL(returnPressed()), this, SLOT(processObject()));
setWindowTitle(tr("Object Information"));
myObject->setFocus();
resize(500, 400);
}
{
}
{
}
{
QString res;
unsigned i;
for (i = 0; i < ids.size(); i++)
{
if (res.length())
{
res += ", ";
}
{
res += QString::fromLocal8Bit(iface->
objectName().c_str());
}
}
return res;
}
{
print(QString(
"Element ID: ") + QString::number(info->
id()));
std::vector<DtVector> locations;
{
}
else
{
}
if (locations.size())
{
QString res = "Locations: ";
int iLimit = locations.size();
int i;
for (i = 0; i < iLimit; i++)
{
if (i != 0)
{
res += ", ";
}
res += locations[i].string().c_str();
}
}
}
{
print(QString(
"Element ID: ") + QString::number(info->
id()));
{
print(QString(
"Velocity: ") + (
myLocal->isChecked() ? comp->localVelocity().string().c_str() : comp->worldVelocity().string().c_str()));
print(QString(
"Acceleration: ") + (
myLocal->isChecked() ? comp->localAcceleration().string().c_str() : comp->worldAcceleration().string().c_str()));
print(QString(
"Orientation: ") + (
myLocal->isChecked() ? comp->localOrientation().string().c_str() : comp->worldOrientation().string().c_str()));
print(QString(
"Heading: ") + QString::number(info->
heading()));
}
print(QString(
"Visible: ") + (DtElementAttributeUtilityFunctions::isVisible(myDe, info->
id()) ?
"True" :
"False"));
print(QString(
"Selected: ") + (DtSelectionManager::instance(myDe).isSelected(info->
id()) ?
"True" :
"False"));
}
{
{
DtEnumDictionary* dict = DtVrfEntityTypeDictionaryManager::instance(myDe).dictionary();
for (
const auto& resource : resources.
resources())
{
print(QString(
"%1: %2/%3 (location %4)").arg(QString::fromUtf8(dict->displayName(resource.
resourceType(),
false, 6).c_str())).
arg(resource.
currentAmount()).arg(resource.
fullAmount()).arg(QString::fromUtf8(dict->enumNameFromValue(DtVrfResourceBinsUid, resource.
bin()))));
}
}
}
{
myRequestId = DtGuiThreadVrfRemoteController::instance(myDe).generateRequestId();
DtGuiThreadVrfRemoteController::instance(myDe).requestResourcesFor({info->
uuid()},
myRequestId);
}
{
print(QString(
"Element ID: ") + QString::number(info->
id()));
{
print(QString(
"Velocity: ") + (
myLocal->isChecked() ? comp->localVelocity().string().c_str() : comp->worldVelocity().string().c_str()));
print(QString(
"Acceleration: ") + (
myLocal->isChecked() ? comp->localAcceleration().string().c_str() : comp->worldAcceleration().string().c_str()));
print(QString(
"Orientation: ") + (
myLocal->isChecked() ? comp->localOrientation().string().c_str() : comp->worldOrientation().string().c_str()));
print(QString(
"Heading: ") + QString::number(info->
heading()));
hostGlobalId = comp->hostGlobalId();
}
print(QString(
"Heading: ") + QString::number(info->
heading()));
print(QString(
"Visible: ") + (DtElementAttributeUtilityFunctions::isVisible(myDe, info->
id()) ?
"True" :
"False"));
print(QString(
"Selected: ") + (DtSelectionManager::instance(myDe).isSelected(info->
id()) ?
"True" :
"False"));
if (hostGlobalId.isValid())
{
{
}
}
if (atr)
{
QString res;
}
if (hierAtr && (hierAtr->
value().parentId() != 0))
{
{
}
}
else
{
print(
"Superior: Force Level");
}
}
{
if (atr)
{
QString res;
}
print(QString(
"Dimensions: ") + DtVector(bv.length(), bv.width(), bv.height()).
string().c_str());
}
{
print(
"info <name|id> - Shows information for object");
print(
"spotinfo <name|id> - Shows spot report information for object");
print(
"select <name|id> - Adds object to current selection");
print(
"remove <name|id> - Removes object from current selection");
print(
"hide <name|id> - Hides object");
print(
"show <name|id> - Shows object");
print(
"help - Shows this list");
}
{
QStringList lst =
myObject->text().split(
' ');
if (lst.count() >= 2)
{
QString name;
int i;
for (i = 1; i < lst.size(); i++)
{
if (i != 1)
{
name += " ";
}
name += lst[i];
}
if (lst[0].toLower() == "info")
{
}
else if (lst[0].toLower() == "spotinfo")
{
}
else if (lst[0].toLower() == "hide")
{
}
else if (lst[0].toLower() == "show")
{
}
else if (lst[0].toLower() == "select")
{
}
else if (lst[0].toLower() == "remove")
{
}
return;
}
}
{
if (id != 0)
{
iface = DtVrfGuiSimObjectManager::instance(myDe).lookup(id);
}
else
{
iface = DtVrfGuiSimObjectManager::instance(myDe).lookup(
DtUUID(name.toUtf8().constData()));
}
return iface;
}
{
{
print(
"Could not find spot report information");
return;
}
{
}
}
{
{
print(
"Could not find information for requested object");
return;
}
{
}
{
}
else
{
}
}
{
{
print(
"Could not find information for requested object");
return;
}
DtDataBankSignaler::instance(myDe.mainEventQueue()).signal_elementAttributeChangeRequested(
}
{
{
print(
"Could not find information for requested object");
return;
}
DtDataBankSignaler::instance(myDe.mainEventQueue()).signal_elementAttributeChangeRequested(
}
{
{
print(
"Could not find information for requested object");
return;
}
showSet.insert( iface->
id() );
DtSelectionManager::instance( myDe ).addToCurrentSelection(showSet);
}
{
{
print(
"Could not find information for requested object");
return;
}
showSet.insert( iface->
id() );
DtSelectionManager::instance( myDe ).removeFromCurrentSelection(showSet);
}