This example demonstrates how to initialize, use, and extend the vrvMilStd 2525D / APP-6D symbology library from a VR-Vantage plugin.
Eight 2D symbol widgets are placed on the Ground_DB II terrain, representing a gallery of entity types across the Air, Land Unit, Land Equipment, Sea Surface, and Sea Subsurface symbol sets. A toolbar provides six interactive buttons that exercise the key rendering parameters in real time.
Unlike the standard vrvMilStd plugin, this example manually performs the full vrvMilStd initialization sequence in init() so that each step is visible and overridable.
After the manager is registered, the plugin connects a one-shot signal_postInitialize slot. When the display engine finishes initialization the manager's own slot_postInitialize() has already run (it was connected first in the manager constructor), so the plugin slot only needs to create and start the driver:
DtMilStdSymbolDriver::onTick() defers widget creation until the manager reports isInitialized(), which guarantees that the texture atlases are ready. On the first tick after initialization the driver switches to Plan View, then creates one DtSceneObjectAgent / DtProjectedWidgetModelAgent / DtWidgetLabelAgent triple per symbol:
The virtual texture key that drives each widget is produced by the manager interface:
DtExampleMilStdRenderer overrides render() to inject a red diamond into the SVG of every Hostile symbol, demonstrating the createRenderer() factory override point in DtMilStdManager:
This example is a plug-in. You can run it by running ./bin64/exampleMilStdSymbology_stealth.bat (on Windows from cmd.exe) or ./bin64/exampleMilStdSymbology_stealth.sh (on Linux). For more information about running examples, please see Running Applications and Examples.
{
static const DtMilStdSymbolDriver::SymbolDef theSymbolDefs[] = {
{"Fighter (Friend)", 1, 2, 225, 1, 0, 0, 0, 1, "1:2:225:1:-1:-1:-1", DtVector(-225.0, -75.0, 200.0)},
{"Attack Helo (Friend)", 1, 2, 225, 20, 0, 0, 0, 1, "1:2:225:20:-1:-1:-1", DtVector(-75.0, -75.0, 200.0)},
{"Tank M1A2 (Friend)", 1, 1, 225, 1, 0, 0, 0, 1, "1:1:225:1:-1:-1:-1", DtVector(75.0, -75.0, 20.0)},
{"IFV Bradley (Friend)", 1, 1, 225, 2, 1, 0, 0, 1, "1:1:225:2:1:-1:-1", DtVector(225.0, -75.0, 20.0)},
{"Destroyer DDG (Friend)", 1, 3, 225, 4, 0, 0, 0, 1, "1:3:225:4:-1:-1:-1", DtVector(-225.0, 75.0, 0.0)},
{"Submarine (Hostile)", 1, 4, 225, 3, 0, 0, 0, 2, "1:4:225:3:-1:-1:-1", DtVector(-75.0, 75.0, 0.0)},
{"Artillery SP (Neutral)", 1, 1, 225, 4, 0, 0, 0, 3, "1:1:225:4:-1:-1:-1", DtVector(75.0, 75.0, 20.0)},
{"Cargo Ship (Neutral)", 1, 3, 225, 80, 0, 0, 0, 3, "1:3:225:80:-1:-1:-1", DtVector(225.0, 75.0, 0.0)}};
static const int theSymbolCount = static_cast<int>(sizeof(theSymbolDefs) / sizeof(theSymbolDefs[0]));
static const char* theStarSvg = "<svg xmlns=\"http://www.w3.org/2000/svg\""
" width=\"100\" height=\"100\" viewBox=\"0 0 100 100\">"
"<rect width=\"100\" height=\"100\" fill=\"none\" stroke=\"none\"/>"
"<polygon"
" points=\"50,10 61,35 90,35 67,57 76,82 50,65 24,82 33,57 10,35 39,35\""
" fill=\"#ffd700\" stroke=\"#333333\" stroke-width=\"2\"/>"
"</svg>";
static const char* theCircleSvg = "<svg xmlns=\"http://www.w3.org/2000/svg\""
" width=\"100\" height=\"100\" viewBox=\"0 0 100 100\">"
"<circle cx=\"50\" cy=\"50\" r=\"40\""
" fill=\"#4488ff\" stroke=\"#222222\" stroke-width=\"3\"/>"
"</svg>";
static const char* theOverridePattern = "1:2:225:1:-1:-1:-1";
: DtDriver(am, "DtMilStdSymbolDriver")
, myMgr(mgr)
{
[this]( auto standard )
{
for ( auto& s : mySymbols )
{
rebuildKey( s );
}
} ) );
[this]( auto colorByForce )
{
for ( auto& s : mySymbols )
{
rebuildKey( s );
}
} ) );
[this]( auto forceId, auto color, auto enabled )
{
for ( auto& s : mySymbols )
{
rebuildKey( s );
}
} ) );
}
DtMilStdSymbolDriver::~DtMilStdSymbolDriver()
{
DtMilStdSymbolDriver::onStop();
}
const std::string& DtMilStdSymbolDriver::className() const
{
static std::string theName = "DtMilStdSymbolDriver";
return theName;
}
bool DtMilStdSymbolDriver::onStart()
{
std::string groundDb = myAgentManager.de().dePathConfiguration().sharedDataPath();
groundDb += "/TerrainData/TerrainConfiguration/Ground_DB II.mtf";
if (obs)
{
}
return true;
}
bool DtMilStdSymbolDriver::onStop()
{
for (auto& s : mySymbols)
{
reportElementDestroyed(s.myElementId);
s.myPwma->removeWidget(s.myLabel);
delete s.myLabel;
s.myLabel = nullptr;
s.mySceneObj->removeModel(s.myPwma);
delete s.myPwma;
s.myPwma = nullptr;
delete s.mySceneObj;
s.mySceneObj = nullptr;
}
mySymbols.clear();
return true;
}
static unsigned long long theFrameNum = 0;
bool DtMilStdSymbolDriver::onTick()
{
{
return true;
}
if (mySymbols.empty())
{
theFrameNum = myAgentManager.de().currentFrameNumber();
mySymbols.reserve(theSymbolCount + 1);
for (int i = 0; i < theSymbolCount; ++i)
{
const SymbolDef& def = theSymbolDefs[i];
const std::string sidc = iface.
generateSIDC(def.myKind, def.myDomain, def.myCountry, def.myCategory,
def.mySubcategory, def.mySpecific, def.myExtra, def.myForceId);
DtInfo << "[exampleMilStdSymbology] " << def.myName << " -> SIDC " << sidc << std::endl;
DtInfo << "[exampleMilStdSymbology] " << def.myName << " key=" << key << std::endl;
if (i == 0)
{
std::string svg;
DtInfo << "[exampleMilStdSymbology] SVG for " << def.myName << " (first " << static_cast<int>(svg.size())
<< " chars):\n"
<< svg << std::endl;
}
LiveSymbol ls;
ls.myDef = &def;
ls.mySidc = sidc;
ls.myParams = params;
ls.myElementId = myAgentManager.createNewUniqueId();
if (!ls.mySceneObj || !ls.myPwma || !ls.myLabel)
{
DtWarn << "[exampleMilStdSymbology] Failed to create agents for " << def.myName << std::endl;
delete ls.myLabel;
delete ls.myPwma;
delete ls.mySceneObj;
continue;
}
ls.mySceneObj->setElementID(ls.myElementId);
ls.myLabel->setColor(1, 1, 1, 1);
ls.myLabel->setSize(symbolSz, renderH);
ls.myLabel->setEventsEnabled(true);
ls.myLabel->setBackgroundImage(key);
ls.myPwma->addWidget(ls.myLabel);
mySymbols.push_back(std::move(ls));
}
{
LiveSymbol ls;
ls.myDef = nullptr;
ls.myElementId = myAgentManager.createNewUniqueId();
if (ls.mySceneObj && ls.myPwma && ls.myLabel)
{
ls.mySceneObj->setElementID(ls.myElementId);
ls.mySceneObj->setPosition(0, DtVector(75.0, 225.0, 200.0));
ls.myLabel->setColor(1, 1, 1, 1);
ls.myLabel->setSize(100, 100);
ls.myLabel->setEventsEnabled(false);
ls.myLabel->setRasterSize(120, 120);
ls.myLabel->setSvgSource(theCircleSvg);
ls.myPwma->addWidget(ls.myLabel);
mySymbols.push_back(std::move(ls));
DtInfo << "[exampleMilStdSymbology] Created SVG widget (blue circle via setSvgSource)." << std::endl;
}
else
{
delete ls.myLabel;
delete ls.myPwma;
delete ls.mySceneObj;
}
}
}
if (myAgentManager.de().currentFrameNumber() == theFrameNum + 1)
{
for (auto& s : mySymbols)
{
if (s.myDef)
{
rebuildKey(s);
}
}
}
return true;
}
void DtMilStdSymbolDriver::rebuildKey(LiveSymbol& s)
{
if (!s.myDef)
{
return;
}
const int context = myExerciseActive ? 1 : 0;
const int status = myPlannedActive ? 1 : 0;
s.myDef->myKind,
s.myDef->myDomain,
s.myDef->myCountry,
s.myDef->myCategory,
s.myDef->mySubcategory,
s.myDef->mySpecific,
s.myDef->myExtra,
s.myDef->myForceId,
context,
status,
0,
0,
standard);
params.
myAlphaOverride = myGhostActive ?
static_cast<uint8_t
>(0x80) : static_cast<uint8_t>(0xFF);
s.myDef->myKind, s.myDef->myDomain, s.myDef->myCountry,
s.myDef->myCategory, s.myDef->mySubcategory, s.myDef->mySpecific,
s.myDef->myExtra, s.myDef->myForceId);
s.myParams = params;
s.myLabel->setColor(1.0, 1.0, 1.0, 1.0);
s.myLabel->setBackgroundImage(key);
}
void DtMilStdSymbolDriver::toggleGhostAlpha()
{
myGhostActive = !myGhostActive;
DtInfo << "[exampleMilStdSymbology] Ghost alpha: "
<< (myGhostActive ? "ON (128/255 = 50% opacity)" : "OFF (255/255 = fully opaque)") << std::endl;
for (auto& s : mySymbols)
{
rebuildKey(s);
}
}
void DtMilStdSymbolDriver::togglePlannedStatus()
{
myPlannedActive = !myPlannedActive;
DtInfo << "[exampleMilStdSymbology] Status: " << (myPlannedActive ? "Planned (dashed frame)" : "Present") << std::endl;
for (auto& s : mySymbols)
{
rebuildKey(s);
}
}
void DtMilStdSymbolDriver::toggleExerciseContext()
{
myExerciseActive = !myExerciseActive;
DtInfo << "[exampleMilStdSymbology] Context: " << (myExerciseActive ? "Exercise (letter decorator)" : "Reality") << std::endl;
for (auto& s : mySymbols)
{
rebuildKey(s);
}
}
void DtMilStdSymbolDriver::toggleApp6D()
{
myApp6DActive = !myApp6DActive;
DtInfo << "[exampleMilStdSymbology] Standard: " << (myApp6DActive ? "APP-6D (NATO)" : "2525D (US)") << std::endl;
for (auto& s : mySymbols)
{
rebuildKey(s);
}
}
void DtMilStdSymbolDriver::addOverride()
{
for (auto& s : mySymbols)
{
rebuildKey(s);
}
DtInfo << "[exampleMilStdSymbology] Override ADDED: Fighter now shows gold star." << std::endl;
}
void DtMilStdSymbolDriver::removeOverride()
{
for (auto& s : mySymbols)
{
rebuildKey(s);
}
DtInfo << "[exampleMilStdSymbology] Override REMOVED: Fighter reverts to MIL-STD icon." << std::endl;
}
}
Contains makVrv:DtAgentManager class.
Contains makVrv::DtDataBank class.
Contains makVrv::DtElementAttributes class.
Contains makVrv::DtElementData class.
Contains makVrv::DtElementEntry class.
Driver that places a gallery of 2525D/APP-6D symbols on the terrain.
Contains makVrv::DtObserver class.
Contains the DtObserverModeManager class declaration.
Contains makVrv::DtOverlayManager class.
Contains makVrv::DtScene class.
Contains makVrv::DtSharedSettingsManager class.
Contains makVrv:DtStateVisualizer class.
Contains the DtSymbolDecorationSettingsSignaler class declaration.
Contains various enum classes relating to symbology.
DtMilStdSymbolDriver(makVrv::DtAgentManager &am, DtExampleMilStdManager *mgr)
Construct with the agent manager and the custom manager pointer.
DtDe & de()
Get the scene manager's Ig object.
Definition DtAgentManager.h:107
DtInputDriver & inputDriver()
Return the DtInputDriver associated with the master scene.
@ Entity
Definition DtElementEntry.h:29
Abstract interface for rendering MIL-STD symbology icons as textures.
Definition DtMilStdManagerInterface.h:93
virtual int renderHeight(const std::string &sidc) const =0
Return the actual rendered pixel height for the given SIDC (size + topHatSize + bottomHatSize).
virtual int isEntityTypeOverridden(int kind, int domain, int country, int category, int subcategory, int specific, int extra, int force=-1) const =0
Test whether the given entity-type fields match any SVG override entry.
virtual std::string generateSIDC(int kind, int domain, int country, int category, int subcategory, int specific, int extra, int forceId, int context=0, int status=0, int hqtf=0, int echelon=0, DtSymbologyStandard standard=DtSymbologyStandard::Undefined)=0
Generate a MIL-STD virtual key from DIS entity-type fields.
virtual std::string generateMilStdKey(const DtMilStdKeyParams ¶ms) const =0
Generate a MIL-STD virtual key from symbol parameters.
static DtMilStdManagerInterface & instance(DtDe &de)
Get (or lazily create) the per-DtDe singleton (main thread).
virtual bool isInitialized() const =0
Return true when the manager has completed initialisation and is ready to build symbols.
virtual void svgSource(const std::string &key, std::string &svg) const =0
Return the SVG source string for the symbol encoded in key. Debugging aid - not used by the manager i...
virtual int symbolSize() const =0
Return the configured symbol slot size in pixels (set via setSymbolSize()). This is the width of a st...
virtual DtWidgetLabelAgent * createMilStdWidgetAgent()=0
Create a DtMilStdWidgetAgent on the correct scene interface.
Registry of customer SVG overrides for MIL-STD-2525D symbols.
Definition DtMilStdSvgOverrideRegistry.h:63
static DtMilStdSvgOverrideRegistry & instance(DtDe &de)
Retrieve the registry registered on de.
virtual void removeEntityTypeOverride(const std::string &pattern, int force=-1)
Remove the entry matching the given entity-type pattern and force.
virtual void addEntityTypeOverride(const std::string &pattern, const std::string &svgContent, bool highlight, int force=-1)
Add or update an entity-type-pattern override.
A facade for a DtObserverObject.
Definition DtObserver.h:39
bool setObserverMode(int observerMode)
DtDe & de()
Get the observer's DtDe.
Definition DtObserver.h:52
DtObserverModeManager is responsible for loading and saving observer modes, and providing a mechanism...
Definition DtObserverModeManager.h:55
int lookupObserverModeKey(const std::string &stringKey) const
static DtObserverModeManager & instance(DtDe &de)
Get an instance used to emit, or to connect.
@ ModelSet_2D_Icons_Overlay
Definition DtOverlayManager.h:42
An object that represents everything that is visible in the scene.
Definition DtScene.h:45
bool loadTerrain(const DtUnicode &filePath)
Load the terrain from a file.
static DtSceneObjectAgent * create(makVrv::DtAgentManagerInterface &sceneInterface, bool bDistribute=true)
Static helper creator.
static DtSharedSettingsManager & instance(DtDe &)
Get an instance of the shared settings manager from the DtDe;.
@ EntityVisualizerType
Definition DtStateVisualizer.h:42
A signaler for the shared symbol decoration settings. This is used to send changes in currently used ...
Definition DtSymbolDecorationSettingsSignaler.h:36
event_signal< void(bool)> signal_colorSymbolByForceChanged
Definition DtSymbolDecorationSettingsSignaler.h:75
event_signal< void(bool, const DtColorValue &, const DtColorValue &)> signal_symbolOutlineColorOverrideChanged
Signal sent when outline color override state/colors have changed.
Definition DtSymbolDecorationSettingsSignaler.h:78
static DtSymbolDecorationSettingsSignaler & instance(const DtSharedSettingsManager &mgr)
event_signal< void(DtSymbologyStandard)> signal_milSymbolStandardChanged
Definition DtSymbolDecorationSettingsSignaler.h:82
DtUniqueElementAttribute< std::string, DtElementAttributes::DisplayName > DtElementAttributeDisplayName
Definition DtElementAttributes.h:88
@ Icons2D
Definition DtModelSetEnums.h:27
DtUniqueElementAttribute< std::string, DtElementAttributes::ConnectionObjectType > DtElementAttributeConnectionObjectType
Definition DtElementAttributes.h:79
@ MilStdApp6D
APP-6D (NATO).
Definition DtSymbologyEnums.h:22
@ MilStd2525D
MIL-STD-2525D (US/default).
Definition DtSymbologyEnums.h:21
DtUniqueElementAttribute< std::string, DtElementAttributes::ConnectionObjectSidc > DtElementAttributeConnectionObjectSidc
Definition DtElementAttributes.h:82
int myOverrideIndex
Zero-based SVG override entry index; -1 = none.
Definition DtMilStdManagerInterface.h:39
uint8_t myAlphaOverride
Definition DtMilStdManagerInterface.h:51
DtSymbologyStandard myMilStdOverride
Definition DtMilStdManagerInterface.h:40
std::string mySidc
20-char SIDC; dashes are accepted on input.
Definition DtMilStdManagerInterface.h:37
int myColorMode
0=Light 1=Medium 2=Dark.
Definition DtMilStdManagerInterface.h:38
#include <QtWidgets/QToolBar>
#include <QtWidgets/QAction>
{
: DtToolbar( de, "DtMilStdSymbolToolbar" )
, myDe( de )
{
}
DtMilStdSymbolToolbar::~DtMilStdSymbolToolbar()
{
}
void DtMilStdSymbolToolbar::setDriver( DtMilStdSymbolDriver* driver )
{
myDriver = driver;
}
{
bar->setWindowTitle( QObject::tr( "MIL-STD Symbology" ) );
bar->setObjectName( "DtMilStdSymbolToolbar" );
QAction* ghostAction = bar->addAction( QObject::tr(
"Ghost Alpha" ) );
ghostAction->setCheckable( true );
ghostAction->setToolTip( QObject::tr(
"Toggle alpha override: 128/255 = 50% opacity (ghost state)" ) );
QObject::connect( ghostAction, &QAction::triggered,
[this]( bool ) { if ( myDriver ) { myDriver->toggleGhostAlpha(); } } );
bar->addSeparator();
QAction* plannedAction = bar->addAction( QObject::tr(
"Planned" ) );
plannedAction->setCheckable( true );
plannedAction->setToolTip( QObject::tr(
"Toggle status: Planned (dashed frame) vs Present" ) );
QObject::connect( plannedAction, &QAction::triggered,
[this]( bool ) { if ( myDriver ) { myDriver->togglePlannedStatus(); } } );
QAction* exerciseAction = bar->addAction( QObject::tr(
"Exercise" ) );
exerciseAction->setCheckable( true );
exerciseAction->setToolTip( QObject::tr(
"Toggle context: Exercise (X/J/K letter decorator) vs Reality" ) );
QObject::connect( exerciseAction, &QAction::triggered,
[this]( bool ) { if ( myDriver ) { myDriver->toggleExerciseContext(); } } );
bar->addSeparator();
QAction* app6Action = bar->addAction( QObject::tr(
"APP-6D" ) );
app6Action->setCheckable( true );
app6Action->setToolTip( QObject::tr(
"Toggle standard: APP-6D (NATO) vs 2525D (US)" ) );
QObject::connect( app6Action, &QAction::triggered,
[this]( bool ) { if ( myDriver ) { myDriver->toggleApp6D(); } } );
bar->addSeparator();
QAction* addOvrAction = bar->addAction( QObject::tr(
"Add Override" ) );
addOvrAction->setToolTip( QObject::tr(
"Replace Fighter aircraft with a custom gold-star SVG override" ) );
QObject::connect( addOvrAction, &QAction::triggered,
[this]( bool ) { if ( myDriver ) { myDriver->addOverride(); } } );
QAction* rmOvrAction = bar->addAction( QObject::tr(
"Remove Override" ) );
rmOvrAction->setToolTip( QObject::tr(
"Remove the custom SVG override; Fighter reverts to MIL-STD icon" ) );
QObject::connect( rmOvrAction, &QAction::triggered,
[this]( bool ) { if ( myDriver ) { myDriver->removeOverride(); } } );
return bar;
}
}