INET Framework for OMNeT++/OMNEST
GaugeFigure Class Reference

#include <GaugeFigure.h>

Inheritance diagram for GaugeFigure:
inet::IIndicatorFigure

Public Member Functions

 GaugeFigure (const char *name=nullptr)
 
virtual ~GaugeFigure ()
 
virtual void setValue (int series, simtime_t timestamp, double value) override
 
const Rectangle & getBounds () const
 
void setBounds (const Rectangle &rect)
 
const ColorgetBackgroundColor () const
 
void setBackgroundColor (const Color &color)
 
const ColorgetNeedleColor () const
 
void setNeedleColor (const Color &color)
 
const char * getLabel () const
 
void setLabel (const char *text)
 
const int getLabelOffset () const
 
void setLabelOffset (int offset)
 
const Font & getLabelFont () const
 
void setLabelFont (const Font &font)
 
const ColorgetLabelColor () const
 
void setLabelColor (const Color &color)
 
double getMinValue () const
 
void setMinValue (double value)
 
double getMaxValue () const
 
void setMaxValue (double value)
 
double getTickSize () const
 
void setTickSize (double value)
 
const char * getColorStrip () const
 
void setColorStrip (const char *colorStrip)
 
- Public Member Functions inherited from inet::IIndicatorFigure
virtual ~IIndicatorFigure ()
 
virtual int getNumSeries () const
 
virtual void refreshDisplay ()
 

Protected Member Functions

virtual void parse (cProperty *property) override
 
virtual const char ** getAllowedPropertyKeys () const override
 
void addChildren ()
 
void setColorCurve (const cFigure::Color &curveColor, double startAngle, double endAngle, cArcFigure *arc)
 
void setCurveGeometry (cArcFigure *curve)
 
void setTickGeometry (cLineFigure *tick, int index)
 
void setNumberGeometry (cTextFigure *number, int index)
 
void setNeedleGeometry ()
 
void setNeedleTransform ()
 
void redrawTicks ()
 
void redrawCurves ()
 
void layout ()
 
void refresh ()
 

Private Attributes

cPathFigure * needle
 
cTextFigure * valueFigure
 
cTextFigure * labelFigure
 
cOvalFigure * backgroundFigure
 
std::vector< cArcFigure * > curveFigures
 
std::vector< cLineFigure * > tickFigures
 
std::vector< cTextFigure * > numberFigures
 
const char * colorStrip = ""
 
double min = 0
 
double max = 100
 
double tickSize = 10
 
double value = NaN
 
int numTicks = 0
 
double shifting = 0
 
int curvesOnCanvas = 0
 
int labelOffset = 10
 

Constructor & Destructor Documentation

GaugeFigure::GaugeFigure ( const char *  name = nullptr)
58  : cGroupFigure(name)
59 {
60  addChildren();
61 }
void addChildren()
Definition: GaugeFigure.cc:255
GaugeFigure::~GaugeFigure ( )
virtual
64 {
65  // delete figures which is not in canvas
66  for (int i = curvesOnCanvas; i < curveFigures.size(); ++i)
67  delete curveFigures[i];
68 
69  for (int i = numTicks; i < tickFigures.size(); ++i) {
70  delete tickFigures[i];
71  delete numberFigures[i];
72  }
73 }
std::vector< cArcFigure * > curveFigures
Definition: GaugeFigure.h:34
int numTicks
Definition: GaugeFigure.h:44
int curvesOnCanvas
Definition: GaugeFigure.h:46
std::vector< cTextFigure * > numberFigures
Definition: GaugeFigure.h:38
std::vector< cLineFigure * > tickFigures
Definition: GaugeFigure.h:37

Member Function Documentation

void GaugeFigure::addChildren ( )
protected

Referenced by GaugeFigure().

