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

#include <PlotFigure.h>

Inheritance diagram for inet::PlotFigure:
inet::IIndicatorFigure

Classes

struct  Tick
 

Public Member Functions

 PlotFigure (const char *name=nullptr)
 
virtual ~PlotFigure ()
 
virtual void parse (cProperty *property) override
 
const char ** getAllowedPropertyKeys () const override
 
virtual void refreshDisplay () override
 
virtual void setNumSeries (int numSeries)
 
virtual int getNumSeries () const override
 
virtual void setValue (int series, simtime_t timestamp, double value) override
 
virtual void setValue (int series, double x, double y)
 
virtual void clearValues (int series)
 
const Point getPlotSize () const
 
void setPlotSize (const Point &p)
 
virtual const Point getSize () const override
 
const Rectangle & getBounds () const
 
void setBounds (const Rectangle &rect)
 
const ColorgetBackgrouncColor () const
 
void setBackgroundColor (const Color &color)
 
double getXTickSize () const
 
void setXTickSize (double size)
 
void setXTickCount (int count)
 
double getYTickSize () const
 
void setYTickSize (double size)
 
void setYTickCount (int count)
 
double getTimeWindow () const
 
void setTimeWindow (double timeWindow)
 
const ColorgetLineColor (int series) const
 
void setLineColor (int series, const Color &color)
 
double getMinX () const
 
void setMinX (double value)
 
double getMaxX () const
 
void setMaxX (double value)
 
double getMinY () const
 
void setMinY (double value)
 
double getMaxY () const
 
void setMaxY (double value)
 
void setXValueFormat (const char *format)
 
void setYValueFormat (const char *format)
 
const char * getXAxisLabel () const
 
void setXAxisLabel (const char *text)
 
const char * getYAxisLabel () const
 
void setYAxisLabel (const char *text)
 
const char * getLabel () const
 
void setLabel (const char *text)
 
int getLabelOffset () const
 
void setLabelOffset (int offset)
 
const Font & getLabelFont () const
 
void setLabelFont (const Font &font)
 
const ColorgetLabelColor () const
 
void setLabelColor (const Color &color)
 
- Public Member Functions inherited from inet::IIndicatorFigure
virtual ~IIndicatorFigure ()
 

Protected Member Functions

void redrawYTicks ()
 
void redrawXTicks ()
 
void addChildren ()
 
void layout ()
 
void plot ()
 

Private Attributes

std::vector< cPathFigure * > seriesPlotFigures
 
cLabelFigure * labelFigure
 
cLabelFigure * xAxisLabelFigure
 
cLabelFigure * yAxisLabelFigure
 
cRectangleFigure * backgroundFigure
 
std::vector< TickxTicks
 
std::vector< TickyTicks
 
Rectangle bounds
 
int numSeries = -1
 
double timeWindow = NaN
 
double yTickSize = INFINITY
 
double xTickSize = INFINITY
 
int labelOffset = 0
 
double minX = 0
 
double maxX = 1
 
double minY = 0
 
double maxY = 1
 
const char * xValueFormat = "%g"
 
const char * yValueFormat = "%g"
 
bool invalidLayout = true
 
bool invalidPlot = true
 
std::vector< std::list< std::pair< double, double > > > seriesValues
 

Constructor & Destructor Documentation

◆ PlotFigure()

inet::PlotFigure::PlotFigure ( const char *  name = nullptr)
39  : cGroupFigure(name)
40 {
41  addChildren();
42  setNumSeries(1);
43 }

◆ ~PlotFigure()

virtual inet::PlotFigure::~PlotFigure ( )
inlinevirtual
61 {}

Member Function Documentation

◆ addChildren()

void inet::PlotFigure::addChildren ( )
protected
284 {
285  labelFigure = new cLabelFigure("label");
286  labelFigure->setAnchor(ANCHOR_N);
287  xAxisLabelFigure = new cLabelFigure("X axis label");
288  xAxisLabelFigure->setAnchor(ANCHOR_S);
289  yAxisLabelFigure = new cLabelFigure("Y axis label");
290  yAxisLabelFigure->setAnchor(ANCHOR_S);
291  yAxisLabelFigure->setAngle(M_PI / 2);
292  backgroundFigure = new cRectangleFigure("bounds");
293 
294  backgroundFigure->setFilled(true);
295  backgroundFigure->setFillColor(INIT_BACKGROUND_COLOR);
296 
297  addFigure(backgroundFigure);
298  addFigure(labelFigure);
299  addFigure(xAxisLabelFigure);
300  addFigure(yAxisLabelFigure);
301 }

