VR-Vantage 3.2 API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
exampleHla1516eFomMapper

Table of Contents

Overview

Shows how to use an extended FOM and visualizes the new attribut

Expected Result

N/A

Example details

Using an Extended FOM in VR-Vantage

Simulation developers often extend FOMs to add attributes that are not part of the base FOM. They then want to be able to visualize the new attributes in VR-Vantage. This example shows how to create a VR-Vantage plug-in that listens for the new attributes in an extended FOM. It also shows how to configure VR-Vantage to display the new attribute. Additionally, it shows how to extend a visualizer and listener.

Requirements and Limitations

The exampleHla1516eFomMapper Plug-in:

The FOM Mapper example is a plug-in that lets VR-Vantage listen to an extended FOM and visualize its new attributes. The plug-in extends several of VR-Vantage's systems.

The simulation connection (VR-Link) drivers (for DIS and HLA protocols) have two subsystems - a visualizer system and a listener system. The listener system consists of listener objects that listen to network traffic and report on entities and interactions. The visualizer system connects to listeners. It creates and controls distributed objects that display models and effects in the scene. Each object or interaction is visualized using state visualizers, each of which is responsible for visualizing a particular effect or component. For example, one visualizer creates and updates the main model of a tank, while another visualizer creates and updates fire effects based on the tank's flame state.

The addAttrHla1516e_64 example adds an attribute called Mass to the FOM. For VR-Vantage to visualize this attribute, it must listen for it and have a visualizer to affect the scene. This example replaces the default entity state listener with a modified entity state listener that contains the additional attributes defined by the extended FOM. This example also adds a new state visualizer class that listens for the new mass attribute and displays the value as a 2D text label that is attached to the object. An extended listener signaler ( MyEntitySignaler ) is added that allows additional signals to be sent from protocol-dependent listeners to protocol-independent visualizers. MyEntitySignalerCreator is registered in place of VR-Vantage's DtListenerSignalerCreator; when protocol-dependent listeners are created they will create the new signaler instead of the default one.

This example has a protocol-independent visualizer - MassLabelVisualizer. MassLabelVisualizer is necessary for configuring model definitions in the GUI. The MassLabelVisualizer connects to the new signals added in MyEntitySignaler.

Because VR-Vantage has many drivers and they may execute in separate threads, it uses a class called an accessory to extend or modify particular drivers. The exampleHla1516eFomMapper plug-in has an accessory class which will only work with HLA 1516e drivers and is responsible for registering the new listener and visualizer classes with the driver's HLA 1516e DtVrlinkConnection object. This allows the connection object to create the newly registered listener rather than the original listener class and also the protocol-dependent visualizer class rather than the protocol-independent version.

The example includes a model definition, MassInfoWidget, which is used to configure the new visualizer, and is merged into the existing model definitions using the command line option –mergeModelDefs. This new model definition has the following attributes:

backgroundImage $YOUR_SHARED_DATA_DIR/Overlays/infoBackground.png
font $YOUR_SHARED_DATA_DIR/fonts/mak_mono.ttf
fontSize 11
height 18
originX 100
originY 0
paddingX 6
paddingY -1
textAlignment Left
textColor 0, 0, 0, 255
width 140
Note
This example is more complex than some of the other VR-Vantage examples, because it does several things: it is an example of a plug-in; it shows how to write a visualizer and a listener; it shows how to create an accessory to extend a driver. Because it does so many things, we do not walk you through the code for each action. Please see the comments in the source files for details as well as the other examples that demonstrate in detail each of these development tasks.

To build the exampleHla1516eFomMapper plug-in, follow the instructions in VR-Vantage Developers Guide.

Using the Plug-in

To use the exampleHla1516eFomMapper plug-in:

  1. Start a VR-Vantage Application that Uses the Plug-in and Model Definition
  2. Load a Terrain
  3. Configure Entities
  4. Create a Connection using the Extended FOM Mapper
  5. Connect to the Network and run the VR-Link addAttrHla1516e_64 Example

Start a VR-Vantage Application that Uses the Plug-in and Model Definition

The startup command must specify the plug-in and the new model definition, as follows (using VR-Vantage):

vrvStealth –plugin ../examples/plugins/release/exampleFomMapperPlugin.dll –mergeModelDefs ../examples/exampleHla1516eFomMapper/MassInfoWidget.ommx

Load a Terrain

The entity published by addAttrHla1516e_64 will be located on the Ground_DB II terrain. It is recommended that you load this terrain.