256 {
257  backgroundFigure = new cOvalFigure("background");
258  needle = new cPathFigure("needle");
259  valueFigure = new cTextFigure("value");
260  labelFigure = new cTextFigure("label");
261 
262  backgroundFigure->setFilled(true);
263  backgroundFigure->setFillColor(Color("#b8afa6"));
264 
265  needle->setFilled(true);
266  needle->setFillColor(cFigure::Color("#dba672"));
267 
268  valueFigure->setAnchor(cFigure::ANCHOR_CENTER);
269  labelFigure->setAnchor(cFigure::ANCHOR_N);
270 
271  addFigure(backgroundFigure);
272  addFigure(needle);
273  addFigure(valueFigure);
274  addFigure(labelFigure);
275 }
cOvalFigure * backgroundFigure
Definition: GaugeFigure.h:33
cPathFigure * needle
Definition: GaugeFigure.h:30
cTextFigure * labelFigure
Definition: GaugeFigure.h:32
Color
Definition: DiffservUtil.h:30
cTextFigure * valueFigure
Definition: GaugeFigure.h:31
const char ** GaugeFigure::getAllowedPropertyKeys ( ) const
overrideprotectedvirtual
241 {
242  static const char *keys[32];
243  if (!keys[0]) {
244  const char *localKeys[] = {
245  PKEY_BACKGROUND_COLOR, PKEY_NEEDLE_COLOR, PKEY_LABEL, PKEY_LABEL_FONT,
246  PKEY_LABEL_COLOR, PKEY_MIN_VALUE, PKEY_MAX_VALUE, PKEY_TICK_SIZE,
247  PKEY_COLOR_STRIP, PKEY_INITIAL_VALUE, PKEY_POS, PKEY_SIZE, PKEY_ANCHOR,
248  PKEY_BOUNDS, PKEY_LABEL_OFFSET, nullptr
249  };
250  concatArrays(keys, cGroupFigure::getAllowedPropertyKeys(), localKeys);
251  }
252  return keys;
253 }
std::vector< K > keys(const std::map< K, V > &m)
Definition: stlutils.h:96
const cFigure::Color & GaugeFigure::getBackgroundColor ( ) const
87 {
88  return backgroundFigure->getFillColor();
89 }
cOvalFigure * backgroundFigure
Definition: GaugeFigure.h:33
const cFigure::Rectangle & GaugeFigure::getBounds ( ) const

Referenced by layout(), parse(), setCurveGeometry(), setLabelOffset(), setNeedleGeometry(), setNeedleTransform(), setNumberGeometry(), and setTickGeometry().

76 {
77  return backgroundFigure->getBounds();
78 }
cOvalFigure * backgroundFigure
Definition: GaugeFigure.h:33
const char * GaugeFigure::getColorStrip ( ) const
192 {
193  return colorStrip;
194 }
const char * colorStrip
Definition: GaugeFigure.h:39
const char * GaugeFigure::getLabel ( ) const
107 {
108  return labelFigure->getText();
109 }
cTextFigure * labelFigure
Definition: GaugeFigure.h:32
const cFigure::Color & GaugeFigure::getLabelColor ( ) const
140 {
141  return labelFigure->getColor();
142 }
cTextFigure * labelFigure
Definition: GaugeFigure.h:32
const cFigure::Font & GaugeFigure::getLabelFont ( ) const
130 {
131  return labelFigure->getFont();
132 }
cTextFigure * labelFigure
Definition: GaugeFigure.h:32
const int GaugeFigure::getLabelOffset ( ) const
117 {
118  return labelOffset;
119 }
int labelOffset
Definition: GaugeFigure.h:47
double GaugeFigure::getMaxValue ( ) const
164 {
165  return max;
166 }
double max
Definition: GaugeFigure.h:41
double GaugeFigure::getMinValue ( ) const
150 {
151  return min;
152 }
double min
Definition: GaugeFigure.h:40
const cFigure::Color & GaugeFigure::getNeedleColor ( ) const
97 {
98  return needle->getFillColor();
99 }
cPathFigure * needle
Definition: GaugeFigure.h:30
double GaugeFigure::getTickSize ( ) const
178 {
179  return tickSize;
180 }
double tickSize
Definition: GaugeFigure.h:42
void GaugeFigure::layout ( )
protected

Referenced by setBounds().