Referenced by PlotFigure().

◆ clearValues()

virtual void inet::PlotFigure::clearValues ( int  series)
inlinevirtual
73 { seriesValues[series].clear(); invalidPlot = true; }

◆ getAllowedPropertyKeys()

const char ** inet::PlotFigure::getAllowedPropertyKeys ( ) const
override
269 {
270  static const char *keys[32];
271  if (!keys[0]) {
272  const char *localKeys[] = {
273  PKEY_Y_TICK_SIZE, PKEY_TIME_WINDOW, PKEY_X_TICK_SIZE,
274  PKEY_LINE_COLOR, PKEY_MIN_X, PKEY_MAX_X, PKEY_MIN_Y, PKEY_MAX_Y, PKEY_BACKGROUND_COLOR,
275  PKEY_LABEL, PKEY_LABEL_OFFSET, PKEY_LABEL_COLOR, PKEY_LABEL_FONT, PKEY_POS,
276  PKEY_SIZE, PKEY_ANCHOR, PKEY_BOUNDS, nullptr
277  };
278  concatArrays(keys, cGroupFigure::getAllowedPropertyKeys(), localKeys);
279  }
280  return keys;
281 }

◆ getBackgrouncColor()

const cFigure::Color & inet::PlotFigure::getBackgrouncColor ( ) const
84 {
85  return backgroundFigure->getFillColor();
86 }

◆ getBounds()

const cFigure::Rectangle & inet::PlotFigure::getBounds ( ) const
70 {
71  if (invalidLayout)
72  const_cast<PlotFigure *>(this)->layout();
73  return bounds;
74 }

Referenced by parse().

◆ getLabel()

const char* inet::PlotFigure::getLabel ( ) const
inline
121 { return labelFigure->getText(); }

◆ getLabelColor()

const cFigure::Color & inet::PlotFigure::getLabelColor ( ) const
220 {
221  return labelFigure->getColor();
222 }

◆ getLabelFont()

const cFigure::Font & inet::PlotFigure::getLabelFont ( ) const
210 {
211  return labelFigure->getFont();
212 }

◆ getLabelOffset()

int inet::PlotFigure::getLabelOffset ( ) const
196 {
197  return labelOffset;
198 }

◆ getLineColor()

const cFigure::Color & inet::PlotFigure::getLineColor ( int  series) const
150 {
151  return seriesPlotFigures[series]->getLineColor();
152 }

◆ getMaxX()

double inet::PlotFigure::getMaxX ( ) const
inline
103 { return maxX; }

◆ getMaxY()

double inet::PlotFigure::getMaxY ( ) const
inline
109 { return maxY; }

◆ getMinX()

double inet::PlotFigure::getMinX ( ) const
inline
100 { return minX; }

◆ getMinY()

double inet::PlotFigure::getMinY ( ) const
inline
106 { return minY; }

◆ getNumSeries()

virtual int inet::PlotFigure::getNumSeries ( ) const
inlineoverridevirtual

Reimplemented from inet::IIndicatorFigure.

69 { return numSeries; }

◆ getPlotSize()

const Point inet::PlotFigure::getPlotSize ( ) const
inline
76 { return backgroundFigure->getBounds().getSize(); }

◆ getSize()

virtual const Point inet::PlotFigure::getSize ( ) const
inlineoverridevirtual

Implements inet::IIndicatorFigure.

79 { return getBounds().getSize(); }

◆ getTimeWindow()

double inet::PlotFigure::getTimeWindow ( ) const
116 {
117  return timeWindow;
118 }

◆ getXAxisLabel()

const char* inet::PlotFigure::getXAxisLabel ( ) const
inline
115 { return xAxisLabelFigure->getText(); }

◆ getXTickSize()

double inet::PlotFigure::getXTickSize ( ) const
129 {
130  return xTickSize;
131 }

◆ getYAxisLabel()

const char* inet::PlotFigure::getYAxisLabel ( ) const
inline
118 { return yAxisLabelFigure->getText(); }

◆ getYTickSize()

double inet::PlotFigure::getYTickSize ( ) const
94 {
95  return yTickSize;
96 }

◆ layout()