Configure Entities

A Visual Definition needs to be added to an Entity Element Definition so that the new MassLabelVisualizer will be created when the entity it will be attached to is created. Since the VR-Link example addAttrHla1516e_64 publishes a Land entity with the new Mass attribute, the following shows how to add this Visual Definition to all Land entities in the 2D Model Set.

  1. Select the Entity Definition Editor page (Settings->Visual Model Editors...->Entity Definition Editor).
  2. Select the Land entity.
  3. Change the model set to 2D
  4. Click on the Add Visual Definitions icon. The Add Visualizers dialog box opens.
  5. Select the 2D Mass Label visualizer. An entry is added to the list of visualizers.
  6. Scroll to the bottom of the Visual Definitions list and select 2D Mass Label
  7. Click on the Add Attribute icon, select modeldefinitionschema, and click OK.
  8. Change the model Definition Schema to WidgetTheme.
  9. Click on the Add Attribute icon, select modeldefinition, and click OK.
  10. Change the modelDefinition to MassInfoWidget.
  11. Click on the Add Attribute icon, select visualtype, and click OK.
  12. Change the visual Type to main_model.
  13. Click on the Add Attribute icon, select type, and click OK.
  14. Type should automatically be set to Mass Label Visualizer; if not, change it.

Close the Visual Model Editors dialog box.

Create a Connection using the Extended FOM Mapper

  1. Choose Settings -> Connections.
  2. Select the HLA 1516e Connections page.
  3. Click the Delete icon (minus sign) until you delete the existing connections. (This will prevent confusion when using this example. The installed connections are still available if you use the default appData directory.)
  4. Click the Add Connection icon. A connection called HLA 1516e Connection #1 is added.
  5. Click the Rename icon. The Rename Connection dialog box opens.
  6. Rename the connection to FOM Mapper Example Connection.
  7. Change the Federation Name to "example-vrlExtend".
  8. Change the RPR FOM Version in advanced settings to 2.0.
  9. Change the FED File Name to "example-vrlExtend_evolved.xml".
  10. Copy the example-vrlExtend_evolved.xml from the VR-Link bin64 directory to the VR-Vantage bin64 directory.
  11. No FOM modules are required, make sure the list is empty.

Connect to the Network and run the VR-Link addAttrHla1516e_64 Example

  1. If the Simulation Connections dialog box is not still open, choose Settings -> Connections.
  2. Select the HLA 1516e Connections page.
  3. Select the FOM Mapper Example Connection.
  4. Click Connect.
  5. Close the Simulation Connections dialog box.
  6. Run the VR-Link addAttrHla1516e_64 example program.

The addAttrHla1516e_64 example should start publishing an entity. VR-Vantage should discover the entity. Double click on the entity in the object list panel to attach to it. A tank should be visible. Change the observer mode to PVD (2D) to the right of the tank there should be a label indicating the entity's mass.

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/exampleHla1516eFomMapper_stealth.bat (on Windows) or ./bin64/exampleHla1516eFomMapper_stealth.sh (on Linux). For more information about running examples, please see Running Applications and Examples.

Example Source Files


exampleFomMapper.h