487 {
488  backgroundFigure->setLineWidth(zeroToOne(getBounds().width * BORDER_WIDTH_PERCENT));
489 
490  for (cArcFigure *item : curveFigures)
491  setCurveGeometry(item);
492 
493  for (int i = 0; i < numTicks; ++i) {
496  }
497 
499 
500  valueFigure->setFont(Font("", getBounds().width * FONT_SIZE_PERCENT, 0));
501  valueFigure->setPosition(Point(getBounds().getCenter().x, getBounds().y + getBounds().height * VALUE_Y_PERCENT));
502 
503  labelFigure->setPosition(Point(getBounds().getCenter().x, getBounds().y + getBounds().height + labelOffset));
504 }
std::vector< cArcFigure * > curveFigures
Definition: GaugeFigure.h:34
cOvalFigure * backgroundFigure
Definition: GaugeFigure.h:33
int numTicks
Definition: GaugeFigure.h:44
const Rectangle & getBounds() const
Definition: GaugeFigure.cc:75
void setTickGeometry(cLineFigure *tick, int index)
Definition: GaugeFigure.cc:314
void setNeedleGeometry()
Definition: GaugeFigure.cc:347
double zeroToOne(double x)
Definition: GaugeFigure.cc:56
cTextFigure * labelFigure
Definition: GaugeFigure.h:32
std::vector< cTextFigure * > numberFigures
Definition: GaugeFigure.h:38
cTextFigure * valueFigure
Definition: GaugeFigure.h:31
std::vector< cLineFigure * > tickFigures
Definition: GaugeFigure.h:37
void setNumberGeometry(cTextFigure *number, int index)
Definition: GaugeFigure.cc:330
int labelOffset
Definition: GaugeFigure.h:47
void setCurveGeometry(cArcFigure *curve)
Definition: GaugeFigure.cc:295
void GaugeFigure::parse ( cProperty *  property)
overrideprotectedvirtual
205 {
206  cGroupFigure::parse(property);
207 
208  const char *s;
209 
210  setBounds(parseBounds(property, getBounds()));
211 
212  // Set default
213  redrawTicks();
214  if ((s = property->getValue(PKEY_BACKGROUND_COLOR)) != nullptr)
215  setBackgroundColor(parseColor(s));
216  if ((s = property->getValue(PKEY_NEEDLE_COLOR)) != nullptr)
217  setNeedleColor(parseColor(s));
218  if ((s = property->getValue(PKEY_LABEL)) != nullptr)
219  setLabel(s);
220  if ((s = property->getValue(PKEY_LABEL_OFFSET)) != nullptr)
221  setLabelOffset(atoi(s));
222  if ((s = property->getValue(PKEY_LABEL_FONT)) != nullptr)
223  setLabelFont(parseFont(s));
224  if ((s = property->getValue(PKEY_LABEL_COLOR)) != nullptr)
225  setLabelColor(parseColor(s));
226  // This must be initialize before min and max because it is possible to be too much unnecessary tick and number
227  if ((s = property->getValue(PKEY_TICK_SIZE)) != nullptr)
228  setTickSize(atof(s));
229  if ((s = property->getValue(PKEY_MIN_VALUE)) != nullptr)
230  setMinValue(atof(s));
231  if ((s = property->getValue(PKEY_MAX_VALUE)) != nullptr)
232  setMaxValue(atof(s));
233  if ((s = property->getValue(PKEY_COLOR_STRIP)) != nullptr)
234  setColorStrip(s);
235  if ((s = property->getValue(PKEY_INITIAL_VALUE)) != nullptr)
236  setValue(0, simTime(), utils::atod(s));
237 
238 }
void setBounds(const Rectangle &rect)
Definition: GaugeFigure.cc:80
void setBackgroundColor(const Color &color)
Definition: GaugeFigure.cc:91
const Rectangle & getBounds() const
Definition: GaugeFigure.cc:75
void setColorStrip(const char *colorStrip)
Definition: GaugeFigure.cc:196
virtual void setValue(int series, simtime_t timestamp, double value) override
Definition: GaugeFigure.cc:285
double atod(const char *s)
Converts string to double.
Definition: INETUtils.cc:38
void setLabel(const char *text)
Definition: GaugeFigure.cc:111
void setLabelOffset(int offset)
Definition: GaugeFigure.cc:121
void setMaxValue(double value)
Definition: GaugeFigure.cc:168
void setNeedleColor(const Color &color)
Definition: GaugeFigure.cc:101
void setLabelColor(const Color &color)
Definition: GaugeFigure.cc:144
value< double, units::s > s
Definition: Units.h:1049
void setTickSize(double value)
Definition: GaugeFigure.cc:182
void setMinValue(double value)
Definition: GaugeFigure.cc:154
void setLabelFont(const Font &font)
Definition: GaugeFigure.cc:134
void redrawTicks()
Definition: GaugeFigure.cc:387
void GaugeFigure::redrawCurves ( )
protected