void inet::PlotFigure::layout ( )
protected
319 {
320  redrawXTicks();
321  redrawYTicks();
322 
323  Rectangle b = backgroundFigure->getBounds();
324  double fontSize = xTicks.size() > 0 && xTicks[0].number ? xTicks[0].number->getFont().pointSize : 12;
325  labelFigure->setPosition(Point(b.getCenter().x, b.y + b.height + fontSize * LABEL_Y_DISTANCE_FACTOR + labelOffset));
326  xAxisLabelFigure->setPosition(Point(b.x + b.width / 2, b.y - 5));
327  yAxisLabelFigure->setPosition(Point(-5, b.height / 2));
328 
329  bounds = backgroundFigure->getBounds();
330  bounds = rectangleUnion(bounds, labelFigure->getBounds());
331  bounds.x -= fontSize;
332  bounds.y -= fontSize;
333  bounds.width += 2 * fontSize;
334  bounds.height += 2 * fontSize;
335  invalidLayout = false;
336 }

Referenced by getBounds(), and refreshDisplay().

◆ parse()

void inet::PlotFigure::parse ( cProperty *  property)
overridevirtual
230 {
231  cGroupFigure::parse(property);
232 
233  const char *s;
234 
235  setBounds(parseBounds(property, getBounds()));
236 
237  if ((s = property->getValue(PKEY_BACKGROUND_COLOR)) != nullptr)
238  setBackgroundColor(parseColor(s));
239  if ((s = property->getValue(PKEY_X_TICK_SIZE)) != nullptr)
240  setXTickSize(atoi(s));
241  if ((s = property->getValue(PKEY_Y_TICK_SIZE)) != nullptr)
242  setYTickSize(atoi(s));
243  if ((s = property->getValue(PKEY_TIME_WINDOW)) != nullptr)
244  setTimeWindow(atoi(s));
245  if ((s = property->getValue(PKEY_LINE_COLOR)) != nullptr) {
246  for (int i = 0; i < numSeries; i++)
247  setLineColor(i, parseColor(s));
248  }
249  if ((s = property->getValue(PKEY_MIN_X)) != nullptr)
250  setMinX(atof(s));
251  if ((s = property->getValue(PKEY_MAX_X)) != nullptr)
252  setMaxX(atof(s));
253  if ((s = property->getValue(PKEY_MIN_Y)) != nullptr)
254  setMinY(atof(s));
255  if ((s = property->getValue(PKEY_MAX_Y)) != nullptr)
256  setMaxY(atof(s));
257  if ((s = property->getValue(PKEY_LABEL)) != nullptr)
258  setLabel(s);
259  if ((s = property->getValue(PKEY_LABEL_OFFSET)) != nullptr)
260  setLabelOffset(atoi(s));
261  if ((s = property->getValue(PKEY_LABEL_COLOR)) != nullptr)
262  setLabelColor(parseColor(s));
263  if ((s = property->getValue(PKEY_LABEL_FONT)) != nullptr)
264  setLabelFont(parseFont(s));
265  refreshDisplay();
266 }

◆ plot()

void inet::PlotFigure::plot ( )
protected
468 {
469  double minX = std::isnan(timeWindow) ? this->minX : simTime().dbl() - timeWindow;
470  double maxX = std::isnan(timeWindow) ? this->maxX : simTime().dbl();
471 
472  for (int i = 0; i < numSeries; i++) {
473  auto values = seriesValues[i];
474  auto plotFigure = seriesPlotFigures[i];
475  plotFigure->clearPath();
476 
477  if (values.size() < 2)
478  continue;
479  if (minX > values.front().first) {
480  values.clear();
481  continue;
482  }
483 
484  auto r = backgroundFigure->getBounds();
485  auto it = values.begin();
486  double startX = r.x + r.width - (maxX - it->first) / (maxX - minX) * r.width;
487  double startY = std::min(r.y + 100 * r.height, r.y + (maxY - it->second) / std::abs(maxY - minY) * r.height);
488  plotFigure->addMoveTo(startX, startY);
489 
490  ++it;
491  do {
492  double endX = r.x + r.width - (maxX - it->first) / (maxX - minX) * r.width;
493  double endY = std::min(r.y + 100 * r.height, r.y + (maxY - it->second) / std::abs(maxY - minY) * r.height);
494 
495  double originalStartX = startX;
496  double originalStartY = startY;
497  double originalEndX = endX;
498  double originalEndY = endY;
499  if (InstrumentUtil::CohenSutherlandLineClip(startX, startY, endX, endY, r.x, r.x + r.width, r.y, r.y + r.height)) {
500  if (originalStartX != startX || originalStartY != startY)
501  plotFigure->addMoveTo(startX, startY);
502 
503  plotFigure->addLineTo(endX, endY);
504  }
505 
506  if (minX > it->first)
507  break;
508 
509  startX = originalEndX;
510  startY = originalEndY;
511  ++it;
512  } while (it != values.end());
513 
514  // Delete old elements
515  if (!std::isnan(timeWindow) && it != values.end())
516  values.erase(++it, values.end());
517  }
518 }

