Overview
Implements a custom entity element attribute.
Expected Result
Custom Element Attribute Result
Example details
VR-Forces publishes various properties for entities and other simulation objects. For entities, one such property is the 'entity label':
VR-Forces GUI - Setting an Entity Label
By default, VR-Vantage does not make use of this entity label property but a toolkit user can write a plugin which extracts this property from the entity state repository and makes it available throughout the application as an element attribute.
This example, implements a custom Entity State Listener class and maintains an entity's label that is published by VR-Forces for all entities and, if defined for an entity, reports it to the rest of the system as a custom element attribute. This custom element attribute can be queried throughout the system for visualization to the console, Qt user interface, or as part of the scene.
This example, when used with the exampleElementAttributesPlugin example, visualizes entity labels to the console.
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/exampleCustomElementAttributePluginDIS_stealth.bat (on Windows) or ./bin64/exampleCustomElementAttributePluginDIS_stealth.sh (on Linux). Once Vantage is started, connect with DIS. Open MAK DIS Logger and load "ExampleCustomElementAttributePluginDIS.lgr". Hit Play and you will see information printed in the console. There are startup scripts for HLA1516e: ./bin64/exampleCustomElementAttributePluginHLA1615e_stealth.bat (on Windows) or ./bin64/exampleCustomElementAttributePluginHLA1615e_stealth.sh (on Linux). There is no MAK Logger tape provided for the HLA1516e version of this example. For more information about running examples, please see Running Applications and Examples.
Example Source Files
exampleCustomElementAttributePlugin.h
#pragma once
#ifdef _WIN32
#ifdef EXAMPLECUSTOMELEMENTATTRIBUTEPLUGIN_EXPORTS
#define DT_DLL_EXAMPLECUSTOMELEMENTATTRIBUTEPLUGIN __declspec ( dllexport )
#else
#define DT_DLL_EXAMPLECUSTOMELEMENTATTRIBUTEPLUGIN __declspec ( dllimport )
#endif
#else
#define DT_DLL_EXAMPLECUSTOMELEMENTATTRIBUTEPLUGIN
#endif
#ifdef DtDIS
# define DT_PROTOCOL_NAMESPACE vrvDis
#else
# ifdef DtHLA_4
# define DT_PROTOCOL_NAMESPACE vrvHla4
# elif DtHLA_1516_EVOLVED
# define DT_PROTOCOL_NAMESPACE vrvHla1516e
# else
# ifdef DtHLA_1516
# include <vrvHla1516/vrvHla1516.h>
# define DT_PROTOCOL_NAMESPACE vrvHla1516
# else
# ifdef DtHLA
# define DT_PROTOCOL_NAMESPACE vrvHla13
# define DL_DLL_IGCONVRLINK DT_DLL_VRVHLA13
# else
# error "Protocol not specified or unsupported."
# endif
# endif
# endif
#endif
#define DT_DE_PLUGIN_EXPORT_MACRO DT_DLL_EXAMPLECUSTOMELEMENTATTRIBUTEPLUGIN
namespace makVrv
{
class DtDe;
}
exampleCustomElementAttributePlugin.cxx
using namespace makVrv;
static vrvSignalsLib::connection postInitializeConnection;
{
postInitializeConnection.disconnect();
}
{
{
}
}
{
return true;
}
DtCustomElementAttributeAccessory.h
#pragma once
namespace makVrv
{
class DtVrlinkBaseConnection;
{
{
public:
DtCustomElementAttributeAccessory();
virtual ~DtCustomElementAttributeAccessory();
virtual void install(DtDriver* driver);
virtual void uninstall(DtDriver* baseConn);
virtual bool isCompatible(DtDriver* driver);
protected:
virtual void slot_onConnectionCreated(DtVrlinkBaseConnection* connection);
};
}
}
DtCustomElementAttributeAccessory.cxx
DtCustomElementAttributeVrlinkEntityStateListener.h
#pragma once
{
public:
public:
protected:
};
{
public:
#ifdef DtHLA
DtHlaObject* object);
#endif
#ifdef DtDIS
const DtEntityIdentifier& id, const DtEntityType& type);
#endif
};
DtCustomElementAttributeVrlinkEntityStateListener.cxx
#include <vrfExtObjects/extEntityStateRepository.h>
using namespace makVrv;
enum class CustomElementAttributeIds : unsigned short
{
};
, myEntityLabel("")
{
}
{
}
{
const DtExtEntityStateRepository& extEsr =
dynamic_cast<const DtExtEntityStateRepository&
>(
esr());
{
}
}
{
}
{
}
#ifdef DtHLA
{
}
#endif
#ifdef DtDIS
{
}
#endif
[<< Examples] [Home] [Top of Page]