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

#include <TracingObstacleLossCanvasVisualizer.h>

Inheritance diagram for inet::visualizer::TracingObstacleLossCanvasVisualizer:
inet::visualizer::TracingObstacleLossVisualizerBase inet::visualizer::VisualizerBase

Classes

class  ObstacleLossCanvasVisualization
 

Protected Member Functions

virtual void initialize (int stage) override
 
virtual void refreshDisplay () const override
 
virtual const ObstacleLossVisualizationcreateObstacleLossVisualization (const ITracingObstacleLoss::ObstaclePenetratedEvent *obstaclePenetratedEvent) const override
 
virtual void addObstacleLossVisualization (const ObstacleLossVisualization *obstacleLossVisualization) override
 
virtual void removeObstacleLossVisualization (const ObstacleLossVisualization *obstacleLossVisualization) override
 
virtual void setAlpha (const ObstacleLossVisualization *obstacleLossVisualization, double alpha) const override
 
- Protected Member Functions inherited from inet::visualizer::TracingObstacleLossVisualizerBase
virtual void subscribe ()
 
virtual void unsubscribe ()
 
- 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
 
Graphics
const CanvasProjectioncanvasProjection = nullptr
 The 2D projection used on the canvas. More...
 
cGroupFigure * obstacleLossLayer = nullptr
 The layer figure that contains the figures representing the obstacle losses. More...
 
- Protected Attributes inherited from inet::visualizer::TracingObstacleLossVisualizerBase
std::vector< const ObstacleLossVisualization * > obstacleLossVisualizations
 
bool displayIntersections = false
 
cFigure::Color intersectionLineColor
 
cFigure::LineStyle intersectionLineStyle
 
double intersectionLineWidth = NaN
 
bool displayFaceNormalVectors = false
 
cFigure::Color faceNormalLineColor
 
cFigure::LineStyle faceNormalLineStyle
 
double faceNormalLineWidth = NaN
 
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::TracingObstacleLossVisualizerBase
virtual ~TracingObstacleLossVisualizerBase ()
 
virtual void receiveSignal (cComponent *source, simsignal_t signal, cObject *object, cObject *details) override
 

Member Function Documentation

void inet::visualizer::TracingObstacleLossCanvasVisualizer::addObstacleLossVisualization ( const ObstacleLossVisualization obstacleLossVisualization)
overrideprotectedvirtual

Reimplemented from inet::visualizer::TracingObstacleLossVisualizerBase.

120 {
122  auto obstacleLossCanvasVisualization = static_cast<const ObstacleLossCanvasVisualization *>(obstacleLossVisualization);
124  obstacleLossLayer->addFigure(obstacleLossCanvasVisualization->intersectionFigure);
126  obstacleLossLayer->addFigure(obstacleLossCanvasVisualization->faceNormalFigure1);
127  obstacleLossLayer->addFigure(obstacleLossCanvasVisualization->faceNormalFigure2);
128  }
129 }
bool displayFaceNormalVectors
Definition: TracingObstacleLossVisualizerBase.h:51
virtual void addObstacleLossVisualization(const ObstacleLossVisualization *obstacleLossVisualization)
Definition: TracingObstacleLossVisualizerBase.cc:108
bool displayIntersections
Definition: TracingObstacleLossVisualizerBase.h:47
cGroupFigure * obstacleLossLayer
The layer figure that contains the figures representing the obstacle losses.
Definition: TracingObstacleLossCanvasVisualizer.h:60
const TracingObstacleLossVisualizerBase::ObstacleLossVisualization * inet::visualizer::TracingObstacleLossCanvasVisualizer::createObstacleLossVisualization ( const ITracingObstacleLoss::ObstaclePenetratedEvent obstaclePenetratedEvent) const
overrideprotectedvirtual

Implements inet::visualizer::TracingObstacleLossVisualizerBase.