/******************************************************************************
** Copyright (c) 2009 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#pragma once
#ifdef _WIN32
#ifdef EXAMPLEFOMMAPPER_EXPORTS
#define DT_DLL_EXAMPLEFOMMAPPER __declspec ( dllexport )
#else
#define DT_DLL_EXAMPLEFOMMAPPER __declspec ( dllimport )
#endif
#else
#define DT_DLL_EXAMPLEFOMMAPPER
#endif
#if DtHLA
#define DT_PROTOCOL_NAMESPACE vrvHla13
//Actually make the shared VRLink code exported as HLA13 code.
#define DL_DLL_IGCONVRLINK DT_DLL_VRVHLA13
#endif

configFomMap.h

/******************************************************************************
** Copyright (c) 2010 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#pragma once
#if DtHLA
#include <vl/fomMapper.h>
// This function registers new encoding, decoding, and checking functions with
// a FOM Mapper for the new attribute of the "BaseEntity" object class called
// "Mass". It also registers encoding and decoding functions for a new
// parameter of the "WeaponFire" interaction class called "Temperature".
void configFomMapper(DtFomMapper* mapper);
// The encoding, decoding and checking functions that configFomMapper
// registers:
namespace makVrv
{
{
}
}
// Encoding function to be used for the "Mass" attribute.
void encodeMass(const DtStateRepository& stateRep,
RTI::AttributeHandleValuePairSet* avList,
RTI::AttributeHandle handle);
// Decoding function to be used for the "Mass" attribute.
void decodeMass(DtStateRepository* stateRep,
const RTI::AttributeHandleValuePairSet& avlist,
int pairSetIndex);
// Checking function to be used for the "Mass" attribute (checks whether
// update condition has been met).
bool needMass(
const DtStateRepository& stateRep,
const DtStateRepository& asSeenByRemote);
#endif

configFomMap.cxx

/******************************************************************************
** Copyright (c) 2014 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#if DtHLA
#if DtHLA
#define DT_PROTOCOL_NAMESPACE vrvHla13
#endif
#include <vl/hlaObject.h>
#include "configFomMap.h"
#include <vl/stateEncoderFactory.h>
#include <vl/stateDecoderFactory.h>
#include <vl/interactionEncoderFactory.h>
#include <vl/interactionDecoderFactory.h>
#include <vl/interactionFactory.h>
void configFomMapper(DtFomMapper* mapper)
{
// Add your encoding function for the "Mass" attribute to the prototype
// encoders for BaseEntity and all of its subclasses.
mapper->stateEncoderFactory()->addAttributeEncoder(
"BaseEntity", "Mass",
(DtHlaStateEncoder::DtAttributeEncoder) encodeMass, true);
// Add your decoding function for the "Mass" attribute to the prototype
// decoders for BaseEntity and all of its subclasses.
mapper->stateDecoderFactory()->addAttributeDecoder(
"BaseEntity", "Mass",
(DtHlaStateDecoder::DtAttributeDecoder) decodeMass, true);
// Add your checking function for the "Mass" attribute to the prototype
// encoders for BaseEntity and all of its subclasses.
mapper->stateEncoderFactory()->addAttributeChecker(
"BaseEntity", "Mass",
(DtHlaStateEncoder::DtAttributeChecker) needMass, true);
}
// Define the new encoding, decoding and checking functions that we register
// with the FOM Mapper. By using VR-Link's "Net" types in out functions, byte
// swapping occurs automatically when necessary.
void encodeMass(const DtStateRepository& stateRep,
RTI::AttributeHandleValuePairSet* avList, RTI::AttributeHandle handle)
{
const MyVrlinkEntityStateRepInterceptor* actualRep = dynamic_cast<const MyVrlinkEntityStateRepInterceptor*>(&stateRep);
if(actualRep)
{
// Get the value using stateRep's mass(), and add it to the avList.
double mass = actualRep->mass();
DtNetFloat64 netVal(mass);
avList->add(handle, (char*) &netVal, sizeof(DtNetFloat64));
}
}
void decodeMass(DtStateRepository* stateRep,
const RTI::AttributeHandleValuePairSet& avlist, int pairSetIndex)
{
if(actualRep)
{
// Get the value from the avList, and pass it to stateRep's setMass().
DtNetFloat64 netVal;
RTI::ULong length = 0;
avlist.getValue(pairSetIndex, (char* )&netVal, length);
actualRep->setMass((double) netVal);
}
}
// Checking function to be used for the "Mass" attribute (checks whether
// update condition has been met).
bool needMass( const DtStateRepository& stateRep, const DtStateRepository& asSeenByRemote)
{
const MyVrlinkEntityStateRepInterceptor* actualRep = dynamic_cast<const MyVrlinkEntityStateRepInterceptor*>(&stateRep);
const MyVrlinkEntityStateRepInterceptor* actualSeen = dynamic_cast<const MyVrlinkEntityStateRepInterceptor*>(&asSeenByRemote);
if(actualRep && actualSeen)
{
// Just compare the masses in the two state repositories.
return (bool) (actualRep->mass() != actualSeen->mass());
}
else
{
return false;
}
}
#endif

MyVrlinkEntityStateListener.h

/******************************************************************************
** Copyright (c) 2021 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#pragma once
#include <vl/entityStateRepository.h>
class MyVrlinkEntityStateListener : public makVrv::vrvHla13::DtVrlinkEntityStateListener
{
public:
class makVrv::vrvHla13::DtVrlinkConnection;
MyVrlinkEntityStateListener(makVrv::DtUniqueID id, makVrv::vrvHla13::DtVrlinkConnection& vrlCon);
};
class MyVrlinkEntityStateListenerCreator : public makVrv::vrvHla13::DtVrlinkEntityStateListenerCreator
{
public:
MyVrlinkEntityStateListenerCreator(makVrv::vrvHla13::DtVrlinkConnection& conn);
//functionality.
virtual makVrv::vrvHla13::DtVrlinkEntityStateListener* create(DtHlaObject* object);
};

MyVrlinkEntityStateListener.cxx

/******************************************************************************
** Copyright (c) 2022 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
using namespace makVrv;
using namespace makVrv::vrvHla13;
{
}
{
}
{
return dynamic_cast<MyVrlinkEntityStateRepInterceptor*>(&esr());
}
{
}
{
}
{
return new MyVrlinkEntityStateListener(mySim.sceneInterface().createNewUniqueId(), mySim);
}

MyVrlinkEntityStateRepInterceptor.h

/*****************************************************************************
* Copyright (c) 2014 MAK Technologies, Inc.
* All rights reserved.
*****************************************************************************/
#pragma once
#include <vl/hlaObject.h>
#include <vl/entityStateRepository.h>
#include <vrfExtObjects/extEntityStateRepository.h>
: public makVrv::vrvHla13::DtEntityStateInterceptor<DtExtEntityStateRepository>
{
public:
virtual void setMass( float mass );
virtual float mass() const;
public:
virtual DtStateRepository* clone(bool copy = false) const;
protected:
MyVrlinkEntityStateRepInterceptor( makVrv::vrvHla13::DtVrlinkEntityStateListener* listener );
protected:
float myMass;
};
: public makVrv::vrvHla13::DtEntityStateInterceptorCreator
{
public:
virtual DtEntityStateRepository* create(makVrv::vrvHla13::DtVrlinkEntityStateListener* listener);
};

