VR-Vantage
Loading...
Searching...
No Matches
exampleDisplayUnits

Overview

The purpose of this example is to show how to use the Display Unit Manager to display an object's position, with appropriate labels, using the current Display Units settings. The example creates a plugin that displays a dialog with a drop down box that allows the user to chose from any of the elements currently selected in a scene, and displays the name, type, and position of the currently chosen element.

Expected Result

Display Unit example Result

Example details

The example also shows how to

  • create and register a new dialog page
  • maintain a list of the currently selected elements in the scene
  • get a DtElementEntry for a selected element, from which the element's name and type can be determined
  • get the position of an element that is represented by one or more scene objects (in local coordinates)
  • get the display unit collection name of an element, if one is specified
  • get the position of an observer
  • convert a position in local coordinates into geocentric coordinates.

Plugin Initialization

When a plugin is loaded, VR-Vantage invokes its initDeModule function. This plugin simply calls its init function from initDeModule.

The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer,...
Definition DtDe.h:77
DT_DE_PLUGIN_EXPORT_MACRO bool initDeModule(makVrv::DtDe *de)
{
makVrv::vrvExampleDisplayUnitsPlugin::init(*de);
return true;
}

The init function ensures that it will only ever be initialize once (even if its init function is called multiple times).

#define DT_DE_INIT_ONCE(de)
This macro is called by modules in their init() function. This macro ensures that the module is only ...
Definition DtDe.h:30

It then makes sure the vrvCoreQt plugin is initialized, as it depends on it (and since vrvCoreQt also calls DT_DE_INIT_ONCE, this call will do nothing if that plugin has already been initialized).

vrvCoreQt::init(de);

The plugin then registers a creator for the dialog page it will display (defined in ElementInspectorPage.cxx) with the DtQtPageAssembler.

DtQtPageAssembler::instance(de).registerPageCreator(new ElementInspectorPageCreator(de));

Finally, it defines how that dialog should appear in the GUI by adding a path to it in the masterModePageConfiguration.

The Root IG Application object. To run the IG simply create one, initialize it and call run.
Definition DtVrvApplication.h:58
static DtVrvApplication * findFromDe(DtDe &)
if(igApp)
{
"ElementPanel",DtUnicode::fromAscii("Example Element Panel"),
DtPageConfiguration::FloatRight,true,"ElementInspectorPage",
false, true, true);
makVrv::DtPagePath::collection("ElementPanel").page("ElementInspectorPage"));
}
void addPagePath(const DtPagePath &, int weight=-1)
Adds the menu path (as well as its entire family).
void addPageCollection(const std::string &collectionClassName, const DtUnicode &pageTitle, PageCollectionLocation location, bool visible, const std::string &pageClassToShow, bool closable=true, bool floatable=true, bool movable=true)
Add a new page collection to the configuration.
static PagePathBuilder collection(const std::string &name)
Start a main menu.
DtPageConfiguration & masterModePageConfiguration()
Get the page configuration which may be altered by plugins.

Element Inspector Page

The ElementInspectorPage dialog maintains a list box that contains all the currently selected elements. For access to this information, it needs to connect to a signal from the DtSelectionManager. Because the DtSelectionManager is created by the Display Engine, it's important to ensure that the connection is done after the Display Engine is fully initialized. One way the VR-Vantage toolkit enables this is through the DtDeObserver class. By inheriting from this class and overriding its slot_activate and slot_deactivate methods, the dialog can know when it is safe to connect (and needs to disconnect) from display engine managed signals creators.

The ElementInspectorPage declaration shows this inheritance.

class ElementInspectorPage : public DtPage, public DtDeObserver

In slot_activate, the ElementInspectorPage connects to the DtSelectionManager's selectionChanged signal.

void ElementInspectorPage::slot_activate(DtDe* de)
{
mySignals += DtSelectionManager::instance(myDe).signal_currentSelectionChanged.connect(
boost::bind(&ElementInspectorPage::selectionChanged,this,boost::placeholders::_1, boost::placeholders::_2, boost::placeholders::_3, boost::placeholders::_4));
}

It disconnects from the signal in slot_deactivate.

