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

#include <LinkCanvasVisualizerBase.h>

Inheritance diagram for inet::visualizer::LinkCanvasVisualizerBase:
inet::visualizer::LinkVisualizerBase inet::visualizer::VisualizerBase inet::visualizer::DataLinkCanvasVisualizer inet::visualizer::PhysicalLinkCanvasVisualizer

Classes

class  LinkCanvasVisualization
 

Protected Member Functions

virtual void initialize (int stage) override
 
virtual void refreshDisplay () const override
 
virtual const LinkVisualizationcreateLinkVisualization (cModule *source, cModule *destination, cPacket *packet) const override
 
virtual void addLinkVisualization (std::pair< int, int > sourceAndDestination, const LinkVisualization *linkVisualization) override
 
virtual void removeLinkVisualization (const LinkVisualization *linkVisualization) override
 
virtual void setAlpha (const LinkVisualization *linkVisualization, double alpha) const override
 
virtual void refreshLinkVisualization (const LinkVisualization *linkVisualization, cPacket *packet) 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 * linkGroup = nullptr
 
- Protected Attributes inherited from inet::visualizer::VisualizerBase
cModule * visualizerTargetModule = nullptr
 
const char * tags = nullptr
 

Additional Inherited Members

Member Function Documentation

void inet::visualizer::LinkCanvasVisualizerBase::addLinkVisualization ( std::pair< int, int >  sourceAndDestination,
const LinkVisualization linkVisualization 
)
overrideprotectedvirtual

Reimplemented from inet::visualizer::LinkVisualizerBase.

89 {
90  LinkVisualizerBase::addLinkVisualization(sourceAndDestination, linkVisualization);
91  auto linkCanvasVisualization = static_cast<const LinkCanvasVisualization *>(linkVisualization);
92  auto figure = linkCanvasVisualization->figure;
93  lineManager->addModuleLine(linkVisualization);
94  linkGroup->addFigure(figure);
95 }
void addModuleLine(const ModuleLine *moduleLine)
Definition: LineManager.cc:70
const LinkVisualizerBase::LinkVisualization * inet::visualizer::LinkCanvasVisualizerBase::createLinkVisualization ( cModule *  source,
cModule *  destination,
cPacket *  packet 
) const
overrideprotectedvirtual

Implements inet::visualizer::LinkVisualizerBase.

Reimplemented in inet::visualizer::DataLinkCanvasVisualizer, and inet::visualizer::PhysicalLinkCanvasVisualizer.

Referenced by inet::visualizer::DataLinkCanvasVisualizer::createLinkVisualization(), and inet::visualizer::PhysicalLinkCanvasVisualizer::createLinkVisualization().

73 {
74  auto figure = new LabeledLineFigure("link");
75  auto lineFigure = figure->getLineFigure();
76  lineFigure->setEndArrowhead(cFigure::ARROW_BARBED);
77  lineFigure->setLineWidth(lineWidth);
78  lineFigure->setLineColor(lineColor);
79  lineFigure->setLineStyle(lineStyle);
80  auto labelFigure = figure->getLabelFigure();
81  labelFigure->setFont(labelFont);
82  labelFigure->setColor(labelColor);
83  auto text = getLinkVisualizationText(packet);
84  labelFigure->setText(text.c_str());
85  return new LinkCanvasVisualization(figure, source->getId(), destination->getId());
86 }
void inet::visualizer::LinkCanvasVisualizerBase::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::visualizer::LinkVisualizerBase.

40 {
42  if (!hasGUI()) return;
43  if (stage == INITSTAGE_LOCAL) {
44  zIndex = par("zIndex");
45  auto canvas = visualizerTargetModule->getCanvas();
47  linkGroup = new cGroupFigure("links");
48  linkGroup->setZIndex(zIndex);
49  canvas->addFigure(linkGroup);
50  }
51 }
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::LinkCanvasVisualizerBase::refreshDisplay ( ) const
overrideprotectedvirtual

Reimplemented from inet::visualizer::LinkVisualizerBase.

