VR-Forces 4.3 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
exampleSymbolFacade3

This example builds on the symbol facade and driver from the previous examples in this tutorial series, and shows additional steps that are necessary for rotating created symbols using an item on the symbol's context menu.

In order to make applying rotations to selected symbols easier, the DtExampleSymbolDriver was updated to maintain a list of currently selected symbols at all times. The DtRotateSymbolItem then uses this list to determine if any symbols are selected, and uses the list to apply the rotation to the selected symbols.

// Don't try to maintain set of selected entities using the selected
// and deselected lists passed in, just update using selection manager.
DtSelectionManager& selMgr =
DtSelectionManager::instance( myAgentManager.de() );
const DtSelectionManager::IdSet& curSel = selMgr.currentSelections();
DtSelectionManager::IdSet::const_iterator selItr = curSel.begin();
DtSelectionManager::IdSet::const_iterator selEnd = curSel.end();
myCurrentlySelectedSymbols.clear();
DtSymbolFacade* symbol;
for ( ; selItr != selEnd; ++selItr )
{
if ( symbol = findSymbol(*selItr) )
{
myCurrentlySelectedSymbols.insert( symbol );
}
}

To signal that a symbol should be rotated and by how much, a menu item was created to prompt the user for the angle to rotate the symbol to and to apply the rotation to the currently selected symbols. In order to get the angle value from the user, a basic dialog (DtRotateSymbolDialog) was created.