Referenced by setColorStrip().

438 {
439  // create color strips
440  cStringTokenizer signalTokenizer(colorStrip, " ,");
441 
442  double lastStop = 0.0;
443  double newStop = 0.0;
444  Color color;
445  int index = 0;
446  const double deg270InRad = 6 * M_PI / 4;
447  while (signalTokenizer.hasMoreTokens()) {
448  const char *token = signalTokenizer.nextToken();
449  newStop = atof(token);
450  if (newStop > lastStop) {
451  if (index == curveFigures.size()) {
452  cArcFigure *arc = new cArcFigure("colorStrip");
453  arc->setZoomLineWidth(true);
454  curveFigures.push_back(arc);
455  }
456 
457  setColorCurve(color, M_PI - (deg270InRad * newStop), M_PI - (deg270InRad * lastStop), curveFigures[index]);
458 
459  ++index;
460  lastStop = newStop;
461  }
462  if (newStop == 0.0)
463  color = Color(token);
464  }
465  if (lastStop < 1.0) {
466  if (index == curveFigures.size()) {
467  cArcFigure *arc = new cArcFigure("colorStrip");
468  arc->setZoomLineWidth(true);
469  curveFigures.push_back(arc);
470  }
471  setColorCurve(color, M_PI - deg270InRad, M_PI - (deg270InRad * lastStop), curveFigures[index]);
472  ++index;
473  }
474 
475  int prevCurvesOnCanvas = curvesOnCanvas;
476  curvesOnCanvas = index;
477 
478  // Add or remove figures from canvas according to previous number of curves
479  for (int i = prevCurvesOnCanvas; i < curvesOnCanvas; ++i) {
480  curveFigures[i]->insertBelow(needle);
481  }
482  for (int i = curvesOnCanvas; i < prevCurvesOnCanvas; ++i)
483  removeFigure(curveFigures[index]);
484 }
std::vector< cArcFigure * > curveFigures
Definition: GaugeFigure.h:34
int curvesOnCanvas
Definition: GaugeFigure.h:46
cPathFigure * needle
Definition: GaugeFigure.h:30
#define M_PI
Definition: PlotFigure.cc:27
void setColorCurve(const cFigure::Color &curveColor, double startAngle, double endAngle, cArcFigure *arc)
Definition: GaugeFigure.cc:277
Color
Definition: DiffservUtil.h:30
const char * colorStrip
Definition: GaugeFigure.h:39
void GaugeFigure::redrawTicks ( )
protected

Referenced by parse(), setMaxValue(), setMinValue(), and setTickSize().

388 {
389  ASSERT(tickFigures.size() == numberFigures.size());
390 
391  double fraction = std::abs(fmod(min / tickSize, 1));
392  shifting = tickSize * (min < 0 ? fraction : 1 - fraction);
393  // if fraction == 0 then shifting == tickSize therefore don't have to shift the ticks
394  if (shifting == tickSize)
395  shifting = 0;
396 
397  int prevNumTicks = numTicks;
398  numTicks = std::max(0.0, std::abs(max - min - shifting) / tickSize + 1);
399 
400  // Allocate ticks and numbers if needed
401  if (numTicks > tickFigures.size())
402  while (numTicks > tickFigures.size()) {
403  cLineFigure *tick = new cLineFigure();
404  cTextFigure *number = new cTextFigure();
405 
406  number->setAnchor(cFigure::ANCHOR_CENTER);
407 
408  tickFigures.push_back(tick);
409  numberFigures.push_back(number);
410  }
411 
412  // Add or remove figures from canvas according to previous number of ticks
413  for (int i = numTicks; i < prevNumTicks; ++i) {
414  removeFigure(tickFigures[i]);
415  removeFigure(numberFigures[i]);
416  }
417  for (int i = prevNumTicks; i < numTicks; ++i) {
418  addFigure(tickFigures[i]);
419  numberFigures[i]->insertBelow(needle);
420  }
421 
422  for (int i = 0; i < numTicks; ++i) {
424 
425  char buf[32];
426 
427  double number = min + i * tickSize + shifting;
428  if (std::abs(number) < tickSize / 2)
429  number = 0;
430 
431  sprintf(buf, "%g", number);
432  numberFigures[i]->setText(buf);
434  }
435 }
int numTicks
Definition: GaugeFigure.h:44
void setTickGeometry(cLineFigure *tick, int index)
Definition: GaugeFigure.cc:314
double max(double a, double b)
Returns the greater of the given parameters.
Definition: INETMath.h:161
cPathFigure * needle
Definition: GaugeFigure.h:30
double shifting
Definition: GaugeFigure.h:45
std::vector< cTextFigure * > numberFigures
Definition: GaugeFigure.h:38
double tickSize
Definition: GaugeFigure.h:42
double max
Definition: GaugeFigure.h:41
std::vector< cLineFigure * > tickFigures
Definition: GaugeFigure.h:37
void setNumberGeometry(cTextFigure *number, int index)
Definition: GaugeFigure.cc:330
double min
Definition: GaugeFigure.h:40
void GaugeFigure::refresh ( )
protected