54 {
56  auto simulation = getSimulation();
57  for (auto it : linkVisualizations) {
58  auto linkVisualization = it.second;
59  auto linkCanvasVisualization = static_cast<const LinkCanvasVisualization *>(linkVisualization);
60  auto figure = linkCanvasVisualization->figure;
61  auto sourceModule = simulation->getModule(linkVisualization->sourceModuleId);
62  auto destinationModule = simulation->getModule(linkVisualization->destinationModuleId);
63  auto sourcePosition = getContactPosition(sourceModule, getPosition(destinationModule), lineContactMode, lineContactSpacing);
64  auto destinationPosition = getContactPosition(destinationModule, getPosition(sourceModule), lineContactMode, lineContactSpacing);
65  auto shift = lineManager->getLineShift(linkVisualization->sourceModuleId, linkVisualization->destinationModuleId, sourcePosition, destinationPosition, lineShiftMode, linkVisualization->shiftOffset) * lineShift;
66  figure->setStart(canvasProjection->computeCanvasPoint(sourcePosition + shift));
67  figure->setEnd(canvasProjection->computeCanvasPoint(destinationPosition + shift));
68  }
69  visualizerTargetModule->getCanvas()->setAnimationSpeed(linkVisualizations.empty() ? 0 : fadeOutAnimationSpeed, this);
70 }
virtual Coord getContactPosition(const cModule *networkNode, const Coord &fromPosition, const char *contactMode, double contactSpacing) const
Definition: VisualizerBase.cc:54
virtual Coord getPosition(const cModule *networkNode) const
Definition: VisualizerBase.cc:42
Coord getLineShift(int sourceModuleId, int destinationModuleId, const Coord &sourcePosition, const Coord &destinationPosition, const char *shiftMode, int shiftOffset)
Definition: LineManager.cc:108
cModule * visualizerTargetModule
Definition: VisualizerBase.h:31
cFigure::Point computeCanvasPoint(const Coord &point) const
Definition: CanvasProjection.cc:32
void inet::visualizer::LinkCanvasVisualizerBase::refreshLinkVisualization ( const LinkVisualization linkVisualization,
cPacket *  packet 
)
overrideprotectedvirtual

Reimplemented from inet::visualizer::LinkVisualizerBase.

113 {
114  LinkVisualizerBase::refreshLinkVisualization(linkVisualization, packet);
115  auto linkCanvasVisualization = static_cast<const LinkCanvasVisualization *>(linkVisualization);
116  auto text = getLinkVisualizationText(packet);
117  linkCanvasVisualization->figure->getLabelFigure()->setText(text.c_str());
118 }
void inet::visualizer::LinkCanvasVisualizerBase::removeLinkVisualization ( const LinkVisualization linkVisualization)
overrideprotectedvirtual

Reimplemented from inet::visualizer::LinkVisualizerBase.

98 {
100  auto linkCanvasVisualization = static_cast<const LinkCanvasVisualization *>(linkVisualization);
101  lineManager->removeModuleLine(linkVisualization);
102  linkGroup->removeFigure(linkCanvasVisualization->figure);
103 }
void removeModuleLine(const ModuleLine *moduleLine)
Definition: LineManager.cc:78
void inet::visualizer::LinkCanvasVisualizerBase::setAlpha ( const LinkVisualization linkVisualization,
double  alpha 
) const
overrideprotectedvirtual

Implements inet::visualizer::LinkVisualizerBase.

106 {
107  auto linkCanvasVisualization = static_cast<const LinkCanvasVisualization *>(linkVisualization);
108  auto figure = linkCanvasVisualization->figure;
109  figure->getLineFigure()->setLineOpacity(alpha);
110 }
const value< double, units::unit > alpha(7.2973525376e-3)

Member Data Documentation

const CanvasProjection* inet::visualizer::LinkCanvasVisualizerBase::canvasProjection = nullptr
protected

Referenced by initialize(), and refreshDisplay().

cGroupFigure* inet::visualizer::LinkCanvasVisualizerBase::linkGroup = nullptr
protected
double inet::visualizer::LinkCanvasVisualizerBase::zIndex = NaN
protected

Referenced by initialize().


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