VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages

guiObjectDataConsole.h

/******************************************************************************
** Copyright (c) 2024 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
//\file guiObjectDataConsole.h
#pragma once
#include <QtWidgets/QDialog>
namespace makVrv
{
class DtDe;
}
namespace makVrf
{
class DtEventManagerEventInterface;
}
//The DtGuiObjectDataConsole class will allow for the entering of an object name
//or element id to retrieve information about that object
class QVBoxLayout;
class QTextEdit;
class QLineEdit;
class QRadioButton;
{
Q_OBJECT
public:
DtGuiObjectDataConsole(makVrv::DtDe& de, QWidget* parent);
virtual ~DtGuiObjectDataConsole() override;
protected:
//Prints a line of text to the console window. Will add CR/LF
virtual void print(const QString&);
//Displays information for the tactical graphics
//Displays information for the tactical graphics
//Displays information for the aggregate
//Displays information for the entity
//Shows help for the console
virtual void help();
//Shows information for the given item
virtual void info(const QString&);
//Shows spot report information for the given item (if it exists)
virtual void spotinfo(const QString&);
//Returns the network data interface for given item
virtual makVrf::DtSimObjectReference lookupObjectData(const QString&) const;
//Hides the specified object
virtual void hideObject(const QString&);
//Shows the specified object
virtual void showObject(const QString&);
//Adds the object to the selection
virtual void selectObject(const QString&);
//Removes the object from the current selection
virtual void removeFromSelection(const QString&);
protected:
//Returns a list of names from the given element ids
virtual QString namesFrom(const std::vector<makVrv::DtElementID>& ids) const;
//Displays information for the entity, along with resource information. This call will
//delete the interface when complete
protected slots:
//Called when return is pressed in the object widget. Will then try and find
//information for that object
virtual void processObject();
protected:
boost::signals2::scoped_connection myResourceCallbackConnection;
unsigned myRequestId = 0;
public:
QRadioButton* myLocal;
QRadioButton* myGeocentric;
QVBoxLayout* myMainLayout;
QTextEdit* myConsole; //The output of the command
QLineEdit* myObject; //Object input
};

guiObjectDataConsole.cxx

/******************************************************************************
** Copyright (c) 2024 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
//\file guiObjectDataConsole.cxx
#include <vrvCore/DtDe.h>
#include <QtWidgets/QTextEdit>
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QLayout>
#include <QtWidgets/QLabel>
#include <QtWidgets/QRadioButton>
using namespace makVrv;
using namespace makVrf;
: QDialog(parent, Qt::Tool)
, myDe(de)
{
//Create the GUI for the console and the command entry
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);
QLabel* label = new QLabel(tr("Output"), this);
myMainLayout->addWidget(label);
myConsole = new QTextEdit(this);
myConsole->setReadOnly(true);
myMainLayout->addWidget(myConsole);
label = new QLabel(tr("Object"), this);
myObject = new QLineEdit(this);
myMainLayout->addWidget(label);
myMainLayout->addWidget(myObject);
connect(myObject, SIGNAL(returnPressed()), this, SLOT(processObject()));
setWindowTitle(tr("Object Information"));
myObject->setFocus();
resize(500, 400);
}
{
}
void DtGuiObjectDataConsole::print(const QString& c)
{
myConsole->insertPlainText(c + "\r\n");
}
QString DtGuiObjectDataConsole::namesFrom(const std::vector<DtElementID>& ids) const
{
QString res;
unsigned i;
for (i = 0; i < ids.size(); i++)
{
if (res.length())
{
res += ", ";
}
DtSimObjectReference iface = lookupObjectData(QString::number(ids[i]));
if (iface.isValid())
{
res += QString::fromLocal8Bit(iface->objectName().c_str());
}
}
return res;
}
{
print(QString("Element ID: ") + QString::number(info->id()));
print(QString("Name: ") + info->objectName().c_str());
print(QString("Entity ID: ") + info->entityId().string());
print(QString("Global ID: ") + info->globalId().c_str());
print(QString("Type: ") + info->entityType().string());
std::vector<DtVector> locations;
if (myLocal->isChecked())
{
locations = info->getStateComponent<DtVrfGeometryStateComponent>()->localVertices().asVector();
}
else
{
locations = info->getStateComponent<DtVrfGeometryStateComponent>()->worldVertices().asVector();
}
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(res);
}
}
{
print(QString("Element ID: ") + QString::number(info->id()));
print(QString("Name: ") + info->objectName().c_str());
print(QString("Type: ") + info->entityType().string());
print(QString("Location: ") + (myLocal->isChecked() ? info->localPosition().string().c_str() : info->worldPosition().string().c_str()));
{
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"));
}
{
const makVrfEvents::DtResourceResponseEvent& resources = dynamic_cast<const makVrfEvents::DtResourceResponseEvent&>(iface->event());
if (resources.requestId() == myRequestId)
{
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("Name: ") + info->objectName().c_str());
print(QString("Label: ") + info->getStateComponent<DtVrfStateComponent>()->label().c_str());
print(QString("Entity ID: ") + info->entityId().string());
print(QString("Global ID: ") + info->globalId().c_str());
print(QString("Type: ") + info->entityType().string());
DtUUID hostGlobalId(DtUUID::nullUUID());
{
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())
{
DtSimObjectReference iface = DtVrfGuiSimObjectManager::instance(myDe).lookup(hostGlobalId);
if (iface.isValid())
{
print(QString("Emarked On: ") + iface->objectName().c_str());
}
}
const DtEmbarkationHierarchyStateAttribute* atr = DtElementAttributeUtilityFunctions::embarkationHierarchyState(myDe, info->id());
if (atr)
{
QString res;
res = "Objects Embarked: " + namesFrom(atr->value().children());
print(res);
}
const DtElementIDHierarchyStateAttribute* hierAtr = DtElementAttributeUtilityFunctions::echelonHierarchyState(myDe, info->id());
if (hierAtr && (hierAtr->value().parentId() != 0))
{
DtSimObjectReference iface = DtVrfGuiSimObjectManager::instance(myDe).lookup(hierAtr->value().parentId());
if (iface.isValid())
{
print(QString("Superior: ") + iface->objectName().c_str());
}
}
else
{
print("Superior: Force Level");
}
}
{
const DtElementIDHierarchyStateAttribute* atr = DtElementAttributeUtilityFunctions::echelonHierarchyState(myDe, info->id());
if (atr)
{
QString res;
res = "Subordinates: " + namesFrom(atr->value().children());
print(res);
}
Dt3dBoundingVolume bv = info->getStateComponent<DtVrfGeometryStateComponent>()->boundingGeometry().boundingVolume();
print(QString("Dimensions: ") + DtVector(bv.length(), bv.width(), bv.height()).string().c_str());
print(QString("Formation: ") + info->getStateComponent<DtAggregateStateComponent>()->formationName().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(' ');
myConsole->clear();
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")
{
info(name);
}
else if (lst[0].toLower() == "spotinfo")
{
spotinfo(name);
}
else if (lst[0].toLower() == "hide")
{
hideObject(name);
}
else if (lst[0].toLower() == "show")
{
showObject(name);
}
else if (lst[0].toLower() == "select")
{
selectObject(name);
}
else if (lst[0].toLower() == "remove")
{
}
myObject->setText("");
return;
}
myObject->setText("");
help();
}
{
DtElementID id = name.toLongLong();
if (id != 0)
{
iface = DtVrfGuiSimObjectManager::instance(myDe).lookup(id);
}
else
{
iface = DtVrfGuiSimObjectManager::instance(myDe).lookup(DtUUID(name.toUtf8().constData()));
}
return iface;
}
void DtGuiObjectDataConsole::spotinfo(const QString& name)
{
DtSimObjectReference iface = DtSpotReportDataProcessor::instance(myDe).lookup(DtUUID(name.toUtf8().constData()));
if (!iface.isValid())
{
print("Could not find spot report information");
return;
}
if (iface->isSpotReport())
{
}
}
void DtGuiObjectDataConsole::info(const QString& name)
{
if (!iface.isValid())
{
print("Could not find information for requested object");
return;
}
if (iface->isUnit())
{
}
else if (iface->isEnvironmental())
{
}
else
{
}
}
void DtGuiObjectDataConsole::hideObject(const QString& name)
{
if (!iface.isValid())
{
print("Could not find information for requested object");
return;
}
DtDataBankSignaler::instance(myDe.mainEventQueue()).signal_elementAttributeChangeRequested(
iface->id(), iface->id(), std::shared_ptr<DtElementAttribute>(new DtElementAttributeVisibility(false)));
}
void DtGuiObjectDataConsole::showObject(const QString& name)
{
if (!iface.isValid())
{
print("Could not find information for requested object");
return;
}
DtDataBankSignaler::instance(myDe.mainEventQueue()).signal_elementAttributeChangeRequested(
iface->id(), iface->id(), std::shared_ptr<DtElementAttribute>(new DtElementAttributeVisibility(true)));
}
void DtGuiObjectDataConsole::selectObject(const QString& name)
{
if (!iface.isValid())
{
print("Could not find information for requested object");
return;
}
showSet.insert( iface->id() );
DtSelectionManager::instance( myDe ).addToCurrentSelection(showSet);
}
{
if (!iface.isValid())
{
print("Could not find information for requested object");
return;
}
showSet.insert( iface->id() );
DtSelectionManager::instance( myDe ).removeFromCurrentSelection(showSet);
}

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)