MyVrlinkEntityStateRepInterceptor.cxx

/******************************************************************************
** Copyright (c) 2022 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
using namespace makVrv;
using namespace makVrv::vrvHla13;
: DtEntityStateInterceptor<DtExtEntityStateRepository>(listener)
, myMass(0.0)
{
}
{
if(myMass != temp)
{
myMass = temp;
MyVrlinkEntityStateListener* listener = dynamic_cast<MyVrlinkEntityStateListener*>(myVrlinkEntityStateListener);
if(listener)
{
MyEntitySignaler* signaler = dynamic_cast<MyEntitySignaler*>(listener->listenerSignaler());
if( signaler )
{
signaler->setMass( myMass );
}
}
}
}
{
return myMass;
}
DtStateRepository* MyVrlinkEntityStateRepInterceptor::clone(bool copy) const
{
DtTHROW_NEW(DtCorruptedState,"Can't clone MyVrlinkEntityStateRepInterceptor");
}
{
}
{
}
{
return new MyVrlinkEntityStateRepInterceptor(listener);
}

MyVrlinkEntityStateRep.h

/******************************************************************************
** Copyright (c) 2022 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#pragma once
#include <vl/entityStateRepository.h>
#include <vrfExtObjects/extEntityStateRepository.h>
class DT_DLL_EXAMPLEFOMMAPPER MyVrlinkEntityStateRep : public DtExtEntityStateRepository
{
public:
virtual void setMass(float mass);
virtual float mass() const;
virtual void printData() const;
virtual DtStateRepository* clone(bool copy = false) const;
protected:
float myMass;
};
: public makVrv::vrvHla13::DtEntityStateRepositoryCreator
{
public:
virtual DtEntityStateRepository* create();
};

MyVrlinkEntityStateRep.cxx

/******************************************************************************
** Copyright (c) 2022 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
: myMass(1.0f)
{
// nothing here
}
{
// nothing here
}
//Sets the mass.
{
}
//Gets the mass.
{
return myMass;
}
{
printf("Mass: %lf\n", mass());
}
DtStateRepository* MyVrlinkEntityStateRep::clone( bool copy /*= false*/ ) const
{
if (copy)
{
//Use the copy constructor.
return new MyVrlinkEntityStateRep(*this);
}
else
{
//Just return a new copy.
return new MyVrlinkEntityStateRep();
}
}
DtEntityStateRepository* MyVrlinkEntityStateRepCreator::create()
{
return new MyVrlinkEntityStateRep();
}

MassLabelVisualizer.h

