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

inet::HeatMapFigure::HeatMapFigure ( int  size,
const char *  name 
)
22  :
23  cPixmapFigure(name)
24 {
25  setPixmap(cFigure::Pixmap(size, size));
26 #if OMNETPP_BUILDNUM >= 1006
27  fillPixmap(fromColor, 0);
28 #else
29  fill(fromColor, 0);
30 #endif
31 }
cFigure::Color fromColor
Definition: HeatMapFigure.h:30

Member Function Documentation

void inet::HeatMapFigure::coolDown ( )
virtual

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

84 {
85  double factor = exp(coolingSpeed * (lastCoolDown - simTime()).dbl());
86  if (factor < 0.9) {
87  lastCoolDown = simTime();
88  for (int x = 0; x < getPixmapWidth(); x++)
89  for (int y = 0; y < getPixmapHeight(); y++)
90  setHeat(x, y, getHeat(x, y) * factor);
91  }
92 }
simtime_t lastCoolDown
Definition: HeatMapFigure.h:32
void setHeat(int x, int y, double value)
Definition: HeatMapFigure.cc:38
double getHeat(int x, int y)
Definition: HeatMapFigure.cc:33
double coolingSpeed
Definition: HeatMapFigure.h:29
virtual const char* inet::HeatMapFigure::getClassNameForRenderer ( ) const
inlinevirtual
41 { return "cPixmapFigure"; }
double inet::HeatMapFigure::getHeat ( int  x,
int  y 
)
protected

Referenced by coolDown(), and heatPoint().

34 {
35  return getPixelOpacity(x, y);
36 }
void inet::HeatMapFigure::heatLine ( int  x1,
int  y1,
int  x2,
int  y2 
)
virtual

Referenced by inet::visualizer::MediumCanvasVisualizer::receptionStarted().

54 {
55  // NOTE: http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm
56  bool steep = (std::abs(y2 - y1) > std::abs(x2 - x1));
57  if (steep) {
58  std::swap(x1, y1);
59  std::swap(x2, y2);
60  }
61  if (x1 > x2) {
62  std::swap(x1, x2);
63  std::swap(y1, y2);
64  }
65  double dx = x2 - x1;
66  double dy = std::abs(y2 - y1);
67  double error = dx / 2.0f;
68  int yStep = (y1 < y2) ? 1 : -1;
69  int y = y1;
70  for (int x = x1; x <= x2; x++) {
71  if (steep)
72  heatPoint(y, x);
73  else
74  heatPoint(x, y);
75  error -= dy;
76  if (error < 0) {
77  y += yStep;
78  error += dx;
79  }
80  }
81 }
virtual void heatPoint(int x, int y)
Definition: HeatMapFigure.cc:47
void inet::HeatMapFigure::heatPoint ( int  x,
int  y 
)
virtual

Referenced by heatLine().

48 {
49  double value = alpha + (1 - alpha) * getHeat(x, y);
50  setHeat(x, y, value);
51 }
void setHeat(int x, int y, double value)
Definition: HeatMapFigure.cc:38
double getHeat(int x, int y)
Definition: HeatMapFigure.cc:33
double alpha
Definition: HeatMapFigure.h:28
void inet::HeatMapFigure::setHeat ( int  x,
int  y,
double  value 
)
protected

Referenced by coolDown(), and heatPoint().

39 {
40  cFigure::Color color(
41  (1 - value) * fromColor.red + value * toColor.red,
42  (1 - value) * fromColor.green + value * toColor.green,
43  (1 - value) * fromColor.blue + value * toColor.blue);
44  setPixel(x, y, color, value);
45 }
cFigure::Color toColor
Definition: HeatMapFigure.h:31
cFigure::Color fromColor
Definition: HeatMapFigure.h:30
Color
Definition: DiffservUtil.h:30

Member Data Documentation

double inet::HeatMapFigure::alpha = 0.5
protected

Referenced by heatPoint().

double inet::HeatMapFigure::coolingSpeed = 0.01
protected

Referenced by coolDown().

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

Referenced by HeatMapFigure(), and setHeat().

simtime_t inet::HeatMapFigure::lastCoolDown
protected

Referenced by coolDown().

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

Referenced by setHeat().


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