63 {
64  auto object = obstaclePenetratedEvent->object;
65  auto intersection1 = obstaclePenetratedEvent->intersection1;
66  auto intersection2 = obstaclePenetratedEvent->intersection2;
67  auto normal1 = obstaclePenetratedEvent->normal1;
68  auto normal2 = obstaclePenetratedEvent->normal2;
69  auto loss = obstaclePenetratedEvent->loss;
70  const Rotation rotation(object->getOrientation());
71  const Coord& position = object->getPosition();
72  const Coord rotatedIntersection1 = rotation.rotateVectorClockwise(intersection1);
73  const Coord rotatedIntersection2 = rotation.rotateVectorClockwise(intersection2);
74  double intersectionDistance = intersection2.distance(intersection1);
75  LabeledLineFigure *intersectionLine = nullptr;
77  intersectionLine = new LabeledLineFigure("intersection");
78  intersectionLine->setTags((std::string("obstacle_loss ") + tags).c_str());
79  intersectionLine->setTooltip("This line represents the intersection of a propagating signal and an obstructing physical object.");
80  intersectionLine->setStart(canvasProjection->computeCanvasPoint(rotatedIntersection1 + position));
81  intersectionLine->setEnd(canvasProjection->computeCanvasPoint(rotatedIntersection2 + position));
82  auto lineFigure = intersectionLine->getLineFigure();
83  lineFigure->setLineColor(intersectionLineColor);
84  lineFigure->setLineStyle(intersectionLineStyle);
85  lineFigure->setLineWidth(intersectionLineWidth);
86  lineFigure->setZoomLineWidth(false);
87  auto labelFigure = intersectionLine->getLabelFigure();
88  char tmp[32];
89  sprintf(tmp, "%.4g dB", inet::math::fraction2dB(loss));
90  labelFigure->setText(tmp);
91  }
92  cLineFigure *faceNormal1Line = nullptr;
93  cLineFigure *faceNormal2Line = nullptr;
95  Coord normalVisualization1 = normal1 / normal1.length() * intersectionDistance / 10;
96  Coord normalVisualization2 = normal2 / normal2.length() * intersectionDistance / 10;
97  faceNormal1Line = new cLineFigure("normal1");
98  faceNormal1Line->setTags((std::string("obstacle_loss face_normal_vector ") + tags).c_str());
99  faceNormal1Line->setTooltip("This line represents the face normal vector at the intersection of a propagating signal and an obstructing physical object.");
100  faceNormal1Line->setStart(canvasProjection->computeCanvasPoint(rotatedIntersection1 + position));
101  faceNormal1Line->setEnd(canvasProjection->computeCanvasPoint(rotatedIntersection1 + position + rotation.rotateVectorClockwise(normalVisualization1)));
102  faceNormal1Line->setLineColor(faceNormalLineColor);
103  faceNormal1Line->setLineStyle(faceNormalLineStyle);
104  faceNormal1Line->setLineWidth(faceNormalLineWidth);
105  faceNormal1Line->setZoomLineWidth(false);
106  faceNormal2Line = new cLineFigure("normal2");
107  faceNormal2Line->setTags((std::string("obstacle_loss face_normal_vector ") + tags).c_str());
108  faceNormal2Line->setTooltip("This line represents the face normal vector at the intersection of a propagating signal and an obstructing physical object.");
109  faceNormal2Line->setStart(canvasProjection->computeCanvasPoint(rotatedIntersection2 + position));
110  faceNormal2Line->setEnd(canvasProjection->computeCanvasPoint(rotatedIntersection2 + position + rotation.rotateVectorClockwise(normalVisualization2)));
111  faceNormal2Line->setLineColor(faceNormalLineColor);
112  faceNormal2Line->setLineStyle(faceNormalLineStyle);
113  faceNormal2Line->setLineWidth(faceNormalLineWidth);
114  faceNormal2Line->setZoomLineWidth(false);
115  }
116  return new ObstacleLossCanvasVisualization(intersectionLine, faceNormal1Line, faceNormal2Line);
117 }
const char * tags
Definition: VisualizerBase.h:32
double intersectionLineWidth
Definition: TracingObstacleLossVisualizerBase.h:50
cFigure::Color intersectionLineColor
Definition: TracingObstacleLossVisualizerBase.h:48
double fraction2dB(double fraction)
Convert a fraction value to dB.
Definition: INETMath.h:171
cFigure::LineStyle intersectionLineStyle
Definition: TracingObstacleLossVisualizerBase.h:49
bool displayFaceNormalVectors
Definition: TracingObstacleLossVisualizerBase.h:51
cFigure::LineStyle faceNormalLineStyle
Definition: TracingObstacleLossVisualizerBase.h:53
double faceNormalLineWidth
Definition: TracingObstacleLossVisualizerBase.h:54
const CanvasProjection * canvasProjection
The 2D projection used on the canvas.
Definition: TracingObstacleLossCanvasVisualizer.h:56
cFigure::Point computeCanvasPoint(const Coord &point) const
Definition: CanvasProjection.cc:32
bool displayIntersections
Definition: TracingObstacleLossVisualizerBase.h:47
cFigure::Color faceNormalLineColor
Definition: TracingObstacleLossVisualizerBase.h:52
void inet::visualizer::TracingObstacleLossCanvasVisualizer::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::visualizer::TracingObstacleLossVisualizerBase.

