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

#include <PacketDropCanvasVisualizer.h>

Inheritance diagram for inet::visualizer::PacketDropCanvasVisualizer:
inet::visualizer::PacketDropVisualizerBase inet::visualizer::VisualizerBase

Classes

class  PacketDropCanvasVisualization
 

Protected Member Functions

virtual void initialize (int stage) override
 
virtual void refreshDisplay () const override
 
virtual const PacketDropVisualizationcreatePacketDropVisualization (cModule *module, cPacket *packet) const override
 
virtual void addPacketDropVisualization (const PacketDropVisualization *packetDrop) override
 
virtual void removePacketDropVisualization (const PacketDropVisualization *packetDrop) override
 
virtual void setAlpha (const PacketDropVisualization *packetDrop, double alpha) const override
 
- Protected Member Functions inherited from inet::visualizer::PacketDropVisualizerBase
virtual void handleParameterChange (const char *name) override
 
virtual void subscribe ()
 
virtual void unsubscribe ()
 
virtual void removeAllPacketDropVisualizations ()
 
- 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 * packetDropGroup = nullptr
 
- Protected Attributes inherited from inet::visualizer::PacketDropVisualizerBase
std::vector< const PacketDropVisualization * > packetDropVisualizations
 
bool displayPacketDrops = false
 
NetworkNodeFilter nodeFilter
 
InterfaceFilter interfaceFilter
 
PacketFilter packetFilter
 
const char * icon = nullptr
 
cFigure::Color iconTintColor
 
double iconTintAmount = NaN
 
cFigure::Font labelFont
 
cFigure::Color labelColor
 
const char * fadeOutMode = nullptr
 
double fadeOutTime = NaN
 
double fadeOutAnimationSpeed = NaN
 
- Protected Attributes inherited from inet::visualizer::VisualizerBase
cModule * visualizerTargetModule = nullptr
 
const char * tags = nullptr
 

Additional Inherited Members

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

Member Function Documentation

void inet::visualizer::PacketDropCanvasVisualizer::addPacketDropVisualization ( const PacketDropVisualization packetDrop)
overrideprotectedvirtual

Reimplemented from inet::visualizer::PacketDropVisualizerBase.

76 {
78  auto packetDropCanvasVisualization = static_cast<const PacketDropCanvasVisualization *>(packetDrop);
79  packetDropGroup->addFigure(packetDropCanvasVisualization->figure);
80 }
cGroupFigure * packetDropGroup
Definition: PacketDropCanvasVisualizer.h:44
virtual void addPacketDropVisualization(const PacketDropVisualization *packetDropVisualization)
Definition: PacketDropVisualizerBase.cc:160
const PacketDropVisualizerBase::PacketDropVisualization * inet::visualizer::PacketDropCanvasVisualizer::createPacketDropVisualization ( cModule *  module,
cPacket *  packet 
) const
overrideprotectedvirtual

Implements inet::visualizer::PacketDropVisualizerBase.

54 {
55  std::string icon(this->icon);
56  auto position = getPosition(getContainingNode(module));
57  auto labeledIconFigure = new LabeledIconFigure("packetDrop");
58  labeledIconFigure->setTags((std::string("packet_drop ") + tags).c_str());
59  labeledIconFigure->setAssociatedObject(packet);
60  labeledIconFigure->setZIndex(zIndex);
61  labeledIconFigure->setPosition(canvasProjection->computeCanvasPoint(position));
62  auto iconFigure = labeledIconFigure->getIconFigure();
63  iconFigure->setTooltip("This icon represents a packet dropped in a network node");
64  iconFigure->setImageName(icon.substr(0, icon.find_first_of(".")).c_str());
65  iconFigure->setTintColor(iconTintColor);
66  iconFigure->setTintAmount(iconTintAmount);
67  auto labelFigure = labeledIconFigure->getLabelFigure();
68  labelFigure->setTooltip("This label represents the name of a packet dropped in a network node");
69  labelFigure->setFont(labelFont);
70  labelFigure->setColor(labelColor);
71  labelFigure->setText(packet->getName());
72  return new PacketDropCanvasVisualization(labeledIconFigure, module->getId(), packet, position);
73 }
const char * tags
Definition: VisualizerBase.h:32
double iconTintAmount
Definition: PacketDropVisualizerBase.h:56
double zIndex
Definition: PacketDropCanvasVisualizer.h:42
cFigure::Font labelFont
Definition: PacketDropVisualizerBase.h:57
const CanvasProjection * canvasProjection
Definition: PacketDropCanvasVisualizer.h:43
virtual Coord getPosition(const cModule *networkNode) const
Definition: VisualizerBase.cc:42
cFigure::Color iconTintColor
Definition: PacketDropVisualizerBase.h:55
const char * icon
Definition: PacketDropVisualizerBase.h:54
cModule * getContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:65
cFigure::Color labelColor
Definition: PacketDropVisualizerBase.h:58
cFigure::Point computeCanvasPoint(const Coord &point) const
Definition: CanvasProjection.cc:32
void inet::visualizer::PacketDropCanvasVisualizer::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::visualizer::PacketDropVisualizerBase.

