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

#include <TransportConnectionCanvasVisualizer.h>

Inheritance diagram for inet::visualizer::TransportConnectionCanvasVisualizer:
inet::visualizer::TransportConnectionVisualizerBase inet::visualizer::VisualizerBase

Classes

class  TransportConnectionCanvasVisualization
 

Protected Member Functions

virtual void initialize (int stage) override
 
virtual LabeledIconFigurecreateConnectionEndFigure (tcp::TCPConnection *connectionVisualization) const
 
virtual const TransportConnectionVisualizationcreateConnectionVisualization (cModule *source, cModule *destination, tcp::TCPConnection *tcpConnection) const override
 
virtual void addConnectionVisualization (const TransportConnectionVisualization *connectionVisualization) override
 
virtual void removeConnectionVisualization (const TransportConnectionVisualization *connectionVisualization) override
 
virtual void setConnectionLabelsVisible (bool visible)
 
- Protected Member Functions inherited from inet::visualizer::TransportConnectionVisualizerBase
virtual void handleParameterChange (const char *name) override
 
virtual void subscribe ()
 
virtual void unsubscribe ()
 
virtual void removeAllConnectionVisualizations ()
 
- 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
 
NetworkNodeCanvasVisualizernetworkNodeVisualizer = nullptr
 
- Protected Attributes inherited from inet::visualizer::TransportConnectionVisualizerBase
std::vector< const TransportConnectionVisualization * > connectionVisualizations
 
bool displayTransportConnections = false
 
NetworkNodeFilter sourceNodeFilter
 
PortFilter sourcePortFilter
 
NetworkNodeFilter destinationNodeFilter
 
PortFilter destinationPortFilter
 
const char * icon = nullptr
 
ColorSet iconColorSet
 
cFigure::Font labelFont
 
cFigure::Color labelColor
 
Displacement displacementHint
 
double displacementPriority
 
- Protected Attributes inherited from inet::visualizer::VisualizerBase
cModule * visualizerTargetModule = nullptr
 
const char * tags = nullptr
 

Additional Inherited Members

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

Member Function Documentation

void inet::visualizer::TransportConnectionCanvasVisualizer::addConnectionVisualization ( const TransportConnectionVisualization connectionVisualization)
overrideprotectedvirtual

Reimplemented from inet::visualizer::TransportConnectionVisualizerBase.

83 {
85  auto connectionCanvasVisualization = static_cast<const TransportConnectionCanvasVisualization *>(connectionVisualization);
86  auto sourceModule = getSimulation()->getModule(connectionVisualization->sourceModuleId);
87  auto sourceVisualization = networkNodeVisualizer->getNetworkNodeVisualization(getContainingNode(sourceModule));
88  sourceVisualization->addAnnotation(connectionCanvasVisualization->sourceFigure, connectionCanvasVisualization->sourceFigure->getBounds().getSize(), displacementHint, displacementPriority);
89  auto destinationModule = getSimulation()->getModule(connectionVisualization->destinationModuleId);
90  auto destinationVisualization = networkNodeVisualizer->getNetworkNodeVisualization(getContainingNode(destinationModule));
91  destinationVisualization->addAnnotation(connectionCanvasVisualization->destinationFigure, connectionCanvasVisualization->destinationFigure->getBounds().getSize(), displacementHint, displacementPriority);
93 }
ColorSet iconColorSet
Definition: TransportConnectionVisualizerBase.h:60
virtual void addAnnotation(cFigure *figure, cFigure::Point size, Displacement displacement=DISPLACEMENT_ANY, double displacementPriority=0)
Definition: NetworkNodeCanvasVisualization.cc:62
Displacement displacementHint
Definition: TransportConnectionVisualizerBase.h:63
virtual NetworkNodeCanvasVisualization * getNetworkNodeVisualization(const cModule *networkNode) const
Definition: NetworkNodeCanvasVisualizer.cc:63
int getSize() const
Definition: ColorSet.h:34
std::vector< const TransportConnectionVisualization * > connectionVisualizations
Definition: TransportConnectionVisualizerBase.h:67
cModule * getContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:65
double displacementPriority
Definition: TransportConnectionVisualizerBase.h:64
virtual void addConnectionVisualization(const TransportConnectionVisualization *connectionVisualization)
Definition: TransportConnectionVisualizerBase.cc:97
NetworkNodeCanvasVisualizer * networkNodeVisualizer
Definition: TransportConnectionCanvasVisualizer.h:45
virtual void setConnectionLabelsVisible(bool visible)
Definition: TransportConnectionCanvasVisualizer.cc:108
LabeledIconFigure * inet::visualizer::TransportConnectionCanvasVisualizer::createConnectionEndFigure ( tcp::TCPConnection connectionVisualization) const
protectedvirtual

