INET Framework for OMNeT++/OMNEST
inet::visualizer::InfoVisualizerBase Class Referenceabstract

#include <InfoVisualizerBase.h>

Inheritance diagram for inet::visualizer::InfoVisualizerBase:
inet::visualizer::VisualizerBase inet::visualizer::InfoCanvasVisualizer inet::visualizer::InfoOsgVisualizer

Classes

class  DirectiveResolver
 
class  InfoVisualization
 

Protected Member Functions

virtual void initialize (int stage) override
 
virtual void handleParameterChange (const char *name) override
 
virtual void refreshDisplay () const override
 
virtual InfoVisualizationcreateInfoVisualization (cModule *module) const =0
 
virtual void addInfoVisualization (const InfoVisualization *infoVisualization)
 
virtual void addInfoVisualizations ()
 
virtual void removeInfoVisualization (const InfoVisualization *infoVisualization)
 
virtual void refreshInfoVisualization (const InfoVisualization *infoVisualization, const char *info) const =0
 
virtual void removeAllInfoVisualizations ()
 
virtual const char * getInfoVisualizationText (cModule *module) const
 
- Protected Member Functions inherited from inet::visualizer::VisualizerBase
virtual int numInitStages () const override
 
virtual Coord getPosition (const cModule *networkNode) const
 
virtual Coord getContactPosition (const cModule *networkNode, const Coord &fromPosition, const char *contactMode, double contactSpacing) const
 
virtual InterfaceEntrygetInterfaceEntry (cModule *networkNode, cModule *module) const
 

Protected Attributes

std::vector< const InfoVisualization * > infoVisualizations
 
Parameters
bool displayInfos = false
 
ModuleFilter modules
 
StringFormat format
 
cFigure::Font font
 
cFigure::Color textColor
 
cFigure::Color backgroundColor
 
double opacity = NaN
 
Displacement displacementHint
 
double displacementPriority
 
- Protected Attributes inherited from inet::visualizer::VisualizerBase
cModule * visualizerTargetModule = nullptr
 
const char * tags = nullptr
 

Member Function Documentation

void inet::visualizer::InfoVisualizerBase::addInfoVisualization ( const InfoVisualization infoVisualization)
protectedvirtual

Reimplemented in inet::visualizer::InfoCanvasVisualizer.

Referenced by inet::visualizer::InfoCanvasVisualizer::addInfoVisualization(), and addInfoVisualizations().

98 {
99  infoVisualizations.push_back(infoVisualization);
100 }
std::vector< const InfoVisualization * > infoVisualizations
Definition: InfoVisualizerBase.h:68
void inet::visualizer::InfoVisualizerBase::addInfoVisualizations ( )
protectedvirtual

Referenced by handleParameterChange(), and initialize().

108 {
109  auto simulation = getSimulation();
110  for (int id = 0; id < simulation->getLastComponentId(); id++) {
111  auto component = simulation->getComponent(id);
112  if (component != nullptr && component->isModule() && modules.matches(static_cast<cModule*>(component))) {
113  auto infoVisualization = createInfoVisualization(static_cast<cModule*>(component));
114  addInfoVisualization(infoVisualization);
115  }
116  }
117 }
ModuleFilter modules
Definition: InfoVisualizerBase.h:58
virtual InfoVisualization * createInfoVisualization(cModule *module) const =0
bool matches(const cModule *module) const
Definition: ModuleFilter.cc:29
virtual void addInfoVisualization(const InfoVisualization *infoVisualization)
Definition: InfoVisualizerBase.cc:97
virtual InfoVisualization* inet::visualizer::InfoVisualizerBase::createInfoVisualization ( cModule *  module) const
protectedpure virtual
const char * inet::visualizer::InfoVisualizerBase::getInfoVisualizationText ( cModule *  module) const
protectedvirtual

Referenced by inet::visualizer::InfoCanvasVisualizer::createInfoVisualization(), and refreshDisplay().

128 {
129  DirectiveResolver directiveResolver(module);
130  return format.formatString(&directiveResolver);
131 }
StringFormat format
Definition: InfoVisualizerBase.h:59
const char * formatString(IDirectiveResolver *resolver) const
Definition: StringFormat.cc:29
void inet::visualizer::InfoVisualizerBase::handleParameterChange ( const char *  name)
overrideprotectedvirtual
76 {
77  if (name != nullptr) {
78  if (!strcmp(name, "modules"))
79  modules.setPattern(par("modules"));
80  else if (!strcmp(name, "format"))
81  format.parseFormat(par("format"));
84  }
85 }
void setPattern(const char *pattern)
Definition: ModuleFilter.cc:24
ModuleFilter modules
Definition: InfoVisualizerBase.h:58
StringFormat format
Definition: InfoVisualizerBase.h:59
virtual void addInfoVisualizations()
Definition: InfoVisualizerBase.cc:107
void parseFormat(const char *format)
Definition: StringFormat.cc:24
virtual void removeAllInfoVisualizations()
Definition: InfoVisualizerBase.cc:119
void inet::visualizer::InfoVisualizerBase::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::visualizer::VisualizerBase.