Referenced by refreshDisplay().

◆ redrawXTicks()

void inet::PlotFigure::redrawXTicks ( )
protected
400 {
401  Rectangle bounds = backgroundFigure->getBounds();
402  double minX = std::isnan(timeWindow) ? this->minX : simTime().dbl() - timeWindow;
403  double maxX = std::isnan(timeWindow) ? this->maxX : simTime().dbl();
404 
405  double shifting = 0;
406  if (!std::isnan(timeWindow)) {
407  double fraction = std::abs(fmod((minX / xTickSize), 1));
408  shifting = xTickSize * (minX < 0 ? fraction : 1 - fraction);
409  // if fraction == 0 then shifting == xTickSize therefore don't have to shift the X ticks
410  if (shifting == xTickSize)
411  shifting = 0;
412  }
413 
414  int numTicks = std::isfinite(xTickSize) ? ((maxX - minX) - shifting) / xTickSize + 1 : 0;
415 
416  // Allocate ticks and numbers if needed
417  if ((size_t)numTicks > xTicks.size())
418  while ((size_t)numTicks > xTicks.size()) {
419  cLineFigure *tick = new cLineFigure("xTick");
420  cLineFigure *dashLine = new cLineFigure("xDashLine");
421  cLabelFigure *number = new cLabelFigure("xNumber");
422 
423  dashLine->setLineStyle(LINE_DASHED);
424 
425  number->setAnchor(ANCHOR_N);
426  auto plotFigure = seriesPlotFigures[seriesPlotFigures.size() - 1];
427  tick->insertBelow(plotFigure);
428  dashLine->insertBelow(plotFigure);
429  number->insertBelow(plotFigure);
430  xTicks.push_back(Tick(tick, dashLine, number));
431  }
432  else
433  // Add or remove figures from canvas according to previous number of ticks
434  for (int i = xTicks.size() - 1; i >= numTicks; --i) {
435  delete removeFigure(xTicks[i].number);
436  delete removeFigure(xTicks[i].dashLine);
437  delete removeFigure(xTicks[i].tick);
438  xTicks.pop_back();
439  }
440 
441  for (uint32_t i = 0; i < xTicks.size(); ++i) {
442  double x = bounds.x + bounds.width * (i * xTickSize + shifting) / (maxX - minX);
443  double y = bounds.y + bounds.height;
444  if (x > bounds.x && x < bounds.x + bounds.width) {
445  xTicks[i].tick->setVisible(true);
446  xTicks[i].tick->setStart(Point(x, y));
447  xTicks[i].tick->setEnd(Point(x, y - TICK_LENGTH));
448 
449  xTicks[i].dashLine->setVisible(true);
450  xTicks[i].dashLine->setStart(Point(x, y - TICK_LENGTH));
451  xTicks[i].dashLine->setEnd(Point(x, bounds.y));
452  }
453  else {
454  xTicks[i].tick->setVisible(false);
455  xTicks[i].dashLine->setVisible(false);
456  }
457 
458  char buf[32];
459  double number = minX + i * xTickSize + shifting;
460 
461  sprintf(buf, xValueFormat, number);
462  xTicks[i].number->setText(buf);
463  xTicks[i].number->setPosition(Point(x, y + 5));
464  }
465 }

Referenced by layout(), and refreshDisplay().

◆ redrawYTicks()

