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

#include <HeatMapFigure.h>

Inheritance diagram for inet::HeatMapFigure:

Public Member Functions

 HeatMapFigure (int size, const char *name)
 
virtual const char * getClassNameForRenderer () const
 
virtual void heatPoint (int x, int y)
 
virtual void heatLine (int x1, int y1, int x2, int y2)
 
virtual void coolDown ()
 

Protected Member Functions

double getHeat (int x, int y)
 
void setHeat (int x, int y, double value)
 

Protected Attributes

double alpha = 0.5
 
double coolingSpeed = 0.01
 
cFigure::Color fromColor = cFigure::BLACK
 
cFigure::Color toColor = cFigure::RED
 
simtime_t lastCoolDown
 

Constructor & Destructor Documentation

◆ HeatMapFigure()

inet::HeatMapFigure::HeatMapFigure ( int  size,
const char *  name 
)
12  :
13  cPixmapFigure(name)
14 {
15  setPixmap(cFigure::Pixmap(size, size));
16  fillPixmap(fromColor, 0);
17 }

Member Function Documentation

◆ coolDown()

void inet::HeatMapFigure::coolDown ( )
virtual
70 {
71  double factor = exp(coolingSpeed * (lastCoolDown - simTime()).dbl());
72  if (factor < 0.9) {
73  lastCoolDown = simTime();
74  for (int x = 0; x < getPixmapWidth(); x++)
75  for (int y = 0; y < getPixmapHeight(); y++)
76  setHeat(x, y, getHeat(x, y) * factor);
77  }
78 }

◆ getClassNameForRenderer()

virtual const char* inet::HeatMapFigure::getClassNameForRenderer ( ) const
inlinevirtual
31 { return "cPixmapFigure"; }

◆ getHeat()

double inet::HeatMapFigure::getHeat ( int  x,
int  y 
)
protected
20 {
21  return getPixelOpacity(x, y);
22 }

Referenced by coolDown(), and heatPoint().

◆ heatLine()

void inet::HeatMapFigure::heatLine ( int  x1,
int  y1,
int  x2,
int  y2 
)
virtual
40 {
41  // NOTE: http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm
42  bool steep = (std::abs(y2 - y1) > std::abs(x2 - x1));
43  if (steep) {
44  std::swap(x1, y1);
45  std::swap(x2, y2);
46  }
47  if (x1 > x2) {
48  std::swap(x1, x2);
49  std::swap(y1, y2);
50  }
51  double dx = x2 - x1;
52  double dy = std::abs(y2 - y1);
53  double error = dx / 2.0f;
54  int yStep = (y1 < y2) ? 1 : -1;
55  int y = y1;
56  for (int x = x1; x <= x2; x++) {
57  if (steep)
58  heatPoint(y, x);
59  else
60  heatPoint(x, y);
61  error -= dy;
62  if (error < 0) {
63  y += yStep;
64  error += dx;
65  }
66  }
67 }

◆ heatPoint()

void inet::HeatMapFigure::heatPoint ( int  x,
int  y 
)
virtual
34 {
35  double value = alpha + (1 - alpha) * getHeat(x, y);
36  setHeat(x, y, value);
37 }

Referenced by heatLine().

◆ setHeat()

void inet::HeatMapFigure::setHeat ( int  x,
int  y,
double  value 
)
protected
25 {
26  cFigure::Color color(
27  (1 - value) * fromColor.red + value * toColor.red,
28  (1 - value) * fromColor.green + value * toColor.green,
29  (1 - value) * fromColor.blue + value * toColor.blue);
30  setPixel(x, y, color, value);
31 }

Referenced by coolDown(), and heatPoint().

Member Data Documentation

◆ alpha

double inet::HeatMapFigure::alpha = 0.5
protected

Referenced by heatPoint().

◆ coolingSpeed

double inet::HeatMapFigure::coolingSpeed = 0.01
protected

Referenced by coolDown().

◆ fromColor

cFigure::Color inet::HeatMapFigure::fromColor = cFigure::BLACK
protected

Referenced by HeatMapFigure(), and setHeat().

◆ lastCoolDown

simtime_t inet::HeatMapFigure::lastCoolDown
protected

Referenced by coolDown().

◆ toColor

cFigure::Color inet::HeatMapFigure::toColor = cFigure::RED
protected

Referenced by setHeat().


The documentation for this class was generated from the following files:
inet::HeatMapFigure::alpha
double alpha
Definition: HeatMapFigure.h:18
inet::HeatMapFigure::getHeat
double getHeat(int x, int y)
Definition: HeatMapFigure.cc:19
inet::swap
INET_ALWAYS_INLINE void swap(IntrusivePtr< T > &lhs, IntrusivePtr< T > &ptr) noexcept
Definition: IntrusivePtr.h:194
inet::HeatMapFigure::heatPoint
virtual void heatPoint(int x, int y)
Definition: HeatMapFigure.cc:33
inet::HeatMapFigure::lastCoolDown
simtime_t lastCoolDown
Definition: HeatMapFigure.h:22
inet::HeatMapFigure::fromColor
cFigure::Color fromColor
Definition: HeatMapFigure.h:20
inet::HeatMapFigure::toColor
cFigure::Color toColor
Definition: HeatMapFigure.h:21
inet::DiffservUtil::Color
Color
Definition: DiffservUtil.h:17
inet::HeatMapFigure::setHeat
void setHeat(int x, int y, double value)
Definition: HeatMapFigure.cc:24
inet::HeatMapFigure::coolingSpeed
double coolingSpeed
Definition: HeatMapFigure.h:19