VR-Vantage 2.2 API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
exampleFomMapper

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.

Requirements and Limitations

Modifying the addAttr Example

You must modify the the addAttr example in VR-Link 3.13.2 to work properly with VR-Vantage. The addAttr example sets the position of the published entity to 0,0,0, which VR-Vantage cannot discover. Therefore, you must change the example to set the position to some other value. The changes also set the Marking Text, which will allow the entity to show up in the Object List panel.

To modify addAttr for this example, in addAttr.cxx, add the following lines:

esr->setLocation(DtVector(1,0,0));
esr->setMarkingText("Entity with mass");

after the line:

esr-setMass(215.0);

Rebuild addAttr. Please see the VR-Link documentation for instructions about how to build and run their examples.

The exampleFomMapper 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 addAttr 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 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.

This example has two visualizer classes, a protocol-independent visualizer - MassLabelVisualizer, and a protocol-dependent visualizer - VrlinkMassLabelVisualizer. MassLabelVisualizer is necessary for configuring model definitions in the GUI. It can also be extended to work with any simulation protocol. The protocol specific subclass is used only with the appropriate protocol specific driver. For this example, it is extended to work with HLA 1.3.

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 exampleFomMapper plug-in has an accessory class which will only work with HLA 1.3 drivers and is responsible for registering the new listener and visualizer classes with the driver's HLA 1.3 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.

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 exampleFomMapper plug-in, follow the instructions in VR-Vantage Developers Guide.

Using the Plug-in

To use the exampleFomMapper plug-in:

  1. Create a Separate Directory for Application Data
  2. Start a VR-Vantage Application that Uses the Plug-in and New Application Data
  3. Create a Model Definition
  4. Configure Entities
  5. Create a Connection using the Extended FOM Mapper
  6. Connect to the Network and run the addAttr Example

Create a Separate Directory for Application Data

To use the exampleFomMapper plug-in, we recommend that you create a separate appData directory so that the changes you make will not affect the default VR-Vantage configuration.

Note
The following procedure creates a configuration that is identical to the factory settings. If you want to start with your current configuration and settings, rather than the factory settings, copy the same set of directories from ./appData.

All paths are relative to the VR-Vantage install directory:

  1. Create a new directory ./exampleFomMapperAppData.
  2. Copy ./factory/definitions to ./exampleFomMapperAppData.
  3. Copy ./factory/drivers to ./exampleFomMapperAppData.
  4. Copy ./factory/gdal_data to ./exampleFomMapperAppData.
  5. Copy ./factory/geotiff to ./exampleFomMapperAppData.
  6. Copy ./factory/importConfig to ./exampleFomMapperAppData.
  7. Copy ./factory/proj_lib to ./exampleFomMapperAppData.
  8. Copy ./factory/schema to ./exampleFomMapperAppData.
  9. Copy ./factory/settings to ./exampleFomMapperAppData.

Start a VR-Vantage Application that Uses the Plug-in and New Application Data

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

vrvStealth –appDataDir ../exampleFomMapperAppData –plugin ../examples/plugins/release/exampleFomMapperPlugin.dll

Create a Model Definition

The MassLabelVisualizer uses a DtLabelWidgetAgent which can have a model definition for defining the appearance of the widget. Widgets use model definitions with the schema 'WidgetTheme'.

  1. Select the Model Definition Editor page.
  2. On the Schemas toolbar, click the Filter icon and select WidgetTheme.
  3. Click the Add Model Definition icon. The Add Model Definition dialog box opens.
  4. Type the name of the definition, in this example MassInfoWidget. MassInfoWidget is added to the list of widgets.
  5. Select MassInfoWidget.
  6. For each of the parameters listed in the following table, click the Add Parameter button and select the parameter from the list. Then, enter the value shown in the table.
backgroundImage ../data/Overlays/infoBackground.png
font ../data/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

Configure Entities

  1. Select the Entity Definition Editor page.
  2. Select the Land entity.
  3. Click on the Add Visual Definitions icon. The Add Visualizers dialog box opens.
  4. Select the 2D Mass Label visualizer. An entry is added to the list of visualizers.
  5. Scroll to the bottom of the Visual Definitions list and select 2D Mass Label
  6. Click on the Add Attribute icon, select modeldefinitionschema, and click OK.
  7. Change the model Definition Schema to WidgetTheme.
  8. Click on the Add Attribute icon, select modeldefinition, and click OK.
  9. Change the modelDefinition to MassInfoWidget.
  10. Click on the Add Attribute icon, select visualtype, and click OK.
  11. Change the visual Type to main_model.
  12. Click on the Add Attribute icon, select parent, and click OK.
  13. Change the parent to Main Object.
  14. Click on the Add Attribute icon, select type, and click OK.
  15. 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 1.3 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 1.3 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 FED File Name to example-vrlExtend.fed.
  9. Copy the example-vrlExtend.fed from the VR-Link bin64 directory to the VR-Vantage bin64 directory.