void DtRotateSymbolItem::on_triggered()
{
// Prompt the user for the amount to rotate by.
DtRotateSymbolDialog rotateDialog( myDe );
int retCode = rotateDialog.exec();
if ( retCode == QDialog::Rejected )
{
return;
}
// Get the list of selected symbols from the driver.
DtExampleSymbolDriver* symbolDriver = (DtExampleSymbolDriver*)
myDe.driverManager().findDriver( "DtExampleSymbolDriver" );
DtExampleSymbolDriver::SymbolList selectedSymbols =
symbolDriver->selectedSymbols();
// Apply the rotation to selected symbols.
DtExampleSymbolDriver::SymbolList::iterator i = selectedSymbols.begin();
DtExampleSymbolDriver::SymbolList::iterator e = selectedSymbols.end();
float angle = rotateDialog.selectedRotationAmount();
for ( ; i != e; ++i )
{
(*i)->setRotation( angle );
}

The menu item also checks to make sure at least one symbol is selected on displaying the context menu, since the rotation only applies to symbols.

void DtRotateSymbolItem::on_aboutToShow()
{
// Get the symbol driver for determining if symbols are selected.
DtExampleSymbolDriver* symbolDriver = (DtExampleSymbolDriver*)
myDe.driverManager().findDriver( "DtExampleSymbolDriver" );
// Only enable the MenuItem if symbols are selected.
myAction->setEnabled( ! symbolDriver->selectedSymbols().empty() );
}

In order for the above DtRotateSymbolItem to work, the setRotation method must be implemented in the DtSymbolFacade.

void DtSymbolFacade::setRotation( float angleInDegrees )
{
myWidgetLabelAgent->setRotation( DtDeg2Rad(angleInDegrees) );
}

[<< exampleSymbolFacade2] [Home] [Top of Page] [exampleSymbolFacade4 >>]


DtSymbolDriverToolbar3.h

/*****************************************************************************
* Copyright (c) 2011 MAK Technologies, Inc.
* All rights reserved.
*****************************************************************************/
#pragma once
namespace makVrv
{
class DtDe;
}
namespace makVrv
{
namespace exampleSymbolFacade3
{
class DT_DLL_EXAMPLESYMBOLFACADE3 DtSymbolDriverToolbar
{
public:
DtSymbolDriverToolbar( makVrv::DtDe& );
virtual ~DtSymbolDriverToolbar();
virtual QToolBar* createToolbar( makVrv::DtDe&, QWidget* parent );
};
class DT_DLL_EXAMPLESYMBOLFACADE3 DtAddSymbolItem : public makVrv::DtMenuItem
{
public:
DtAddSymbolItem( makVrv::DtDe& de );
virtual ~DtAddSymbolItem();
virtual QAction* createAction( makVrv::DtDe&, QWidget* parent );
virtual void on_triggered();
protected:
makVrv::DtDe& myDe;
};
class DT_DLL_EXAMPLESYMBOLFACADE3 DtRotateSymbolItem : public makVrv::DtMenuItem
{
public:
DtRotateSymbolItem( makVrv::DtDe& de );
virtual ~DtRotateSymbolItem();
virtual QAction* createAction( makVrv::DtDe&, QWidget* parent );
virtual void on_aboutToShow();
virtual void on_triggered();
protected:
QAction* myAction;
makVrv::DtDe& myDe;
};
class DT_DLL_EXAMPLESYMBOLFACADE3 DtSymbolFacadeExampleMenu : public DtMenu
{
public:
DtSymbolFacadeExampleMenu(DtDe& de);
virtual ~DtSymbolFacadeExampleMenu();
virtual QMenu* createMenu( DtDe& de, QWidget* parent );
};
}
}

DtSymbolDriverToolbar3.cxx

/*****************************************************************************
* Copyright (c) 2011 MAK Technologies, Inc.
* All rights reserved.
*****************************************************************************/
#include <vrvCore/DtDe.h>
#include <QtGui/QToolBar>
#include <QtGui/QAction>
#include <QtGui/QMenu>
#include <matrix/vlVector.h>
#include <time.h>
#include <math.h>
namespace makVrv
{
namespace exampleSymbolFacade3
{
: DtToolbar( de, "DtSymbolDriverToolbar" )
{
}
DtSymbolDriverToolbar::~DtSymbolDriverToolbar()
{
}
QToolBar* DtSymbolDriverToolbar::createToolbar( DtDe&, QWidget* parent )
{
QToolBar* bar = new QToolBar( parent );
bar->setWindowTitle( QObject::tr("Symbol Driver Toolbar") );
bar->setObjectName( QObject::tr("Symbol Driver Toolbar") );
return bar;
}
DtAddSymbolItem::DtAddSymbolItem( DtDe& de )
: DtMenuItem( "DtAddSymbolItem" )
, myDe( de )
{
// Seed the random number generator.
srand( time(NULL ) );
}
DtAddSymbolItem::~DtAddSymbolItem()
{
}
QAction* DtAddSymbolItem::createAction( DtDe&, QWidget* parent )
{
QAction* act = new QAction( parent );
act->setText( DtMenuItem::tr("&Add new symbol...") );
act->setToolTip( DtMenuItem::tr("Create a new symbol...") );
act->setIcon( QIcon(QObject::tr("../data/Icons/UtilityAdd.svg")) );
return act;
}
void DtAddSymbolItem::on_triggered()
{
// Keep track of how many symbols have been created.
static int numSymbolsCreated = 0;
// Give the symbol a unique name.
DtString symbolName( "Symbol #" );
symbolName += DtString(numSymbolsCreated);
// Put the symbol somewhere random on the makland terrain.
double rand_x = 4000.0*((double)rand())/RAND_MAX;
double rand_y = 4000.0*((double)rand())/RAND_MAX;
double rand_z = 4000.0*((double)rand())/RAND_MAX;
DtVector location( rand_x, rand_y, rand_z );
// Get the driver and create the symbol
DtExampleSymbolDriver* symbolDriver = (DtExampleSymbolDriver*)
myDe.driverManager().findDriver( "DtExampleSymbolDriver" );
symbolDriver->createSymbol( symbolName.string(), location );
++numSymbolsCreated;
}
DtRotateSymbolItem::DtRotateSymbolItem( DtDe& de )
: DtMenuItem( "DtRotateSymbolItem" )
, myAction( 0 )
, myDe( de )
{
}
DtRotateSymbolItem::~DtRotateSymbolItem()
{
}
QAction* DtRotateSymbolItem::createAction( DtDe&, QWidget* parent )
{
myAction = new QAction( parent );
myAction->setText( DtMenuItem::tr("&Rotate symbol...") );
myAction->setToolTip( DtMenuItem::tr("Rotate symbol...") );
myAction->setIcon( QIcon(QObject::tr("../data/Icons/SetRestore.svg")) );
return myAction;
}
void DtRotateSymbolItem::on_aboutToShow()
{
// Get the symbol driver for determining if symbols are selected.
DtExampleSymbolDriver* symbolDriver = (DtExampleSymbolDriver*)
myDe.driverManager().findDriver( "DtExampleSymbolDriver" );
// Only enable the MenuItem if symbols are selected.
myAction->setEnabled( ! symbolDriver->selectedSymbols().empty() );
}
void DtRotateSymbolItem::on_triggered()
{
// Prompt the user for the amount to rotate by.
DtRotateSymbolDialog rotateDialog( myDe );
int retCode = rotateDialog.exec();
if ( retCode == QDialog::Rejected )
{
return;
}
// Get the list of selected symbols from the driver.
DtExampleSymbolDriver* symbolDriver = (DtExampleSymbolDriver*)
myDe.driverManager().findDriver( "DtExampleSymbolDriver" );
DtExampleSymbolDriver::SymbolList selectedSymbols =
symbolDriver->selectedSymbols();
// Apply the rotation to selected symbols.
DtExampleSymbolDriver::SymbolList::iterator i = selectedSymbols.begin();
DtExampleSymbolDriver::SymbolList::iterator e = selectedSymbols.end();
float angle = rotateDialog.selectedRotationAmount();
for ( ; i != e; ++i )
{
(*i)->setRotation( angle );
}
}
DtSymbolFacadeExampleMenu::DtSymbolFacadeExampleMenu(DtDe& de)
: DtMenu(de, "DtSymbolFacadeExampleMenu")
{
}
DtSymbolFacadeExampleMenu::~DtSymbolFacadeExampleMenu()
{
}
QMenu* DtSymbolFacadeExampleMenu::createMenu( DtDe& de, QWidget* parent )
{
QMenu* menu = new QMenu(QObject::tr("Example"), parent);
return menu;
}
}
}

DtRotateSymbolDialog3.h

/*****************************************************************************
* Copyright (c) 2011 MAK Technologies, Inc.
* All rights reserved.
*****************************************************************************/
#pragma once
#include <QtGui/QDialog>
class QDoubleSpinBox;
namespace makVrv
{
namespace exampleSymbolFacade3
{
class DT_DLL_EXAMPLESYMBOLFACADE3 DtRotateSymbolDialog : public QDialog
{ Q_OBJECT;
public:
DtRotateSymbolDialog( makVrv::DtDe& de, QWidget* parent = 0,
Qt::WindowFlags f = 0 );
virtual ~DtRotateSymbolDialog();
float selectedRotationAmount() const;
private:
DtRotateSymbolDialog( const DtRotateSymbolDialog& orig );
DtRotateSymbolDialog& operator = ( const DtRotateSymbolDialog& orig );
protected:
void setupGui();
protected:
QDoubleSpinBox* myRotationSpinner;
};
}
}

DtRotateSymbolDialog3.cxx

/*****************************************************************************
* Copyright (c) 2011 MAK Technologies, Inc.
* All rights reserved.
*****************************************************************************/
#include <QtGui/QDoubleSpinBox>
#include <QtGui/QVBoxLayout>
#include <QtGui/QHBoxLayout>
#include <QtGui/QPushButton>
#include <QtGui/QLabel>
namespace makVrv
{
namespace exampleSymbolFacade3
{
QWidget* parent /*= 0*/, Qt::WindowFlags f /*= 0 */ )
: QDialog( parent, f )
, myRotationSpinner( 0 )
{
setupGui();
setWindowTitle(tr("Rotate Symbol"));
}
DtRotateSymbolDialog::~DtRotateSymbolDialog()
{
}
void DtRotateSymbolDialog::setupGui()
{
QVBoxLayout* dialogLayout = new QVBoxLayout();
QHBoxLayout* fieldLayout = new QHBoxLayout();
{
QLabel* fieldLabel = new QLabel();
fieldLabel->setText( "Rotation (deg):" );
fieldLayout->addWidget( fieldLabel );
myRotationSpinner = new QDoubleSpinBox();
myRotationSpinner->setMinimum( 0 );
myRotationSpinner->setDecimals( 1 );
myRotationSpinner->setMaximum( 360 );
fieldLayout->addWidget( myRotationSpinner );
}
dialogLayout->addLayout( fieldLayout );
QHBoxLayout* okCancelLayout = new QHBoxLayout();
{
okCancelLayout->addStretch( 1 );
QPushButton* okButton = new QPushButton();
okButton->setText( "OK" );
okButton->setDefault( true );
okCancelLayout->addWidget( okButton );
connect( okButton, SIGNAL(clicked()), this, SLOT(accept()) );
QPushButton* cancelButton = new QPushButton();
cancelButton->setText( "Cancel" );
cancelButton->setDefault( false );
okCancelLayout->addWidget( cancelButton );
connect( cancelButton, SIGNAL(clicked()), this, SLOT(reject()) );
okCancelLayout->addStretch( 1 );
}
dialogLayout->addLayout( okCancelLayout );
setLayout( dialogLayout );
}
float DtRotateSymbolDialog::selectedRotationAmount() const
{
return myRotationSpinner->value();
}
}
}

