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

guiObjectDataConsole.h

/******************************************************************************
** Copyright (c) 2012 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
/******************************************************************************
** $RCSfile: guiObjectDataConsole.h,v $ $Revision: 1.2 $ $State: Exp $
******************************************************************************/
//\file guiObjectDataConsole.h
#pragma once
#include <QtWidgets/QDialog>
namespace makVrv
{
class DtDe;
}
//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);
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 DtBoost::shared_ptr<makVrf::DtObjectDataInterface> 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:
public:
QRadioButton* myLocal;
QRadioButton* myGeocentric;
QVBoxLayout* myMainLayout;
QTextEdit* myConsole; //The output of the command
QLineEdit* myObject; //Object input
};

guiObjectDataConsole.cxx

/******************************************************************************
** Copyright (c) 2012 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
/******************************************************************************
** $RCSfile: guiObjectDataConsole.cxx,v $ $Revision: 1.2 $ $State: Exp $
******************************************************************************/
//\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 += ", ";
}
DtVrfVrlinkDataInterfacePtr iface = DtObjectDataInterface::cast<DtVrfVrlinkDataInterface>(
lookupObjectData(QString::number(ids[i])));
if (iface)
{
res += iface->name().c_str();
// delete iface;
}
}
return res;
}
{
DtObjectDataInterface::Representation rep = (myLocal->isChecked() ? DtObjectDataInterface::Local : DtObjectDataInterface::World);
print(QString("Element ID: ") + QString::number(info->elementID()));
print(QString("Name: ") + info->name().c_str());
print(QString("Entity ID: ") + info->entityId().c_str());
print(QString("Global ID: ") + info->globalId().c_str());
print(QString("Type: ") + info->entityType().string());
std::vector<DtVector> locations = info->locations(rep);
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);
}
}
{
DtObjectDataInterface::Representation rep = (myLocal->isChecked() ? DtObjectDataInterface::Local : DtObjectDataInterface::World);
print(QString("Element ID: ") + QString::number(info->elementID()));
print(QString("Name: ") + info->name().c_str());
print(QString("Type: ") + info->entityType().c_str());
print(QString("Location: ") + info->location(rep).string().c_str());
print(QString("Velocity: ") + info->velocity(rep).string().c_str());
print(QString("Acceleration: ") + info->acceleration(rep).string().c_str());
print(QString("Orientation: ") + info->orientation(rep).string().c_str());
print(QString("Heading: ") + QString::number(info->heading()));
print(QString("Visible: ") + (info->isVisible() ? "True" : "False"));
print(QString("Selected: ") + (info->isSelected() ? "True" : "False"));
}
{
DtVrfDataInterraceResourceRequestor::ResourceMap::const_iterator iter = info->resources().begin();
print("Resources:");
while (iter != info->resources().end())
{
QString res = iter->second.myResourceName.c_str();
res += ": ";
res += QString::number(iter->second.myCurrentAmount);
res += " (";
res += QString::number(iter->second.myFullAmount);
res += ")";
print(res);
++iter;
}
info->signal_resourcesChanged.disconnect(boost::bind(&DtGuiObjectDataConsole::displayEntityInformationWithResources, this, info));
}
{
DtObjectDataInterface::Representation rep = (myLocal->isChecked() ? DtObjectDataInterface::Local : DtObjectDataInterface::World);
print(QString("Element ID: ") + QString::number(info->elementID()));
print(QString("Name: ") + info->name().c_str());
print(QString("Label: ") + info->label().c_str());
print(QString("Entity ID: ") + info->entityId().c_str());
print(QString("Global ID: ") + info->globalId().c_str());
print(QString("Type: ") + info->entityType().string());
print(QString("Location: ") + info->location(rep).string().c_str());
print(QString("Velocity: ") + info->velocity(rep).string().c_str());
print(QString("Acceleration: ") + info->acceleration(rep).string().c_str());
print(QString("Orientation: ") + info->orientation(rep).string().c_str());
print(QString("Heading: ") + QString::number(info->heading()));
print(QString("Visible: ") + (info->isVisible() ? "True" : "False"));
print(QString("Selected: ") + (info->isSelected() ? "True" : "False"));
DtElementID embarkedOn = info->embarkedOn();
if (embarkedOn != 0)
{
DtVrfVrlinkDataInterfacePtr iface = DtObjectDataInterface::cast<DtVrfVrlinkDataInterface>(
lookupObjectData(QString::number(embarkedOn)));
if (iface)
{
print(QString("Emarked On: ") + iface->name().c_str());
}
}
std::vector<DtElementID> emb = info->objectsEmbarked();
if (emb.size())
{
QString res;
res = "Objects Embarked: " + namesFrom(emb);
print(res);
}
DtElementID superior = info->superior();
if (superior != 0)
{
DtVrfVrlinkDataInterfacePtr iface = DtObjectDataInterface::cast<DtVrfVrlinkDataInterface>(
lookupObjectData(QString::number(superior)));
if (iface)
{
print(QString("Superior: ") + iface->name().c_str());
}
}
else
{
print("Superior: Force Level");
}
}
{
std::vector<DtElementID> emb = info->subordinates();
if (emb.size())
{
QString res;
res = "Subordinates: " + namesFrom(emb);
print(res);
}
print(QString("Dimensions: ") + info->dimensions().string().c_str());
print(QString("Formation: ") + info->formation().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();
}
DtBoost::shared_ptr<DtObjectDataInterface> DtGuiObjectDataConsole::lookupObjectData(const QString& name) const
{
DtElementID id = name.toLongLong();
DtBoost::shared_ptr<DtObjectDataInterface> iface;
if (id != 0)
{
iface = DtVrfStateViewCollectionManager::instance(myDe).lookupObjectData(id);
}
else
{
iface = DtVrfStateViewCollectionManager::instance(myDe).lookupObjectData(DtUUID(name.toUtf8().constData()));
}
return iface;
}
void DtGuiObjectDataConsole::spotinfo(const QString& name)
{
DtElementID id = name.toLongLong();
if (id != 0)
{
iface = DtVrfStateViewCollectionManager::instance(myDe).lookupSpotReportData(id);
}
else
{
iface = DtVrfStateViewCollectionManager::instance(myDe).lookupSpotReportData(name.toUtf8().constData());
}
if (!iface)
{
print("Could not find spot report information");
return;
}
if (iface->type() == SpotReportsElementType)
{
displaySpotReportInformation(DtObjectDataInterface::cast<DtSpotReportDataInterface>(iface));
}
}
void DtGuiObjectDataConsole::info(const QString& name)
{
if (!iface)
{
print("Could not find information for requested object");
return;
}
if (iface->type() == DtElementEntry::Entity)
{
DtEntityDataInterfacePtr eface = DtObjectDataInterface::cast<DtEntityDataInterface>(iface);
if (eface->resources().size())
{
}
else
{
eface->signal_resourcesChanged.connect(boost::bind(&DtGuiObjectDataConsole::displayEntityInformationWithResources, this, eface));
return;
}
}
else if (iface->type() == DtElementEntry::Aggregate)
{
DtObjectDataInterface::cast<DtAggregateDataInterface>(iface));
}
else if (iface->type() == DtElementEntry::TacticalGraphic)
{
DtObjectDataInterface::cast<DtTacticalGraphicDataInterface>(iface));
}
}
void DtGuiObjectDataConsole::hideObject(const QString& name)
{
if (!iface)
{
print("Could not find information for requested object");
return;
}
iface->setVisible(false);
}
void DtGuiObjectDataConsole::showObject(const QString& name)
{
if (!iface)
{
print("Could not find information for requested object");
return;
}
iface->setVisible(true);
}
void DtGuiObjectDataConsole::selectObject(const QString& name)
{
if (!iface)
{
print("Could not find information for requested object");
return;
}
iface->addToSelection();
}
{
if (!iface)
{
print("Could not find information for requested object");
return;
}
iface->removeFromSelection();
}

Document ID: Generated on Mon Jun 20 00:38:30 EDT 2022 from SVN revision 244029
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)