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

#include <RadioCanvasVisualizer.h>

Inheritance diagram for inet::visualizer::RadioCanvasVisualizer:
inet::visualizer::RadioVisualizerBase inet::visualizer::VisualizerBase

Classes

class  RadioCanvasVisualization
 

Protected Member Functions

virtual void initialize (int stage) override
 
virtual RadioVisualizationcreateRadioVisualization (const IRadio *radio) const override
 
virtual void addRadioVisualization (const RadioVisualization *radioVisualization) override
 
virtual void removeRadioVisualization (const RadioVisualization *radioVisualization) override
 
virtual void refreshRadioVisualization (const RadioVisualization *radioVisualization) const override
 
virtual void setImageIndex (IndexedImageFigure *indexedImageFigure, int index) const
 
- Protected Member Functions inherited from inet::visualizer::RadioVisualizerBase
virtual void handleParameterChange (const char *name) override
 
virtual void refreshDisplay () const override
 
virtual void subscribe ()
 
virtual void unsubscribe ()
 
virtual const RadioVisualizationgetRadioVisualization (int radioModuleId)
 
- 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
 
NetworkNodeCanvasVisualizernetworkNodeVisualizer = nullptr
 
- Protected Attributes inherited from inet::visualizer::RadioVisualizerBase
std::map< int, const RadioVisualization * > radioVisualizations
 
bool displayRadios = false
 
bool displayRadioMode = false
 
bool displayReceptionState = false
 
bool displayTransmissionState = false
 
std::vector< std::string > radioModeImages
 
std::vector< std::string > receptionStateImages
 
std::vector< std::string > transmissionStateImages
 
ModuleFilter radioFilter
 
double width
 
double height
 
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::RadioVisualizerBase
virtual ~RadioVisualizerBase ()
 
virtual void receiveSignal (cComponent *source, simsignal_t signal, long value, cObject *details) override
 

Member Function Documentation

void inet::visualizer::RadioCanvasVisualizer::addRadioVisualization ( const RadioVisualization radioVisualization)
overrideprotectedvirtual

Reimplemented from inet::visualizer::RadioVisualizerBase.

77 {
79  auto radioCanvasVisualization = static_cast<const RadioCanvasVisualization *>(radioVisualization);
80  radioCanvasVisualization->networkNodeVisualization->addAnnotation(radioCanvasVisualization->radioModeFigure, radioCanvasVisualization->radioModeFigure->getSize(), displacementHint, displacementPriority);
81  radioCanvasVisualization->networkNodeVisualization->addAnnotation(radioCanvasVisualization->receptionStateFigure, radioCanvasVisualization->receptionStateFigure->getSize(), displacementHint, displacementPriority);
82  radioCanvasVisualization->networkNodeVisualization->addAnnotation(radioCanvasVisualization->transmissionStateFigure, radioCanvasVisualization->transmissionStateFigure->getSize(), displacementHint, displacementPriority);
83 }
double displacementPriority
Definition: RadioVisualizerBase.h:59
Displacement displacementHint
Definition: RadioVisualizerBase.h:58
virtual void addRadioVisualization(const RadioVisualization *radioVisualization)
Definition: RadioVisualizerBase.cc:106
RadioVisualizerBase::RadioVisualization * inet::visualizer::RadioCanvasVisualizer::createRadioVisualization ( const IRadio radio) const
overrideprotectedvirtual

Implements inet::visualizer::RadioVisualizerBase.

52 {
53  auto module = check_and_cast<const cModule *>(radio);
54  // TODO: use RadioFigure?
55  auto radioModeFigure = new IndexedImageFigure("radioMode");
56  radioModeFigure->setTags((std::string("radioMode ") + tags).c_str());
57  radioModeFigure->setTooltip("This figure represents the radio mode of a radio");
58  radioModeFigure->setAssociatedObject(const_cast<cModule *>(module));
59  radioModeFigure->setImages(radioModeImages);
60  radioModeFigure->setSize(cFigure::Point(width, height));
61  auto receptionStateFigure = new IndexedImageFigure("receptionState");
62  receptionStateFigure->setTags((std::string("receptionState ") + tags).c_str());
63  receptionStateFigure->setTooltip("This figure represents the reception state of a radio");
64  receptionStateFigure->setImages(receptionStateImages);
65  receptionStateFigure->setSize(cFigure::Point(width, height));
66  auto transmissionStateFigure = new IndexedImageFigure("transmissionState");
67  transmissionStateFigure->setTags((std::string("transmissionState ") + tags).c_str());
68  transmissionStateFigure->setTooltip("This figure represents the transmission state of a radio");
69  transmissionStateFigure->setImages(transmissionStateImages);
70  transmissionStateFigure->setSize(cFigure::Point(width, height));
71  auto networkNode = getContainingNode(module);
72  auto networkNodeVisualization = networkNodeVisualizer->getNetworkNodeVisualization(networkNode);
73  return new RadioCanvasVisualization(networkNodeVisualization, radioModeFigure, receptionStateFigure, transmissionStateFigure, module->getId());
74 }
const char * tags
Definition: VisualizerBase.h:32
std::vector< std::string > transmissionStateImages
Definition: RadioVisualizerBase.h:54
std::vector< std::string > receptionStateImages
Definition: RadioVisualizerBase.h:53
virtual NetworkNodeCanvasVisualization * getNetworkNodeVisualization(const cModule *networkNode) const
Definition: NetworkNodeCanvasVisualizer.cc:63
cModule * getContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:65
double width
Definition: RadioVisualizerBase.h:56
std::vector< std::string > radioModeImages
Definition: RadioVisualizerBase.h:52
double height
Definition: RadioVisualizerBase.h:57
NetworkNodeCanvasVisualizer * networkNodeVisualizer
Definition: RadioCanvasVisualizer.h:47
Definition: IndexedImageFigure.h:28
void inet::visualizer::RadioCanvasVisualizer::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::visualizer::RadioVisualizerBase.

