INET Framework for OMNeT++/OMNEST
inet::visualizer::LinkBreakCanvasVisualizer Class Reference

#include <LinkBreakCanvasVisualizer.h>

Inheritance diagram for inet::visualizer::LinkBreakCanvasVisualizer:
inet::visualizer::LinkBreakVisualizerBase inet::visualizer::VisualizerBase

Classes

class  LinkBreakCanvasVisualization
 

Protected Member Functions

virtual void initialize (int stage) override
 
virtual void refreshDisplay () const override
 
virtual const LinkBreakVisualizationcreateLinkBreakVisualization (cModule *transmitter, cModule *receiver) const override
 
virtual void addLinkBreakVisualization (const LinkBreakVisualization *linkBreakVisualization) override
 
virtual void removeLinkBreakVisualization (const LinkBreakVisualization *linkBreakVisualization) override
 
virtual void setAlpha (const LinkBreakVisualization *linkBreakVisualization, double alpha) const override
 
- 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

double zIndex = NaN
 
const CanvasProjectioncanvasProjection = nullptr
 
cGroupFigure * linkBreakGroup = nullptr
 
- Protected Attributes inherited from inet::visualizer::VisualizerBase
cModule * visualizerTargetModule = nullptr
 
const char * tags = nullptr
 

Additional Inherited Members

Member Function Documentation

void inet::visualizer::LinkBreakCanvasVisualizer::addLinkBreakVisualization ( const LinkBreakVisualization linkBreakVisualization)
overrideprotectedvirtual

Reimplemented from inet::visualizer::LinkBreakVisualizerBase.

78 {
80  auto linkBreakCanvasVisualization = static_cast<const LinkBreakCanvasVisualization *>(linkBreakVisualization);
81  linkBreakGroup->addFigure(linkBreakCanvasVisualization->figure);
82 }
const LinkBreakVisualizerBase::LinkBreakVisualization * inet::visualizer::LinkBreakCanvasVisualizer::createLinkBreakVisualization ( cModule *  transmitter,
cModule *  receiver 
) const
overrideprotectedvirtual

Implements inet::visualizer::LinkBreakVisualizerBase.

63 {
64  std::string icon(this->icon);
65  auto transmitterPosition = canvasProjection->computeCanvasPoint(getPosition(getContainingNode(transmitter)));
66  auto receiverPosition = canvasProjection->computeCanvasPoint(getPosition(getContainingNode(receiver)));
67  auto figure = new cIconFigure("linkBreak");
68  figure->setTags((std::string("link_break ") + tags).c_str());
69  figure->setTooltip("This icon represents a link break between two network nodes");
70  figure->setImageName(icon.substr(0, icon.find_first_of(".")).c_str());
71  figure->setTintAmount(iconTintAmount);
72  figure->setTintColor(iconTintColor);
73  figure->setPosition((transmitterPosition + receiverPosition) / 2);
74  return new LinkBreakCanvasVisualization(figure, transmitter->getId(), receiver->getId());
75 }
const char * tags
Definition: VisualizerBase.h:32
virtual Coord getPosition(const cModule *networkNode) const
Definition: VisualizerBase.cc:42
cModule * getContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:65
cFigure::Point computeCanvasPoint(const Coord &point) const
Definition: CanvasProjection.cc:32
void inet::visualizer::LinkBreakCanvasVisualizer::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::visualizer::LinkBreakVisualizerBase.

34 {
36  if (!hasGUI()) return;
37  if (stage == INITSTAGE_LOCAL) {
38  zIndex = par("zIndex");
39  auto canvas = visualizerTargetModule->getCanvas();
41  linkBreakGroup = new cGroupFigure("link breaks");
42  linkBreakGroup->setZIndex(zIndex);
43  canvas->addFigure(linkBreakGroup);
44  }
45 }
Local initializations.
Definition: InitStages.h:35
cModule * visualizerTargetModule
Definition: VisualizerBase.h:31
static const CanvasProjection * getCanvasProjection(const cCanvas *canvas)
Definition: CanvasProjection.cc:38
void inet::visualizer::LinkBreakCanvasVisualizer::refreshDisplay ( ) const
overrideprotectedvirtual

Reimplemented from inet::visualizer::LinkBreakVisualizerBase.

48 {
50  for (auto it : linkBreakVisualizations) {
51  auto linkBreakVisualization = static_cast<const LinkBreakCanvasVisualization *>(it.second);
52  auto transmitter = getSimulation()->getModule(linkBreakVisualization->transmitterModuleId);
53  auto receiver = getSimulation()->getModule(linkBreakVisualization->receiverModuleId);
54  auto transmitterPosition = canvasProjection->computeCanvasPoint(getPosition(getContainingNode(transmitter)));
55  auto receiverPosition = canvasProjection->computeCanvasPoint(getPosition(getContainingNode(receiver)));
56  auto figure = linkBreakVisualization->figure;
57  figure->setPosition((transmitterPosition + receiverPosition) / 2);
58  }
59  visualizerTargetModule->getCanvas()->setAnimationSpeed(linkBreakVisualizations.empty() ? 0 : fadeOutAnimationSpeed, this);
60 }
virtual Coord getPosition(const cModule *networkNode) const
Definition: VisualizerBase.cc:42
cModule * getContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:65
cModule * visualizerTargetModule
Definition: VisualizerBase.h:31
cFigure::Point computeCanvasPoint(const Coord &point) const
Definition: CanvasProjection.cc:32
void inet::visualizer::LinkBreakCanvasVisualizer::removeLinkBreakVisualization ( const LinkBreakVisualization linkBreakVisualization)
overrideprotectedvirtual

Reimplemented from inet::visualizer::LinkBreakVisualizerBase.

85 {
87  auto linkBreakCanvasVisualization = static_cast<const LinkBreakCanvasVisualization *>(linkBreakVisualization);
88  linkBreakGroup->removeFigure(linkBreakCanvasVisualization->figure);
89 }
void inet::visualizer::LinkBreakCanvasVisualizer::setAlpha ( const LinkBreakVisualization linkBreakVisualization,
double  alpha 
) const
overrideprotectedvirtual

Implements inet::visualizer::LinkBreakVisualizerBase.

92 {
93  auto linkBreakCanvasVisualization = static_cast<const LinkBreakCanvasVisualization *>(linkBreakVisualization);
94  auto figure = linkBreakCanvasVisualization->figure;
95  figure->setOpacity(alpha);
96 }
const value< double, units::unit > alpha(7.2973525376e-3)

Member Data Documentation

const CanvasProjection* inet::visualizer::LinkBreakCanvasVisualizer::canvasProjection = nullptr
protected
cGroupFigure* inet::visualizer::LinkBreakCanvasVisualizer::linkBreakGroup = nullptr
protected
double inet::visualizer::LinkBreakCanvasVisualizer::zIndex = NaN
protected

Referenced by initialize().


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