Referenced by createConnectionVisualization().

47 {
48 #ifdef WITH_TCP_INET
49  std::string icon(this->icon);
50  auto labeledIconFigure = new LabeledIconFigure("transportConnection");
51  labeledIconFigure->setTags((std::string("transport_connection ") + tags).c_str());
52  labeledIconFigure->setTooltip("This icon represents a transport connection between two network nodes");
53  labeledIconFigure->setAssociatedObject(tcpConnection);
54  labeledIconFigure->setZIndex(zIndex);
55  auto iconFigure = labeledIconFigure->getIconFigure();
56  iconFigure->setTooltip("This icon represents a transport connection between two network nodes");
57  iconFigure->setImageName(icon.substr(0, icon.find_first_of(".")).c_str());
58  iconFigure->setTintColor(iconColorSet.getColor(connectionVisualizations.size()));
59  iconFigure->setTintAmount(1);
60  auto labelFigure = labeledIconFigure->getLabelFigure();
61  labelFigure->setTooltip("This label represents a transport connection between two network nodes");
62  labelFigure->setPosition(iconFigure->getBounds().getSize() / 2);
63  labelFigure->setFont(labelFont);
64  labelFigure->setColor(labelColor);
65  char label[2];
66  label[0] = 'A' + (char)(connectionVisualizations.size() / iconColorSet.getSize());
67  label[1] = '\0';
68  labelFigure->setText(label);
69  return labeledIconFigure;
70 #else
71  return nullptr;
72 #endif // WITH_TCP_INET
73 }
ColorSet iconColorSet
Definition: TransportConnectionVisualizerBase.h:60
const char * tags
Definition: VisualizerBase.h:32
cFigure::Font labelFont
Definition: TransportConnectionVisualizerBase.h:61
int getSize() const
Definition: ColorSet.h:34
std::vector< const TransportConnectionVisualization * > connectionVisualizations
Definition: TransportConnectionVisualizerBase.h:67
cFigure::Color labelColor
Definition: TransportConnectionVisualizerBase.h:62
const char * icon
Definition: TransportConnectionVisualizerBase.h:59
double zIndex
Definition: TransportConnectionCanvasVisualizer.h:43
cFigure::Color getColor(int index) const
Definition: ColorSet.cc:43
const TransportConnectionVisualizerBase::TransportConnectionVisualization * inet::visualizer::TransportConnectionCanvasVisualizer::createConnectionVisualization ( cModule *  source,
cModule *  destination,
tcp::TCPConnection tcpConnection 
) const
overrideprotectedvirtual

Implements inet::visualizer::TransportConnectionVisualizerBase.

76 {
77  auto sourceFigure = createConnectionEndFigure(tcpConnection);
78  auto destinationFigure = createConnectionEndFigure(tcpConnection);
79  return new TransportConnectionCanvasVisualization(sourceFigure, destinationFigure, source->getId(), destination->getId(), 1);
80 }
virtual LabeledIconFigure * createConnectionEndFigure(tcp::TCPConnection *connectionVisualization) const
Definition: TransportConnectionCanvasVisualizer.cc:46
void inet::visualizer::TransportConnectionCanvasVisualizer::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::visualizer::TransportConnectionVisualizerBase.

