|
INET Framework for OMNeT++/OMNEST
|
#include <PlotFigure.h>
◆ PlotFigure()
| inet::PlotFigure::PlotFigure |
( |
const char * |
name = nullptr | ) |
|
◆ ~PlotFigure()
| virtual inet::PlotFigure::~PlotFigure |
( |
| ) |
|
|
inlinevirtual |
◆ addChildren()
| void inet::PlotFigure::addChildren |
( |
| ) |
|
|
protected |
◆ clearValues()
| virtual void inet::PlotFigure::clearValues |
( |
int |
series | ) |
|
|
inlinevirtual |
◆ getAllowedPropertyKeys()
| const char ** inet::PlotFigure::getAllowedPropertyKeys |
( |
| ) |
const |
|
override |
270 static const char *
keys[32];
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
278 concatArrays(
keys, cGroupFigure::getAllowedPropertyKeys(), localKeys);
◆ getBackgrouncColor()
| const cFigure::Color & inet::PlotFigure::getBackgrouncColor |
( |
| ) |
const |
◆ getBounds()
| const cFigure::Rectangle & inet::PlotFigure::getBounds |
( |
| ) |
const |
◆ getLabel()
| const char* inet::PlotFigure::getLabel |
( |
| ) |
const |
|
inline |
◆ getLabelColor()
| const cFigure::Color & inet::PlotFigure::getLabelColor |
( |
| ) |
const |
◆ getLabelFont()
| const cFigure::Font & inet::PlotFigure::getLabelFont |
( |
| ) |
const |
◆ getLabelOffset()
| int inet::PlotFigure::getLabelOffset |
( |
| ) |
const |
◆ getLineColor()
| const cFigure::Color & inet::PlotFigure::getLineColor |
( |
int |
series | ) |
const |
◆ getMaxX()
| double inet::PlotFigure::getMaxX |
( |
| ) |
const |
|
inline |
◆ getMaxY()
| double inet::PlotFigure::getMaxY |
( |
| ) |
const |
|
inline |
◆ getMinX()
| double inet::PlotFigure::getMinX |
( |
| ) |
const |
|
inline |
◆ getMinY()
| double inet::PlotFigure::getMinY |
( |
| ) |
const |
|
inline |
◆ getNumSeries()
| virtual int inet::PlotFigure::getNumSeries |
( |
| ) |
const |
|
inlineoverridevirtual |
◆ getPlotSize()
| const Point inet::PlotFigure::getPlotSize |
( |
| ) |
const |
|
inline |
◆ getSize()
| virtual const Point inet::PlotFigure::getSize |
( |
| ) |
const |
|
inlineoverridevirtual |
◆ getTimeWindow()
| double inet::PlotFigure::getTimeWindow |
( |
| ) |
const |
◆ getXAxisLabel()
| const char* inet::PlotFigure::getXAxisLabel |
( |
| ) |
const |
|
inline |
◆ getXTickSize()
| double inet::PlotFigure::getXTickSize |
( |
| ) |
const |
◆ getYAxisLabel()
| const char* inet::PlotFigure::getYAxisLabel |
( |
| ) |
const |
|
inline |
◆ getYTickSize()
| double inet::PlotFigure::getYTickSize |
( |
| ) |
const |
◆ layout()
| void inet::PlotFigure::layout |
( |
| ) |
|
|
protected |
◆ parse()
| void inet::PlotFigure::parse |
( |
cProperty * |
property | ) |
|
|
overridevirtual |
231 cGroupFigure::parse(property);
237 if ((
s = property->getValue(PKEY_BACKGROUND_COLOR)) !=
nullptr)
239 if ((
s = property->getValue(PKEY_X_TICK_SIZE)) !=
nullptr)
241 if ((
s = property->getValue(PKEY_Y_TICK_SIZE)) !=
nullptr)
243 if ((
s = property->getValue(PKEY_TIME_WINDOW)) !=
nullptr)
245 if ((
s = property->getValue(PKEY_LINE_COLOR)) !=
nullptr) {
249 if ((
s = property->getValue(PKEY_MIN_X)) !=
nullptr)
251 if ((
s = property->getValue(PKEY_MAX_X)) !=
nullptr)
253 if ((
s = property->getValue(PKEY_MIN_Y)) !=
nullptr)
255 if ((
s = property->getValue(PKEY_MAX_Y)) !=
nullptr)
257 if ((
s = property->getValue(PKEY_LABEL)) !=
nullptr)
259 if ((
s = property->getValue(PKEY_LABEL_OFFSET)) !=
nullptr)
261 if ((
s = property->getValue(PKEY_LABEL_COLOR)) !=
nullptr)
263 if ((
s = property->getValue(PKEY_LABEL_FONT)) !=
nullptr)
◆ plot()
| void inet::PlotFigure::plot |
( |
| ) |
|
|
protected |
475 plotFigure->clearPath();
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);
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);
495 double originalStartX = startX;
496 double originalStartY = startY;
497 double originalEndX = endX;
498 double originalEndY = endY;
500 if (originalStartX != startX || originalStartY != startY)
501 plotFigure->addMoveTo(startX, startY);
503 plotFigure->addLineTo(endX, endY);
506 if (
minX > it->first)
509 startX = originalEndX;
510 startY = originalEndY;
512 }
while (it !=
values.end());
Referenced by refreshDisplay().
◆ redrawXTicks()
| void inet::PlotFigure::redrawXTicks |
( |
| ) |
|
|
protected |
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");
423 dashLine->setLineStyle(LINE_DASHED);
425 number->setAnchor(ANCHOR_N);
427 tick->insertBelow(plotFigure);
428 dashLine->insertBelow(plotFigure);
429 number->insertBelow(plotFigure);
430 xTicks.push_back(Tick(tick, dashLine, number));
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);
441 for (uint32_t i = 0; i <
xTicks.size(); ++i) {
445 xTicks[i].tick->setVisible(
true);
446 xTicks[i].tick->setStart(Point(x, y));
447 xTicks[i].tick->setEnd(Point(x, y - TICK_LENGTH));
449 xTicks[i].dashLine->setVisible(
true);
450 xTicks[i].dashLine->setStart(Point(x, y - TICK_LENGTH));
454 xTicks[i].tick->setVisible(
false);
455 xTicks[i].dashLine->setVisible(
false);
462 xTicks[i].number->setText(buf);
463 xTicks[i].number->setPosition(Point(x, y + 5));
Referenced by layout(), and refreshDisplay().
◆ redrawYTicks()
| void inet::PlotFigure::redrawYTicks |
( |
| ) |
|
|
protected |
343 double valueTickYposAdjust[2] = { 0, 0 };
346 valueTickYposAdjust[0] = -(fontSize / 2);
347 valueTickYposAdjust[1] = fontSize / 2;
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");
357 dashLine->setLineStyle(LINE_DASHED);
359 number->setAnchor(ANCHOR_W);
361 tick->insertBelow(plotFigure);
362 dashLine->insertBelow(plotFigure);
363 number->insertBelow(plotFigure);
364 yTicks.push_back(Tick(tick, dashLine, number));
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);
375 for (
size_t i = 0; i <
yTicks.size(); ++i) {
379 yTicks[i].tick->setVisible(
true);
380 yTicks[i].tick->setStart(Point(x, y));
381 yTicks[i].tick->setEnd(Point(x - TICK_LENGTH, y));
383 yTicks[i].dashLine->setVisible(
true);
384 yTicks[i].dashLine->setStart(Point(x - TICK_LENGTH, y));
388 yTicks[i].tick->setVisible(
false);
389 yTicks[i].dashLine->setVisible(
false);
394 yTicks[i].number->setText(buf);
395 yTicks[i].number->setPosition(Point(x + 5, y + valueTickYposAdjust[i % 2]));
Referenced by layout().
◆ refreshDisplay()
| void inet::PlotFigure::refreshDisplay |
( |
| ) |
|
|
overridevirtual |
◆ setBackgroundColor()
| void inet::PlotFigure::setBackgroundColor |
( |
const Color & |
color | ) |
|
◆ setBounds()
| void inet::PlotFigure::setBounds |
( |
const Rectangle & |
rect | ) |
|
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)));
Referenced by parse().
◆ setLabel()
| void inet::PlotFigure::setLabel |
( |
const char * |
text | ) |
|
|
inline |
◆ setLabelColor()
| void inet::PlotFigure::setLabelColor |
( |
const Color & |
color | ) |
|
◆ setLabelFont()
| void inet::PlotFigure::setLabelFont |
( |
const Font & |
font | ) |
|
◆ setLabelOffset()
| void inet::PlotFigure::setLabelOffset |
( |
int |
offset | ) |
|
◆ setLineColor()
| void inet::PlotFigure::setLineColor |
( |
int |
series, |
|
|
const Color & |
color |
|
) |
| |
◆ setMaxX()
| void inet::PlotFigure::setMaxX |
( |
double |
value | ) |
|
◆ setMaxY()
| void inet::PlotFigure::setMaxY |
( |
double |
value | ) |
|
◆ setMinX()
| void inet::PlotFigure::setMinX |
( |
double |
value | ) |
|
◆ setMinY()
| void inet::PlotFigure::setMinY |
( |
double |
value | ) |
|
◆ setNumSeries()
| void inet::PlotFigure::setNumSeries |
( |
int |
numSeries | ) |
|
|
virtual |
50 removeFigure(plotFigure);
55 auto plotFigure =
new cPathFigure(
"plot");
56 plotFigure->setLineColor(INIT_PLOT_COLOR);
57 addFigure(plotFigure);
Referenced by PlotFigure().
◆ setPlotSize()
| void inet::PlotFigure::setPlotSize |
( |
const Point & |
p | ) |
|
65 backgroundFigure->setBounds(Rectangle(backgroundBounds.x, backgroundBounds.y, p.x, p.y));
◆ setTimeWindow()
| void inet::PlotFigure::setTimeWindow |
( |
double |
timeWindow | ) |
|
◆ setValue() [1/2]
| void inet::PlotFigure::setValue |
( |
int |
series, |
|
|
double |
x, |
|
|
double |
y |
|
) |
| |
|
virtual |
◆ setValue() [2/2]
| virtual void inet::PlotFigure::setValue |
( |
int |
series, |
|
|
simtime_t |
timestamp, |
|
|
double |
value |
|
) |
| |
|
inlineoverridevirtual |
◆ setXAxisLabel()
| void inet::PlotFigure::setXAxisLabel |
( |
const char * |
text | ) |
|
|
inline |
◆ setXTickCount()
| void inet::PlotFigure::setXTickCount |
( |
int |
count | ) |
|
143 if (
count != 0 && std::isfinite(
minX) && std::isfinite(
maxX))
◆ setXTickSize()
| void inet::PlotFigure::setXTickSize |
( |
double |
size | ) |
|
◆ setXValueFormat()
| void inet::PlotFigure::setXValueFormat |
( |
const char * |
format | ) |
|
|
inline |
◆ setYAxisLabel()
| void inet::PlotFigure::setYAxisLabel |
( |
const char * |
text | ) |
|
|
inline |
◆ setYTickCount()
| void inet::PlotFigure::setYTickCount |
( |
int |
count | ) |
|
109 if (
count != 0 && std::isfinite(
minY) && std::isfinite(
maxY))
◆ setYTickSize()
| void inet::PlotFigure::setYTickSize |
( |
double |
size | ) |
|
◆ setYValueFormat()
| void inet::PlotFigure::setYValueFormat |
( |
const char * |
format | ) |
|
|
inline |
◆ backgroundFigure
| cRectangleFigure* inet::PlotFigure::backgroundFigure |
|
private |
◆ bounds
| Rectangle inet::PlotFigure::bounds |
|
private |
◆ invalidLayout
| bool inet::PlotFigure::invalidLayout = true |
|
private |
Referenced by getBounds(), layout(), refreshDisplay(), setBounds(), setLabelOffset(), setMaxX(), setMaxY(), setMinX(), setMinY(), setPlotSize(), and setYTickSize().
◆ invalidPlot
| bool inet::PlotFigure::invalidPlot = true |
|
private |
◆ 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 |
◆ seriesPlotFigures
| std::vector<cPathFigure *> inet::PlotFigure::seriesPlotFigures |
|
private |
◆ seriesValues
| std::vector<std::list<std::pair<double, double> > > inet::PlotFigure::seriesValues |
|
private |
◆ timeWindow
| double inet::PlotFigure::timeWindow = NaN |
|
private |
◆ xAxisLabelFigure
| cLabelFigure* inet::PlotFigure::xAxisLabelFigure |
|
private |
◆ xTicks
| std::vector<Tick> inet::PlotFigure::xTicks |
|
private |
◆ xTickSize
| double inet::PlotFigure::xTickSize = INFINITY |
|
private |
◆ xValueFormat
| const char* inet::PlotFigure::xValueFormat = "%g" |
|
private |
◆ yAxisLabelFigure
| cLabelFigure* inet::PlotFigure::yAxisLabelFigure |
|
private |
◆ yTicks
| std::vector<Tick> inet::PlotFigure::yTicks |
|
private |
◆ yTickSize
| double inet::PlotFigure::yTickSize = INFINITY |
|
private |
◆ yValueFormat
| const char* inet::PlotFigure::yValueFormat = "%g" |
|
private |
The documentation for this class was generated from the following files:
int count(const std::vector< T > &v, const Tk &a)
Definition: stlutils.h:54
double min(const double a, const double b)
Returns the minimum of a and b.
Definition: SctpAssociation.h:261
std::vector< V > values(const std::map< K, V > &m)
Definition: stlutils.h:121
value< double, units::s > s
Definition: Units.h:1235
#define INFINITY
Definition: Topology.h:20
std::vector< K > keys(const std::map< K, V > &m)
Definition: stlutils.h:113
value< int64_t, units::b > b
Definition: Units.h:1241
#define M_PI
Definition: INETMath.h:52
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