42 {
44  if (!hasGUI()) return;
45  if (stage == INITSTAGE_LOCAL) {
46  zIndex = par("zIndex");
47  cCanvas *canvas = visualizerTargetModule->getCanvas();
48  obstacleLossLayer = new cGroupFigure("obstacle_loss");
49  obstacleLossLayer->setZIndex(zIndex);
50  obstacleLossLayer->insertBefore(canvas->getSubmodulesLayer());
51  }
52  else if (stage == INITSTAGE_PHYSICAL_ENVIRONMENT)
54 }
virtual void initialize(int stage) override
Definition: TracingObstacleLossVisualizerBase.cc:34
Physical environment initializations (mobility, obstacles, battery, annotations, etc).
Definition: InitStages.h:40
double zIndex
Definition: TracingObstacleLossCanvasVisualizer.h:48
Local initializations.
Definition: InitStages.h:35
cModule * visualizerTargetModule
Definition: VisualizerBase.h:31
const CanvasProjection * canvasProjection
The 2D projection used on the canvas.
Definition: TracingObstacleLossCanvasVisualizer.h:56
static const CanvasProjection * getCanvasProjection(const cCanvas *canvas)
Definition: CanvasProjection.cc:38
cGroupFigure * obstacleLossLayer
The layer figure that contains the figures representing the obstacle losses.
Definition: TracingObstacleLossCanvasVisualizer.h:60
void inet::visualizer::TracingObstacleLossCanvasVisualizer::refreshDisplay ( ) const
overrideprotectedvirtual

Reimplemented from inet::visualizer::TracingObstacleLossVisualizerBase.

57 {
59  visualizerTargetModule->getCanvas()->setAnimationSpeed(obstacleLossVisualizations.empty() ? 0 : fadeOutAnimationSpeed, this);
60 }
std::vector< const ObstacleLossVisualization * > obstacleLossVisualizations
Definition: TracingObstacleLossVisualizerBase.h:60
cModule * visualizerTargetModule
Definition: VisualizerBase.h:31
double fadeOutAnimationSpeed
Definition: TracingObstacleLossVisualizerBase.h:57
virtual void refreshDisplay() const override
Definition: TracingObstacleLossVisualizerBase.cc:55
void inet::visualizer::TracingObstacleLossCanvasVisualizer::removeObstacleLossVisualization ( const ObstacleLossVisualization obstacleLossVisualization)
overrideprotectedvirtual

Reimplemented from inet::visualizer::TracingObstacleLossVisualizerBase.

132 {
134  auto obstacleLossCanvasVisualization = static_cast<const ObstacleLossCanvasVisualization *>(obstacleLossVisualization);
136  obstacleLossLayer->removeFigure(obstacleLossCanvasVisualization->intersectionFigure);
138  obstacleLossLayer->removeFigure(obstacleLossCanvasVisualization->faceNormalFigure1);
139  obstacleLossLayer->removeFigure(obstacleLossCanvasVisualization->faceNormalFigure2);
140  }
141 }
bool displayFaceNormalVectors
Definition: TracingObstacleLossVisualizerBase.h:51
virtual void removeObstacleLossVisualization(const ObstacleLossVisualization *obstacleLossVisualization)
Definition: TracingObstacleLossVisualizerBase.cc:113
bool displayIntersections
Definition: TracingObstacleLossVisualizerBase.h:47
cGroupFigure * obstacleLossLayer
The layer figure that contains the figures representing the obstacle losses.
Definition: TracingObstacleLossCanvasVisualizer.h:60
void inet::visualizer::TracingObstacleLossCanvasVisualizer::setAlpha ( const ObstacleLossVisualization obstacleLossVisualization,
double  alpha 
) const
overrideprotectedvirtual

Implements inet::visualizer::TracingObstacleLossVisualizerBase.

144 {
145  auto obstacleLossCanvasVisualization = static_cast<const ObstacleLossCanvasVisualization *>(obstacleLossVisualization);
147  obstacleLossCanvasVisualization->intersectionFigure->getLineFigure()->setLineOpacity(alpha);
149  obstacleLossCanvasVisualization->faceNormalFigure1->setLineOpacity(alpha);
150  obstacleLossCanvasVisualization->faceNormalFigure2->setLineOpacity(alpha);
151  }
152 }
bool displayFaceNormalVectors
Definition: TracingObstacleLossVisualizerBase.h:51
const value< double, units::unit > alpha(7.2973525376e-3)
bool displayIntersections
Definition: TracingObstacleLossVisualizerBase.h:47

Member Data Documentation

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

The 2D projection used on the canvas.

Referenced by createObstacleLossVisualization(), and initialize().

cGroupFigure* inet::visualizer::TracingObstacleLossCanvasVisualizer::obstacleLossLayer = nullptr
protected

The layer figure that contains the figures representing the obstacle losses.

Referenced by addObstacleLossVisualization(), initialize(), and removeObstacleLossVisualization().

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

Referenced by initialize().


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