DtSymbolFacade3.h

/*****************************************************************************
* Copyright (c) 2011 MAK Technologies, Inc.
* All rights reserved.
*****************************************************************************/
#pragma once
#include <boost/signal.hpp>
class DtVector;
namespace makVrv
{
class DtSceneObjectAgent;
class DtWidgetLabelAgent;
class DtAgentManagerInterface;
class DtProjectedWidgetModelAgent;
}
namespace makVrv
{
namespace exampleSymbolFacade3
{
class DT_DLL_EXAMPLESYMBOLFACADE3 DtSymbolFacade
{
public:
DtSymbolFacade( makVrv::DtAgentManagerInterface& sceneInterface,
virtual ~DtSymbolFacade();
virtual makVrv::DtElementID elementId() const;
virtual makVrv::DtWidgetLabelAgent& widgetLabelAgent();
virtual void setPosition( const DtVector& pos );
virtual void setRotation( float angleInDegrees );
protected:
// Sets up the sceneobject and widget agents.
// Non-virtual (Called from CTOR).
void initialize();
protected:
makVrv::DtElementID myElementId;
makVrv::DtSceneObjectAgent* mySceneObjectAgent;
makVrv::DtProjectedWidgetModelAgent* myProjectedWidgetModelAgent;
makVrv::DtWidgetLabelAgent* myWidgetLabelAgent;
};
}
}

DtSymbolFacade3.cxx

/*****************************************************************************
* Copyright (c) 2011 MAK Technologies, Inc.
* All rights reserved.
*****************************************************************************/
#include <vrvCore/DtProjectedWidgetModelAgent.hpp>
#include <vrvCore/DtWidgetLabelAgent.hpp>
#include <vrvCore/DtSceneObjectAgent.hpp>
#include <vlutil/vlUtil.h>
#include <matrix/vlMath.h>
namespace makVrv
{
namespace exampleSymbolFacade3
{
DtAgentManagerInterface& sceneInterface, DtElementID id )
: myElementId( id )
, mySceneObjectAgent( DtSceneObjectAgent::create(sceneInterface) )
, myProjectedWidgetModelAgent( DtProjectedWidgetModelAgent::create(sceneInterface) )
, myWidgetLabelAgent( DtWidgetLabelAgent::create(sceneInterface) )
{
initialize();
}
DtSymbolFacade::~DtSymbolFacade()
{
// Remove the widget label agent from the PWMA and delete it.
myProjectedWidgetModelAgent->removeWidget( myWidgetLabelAgent );
DtDELETE( myWidgetLabelAgent );
// Remove the PWMA from the scene object and delete it.
mySceneObjectAgent->removeModel( myProjectedWidgetModelAgent );
DtDELETE( myProjectedWidgetModelAgent );
// Delete the scene object now that everything's been removed from it.
DtDELETE( mySceneObjectAgent );
}
void DtSymbolFacade::initialize()
{
// Make sure the agents were fully created.
if ( ! mySceneObjectAgent ) DtTHROW_NEW( DtCorruptedState, "Unable to create scene object agent." );
if ( ! myProjectedWidgetModelAgent ) DtTHROW_NEW( DtCorruptedState, "Unable to create projected widget model agent." );
if ( ! myWidgetLabelAgent ) DtTHROW_NEW( DtCorruptedState, "Unable to create widget label agent." );
// Initialize the scene object
mySceneObjectAgent->setModelSet( 5 ); // PVD
mySceneObjectAgent->setElementID( myElementId );
mySceneObjectAgent->addModel( myProjectedWidgetModelAgent, DtStateVisualizer::EntityVisualizerType );
// Initialize the label
myWidgetLabelAgent->setOverlay( DtOverlayManager::ModelSet_2D_Icons_Overlay );
myWidgetLabelAgent->setBackgroundImage( "$(DATA_DIR)/images/ArrowCircle.png" );
myWidgetLabelAgent->setColor( 0.8f, 0.8f, 0.8f, 1.0f );
myWidgetLabelAgent->setSize( 32, 32 );
// Add the label to the projected widget model.
myProjectedWidgetModelAgent->addWidget( myWidgetLabelAgent );
// Enable events processing so symbols accept mouse input.
// Enabling events for the widget label agent allows mouse click
// events on the symbol to select them, as well as allowing for
// the context menu to be shown on right-click.
myWidgetLabelAgent->setEventsEnabled( true );
}
DtUniqueID DtSymbolFacade::elementId() const
{
return myElementId;
}
DtWidgetLabelAgent& DtSymbolFacade::widgetLabelAgent()
{
return *myWidgetLabelAgent;
}
void DtSymbolFacade::setPosition( const DtVector& pos )
{
mySceneObjectAgent->setPosition( 0, pos );
}
void DtSymbolFacade::setRotation( float angleInDegrees )
{
myWidgetLabelAgent->setRotation( DtDeg2Rad(angleInDegrees) );
}
// This is a static method that can be used to query what type of element
// DtSymbolFacades are. The returned value indicates whether the symbol
// is an entity, a prop, or a terrain (among other things).
// For this example we'll consider the symbol to be an entity.
DtElementEntry::ElementType DtSymbolFacade::elementType()
{
}
}
}

