VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
exampleMilStdSymbology

Table of Contents

Overview

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.

Expected Result

exampleMilStd.PNG
Symbol gallery on Plan View

Example details

Unlike the standard vrvMilStd plugin, this example manually performs the full vrvMilStd initialization sequence in init() so that each step is visible and overridable.

The init() function loads the three JSON registries and creates a custom DtExampleMilStdManager – a DtMilStdManager subclass that overrides the renderer and SIDC-generator factory methods:

#include <vrvMilStd/DtMilStdWidgetClasses.hpp>
#include <vrvCore/DtDe.h>
#include <boost/bind/bind.hpp>
static makVrv::vrvSignalsLib::connection thePostInitializeConnection;
static DtExampleMilStd::DtMilStdSymbolToolbar* theToolbar = nullptr;
static void slotPostInit( makVrv::DtDe& de, DtExampleMilStd::DtExampleMilStdManager* mgr )
{
thePostInitializeConnection.disconnect();
// DtExampleMilStdManager::slot_postInitialize() has already run (it was
// connected first, in the manager constructor) and has called initialize()
// and connectToDecorationSettings(). All that remains here is to create
// and start the driver now that the manager is fully initialised.
// Ownership transfers to driverManager on addDriver().
de.driverManager().addDriver( driver );
de.driverManager().startDriver( driver );
if ( theToolbar )
{
theToolbar->setDriver( driver );
}
}
void init( makVrv::DtDe& de )
{
// ----------------------------------------------------------------
// Step 1: Geometry database -- parses all milstd_*.json files.
// Stores pre-scaled polyline geometry in 200x200 milsymbol space.
// ----------------------------------------------------------------
auto* jsonReg = new makVrv::DtMilStdJsonRegistry();
jsonReg->load( de.dePathConfiguration().resolvePath( "$(DATA_DIR)/MilStd" ) );

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:

thePostInitializeConnection = de.signal_postInitialize.connect(boost::bind(&slotPostInit, boost::ref(de), mgr));

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:

if (!iface.isInitialized())

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:

if ( symbol.standardIdentity() != makVrv::DtStandardIdentity::Hostile )

Toolbar buttons

Button What it demonstrates
Ghost Alpha Toggles DtMilStdKeyParams::myAlphaOverride between 128 (50%% ghost) and 255 (fully opaque).
Planned Toggles status 0 / 1; status=1 renders with a dashed-frame overlay.
Exercise Toggles context 0 / 1; exercise adds an X/J/K letter decorator to the right of the frame.
APP-6D Toggles DtMilStdKeyParams::myMilStdOverride between 2525D and APP-6D per symbol.
Add Override Calls DtMilStdSvgOverrideRegistry::addEntityTypeOverride() with a gold-star SVG for the Fighter aircraft, then rebuilds all keys.
Remove Override Removes the override and rebuilds keys to revert to the standard icon.

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/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.

Example Source Files


DtExampleMilStdManager.h

/******************************************************************************
** Copyright (c) 2026 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#pragma once
namespace DtExampleMilStd
{
class DT_DLL_EXAMPLEMILSTD DtExampleMilStdManager : public makVrv::DtMilStdManager
{
public:
explicit DtExampleMilStdManager( makVrv::DtDe& de );
protected:
virtual std::unique_ptr<makVrv::DtMilStdSVGRenderer>
createRenderer( const makVrv::DtMilStdJsonRegistry& registry ) override;
virtual std::unique_ptr<makVrv::DtMilStdSIDCGenerator>
createSidcGenerator( const makVrv::DtTypeToSidcJsonRegistry& registry ) override;
};
} // namespace DtExampleMilStd

DtExampleMilStdManager.cxx

/******************************************************************************
** Copyright (c) 2026 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#include <memory>
namespace DtExampleMilStd
{
// ============================================================
// DtTracingSIDCGenerator -- private to this translation unit.
// Overrides generateSIDC() to log every DIS->SIDC translation.
// ============================================================
class DtTracingSIDCGenerator : public makVrv::DtMilStdSIDCGenerator
{
public:
virtual std::string generateSIDC(
int kind, int domain, int country,
int category, int subcategory,
int specific, int extra,
makVrv::DtStandardIdentity standardIdentity,
makVrv::DtSymbologyStandard standard ) const override
{
kind, domain, country,
category, subcategory, specific, extra,
standardIdentity, ctx, stat, hqtf, echelon, standard );
DtInfo << "[exampleMilStdSymbology] DIS "
<< kind << ":" << domain << ":" << country << ":"
<< category << ":" << subcategory << ":" << specific << ":" << extra
<< " stdId=" << static_cast<int>( standardIdentity )
<< " -> SIDC " << sidc << std::endl;
return sidc;
}
};
// ============================================================
// DtExampleMilStdManager
// ============================================================
: DtMilStdManager( de )
{
}
std::unique_ptr<makVrv::DtMilStdSVGRenderer>
DtExampleMilStdManager::createRenderer( const makVrv::DtMilStdJsonRegistry& registry )
{
// Return our custom renderer instead of the default DtMilStdSVGRenderer.
// DtMilStdManager::initialize() calls createRenderer() once and stores
// the result; every subsequent buildBitmap() call uses this renderer.
return std::make_unique<DtExampleMilStdRenderer>( registry );
}
std::unique_ptr<makVrv::DtMilStdSIDCGenerator>
DtExampleMilStdManager::createSidcGenerator( const makVrv::DtTypeToSidcJsonRegistry& registry )
{
// Return the tracing generator instead of the default DtMilStdSIDCGenerator.
// Every call to DtMilStdManagerInterface::generateSIDC() dispatches through here.
return std::make_unique<DtTracingSIDCGenerator>( registry );
}
} // namespace DtExampleMilStd

DtExampleMilStdRenderer.h

/******************************************************************************
** Copyright (c) 2026 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#pragma once
namespace DtExampleMilStd
{
class DT_DLL_EXAMPLEMILSTD DtExampleMilStdRenderer : public makVrv::DtMilStdSVGRenderer
{
public:
explicit DtExampleMilStdRenderer( const makVrv::DtMilStdJsonRegistry& registry );
virtual bool render( const makVrv::DtMilStdSymbol& symbol, std::string& svgOut ) override;
};
} // namespace DtExampleMilStd

DtExampleMilStdRenderer.cxx

/******************************************************************************
** Copyright (c) 2026 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#include <cstdio>
#include <string>
namespace DtExampleMilStd
{
: makVrv::DtMilStdSVGRenderer( registry )
{
}
bool DtExampleMilStdRenderer::render( const makVrv::DtMilStdSymbol& symbol, std::string& svgOut )
{
// Call the base renderer first to produce the standard 2525D / APP-6D SVG.
if ( !makVrv::DtMilStdSVGRenderer::render( symbol, svgOut ) )
{
return false;
}
// Only hostile symbols receive the extra indicator.
{
return true;
}
// Inject a small red filled diamond centered on the symbol frame.
// The SVG canvas is (size) pixels wide. topHatSize() is the number of
// extra pixels above the standard frame area (for echelon/HQ decorations).
// Frame center in SVG pixel space:
// cx = size / 2
// cy = topHatSize + size / 2
// Diamond half-extent = size / 10 (10% of the symbol size).
const int sz = symbol.size();
const int top = symbol.topHatSize();
const int cx = sz / 2;
const int cy = top + sz / 2;
const int r = sz / 10;
// Build a polygon string using the four cardinal points of the diamond.
// Format: top, right, bottom, left (x,y pairs).
static constexpr int thePolygonBufSize = 256;
char buf[thePolygonBufSize];
std::snprintf( buf, sizeof( buf ),
"<polygon points=\"%d,%d %d,%d %d,%d %d,%d\""
" fill=\"#cc0000\" fill-opacity=\"0.75\" stroke=\"none\"/>\n",
cx, cy - r, // top
cx + r, cy, // right
cx, cy + r, // bottom
cx - r, cy // left
);
// Insert the polygon before the closing </svg> tag.
const std::string::size_type pos = svgOut.rfind( "</svg>" );
if ( pos != std::string::npos )
{
svgOut.insert( pos, std::string( buf ) );
}
return true;
}
} // namespace DtExampleMilStd

DtMilStdSymbolDriver.h

/******************************************************************************
** Copyright (c) 2026 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#pragma once
#include <matrix/vlVector.h>
#include <string>
#include <vector>
namespace makVrv
{
class DtAgentManager;
class DtWidgetLabelAgent;
class DtSceneObjectAgent;
class DtProjectedWidgetModelAgent;
} // namespace makVrv
namespace DtExampleMilStd
{
class DtExampleMilStdManager;
class DT_DLL_EXAMPLEMILSTD DtMilStdSymbolDriver : public makVrv::DtDriver
{
public:
DtMilStdSymbolDriver(makVrv::DtAgentManager& am, DtExampleMilStdManager* mgr);
virtual ~DtMilStdSymbolDriver();
virtual const std::string& className() const override;
virtual bool onStart() override;
virtual bool onStop() override;
virtual bool onTick() override;
void toggleGhostAlpha();
void togglePlannedStatus();
void toggleExerciseContext();
void toggleApp6D();
void addOverride();
void removeOverride();
struct SymbolDef
{
const char* myName = nullptr;
int myKind = 0;
int myDomain = 0;
int myCountry = 0;
int myCategory = 0;
int mySubcategory = 0;
int mySpecific = 0;
int myExtra = 0;
int myForceId = 0;
std::string myTypeString;
DtVector myWorldPos;
};
private:
struct LiveSymbol
{
const SymbolDef* myDef = nullptr;
makVrv::DtElementID myElementId;
makVrv::DtSceneObjectAgent* mySceneObj = nullptr;
makVrv::DtProjectedWidgetModelAgent* myPwma = nullptr;
makVrv::DtWidgetLabelAgent* myLabel = nullptr;
std::string mySidc;
};
void rebuildKey(LiveSymbol& s);
DtExampleMilStdManager* myMgr = nullptr;
std::vector<LiveSymbol> mySymbols;
bool myGhostActive = false;
bool myPlannedActive = false;
bool myExerciseActive = false;
bool myApp6DActive = false;
};
} // namespace DtExampleMilStd

DtMilStdSymbolDriver.cxx

/******************************************************************************
** Copyright (c) 2026 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#include <vrvCore/DtDe.h>
#include <vrvCore/DtSceneObjectAgent.hpp>
#include <vrvCore/DtProjectedWidgetModelAgent.hpp>
#include <vrvCore/DtWidgetLabelAgent.hpp>
namespace DtExampleMilStd
{
// -----------------------------------------------------------------------
// Symbol gallery definition -- 8 entities across 5 symbol sets.
// World positions are in Ground_DB II local database coordinates.
// forceId: 1=Friend, 2=Hostile, 3=Neutral (per DIS convention).
// -----------------------------------------------------------------------
static const DtMilStdSymbolDriver::SymbolDef theSymbolDefs[] = {
// name kind dom cty cat sub sp ex force worldPos
{"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]));
// Gold star SVG used for the Fighter override.
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>";
// Blue circle SVG used for the atlas pathway demo.
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>";
// Entity-type pattern for the Fighter: kind=1, domain=2, country=225, category=1,
// subcategory=-1 (wildcard), specific=-1 (wildcard), extra=-1 (wildcard).
static const char* theOverridePattern = "1:2:225:1:-1:-1:-1";
// -----------------------------------------------------------------------
: DtDriver(am, "DtMilStdSymbolDriver")
, myMgr(mgr)
{
myConnections.manageConnection( sig.signal_milSymbolStandardChanged.connect(
[this]( auto standard )
{
for ( auto& s : mySymbols )
{
rebuildKey( s );
}
} ) );
myConnections.manageConnection( sig.signal_colorSymbolByForceChanged.connect(
[this]( auto colorByForce )
{
for ( auto& s : mySymbols )
{
rebuildKey( s );
}
} ) );
myConnections.manageConnection( sig.signal_symbolOutlineColorOverrideChanged.connect(
[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()
{
// Load Ground_DB II so there is a terrain beneath the symbols.
makVrv::DtScene& scene = myAgentManager.de().scene();
std::string groundDb = myAgentManager.de().dePathConfiguration().sharedDataPath();
groundDb += "/TerrainData/TerrainConfiguration/Ground_DB II.mtf";
scene.loadTerrain(groundDb);
if (obs)
{
obs->setObserverMode( omm.lookupObserverModeKey( "Plan View" ) );
}
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()
{
if (!iface.isInitialized())
{
return true;
}
if (mySymbols.empty())
{
theFrameNum = myAgentManager.de().currentFrameNumber();
// ----------------------------------------------------------------
// Create 8 symbol widgets, one for each entry in theSymbolDefs.
// ----------------------------------------------------------------
mySymbols.reserve(theSymbolCount + 1);
for (int i = 0; i < theSymbolCount; ++i)
{
const SymbolDef& def = theSymbolDefs[i];
// --- Generate the 20-character SIDC ----------------------------
// DtTracingSIDCGenerator (injected via createSidcGenerator) logs
// the DIS tuple -> SIDC mapping to stdout on every call.
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;
// --- Build the virtual key ------------------------------------
// The key encodes the SIDC plus rendering parameters.
params.mySidc = sidc;
params.myColorMode = 0; // 0=Light (default pastel fills)
params.myAlphaOverride = 255; // 255=fully opaque
const std::string key = iface.generateMilStdKey(params);
DtInfo << "[exampleMilStdSymbology] " << def.myName << " key=" << key << std::endl;
// --- Dump SVG for the first symbol (debug tool) ---------------
if (i == 0)
{
std::string svg;
iface.svgSource(key, svg);
DtInfo << "[exampleMilStdSymbology] SVG for " << def.myName << " (first " << static_cast<int>(svg.size())
<< " chars):\n"
<< svg << std::endl;
}
// --- Create the scene agents ----------------------------------
const int symbolSz = iface.symbolSize();
const int renderH = iface.renderHeight(sidc);
LiveSymbol ls;
ls.myDef = &def;
ls.mySidc = sidc;
ls.myParams = params;
ls.myElementId = myAgentManager.createNewUniqueId();
ls.mySceneObj = makVrv::DtSceneObjectAgent::create(myAgentManager);
ls.myPwma = makVrv::DtProjectedWidgetModelAgent::create(myAgentManager);
ls.myLabel = dynamic_cast<makVrv::DtWidgetLabelAgent*>(iface.createMilStdWidgetAgent());
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;
}
// Scene object: attach to the 2D icon model set.
ls.mySceneObj->setModelSet(makVrv::DtModelSetId::Icons2D);
ls.mySceneObj->setElementID(ls.myElementId);
ls.mySceneObj->addModel(ls.myPwma, makVrv::DtStateVisualizer::EntityVisualizerType);
ls.mySceneObj->setPosition(0, def.myWorldPos);
// Widget label: set the MIL-STD key as the background image.
ls.myLabel->setColor(1, 1, 1, 1);
ls.myLabel->setTextBoundsPolicy(static_cast<int>(makVrv::DtWidgetLabel::TextBoundsPolicy::ConstrainToNone));
ls.myLabel->setSize(symbolSz, renderH);
ls.myLabel->setEventsEnabled(true);
ls.myLabel->setBackgroundImage(key);
ls.myPwma->addWidget(ls.myLabel);
// Report the element to VR-Vantage so it appears in the entity list.
reportElementAttribute(ls.myElementId, new makVrv::DtElementAttributeDisplayName(def.myName));
reportElementAttribute(ls.myElementId, new makVrv::DtElementAttributeConnectionObjectSidc(sidc));
reportElementAttribute(ls.myElementId, new makVrv::DtElementAttributeConnectionObjectType(def.myTypeString));
reportElementCreated(ls.myElementId, 0, makVrv::DtElementEntry::Entity);
mySymbols.push_back(std::move(ls));
}
// --- SVG Demo: Blue circle (same pathway, different SVG) ------
{
LiveSymbol ls;
ls.myDef = nullptr;
ls.myElementId = myAgentManager.createNewUniqueId();
ls.mySceneObj = makVrv::DtSceneObjectAgent::create(myAgentManager);
ls.myPwma = makVrv::DtProjectedWidgetModelAgent::create(myAgentManager);
ls.myLabel = makVrv::DtWidgetLabelAgent::create(myAgentManager);
if (ls.mySceneObj && ls.myPwma && ls.myLabel)
{
ls.mySceneObj->setModelSet(makVrv::DtModelSetId::Icons2D);
ls.mySceneObj->setElementID(ls.myElementId);
ls.mySceneObj->addModel(ls.myPwma, makVrv::DtStateVisualizer::EntityVisualizerType);
ls.mySceneObj->setPosition(0, DtVector(75.0, 225.0, 200.0));
ls.myLabel->setColor(1, 1, 1, 1);
ls.myLabel->setTextBoundsPolicy(static_cast<int>(makVrv::DtWidgetLabel::TextBoundsPolicy::ConstrainToBounds));
ls.myLabel->setSize(100, 100);
ls.myLabel->setEventsEnabled(false);
ls.myLabel->setRasterSize(120, 120);
ls.myLabel->setSvgSource(theCircleSvg);
ls.myPwma->addWidget(ls.myLabel);
reportElementAttribute(ls.myElementId, new makVrv::DtElementAttributeDisplayName("SVG (circle)"));
reportElementCreated(ls.myElementId, 0, makVrv::DtElementEntry::Entity);
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;
}
// -----------------------------------------------------------------------
// rebuildKey -- regenerate SIDC + key from current state flags and push
// the new key to the widget label.
// -----------------------------------------------------------------------
void DtMilStdSymbolDriver::rebuildKey(LiveSymbol& s)
{
if (!s.myDef)
{
return;
}
const int context = myExerciseActive ? 1 : 0;
const int status = myPlannedActive ? 1 : 0;
// Regenerate the SIDC with updated context/status/standard.
// The tracing generator in DtExampleMilStdManager will log the call.
s.mySidc = iface.generateSIDC(
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.mySidc = s.mySidc;
params.myColorMode = 0;
params.myAlphaOverride = myGhostActive ? static_cast<uint8_t>(0x80) : static_cast<uint8_t>(0xFF);
params.myMilStdOverride = standard;
s.myDef->myKind, s.myDef->myDomain, s.myDef->myCountry,
s.myDef->myCategory, s.myDef->mySubcategory, s.myDef->mySpecific,
s.myDef->myExtra, s.myDef->myForceId);
// also can be used
// params.myOverrideIndex = iface.isSidcOverridden(s.mySidc);
s.myParams = params;
const std::string key = iface.generateMilStdKey(params);
s.myLabel->setColor(1.0, 1.0, 1.0, 1.0);
s.myLabel->setBackgroundImage(key);
// Update the widget height in case status/context changed the decoration.
s.myLabel->setSize(iface.symbolSize(), iface.renderHeight(s.mySidc));
}
// -----------------------------------------------------------------------
// Toggle methods (called from DtMilStdSymbolToolbar)
// -----------------------------------------------------------------------
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()
{
// Inject a custom gold-star SVG for all Fighter aircraft (1:2:225:1:*:*:*).
// This overrides the standard 2525D fixed-wing aircraft icon.
//
// addEntityTypeOverride() stores the SVG in the override registry.
// Rebuilding all keys causes the Fighter symbol's atlas slot to be
// re-rendered using the new SVG without needing to change the widget's
// key string.
reg.addEntityTypeOverride(theOverridePattern, theStarSvg, /*highlight=*/false);
for (auto& s : mySymbols)
{
rebuildKey(s);
}
DtInfo << "[exampleMilStdSymbology] Override ADDED: Fighter now shows gold star." << std::endl;
}
void DtMilStdSymbolDriver::removeOverride()
{
reg.removeEntityTypeOverride(theOverridePattern);
// Rebuild keys for all symbols so the Override/<N> segment is dropped from
// any key that was generated while the override was active.
for (auto& s : mySymbols)
{
rebuildKey(s);
}
DtInfo << "[exampleMilStdSymbology] Override REMOVED: Fighter reverts to MIL-STD icon." << std::endl;
}
} // namespace DtExampleMilStd

