Skip to content

Commit a62b810

Browse files
committed
gui: add Chart::addVerticalMarker
Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
1 parent b08ba66 commit a62b810

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

src/gui/include/gui/gui.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,8 @@ class Chart
579579
= 0;
580580
virtual void addPoint(double x, double y) = 0;
581581

582+
virtual void addVerticalMarker(double x, const Painter::Color& color) = 0;
583+
582584
protected:
583585
Chart() = default;
584586
};

src/gui/src/chartsWidget.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ class GuiChart : public Chart
3737
odb::Orientation2D orientation) override;
3838
void addPoint(double x, double y) override;
3939

40+
void addVerticalMarker(double x, const Painter::Color& color) override;
41+
4042
private:
4143
QChart* chart_;
4244
QLineSeries* series_;
@@ -87,6 +89,22 @@ void GuiChart::addPoint(const double x, const double y)
8789
y_axis_->setMax(y_max_);
8890
}
8991

92+
void GuiChart::addVerticalMarker(const double x, const Painter::Color& color)
93+
{
94+
QLineSeries* vline = new QLineSeries();
95+
vline->append(x, y_axis_->min());
96+
vline->append(x, y_axis_->max());
97+
98+
QColor qt_color(color.r, color.g, color.b, color.a);
99+
vline->setPen(QPen(qt_color, 2, Qt::DashLine));
100+
101+
chart_->addSeries(vline);
102+
103+
// link to same axes
104+
vline->attachAxis(x_axis_);
105+
vline->attachAxis(y_axis_);
106+
}
107+
90108
//////////////////////////////////////////////////
91109

92110
ChartsWidget::ChartsWidget(QWidget* parent)

0 commit comments

Comments
 (0)