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

#include <MediumCanvasVisualizer.h>

Inheritance diagram for inet::visualizer::MediumCanvasVisualizer:
inet::visualizer::MediumVisualizerBase inet::visualizer::VisualizerBase

Protected Member Functions

virtual void initialize (int stage) override
 
virtual void refreshDisplay () const override
 
virtual void setAnimationSpeed ()
 
virtual cFigure * getTransmissionFigure (const IRadio *radio) const
 
virtual void setTransmissionFigure (const IRadio *radio, cFigure *figure)
 
virtual cFigure * removeTransmissionFigure (const IRadio *radio)
 
virtual cFigure * getReceptionFigure (const IRadio *radio) const
 
virtual void setReceptionFigure (const IRadio *radio, cFigure *figure)
 
virtual cFigure * removeReceptionFigure (const IRadio *radio)
 
virtual cFigure * getSignalFigure (const ITransmission *transmission) const
 
virtual void setSignalFigure (const ITransmission *transmission, cFigure *figure)
 
virtual cFigure * removeSignalFigure (const ITransmission *transmission)
 
virtual cGroupFigure * createSignalFigure (const ITransmission *transmission) const
 
virtual void refreshSignalFigure (const ITransmission *transmission) const
 
virtual void radioAdded (const IRadio *radio) override
 
virtual void radioRemoved (const IRadio *radio) override
 
virtual void transmissionAdded (const ITransmission *transmission) override
 
virtual void transmissionRemoved (const ITransmission *transmission) override
 
virtual void transmissionStarted (const ITransmission *transmission) override
 
virtual void transmissionEnded (const ITransmission *transmission) override
 
virtual void receptionStarted (const IReception *reception) override
 
virtual void receptionEnded (const IReception *reception) override
 
- Protected Member Functions inherited from inet::visualizer::MediumVisualizerBase
virtual void handleParameterChange (const char *name) override
 
virtual bool isSignalPropagationInProgress (const ITransmission *transmission) const
 
virtual bool isSignalTransmissionInProgress (const ITransmission *transmission) const
 
virtual bool matchesTransmission (const ITransmission *transmission) 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

Parameters
double zIndex = NaN
 
const CanvasProjectioncanvasProjection = nullptr
 
SignalShape signalShape = SIGNAL_SHAPE_RING
 
double signalOpacity = NaN
 
int signalRingCount = -1
 
double signalRingSize = NaN
 
double signalFadingDistance = NaN
 
double signalFadingFactor = NaN
 
int signalWaveCount = -1
 
double signalWaveLength = NaN
 
double signalWaveWidth = NaN
 
double signalWaveFadingAnimationSpeedFactor = NaN
 
bool displayCommunicationHeat = false
 
int communicationHeatMapSize = 100
 
Figures
cGroupFigure * signalLayer = nullptr
 The layer figure that contains the figures representing the ongoing communications. More...
 
HeatMapFigurecommunicationHeat = nullptr
 The heat map figure that shows the recent successful communications. More...
 
- Protected Attributes inherited from inet::visualizer::MediumVisualizerBase
IRadioMediumradioMedium = nullptr
 
NetworkNodeFilter networkNodeFilter
 
InterfaceFilter interfaceFilter
 
PacketFilter packetFilter
 
bool displaySignals = false
 
ColorSet signalColorSet
 
double signalPropagationAnimationSpeed = NaN
 
double signalPropagationAnimationTime = NaN
 
double signalPropagationAdditionalTime = NaN
 
double signalTransmissionAnimationSpeed = NaN
 
double signalTransmissionAnimationTime = NaN
 
double signalAnimationSpeedChangeTime = NaN
 
bool displayTransmissions = false
 
bool displayReceptions = false
 
Displacement transmissionDisplacementHint
 
Displacement receptionDisplacementHint
 
double transmissionDisplacementPriority
 
double receptionDisplacementPriority
 
bool displayInterferenceRanges = false
 
cFigure::Color interferenceRangeLineColor
 
cFigure::LineStyle interferenceRangeLineStyle
 
double interferenceRangeLineWidth = NaN
 
bool displayCommunicationRanges = false
 
cFigure::Color communicationRangeLineColor
 
cFigure::LineStyle communicationRangeLineStyle
 
double communicationRangeLineWidth = NaN
 
double defaultSignalPropagationAnimationSpeed = NaN
 
double defaultSignalTransmissionAnimationSpeed = NaN
 
- Protected Attributes inherited from inet::visualizer::VisualizerBase
cModule * visualizerTargetModule = nullptr
 
const char * tags = nullptr
 

Internal state

enum  SignalInProgress { SIP_NONE, SIP_PROPAGATION, SIP_TRANSMISSION }
 
SignalInProgress lastSignalInProgress = SIP_NONE
 
AnimationSpeedInterpolator animationSpeedInterpolator
 
NetworkNodeCanvasVisualizernetworkNodeVisualizer = nullptr
 
std::vector< const ITransmission * > transmissions
 The list of ongoing transmissions. More...
 
std::map< const IRadio *, cFigure * > transmissionFigures
 The list of transmission figures. More...
 
std::map< const IRadio *, cFigure * > receptionFigures
 The list of reception figures. More...
 
std::map< const ITransmission *, cFigure * > signalFigures
 The propagating signal figures. More...
 

Additional Inherited Members

- Public Member Functions inherited from inet::visualizer::MediumVisualizerBase
virtual ~MediumVisualizerBase ()
 
virtual void receiveSignal (cComponent *source, simsignal_t signal, cObject *object, cObject *details) override
 
- Protected Types inherited from inet::visualizer::MediumVisualizerBase
enum  SignalShape { SIGNAL_SHAPE_RING, SIGNAL_SHAPE_SPHERE, SIGNAL_SHAPE_BOTH }
 

Member Enumeration Documentation

Enumerator
SIP_NONE 
SIP_PROPAGATION 
SIP_TRANSMISSION 
58  {
59  SIP_NONE,
62  };
Definition: MediumCanvasVisualizer.h:61
Definition: MediumCanvasVisualizer.h:60
Definition: MediumCanvasVisualizer.h:59

Member Function Documentation

cGroupFigure * inet::visualizer::MediumCanvasVisualizer::createSignalFigure ( const ITransmission transmission) const
protectedvirtual

Referenced by transmissionAdded().