35 {
37  if (!hasGUI()) return;
38  if (stage == INITSTAGE_LOCAL) {
39  zIndex = par("zIndex");
40  auto canvas = visualizerTargetModule->getCanvas();
42  networkNodeVisualizer = getModuleFromPar<NetworkNodeCanvasVisualizer>(par("networkNodeVisualizerModule"), this);
43  }
44 }
const CanvasProjection * canvasProjection
Definition: TransportConnectionCanvasVisualizer.h:44
virtual void initialize(int stage) override
Definition: TransportConnectionVisualizerBase.cc:43
Local initializations.
Definition: InitStages.h:35
NetworkNodeCanvasVisualizer * networkNodeVisualizer
Definition: TransportConnectionCanvasVisualizer.h:45
cModule * visualizerTargetModule
Definition: VisualizerBase.h:31
double zIndex
Definition: TransportConnectionCanvasVisualizer.h:43
static const CanvasProjection * getCanvasProjection(const cCanvas *canvas)
Definition: CanvasProjection.cc:38
void inet::visualizer::TransportConnectionCanvasVisualizer::removeConnectionVisualization ( const TransportConnectionVisualization connectionVisualization)
overrideprotectedvirtual

Reimplemented from inet::visualizer::TransportConnectionVisualizerBase.

96 {
98  auto connectionCanvasVisualization = static_cast<const TransportConnectionCanvasVisualization *>(connectionVisualization);
99  auto sourceModule = getSimulation()->getModule(connectionVisualization->sourceModuleId);
100  auto sourceVisualization = networkNodeVisualizer->getNetworkNodeVisualization(getContainingNode(sourceModule));
101  sourceVisualization->removeAnnotation(connectionCanvasVisualization->sourceFigure);
102  auto destinationModule = getSimulation()->getModule(connectionVisualization->destinationModuleId);
103  auto destinationVisualization = networkNodeVisualizer->getNetworkNodeVisualization(getContainingNode(destinationModule));
104  destinationVisualization->removeAnnotation(connectionCanvasVisualization->destinationFigure);
106 }
ColorSet iconColorSet
Definition: TransportConnectionVisualizerBase.h:60
virtual NetworkNodeCanvasVisualization * getNetworkNodeVisualization(const cModule *networkNode) const
Definition: NetworkNodeCanvasVisualizer.cc:63
virtual void removeConnectionVisualization(const TransportConnectionVisualization *connectionVisualization)
Definition: TransportConnectionVisualizerBase.cc:102
int getSize() const
Definition: ColorSet.h:34
std::vector< const TransportConnectionVisualization * > connectionVisualizations
Definition: TransportConnectionVisualizerBase.h:67
cModule * getContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:65
virtual void removeAnnotation(cFigure *figure)
Definition: NetworkNodeCanvasVisualization.cc:69
NetworkNodeCanvasVisualizer * networkNodeVisualizer
Definition: TransportConnectionCanvasVisualizer.h:45
virtual void setConnectionLabelsVisible(bool visible)
Definition: TransportConnectionCanvasVisualizer.cc:108
void inet::visualizer::TransportConnectionCanvasVisualizer::setConnectionLabelsVisible ( bool  visible)
protectedvirtual

Referenced by addConnectionVisualization(), and removeConnectionVisualization().

109 {
110  for (auto connectionVisualization : connectionVisualizations) {
111  auto connectionCanvasVisualization = static_cast<const TransportConnectionCanvasVisualization *>(connectionVisualization);
112  connectionCanvasVisualization->sourceFigure->getLabelFigure()->setVisible(visible);
113  connectionCanvasVisualization->destinationFigure->getLabelFigure()->setVisible(visible);
114  }
115 }
std::vector< const TransportConnectionVisualization * > connectionVisualizations
Definition: TransportConnectionVisualizerBase.h:67

Member Data Documentation

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

Referenced by initialize().

NetworkNodeCanvasVisualizer* inet::visualizer::TransportConnectionCanvasVisualizer::networkNodeVisualizer = nullptr
protected
double inet::visualizer::TransportConnectionCanvasVisualizer::zIndex = NaN
protected

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