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

#include <RoutingTableCanvasVisualizer.h>

Inheritance diagram for inet::visualizer::RoutingTableCanvasVisualizer:
inet::visualizer::RoutingTableVisualizerBase inet::visualizer::VisualizerBase

Classes

class  RouteCanvasVisualization
 

Protected Member Functions

virtual void initialize (int stage) override
 
virtual void refreshDisplay () const override
 
virtual const RouteVisualizationcreateRouteVisualization (IPv4Route *route, cModule *node, cModule *nextHop) const override
 
virtual void addRouteVisualization (const RouteVisualization *routeVisualization) override
 
virtual void removeRouteVisualization (const RouteVisualization *routeVisualization) override
 
virtual void refreshRouteVisualization (const RouteVisualization *routeVisualization) const override
 
- Protected Member Functions inherited from inet::visualizer::RoutingTableVisualizerBase
virtual void handleParameterChange (const char *name) override
 
virtual void subscribe ()
 
virtual void unsubscribe ()
 
virtual const RouteVisualizationgetRouteVisualization (IPv4Route *route, int nodeModuleId, int nextHopModuleId)
 
virtual std::vector< IPv4AddressgetDestinations ()
 
virtual void addRouteVisualizations (IIPv4RoutingTable *routingTable)
 
virtual void removeRouteVisualizations (IIPv4RoutingTable *routingTable)
 
virtual void removeAllRouteVisualizations ()
 
virtual void updateRouteVisualizations (IIPv4RoutingTable *routingTable)
 
virtual void updateAllRouteVisualizations ()
 
virtual std::string getRouteVisualizationText (const IPv4Route *route) 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

double zIndex = NaN
 
const CanvasProjectioncanvasProjection = nullptr
 
cGroupFigure * routeGroup = nullptr
 
- Protected Attributes inherited from inet::visualizer::RoutingTableVisualizerBase
LineManagerlineManager = nullptr
 
std::map< std::tuple< const IPv4Route *, int, int >, const RouteVisualization * > routeVisualizations
 
bool displayRoutingTables = false
 
bool displayRoutesIndividually = false
 
bool displayLabels = false
 
NetworkNodeFilter destinationFilter
 
NetworkNodeFilter nodeFilter
 
cFigure::Color lineColor
 
cFigure::LineStyle lineStyle
 
double lineShift = NaN
 
const char * lineShiftMode = nullptr
 
double lineWidth = NaN
 
double lineContactSpacing = NaN
 
const char * lineContactMode = nullptr
 
StringFormat labelFormat
 
cFigure::Font labelFont
 
cFigure::Color labelColor
 
- Protected Attributes inherited from inet::visualizer::VisualizerBase
cModule * visualizerTargetModule = nullptr
 
const char * tags = nullptr
 

Additional Inherited Members

- Public Member Functions inherited from inet::visualizer::RoutingTableVisualizerBase
virtual ~RoutingTableVisualizerBase ()
 
virtual void receiveSignal (cComponent *source, simsignal_t signal, cObject *obj, cObject *details) override
 

Member Function Documentation

void inet::visualizer::RoutingTableCanvasVisualizer::addRouteVisualization ( const RouteVisualization routeVisualization)
overrideprotectedvirtual

Reimplemented from inet::visualizer::RoutingTableVisualizerBase.

90 {
92  auto routeCanvasVisualization = static_cast<const RouteCanvasVisualization *>(routeVisualization);
93  lineManager->addModuleLine(routeVisualization);
94  routeGroup->addFigure(routeCanvasVisualization->figure);
95 }
virtual void addRouteVisualization(const RouteVisualization *routeVisualization)
Definition: RoutingTableVisualizerBase.cc:150
LineManager * lineManager
Definition: RoutingTableVisualizerBase.h:77
void addModuleLine(const ModuleLine *moduleLine)
Definition: LineManager.cc:70
cGroupFigure * routeGroup
Definition: RoutingTableCanvasVisualizer.h:44
const RoutingTableVisualizerBase::RouteVisualization * inet::visualizer::RoutingTableCanvasVisualizer::createRouteVisualization ( IPv4Route route,
cModule *  node,
cModule *  nextHop 
) const
overrideprotectedvirtual

Implements inet::visualizer::RoutingTableVisualizerBase.

69 {
70  auto figure = new LabeledLineFigure("routing entry");
71  figure->setTags((std::string("route ") + tags).c_str());
72  figure->setTooltip("This arrow represents a route in a routing table");
73  figure->setAssociatedObject(route);
74  auto lineFigure = figure->getLineFigure();
75  lineFigure->setEndArrowhead(cFigure::ARROW_TRIANGLE);
76  lineFigure->setLineWidth(lineWidth);
77  lineFigure->setLineColor(lineColor);
78  lineFigure->setLineStyle(lineStyle);
79  auto labelFigure = figure->getLabelFigure();
80  labelFigure->setFont(labelFont);
81  labelFigure->setColor(labelColor);
82  labelFigure->setVisible(displayLabels);
83  auto routeVisualization = new RouteCanvasVisualization(figure, route, node->getId(), nextHop->getId());
84  routeVisualization->shiftPriority = 0.5;
85  refreshRouteVisualization(routeVisualization);
86  return routeVisualization;
87 }
virtual void refreshRouteVisualization(const RouteVisualization *routeVisualization) const override
Definition: RoutingTableCanvasVisualizer.cc:105
cFigure::LineStyle lineStyle
Definition: RoutingTableVisualizerBase.h:66
const char * tags
Definition: VisualizerBase.h:32
cFigure::Font labelFont
Definition: RoutingTableVisualizerBase.h:73
cFigure::Color lineColor
Definition: RoutingTableVisualizerBase.h:65
bool displayLabels
Definition: RoutingTableVisualizerBase.h:62
cFigure::Color labelColor
Definition: RoutingTableVisualizerBase.h:74
double lineWidth
Definition: RoutingTableVisualizerBase.h:69
void inet::visualizer::RoutingTableCanvasVisualizer::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::visualizer::RoutingTableVisualizerBase.