DtMilStdSymbolToolbar.h

/******************************************************************************
** Copyright (c) 2026 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#pragma once
class QToolBar;
class QWidget;
namespace makVrv { class DtDe; }
namespace DtExampleMilStd { class DtMilStdSymbolDriver; }
namespace DtExampleMilStd
{
class DT_DLL_EXAMPLEMILSTD DtMilStdSymbolToolbar : public makVrv::DtToolbar
{
public:
explicit DtMilStdSymbolToolbar( makVrv::DtDe& de );
virtual ~DtMilStdSymbolToolbar();
void setDriver(DtMilStdSymbolDriver* driver);
virtual QToolBar* createToolbar( makVrv::DtDe& de, QWidget* parent ) override;
private:
makVrv::DtDe& myDe;
DtMilStdSymbolDriver* myDriver = nullptr;
};
} // namespace DtExampleMilStd

DtMilStdSymbolToolbar.cxx

/******************************************************************************
** Copyright (c) 2026 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#include <vrvCore/DtDe.h>
#include <QtWidgets/QToolBar>
#include <QtWidgets/QAction>
namespace DtExampleMilStd
{
: DtToolbar( de, "DtMilStdSymbolToolbar" )
, myDe( de )
{
}
DtMilStdSymbolToolbar::~DtMilStdSymbolToolbar()
{
}
void DtMilStdSymbolToolbar::setDriver( DtMilStdSymbolDriver* driver )
{
myDriver = driver;
}
QToolBar* DtMilStdSymbolToolbar::createToolbar( makVrv::DtDe& /*de*/, QWidget* parent )
{
QToolBar* bar = new QToolBar( parent );
bar->setWindowTitle( QObject::tr( "MIL-STD Symbology" ) );
bar->setObjectName( "DtMilStdSymbolToolbar" );
// Ghost Alpha: toggles myAlphaOverride between 128 (ghost) and 255 (opaque).
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();
// Planned Status: status=1 renders a dashed frame overlay.
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(); } } );
// Exercise Context: context=1 adds a letter decorator right of the frame.
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();
// APP-6D: per-symbol standard override via myMilStdOverride.
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();
// SVG Override: injects a gold star SVG for the Fighter via addEntityTypeOverride().
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;
}
} // namespace DtExampleMilStd

