INET Framework for OMNeT++/OMNEST
inet::visualizer::TracingObstacleLossVisualizerBase Class Referenceabstract

#include <TracingObstacleLossVisualizerBase.h>

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

Classes

class  ObstacleLossVisualization
 

Public Member Functions

virtual ~TracingObstacleLossVisualizerBase ()
 
virtual void receiveSignal (cComponent *source, simsignal_t signal, cObject *object, cObject *details) override
 

Protected Member Functions

virtual void initialize (int stage) override
 
virtual void refreshDisplay () const override
 
virtual void subscribe ()
 
virtual void unsubscribe ()
 
virtual const ObstacleLossVisualizationcreateObstacleLossVisualization (const ITracingObstacleLoss::ObstaclePenetratedEvent *obstaclePenetratedEvent) const =0
 
virtual void addObstacleLossVisualization (const ObstacleLossVisualization *obstacleLossVisualization)
 
virtual void removeObstacleLossVisualization (const ObstacleLossVisualization *obstacleLossVisualization)
 
virtual void setAlpha (const ObstacleLossVisualization *obstacleLossVisualization, double alpha) const =0
 
- 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

std::vector< const ObstacleLossVisualization * > obstacleLossVisualizations
 
Parameters
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
 

Constructor & Destructor Documentation

inet::visualizer::TracingObstacleLossVisualizerBase::~TracingObstacleLossVisualizerBase ( )
virtual
29 {
31  unsubscribe();
32 }
virtual void unsubscribe()
Definition: TracingObstacleLossVisualizerBase.cc:86
bool displayIntersections
Definition: TracingObstacleLossVisualizerBase.h:47

Member Function Documentation

void inet::visualizer::TracingObstacleLossVisualizerBase::addObstacleLossVisualization ( const ObstacleLossVisualization obstacleLossVisualization)
protectedvirtual

Reimplemented in inet::visualizer::TracingObstacleLossCanvasVisualizer.

Referenced by inet::visualizer::TracingObstacleLossCanvasVisualizer::addObstacleLossVisualization().

109 {
110  obstacleLossVisualizations.push_back(obstacleLossVisualization);
111 }
std::vector< const ObstacleLossVisualization * > obstacleLossVisualizations
Definition: TracingObstacleLossVisualizerBase.h:60
virtual const ObstacleLossVisualization* inet::visualizer::TracingObstacleLossVisualizerBase::createObstacleLossVisualization ( const ITracingObstacleLoss::ObstaclePenetratedEvent obstaclePenetratedEvent) const
protectedpure virtual
void inet::visualizer::TracingObstacleLossVisualizerBase::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::visualizer::VisualizerBase.

Reimplemented in inet::visualizer::TracingObstacleLossCanvasVisualizer, and inet::visualizer::TracingObstacleLossOsgVisualizer.

Referenced by inet::visualizer::TracingObstacleLossCanvasVisualizer::initialize().