Connect to the Network and run the addAttr Example

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

The addAttr example should start publishing an entity. VR-Vantage should discover the entity. To quickly see the entity, attach to it by pressing the period (.) key. A tank should be visible. To the right of the tank there should be a label indicating the entity's mass.

Note
The entity will be displayed in space, with no terrain. If you want it on a specific terrain, when you rebuild addAttr use a set of coordinates that you know will work with a specific terrain and load that terrain in VR-Vantage. For the purposes of this example, displaying the label that shows the vehicle's mass proves that VR-Vantage works with the extended FOM.

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 ./bin/exampleFomMapper_stealth.bat (on Windows) or ./bin/exampleFomMapper_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.
******************************************************************************/
/******************************************************************************
** $RCSfile: exampleFomMapper.h,v $ $Revision: 1.2 $ $State: Exp $
******************************************************************************/
#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.
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 MyEntityStateRepInterceptor* actualRep = dynamic_cast<const MyEntityStateRepInterceptor*>(&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)
{
MyEntityStateRepInterceptor* actualRep = dynamic_cast<MyEntityStateRepInterceptor*>(stateRep);
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 MyEntityStateRepInterceptor* actualRep = dynamic_cast<const MyEntityStateRepInterceptor*>(&stateRep);
const MyEntityStateRepInterceptor* actualSeen = dynamic_cast<const MyEntityStateRepInterceptor*>(&asSeenByRemote);
if(actualRep && actualSeen)
{
// Just compare the masses in the two state repositories.
return (bool) (actualRep->mass() != actualSeen->mass());
}
else
{
return false;
}
}
#endif

MyEntityStateListener.h

/******************************************************************************
** Copyright (c) 2014 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#pragma once
#include <vl/entityStateRepository.h>
class MyEntityStateListener : public makVrv::vrvHla13::DtVrlinkEntityStateListener
{
public:
boost::signal< void (float )> signal_massSet;
};
class MyEntityStateListenerCreator : public makVrv::vrvHla13::DtVrlinkEntityStateListenerCreator
{
public:
MyEntityStateListenerCreator(makVrv::vrvHla13::DtVrlinkConnection& conn);
//functionality.
virtual makVrv::vrvHla13::DtVrlinkEntityStateListener* create(DtHlaObject* object);
};

MyEntityStateListener.cxx

/******************************************************************************
** Copyright (c) 2010 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
using namespace makVrv;
using namespace makVrv::vrvHla13;
{
}
{
}
{
return dynamic_cast<MyEntityStateRepInterceptor*>(&esr());
}
MyEntityStateListenerCreator::MyEntityStateListenerCreator( makVrv::vrvHla13::DtVrlinkConnection& conn )
{
}
{
}
{
return new MyEntityStateListener(mySim.sceneInterface().createNewUniqueId());
}

MyEntityStateRepInterceptor.h

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

MyEntityStateRepInterceptor.cxx

/******************************************************************************
** Copyright (c) 2010 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
using namespace makVrv;
using namespace makVrv::vrvHla13;
, myMass(0.0)
{
}
{
if(myMass != temp)
{
myMass = temp;
MyEntityStateListener* listener = dynamic_cast<MyEntityStateListener*>(myListener);
if(listener)
{
listener->signal_massSet(myMass);
}
}
}
{
return myMass;
}
{
DtTHROW_NEW(DtCorruptedState,"Can't clone MyEntityStateRepInterceptor");
}
{
}
{
}
{
return new MyEntityStateRepInterceptor(listener);
}

MyEntityStateRep.h

/******************************************************************************
** Copyright (c) 2014 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#include <vl/entityStateRepository.h>
{
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();
};

MyEntityStateRep.cxx

/******************************************************************************
** Copyright (c) 2010 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
//Sets the mass.
void MyEntityStateRep::setMass( float mass )
{
}
//Gets the mass.
{
return myMass;
}
{
printf("Mass: %lf\n", mass());
}
DtStateRepository* MyEntityStateRep::clone( bool copy /*= false*/ ) const
{
if (copy)
{
//Use the copy constructor.
return new MyEntityStateRep(*this);
}
else
{
//Just return a new copy.
return new MyEntityStateRep();
}
}
{
return new MyEntityStateRep();
}