Referenced by setMaxValue(), setMinValue(), setTickSize(), and setValue().

507 {
509 
510  // update displayed number
511  if (std::isnan(value))
512  valueFigure->setText("");
513  else {
514  char buf[32];
515  sprintf(buf, "%g", value);
516  valueFigure->setText(buf);
517  }
518 }
void setNeedleTransform()
Definition: GaugeFigure.cc:366
double value
Definition: GaugeFigure.h:43
cTextFigure * valueFigure
Definition: GaugeFigure.h:31
void GaugeFigure::setBackgroundColor ( const Color color)

Referenced by parse().

92 {
93  backgroundFigure->setFillColor(color);
94 }
cOvalFigure * backgroundFigure
Definition: GaugeFigure.h:33
void GaugeFigure::setBounds ( const Rectangle &  rect)

Referenced by parse().

81 {
82  backgroundFigure->setBounds(rect);
83  layout();
84 }
cOvalFigure * backgroundFigure
Definition: GaugeFigure.h:33
void layout()
Definition: GaugeFigure.cc:486
void GaugeFigure::setColorCurve ( const cFigure::Color &  curveColor,
double  startAngle,
double  endAngle,
cArcFigure *  arc 
)
protected

Referenced by redrawCurves().

278 {
279  arc->setLineColor(curveColor);
280  arc->setStartAngle(startAngle);
281  arc->setEndAngle(endAngle);
282  setCurveGeometry(arc);
283 }
void setCurveGeometry(cArcFigure *curve)
Definition: GaugeFigure.cc:295
void GaugeFigure::setColorStrip ( const char *  colorStrip)

Referenced by parse().

197 {
198  if (strcmp(this->colorStrip, colorStrip) != 0) {
199  this->colorStrip = colorStrip;
200  redrawCurves();
201  }
202 }
void redrawCurves()
Definition: GaugeFigure.cc:437
const char * colorStrip
Definition: GaugeFigure.h:39
void GaugeFigure::setCurveGeometry ( cArcFigure *  curve)
protected

Referenced by layout(), and setColorCurve().

296 {
297  double lineWidth = getBounds().width * CURVE_WIDTH_PERCENT;
298  Rectangle arcBounds = getBounds();
299  double offset = lineWidth + backgroundFigure->getLineWidth();
300 
301  arcBounds.height -= offset;
302  arcBounds.width -= offset;
303  arcBounds.x += offset / 2;
304  arcBounds.y += offset / 2;
305 
306  curve->setBounds(arcBounds);
307  curve->setLineWidth(lineWidth);
308 
309  Transform trans;
310  trans.rotate(-M_PI / 4, getBounds().getCenter());
311  curve->setTransform(trans);
312 }
cOvalFigure * backgroundFigure
Definition: GaugeFigure.h:33
const Rectangle & getBounds() const
Definition: GaugeFigure.cc:75
#define M_PI
Definition: PlotFigure.cc:27
void GaugeFigure::setLabel ( const char *  text)

Referenced by parse().

112 {
113  labelFigure->setText(text);
114 }
cTextFigure * labelFigure
Definition: GaugeFigure.h:32
void GaugeFigure::setLabelColor ( const Color color)

Referenced by parse().

145 {
146  labelFigure->setColor(color);
147 }
cTextFigure * labelFigure
Definition: GaugeFigure.h:32
void GaugeFigure::setLabelFont ( const Font &  font)

Referenced by parse().

135 {
136  labelFigure->setFont(font);
137 }
cTextFigure * labelFigure
Definition: GaugeFigure.h:32
void GaugeFigure::setLabelOffset ( int  offset)