35 {
37  if (!hasGUI()) return;
38  if (stage == INITSTAGE_LOCAL) {
39  displayIntersections = par("displayIntersections");
40  intersectionLineColor = cFigure::parseColor(par("intersectionLineColor"));
41  intersectionLineStyle = cFigure::parseLineStyle(par("intersectionLineStyle"));
42  intersectionLineWidth = par("intersectionLineWidth");
43  displayFaceNormalVectors = par("displayFaceNormalVectors");
44  faceNormalLineColor = cFigure::parseColor(par("faceNormalLineColor"));
45  faceNormalLineStyle = cFigure::parseLineStyle(par("faceNormalLineStyle"));
46  faceNormalLineWidth = par("faceNormalLineWidth");
47  fadeOutMode = par("fadeOutMode");
48  fadeOutTime = par("fadeOutTime");
49  fadeOutAnimationSpeed = par("fadeOutAnimationSpeed");
51  subscribe();
52  }
53 }
double intersectionLineWidth
Definition: TracingObstacleLossVisualizerBase.h:50
cFigure::Color intersectionLineColor
Definition: TracingObstacleLossVisualizerBase.h:48
double fadeOutTime
Definition: TracingObstacleLossVisualizerBase.h:56
virtual void initialize(int stage) override
Definition: VisualizerBase.cc:29
const char * fadeOutMode
Definition: TracingObstacleLossVisualizerBase.h:55
cFigure::LineStyle intersectionLineStyle
Definition: TracingObstacleLossVisualizerBase.h:49
virtual void subscribe()
Definition: TracingObstacleLossVisualizerBase.cc:80
Local initializations.
Definition: InitStages.h:35
bool displayFaceNormalVectors
Definition: TracingObstacleLossVisualizerBase.h:51
cFigure::LineStyle faceNormalLineStyle
Definition: TracingObstacleLossVisualizerBase.h:53
double fadeOutAnimationSpeed
Definition: TracingObstacleLossVisualizerBase.h:57
double faceNormalLineWidth
Definition: TracingObstacleLossVisualizerBase.h:54
bool displayIntersections
Definition: TracingObstacleLossVisualizerBase.h:47
cFigure::Color faceNormalLineColor
Definition: TracingObstacleLossVisualizerBase.h:52
void inet::visualizer::TracingObstacleLossVisualizerBase::receiveSignal ( cComponent *  source,
simsignal_t  signal,
cObject *  object,
cObject *  details 
)
overridevirtual
95 {
96  Enter_Method_Silent();
99  auto event = static_cast<ITracingObstacleLoss::ObstaclePenetratedEvent *>(object);
100  auto obstacleLossVisualization = createObstacleLossVisualization(event);
101  addObstacleLossVisualization(obstacleLossVisualization);
102  }
103  }
104  else
105  throw cRuntimeError("Unknown signal");
106 }
static simsignal_t obstaclePenetratedSignal
Definition: ITracingObstacleLoss.h:48
bool displayFaceNormalVectors
Definition: TracingObstacleLossVisualizerBase.h:51
virtual const ObstacleLossVisualization * createObstacleLossVisualization(const ITracingObstacleLoss::ObstaclePenetratedEvent *obstaclePenetratedEvent) const =0
virtual void addObstacleLossVisualization(const ObstacleLossVisualization *obstacleLossVisualization)
Definition: TracingObstacleLossVisualizerBase.cc:108
bool displayIntersections
Definition: TracingObstacleLossVisualizerBase.h:47
void inet::visualizer::TracingObstacleLossVisualizerBase::refreshDisplay ( ) const
overrideprotectedvirtual

Reimplemented in inet::visualizer::TracingObstacleLossCanvasVisualizer.

Referenced by inet::visualizer::TracingObstacleLossCanvasVisualizer::refreshDisplay().

56 {
57  AnimationPosition currentAnimationPosition;
58  std::vector<const ObstacleLossVisualization *> removedObstacleLossVisualizations;
59  for (auto obstacleLossVisualization : obstacleLossVisualizations) {
60  double delta;
61  if (!strcmp(fadeOutMode, "simulationTime"))
62  delta = (currentAnimationPosition.getSimulationTime() - obstacleLossVisualization->obstacleLossAnimationPosition.getSimulationTime()).dbl();
63  else if (!strcmp(fadeOutMode, "animationTime"))
64  delta = currentAnimationPosition.getAnimationTime() - obstacleLossVisualization->obstacleLossAnimationPosition.getAnimationTime();
65  else if (!strcmp(fadeOutMode, "realTime"))
66  delta = currentAnimationPosition.getRealTime() - obstacleLossVisualization->obstacleLossAnimationPosition.getRealTime();
67  else
68  throw cRuntimeError("Unknown fadeOutMode: %s", fadeOutMode);
69  if (delta > fadeOutTime)
70  removedObstacleLossVisualizations.push_back(obstacleLossVisualization);
71  else
72  setAlpha(obstacleLossVisualization, 1 - delta / fadeOutTime);
73  }
74  for (auto obstacleLossVisualization : removedObstacleLossVisualizations) {
75  const_cast<TracingObstacleLossVisualizerBase *>(this)->removeObstacleLossVisualization(obstacleLossVisualization);
76  delete obstacleLossVisualization;
77  }
78 }
double fadeOutTime
Definition: TracingObstacleLossVisualizerBase.h:56
const char * fadeOutMode
Definition: TracingObstacleLossVisualizerBase.h:55
std::vector< const ObstacleLossVisualization * > obstacleLossVisualizations
Definition: TracingObstacleLossVisualizerBase.h:60
virtual void removeObstacleLossVisualization(const ObstacleLossVisualization *obstacleLossVisualization)
Definition: TracingObstacleLossVisualizerBase.cc:113
virtual void setAlpha(const ObstacleLossVisualization *obstacleLossVisualization, double alpha) const =0
void inet::visualizer::TracingObstacleLossVisualizerBase::removeObstacleLossVisualization ( const ObstacleLossVisualization obstacleLossVisualization)
protectedvirtual

