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

#include <BarFigure.h>

Inheritance diagram for inet::BarFigure:

Public Member Functions

 BarFigure (const char *name=nullptr)
 
void setColor (const cFigure::Color &color)
 
void setSpacing (double spacing)
 
void setMinValue (double minValue)
 
void setMaxValue (double maxValue)
 
void setValue (double value)
 

Protected Member Functions

virtual void refreshDisplay ()
 

Protected Attributes

double value = NaN
 
double minValue = NaN
 
double maxValue = NaN
 
double spacing = 2
 
cRectangleFigure * valueFigure = nullptr
 

Constructor & Destructor Documentation

inet::BarFigure::BarFigure ( const char *  name = nullptr)
22  :
23  cRectangleFigure(name)
24 {
25  valueFigure = new cRectangleFigure();
26  valueFigure->setFilled(true);
27  addFigure(valueFigure);
28 }
cRectangleFigure * valueFigure
Definition: BarFigure.h:32

Member Function Documentation

void inet::BarFigure::refreshDisplay ( )
protectedvirtual

Referenced by setValue().

39 {
40  auto alpha = (value - minValue) / (maxValue - minValue);
41  alpha = std::min(std::max(alpha, 0.0), 1.0);
42  auto& bounds = getBounds();
43  auto height = (bounds.height - 2 * spacing) * alpha;
44  valueFigure->setBounds(cFigure::Rectangle(spacing, bounds.height - spacing - height, bounds.width - 2 * spacing, height));
45 }
double min(const double a, const double b)
Returns the minimum of a and b.
Definition: SCTPAssociation.h:270
double spacing
Definition: BarFigure.h:31
double max(double a, double b)
Returns the greater of the given parameters.
Definition: INETMath.h:161
cRectangleFigure * valueFigure
Definition: BarFigure.h:32
double minValue
Definition: BarFigure.h:29
double maxValue
Definition: BarFigure.h:30
double value
Definition: BarFigure.h:28
const value< double, units::unit > alpha(7.2973525376e-3)
void inet::BarFigure::setColor ( const cFigure::Color &  color)
inline
40 { valueFigure->setFillColor(color); }
cRectangleFigure * valueFigure
Definition: BarFigure.h:32
void inet::BarFigure::setMaxValue ( double  maxValue)
inline
44 { this->maxValue = maxValue; }
double maxValue
Definition: BarFigure.h:30
void inet::BarFigure::setMinValue ( double  minValue)
inline
43 { this->minValue = minValue; }
double minValue
Definition: BarFigure.h:29
void inet::BarFigure::setSpacing ( double  spacing)
inline
42 { this->spacing = spacing; }
double spacing
Definition: BarFigure.h:31
void inet::BarFigure::setValue ( double  value)

Referenced by inet::visualizer::EnergyStorageCanvasVisualizer::refreshEnergyStorageVisualization().

31 {
32  if (this->value != value) {
33  this->value = value;
35  }
36 }
virtual void refreshDisplay()
Definition: BarFigure.cc:38
double value
Definition: BarFigure.h:28

Member Data Documentation

double inet::BarFigure::maxValue = NaN
protected

Referenced by refreshDisplay().

double inet::BarFigure::minValue = NaN
protected

Referenced by refreshDisplay().

double inet::BarFigure::spacing = 2
protected

Referenced by refreshDisplay().

double inet::BarFigure::value = NaN
protected

Referenced by refreshDisplay(), and setValue().

cRectangleFigure* inet::BarFigure::valueFigure = nullptr
protected

Referenced by BarFigure(), and refreshDisplay().


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