42 {
44  if (!hasGUI()) return;
45  if (stage == INITSTAGE_LOCAL) {
46  zIndex = par("zIndex");
47  networkNodeVisualizer = getModuleFromPar<NetworkNodeCanvasVisualizer>(par("networkNodeVisualizerModule"), this);
48  }
49 }
Local initializations.
Definition: InitStages.h:35
virtual void initialize(int stage) override
Definition: RadioVisualizerBase.cc:36
NetworkNodeCanvasVisualizer * networkNodeVisualizer
Definition: RadioCanvasVisualizer.h:47
double zIndex
Definition: RadioCanvasVisualizer.h:46
void inet::visualizer::RadioCanvasVisualizer::refreshRadioVisualization ( const RadioVisualization radioVisualization) const
overrideprotectedvirtual

Implements inet::visualizer::RadioVisualizerBase.

95 {
96  auto radioCanvasVisualization = static_cast<const RadioCanvasVisualization *>(radioVisualization);
97  auto module = getSimulation()->getComponent(radioCanvasVisualization->radioModuleId);
98  if (module != nullptr) {
99  auto radio = check_and_cast<IRadio *>(module);
100  setImageIndex(radioCanvasVisualization->radioModeFigure, radio->getRadioMode());
101  setImageIndex(radioCanvasVisualization->receptionStateFigure, radio->getReceptionState());
102  setImageIndex(radioCanvasVisualization->transmissionStateFigure, radio->getTransmissionState());
103  radioCanvasVisualization->receptionStateFigure->setAssociatedObject(const_cast<cObject *>(dynamic_cast<const cObject *>(radio->getReceptionInProgress())));
104  radioCanvasVisualization->transmissionStateFigure->setAssociatedObject(const_cast<cObject *>(dynamic_cast<const cObject *>(radio->getTransmissionInProgress())));
105  }
106 }
virtual void setImageIndex(IndexedImageFigure *indexedImageFigure, int index) const
Definition: RadioCanvasVisualizer.cc:108
This interface represents a physical device that is capable of transmitting and receiving radio signa...
Definition: IRadio.h:44
void inet::visualizer::RadioCanvasVisualizer::removeRadioVisualization ( const RadioVisualization radioVisualization)
overrideprotectedvirtual

Reimplemented from inet::visualizer::RadioVisualizerBase.

86 {
88  auto radioCanvasVisualization = static_cast<const RadioCanvasVisualization *>(radioVisualization);
89  radioCanvasVisualization->networkNodeVisualization->removeAnnotation(radioCanvasVisualization->radioModeFigure);
90  radioCanvasVisualization->networkNodeVisualization->removeAnnotation(radioCanvasVisualization->receptionStateFigure);
91  radioCanvasVisualization->networkNodeVisualization->removeAnnotation(radioCanvasVisualization->transmissionStateFigure);
92 }
virtual void removeRadioVisualization(const RadioVisualization *radioVisualization)
Definition: RadioVisualizerBase.cc:111
void inet::visualizer::RadioCanvasVisualizer::setImageIndex ( IndexedImageFigure indexedImageFigure,
int  index 
) const
protectedvirtual

Referenced by refreshRadioVisualization().

109 {
110  indexedImageFigure->setValue(0, simTime(), index);
111  indexedImageFigure->setVisible(indexedImageFigure->getImages()[index] != "-");
112 }
const std::vector< std::string > & getImages() const
Definition: IndexedImageFigure.cc:47
virtual void setValue(int series, simtime_t timestamp, double value) override
Definition: IndexedImageFigure.cc:248

Member Data Documentation

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

Referenced by initialize().


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