void inet::PlotFigure::redrawYTicks ( )
protected
339 {
340  Rectangle bounds = backgroundFigure->getBounds();
341  int numTicks = std::isfinite(yTickSize) ? std::abs(maxY - minY) / yTickSize + 1 : 0;
342 
343  double valueTickYposAdjust[2] = { 0, 0 };
344  int fontSize = labelFigure->getFont().pointSize;
345  if (yTicks.size() == 1) {
346  valueTickYposAdjust[0] = -(fontSize / 2);
347  valueTickYposAdjust[1] = fontSize / 2;
348  }
349 
350  // Allocate ticks and numbers if needed
351  if ((size_t)numTicks > yTicks.size())
352  while ((size_t)numTicks > yTicks.size()) {
353  cLineFigure *tick = new cLineFigure("yTick");
354  cLineFigure *dashLine = new cLineFigure("yDashLine");
355  cLabelFigure *number = new cLabelFigure("yNumber");
356 
357  dashLine->setLineStyle(LINE_DASHED);
358 
359  number->setAnchor(ANCHOR_W);
360  auto plotFigure = seriesPlotFigures[seriesPlotFigures.size() - 1];
361  tick->insertBelow(plotFigure);
362  dashLine->insertBelow(plotFigure);
363  number->insertBelow(plotFigure);
364  yTicks.push_back(Tick(tick, dashLine, number));
365  }
366  else
367  // Add or remove figures from canvas according to previous number of ticks
368  for (int i = yTicks.size() - 1; i >= numTicks; --i) {
369  delete removeFigure(yTicks[i].number);
370  delete removeFigure(yTicks[i].dashLine);
371  delete removeFigure(yTicks[i].tick);
372  yTicks.pop_back();
373  }
374 
375  for (size_t i = 0; i < yTicks.size(); ++i) {
376  double x = bounds.x + bounds.width;
377  double y = bounds.y + bounds.height - bounds.height * (i * yTickSize) / std::abs(maxY - minY);
378  if (y > bounds.y && y < bounds.y + bounds.height) {
379  yTicks[i].tick->setVisible(true);
380  yTicks[i].tick->setStart(Point(x, y));
381  yTicks[i].tick->setEnd(Point(x - TICK_LENGTH, y));
382 
383  yTicks[i].dashLine->setVisible(true);
384  yTicks[i].dashLine->setStart(Point(x - TICK_LENGTH, y));
385  yTicks[i].dashLine->setEnd(Point(bounds.x, y));
386  }
387  else {
388  yTicks[i].tick->setVisible(false);
389  yTicks[i].dashLine->setVisible(false);
390  }
391 
392  char buf[32];
393  sprintf(buf, yValueFormat, minY + i * yTickSize);
394  yTicks[i].number->setText(buf);
395  yTicks[i].number->setPosition(Point(x + 5, y + valueTickYposAdjust[i % 2]));
396  }
397 }

Referenced by layout().

◆ refreshDisplay()

void inet::PlotFigure::refreshDisplay ( )
overridevirtual

Reimplemented from inet::IIndicatorFigure.

521 {
522  if (invalidLayout)
523  layout();
524  else if (!std::isnan(timeWindow))
525  redrawXTicks();
526  if (invalidPlot)
527  plot();
528 }

Referenced by parse().

◆ setBackgroundColor()

void inet::PlotFigure::setBackgroundColor ( const Color color)
89 {
90  backgroundFigure->setFillColor(color);
91 }

Referenced by parse().

◆ setBounds()

void inet::PlotFigure::setBounds ( const Rectangle &  rect)
77 {
78  const auto& backgroundBounds = backgroundFigure->getBounds();
79  backgroundFigure->setBounds(Rectangle(backgroundBounds.x + rect.x - bounds.x, backgroundBounds.y + rect.y - bounds.y, rect.width - (bounds.width - backgroundBounds.width), rect.height - (bounds.height - backgroundBounds.height)));
80  invalidLayout = true;
81 }

Referenced by parse().

◆ setLabel()

void inet::PlotFigure::setLabel ( const char *  text)
inline
122 { labelFigure->setText(text); }

Referenced by parse().

◆ setLabelColor()

void inet::PlotFigure::setLabelColor ( const Color color)
225 {
226  labelFigure->setColor(color);
227 }

Referenced by parse().

◆ setLabelFont()

void inet::PlotFigure::setLabelFont ( const Font &  font)
215 {
216  labelFigure->setFont(font);
217 }

Referenced by parse().

◆ setLabelOffset()

void inet::PlotFigure::setLabelOffset ( int  offset)
201 {
202  if (labelOffset == offset)
203  return;
204 
205  labelOffset = offset;
206  invalidLayout = true;
207 }