Referenced by parse().

122 {
123  if (labelOffset != offset) {
124  labelOffset = offset;
125  labelFigure->setPosition(Point(getBounds().getCenter().x, getBounds().y + getBounds().height + labelOffset));
126  }
127 }
const Rectangle & getBounds() const
Definition: GaugeFigure.cc:75
cTextFigure * labelFigure
Definition: GaugeFigure.h:32
int labelOffset
Definition: GaugeFigure.h:47
void GaugeFigure::setMaxValue ( double  value)

Referenced by parse().

169 {
170  if (max != value) {
171  max = value;
172  redrawTicks();
173  refresh();
174  }
175 }
double value
Definition: GaugeFigure.h:43
void refresh()
Definition: GaugeFigure.cc:506
double max
Definition: GaugeFigure.h:41
void redrawTicks()
Definition: GaugeFigure.cc:387
void GaugeFigure::setMinValue ( double  value)

Referenced by parse().

155 {
156  if (min != value) {
157  min = value;
158  redrawTicks();
159  refresh();
160  }
161 }
double value
Definition: GaugeFigure.h:43
void refresh()
Definition: GaugeFigure.cc:506
void redrawTicks()
Definition: GaugeFigure.cc:387
double min
Definition: GaugeFigure.h:40
void GaugeFigure::setNeedleColor ( const Color color)

Referenced by parse().

102 {
103  needle->setFillColor(color);
104 }
cPathFigure * needle
Definition: GaugeFigure.h:30
void GaugeFigure::setNeedleGeometry ( )
protected

Referenced by layout().

348 {
349  double cx = getBounds().getCenter().x;
350  double cy = getBounds().getCenter().y;
351  double w = getBounds().width;
352 
353  // draw needle in horizontal position, pointing 9:00 hours
354  double needleHalfWidth = w * NEEDLE_WIDTH_PERCENT / 2;
355  double needleLength = w * NEEDLE_HEIGHT_PERCENT;
356  needle->clearPath();
357  needle->addMoveTo(cx + needleHalfWidth, cy);
358  needle->addLineTo(cx, cy - needleHalfWidth);
359  needle->addLineTo(cx - needleLength, cy);
360  needle->addLineTo(cx, cy + needleHalfWidth);
361  needle->addClosePath();
362 
364 }
void setNeedleTransform()
Definition: GaugeFigure.cc:366
const Rectangle & getBounds() const
Definition: GaugeFigure.cc:75
cPathFigure * needle
Definition: GaugeFigure.h:30
void GaugeFigure::setNeedleTransform ( )
protected

Referenced by refresh(), and setNeedleGeometry().

367 {
368  double angle;
369  const double offset = NEEDLE_OFFSET_IN_DEGREE * M_PI / 180;
370  needle->setVisible(true);
371  if (value < min)
372  angle = -offset;
373  else if (value > max)
374  angle = (END_ANGLE - START_ANGLE) + offset;
375  else if (std::isnan(value)) {
376  needle->setVisible(false);
377  return;
378  }
379  else
380  angle = (value - min) / (max - min) * (END_ANGLE - START_ANGLE);
381 
382  cFigure::Transform t;
383  t.rotate(angle, getBounds().getCenter()).rotate(-M_PI / 4, getBounds().getCenter());
384  needle->setTransform(t);
385 }
double value
Definition: GaugeFigure.h:43
const Rectangle & getBounds() const
Definition: GaugeFigure.cc:75
cPathFigure * needle
Definition: GaugeFigure.h:30
#define M_PI
Definition: PlotFigure.cc:27
double max
Definition: GaugeFigure.h:41
double min
Definition: GaugeFigure.h:40
void GaugeFigure::setNumberGeometry ( cTextFigure *  number,
int  index 
)
protected

Referenced by layout(), and redrawTicks().