/******************************************************************************
** Copyright (c) 2022 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#pragma once
namespace makVrv
{
class DtWidgetLabelAgent;
class DtProjectedWidgetModelAgent;
class DtSceneObjectAgent;
enum class DtModelSetId;
}
class MyEntityStateListener;
{
public:
virtual void createModelAgents();
virtual void destroyModelAgents();
virtual void updateMass(float mass);
protected:
virtual void setModelDefinitionForAgents();
protected:
//A pointer to the model which attaches the widget to the scene object.
//A pointer to the lable which will display text.
};

MassLabelVisualizer.cxx

/******************************************************************************
** Copyright (c) 2023 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#include <stdio.h>
using namespace makVrv;
DtStateListener& listener, DtSceneObjectAgent* sceneObject, DtModelSetId modelSet )
: DtEntityStateVisualizer(simulation,listener, sceneObject, modelSet)
, myProjectedModel(0)
, myLabel(0)
{
MyEntitySignaler* signaler = dynamic_cast<MyEntitySignaler*>(listener.listenerSignaler());
if( signaler )
{
signaler->signal_massSet.connect( std::bind( &MassLabelVisualizer::updateMass, this, std::placeholders::_1 ) );
}
}
{
}
{
if(!myLabel)
{
myLabel = DtWidgetLabelAgent::create(mySimulation.sceneInterface(), myDistributeFlag);
myLabel->setOverlay(DtOverlayManager::modelSetToOverlay(myModelSet));
}
{
myProjectedModel = DtProjectedWidgetModelAgent::create(mySimulation.sceneInterface(), myDistributeFlag);
}
{
}
if( signaler )
{
updateMass( signaler->mass() );
}
else if( myLabel )
{
}
}
{
if(myLabel)
{
char buffer[256];
sprintf(buffer,"Mass: %4.4f kg",mass);
DtUnicode txt = DtUnicode::fromAscii(buffer);
}
}
{
{
}
delete myLabel;
myLabel = 0;
}
{
if(myLabel)
{
}
}
{
return theTypeInfo();
}
{
static makVrv::DtVisualizerSchema thisSchema(
"MassLabelVisualizerSchema",
DtUnicode::tr("2D Mass Label"));
"MassLabelVisualizer",
DtUnicode::tr("Mass Label Visualizer"),
DtStateVisualizer::EntityVisualizerType,
thisSchema);
return thisTypeInfo;
}

DtFomMapperAccessory.h

/******************************************************************************
** Copyright (c) 2010 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#pragma once
namespace makVrv
{
class DtVrlinkBaseConnection;
{
class DT_DLL_EXAMPLEFOMMAPPER DtFomMapperAccessory : public DtBaseAccessory
{
public:
DtFomMapperAccessory();
virtual ~DtFomMapperAccessory();
virtual void install(DtDriver* driver);
virtual void uninstall(DtDriver* baseConn);
virtual bool isCompatible(DtDriver* driver);
protected:
virtual void slot_onConnectionCreated(DtVrlinkBaseConnection* connection);
virtual void slot_onConnectionConnected(DtVrlinkBaseConnection* connection);
virtual void slot_onConnectionAboutToBeDisconnected(DtVrlinkBaseConnection* connection);
};
}
}

DtFomMapperAccessory.inl

/******************************************************************************
** Copyright (c) 2010 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#include "configFomMap.h"
#include <vl/exerciseConn.h>
#include <boost/bind.hpp>
#include <iostream>
namespace makVrv
{
{
{
}
DtFomMapperAccessory::~DtFomMapperAccessory()
{
}
void DtFomMapperAccessory::install(DtDriver* driver)
{
DtVrlinkDriver* vld = dynamic_cast<DtVrlinkDriver*>(driver);
if(vld)
{
boost::bind(&DtFomMapperAccessory::slot_onConnectionCreated, this, _1));
}
}
void DtFomMapperAccessory::uninstall(DtDriver* baseConn)
{
//std::cout << "Accessory unInstall" << std::endl;
DtVrlinkDriver* vld = dynamic_cast<DtVrlinkDriver*>(baseConn);
if(vld)
{
vld->signal_connectionCreated.disconnect(
boost::bind(&DtFomMapperAccessory::slot_onConnectionCreated, this, _1));
}
}
bool DtFomMapperAccessory::isCompatible(DtDriver* driver)
{
DtVrlinkDriver* dd = dynamic_cast<DtVrlinkDriver*>(driver);
if(dd)
{
return true;
}
return false;
}
void DtFomMapperAccessory::slot_onConnectionCreated(DtVrlinkBaseConnection* conn)
{
conn->signal_connected.connect(
boost::bind(&DtFomMapperAccessory::slot_onConnectionConnected, this, conn));
conn->signal_toBeDisconnected.connect(
boost::bind(&DtFomMapperAccessory::slot_onConnectionAboutToBeDisconnected, this, conn));
DtVrlinkConnection* vrlCon = dynamic_cast<DtVrlinkConnection*>(conn);
if(vrlCon)
{
conn->registerInstance( "DtListenerSignalerCreator",
new MyEntitySignalerCreator() );
DtEntityStateRepositoryCreator::registerInstance(*vrlCon,
conn->registerInstance("DtEntityStateInterceptorCreator",
conn->registerInstance("DtVrlinkEntityStateListenerCreator",
}
}
void DtFomMapperAccessory::slot_onConnectionConnected(DtVrlinkBaseConnection* conn)
{
DtVrlinkConnection* vrlCon = dynamic_cast<DtVrlinkConnection*>(conn);
if(vrlCon)
{
//Configure the Fom Mapper to decode the new attributes.
configFomMapper(vrlCon->exerciseConn()->fomMapper());
}
}
void DtFomMapperAccessory::slot_onConnectionAboutToBeDisconnected(DtVrlinkBaseConnection* conn)
{
DtVrlinkConnection* vrlCon = dynamic_cast<DtVrlinkConnection*>(conn);
if(vrlCon)
{
// Remove the print visualizer instance from the sim connection
vrlCon->registerInstance("DtFomMapperVisualizer", 0);
}
}
}
}

exampleFomMapperPlugin.h

/******************************************************************************
** Copyright (c) 2009 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#pragma once
// Get proper local export symbol
// Setup proper plugin export symbol
#define DT_DE_PLUGIN_EXPORT_MACRO DT_DLL_EXAMPLEFOMMAPPER
// Declare & export the plugin initialization function (bool initDeModule(DtDe* de))
namespace makVrv
{
class DtDe;
}
// Work function for the plugin initialization
void init(makVrv::DtDe& de);

exampleFomMapperPlugin.cxx

/******************************************************************************
** Copyright (c) 2023 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#include <vrvCore/DtDe.h>
#include <functional>
using namespace makVrv;
namespace exampleFomMapperPlugin
{
static vrvSignalsLib::connection postInitializeConnection;
void postInitializeWork(DtDe* de)
{
// We're done with the signal, so disconnect from it
postInitializeConnection.disconnect();
// Add the print accessory to the accessory manager. It will get the option
// to install itself into any DtDriver objects that are created.
new MassLabelVisualizerCreator() );
}
void init(DtDe& de)
{
// Ensure that init only gets called once
// (not strictly necessary here, but this is good practice in general)
// We only want to create the accessory if we're running in master mode:
if (de.isInMasterMode())
{
// The accessory must be created after the DE's initialization is
// finished, to make sure all the objects it uses exist.
postInitializeConnection = de.signal_postInitialize.connect(std::bind(&postInitializeWork, &de));
}
}
}
{
// Setup the plug-in. Normally, the init function and functionality
// should be in its own library.
return true;
}

MyEntitySignaler.h

/******************************************************************************
** Copyright (c) 2023 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#pragma once
namespace makVrv
{
class DtBaseConnection;
class DtDe;
class MyEntitySignaler : public DtListenerSignaler
{
public:
virtual ~MyEntitySignaler();
MyEntitySignaler( const MyEntitySignaler& ) = delete;
public:
//signals
virtual void setMass( float mass );
virtual const float mass();
vrvSignalsLib::signal< void( float )> signal_massSet;
protected:
float myMass;
};
class MyEntitySignalerCreator : public DtListenerSignalerCreator
{
public:
public:
virtual DtListenerSignaler* create() const override;
};
}

MyEntitySignaler.cxx

/******************************************************************************
** Copyright (c) 2022 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#include <vrvCore/DtDe.h>
namespace makVrv
{
DtListenerSignaler()
, myMass( 0.0 )
{
// intentional NOP
}
MyEntitySignaler::~MyEntitySignaler()
{
// intentional NOP
}
void MyEntitySignaler::setMass( float mass )
{
myMass = mass;
signal_massSet( mass );
}
const float MyEntitySignaler::mass()
{
return myMass;
}
MyEntitySignalerCreator::MyEntitySignalerCreator() :
DtListenerSignalerCreator()
{
// intentional NOP
}
MyEntitySignalerCreator::~MyEntitySignalerCreator()
{
// intentional NOP
}
DtListenerSignaler* MyEntitySignalerCreator::create() const
{
return new MyEntitySignaler();
}
}

[<< Examples] [Home] [Top of Page]



Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)