241 {
242  cFigure::Point position = canvasProjection->computeCanvasPoint( transmission->getStartPosition());
243  cGroupFigure* groupFigure = new cGroupFigure("signal");
244  cFigure::Color color = signalColorSet.getColor(transmission->getId());
245  SignalFigure* signalFigure = new SignalFigure("bubble");
246  signalFigure->setTags((std::string("propagating_signal ") + tags).c_str());
247  signalFigure->setTooltip("These rings represents a signal propagating through the medium");
248  signalFigure->setAssociatedObject(const_cast<cObject *>(check_and_cast<const cObject *>(transmission)));
249  signalFigure->setRingCount(signalRingCount);
250  signalFigure->setRingSize(signalRingSize);
251  signalFigure->setFadingDistance(signalFadingDistance);
252  signalFigure->setFadingFactor(signalFadingFactor);
253  signalFigure->setWaveCount(signalWaveCount);
254  signalFigure->setWaveLength(signalWaveLength);
255  signalFigure->setWaveWidth(signalWaveWidth);
256  signalFigure->setOpacity(signalOpacity);
257  signalFigure->setColor(color);
258  signalFigure->setBounds(cFigure::Rectangle(position.x, position.y, 0, 0));
259  signalFigure->refresh();
260  groupFigure->addFigure(signalFigure);
261  cLabelFigure* nameFigure = new cLabelFigure("packet name");
262  nameFigure->setPosition(position);
263  nameFigure->setTags((std::string("propagating_signal packet_name label ") + tags).c_str());
264  nameFigure->setText(transmission->getMacFrame()->getName());
265  nameFigure->setColor(color);
266  groupFigure->addFigure(nameFigure);
267  return groupFigure;
268 }
int signalWaveCount
Definition: MediumCanvasVisualizer.h:48
const char * tags
Definition: VisualizerBase.h:32
double signalFadingDistance
Definition: MediumCanvasVisualizer.h:46
double signalRingSize
Definition: MediumCanvasVisualizer.h:45
double signalFadingFactor
Definition: MediumCanvasVisualizer.h:47
ColorSet signalColorSet
Definition: MediumVisualizerBase.h:53
Color
Definition: DiffservUtil.h:30
double signalOpacity
Definition: MediumCanvasVisualizer.h:43
const CanvasProjection * canvasProjection
Definition: MediumCanvasVisualizer.h:41
double signalWaveWidth
Definition: MediumCanvasVisualizer.h:50
int signalRingCount
Definition: MediumCanvasVisualizer.h:44
cFigure::Point computeCanvasPoint(const Coord &point) const
Definition: CanvasProjection.cc:32
double signalWaveLength
Definition: MediumCanvasVisualizer.h:49
cFigure::Color getColor(int index) const
Definition: ColorSet.cc:43
cFigure * inet::visualizer::MediumCanvasVisualizer::getReceptionFigure ( const IRadio radio) const
protectedvirtual

Referenced by receptionEnded(), and receptionStarted().

191 {
192  auto it = receptionFigures.find(radio);
193  if (it == receptionFigures.end())
194  return nullptr;
195  else
196  return it->second;
197 }
std::map< const IRadio *, cFigure * > receptionFigures
The list of reception figures.
Definition: MediumCanvasVisualizer.h:77
cFigure * inet::visualizer::MediumCanvasVisualizer::getSignalFigure ( const ITransmission transmission) const
protectedvirtual

Referenced by refreshSignalFigure(), and transmissionRemoved().

216 {
217  auto it = signalFigures.find(transmission);
218  if (it == signalFigures.end())
219  return nullptr;
220  else
221  return it->second;
222 }
std::map< const ITransmission *, cFigure * > signalFigures
The propagating signal figures.
Definition: MediumCanvasVisualizer.h:81
cFigure * inet::visualizer::MediumCanvasVisualizer::getTransmissionFigure ( const IRadio radio) const
protectedvirtual

Referenced by transmissionEnded(), and transmissionStarted().

166 {
167  auto it = transmissionFigures.find(radio);
168  if (it == transmissionFigures.end())
169  return nullptr;
170  else
171  return it->second;
172 }
std::map< const IRadio *, cFigure * > transmissionFigures
The list of transmission figures.
Definition: MediumCanvasVisualizer.h:73
void inet::visualizer::MediumCanvasVisualizer::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::visualizer::MediumVisualizerBase.

34 {
36  if (!hasGUI()) return;
37  if (stage == INITSTAGE_LOCAL) {
38  zIndex = par("zIndex");
39  const char *signalShapeString = par("signalShape");
40  if (!strcmp(signalShapeString, "ring"))
42  else if (!strcmp(signalShapeString, "sphere"))
44  else
45  throw cRuntimeError("Unknown signalShape parameter value: '%s'", signalShapeString);
46  signalOpacity = par("signalOpacity");
47  signalRingCount = par("signalRingCount");
48  signalRingSize = par("signalRingSize");
49  signalFadingDistance = par("signalFadingDistance");
50  signalFadingFactor = par("signalFadingFactor");
51  signalWaveCount = par("signalWaveCount");
52  signalWaveLength = par("signalWaveLength");
53  signalWaveWidth = par("signalWaveWidth");
54  signalWaveFadingAnimationSpeedFactor = par("signalWaveFadingAnimationSpeedFactor");
55  cCanvas *canvas = visualizerTargetModule->getCanvas();
56  if (displaySignals) {
57  signalLayer = new cGroupFigure("communication");
58  signalLayer->setZIndex(zIndex);
59  signalLayer->insertBelow(canvas->getSubmodulesLayer());
60  }
61  displayCommunicationHeat = par("displayCommunicationHeat");
63  communicationHeat = new HeatMapFigure(communicationHeatMapSize, "communication heat");
64  communicationHeat->setZIndex(zIndex);
65  communicationHeat->setTags((std::string("successful_reception heat ") + tags).c_str());
66  canvas->addFigure(communicationHeat, 0);
67  }
70  networkNodeVisualizer = getModuleFromPar<NetworkNodeCanvasVisualizer>(par("networkNodeVisualizerModule"), this);
71  }
72  else if (stage == INITSTAGE_LAST) {
74  if (communicationHeat != nullptr) {
75  const IMediumLimitCache *mediumLimitCache = radioMedium->getMediumLimitCache();
76  Coord min = mediumLimitCache->getMinConstraintArea();
77  Coord max = mediumLimitCache->getMaxConstraintArea();
78  cFigure::Point o = canvasProjection->computeCanvasPoint(Coord::ZERO);
79  cFigure::Point x = canvasProjection->computeCanvasPoint(Coord(1, 0, 0));
80  cFigure::Point y = canvasProjection->computeCanvasPoint(Coord(0, 1, 0));
81  double t1 = o.x;
82  double t2 = o.y;
83  double a = x.x - t1;
84  double b = x.y - t2;
85  double c = y.x - t1;
86  double d = y.y - t2;
87  communicationHeat->setTransform(cFigure::Transform(a, b, c, d, t1, t2));
88  communicationHeat->setPosition(cFigure::Point((min.x + max.x) / 2, (min.y + max.y) / 2));
89  communicationHeat->setWidth(max.x - min.x);
90  communicationHeat->setHeight(max.y - min.y);
91  }
92  }
93 }
void setTargetAnimationSpeed(AnimationPosition::TimeType targetType, double targetTime, double targetAnimationSpeed)
Definition: AnimationSpeedInterpolator.cc:49
int signalWaveCount
Definition: MediumCanvasVisualizer.h:48
const char * tags
Definition: VisualizerBase.h:32
double zIndex
Definition: MediumCanvasVisualizer.h:40
double min(const double a, const double b)
Returns the minimum of a and b.
Definition: SCTPAssociation.h:270
double signalFadingDistance
Definition: MediumCanvasVisualizer.h:46
double signalRingSize
Definition: MediumCanvasVisualizer.h:45
NetworkNodeCanvasVisualizer * networkNodeVisualizer
Definition: MediumCanvasVisualizer.h:65
SignalShape signalShape
Definition: MediumCanvasVisualizer.h:42
virtual void initialize(int stage) override
Definition: MediumVisualizerBase.cc:42
double signalFadingFactor
Definition: MediumCanvasVisualizer.h:47
double max(double a, double b)
Returns the greater of the given parameters.
Definition: INETMath.h:161
bool displaySignals
Definition: MediumVisualizerBase.h:52
Operations that no other initializations can depend on, e.g.
Definition: InitStages.h:111
int communicationHeatMapSize
Definition: MediumCanvasVisualizer.h:53
const value< double, compose< units::m, pow< units::s,-1 > > > c(299792458)
Local initializations.
Definition: InitStages.h:35
cGroupFigure * signalLayer
The layer figure that contains the figures representing the ongoing communications.
Definition: MediumCanvasVisualizer.h:89
Definition: AnimationPosition.h:33
double signalOpacity
Definition: MediumCanvasVisualizer.h:43
cModule * visualizerTargetModule
Definition: VisualizerBase.h:31
bool displayCommunicationHeat
Definition: MediumCanvasVisualizer.h:52
AnimationSpeedInterpolator animationSpeedInterpolator
Definition: MediumCanvasVisualizer.h:64
static const Coord ZERO
Definition: Coord.h:41
const CanvasProjection * canvasProjection
Definition: MediumCanvasVisualizer.h:41
HeatMapFigure * communicationHeat
The heat map figure that shows the recent successful communications.
Definition: MediumCanvasVisualizer.h:93
double signalWaveWidth
Definition: MediumCanvasVisualizer.h:50
void setCurrentAnimationSpeed(double currentAnimationSpeed)
Definition: AnimationSpeedInterpolator.cc:43
IRadioMedium * radioMedium
Definition: MediumVisualizerBase.h:48
double signalWaveFadingAnimationSpeedFactor
Definition: MediumCanvasVisualizer.h:51
int signalRingCount
Definition: MediumCanvasVisualizer.h:44
virtual const IMediumLimitCache * getMediumLimitCache() const =0
value< double, units::m > b
Definition: Units.h:1054
cFigure::Point computeCanvasPoint(const Coord &point) const
Definition: CanvasProjection.cc:32
double signalWaveLength
Definition: MediumCanvasVisualizer.h:49
static const CanvasProjection * getCanvasProjection(const cCanvas *canvas)
Definition: CanvasProjection.cc:38
void inet::visualizer::MediumCanvasVisualizer::radioAdded ( const IRadio radio)
overrideprotectedvirtual

Implements inet::visualizer::MediumVisualizerBase.

325 {
326  Enter_Method_Silent();
327  auto module = check_and_cast<const cModule *>(radio);
328  auto networkNode = getContainingNode(module);
329  if (networkNodeFilter.matches(networkNode)) {
330  if (displayInterferenceRanges || (module->hasPar("displayInterferenceRange") && module->par("displayInterferenceRange"))) {
331  auto networkNodeVisualization = networkNodeVisualizer->getNetworkNodeVisualization(networkNode);
332  auto interferenceRangeFigure = new cOvalFigure("interferenceRange");
333  m maxInterferenceRange = check_and_cast<const IRadioMedium *>(radio->getMedium())->getMediumLimitCache()->getMaxInterferenceRange(radio);
334  interferenceRangeFigure->setTags((std::string("interference_range ") + tags).c_str());
335  interferenceRangeFigure->setTooltip("This circle represents the interference range of a wireless interface");
336  interferenceRangeFigure->setBounds(cFigure::Rectangle(-maxInterferenceRange.get(), -maxInterferenceRange.get(), 2 * maxInterferenceRange.get(), 2 * maxInterferenceRange.get()));
337  interferenceRangeFigure->setLineColor(interferenceRangeLineColor);
338  interferenceRangeFigure->setLineStyle(interferenceRangeLineStyle);
339  interferenceRangeFigure->setLineWidth(interferenceRangeLineWidth);
340  networkNodeVisualization->addFigure(interferenceRangeFigure);
341  }
342  if (displayCommunicationRanges || (module->hasPar("displayCommunicationRange") && module->par("displayCommunicationRange"))) {
343  auto networkNodeVisualization = networkNodeVisualizer->getNetworkNodeVisualization(networkNode);
344  auto communicationRangeFigure = new cOvalFigure("communicationRange");
345  m maxCommunicationRange = check_and_cast<const IRadioMedium *>(radio->getMedium())->getMediumLimitCache()->getMaxCommunicationRange(radio);
346  communicationRangeFigure->setTags((std::string("communication_range ") + tags).c_str());
347  communicationRangeFigure->setTooltip("This circle represents the communication range of a wireless interface");
348  communicationRangeFigure->setBounds(cFigure::Rectangle(-maxCommunicationRange.get(), -maxCommunicationRange.get(), 2 * maxCommunicationRange.get(), 2 * maxCommunicationRange.get()));
349  communicationRangeFigure->setLineColor(communicationRangeLineColor);
350  communicationRangeFigure->setLineStyle(communicationRangeLineStyle);
351  communicationRangeFigure->setLineWidth(communicationRangeLineWidth);
352  networkNodeVisualization->addFigure(communicationRangeFigure);
353  }
355  auto networkNodeVisualization = networkNodeVisualizer->getNetworkNodeVisualization(networkNode);
356  if (displayTransmissions) {
357  std::string imageName = par("transmissionImage");
358  auto transmissionFigure = new LabeledIconFigure("transmission");
359  transmissionFigure->setTags((std::string("transmission ") + tags).c_str());
360  transmissionFigure->setTooltip("This icon represents an ongoing transmission in a wireless interface");
361  transmissionFigure->setVisible(false);
362  auto iconFigure = transmissionFigure->getIconFigure();
363  iconFigure->setImageName(imageName.substr(0, imageName.find_first_of(".")).c_str());
364  iconFigure->setAnchor(cFigure::ANCHOR_NW);
365  auto labelFigure = transmissionFigure->getLabelFigure();
366  labelFigure->setPosition(iconFigure->getBounds().getSize() / 2);
367  networkNodeVisualization->addAnnotation(transmissionFigure, transmissionFigure->getBounds().getSize(), transmissionDisplacementHint, transmissionDisplacementPriority);
368  setTransmissionFigure(radio, transmissionFigure);
369  }
370  if (displayReceptions) {
371  std::string imageName = par("receptionImage");
372  auto receptionFigure = new LabeledIconFigure("reception");
373  receptionFigure->setTags((std::string("reception ") + tags).c_str());
374  receptionFigure->setTooltip("This icon represents an ongoing reception in a wireless interface");
375  receptionFigure->setVisible(false);
376  auto iconFigure = receptionFigure->getIconFigure();
377  iconFigure->setImageName(imageName.substr(0, imageName.find_first_of(".")).c_str());
378  iconFigure->setAnchor(cFigure::ANCHOR_NW);
379  auto labelFigure = receptionFigure->getLabelFigure();
380  labelFigure->setPosition(iconFigure->getBounds().getSize() / 2);
381  networkNodeVisualization->addAnnotation(receptionFigure, receptionFigure->getBounds().getSize(), receptionDisplacementHint, receptionDisplacementPriority);
382  setReceptionFigure(radio, receptionFigure);
383  }
384  }
385  }
386 }
bool displayTransmissions
Definition: MediumVisualizerBase.h:60
virtual void setTransmissionFigure(const IRadio *radio, cFigure *figure)
Definition: MediumCanvasVisualizer.cc:174
bool displayReceptions
Definition: MediumVisualizerBase.h:61
bool matches(const cModule *module) const
Definition: NetworkNodeFilter.cc:29
double interferenceRangeLineWidth
Definition: MediumVisualizerBase.h:69
const char * tags
Definition: VisualizerBase.h:32
NetworkNodeCanvasVisualizer * networkNodeVisualizer
Definition: MediumCanvasVisualizer.h:65
bool displayInterferenceRanges
Definition: MediumVisualizerBase.h:66
double transmissionDisplacementPriority
Definition: MediumVisualizerBase.h:64
Displacement receptionDisplacementHint
Definition: MediumVisualizerBase.h:63
cFigure::Color interferenceRangeLineColor
Definition: MediumVisualizerBase.h:67
double communicationRangeLineWidth
Definition: MediumVisualizerBase.h:73
virtual void setReceptionFigure(const IRadio *radio, cFigure *figure)
Definition: MediumCanvasVisualizer.cc:199
cFigure::LineStyle communicationRangeLineStyle
Definition: MediumVisualizerBase.h:72
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
Displacement transmissionDisplacementHint
Definition: MediumVisualizerBase.h:62
bool displayCommunicationRanges
Definition: MediumVisualizerBase.h:70
double receptionDisplacementPriority
Definition: MediumVisualizerBase.h:65
NetworkNodeFilter networkNodeFilter
Definition: MediumVisualizerBase.h:49
cFigure::Color communicationRangeLineColor
Definition: MediumVisualizerBase.h:71
cFigure::LineStyle interferenceRangeLineStyle
Definition: MediumVisualizerBase.h:68
value< double, units::m > m
Definition: Units.h:1047
void inet::visualizer::MediumCanvasVisualizer::radioRemoved ( const IRadio radio)
overrideprotectedvirtual

Implements inet::visualizer::MediumVisualizerBase.

389 {
390  Enter_Method_Silent();
391  auto transmissionFigure = removeTransmissionFigure(radio);
392  if (transmissionFigure != nullptr) {
393  auto module = const_cast<cModule *>(check_and_cast<const cModule *>(radio));
394  auto networkNodeVisualization = networkNodeVisualizer->getNetworkNodeVisualization(getContainingNode(module));
395  networkNodeVisualization->removeAnnotation(transmissionFigure);
396  }
397  auto figure = removeReceptionFigure(radio);
398  if (figure != nullptr) {
399  auto module = const_cast<cModule *>(check_and_cast<const cModule *>(radio));
400  auto networkNodeVisualization = networkNodeVisualizer->getNetworkNodeVisualization(getContainingNode(module));
401  networkNodeVisualization->removeAnnotation(figure);
402  }
403 }
NetworkNodeCanvasVisualizer * networkNodeVisualizer
Definition: MediumCanvasVisualizer.h:65
virtual cFigure * removeTransmissionFigure(const IRadio *radio)
Definition: MediumCanvasVisualizer.cc:179
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
virtual cFigure * removeReceptionFigure(const IRadio *radio)
Definition: MediumCanvasVisualizer.cc:204
virtual void removeAnnotation(cFigure *figure)
Definition: NetworkNodeCanvasVisualization.cc:69
void inet::visualizer::MediumCanvasVisualizer::receptionEnded ( const IReception reception)
overrideprotectedvirtual

Implements inet::visualizer::MediumVisualizerBase.

513 {
514  Enter_Method_Silent();
515  if (matchesTransmission(reception->getTransmission())) {
516  if (displaySignals)
518  if (displayReceptions) {
519  auto receiver = reception->getReceiver();
520  if (networkNodeFilter.matches(check_and_cast<const cModule *>(receiver))) {
521  auto figure = getReceptionFigure(receiver);
522  auto networkNode = getContainingNode(check_and_cast<const cModule *>(receiver));
523  auto networkNodeVisualization = networkNodeVisualizer->getNetworkNodeVisualization(networkNode);
524  networkNodeVisualization->setAnnotationVisible(figure, false);
525  }
526  }
527  }
528 }
bool displayReceptions
Definition: MediumVisualizerBase.h:61
bool matches(const cModule *module) const
Definition: NetworkNodeFilter.cc:29
NetworkNodeCanvasVisualizer * networkNodeVisualizer
Definition: MediumCanvasVisualizer.h:65
bool displaySignals
Definition: MediumVisualizerBase.h:52
virtual NetworkNodeCanvasVisualization * getNetworkNodeVisualization(const cModule *networkNode) const
Definition: NetworkNodeCanvasVisualizer.cc:63
virtual void setAnnotationVisible(cFigure *figure, bool visible)
Definition: NetworkNodeCanvasVisualization.cc:95
cModule * getContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:65
virtual cFigure * getReceptionFigure(const IRadio *radio) const
Definition: MediumCanvasVisualizer.cc:190
virtual bool matchesTransmission(const ITransmission *transmission) const
Definition: MediumVisualizerBase.cc:154
virtual void setAnimationSpeed()
Definition: MediumCanvasVisualizer.cc:107
NetworkNodeFilter networkNodeFilter
Definition: MediumVisualizerBase.h:49
void inet::visualizer::MediumCanvasVisualizer::receptionStarted ( const IReception reception)
overrideprotectedvirtual

Implements inet::visualizer::MediumVisualizerBase.

473 {
474  Enter_Method_Silent();
475  if (matchesTransmission(reception->getTransmission())) {
476  if (displaySignals)
478  if (displayReceptions) {
479  auto receiver = reception->getReceiver();
480  if (networkNodeFilter.matches(check_and_cast<const cModule *>(receiver))) {
481  auto figure = getReceptionFigure(receiver);
482  auto networkNode = getContainingNode(check_and_cast<const cModule *>(receiver));
483  auto networkNodeVisualization = networkNodeVisualizer->getNetworkNodeVisualization(networkNode);
484  networkNodeVisualization->setAnnotationVisible(figure, true);
485  auto labelFigure = check_and_cast<LabeledIconFigure *>(figure)->getLabelFigure();
486 #ifdef WITH_RADIO
487  if (auto scalarReception = dynamic_cast<const ScalarReception *>(reception)) {
488  char tmp[32];
489  sprintf(tmp, "%.4g dBW", inet::math::fraction2dB(W(scalarReception->getPower()).get()));
490  labelFigure->setText(tmp);
491  }
492  else
493 #endif // WITH_RADIO
494  labelFigure->setText("");
495  }
496  }
498  const ITransmission *transmission = reception->getTransmission();
499  const IMediumLimitCache *mediumLimitCache = radioMedium->getMediumLimitCache();
500  Coord min = mediumLimitCache->getMinConstraintArea();
501  Coord max = mediumLimitCache->getMaxConstraintArea();
502  Coord delta = max - min;
503  int x1 = std::round((communicationHeatMapSize - 1) * ((transmission->getStartPosition().x - min.x) / delta.x));
504  int y1 = std::round((communicationHeatMapSize - 1) * ((transmission->getStartPosition().y - min.x) / delta.y));
505  int x2 = std::round((communicationHeatMapSize - 1) * ((reception->getStartPosition().x - min.x) / delta.x));
506  int y2 = std::round((communicationHeatMapSize - 1) * ((reception->getStartPosition().y - min.y) / delta.y));
507  communicationHeat->heatLine(x1, y1, x2, y2);
508  }
509  }
510 }
bool displayReceptions
Definition: MediumVisualizerBase.h:61
bool matches(const cModule *module) const
Definition: NetworkNodeFilter.cc:29
double min(const double a, const double b)
Returns the minimum of a and b.
Definition: SCTPAssociation.h:270
NetworkNodeCanvasVisualizer * networkNodeVisualizer
Definition: MediumCanvasVisualizer.h:65
double max(double a, double b)
Returns the greater of the given parameters.
Definition: INETMath.h:161
bool displaySignals
Definition: MediumVisualizerBase.h:52
virtual void heatLine(int x1, int y1, int x2, int y2)
Definition: HeatMapFigure.cc:53
compose< J, pow< s,-1 > > W
Definition: Units.h:770
int communicationHeatMapSize
Definition: MediumCanvasVisualizer.h:53
double fraction2dB(double fraction)
Convert a fraction value to dB.
Definition: INETMath.h:171
virtual NetworkNodeCanvasVisualization * getNetworkNodeVisualization(const cModule *networkNode) const
Definition: NetworkNodeCanvasVisualizer.cc:63
int round(double d)
Returns an integer that corresponds to rounded double parameter.
Definition: INETMath.h:151
virtual void setAnnotationVisible(cFigure *figure, bool visible)
Definition: NetworkNodeCanvasVisualization.cc:95
cModule * getContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:65
virtual cFigure * getReceptionFigure(const IRadio *radio) const
Definition: MediumCanvasVisualizer.cc:190
virtual bool matchesTransmission(const ITransmission *transmission) const
Definition: MediumVisualizerBase.cc:154
bool displayCommunicationHeat
Definition: MediumCanvasVisualizer.h:52
HeatMapFigure * communicationHeat
The heat map figure that shows the recent successful communications.
Definition: MediumCanvasVisualizer.h:93
IRadioMedium * radioMedium
Definition: MediumVisualizerBase.h:48
virtual void setAnimationSpeed()
Definition: MediumCanvasVisualizer.cc:107
NetworkNodeFilter networkNodeFilter
Definition: MediumVisualizerBase.h:49
virtual const IMediumLimitCache * getMediumLimitCache() const =0
void inet::visualizer::MediumCanvasVisualizer::refreshDisplay ( ) const
overrideprotectedvirtual
96 {
97  if (displaySignals) {
98  for (auto transmission : transmissions)
99  if (matchesTransmission(transmission))
100  refreshSignalFigure(transmission);
101  const_cast<MediumCanvasVisualizer *>(this)->setAnimationSpeed();
102  }
105 }
virtual void coolDown()
Definition: HeatMapFigure.cc:83
bool displaySignals
Definition: MediumVisualizerBase.h:52
virtual void refreshSignalFigure(const ITransmission *transmission) const
Definition: MediumCanvasVisualizer.cc:270
virtual bool matchesTransmission(const ITransmission *transmission) const
Definition: MediumVisualizerBase.cc:154
bool displayCommunicationHeat
Definition: MediumCanvasVisualizer.h:52
HeatMapFigure * communicationHeat
The heat map figure that shows the recent successful communications.
Definition: MediumCanvasVisualizer.h:93
std::vector< const ITransmission * > transmissions
The list of ongoing transmissions.
Definition: MediumCanvasVisualizer.h:69
virtual void setAnimationSpeed()
Definition: MediumCanvasVisualizer.cc:107
void inet::visualizer::MediumCanvasVisualizer::refreshSignalFigure ( const ITransmission transmission) const
protectedvirtual

Referenced by refreshDisplay().

271 {
272  const IPropagation *propagation = radioMedium->getPropagation();
273  cFigure *groupFigure = getSignalFigure(transmission);
274  double startRadius = propagation->getPropagationSpeed().get() * (simTime() - transmission->getStartTime()).dbl();
275  double endRadius = std::max(0.0, propagation->getPropagationSpeed().get() * (simTime() - transmission->getEndTime()).dbl());
276  if (groupFigure) {
277  SignalFigure *signalFigure = static_cast<SignalFigure *>(groupFigure->getFigure(0));
278  cLabelFigure *labelFigure = static_cast<cLabelFigure *>(groupFigure->getFigure(1));
279  double phi = transmission->getId();
280  labelFigure->setTransform(cFigure::Transform().translate(endRadius * sin(phi), endRadius * cos(phi)));
281  const Coord transmissionStart = transmission->getStartPosition();
282  // KLUDGE: to workaround overflow bugs in drawing
283  double offset = std::fmod(startRadius, signalFigure->getWaveLength());
284  if (startRadius > 10000)
285  startRadius = 10000;
286  if (endRadius > 10000)
287  endRadius = 10000;
288  switch (signalShape) {
289  case SIGNAL_SHAPE_RING: {
290  // determine the rotated 2D canvas points by computing the 2D affine transformation from the 3D transformation of the environment
291  cFigure::Point o = canvasProjection->computeCanvasPoint(transmissionStart);
292  cFigure::Point x = canvasProjection->computeCanvasPoint(transmissionStart + Coord(1, 0, 0));
293  cFigure::Point y = canvasProjection->computeCanvasPoint(transmissionStart + Coord(0, 1, 0));
294  double t1 = o.x;
295  double t2 = o.y;
296  double a = x.x - t1;
297  double b = x.y - t2;
298  double c = y.x - t1;
299  double d = y.y - t2;
300  signalFigure->setTransform(cFigure::Transform(a, b, c, d, t1, t2));
301  signalFigure->setBounds(cFigure::Rectangle(-startRadius, -startRadius, startRadius * 2, startRadius * 2));
302  signalFigure->setInnerRx(endRadius);
303  signalFigure->setInnerRy(endRadius);
304  signalFigure->setWaveOffset(offset);
305  double currentSignalPropagationAnimationSpeed = std::isnan(signalPropagationAnimationSpeed) ? defaultSignalPropagationAnimationSpeed : signalPropagationAnimationSpeed;
306  signalFigure->setWaveOpacityFactor(std::min(1.0, currentSignalPropagationAnimationSpeed / getSimulation()->getEnvir()->getAnimationSpeed() / signalWaveFadingAnimationSpeedFactor));
307  signalFigure->refresh();
308  break;
309  }
310  case SIGNAL_SHAPE_SPHERE: {
311  // a sphere looks like a circle from any view angle
312  cFigure::Point center = canvasProjection->computeCanvasPoint(transmissionStart);
313  signalFigure->setBounds(cFigure::Rectangle(center.x - startRadius, center.y - startRadius, 2 * startRadius, 2 * startRadius));
314  signalFigure->setInnerRx(endRadius);
315  signalFigure->setInnerRy(endRadius);
316  break;
317  }
318  default:
319  throw cRuntimeError("Unimplemented signal shape");
320  }
321  }
322 }
Value cos(const value< Value, Unit > &angle)
Definition: Units.h:1201
double min(const double a, const double b)
Returns the minimum of a and b.
Definition: SCTPAssociation.h:270
virtual cFigure * getSignalFigure(const ITransmission *transmission) const
Definition: MediumCanvasVisualizer.cc:215
SignalShape signalShape
Definition: MediumCanvasVisualizer.h:42
double max(double a, double b)
Returns the greater of the given parameters.
Definition: INETMath.h:161
virtual const IPropagation * getPropagation() const =0
Returns the radio signal propagation model of this radio medium.
const value< double, compose< units::m, pow< units::s,-1 > > > c(299792458)
const CanvasProjection * canvasProjection
Definition: MediumCanvasVisualizer.h:41
IRadioMedium * radioMedium
Definition: MediumVisualizerBase.h:48
double defaultSignalPropagationAnimationSpeed
Definition: MediumVisualizerBase.h:78
double signalWaveFadingAnimationSpeedFactor
Definition: MediumCanvasVisualizer.h:51
Value sin(const value< Value, Unit > &angle)
Definition: Units.h:1195
double signalPropagationAnimationSpeed
Definition: MediumVisualizerBase.h:54
value< double, units::m > b
Definition: Units.h:1054
cFigure::Point computeCanvasPoint(const Coord &point) const
Definition: CanvasProjection.cc:32
cFigure * inet::visualizer::MediumCanvasVisualizer::removeReceptionFigure ( const IRadio radio)
protectedvirtual

Referenced by radioRemoved().

205 {
206  auto it = receptionFigures.find(radio);
207  if (it == receptionFigures.end())
208  return nullptr;
209  else {
210  receptionFigures.erase(it);
211  return it->second;
212  }
213 }
std::map< const IRadio *, cFigure * > receptionFigures
The list of reception figures.
Definition: MediumCanvasVisualizer.h:77
cFigure * inet::visualizer::MediumCanvasVisualizer::removeSignalFigure ( const ITransmission transmission)
protectedvirtual

Referenced by transmissionRemoved().

230 {
231  auto it = signalFigures.find(transmission);
232  if (it == signalFigures.end())
233  return nullptr;
234  else {
235  signalFigures.erase(it);
236  return it->second;
237  }
238 }
std::map< const ITransmission *, cFigure * > signalFigures
The propagating signal figures.
Definition: MediumCanvasVisualizer.h:81
cFigure * inet::visualizer::MediumCanvasVisualizer::removeTransmissionFigure ( const IRadio radio)
protectedvirtual

Referenced by radioRemoved().

180 {
181  auto it = transmissionFigures.find(radio);
182  if (it == transmissionFigures.end())
183  return nullptr;
184  else {
185  transmissionFigures.erase(it);
186  return it->second;
187  }
188 }
std::map< const IRadio *, cFigure * > transmissionFigures
The list of transmission figures.
Definition: MediumCanvasVisualizer.h:73
void inet::visualizer::MediumCanvasVisualizer::setAnimationSpeed ( )
protectedvirtual

Referenced by receptionEnded(), receptionStarted(), refreshDisplay(), transmissionAdded(), transmissionEnded(), transmissionRemoved(), and transmissionStarted().

108 {
109  SignalInProgress newSignalInProgress = SIP_NONE;
110  double newSignalTransmissionAnimationSpeed = DBL_MAX;
111  for (auto transmission : transmissions) {
112  if (matchesTransmission(transmission)) {
113  if (isSignalPropagationInProgress(transmission))
114  newSignalInProgress = SIP_PROPAGATION;
115  if (isSignalTransmissionInProgress(transmission)) {
116  if (newSignalInProgress == SIP_NONE)
117  newSignalInProgress = SIP_TRANSMISSION;
118  // TODO: overwrite only...
119  if (std::isnan(signalTransmissionAnimationSpeed))
120  newSignalTransmissionAnimationSpeed = std::min(newSignalTransmissionAnimationSpeed, transmission->getDuration().dbl() / signalTransmissionAnimationTime);
121  }
122  }
123  }
124  if (newSignalTransmissionAnimationSpeed != DBL_MAX)
125  defaultSignalTransmissionAnimationSpeed = newSignalTransmissionAnimationSpeed;
126  double currentSignalPropagationAnimationSpeed = std::isnan(signalPropagationAnimationSpeed) ? defaultSignalPropagationAnimationSpeed : signalPropagationAnimationSpeed;
127  double currentSignalTransmissionAnimationSpeed = std::isnan(signalTransmissionAnimationSpeed) ? defaultSignalTransmissionAnimationSpeed : signalTransmissionAnimationSpeed;
128  AnimationPosition currentPosition;
130  if (newSignalInProgress == SIP_NONE) {
133  }
134  else if (newSignalInProgress == SIP_PROPAGATION)
135  animationSpeedInterpolator.setAnimationSpeed(currentSignalPropagationAnimationSpeed);
136  else if (newSignalInProgress == SIP_TRANSMISSION)
137  animationSpeedInterpolator.setAnimationSpeed(currentSignalTransmissionAnimationSpeed);
138  }
140  if (newSignalInProgress == SIP_NONE) {
141  animationSpeedInterpolator.setCurrentAnimationSpeed(currentSignalPropagationAnimationSpeed);
142  animationSpeedInterpolator.setTargetAnimationSpeed(AnimationPosition::REAL_TIME, currentPosition.getRealTime() + signalAnimationSpeedChangeTime, currentSignalTransmissionAnimationSpeed);
143  }
144  else if (newSignalInProgress == SIP_PROPAGATION)
145  ; // void
146  else if (newSignalInProgress == SIP_TRANSMISSION) {
147  animationSpeedInterpolator.setCurrentAnimationSpeed(currentSignalPropagationAnimationSpeed);
148  animationSpeedInterpolator.setTargetAnimationSpeed(AnimationPosition::REAL_TIME, currentPosition.getRealTime() + signalAnimationSpeedChangeTime, currentSignalTransmissionAnimationSpeed);
149  }
150  }
152  if (newSignalInProgress == SIP_NONE)
154  else if (newSignalInProgress == SIP_PROPAGATION)
155  animationSpeedInterpolator.setAnimationSpeed(currentSignalPropagationAnimationSpeed);
156  else if (newSignalInProgress == SIP_TRANSMISSION)
157  ; // void
158  }
159  lastSignalInProgress = newSignalInProgress;
160  double animationSpeed = animationSpeedInterpolator.getCurrentAnimationSpeed();
161  ASSERT(!std::isnan(animationSpeed));
162  visualizerTargetModule->getCanvas()->setAnimationSpeed(animationSpeed, this);
163 }
SignalInProgress lastSignalInProgress
Definition: MediumCanvasVisualizer.h:63
void setAnimationSpeed(double animationSpeed)
Definition: AnimationSpeedInterpolator.cc:56
double getCurrentAnimationSpeed() const
Definition: AnimationSpeedInterpolator.cc:30
void setTargetAnimationSpeed(AnimationPosition::TimeType targetType, double targetTime, double targetAnimationSpeed)
Definition: AnimationSpeedInterpolator.cc:49
Definition: MediumCanvasVisualizer.h:61
double min(const double a, const double b)
Returns the minimum of a and b.
Definition: SCTPAssociation.h:270
double signalTransmissionAnimationSpeed
Definition: MediumVisualizerBase.h:57
double defaultSignalTransmissionAnimationSpeed
Definition: MediumVisualizerBase.h:79
double getTargetAnimationSpeed() const
Definition: AnimationSpeedInterpolator.h:45
Definition: MediumCanvasVisualizer.h:60
Definition: AnimationPosition.h:33
virtual bool isSignalTransmissionInProgress(const ITransmission *transmission) const
Definition: MediumVisualizerBase.cc:148
double signalTransmissionAnimationTime
Definition: MediumVisualizerBase.h:58
virtual bool matchesTransmission(const ITransmission *transmission) const
Definition: MediumVisualizerBase.cc:154
cModule * visualizerTargetModule
Definition: VisualizerBase.h:31
Definition: MediumCanvasVisualizer.h:59
AnimationSpeedInterpolator animationSpeedInterpolator
Definition: MediumCanvasVisualizer.h:64
std::vector< const ITransmission * > transmissions
The list of ongoing transmissions.
Definition: MediumCanvasVisualizer.h:69
void setCurrentAnimationSpeed(double currentAnimationSpeed)
Definition: AnimationSpeedInterpolator.cc:43
double defaultSignalPropagationAnimationSpeed
Definition: MediumVisualizerBase.h:78
double signalAnimationSpeedChangeTime
Definition: MediumVisualizerBase.h:59
SignalInProgress
Definition: MediumCanvasVisualizer.h:58
double signalPropagationAnimationSpeed
Definition: MediumVisualizerBase.h:54
virtual bool isSignalPropagationInProgress(const ITransmission *transmission) const
Definition: MediumVisualizerBase.cc:135
void inet::visualizer::MediumCanvasVisualizer::setReceptionFigure ( const IRadio radio,
cFigure *  figure 
)
protectedvirtual

Referenced by radioAdded().

200 {
201  receptionFigures[radio] = figure;
202 }
std::map< const IRadio *, cFigure * > receptionFigures
The list of reception figures.
Definition: MediumCanvasVisualizer.h:77
void inet::visualizer::MediumCanvasVisualizer::setSignalFigure ( const ITransmission transmission,
cFigure *  figure 
)
protectedvirtual

Referenced by transmissionAdded().

225 {
226  signalFigures[transmission] = figure;
227 }
std::map< const ITransmission *, cFigure * > signalFigures
The propagating signal figures.
Definition: MediumCanvasVisualizer.h:81
void inet::visualizer::MediumCanvasVisualizer::setTransmissionFigure ( const IRadio radio,
cFigure *  figure 
)
protectedvirtual

Referenced by radioAdded().

175 {
176  transmissionFigures[radio] = figure;
177 }
std::map< const IRadio *, cFigure * > transmissionFigures
The list of transmission figures.
Definition: MediumCanvasVisualizer.h:73
void inet::visualizer::MediumCanvasVisualizer::transmissionAdded ( const ITransmission transmission)
overrideprotectedvirtual

Implements inet::visualizer::MediumVisualizerBase.

406 {
407  Enter_Method_Silent();
408  if (displaySignals && matchesTransmission(transmission)) {
409  transmissions.push_back(transmission);
410  cGroupFigure *signalFigure = createSignalFigure(transmission);
411  signalLayer->addFigure(signalFigure);
412  setSignalFigure(transmission, signalFigure);
414  }
415 }
virtual cGroupFigure * createSignalFigure(const ITransmission *transmission) const
Definition: MediumCanvasVisualizer.cc:240
virtual void setSignalFigure(const ITransmission *transmission, cFigure *figure)
Definition: MediumCanvasVisualizer.cc:224
bool displaySignals
Definition: MediumVisualizerBase.h:52
cGroupFigure * signalLayer
The layer figure that contains the figures representing the ongoing communications.
Definition: MediumCanvasVisualizer.h:89
virtual bool matchesTransmission(const ITransmission *transmission) const
Definition: MediumVisualizerBase.cc:154
std::vector< const ITransmission * > transmissions
The list of ongoing transmissions.
Definition: MediumCanvasVisualizer.h:69
virtual void setAnimationSpeed()
Definition: MediumCanvasVisualizer.cc:107
void inet::visualizer::MediumCanvasVisualizer::transmissionEnded ( const ITransmission transmission)
overrideprotectedvirtual

Implements inet::visualizer::MediumVisualizerBase.

457 {
458  Enter_Method_Silent();
459  if (matchesTransmission(transmission)) {
460  if (displaySignals)
462  if (displayTransmissions) {
463  auto transmitter = transmission->getTransmitter();
464  auto figure = getTransmissionFigure(transmitter);
465  auto networkNode = getContainingNode(check_and_cast<const cModule *>(transmitter));
466  auto networkNodeVisualization = networkNodeVisualizer->getNetworkNodeVisualization(networkNode);
467  networkNodeVisualization->setAnnotationVisible(figure, false);
468  }
469  }
470 }
bool displayTransmissions
Definition: MediumVisualizerBase.h:60
NetworkNodeCanvasVisualizer * networkNodeVisualizer
Definition: MediumCanvasVisualizer.h:65
bool displaySignals
Definition: MediumVisualizerBase.h:52
virtual NetworkNodeCanvasVisualization * getNetworkNodeVisualization(const cModule *networkNode) const
Definition: NetworkNodeCanvasVisualizer.cc:63
virtual cFigure * getTransmissionFigure(const IRadio *radio) const
Definition: MediumCanvasVisualizer.cc:165
virtual void setAnnotationVisible(cFigure *figure, bool visible)
Definition: NetworkNodeCanvasVisualization.cc:95
cModule * getContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:65
virtual bool matchesTransmission(const ITransmission *transmission) const
Definition: MediumVisualizerBase.cc:154
virtual void setAnimationSpeed()
Definition: MediumCanvasVisualizer.cc:107
void inet::visualizer::MediumCanvasVisualizer::transmissionRemoved ( const ITransmission transmission)
overrideprotectedvirtual

Implements inet::visualizer::MediumVisualizerBase.

418 {
419  Enter_Method_Silent();
420  if (displaySignals && matchesTransmission(transmission)) {
421  transmissions.erase(std::remove(transmissions.begin(), transmissions.end(), transmission));
422  cFigure *signalFigure = getSignalFigure(transmission);
423  removeSignalFigure(transmission);
424  if (signalFigure != nullptr)
425  delete signalLayer->removeFigure(signalFigure);
427  }
428 }
virtual cFigure * removeSignalFigure(const ITransmission *transmission)
Definition: MediumCanvasVisualizer.cc:229
void remove(std::vector< T > &v, const A &a)
Definition: stlutils.h:91
virtual cFigure * getSignalFigure(const ITransmission *transmission) const
Definition: MediumCanvasVisualizer.cc:215
bool displaySignals
Definition: MediumVisualizerBase.h:52
cGroupFigure * signalLayer
The layer figure that contains the figures representing the ongoing communications.
Definition: MediumCanvasVisualizer.h:89
virtual bool matchesTransmission(const ITransmission *transmission) const
Definition: MediumVisualizerBase.cc:154
std::vector< const ITransmission * > transmissions
The list of ongoing transmissions.
Definition: MediumCanvasVisualizer.h:69
virtual void setAnimationSpeed()
Definition: MediumCanvasVisualizer.cc:107
void inet::visualizer::MediumCanvasVisualizer::transmissionStarted ( const ITransmission transmission)
overrideprotectedvirtual

Implements inet::visualizer::MediumVisualizerBase.

431 {
432  Enter_Method_Silent();
433  if (matchesTransmission(transmission)) {
434  if (displaySignals)
436  if (displayTransmissions) {
437  auto transmitter = transmission->getTransmitter();
438  auto figure = getTransmissionFigure(transmitter);
439  auto networkNode = getContainingNode(check_and_cast<const cModule *>(transmitter));
440  auto networkNodeVisualization = networkNodeVisualizer->getNetworkNodeVisualization(networkNode);
441  networkNodeVisualization->setAnnotationVisible(figure, true);
442  auto labelFigure = check_and_cast<LabeledIconFigure *>(figure)->getLabelFigure();
443 #ifdef WITH_RADIO
444  if (auto scalarTransmission = dynamic_cast<const ScalarTransmission *>(transmission)) {
445  char tmp[32];
446  sprintf(tmp, "%.4g dBW", inet::math::fraction2dB(W(scalarTransmission->getPower()).get()));
447  labelFigure->setText(tmp);
448  }
449  else
450 #endif // WITH_RADIO
451  labelFigure->setText("");
452  }
453  }
454 }
bool displayTransmissions
Definition: MediumVisualizerBase.h:60
NetworkNodeCanvasVisualizer * networkNodeVisualizer
Definition: MediumCanvasVisualizer.h:65
bool displaySignals
Definition: MediumVisualizerBase.h:52
compose< J, pow< s,-1 > > W
Definition: Units.h:770
double fraction2dB(double fraction)
Convert a fraction value to dB.
Definition: INETMath.h:171
virtual NetworkNodeCanvasVisualization * getNetworkNodeVisualization(const cModule *networkNode) const
Definition: NetworkNodeCanvasVisualizer.cc:63
virtual cFigure * getTransmissionFigure(const IRadio *radio) const
Definition: MediumCanvasVisualizer.cc:165
virtual void setAnnotationVisible(cFigure *figure, bool visible)
Definition: NetworkNodeCanvasVisualization.cc:95
cModule * getContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:65
virtual bool matchesTransmission(const ITransmission *transmission) const
Definition: MediumVisualizerBase.cc:154
virtual void setAnimationSpeed()
Definition: MediumCanvasVisualizer.cc:107

Member Data Documentation

AnimationSpeedInterpolator inet::visualizer::MediumCanvasVisualizer::animationSpeedInterpolator
protected

Referenced by initialize(), and setAnimationSpeed().

const CanvasProjection* inet::visualizer::MediumCanvasVisualizer::canvasProjection = nullptr
protected
HeatMapFigure* inet::visualizer::MediumCanvasVisualizer::communicationHeat = nullptr
protected

The heat map figure that shows the recent successful communications.

Referenced by initialize(), receptionStarted(), and refreshDisplay().

int inet::visualizer::MediumCanvasVisualizer::communicationHeatMapSize = 100
protected

Referenced by initialize(), and receptionStarted().

bool inet::visualizer::MediumCanvasVisualizer::displayCommunicationHeat = false
protected
SignalInProgress inet::visualizer::MediumCanvasVisualizer::lastSignalInProgress = SIP_NONE
protected

Referenced by setAnimationSpeed().

NetworkNodeCanvasVisualizer* inet::visualizer::MediumCanvasVisualizer::networkNodeVisualizer = nullptr
protected
std::map<const IRadio *, cFigure *> inet::visualizer::MediumCanvasVisualizer::receptionFigures
protected

The list of reception figures.

Referenced by getReceptionFigure(), removeReceptionFigure(), and setReceptionFigure().

double inet::visualizer::MediumCanvasVisualizer::signalFadingDistance = NaN
protected

Referenced by createSignalFigure(), and initialize().

double inet::visualizer::MediumCanvasVisualizer::signalFadingFactor = NaN
protected

Referenced by createSignalFigure(), and initialize().

std::map<const ITransmission *, cFigure *> inet::visualizer::MediumCanvasVisualizer::signalFigures
protected

The propagating signal figures.

Referenced by getSignalFigure(), removeSignalFigure(), and setSignalFigure().

cGroupFigure* inet::visualizer::MediumCanvasVisualizer::signalLayer = nullptr
protected

The layer figure that contains the figures representing the ongoing communications.

Referenced by initialize(), transmissionAdded(), and transmissionRemoved().

double inet::visualizer::MediumCanvasVisualizer::signalOpacity = NaN
protected

Referenced by createSignalFigure(), and initialize().

int inet::visualizer::MediumCanvasVisualizer::signalRingCount = -1
protected

Referenced by createSignalFigure(), and initialize().

double inet::visualizer::MediumCanvasVisualizer::signalRingSize = NaN
protected

Referenced by createSignalFigure(), and initialize().

SignalShape inet::visualizer::MediumCanvasVisualizer::signalShape = SIGNAL_SHAPE_RING
protected

Referenced by initialize(), and refreshSignalFigure().

int inet::visualizer::MediumCanvasVisualizer::signalWaveCount = -1
protected

Referenced by createSignalFigure(), and initialize().

double inet::visualizer::MediumCanvasVisualizer::signalWaveFadingAnimationSpeedFactor = NaN
protected

Referenced by initialize(), and refreshSignalFigure().

double inet::visualizer::MediumCanvasVisualizer::signalWaveLength = NaN
protected

Referenced by createSignalFigure(), and initialize().

double inet::visualizer::MediumCanvasVisualizer::signalWaveWidth = NaN
protected

Referenced by createSignalFigure(), and initialize().

std::map<const IRadio *, cFigure *> inet::visualizer::MediumCanvasVisualizer::transmissionFigures
protected

The list of transmission figures.

Referenced by getTransmissionFigure(), removeTransmissionFigure(), and setTransmissionFigure().

std::vector<const ITransmission *> inet::visualizer::MediumCanvasVisualizer::transmissions
protected

The list of ongoing transmissions.

Referenced by refreshDisplay(), setAnimationSpeed(), transmissionAdded(), and transmissionRemoved().

double inet::visualizer::MediumCanvasVisualizer::zIndex = NaN
protected

Referenced by initialize().


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