void ElementInspectorPage::slot_deactivate(DtDe* de)
{
// Display Engine is going away (so the selection manager is as well)
// Disconnect from its signal(s)
mySignals.disconnectSignals();
}

The ElementInspectorPage also needs to periodically update itself irrespective of any selection changes, since it displays the position of a selected element, that may be moving. However, it only needs to do this if it is actually displayed. Because it derives from DtPage, it can override DtPage's activate and deactivate methods to know when it is being displayed, and start and stop its refresh timer accordingly.

void ElementInspectorPage::activate()
{
myRefreshTimer->start();
}
void ElementInspectorPage::deactivate()
{
myRefreshTimer->stop();
}

Whenever a selection changes, or when the refresh timer expires, the dialog updates its information. The updateElementPosition method demonstrates the use of the DtDisplayUnitsConverter to display the element's current position in the current coordinate system and with the current unit settings.

First, updateElementPosition gets a reference to an instance of the DtDisplayUnitsSettingsManager and it uses that to get a reference to the application's DtDisplayUnitsConverter.

const DtDisplayUnitsConverter& converter = DtDisplayUnitsSettingsManager::instance(myDe).converter();

It queries the DtDisplayUnitsConverter for the correct X, Y, and Z labels given the current display coordinate system and units, and sets the dialog's QLabel labels to those values.

DtUnicode xLabel,yLabel,zLabel;
converter.coordinateSystemLabels(xLabel,yLabel,zLabel);
myXLabel->setText(xLabel.toQString<QString>() + ":" );
myYLabel->setText(yLabel.toQString<QString>() + ":" );
myZLabel->setText(zLabel.toQString<QString>() + ":" );

Using the DtElementEntry passed into updateElementPosition, updateElementPosition gets the element's current position using its getPosition method.

DtVector position = getPosition(entry);

The position returned is in local (or database) coordinates; updateElementPosition coverts it to geocentric coordinates for use with the DtDisplayUnitsConverter.

DtVector geocPosition;
myCoordinateSystem->localToNetPos(position,geocPosition);

It then determines the display unit collection name associated with the element, if there is one. If there is not one, the example defaults to using the 'Application' display unit collection. The example makes use of the object-type specific display unit collection name to help determine the unit of measurement and the number of decimal places to use when displaying the element's altitude, e.g. "Fixed Wing" elements may use feet with 1 decimal place while "Space" elements use kilometers with 0 decimal places.

DtUnicode objectTypeSpecificDisplayUnitCollectionName = getDisplayUnitCollectionName(entry);

The example also does a check against the current Application/Coordinate System display unit setting to determine whether to use the Application/Coordinate System display unit or the Application/Distance display unit when determining the unit of measurement and number of decimal places to use for the X/Y components of the position strings.

DtDisplayUnitsConverter::CoordSys currentCoordinateSystem = converter.currentCoordinateDisplaySystem();
// We want to use the 'Coordinate System' display unit for decimals
// for X/Y if we are using a Geodetic or zone-based coordinate system
DtUnicode displayUnitDecimalsToUseForXY = DtSharedDisplayUnitsSettings::theCoordinateSystemDisplayUnitName;
if (currentCoordinateSystem == DtDisplayUnitsConverter::CoordSys::CoordSysDatabase
|| currentCoordinateSystem == DtDisplayUnitsConverter::CoordSys::CoordSysGeocentric)
{
// In the case of Database or Geocentric, we want to use 'Distance' display unit for decimals
displayUnitDecimalsToUseForXY = DtSharedDisplayUnitsSettings::theDistanceDisplayUnitName;
}

Finally, it queries the DtDisplayUnitsConverter with the geocentric position for properly formatted x, y, and z position strings, and sets its QLabel value fields to the returned strings.

