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

#include <EnergyStorageCanvasVisualizer.h>

Inheritance diagram for inet::visualizer::EnergyStorageCanvasVisualizer:
inet::visualizer::EnergyStorageVisualizerBase inet::visualizer::VisualizerBase

Classes

class  EnergyStorageCanvasVisualization
 

Protected Member Functions

virtual void initialize (int stage) override
 
virtual EnergyStorageVisualizationcreateEnergyStorageVisualization (const IEnergyStorage *energyStorage) const override
 
virtual void addEnergyStorageVisualization (const EnergyStorageVisualization *energyStorageVisualization) override
 
virtual void removeEnergyStorageVisualization (const EnergyStorageVisualization *energyStorageVisualization) override
 
virtual void refreshEnergyStorageVisualization (const EnergyStorageVisualization *energyStorageVisualization) const override
 
- Protected Member Functions inherited from inet::visualizer::EnergyStorageVisualizerBase
virtual void handleParameterChange (const char *name) override
 
virtual void refreshDisplay () const override
 
virtual double getNominalCapacity (const IEnergyStorage *energyStorage) const
 
virtual double getResidualCapacity (const IEnergyStorage *energyStorage) const
 
virtual void addEnergyStorageVisualizations ()
 
virtual void removeAllEnergyStorageVisualizations ()
 
- 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::EnergyStorageVisualizerBase
std::vector< const EnergyStorageVisualization * > energyStorageVisualizations
 
bool displayEnergyStorages = false
 
ModuleFilter energyStorageFilter
 
cFigure::Color color
 
double width
 
double height
 
double spacing
 
Displacement displacementHint
 
double displacementPriority
 
- Protected Attributes inherited from inet::visualizer::VisualizerBase
cModule * visualizerTargetModule = nullptr
 
const char * tags = nullptr
 

Member Function Documentation

void inet::visualizer::EnergyStorageCanvasVisualizer::addEnergyStorageVisualization ( const EnergyStorageVisualization energyStorageVisualization)
overrideprotectedvirtual

Reimplemented from inet::visualizer::EnergyStorageVisualizerBase.

67 {
69  auto energyStorageCanvasVisualization = static_cast<const EnergyStorageCanvasVisualization *>(energyStorageVisualization);
70  auto figure = energyStorageCanvasVisualization->figure;
71  energyStorageCanvasVisualization->networkNodeVisualization->addAnnotation(figure, figure->getBounds().getSize(), displacementHint, displacementPriority);
72 }
Displacement displacementHint
Definition: EnergyStorageVisualizerBase.h:54
double displacementPriority
Definition: EnergyStorageVisualizerBase.h:55
virtual void addEnergyStorageVisualization(const EnergyStorageVisualization *energyStorageVisualization)
Definition: EnergyStorageVisualizerBase.cc:86
EnergyStorageVisualizerBase::EnergyStorageVisualization * inet::visualizer::EnergyStorageCanvasVisualizer::createEnergyStorageVisualization ( const IEnergyStorage energyStorage) const
overrideprotectedvirtual

Implements inet::visualizer::EnergyStorageVisualizerBase.

50 {
51  auto module = check_and_cast<const cModule *>(energyStorage);
52  auto figure = new BarFigure("energyStorage");
53  figure->setTags((std::string("energyStorage ") + tags).c_str());
54  figure->setTooltip("This figure represents an energy storage");
55  figure->setAssociatedObject(const_cast<cModule *>(module));
56  figure->setBounds(cFigure::Rectangle(0, 0, width, height));
57  figure->setSpacing(spacing);
58  figure->setColor(color);
59  figure->setMinValue(0);
60  figure->setMaxValue(getNominalCapacity(energyStorage));
61  auto networkNode = getContainingNode(module);
62  auto networkNodeVisualization = networkNodeVisualizer->getNetworkNodeVisualization(networkNode);
63  return new EnergyStorageCanvasVisualization(networkNodeVisualization, figure, energyStorage);
64 }
const char * tags
Definition: VisualizerBase.h:32
double height
Definition: EnergyStorageVisualizerBase.h:52
double width
Definition: EnergyStorageVisualizerBase.h:51
virtual NetworkNodeCanvasVisualization * getNetworkNodeVisualization(const cModule *networkNode) const
Definition: NetworkNodeCanvasVisualizer.cc:63
NetworkNodeCanvasVisualizer * networkNodeVisualizer
Definition: EnergyStorageCanvasVisualizer.h:45
cModule * getContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:65
cFigure::Color color
Definition: EnergyStorageVisualizerBase.h:50
virtual double getNominalCapacity(const IEnergyStorage *energyStorage) const
Definition: EnergyStorageVisualizerBase.cc:66
double spacing
Definition: EnergyStorageVisualizerBase.h:53
void inet::visualizer::EnergyStorageCanvasVisualizer::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::visualizer::EnergyStorageVisualizerBase.

40 {
42  if (!hasGUI()) return;
43  if (stage == INITSTAGE_LOCAL) {
44  zIndex = par("zIndex");
45  networkNodeVisualizer = getModuleFromPar<NetworkNodeCanvasVisualizer>(par("networkNodeVisualizerModule"), this);
46  }
47 }
double zIndex
Definition: EnergyStorageCanvasVisualizer.h:44
Local initializations.
Definition: InitStages.h:35
NetworkNodeCanvasVisualizer * networkNodeVisualizer
Definition: EnergyStorageCanvasVisualizer.h:45
virtual void initialize(int stage) override
Definition: EnergyStorageVisualizerBase.cc:32
void inet::visualizer::EnergyStorageCanvasVisualizer::refreshEnergyStorageVisualization ( const EnergyStorageVisualization energyStorageVisualization) const
overrideprotectedvirtual

Implements inet::visualizer::EnergyStorageVisualizerBase.

83 {
84  auto energyStorageCanvasVisualization = static_cast<const EnergyStorageCanvasVisualization *>(energyStorageVisualization);
85  auto energyStorage = energyStorageVisualization->energyStorage;
86  auto figure = energyStorageCanvasVisualization->figure;
87  figure->setValue(getResidualCapacity(energyStorage));
88 }
virtual double getResidualCapacity(const IEnergyStorage *energyStorage) const
Definition: EnergyStorageVisualizerBase.cc:76
void inet::visualizer::EnergyStorageCanvasVisualizer::removeEnergyStorageVisualization ( const EnergyStorageVisualization energyStorageVisualization)
overrideprotectedvirtual

Reimplemented from inet::visualizer::EnergyStorageVisualizerBase.

75 {
77  auto energyStorageCanvasVisualization = static_cast<const EnergyStorageCanvasVisualization *>(energyStorageVisualization);
78  auto figure = energyStorageCanvasVisualization->figure;
79  energyStorageCanvasVisualization->networkNodeVisualization->removeAnnotation(figure);
80 }
virtual void removeEnergyStorageVisualization(const EnergyStorageVisualization *energyStorageVisualization)
Definition: EnergyStorageVisualizerBase.cc:91

Member Data Documentation

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

Referenced by initialize().


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