11 #include <QFontDatabase> 15 inline bool operator()(
const double x,
const QPointF& pos)
const 47 bool changed =
_param != par;
62 for (
int i = 0; i <
_marker.size(); i++)
86 double max_Y = -min_Y;
87 int visible_points = 0;
89 while (
_marker.size() > curves.size())
95 for (
int i =
_marker.size(); i < curves.size(); i++)
101 double text_X_offset = 0;
103 std::multimap<double, QString> text_lines;
105 for (
int i = 0; i < curves.size(); i++)
114 QColor color = curve->
pen().color();
116 text_X_offset = rect.width() * 0.02;
118 if (!
_marker[i]->symbol() ||
_marker[i]->symbol()->brush().color() != color)
124 const QLineF line =
curveLineAt(curve, position.x());
132 double middle_X = (line.p1().x() + line.p2().x()) / 2.0;
134 if (position.x() < middle_X)
141 if (rect.contains(point) &&
_visible)
147 double val = point.y();
153 line = QString(
"<font color=%1>%2</font>").arg(color.name()).
arg(val);
157 QString
value = QString::number(val,
'f', 3);
158 int whitespaces = 8 - value.length();
159 while (whitespaces-- > 0)
160 value.prepend(
" ");
162 line = QString(
"<font color=%1>%2 : %3</font>").arg(color.name()).
arg(value).arg(curve->
title().
text());
165 text_lines.insert(std::make_pair(val, line));
177 QString text_marker_info;
180 for (
auto it = text_lines.rbegin(); it != text_lines.rend(); it++)
182 text_marker_info += it->second;
183 if (count++ < text_lines.size() - 1)
185 text_marker_info +=
"<br>";
190 QColor background_color =
_plot->palette().background().color();
191 background_color.setAlpha(180);
193 mark_text.
setText(text_marker_info);
195 QFont font = QFontDatabase::systemFont(QFontDatabase::FixedFont);
196 font.setPointSize(9);
206 if (visible_points > 0)
211 double canvas_ratio = rect.width() / double(
_plot->width());
212 double text_width = mark_text.
textSize().width() * canvas_ratio;
231 int index = qwtUpperSampleIndex<QPointF>(*curve->
data(), x,
compareX());
235 line.setP1(curve->
sample(index - 1));
236 line.setP2(curve->
sample(index));
void setLineStyle(LineStyle)
Set the line style.
enum MQTTPropertyCodes value
A plot item, that represents a series of points.
void setFont(const QFont &)
void setValue(double, double)
Set Value.
void setRenderFlags(int)
Change the render flags.
void setText(const QString &, QwtText::TextFormat textFormat=AutoText)
void setBorderPen(const QPen &)
const QwtPlotItemList & itemList() const
A QwtPlotItemList of all attached plot items.
QwtSeriesData< T > * data()
A class for drawing symbols.
Y axis left of the canvas.
void setLinePen(const QColor &, qreal width=0.0, Qt::PenStyle=Qt::SolidLine)
virtual QRectF boundingRect() const QWT_OVERRIDE
QwtPlotMarker * _line_marker
QLineF curveLineAt(const QwtPlotCurve *, double x) const
void setXValue(double)
Set X Value.
A class representing a text.
virtual QwtScaleMap canvasMap(int axisId) const
void setBackgroundBrush(const QBrush &)
T sample(int index) const
void setEnabled(bool enable)
detail::named_arg< Char, T > arg(const Char *name, const T &arg)
QwtPlotMarker * _text_marker
void setLabel(const QwtText &)
Set the label.
QPointF _prev_trackerpoint
std::vector< QwtPlotMarker * > _marker
virtual void setVisible(bool)
void attach(QwtPlot *plot)
Attach the item to a plot.
void setLabelAlignment(Qt::Alignment)
Set the alignment of the label.
void setYValue(double)
Set Y Value.
QPointF actualPosition() const
virtual size_t dataSize() const QWT_OVERRIDE
void setPosition(const QPointF &pos)
void setParameter(Parameter par)
bool operator()(const double x, const QPointF &pos) const
A class for drawing markers.
const QwtText & title() const