Referenced by parse().

◆ setLineColor()

void inet::PlotFigure::setLineColor ( int  series,
const Color color 
)
155 {
156  seriesPlotFigures[series]->setLineColor(color);
157 }

Referenced by parse().

◆ setMaxX()

void inet::PlotFigure::setMaxX ( double  value)
169 {
170  if (maxX == value)
171  return;
172 
173  maxX = value;
174  invalidLayout = true;
175 }

Referenced by parse().

◆ setMaxY()

void inet::PlotFigure::setMaxY ( double  value)
187 {
188  if (maxY == value)
189  return;
190 
191  maxY = value;
192  invalidLayout = true;
193 }

Referenced by parse().

◆ setMinX()

void inet::PlotFigure::setMinX ( double  value)
160 {
161  if (minX == value)
162  return;
163 
164  minX = value;
165  invalidLayout = true;
166 }

Referenced by parse().

◆ setMinY()

void inet::PlotFigure::setMinY ( double  value)
178 {
179  if (minY == value)
180  return;
181 
182  minY = value;
183  invalidLayout = true;
184 }

Referenced by parse().

◆ setNumSeries()

void inet::PlotFigure::setNumSeries ( int  numSeries)
virtual
46 {
47  this->numSeries = numSeries;
48  seriesValues.resize(numSeries);
49  for (auto plotFigure : seriesPlotFigures) {
50  removeFigure(plotFigure);
51  delete plotFigure;
52  }
53  seriesPlotFigures.clear();
54  for (int i = 0; i < numSeries; i++) {
55  auto plotFigure = new cPathFigure("plot");
56  plotFigure->setLineColor(INIT_PLOT_COLOR);
57  addFigure(plotFigure);
58  seriesPlotFigures.push_back(plotFigure);
59  }
60 }

Referenced by PlotFigure().

◆ setPlotSize()

void inet::PlotFigure::setPlotSize ( const Point p)
63 {
64  const auto& backgroundBounds = backgroundFigure->getBounds();
65  backgroundFigure->setBounds(Rectangle(backgroundBounds.x, backgroundBounds.y, p.x, p.y));
66  invalidLayout = true;
67 }

◆ setTimeWindow()

void inet::PlotFigure::setTimeWindow ( double  timeWindow)
121 {
122  if (this->timeWindow == timeWindow)
123  return;
124 
125  this->timeWindow = timeWindow;
126 }

Referenced by parse().

◆ setValue() [1/2]

void inet::PlotFigure::setValue ( int  series,
double  x,
double  y 
)
virtual
304 {
305  seriesValues[series].push_front({ x, y });
306  invalidPlot = true;
307 }

◆ setValue() [2/2]

virtual void inet::PlotFigure::setValue ( int  series,
simtime_t  timestamp,
double  value 
)
inlineoverridevirtual

Implements inet::IIndicatorFigure.

71 { setValue(series, timestamp.dbl(), value); }

Referenced by setValue().

◆ setXAxisLabel()

void inet::PlotFigure::setXAxisLabel ( const char *  text)
inline
116 { xAxisLabelFigure->setText(text); }

◆ setXTickCount()

void inet::PlotFigure::setXTickCount ( int  count)
142 {
143  if (count != 0 && std::isfinite(minX) && std::isfinite(maxX))
144  setXTickSize((maxX - minX) / (count - 1));
145  else
147 }

◆ setXTickSize()

void inet::PlotFigure::setXTickSize ( double  size)
134 {
135  if (xTickSize == size)
136  return;
137 
138  xTickSize = size;
139 }

Referenced by parse(), and setXTickCount().

◆ setXValueFormat()

void inet::PlotFigure::setXValueFormat ( const char *  format)
inline
112 { xValueFormat = format; }

◆ setYAxisLabel()

void inet::PlotFigure::setYAxisLabel ( const char *  text)
inline
119 { yAxisLabelFigure->setText(text); }

◆ setYTickCount()

void inet::PlotFigure::setYTickCount ( int  count)
108 {
109  if (count != 0 && std::isfinite(minY) && std::isfinite(maxY))
110  setYTickSize((maxY - minY) / (count - 1));
111  else
113 }

◆ setYTickSize()

void inet::PlotFigure::setYTickSize ( double  size)
99 {
100  if (yTickSize == size)
101  return;
102 
103  yTickSize = size;
104  invalidLayout = true;
105 }