38 {
40  if (!hasGUI()) return;
41  if (stage == INITSTAGE_LOCAL) {
42  zIndex = par("zIndex");
43  auto canvas = visualizerTargetModule->getCanvas();
45  routeGroup = new cGroupFigure("routing tables");
46  routeGroup->setZIndex(zIndex);
47  canvas->addFigure(routeGroup);
48  }
49 }
virtual void initialize(int stage) override
Definition: RoutingTableVisualizerBase.cc:68
Local initializations.
Definition: InitStages.h:35
const CanvasProjection * canvasProjection
Definition: RoutingTableCanvasVisualizer.h:43
cModule * visualizerTargetModule
Definition: VisualizerBase.h:31
cGroupFigure * routeGroup
Definition: RoutingTableCanvasVisualizer.h:44
double zIndex
Definition: RoutingTableCanvasVisualizer.h:42
static const CanvasProjection * getCanvasProjection(const cCanvas *canvas)
Definition: CanvasProjection.cc:38
void inet::visualizer::RoutingTableCanvasVisualizer::refreshDisplay ( ) const
overrideprotectedvirtual
52 {
53  auto simulation = getSimulation();
54  for (auto it : routeVisualizations) {
55  auto routeVisualization = it.second;
56  auto routeCanvasVisualization = static_cast<const RouteCanvasVisualization *>(routeVisualization);
57  auto figure = routeCanvasVisualization->figure;
58  auto sourceModule = simulation->getModule(routeVisualization->sourceModuleId);
59  auto destinationModule = simulation->getModule(routeVisualization->destinationModuleId);
60  auto sourcePosition = getContactPosition(sourceModule, getPosition(destinationModule), lineContactMode, lineContactSpacing);
61  auto destinationPosition = getContactPosition(destinationModule, getPosition(sourceModule), lineContactMode, lineContactSpacing);
62  auto shift = lineManager->getLineShift(routeVisualization->sourceModuleId, routeVisualization->destinationModuleId, sourcePosition, destinationPosition, lineShiftMode, routeVisualization->shiftOffset) * lineShift;
63  figure->setStart(canvasProjection->computeCanvasPoint(sourcePosition + shift));
64  figure->setEnd(canvasProjection->computeCanvasPoint(destinationPosition + shift));
65  }
66 }
std::map< std::tuple< const IPv4Route *, int, int >, const RouteVisualization * > routeVisualizations
Definition: RoutingTableVisualizerBase.h:79
const char * lineContactMode
Definition: RoutingTableVisualizerBase.h:71
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
double lineShift
Definition: RoutingTableVisualizerBase.h:67
Coord getLineShift(int sourceModuleId, int destinationModuleId, const Coord &sourcePosition, const Coord &destinationPosition, const char *shiftMode, int shiftOffset)
Definition: LineManager.cc:108
LineManager * lineManager
Definition: RoutingTableVisualizerBase.h:77
const CanvasProjection * canvasProjection
Definition: RoutingTableCanvasVisualizer.h:43
const char * lineShiftMode
Definition: RoutingTableVisualizerBase.h:68
cFigure::Point computeCanvasPoint(const Coord &point) const
Definition: CanvasProjection.cc:32
double lineContactSpacing
Definition: RoutingTableVisualizerBase.h:70
void inet::visualizer::RoutingTableCanvasVisualizer::refreshRouteVisualization ( const RouteVisualization routeVisualization) const
overrideprotectedvirtual

Implements inet::visualizer::RoutingTableVisualizerBase.

Referenced by createRouteVisualization().

106 {
107  auto routeCanvasVisualization = static_cast<const RouteCanvasVisualization *>(routeVisualization);
108  auto labelFigure = routeCanvasVisualization->figure->getLabelFigure();
109  auto text = displayRoutesIndividually ? getRouteVisualizationText(routeCanvasVisualization->route) : std::to_string(routeVisualization->numRoutes) + (routeVisualization->numRoutes > 1 ? " routes" : " route");
110  labelFigure->setText(text.c_str());
111 }
virtual std::string getRouteVisualizationText(const IPv4Route *route) const
Definition: RoutingTableVisualizerBase.cc:251
bool displayRoutesIndividually
Definition: RoutingTableVisualizerBase.h:61
void inet::visualizer::RoutingTableCanvasVisualizer::removeRouteVisualization ( const RouteVisualization routeVisualization)
overrideprotectedvirtual

Reimplemented from inet::visualizer::RoutingTableVisualizerBase.

98 {
100  auto routeCanvasVisualization = static_cast<const RouteCanvasVisualization *>(routeVisualization);
101  lineManager->removeModuleLine(routeVisualization);
102  routeGroup->removeFigure(routeCanvasVisualization->figure);
103 }
void removeModuleLine(const ModuleLine *moduleLine)
Definition: LineManager.cc:78
virtual void removeRouteVisualization(const RouteVisualization *routeVisualization)
Definition: RoutingTableVisualizerBase.cc:156
LineManager * lineManager
Definition: RoutingTableVisualizerBase.h:77
cGroupFigure * routeGroup
Definition: RoutingTableCanvasVisualizer.h:44

Member Data Documentation

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

Referenced by initialize(), and refreshDisplay().

cGroupFigure* inet::visualizer::RoutingTableCanvasVisualizer::routeGroup = nullptr
protected
double inet::visualizer::RoutingTableCanvasVisualizer::zIndex = NaN
protected

Referenced by initialize().


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