DtExampleSymbolDriver3.h

/*****************************************************************************
* Copyright (c) 2012 MAK Technologies, Inc.
* All rights reserved.
*****************************************************************************/
#pragma once
#include <boost/unordered_set.hpp>
class DtVector;
namespace makVrv
{
namespace exampleSymbolFacade3
{
class DtSymbolFacade;
class DT_DLL_EXAMPLESYMBOLFACADE3 DtExampleSymbolDriver
{
public:
typedef boost::unordered_set<DtSymbolFacade*> SymbolList;
public:
DtExampleSymbolDriver( makVrv::DtAgentManager& am );
virtual ~DtExampleSymbolDriver();
virtual const std::string& className() const;
virtual bool onStart();
virtual bool onStop();
virtual bool onTick();
virtual DtSymbolFacade* createSymbol( const std::string& name,
const DtVector& pos );
virtual DtSymbolFacade* findSymbol( makVrv::DtElementID id );
virtual SymbolList selectedSymbols() const;
protected:
virtual void positionSymbol( DtSymbolFacade* symbol, const DtVector& pos );
virtual void slot_currentSelectionChanged(
virtual void slot_displayEngineAdded( const makVrv::DtDeRecord& igRecord );
protected:
typedef boost::unordered_map<makVrv::DtElementID,DtSymbolFacade*> SymbolFacadeMap;
SymbolFacadeMap mySymbolFacades;
SymbolList myCurrentlySelectedSymbols;
};
}
}

DtExampleSymbolDriver3.cxx

/*****************************************************************************
* Copyright (c) 2011 MAK Technologies, Inc.
* All rights reserved.
*****************************************************************************/
#include <vrvCore/DtDe.h>
#include <vrvCore/DtWidgetAgent.hpp>
#include <vrvCore/DtWidgetLabelAgent.hpp>
#include <vrvCore/DtSceneObjectAgent.hpp>
#include <vrvCore/DtProjectedWidgetModelAgent.hpp>
#include <matrix/vlVector.h>
namespace makVrv
{
namespace exampleSymbolFacade3
{
: makVrv::DtDriver( am, "DtExampleSymbolDriver" )
{
}
DtExampleSymbolDriver::~DtExampleSymbolDriver()
{
DtExampleSymbolDriver::onStop();
}
const std::string& DtExampleSymbolDriver::className() const
{
static std::string name = "DtExampleSymbolDriver";
return name;
}
bool DtExampleSymbolDriver::onStart()
{
// Load the Makland programatically.
DtScene& sceneDriver = myAgentManager.de().scene();
std::string maklandPath = myAgentManager.de().dePathConfiguration().userPath();
maklandPath += "/terrains/Makland.mtf";
sceneDriver.loadTerrain( maklandPath );
// Listen for selection changes.
DtSelectionManager& selectionManager =
DtSelectionManager::instance( myAgentManager.de() );
selectionManager.signal_currentSelectionChanged.connect( boost::bind(
&DtExampleSymbolDriver::slot_currentSelectionChanged,
this, _1, _2, _3, _4 ) );
return true;
}
bool DtExampleSymbolDriver::onStop()
{
// Stop listening for selection changes.
DtSelectionManager& selectionManager =
DtSelectionManager::instance( myAgentManager.de() );
selectionManager.signal_currentSelectionChanged.disconnect(
boost::bind( &DtExampleSymbolDriver::slot_currentSelectionChanged,
this, _1, _2, _3, _4 ) );
// Delete all created facades.
SymbolFacadeMap::iterator i = mySymbolFacades.begin();
SymbolFacadeMap::iterator e = mySymbolFacades.end();
for ( ; i != e; ++i )
{
delete i->second;
}
// Clear the list of facades.
mySymbolFacades.clear();
return true;
}
bool DtExampleSymbolDriver::onTick()
{
return true;
}
DtSymbolFacade* DtExampleSymbolDriver::createSymbol(
const std::string& name, const DtVector& pos )
{
// Create symbol.
DtElementID elementId = myAgentManager.createNewUniqueId();
DtSymbolFacade* symbol = new DtSymbolFacade( myAgentManager, elementId );
symbol->widgetLabelAgent().setColor( 0.8f, 0.8f, 0.8f, 1.0f );
symbol->widgetLabelAgent().setSize( 32, 32 );
// Store the symbol in the driver's symbol map.
mySymbolFacades.insert( std::make_pair(elementId,symbol) );
// Report that the symbol was created and report its name.
// These commands report to VR-Vantage that a new object has been created
// and that it should be managed as an object that may be visualized in various ways.
reportElementCreated( elementId, 0, DtSymbolFacade::elementType() );
reportElementAttribute( elementId, new DtElementAttributeDisplayName(name) );
// Position the symbol.
positionSymbol( symbol, pos );
return symbol;
}
DtSymbolFacade* DtExampleSymbolDriver::findSymbol( DtElementID symbolId )
{
SymbolFacadeMap::iterator itr = mySymbolFacades.find( symbolId );
if ( itr != mySymbolFacades.end() )
return itr->second;
return NULL;
}
DtExampleSymbolDriver::SymbolList
DtExampleSymbolDriver::selectedSymbols() const
{
return myCurrentlySelectedSymbols;
}
void DtExampleSymbolDriver::positionSymbol(
DtSymbolFacade* symbol, const DtVector& pos )
{
// Initialize the coordinate converter with the position.
DtCoordinateConverter* coordConverter =
myAgentManager.de().sharedState().coordinateSystem().converter();
coordConverter->setupTopoFrame( pos );
// Convert the position (from ENU) to our local database (CIG) coordinate system.
DtVector position;
coordConverter->enuToCig_coordTrans( pos, position );
symbol->setPosition( position );
}
void DtExampleSymbolDriver::slot_currentSelectionChanged(
const DtSelectionManager::IdSet& selected,
const DtSelectionManager::IdSet& deselected,
DtSelectionManager::SelectionType newType,
DtSelectionManager::SelectionType oldType )
{
DtSelectionManager::IdSet::const_iterator i, e;
// Update selected symbols to indicate they're selected.
e = selected.end();
i = selected.begin();
for ( ; i != e; ++i )
{
SymbolFacadeMap::iterator itr = mySymbolFacades.find( *i );
if ( itr != mySymbolFacades.end() )
{
DtWidgetLabelAgent& label = itr->second->widgetLabelAgent();
label.setColor( 1.0f, 1.0f, 1.0f, 1.0f );
label.setSize( 36, 36 );
}
}
// Revert deselected symbols to the default (unselected) look.
e = deselected.end();
i = deselected.begin();
for ( ; i != e; ++i )
{
SymbolFacadeMap::iterator itr = mySymbolFacades.find( *i );
if ( itr != mySymbolFacades.end() )
{
DtWidgetLabelAgent& label = itr->second->widgetLabelAgent();
label.setColor( 0.8f, 0.8f, 0.8f, 1.0f );
label.setSize( 32, 32 );
}
}
// Don't try to maintain set of selected entities using the selected
// and deselected lists passed in, just update using selection manager.
DtSelectionManager& selMgr =
DtSelectionManager::instance( myAgentManager.de() );
const DtSelectionManager::IdSet& curSel = selMgr.currentSelections();
DtSelectionManager::IdSet::const_iterator selItr = curSel.begin();
DtSelectionManager::IdSet::const_iterator selEnd = curSel.end();
myCurrentlySelectedSymbols.clear();
DtSymbolFacade* symbol;
for ( ; selItr != selEnd; ++selItr )
{
if ( symbol = findSymbol(*selItr) )
{
myCurrentlySelectedSymbols.insert( symbol );
}
}
}
void DtExampleSymbolDriver::slot_displayEngineAdded( const DtDeRecord& igRecord )
{
// When a new display engine is connected to our driver, the driver
// must be re-started in order to ensure the terrain and all symbols
// are properly loaded on all connected De's.
stop();
start();
}
}
}

exampleSymbolFacade3.cxx

/*****************************************************************************
* Copyright (c) 2011 MAK Technologies, Inc.
* All rights reserved.
*****************************************************************************/
#include <vrvCore/DtDe.h>
// Use the VR-Vantage namespace.
// All classes in VR-Vantage are in this namespace.
using namespace makVrv;
using namespace makVrv::exampleSymbolFacade3;
bool initDeModule( DtDe* de )
{
// Setup the plug-in.
init( *de );
return true;
}
void init( DtDe& de )
{
// Ensure that init only gets called once
// (not strictly necessary here, but this is good practice in general)
// Make sure that the vrvCoreQt and vrvOsgEarthQt module are init'ed.
// Don't show the startup dialog for selecting a terrain.
//Add example menu and example page item.
if ( igApp )
{
// Register the toolbar and MenuItems so they can be created where they're placed.
// Add a new main menu to place example menu items that are also placed on the right click
// context menu. The new menu will be placed before the help menu
DtMenuPath::mainMenu("DtSymbolFacadeExampleMenu"), DtMenuPath::mainMenu("DtHelpMenu"));
DtMenuPath::mainMenu("DtSymbolFacadeExampleMenu").item("DtAddSymbolItem") );
DtMenuPath::mainMenu("DtSymbolFacadeExampleMenu").item("DtRotateSymbolItem") );
DtMenuPath::popupMenu("DtObjectContextMenu").item("DtRotateSymbolItem") );
// Add the buttons to the toolbar and context menu.
DtToolbarPath::toolbar("DtSymbolDriverToolbar").item("DtAddSymbolItem") );
DtMenuPath::popupMenu("DtObjectContextMenu").item("DtRotateSymbolItem") );
}
// We only want to create the driver if we are 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.
&installDriver, boost::ref(de) ) );
}
}
void installDriver( DtDe& de )
{
// Create DtExampleDriver.
// The driver is now owned by the display engine. Do not delete it.
de.driverManager().addDriver( driver );
// Start the driver, creating the agent.
de.driverManager().startDriver( driver );
}

exampleSymbolFacade3.h

/*****************************************************************************
* Copyright (c) 2011 MAK Technologies, Inc.
* All rights reserved.
*****************************************************************************/
#pragma once
// Plugin export macro.
#ifdef _WIN32
# ifdef EXAMPLESYMBOLFACADE3_EXPORTS
# define DT_DLL_EXAMPLESYMBOLFACADE3 __declspec ( dllexport )
# else
# define DT_DLL_EXAMPLESYMBOLFACADE3 __declspec ( dllimport )
# endif
#else
# define DT_DLL_EXAMPLESYMBOLFACADE3
#endif
// Declare & export the plugin initialization function (bool initDeModule(DtDe* de))
#define DT_DE_PLUGIN_EXPORT_MACRO DT_DLL_EXAMPLESYMBOLFACADE3
// Plugin initialization methods.

Document ID: Generated on Wed Mar 11 21:20:57 EDT 2015 from SVN revision 150940
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)