Referenced by parse(), and setYTickCount().

◆ setYValueFormat()

void inet::PlotFigure::setYValueFormat ( const char *  format)
inline
113 { yValueFormat = format; }

Member Data Documentation

◆ backgroundFigure

cRectangleFigure* inet::PlotFigure::backgroundFigure
private

◆ bounds

Rectangle inet::PlotFigure::bounds
private

◆ invalidLayout

bool inet::PlotFigure::invalidLayout = true
private

◆ invalidPlot

bool inet::PlotFigure::invalidPlot = true
private

Referenced by refreshDisplay(), and setValue().

◆ labelFigure

cLabelFigure* inet::PlotFigure::labelFigure
private

◆ labelOffset

int inet::PlotFigure::labelOffset = 0
private

◆ maxX

double inet::PlotFigure::maxX = 1
private

◆ maxY

double inet::PlotFigure::maxY = 1
private

◆ minX

double inet::PlotFigure::minX = 0
private

◆ minY

double inet::PlotFigure::minY = 0
private

◆ numSeries

int inet::PlotFigure::numSeries = -1
private

Referenced by parse(), plot(), and setNumSeries().

◆ seriesPlotFigures

std::vector<cPathFigure *> inet::PlotFigure::seriesPlotFigures
private

◆ seriesValues

std::vector<std::list<std::pair<double, double> > > inet::PlotFigure::seriesValues
private

Referenced by plot(), setNumSeries(), and setValue().

◆ timeWindow

double inet::PlotFigure::timeWindow = NaN
private

◆ xAxisLabelFigure

cLabelFigure* inet::PlotFigure::xAxisLabelFigure
private

Referenced by addChildren(), and layout().

◆ xTicks

std::vector<Tick> inet::PlotFigure::xTicks
private

Referenced by layout(), and redrawXTicks().

◆ xTickSize

double inet::PlotFigure::xTickSize = INFINITY
private

◆ xValueFormat

const char* inet::PlotFigure::xValueFormat = "%g"
private

Referenced by redrawXTicks().

◆ yAxisLabelFigure

cLabelFigure* inet::PlotFigure::yAxisLabelFigure
private

Referenced by addChildren(), and layout().

◆ yTicks

std::vector<Tick> inet::PlotFigure::yTicks
private

Referenced by redrawYTicks().

◆ yTickSize

double inet::PlotFigure::yTickSize = INFINITY
private

◆ yValueFormat

const char* inet::PlotFigure::yValueFormat = "%g"
private

Referenced by redrawYTicks().