std::vector<DtUnicode> strings = converter.convertPositionToNotatedStringList(geocPosition,
converter.currentDistanceUnit(DtSharedDisplayUnitsSettings::theApplicationDisplayUnitCollectionName, DtSharedDisplayUnitsSettings::theDistanceDisplayUnitName),
converter.displayUnitDecimals(DtSharedDisplayUnitsSettings::theApplicationDisplayUnitCollectionName, displayUnitDecimalsToUseForXY),
converter.currentDistanceUnit(objectTypeSpecificDisplayUnitCollectionName, DtSharedDisplayUnitsSettings::theAltitudeDisplayUnitName),
converter.displayUnitDecimals(objectTypeSpecificDisplayUnitCollectionName, DtSharedDisplayUnitsSettings::theAltitudeDisplayUnitName));
if(strings.size() > 0)
{
myXValue->setText(QString::fromLatin1(strings[0].toLatin1().c_str()));
}
if(strings.size() > 1)
{
myYValue->setText(QString::fromLatin1(strings[1].toLatin1().c_str()));
}
if(strings.size() > 2)
{
myZValue->setText(QString::fromLatin1(strings[2].toLatin1().c_str()));
}

Building the Example

VR-Vantage includes pre-built versions of the example plug-in. To build it yourself, follow the instructions at Building VR-Vantage Examples, Applications, and Plug-ins.

Running the Example

This example is a plug-in. You can run it by running ./bin64/exampleDisplayUnits_stealth.bat (on Windows) or ./bin64/exampleDisplayUnits_stealth.sh (on Linux). Load the Ala Moana terrain from the Load Terrain Dialog ('Ala Moana.mtf'); from the menu "Settings->Connections...", connect to 'DIS (7) localhost'. Then start the MAK Logger for DIS (loggerDIS.exe) and load 'Raid2021-DIS.lgr' and hit play. In VR-Vantage zoom in on an entity and select it. You will see the entity information display in the popup that is created by this example.

For more information about running examples, please see Running Applications and Examples.

Example Source Files


exampleDialogPagePluginInit.h