34 {
36  if (!hasGUI()) return;
37  if (stage == INITSTAGE_LOCAL) {
38  zIndex = par("zIndex");
39  auto canvas = visualizerTargetModule->getCanvas();
41  packetDropGroup = new cGroupFigure("packet drops");
42  packetDropGroup->setZIndex(zIndex);
43  canvas->addFigure(packetDropGroup);
44  }
45 }
double zIndex
Definition: PacketDropCanvasVisualizer.h:42
virtual void initialize(int stage) override
Definition: PacketDropVisualizerBase.cc:52
const CanvasProjection * canvasProjection
Definition: PacketDropCanvasVisualizer.h:43
Local initializations.
Definition: InitStages.h:35
cGroupFigure * packetDropGroup
Definition: PacketDropCanvasVisualizer.h:44
cModule * visualizerTargetModule
Definition: VisualizerBase.h:31
static const CanvasProjection * getCanvasProjection(const cCanvas *canvas)
Definition: CanvasProjection.cc:38
void inet::visualizer::PacketDropCanvasVisualizer::refreshDisplay ( ) const
overrideprotectedvirtual

Reimplemented from inet::visualizer::PacketDropVisualizerBase.

48 {
50  visualizerTargetModule->getCanvas()->setAnimationSpeed(packetDropVisualizations.empty() ? 0 : fadeOutAnimationSpeed, this);
51 }
virtual void refreshDisplay() const override
Definition: PacketDropVisualizerBase.cc:88
std::vector< const PacketDropVisualization * > packetDropVisualizations
Definition: PacketDropVisualizerBase.h:64
cModule * visualizerTargetModule
Definition: VisualizerBase.h:31
double fadeOutAnimationSpeed
Definition: PacketDropVisualizerBase.h:61
void inet::visualizer::PacketDropCanvasVisualizer::removePacketDropVisualization ( const PacketDropVisualization packetDrop)
overrideprotectedvirtual

Reimplemented from inet::visualizer::PacketDropVisualizerBase.

83 {
85  auto packetDropCanvasVisualization = static_cast<const PacketDropCanvasVisualization *>(packetDrop);
86  packetDropGroup->removeFigure(packetDropCanvasVisualization->figure);
87 }
virtual void removePacketDropVisualization(const PacketDropVisualization *packetDropVisualization)
Definition: PacketDropVisualizerBase.cc:165
cGroupFigure * packetDropGroup
Definition: PacketDropCanvasVisualizer.h:44
void inet::visualizer::PacketDropCanvasVisualizer::setAlpha ( const PacketDropVisualization packetDrop,
double  alpha 
) const
overrideprotectedvirtual

Implements inet::visualizer::PacketDropVisualizerBase.

90 {
91  auto packetDropCanvasVisualization = static_cast<const PacketDropCanvasVisualization *>(packetDrop);
92  auto figure = packetDropCanvasVisualization->figure;
93  figure->setOpacity(alpha);
94  double dx = 10 / alpha;
95  double dy = pow((dx / 4 - 9), 2) - 58;
96  figure->setPosition(canvasProjection->computeCanvasPoint(packetDrop->position) + cFigure::Point(dx, dy));
97 }
const CanvasProjection * canvasProjection
Definition: PacketDropCanvasVisualizer.h:43
const value< double, units::unit > alpha(7.2973525376e-3)
cFigure::Point computeCanvasPoint(const Coord &point) const
Definition: CanvasProjection.cc:32

Member Data Documentation

const CanvasProjection* inet::visualizer::PacketDropCanvasVisualizer::canvasProjection = nullptr
protected
cGroupFigure* inet::visualizer::PacketDropCanvasVisualizer::packetDropGroup = nullptr
protected
double inet::visualizer::PacketDropCanvasVisualizer::zIndex = NaN
protected

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