The documentation for this class was generated from the following files:
inet::PlotFigure::yAxisLabelFigure
cLabelFigure * yAxisLabelFigure
Definition: PlotFigure.h:30
inet::PlotFigure::addChildren
void addChildren()
Definition: PlotFigure.cc:283
inet::PlotFigure::setBounds
void setBounds(const Rectangle &rect)
Definition: PlotFigure.cc:76
inet::PlotFigure::maxX
double maxX
Definition: PlotFigure.h:42
inet::PlotFigure::redrawXTicks
void redrawXTicks()
Definition: PlotFigure.cc:399
inet::PlotFigure::labelFigure
cLabelFigure * labelFigure
Definition: PlotFigure.h:28
inet::count
int count(const std::vector< T > &v, const Tk &a)
Definition: stlutils.h:54
inet::PlotFigure::seriesValues
std::vector< std::list< std::pair< double, double > > > seriesValues
Definition: PlotFigure.h:50
inet::PlotFigure::backgroundFigure
cRectangleFigure * backgroundFigure
Definition: PlotFigure.h:31
inet::sctp::min
double min(const double a, const double b)
Returns the minimum of a and b.
Definition: SctpAssociation.h:261
inet::PlotFigure::layout
void layout()
Definition: PlotFigure.cc:318
inet::PlotFigure::setNumSeries
virtual void setNumSeries(int numSeries)
Definition: PlotFigure.cc:45
inet::PlotFigure::setBackgroundColor
void setBackgroundColor(const Color &color)
Definition: PlotFigure.cc:88
inet::PlotFigure::invalidPlot
bool invalidPlot
Definition: PlotFigure.h:48
inet::PlotFigure::yTickSize
double yTickSize
Definition: PlotFigure.h:38
inet::PlotFigure::plot
void plot()
Definition: PlotFigure.cc:467
inet::PlotFigure::refreshDisplay
virtual void refreshDisplay() override
Definition: PlotFigure.cc:520
inet::values
std::vector< V > values(const std::map< K, V > &m)
Definition: stlutils.h:121
inet::units::values::s
value< double, units::s > s
Definition: Units.h:1235
inet::PlotFigure::maxY
double maxY
Definition: PlotFigure.h:44
INFINITY
#define INFINITY
Definition: Topology.h:20
inet::PlotFigure::setLabelFont
void setLabelFont(const Font &font)
Definition: PlotFigure.cc:214
inet::keys
std::vector< K > keys(const std::map< K, V > &m)
Definition: stlutils.h:113
inet::PlotFigure::invalidLayout
bool invalidLayout
Definition: PlotFigure.h:47
inet::PlotFigure::bounds
Rectangle bounds
Definition: PlotFigure.h:35
inet::PlotFigure::xTicks
std::vector< Tick > xTicks
Definition: PlotFigure.h:32
inet::units::values::b
value< int64_t, units::b > b
Definition: Units.h:1241
inet::PlotFigure::setLineColor
void setLineColor(int series, const Color &color)
Definition: PlotFigure.cc:154
inet::PlotFigure::getBounds
const Rectangle & getBounds() const
Definition: PlotFigure.cc:69
inet::PlotFigure::setLabelOffset
void setLabelOffset(int offset)
Definition: PlotFigure.cc:200
inet::PlotFigure::yTicks
std::vector< Tick > yTicks
Definition: PlotFigure.h:33
inet::PlotFigure::minY
double minY
Definition: PlotFigure.h:43
inet::PlotFigure::PlotFigure
PlotFigure(const char *name=nullptr)
Definition: PlotFigure.cc:39
inet::PlotFigure::setMinY
void setMinY(double value)
Definition: PlotFigure.cc:177
inet::PlotFigure::xTickSize
double xTickSize
Definition: PlotFigure.h:39
inet::PlotFigure::seriesPlotFigures
std::vector< cPathFigure * > seriesPlotFigures
Definition: PlotFigure.h:27
inet::PlotFigure::setMaxX
void setMaxX(double value)
Definition: PlotFigure.cc:168
inet::PlotFigure::setLabel
void setLabel(const char *text)
Definition: PlotFigure.h:122
inet::PlotFigure::setMinX
void setMinX(double value)
Definition: PlotFigure.cc:159
inet::PlotFigure::setYTickSize
void setYTickSize(double size)
Definition: PlotFigure.cc:98
inet::PlotFigure::setLabelColor
void setLabelColor(const Color &color)
Definition: PlotFigure.cc:224
inet::PlotFigure::setTimeWindow
void setTimeWindow(double timeWindow)
Definition: PlotFigure.cc:120
inet::PlotFigure::setXTickSize
void setXTickSize(double size)
Definition: PlotFigure.cc:133
inet::PlotFigure::yValueFormat
const char * yValueFormat
Definition: PlotFigure.h:46
inet::PlotFigure::xValueFormat
const char * xValueFormat
Definition: PlotFigure.h:45
inet::PlotFigure::numSeries
int numSeries
Definition: PlotFigure.h:36
inet::PlotFigure::labelOffset
int labelOffset
Definition: PlotFigure.h:40
inet::PlotFigure::redrawYTicks
void redrawYTicks()
Definition: PlotFigure.cc:338
inet::PlotFigure::timeWindow
double timeWindow
Definition: PlotFigure.h:37
inet::PlotFigure::xAxisLabelFigure
cLabelFigure * xAxisLabelFigure
Definition: PlotFigure.h:29
inet::PlotFigure::setValue
virtual void setValue(int series, simtime_t timestamp, double value) override
Definition: PlotFigure.h:71
inet::PlotFigure::minX
double minX
Definition: PlotFigure.h:41
M_PI
#define M_PI
Definition: INETMath.h:52
inet::PlotFigure::setMaxY
void setMaxY(double value)
Definition: PlotFigure.cc:186
InstrumentUtil::CohenSutherlandLineClip
static bool CohenSutherlandLineClip(double &x0, double &y0, double &x1, double &y1, double xmin, double xmax, double ymin, double ymax)
Cohen–Sutherland clipping algorithm clips a line from P0 = (x0, y0) to P1 = (x1, y1) against a rectan...
Definition: InstrumentUtil.cc:28