/******************************************************************************
** Copyright (c) 2022 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#pragma once
#include <matrix/vlVector.h>
class QGridLayout;
class QLabel;
class QComboBox;
class QTimer;
namespace makVrv
{
class DtElementEntry;
class DtCoordinateSystem;
namespace vrvExampleDisplayUnitsPlugin
{
class ElementInspectorPage : public DtPage, public DtDeObserver
{
Q_OBJECT;
public:
ElementInspectorPage(DtDe& de,QWidget* parent = 0, Qt::WindowFlags f = 0);
virtual QIcon icon();
virtual DtQIconConfigurations qIconConfigurations() const;
virtual QString title();
virtual const std::string& pageClassName() const;
static const std::string& thePageClassName();
protected slots:
void onCurrentElementIdChanged(int index);
protected:
void setupGui();
virtual void activate();
virtual void deactivate();
virtual void slot_activate(DtDe* de);
virtual void slot_deactivate(DtDe* de);
const DtSelectionManager::IdSet& deselected,
void updateElementParameters(DtElementEntry* entry);
void updateElementPosition( DtElementEntry* entry );
void updateElementType( DtElementEntry* entry ) ;
DtVector getPosition( DtElementEntry* entry ) const;
DtUnicode getDisplayUnitCollectionName( DtElementEntry* entry ) const;
protected:
DtSignalConnectionManager mySignals;
QGridLayout* myMainLayout;
DtSignalConnectionManager myConnections;
DtCoordinateSystem* myCoordinateSystem = nullptr;
};
typedef DtPageCreatorTemplate<ElementInspectorPage> ElementInspectorPageCreator;
}
}
Contains makVrv::DtPage class declaration.
Contains makVrv:DtSelectionManager class.
Base class to provide boost signal/slot management.
Contains makVrv::DtSubjectObserver class.
std::set< DtUniqueID > IdSet
Definition DtSelectionManager.h:32
SelectionType
The nature of the current selection.
Definition DtSelectionManager.h:43
virtual void slot_deactivate(DtDe *de)
Called when the display engine is destroyed.
virtual DtQIconConfigurations qIconConfigurations() const
Get the icon configurations for the page. This is used to style the page's icon based on application ...
virtual void activate()
Called when the page is displayed.
virtual QIcon icon()
Get the icon of the page.
DtVector getPosition(DtElementEntry *entry) const
virtual QString title()
Get the title of the page.
QLabel * myZLabel
Definition ElementInspectorPage.h:127
void updateElementPosition(DtElementEntry *entry)
Update the element position label.
DtSignalConnectionManager mySignals
Definition ElementInspectorPage.h:117
QLabel * myYLabel
Definition ElementInspectorPage.h:126
DtUnicode getDisplayUnitCollectionName(DtElementEntry *entry) const
QLabel * myXLabel
Definition ElementInspectorPage.h:125
ElementInspectorPage(DtDe &de, QWidget *parent=0, Qt::WindowFlags f=0)
void updateElementType(DtElementEntry *entry)
Update the element type label.
static const std::string & thePageClassName()
Get the class name of this page class.
QLabel * myYValue
Definition ElementInspectorPage.h:130
QGridLayout * myMainLayout
Definition ElementInspectorPage.h:118
QLabel * myZValue
Definition ElementInspectorPage.h:131
virtual const std::string & pageClassName() const
Get the class name of the page.
QLabel * myTypeValue
Definition ElementInspectorPage.h:123
virtual void slot_activate(DtDe *de)
Called when the display engine is done initializing.
virtual void deactivate()
Called when the page is hidden.
QLabel * myIdLabel
Definition ElementInspectorPage.h:119
void selectionChanged(const DtSelectionManager::IdSet &selected, const DtSelectionManager::IdSet &deselected, DtSelectionManager::SelectionType newType, DtSelectionManager::SelectionType oldType)
virtual void slot_coordinateSystemChanged()
slot for when the coordinate system changes
void onCurrentElementIdChanged(int index)
Called when the current elemment id in the combo box is changed.
void updateElementParameters(DtElementEntry *entry)
Update all of the element parameters.
QComboBox * myIdBox
Definition ElementInspectorPage.h:120
DtSignalConnectionManager myConnections
Definition ElementInspectorPage.h:135
DtCoordinateSystem * myCoordinateSystem
Definition ElementInspectorPage.h:139
QLabel * myTypeLabel
Definition ElementInspectorPage.h:122
void onRefreshElementDisplay()
Called by a timer ever so often to update the element display.
QLabel * myXValue
Definition ElementInspectorPage.h:129
QTimer * myRefreshTimer
Definition ElementInspectorPage.h:133
DtPageCreatorTemplate< ElementInspectorPage > ElementInspectorPageCreator
Definition ElementInspectorPage.h:142
Contains DtCreateSensorFieldOfViewCommand and DtCreateSensorFieldOfViewCommandCreator class declarati...
Definition DtGridLinesSettingsRecord.h:16

exampleDialogPagePlugin.h

/******************************************************************************
** Copyright (c) 2024 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#include <vrvCore/DtDe.h>
#include <QtWidgets/QLabel>
#include <QtWidgets/QGridLayout>
#include <QtWidgets/QComboBox>
#include <QtCore/QTimer>
#include <boost/bind/bind.hpp>
#include <boost/bind/bind.hpp>
using namespace makVrv;
ElementInspectorPage::ElementInspectorPage(DtDe& de,QWidget* parent, Qt::WindowFlags f)
: DtPage(de,parent,f)
, DtDeObserver()
{
// This sets us up to have our slot_activate() and slot_deactivate() methods
// called when the display engine is init'ed and uninit'ed
bind( de );
//Create and layout the widgets.
setupGui();
myConnections += DtDeSharedStateSignaler::instance(myDe).signal_coordinateSystemChanged.connect(
boost::bind(&ElementInspectorPage::slot_coordinateSystemChanged, this));
slot_coordinateSystemChanged();
}
ElementInspectorPage::~ElementInspectorPage()
{
delete myCoordinateSystem;
}
void ElementInspectorPage::slot_coordinateSystemChanged()
{
if( myCoordinateSystem == nullptr && myDe.sharedStatePtr() )
{
myCoordinateSystem = myDe.sharedState().coordinateSystem().clone();
if( myCoordinateSystem == nullptr )
{
DtTHROW_NEW( DtCorruptedState, "myDe.sharedState().coordinateSystem().clone() failed." );
}
}
if( myCoordinateSystem )
{
myCoordinateSystem->set( myDe.sharedState().coordinateSystem().type(), myDe.sharedState().coordinateSystem().parameters() );
}
}
QIcon ElementInspectorPage::icon()
{
return QIcon();
}
QString ElementInspectorPage::title()
{
return tr("Element Inspector");
}
const std::string& ElementInspectorPage::pageClassName() const
{
return thePageClassName();
}
const std::string& ElementInspectorPage::thePageClassName()
{
static std::string theClassName("ElementInspectorPage");
return theClassName;
}
void ElementInspectorPage::activate()
{
myRefreshTimer->start();
}
void ElementInspectorPage::deactivate()
{
myRefreshTimer->stop();
}
void ElementInspectorPage::slot_activate(DtDe* de)
{
mySignals += DtSelectionManager::instance(myDe).signal_currentSelectionChanged.connect(
boost::bind(&ElementInspectorPage::selectionChanged,this,boost::placeholders::_1, boost::placeholders::_2, boost::placeholders::_3, boost::placeholders::_4));
}
void ElementInspectorPage::slot_deactivate(DtDe* de)
{
// Display Engine is going away (so the selection manager is as well)
// Disconnect from its signal(s)
mySignals.disconnectSignals();
}
void ElementInspectorPage::selectionChanged(const DtSelectionManager::IdSet& selected,
const DtSelectionManager::IdSet& deselected,
{
// For each selected id, add it to the combo box.
DtSelectionManager::IdSet::const_iterator i = selected.begin();
DtSelectionManager::IdSet::const_iterator e = selected.end();
for(; i != e;++i)
{
QString nameQStr = tr("Unnamed");
std::string nameStr;
if (myDe.dataBank().elementData().attributeManager().getElementDisplayName(*i, nameStr))
{
nameQStr = QString::fromStdString(nameStr);
}
myIdBox->addItem(nameQStr, QVariant(*i) );
}
// For each deselected id, find in in the combo box and remove it.
i = deselected.begin();
e = deselected.end();
for(; i != e;++i)
{
int index = myIdBox->findData( QVariant( *i ) );
if ( index != -1 )
{
myIdBox->removeItem(index);
}
}
}
void ElementInspectorPage::setupGui()
{
int row = 0;
myMainLayout = new QGridLayout(this);
myMainLayout->setAlignment(Qt::AlignTop);
myIdLabel = new QLabel(tr("Elements Selected:"),this);
myMainLayout->addWidget(myIdLabel,row,0);
myIdBox = new QComboBox(this);
QObject::connect(myIdBox,SIGNAL(currentIndexChanged(int)),SLOT(onCurrentElementIdChanged(int)));
myMainLayout->addWidget(myIdBox,row,1);
++row;
myTypeLabel = new QLabel(tr("Element Type:"),this);
myMainLayout->addWidget(myTypeLabel,row,0);
myTypeValue = new QLabel(tr(""),this);
myMainLayout->addWidget(myTypeValue,row,1);
++row;
myXLabel = new QLabel(this);
myMainLayout->addWidget(myXLabel,row,0);
myXValue = new QLabel(tr(""),this);
myMainLayout->addWidget(myXValue,row,1);
++row;
myYLabel = new QLabel(this);
myMainLayout->addWidget(myYLabel,row,0);
myYValue = new QLabel(tr(""),this);
myMainLayout->addWidget(myYValue,row,1);
++row;
myZLabel = new QLabel(this);
myMainLayout->addWidget(myZLabel,row,0);
myZValue = new QLabel(tr(""),this);
myMainLayout->addWidget(myZValue,row,1);
myRefreshTimer = new QTimer(this);
QObject::connect(myRefreshTimer,SIGNAL(timeout()),SLOT(onRefreshElementDisplay()));
myRefreshTimer->setInterval(500);
myRefreshTimer->stop();
}
void ElementInspectorPage::onCurrentElementIdChanged(int index)
{
if(index == -1)
{
updateElementParameters(0);
return;
}
//Get the unique id in the combo box.
DtUniqueID id = myIdBox->itemData(index).toULongLong();
//Find the element.
DtElementEntry* entry = myDe.dataBank().elementData().findElement(id);
//Update it's parameters, supports if the entry is NULL.
updateElementParameters(entry);
}
DtQIconConfigurations ElementInspectorPage::qIconConfigurations() const
{
return result;
}
{
int index = myIdBox->currentIndex();
if( index == -1) return;
if(myIdBox->currentText() == QString()) return;
//Get the current element id.
bool ok = false;
DtUniqueID id = myIdBox->itemData(index).toULongLong(&ok);
if(!ok) return;
//Find the element.
DtElementEntry* entry = myDe.dataBank().elementData().findElement(id);
//Update it's parameters, supports if the entry is NULL.
}
makVrv::DtUnicode ElementInspectorPage::getDisplayUnitCollectionName(DtElementEntry* entry) const
{
// Get the display unit collection name if one is set in the element attribute manager.
// If one is not set, default to theApplicationDisplayUnitCollectionName for altitude.
DtElementAttributeManager& mgr = myDe.dataBank().elementData().attributeManager();
std::string foundAttributeResult;
if (mgr.getElementDisplayUnitCollectionName(entry->elementID(), foundAttributeResult))
{
result = DtUnicode::fromAscii(foundAttributeResult);
}
return result;
}
{
}
void ElementInspectorPage::updateElementPosition( DtElementEntry* entry )
{
//Update the labels to based on the current display units settings.
const DtDisplayUnitsConverter& converter = DtDisplayUnitsSettingsManager::instance(myDe).converter();
DtUnicode xLabel,yLabel,zLabel;
converter.coordinateSystemLabels(xLabel,yLabel,zLabel);
myXLabel->setText(xLabel.toQString<QString>() + ":" );
myYLabel->setText(yLabel.toQString<QString>() + ":" );
myZLabel->setText(zLabel.toQString<QString>() + ":" );
if(entry)
{
//Get the position of the entry.
DtVector position = getPosition(entry);
//Get the position in geocentric.
DtVector geocPosition;
myCoordinateSystem->localToNetPos(position,geocPosition);
// The object-type specific display unit collection determines the unit of
// measurement and decimal places to use when displaying the element's
// altitude, e.g. Fixed Wing elements may use feet while Space elements use
// kilometers.
DtUnicode objectTypeSpecificDisplayUnitCollectionName = getDisplayUnitCollectionName(entry);
// We want to use the 'Coordinate System' display unit for decimals
// for X/Y if we are using a Geodetic or zone-based coordinate system
DtUnicode displayUnitDecimalsToUseForXY = DtSharedDisplayUnitsSettings::theCoordinateSystemDisplayUnitName;
if (currentCoordinateSystem == DtDisplayUnitsConverter::CoordSys::CoordSysDatabase
|| currentCoordinateSystem == DtDisplayUnitsConverter::CoordSys::CoordSysGeocentric)
{
// In the case of Database or Geocentric, we want to use 'Distance' display unit for decimals
}
// Get the position as it should be displayed with notations included.
std::vector<DtUnicode> strings = converter.convertPositionToNotatedStringList(geocPosition,
converter.currentDistanceUnit(objectTypeSpecificDisplayUnitCollectionName, DtSharedDisplayUnitsSettings::theAltitudeDisplayUnitName),
converter.displayUnitDecimals(objectTypeSpecificDisplayUnitCollectionName, DtSharedDisplayUnitsSettings::theAltitudeDisplayUnitName));
if(strings.size() > 0)
{
myXValue->setText(QString::fromLatin1(strings[0].toLatin1().c_str()));
}
if(strings.size() > 1)
{
myYValue->setText(QString::fromLatin1(strings[1].toLatin1().c_str()));
}
if(strings.size() > 2)
{
myZValue->setText(QString::fromLatin1(strings[2].toLatin1().c_str()));
}
}
else
{
myXValue->clear();
myYValue->clear();
myZValue->clear();
}
}
void ElementInspectorPage::updateElementType( DtElementEntry* entry )
{
if(entry)
{
QString typeStr;
switch(entry->type())
{
typeStr = tr("Entity");
break;
typeStr = tr("Aggregate");
break;
typeStr = tr("Prop");
break;
typeStr = tr("Observer");
break;
typeStr = tr("Graphic Point");
break;
typeStr = tr("Graphic Shape");
break;
typeStr = tr("Graphic Vertex");
break;
typeStr = tr("Remote Graphic");
break;
typeStr = tr("Intervisibility Line");
break;
typeStr = tr("Terrain Patch");
break;
typeStr = tr("Feature");
break;
default:
typeStr = tr("Unknown");
break;
}
myTypeValue->setText(typeStr);
}
else
{
}
}
DtVector ElementInspectorPage::getPosition( DtElementEntry* entry ) const
{
if(!entry)
{
return DtVector::zero();
}
// Not everything has a scene object (and not everything has a position, such as
// a terrain patch or an intervisibility line). One example of something that
// does have a position but is not a scene object is an observer. Handle that first
if ( entry->type() == DtElementEntry::Observer )
{
std::string observerName;
if (myDe.dataBank().elementData().attributeManager().getElementDisplayName(entry->elementID(), observerName))
{
DtObserver* observer = myDe.driverManager().inputDriver().findObserverByName( observerName );
{
if ( observer )
{
return observer->location();
}
return DtVector::zero();
}
}
return DtVector::zero();
}
//Find the first model set which is realized.
{
DtModelSetRealizationManager::ModelSetRealizations::const_iterator i =
myDe.sharedState().modelSetRealizationManager().modelSetRealizations().begin();
DtModelSetRealizationManager::ModelSetRealizations::const_iterator e =
myDe.sharedState().modelSetRealizationManager().modelSetRealizations().end();
for ( ; i != e;++i)
{
if(i->second)
{
modelSet = i->first;
break;
}
}
}
//Find the scene objects for the element.
myDe.dataBank().elementData().getSceneObjectIds(entry->elementID(),
sceneObjects,modelSet);
if(sceneObjects.size() == 0)
{
return DtVector::zero();
}
//Find the resolver to get the scene object.
DtAgentUpdateResolverInterface* resolver =
myDe.agentManager().findUpdater( sceneObjects.front() );
if( !resolver )
{
return DtVector::zero();
}
DtSceneObject* sceneObject =
resolver->castObjectTypeFromUpdater<DtSceneObject>( "DtSceneObject" );
if(!sceneObject)
{
return DtVector::zero();
}
//Get the position of the scene object.
DtVector position;
sceneObject->getPosition(0,position);
return position;
}
Contains makVrv:DtAgentManager class.
Contains makVrv::DtDataBank class.
Contains makVrv::DtDe class.
Contains makVrv::DtDeSharedState class.
Contains makVrv::DtDeSharedStateSignaler class.
Contains the DtDisplayUnitsSettingsManager class declaration.
Contains makVrv:DtMasterScene class.
Contains the DtElementAttributeManager class declaration.
Contains makVrv::DtElementData class.
Contains makVrv::DtInputDriver class.
Contains makVrv::DtModelSetRealizationManager class.
Contains makVrv::DtObserver class.
Contains makVrv::DtSceneObject class.
Contains the declaration of the ElementInspectorPage.
ObjectType * castObjectTypeFromUpdater(const std::string &className)
Attempt to cast an object from an updater using the className. It is vital that the class name is the...
Definition DtAgentUpdateResolverInterface.h:35
static DtDeSharedStateSignaler & instance(DtDe &de)
Get an instance used to emit, or to connect.
void coordinateSystemLabels(DtUnicode &x, DtUnicode &y, DtUnicode &z) const
Gets the coordinate system labels for the current coordinate system.
CoordSys currentCoordinateDisplaySystem() const
Returns the distance unit of measurement to use for a given display unit.
unsigned int displayUnitDecimals(const DtUnicode &displayUnitCollectionName, const DtUnicode &displayUnitName) const
Returns the number of decimal places to use for a display unit.
DistanceUnits currentDistanceUnit(const DtUnicode &displayUnitCollectionName, const DtUnicode &displayUnitName) const
Returns the distance unit of measurement to use for a given display unit.
makArchives::DtDisplayUnitsSettingsRecord::CoordSys CoordSys
Definition DtDisplayUnitsSettingsManager.h:66
std::vector< DtUnicode > convertPositionToNotatedStringList(CoordSys coordSys, const DtVector &pos, DistanceUnits coordinateSystemUnit, unsigned int coordinateSystemDecimals, DistanceUnits altitudeUnit, unsigned int altitudeDecimals, bool minimal=false) const
Convert the geocentric position to a vector of notated strings.
static DtDisplayUnitsSettingsManager & instance(DtDe &de)
Get an instance of the settings manager.
const DtDisplayUnitsConverter & converter()
Returns the manager's internal converter.
virtual bool getElementDisplayUnitCollectionName(const DtElementEntry &entry, std::string &value) const
Get the display unit collection name from an element entry. Returns false if no display unit collecti...
std::vector< DtUniqueID > SceneObjectIdList
Public Type Definitions.
Definition DtElementData.h:38
DtElementEntry holds the non-simulation-specific data about an element, including its element type an...
Definition DtElementEntry.h:23
@ GraphicShape
Definition DtElementEntry.h:36
@ TerrainPatch
Definition DtElementEntry.h:31
@ Aggregate
Definition DtElementEntry.h:32
@ Observer
Definition DtElementEntry.h:33
@ RemoteGraphic
Definition DtElementEntry.h:38
@ Intervisibility
Definition DtElementEntry.h:40
@ GraphicVertex
Definition DtElementEntry.h:37
@ Feature
Definition DtElementEntry.h:41
@ Prop
Definition DtElementEntry.h:30
@ GraphicPoint
Definition DtElementEntry.h:35
@ Entity
Definition DtElementEntry.h:29
ObjectType type() const
Get the object type of an element.
DtElementID elementID() const
Get the unique ID of an element.
DtVector location() const
Get the observer's position from the remote object (no observer camera offset).
The page is a single widget component which is viewed in a page collection.
Definition DtPage.h:52
DtDe & myDe
Definition DtPage.h:139
A single configuration for an icon. The icon configuration is used by the DtWidgetIconStyleManager to...
Definition DtQIconConfiguration.h:60
A collection of icon configurations. The collection maintains flags indicating whether to generate ic...
Definition DtQIconConfiguration.h:132
virtual void addConfiguration(const DtQIconConfiguration &configuration)
Add an icon configuration to this list of configurations When adding a configuration,...
void getPosition(int vtx, DtVector &position) const
Gets the position of the object's specified vertex.
static DtSelectionManager & instance(DtDe &de)
Get the selection manager instance.
static const DtUnicode theAltitudeDisplayUnitName
Definition DtSharedDisplayUnitsSettings.h:229
static const DtUnicode theApplicationDisplayUnitCollectionName
The DtUnicode names used for the display unit collections.
Definition DtSharedDisplayUnitsSettings.h:214
static const DtUnicode theDistanceDisplayUnitName
Definition DtSharedDisplayUnitsSettings.h:228
static const DtUnicode theCoordinateSystemDisplayUnitName
Definition DtSharedDisplayUnitsSettings.h:235
QStringType toQString() const
Template function for outputting a Qt 4 style string.
Definition DtUnicode.h:171
static DtUnicode fromAscii(const std::string &ascii)
Definition DtUnicode.inl:285
Definition ElementInspectorPage.h:30
DtModelSetId
Definition DtModelSetEnums.h:20
@ Unspecified
Definition DtModelSetEnums.h:21
unsigned long long DtUniqueID
Definition DtUniqueID.h:19

exampleDialogPagePluginInit.cxx

/******************************************************************************
** Copyright (c) 2019 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#include <vrvCore/DtDe.h>
namespace makVrv
{
{
void init(DtDe& de)
{
// First make sure that the vrvCoreQt module is init'ed.
// Add the Example Page to the Example Dialog
//Add example menu and example menu settings item.
if(igApp)
{
"ElementPanel",DtUnicode::fromAscii("Example Element Panel"),
DtPageConfiguration::FloatRight,true,"ElementInspectorPage",
false, true, true);
makVrv::DtPagePath::collection("ElementPanel").page("ElementInspectorPage"));
}
}
}
}
{
makVrv::vrvExampleDisplayUnitsPlugin::init(*de);
return true;
}
Contains makVrv::DtQtPageAssembler class.
Contains makVrv::DtVrvApplication implementation.
@ FloatRight
Definition DtPageConfiguration.h:49
void registerPageCreator(DtPageCreator *creator)
static DtQtPageAssembler & instance(DtDe &de)
Get an instance of the Qt page Assembler.
DT_DLL_VRVCOREQT void init(DtDe &de)
DT_DLL_EXAMPLESCENEROOTPLUGIN void init(DtDe &anIG)