331 {
332  ASSERT(tickFigures.size() > 0);
333 
334  double distanceToBorder = tickFigures[0]->getStart().distanceTo(tickFigures[0]->getEnd());
335  number->setFont(cFigure::Font("", getBounds().width * FONT_SIZE_PERCENT, 0));
336  Point textPos = Point(getBounds().x + distanceToBorder + number->getFont().pointSize, getBounds().getCenter().y);
337  number->setPosition(textPos);
338 
339  Transform trans;
340  trans.rotate(-(M_PI + M_PI / 2) * (index * tickSize + shifting) / (max - min), textPos).
341  rotate(M_PI / 4, textPos).
342  rotate((M_PI + M_PI / 2) * (index * tickSize + shifting) / (max - min), getBounds().getCenter()).
343  rotate(-M_PI / 4, getBounds().getCenter());
344  number->setTransform(trans);
345 }
const Rectangle & getBounds() const
Definition: GaugeFigure.cc:75
double shifting
Definition: GaugeFigure.h:45
#define M_PI
Definition: PlotFigure.cc:27
double tickSize
Definition: GaugeFigure.h:42
double max
Definition: GaugeFigure.h:41
std::vector< cLineFigure * > tickFigures
Definition: GaugeFigure.h:37
double min
Definition: GaugeFigure.h:40
void GaugeFigure::setTickGeometry ( cLineFigure *  tick,
int  index 
)
protected

Referenced by layout(), and redrawTicks().

315 {
316  tick->setStart(Point(getBounds().x, getBounds().getCenter().y));
317 
318  Point endPos = getBounds().getCenter();
319  endPos.x -= !(index % 3) ? getBounds().width * TICK_BIG_LENGTH_PERCENT :
320  getBounds().width * TICK_SMALL_LENGTH_PERCENT;
321  tick->setEnd(endPos);
322  tick->setLineWidth(zeroToOne(getBounds().width * TICK_LINE_WIDTH_PERCENT));
323 
324  Transform trans;
325  trans.rotate((M_PI + M_PI / 2) * (index * tickSize + shifting) / (max - min), getBounds().getCenter()).
326  rotate(-M_PI / 4, getBounds().getCenter());
327  tick->setTransform(trans);
328 }
const Rectangle & getBounds() const
Definition: GaugeFigure.cc:75
double zeroToOne(double x)
Definition: GaugeFigure.cc:56
double shifting
Definition: GaugeFigure.h:45
#define M_PI
Definition: PlotFigure.cc:27
double tickSize
Definition: GaugeFigure.h:42
double max
Definition: GaugeFigure.h:41
double min
Definition: GaugeFigure.h:40
void GaugeFigure::setTickSize ( double  value)

Referenced by parse().

183 {
184  if (tickSize != value) {
185  tickSize = value;
186  redrawTicks();
187  refresh();
188  }
189 }
double value
Definition: GaugeFigure.h:43
void refresh()
Definition: GaugeFigure.cc:506
double tickSize
Definition: GaugeFigure.h:42
void redrawTicks()
Definition: GaugeFigure.cc:387
void GaugeFigure::setValue ( int  series,
simtime_t  timestamp,
double  value 
)
overridevirtual

Implements inet::IIndicatorFigure.

Referenced by parse().

286 {
287  ASSERT(series == 0);
288  // Note: we currently ignore timestamp
289  if (value != newValue) {
290  value = newValue;
291  refresh();
292  }
293 }
double value
Definition: GaugeFigure.h:43
void refresh()
Definition: GaugeFigure.cc:506

Member Data Documentation

cOvalFigure* GaugeFigure::backgroundFigure
private
const char* GaugeFigure::colorStrip = ""
private
std::vector<cArcFigure *> GaugeFigure::curveFigures
private

Referenced by layout(), redrawCurves(), and ~GaugeFigure().

int GaugeFigure::curvesOnCanvas = 0
private

Referenced by redrawCurves(), and ~GaugeFigure().

cTextFigure* GaugeFigure::labelFigure
private
int GaugeFigure::labelOffset = 10
private
double GaugeFigure::max = 100
private
double GaugeFigure::min = 0
private
cPathFigure* GaugeFigure::needle
private
std::vector<cTextFigure *> GaugeFigure::numberFigures
private

Referenced by layout(), redrawTicks(), and ~GaugeFigure().

int GaugeFigure::numTicks = 0
private

Referenced by layout(), redrawTicks(), and ~GaugeFigure().

double GaugeFigure::shifting = 0
private
std::vector<cLineFigure *> GaugeFigure::tickFigures
private
double GaugeFigure::tickSize = 10
private
double GaugeFigure::value = NaN
private
cTextFigure* GaugeFigure::valueFigure
private

Referenced by addChildren(), layout(), and refresh().


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