Reimplemented in inet::visualizer::TracingObstacleLossCanvasVisualizer.

Referenced by inet::visualizer::TracingObstacleLossCanvasVisualizer::removeObstacleLossVisualization().

114 {
116 }
void remove(std::vector< T > &v, const A &a)
Definition: stlutils.h:91
std::vector< const ObstacleLossVisualization * > obstacleLossVisualizations
Definition: TracingObstacleLossVisualizerBase.h:60
virtual void inet::visualizer::TracingObstacleLossVisualizerBase::setAlpha ( const ObstacleLossVisualization obstacleLossVisualization,
double  alpha 
) const
protectedpure virtual
void inet::visualizer::TracingObstacleLossVisualizerBase::subscribe ( )
protectedvirtual
81 {
82  auto subscriptionModule = getModuleFromPar<cModule>(par("subscriptionModule"), this);
83  subscriptionModule->subscribe(ITracingObstacleLoss::obstaclePenetratedSignal, this);
84 }
static simsignal_t obstaclePenetratedSignal
Definition: ITracingObstacleLoss.h:48
void inet::visualizer::TracingObstacleLossVisualizerBase::unsubscribe ( )
protectedvirtual
87 {
88  // NOTE: lookup the module again because it may have been deleted first
89  auto subscriptionModule = getModuleFromPar<cModule>(par("subscriptionModule"), this, false);
90  if (subscriptionModule != nullptr)
91  subscriptionModule->unsubscribe(ITracingObstacleLoss::obstaclePenetratedSignal, this);
92 }
static simsignal_t obstaclePenetratedSignal
Definition: ITracingObstacleLoss.h:48

Member Data Documentation

cFigure::Color inet::visualizer::TracingObstacleLossVisualizerBase::faceNormalLineColor
protected
cFigure::LineStyle inet::visualizer::TracingObstacleLossVisualizerBase::faceNormalLineStyle
protected
double inet::visualizer::TracingObstacleLossVisualizerBase::faceNormalLineWidth = NaN
protected
double inet::visualizer::TracingObstacleLossVisualizerBase::fadeOutAnimationSpeed = NaN
protected
const char* inet::visualizer::TracingObstacleLossVisualizerBase::fadeOutMode = nullptr
protected
double inet::visualizer::TracingObstacleLossVisualizerBase::fadeOutTime = NaN
protected
cFigure::Color inet::visualizer::TracingObstacleLossVisualizerBase::intersectionLineColor
protected
cFigure::LineStyle inet::visualizer::TracingObstacleLossVisualizerBase::intersectionLineStyle
protected
double inet::visualizer::TracingObstacleLossVisualizerBase::intersectionLineWidth = NaN
protected
std::vector<const ObstacleLossVisualization *> inet::visualizer::TracingObstacleLossVisualizerBase::obstacleLossVisualizations
protected

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