exampleMilStdSymbology.h

/******************************************************************************
** Copyright (c) 2026 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#pragma once
#ifdef _WIN32
# ifdef exampleMilStdSymbology_EXPORTS
# define DT_DLL_EXAMPLEMILSTD __declspec( dllexport )
# else
# define DT_DLL_EXAMPLEMILSTD __declspec( dllimport )
# endif
#else
# define DT_DLL_EXAMPLEMILSTD
#endif
#define DT_DE_PLUGIN_EXPORT_MACRO DT_DLL_EXAMPLEMILSTD
namespace makVrv { class DtDe; }

exampleMilStdSymbology.cxx

/******************************************************************************
** Copyright (c) 2026 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#include <vrvMilStd/DtMilStdWidgetClasses.hpp>
#include <vrvCore/DtDe.h>
#include <boost/bind/bind.hpp>
static makVrv::vrvSignalsLib::connection thePostInitializeConnection;
static DtExampleMilStd::DtMilStdSymbolToolbar* theToolbar = nullptr;
static void slotPostInit( makVrv::DtDe& de, DtExampleMilStd::DtExampleMilStdManager* mgr )
{
thePostInitializeConnection.disconnect();
// DtExampleMilStdManager::slot_postInitialize() has already run (it was
// connected first, in the manager constructor) and has called initialize()
// and connectToDecorationSettings(). All that remains here is to create
// and start the driver now that the manager is fully initialised.
// Ownership transfers to driverManager on addDriver().
de.driverManager().addDriver( driver );
de.driverManager().startDriver( driver );
if ( theToolbar )
{
theToolbar->setDriver( driver );
}
}
void init( makVrv::DtDe& de )
{
// ----------------------------------------------------------------
// Step 1: Geometry database -- parses all milstd_*.json files.
// Stores pre-scaled polyline geometry in 200x200 milsymbol space.
// ----------------------------------------------------------------
auto* jsonReg = new makVrv::DtMilStdJsonRegistry();
jsonReg->load( de.dePathConfiguration().resolvePath( "$(DATA_DIR)/MilStd" ) );
// ----------------------------------------------------------------
// Step 2: DIS-to-SIDC mapping table -- loaded from type_to_sidc_mappings.json.
// Maps 7-field DIS entity type tuples to SIDC function codes.
// ----------------------------------------------------------------
auto* sidcReg = new makVrv::DtTypeToSidcJsonRegistry();
sidcReg->load( de.dePathConfiguration().resolvePath(
"$(DATA_DIR)/MilStd/type_to_sidc_mappings.json" ) );
// ----------------------------------------------------------------
// Step 3: SVG override registry.
// Loads sidc_svg_overrides.json if present; silent no-op otherwise.
// ----------------------------------------------------------------
auto* overrideReg = new makVrv::DtMilStdSvgOverrideRegistry();
overrideReg->load( de.dePathConfiguration().resolvePath( "$(DATA_DIR)/MilStd/overrides" ) );
// ----------------------------------------------------------------
// Step 4: Custom manager (subclass of DtMilStdManager).
// Injects DtExampleMilStdRenderer and DtTracingSIDCGenerator
// via the createRenderer() / createSidcGenerator() factory overrides.
// ----------------------------------------------------------------
// Pre-init configuration: these calls are safe before signal_postInitialize
// fires. setSymbolSize() stores the value; setOperationalConditionMode() stores
// the mode. Neither touches the atlases (guarded by myInitialized). Both
// values are applied automatically when slot_postInitialize() runs.
mgr->setSymbolSize(120);
// Deferred init: manager setup, driver creation, and toolbar wiring all run
// after the DE finishes its own initialisation sequence.
thePostInitializeConnection = de.signal_postInitialize.connect(boost::bind(&slotPostInit, boost::ref(de), mgr));
// Register the MIL-STD widget factory so createMilStdWidgetAgent() works.
"DtMilStdWidget", new makVrv::DtMilStdWidgetClassesCreator );
// Register the imgui debug menu (shows SVG source, key info in the debug overlay).
// ----------------------------------------------------------------
// Qt setup: hide terrain picker, register toolbar, schedule driver.
// ----------------------------------------------------------------
makVrv::DtQtDeMainWindow* mainWindow = dynamic_cast<makVrv::DtQtDeMainWindow*>( &mw );
if ( mainWindow )
{
mainWindow->hideStartupDialog();
}
// Add the toolbar to the master-mode layout so VR-Vantage displays it.
if ( igApp )
{
makVrv::DtToolbarPath::toolbar( "DtMilStdSymbolToolbar" ) );
}
}
{
init( *de );
return true;
}

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)