MassLabelVisualizer.h

/******************************************************************************
** Copyright (c) 2010 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#pragma once
namespace makVrv
{
class DtWidgetLabelAgent;
class DtProjectedWidgetModelAgent;
}
{
public:
makVrv::DtStateListener& listener, int modelSet);
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) 2010 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#include <stdio.h>
using namespace makVrv;
DtStateListener& listener, int modelSet )
: DtEntityStateVisualizer(simulation,listener,modelSet)
, myProjectedModel(0)
, myLabel(0)
{
}
{
}
{
if(!myLabel)
{
myLabel = DtWidgetLabelAgent::create(mySimulation.sceneInterface(), myDistributeFlag);
myLabel->setOverlay(DtOverlayManager::modelSetToOverlay(myModelSet));
}
{
myProjectedModel = DtProjectedWidgetModelAgent::create(mySimulation.sceneInterface(), myDistributeFlag);
}
{
}
}
{
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;
}

VrlinkMassLabelVisualizer.h

/******************************************************************************
** Copyright (c) 2010 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#pragma once
{
public:
makVrv::DtStateListener& listener, int modelSet);
virtual void createModelAgents();
protected:
};

VrlinkMassLabelVisualizer.inl

/******************************************************************************
** Copyright (c) 2010 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#pragma once
makVrv::DtBaseConnection& simulation, makVrv::DtStateListener& listener, int modelSet)
: MassLabelVisualizer(simulation,listener,modelSet)
, myCustomListener(dynamic_cast<MyEntityStateListener*>(&listener))
{
if(myCustomListener)
{
myCustomListener->signal_massSet.connect(boost::bind(&MassLabelVisualizer::updateMass,this,_1));
}
}
{
{
if(rep)
{
updateMass(rep->mass());
}
else
{
}
}
}

DtFomMapperAccessory.h

/******************************************************************************
** Copyright (c) 2010 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#pragma once
namespace makVrv
{
class DtConnection;
{
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_onSimCreated(DtConnection* connection);
virtual void slot_onSimConnected(DtConnection* connection);
virtual void slot_onSimAboutToBeDisconnected(DtConnection* 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_onSimCreated, this, _1));
}
}
void DtFomMapperAccessory::uninstall(DtDriver* baseConn)
{
//std::cout << "Accessory unInstall" << std::endl;
DtVrlinkDriver* vld = dynamic_cast<DtVrlinkDriver*>(baseConn);
if(vld)
{
vld->signal_simulationCreated.disconnect(
boost::bind(&DtFomMapperAccessory::slot_onSimCreated, this, _1));
}
}
bool DtFomMapperAccessory::isCompatible(DtDriver* driver)
{
DtVrlinkDriver* dd = dynamic_cast<DtVrlinkDriver*>(driver);
if(dd)
{
return true;
}
return false;
}
void DtFomMapperAccessory::slot_onSimCreated(DtConnection* conn)
{
conn->signal_connected.connect(
boost::bind(&DtFomMapperAccessory::slot_onSimConnected, this, conn));
conn->signal_toBeDisconnected.connect(
boost::bind(&DtFomMapperAccessory::slot_onSimAboutToBeDisconnected, this, conn));
DtVrlinkConnection* vrlCon = dynamic_cast<DtVrlinkConnection*>(conn);
if(vrlCon)
{
DtEntityStateRepositoryCreator::registerInstance(*vrlCon,
conn->registerInstance("DtEntityStateInterceptorCreator",
conn->registerInstance("DtVrlinkEntityStateListenerCreator",
}
}
void DtFomMapperAccessory::slot_onSimConnected(DtConnection* 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_onSimAboutToBeDisconnected(DtConnection* 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.
******************************************************************************/
/******************************************************************************
** $RCSfile: exampleFomMapperPlugin.h,v $ $Revision: 1.2 $ $State: Exp $
******************************************************************************/
#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) 2010 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#include <vrvCore/DtDe.h>
#include <boost/bind.hpp>
using namespace makVrv;
namespace exampleFomMapperPlugin
{
void postInitializeWork(DtDe* de)
{
// We're done with the signal, so disconnect from it
de->signal_postInitialize.disconnect(boost::bind(&postInitializeWork, de));
// 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);
new VrlinkMassLabelVisualizerCreator);
}
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.
de.signal_postInitialize.connect(boost::bind(&postInitializeWork, &de));
}
}
}
{
// Setup the plug-in. Normally, the init function and functionality
// should be in its own library.
return true;
}


Copyright © 2005-2017 VT MÄK. All Rights Reserved (www.mak.com)