The Range Line example demonstrates how to add a new visual definition to show a line of range between two points.
The Range Line is added as a new tactical graphic object. It will also show how to install a subclass of the vertex visualizer to add information next to a vertex (in this case, the range to the previous or next point).
This example also replaces the vertex used by the entity intervisibility fan to show the distance from the origin to the outer edge of this fan. The distance label will be shown close to the origin of the fan. If you try and attach this fan to an entity it is possible the entity will occlude the label
Reference this example in order to see how to replace existing visualizers and to add a new visualizer concept to the front-end.
In the Launcher, click the Plug-ins button to bring up the Plug-ins Selection dialog. Enable the plugin.
using namespace makVrf;
using namespace makVrv;
static DtUnicode theRangeLineDefinition = DtUnicode::fromAscii(
"Range_Line");
static DtUnicode theRangeVertexDefinition = DtUnicode::fromAscii(
"RangedVertex");
static DtUnicode theRangeVertexIVDefinition = DtUnicode::fromAscii(
"RangedIVVertex");
void DtCreateMenuConfigurationLoaded(
DtDe* de)
{
{
cats.add("Distance");
entry->
setMenuIcon(
"$(DATA_DIR)/images/overlays/small/line.png");
}
}
{
std::vector<DtVisualizerDefinition*> defs;
if (defs.size())
{
defs[0]->findOrCreateLocalAttribute("enabled"));
if (!setValue)
{
setValue =
DtVisualizerAttributeFactory::instance(de).create(DtVisualizerAttributeBool::theTypeInfo().className));
defs[0]->setAttribute("enabled", std::auto_ptr<DtVisualizerAttribute>(setValue));
}
else
{
*setValue = false;
}
}
}
{
if (rangeVertexDef)
{
disableHATLinesFor(de, set);
DtVisualizerAttributeFactory::instance(de).create(DtVisualizerAttributeString::theTypeInfo().className));
attr->
setValue(DtUnicode::fromAscii(
"Main Object"));
rangeDefinition->
setAttribute(
"parent", std::auto_ptr<DtVisualizerAttribute>(attr));
attr =
DtVisualizerAttributeFactory::instance(de).create(DtVisualizerAttributeString::theTypeInfo().className));
attr->
setValue(DtUnicode::fromAscii(
"DtRangeLineTextVisualizer"));
rangeDefinition->
setAttribute(
"type", std::auto_ptr<DtVisualizerAttribute>(attr));
attr =
DtVisualizerAttributeFactory::instance(de).create(DtVisualizerAttributeString::theTypeInfo().className));
attr->
setValue(DtUnicode::fromAscii(
"main_model"));
rangeDefinition->
setAttribute(
"visualtype", std::auto_ptr<DtVisualizerAttribute>(attr));
return rangeDefinition;
}
return 0;
}
void setupRangeLine(
DtDe* de)
{
{
if (names)
{
settings->tacticalGraphicsMapper().removeMappings(theRangeLineType);
}
settings->tacticalGraphicsMapper().addMapping(theRangeLineType, theRangeLineDefinition);
}
{
if (curDef)
{
if (rangeLineDef)
{
for(auto i : sets)
{
std::vector<DtVisualizerDefinition*> defs;
if (defs.size())
{
if (childDef)
{
if (setValue)
{
*setValue = theRangeVertexDefinition;
}
}
}
}
}
}
}
{
if (curDef)
{
createRangeVertexDefinition(*de, curDef, theRangeVertexDefinition);
}
if (curDef)
{
if (ivVertexDef)
{
if (!setValue)
{
setValue =
DtVisualizerAttributeFactory::instance(*de).create(DtVisualizerAttributeBool::theTypeInfo().className));
ivVertexDef->
setAttribute(
"computeToNextPoint", std::auto_ptr<DtVisualizerAttribute>(setValue));
}
else
{
*setValue = true;
}
}
}
}
if (fanDef)
{
disableHATLinesFor(*de, set);
std::vector<DtVisualizerDefinition*> defs;
if (defs.size())
{
defs[0]->findOrCreateLocalAttribute("vertexelementdefinition"));
if (setValue)
{
*setValue = theRangeVertexIVDefinition;
}
}
}
}
{
}
{
return true;
}
{
info.
pluginDescription =
"This example shows how to create a new object from scratch and create a new visualizer and updater";
}