Reimplemented in inet::visualizer::InfoOsgVisualizer, and inet::visualizer::InfoCanvasVisualizer.

Referenced by inet::visualizer::InfoCanvasVisualizer::initialize().

55 {
57  if (!hasGUI()) return;
58  if (stage == INITSTAGE_LOCAL) {
59  displayInfos = par("displayInfos");
60  modules.setPattern(par("modules"));
61  format.parseFormat(par("format"));
62  font = cFigure::parseFont(par("font"));
63  textColor = cFigure::Color(par("textColor"));
64  backgroundColor = cFigure::Color(par("backgroundColor"));
65  opacity = par("opacity");
66  displacementHint = parseDisplacement(par("displacementHint"));
67  displacementPriority = par("displacementPriority");
68  }
69  else if (stage == INITSTAGE_LAST) {
70  if (displayInfos)
72  }
73 }
double displacementPriority
Definition: InfoVisualizerBase.h:65
void setPattern(const char *pattern)
Definition: ModuleFilter.cc:24
ModuleFilter modules
Definition: InfoVisualizerBase.h:58
StringFormat format
Definition: InfoVisualizerBase.h:59
Operations that no other initializations can depend on, e.g.
Definition: InitStages.h:111
virtual void initialize(int stage) override
Definition: VisualizerBase.cc:29
Displacement parseDisplacement(const char *s)
Definition: Displacement.cc:24
Local initializations.
Definition: InitStages.h:35
Displacement displacementHint
Definition: InfoVisualizerBase.h:64
virtual void addInfoVisualizations()
Definition: InfoVisualizerBase.cc:107
Color
Definition: DiffservUtil.h:30
void parseFormat(const char *format)
Definition: StringFormat.cc:24
cFigure::Color textColor
Definition: InfoVisualizerBase.h:61
bool displayInfos
Definition: InfoVisualizerBase.h:57
cFigure::Color backgroundColor
Definition: InfoVisualizerBase.h:62
double opacity
Definition: InfoVisualizerBase.h:63
cFigure::Font font
Definition: InfoVisualizerBase.h:60
void inet::visualizer::InfoVisualizerBase::refreshDisplay ( ) const
overrideprotectedvirtual
88 {
89  auto simulation = getSimulation();
90  for (auto infoVisualization : infoVisualizations) {
91  auto module = simulation->getModule(infoVisualization->moduleId);
92  if (module != nullptr)
93  refreshInfoVisualization(infoVisualization, getInfoVisualizationText(module));
94  }
95 }
virtual const char * getInfoVisualizationText(cModule *module) const
Definition: InfoVisualizerBase.cc:127
virtual void refreshInfoVisualization(const InfoVisualization *infoVisualization, const char *info) const =0
std::vector< const InfoVisualization * > infoVisualizations
Definition: InfoVisualizerBase.h:68
virtual void inet::visualizer::InfoVisualizerBase::refreshInfoVisualization ( const InfoVisualization infoVisualization,
const char *  info 
) const
protectedpure virtual
void inet::visualizer::InfoVisualizerBase::removeAllInfoVisualizations ( )
protectedvirtual

Referenced by handleParameterChange().

120 {
121  for (auto infoVisualization : infoVisualizations) {
122  removeInfoVisualization(infoVisualization);
123  delete infoVisualization;
124  }
125 }
std::vector< const InfoVisualization * > infoVisualizations
Definition: InfoVisualizerBase.h:68
virtual void removeInfoVisualization(const InfoVisualization *infoVisualization)
Definition: InfoVisualizerBase.cc:102
void inet::visualizer::InfoVisualizerBase::removeInfoVisualization ( const InfoVisualization infoVisualization)
protectedvirtual

Reimplemented in inet::visualizer::InfoCanvasVisualizer.

Referenced by removeAllInfoVisualizations(), and inet::visualizer::InfoCanvasVisualizer::removeInfoVisualization().

103 {
104  infoVisualizations.erase(std::remove(infoVisualizations.begin(), infoVisualizations.end(), infoVisualization), infoVisualizations.end());
105 }
void remove(std::vector< T > &v, const A &a)
Definition: stlutils.h:91
std::vector< const InfoVisualization * > infoVisualizations
Definition: InfoVisualizerBase.h:68

Member Data Documentation

cFigure::Color inet::visualizer::InfoVisualizerBase::backgroundColor
protected
Displacement inet::visualizer::InfoVisualizerBase::displacementHint
protected
double inet::visualizer::InfoVisualizerBase::displacementPriority
protected
bool inet::visualizer::InfoVisualizerBase::displayInfos = false
protected

Referenced by initialize().

cFigure::Font inet::visualizer::InfoVisualizerBase::font
protected
StringFormat inet::visualizer::InfoVisualizerBase::format
protected
std::vector<const InfoVisualization *> inet::visualizer::InfoVisualizerBase::infoVisualizations
protected
ModuleFilter inet::visualizer::InfoVisualizerBase::modules
protected
double inet::visualizer::InfoVisualizerBase::opacity = NaN
protected
cFigure::Color inet::visualizer::InfoVisualizerBase::textColor
protected

The documentation for this class was generated from the following files: