INET Framework for OMNeT++/OMNEST
inet::SignalFigure Class Reference

#include <SignalFigure.h>

Inheritance diagram for inet::SignalFigure:

Public Member Functions

 SignalFigure (const char *name=nullptr)
 
void setColor (const cFigure::Color &color)
 
void setOpacity (double opacity)
 
void setBounds (const cFigure::Rectangle &bounds)
 
void setInnerRx (double innerRx)
 
void setInnerRy (double innerRy)
 
int getRingCount () const
 
void setRingCount (int count)
 
double getRingSize () const
 
void setRingSize (double ringSize)
 
double getFadingDistance () const
 
void setFadingDistance (double fadingDistance)
 
double getFadingFactor () const
 
void setFadingFactor (double fadingFactor)
 
int getWaveCount () const
 
void setWaveCount (int count)
 
double getWaveLength () const
 
void setWaveLength (double waveLength)
 
double getWaveWidth () const
 
void setWaveWidth (double waveWidth)
 
double getWaveOffset () const
 
void setWaveOffset (double waveOffset)
 
double getWaveOpacityFactor () const
 
void setWaveOpacityFactor (double waveOpacityFactor)
 
void refresh ()
 

Protected Attributes

double opacity = NaN
 
double ringSize = NaN
 
double fadingDistance = NaN
 
double fadingFactor = NaN
 
double waveLength = NaN
 
double waveWidth = NaN
 
double waveOffset = NaN
 
double waveOpacityFactor = NaN
 
std::vector< cRingFigure * > rings
 
std::vector< cOvalFigure * > waves
 
Rectangle bounds
 
double innerRx = NaN
 
double innerRy = NaN
 

Constructor & Destructor Documentation

inet::SignalFigure::SignalFigure ( const char *  name = nullptr)
22  :
23  cGroupFigure(name)
24 {
25 }

Member Function Documentation

double inet::SignalFigure::getFadingDistance ( ) const
inline
58 { return fadingDistance; }
double fadingDistance
Definition: SignalFigure.h:30
double inet::SignalFigure::getFadingFactor ( ) const
inline
61 { return fadingFactor; }
double fadingFactor
Definition: SignalFigure.h:31
int inet::SignalFigure::getRingCount ( ) const
inline
52 { return rings.size(); }
std::vector< cRingFigure * > rings
Definition: SignalFigure.h:36
double inet::SignalFigure::getRingSize ( ) const
inline
55 { return ringSize; }
double ringSize
Definition: SignalFigure.h:29
int inet::SignalFigure::getWaveCount ( ) const
inline
64 { return waves.size(); }
std::vector< cOvalFigure * > waves
Definition: SignalFigure.h:37
double inet::SignalFigure::getWaveLength ( ) const
inline

Referenced by inet::visualizer::MediumCanvasVisualizer::refreshSignalFigure().

67 { return waveLength; }
double waveLength
Definition: SignalFigure.h:32
double inet::SignalFigure::getWaveOffset ( ) const
inline
73 { return waveOffset; }
double waveOffset
Definition: SignalFigure.h:34
double inet::SignalFigure::getWaveOpacityFactor ( ) const
inline
76 { return waveOpacityFactor; }
double waveOpacityFactor
Definition: SignalFigure.h:35
double inet::SignalFigure::getWaveWidth ( ) const
inline
70 { return waveWidth; }
double waveWidth
Definition: SignalFigure.h:33
void inet::SignalFigure::refresh ( )

Referenced by inet::visualizer::MediumCanvasVisualizer::createSignalFigure(), and inet::visualizer::MediumCanvasVisualizer::refreshSignalFigure().

58 {
59  auto center = bounds.getCenter();
60  auto size = bounds.getSize() / 2;
61  for (int i = 0; i < rings.size(); i++) {
62  auto ring = rings[i];
63  bool isLast = i == rings.size() - 1;
64  double minR = i * ringSize;
65  double maxRx = isLast ? DBL_MAX : minR + ringSize;
66  double maxRy = isLast ? DBL_MAX : minR + ringSize;
67  double innerRx = std::max(minR, std::min(maxRx, this->innerRx));
68  double innerRy = std::max(minR, std::min(maxRy, this->innerRy));
69  ring->setInnerRx(innerRx);
70  ring->setInnerRy(innerRy);
71  double outerRx = isLast ? size.x : std::min(size.x, maxRx);
72  double outerRy = isLast ? size.y : std::min(size.y, maxRy);
73  ring->setBounds(cFigure::Rectangle(center.x - outerRx, center.y - outerRy, 2 * outerRx, 2 * outerRy));
74  ring->setVisible(innerRx < outerRx && innerRy < outerRy);
75  }
76  for (int i = 0; i < waves.size(); i++) {
77  auto wave = waves[i];
78  bool isLast = i == waves.size() - 1;
79  double radius = waveOffset + i * waveLength;
80  double outerRx = isLast ? size.x : std::min(size.x, radius);
81  double outerRy = isLast ? size.y : std::min(size.y, radius);
82  wave->setLineWidth(waveWidth);
83  wave->setBounds(cFigure::Rectangle(center.x - outerRx, center.y - outerRy, 2 * outerRx, 2 * outerRy));
84  wave->setVisible(innerRx < radius && innerRy < radius && radius < size.x && radius < size.y);
85  }
86  for (int i = 0; i < rings.size(); i++)
87  rings[i]->setFillOpacity(opacity / pow(fadingFactor, i * ringSize / fadingDistance));
88  for (int i = 0; i < waves.size(); i++)
89  waves[i]->setLineOpacity(waveOpacityFactor * opacity / pow(fadingFactor, i * waveLength / fadingDistance));
90 }
double ringSize
Definition: SignalFigure.h:29
double innerRx
Definition: SignalFigure.h:40
double innerRy
Definition: SignalFigure.h:41
double waveLength
Definition: SignalFigure.h:32
double waveOpacityFactor
Definition: SignalFigure.h:35
double min(const double a, const double b)
Returns the minimum of a and b.
Definition: SCTPAssociation.h:270
double fadingFactor
Definition: SignalFigure.h:31
double waveOffset
Definition: SignalFigure.h:34
double opacity
Definition: SignalFigure.h:28
double max(double a, double b)
Returns the greater of the given parameters.
Definition: INETMath.h:161
Rectangle bounds
Definition: SignalFigure.h:39
std::vector< cOvalFigure * > waves
Definition: SignalFigure.h:37
std::vector< cRingFigure * > rings
Definition: SignalFigure.h:36
double fadingDistance
Definition: SignalFigure.h:30
double waveWidth
Definition: SignalFigure.h:33
void inet::SignalFigure::setBounds ( const cFigure::Rectangle &  bounds)
inline
void inet::SignalFigure::setColor ( const cFigure::Color &  color)

Referenced by inet::visualizer::MediumCanvasVisualizer::createSignalFigure().

28 {
29  for (auto ring : rings)
30  ring->setFillColor(color);
31  for (auto wave : waves)
32  wave->setLineColor(color);
33 }
std::vector< cOvalFigure * > waves
Definition: SignalFigure.h:37
std::vector< cRingFigure * > rings
Definition: SignalFigure.h:36
void inet::SignalFigure::setFadingDistance ( double  fadingDistance)
inline

Referenced by inet::visualizer::MediumCanvasVisualizer::createSignalFigure().

59 { this->fadingDistance = fadingDistance; }
double fadingDistance
Definition: SignalFigure.h:30
void inet::SignalFigure::setFadingFactor ( double  fadingFactor)
inline

Referenced by inet::visualizer::MediumCanvasVisualizer::createSignalFigure().

62 { this->fadingFactor = fadingFactor; }
double fadingFactor
Definition: SignalFigure.h:31
void inet::SignalFigure::setInnerRx ( double  innerRx)
inline

Referenced by inet::visualizer::MediumCanvasVisualizer::refreshSignalFigure().

49 { this->innerRx = innerRx; }
double innerRx
Definition: SignalFigure.h:40
void inet::SignalFigure::setInnerRy ( double  innerRy)
inline

Referenced by inet::visualizer::MediumCanvasVisualizer::refreshSignalFigure().

50 { this->innerRy = innerRy; }
double innerRy
Definition: SignalFigure.h:41
void inet::SignalFigure::setOpacity ( double  opacity)
inline

Referenced by inet::visualizer::MediumCanvasVisualizer::createSignalFigure().

47 { this->opacity = opacity; }
double opacity
Definition: SignalFigure.h:28
void inet::SignalFigure::setRingCount ( int  count)

Referenced by inet::visualizer::MediumCanvasVisualizer::createSignalFigure().

36 {
37  for (int i = 0; i < count; i++) {
38  auto ring = new cRingFigure("wave power");
39  ring->setFilled(true);
40  ring->setOutlined(false);
41  rings.push_back(ring);
42  addFigure(ring);
43  }
44 }
int count(const std::vector< T > &v, const T &a)
Definition: stlutils.h:58
std::vector< cRingFigure * > rings
Definition: SignalFigure.h:36
void inet::SignalFigure::setRingSize ( double  ringSize)
inline

Referenced by inet::visualizer::MediumCanvasVisualizer::createSignalFigure().

56 { this->ringSize = ringSize; }
double ringSize
Definition: SignalFigure.h:29
void inet::SignalFigure::setWaveCount ( int  count)

Referenced by inet::visualizer::MediumCanvasVisualizer::createSignalFigure().

47 {
48  for (int i = 0; i < count; i++) {
49  auto wave = new cOvalFigure("wave crest");
50  wave->setFilled(false);
51  wave->setOutlined(true);
52  waves.push_back(wave);
53  addFigure(wave);
54  }
55 }
int count(const std::vector< T > &v, const T &a)
Definition: stlutils.h:58
std::vector< cOvalFigure * > waves
Definition: SignalFigure.h:37
void inet::SignalFigure::setWaveLength ( double  waveLength)
inline

Referenced by inet::visualizer::MediumCanvasVisualizer::createSignalFigure().

68 { this->waveLength = waveLength; }
double waveLength
Definition: SignalFigure.h:32
void inet::SignalFigure::setWaveOffset ( double  waveOffset)
inline

Referenced by inet::visualizer::MediumCanvasVisualizer::refreshSignalFigure().

74 { this->waveOffset = waveOffset; }
double waveOffset
Definition: SignalFigure.h:34
void inet::SignalFigure::setWaveOpacityFactor ( double  waveOpacityFactor)
inline
void inet::SignalFigure::setWaveWidth ( double  waveWidth)
inline

Referenced by inet::visualizer::MediumCanvasVisualizer::createSignalFigure().

71 { this->waveWidth = waveWidth; }
double waveWidth
Definition: SignalFigure.h:33

Member Data Documentation

Rectangle inet::SignalFigure::bounds
protected

Referenced by refresh().

double inet::SignalFigure::fadingDistance = NaN
protected

Referenced by refresh().

double inet::SignalFigure::fadingFactor = NaN
protected

Referenced by refresh().

double inet::SignalFigure::innerRx = NaN
protected

Referenced by refresh().

double inet::SignalFigure::innerRy = NaN
protected

Referenced by refresh().

double inet::SignalFigure::opacity = NaN
protected

Referenced by refresh().

std::vector<cRingFigure *> inet::SignalFigure::rings
protected

Referenced by refresh(), setColor(), and setRingCount().

double inet::SignalFigure::ringSize = NaN
protected

Referenced by refresh().

double inet::SignalFigure::waveLength = NaN
protected

Referenced by refresh().

double inet::SignalFigure::waveOffset = NaN
protected

Referenced by refresh().

double inet::SignalFigure::waveOpacityFactor = NaN
protected

Referenced by refresh().

std::vector<cOvalFigure *> inet::SignalFigure::waves
protected

Referenced by refresh(), setColor(), and setWaveCount().

double inet::SignalFigure::waveWidth = NaN
protected

Referenced by refresh().


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