17 #include <QFontDatabase>
21 inline bool operator()(
const double x,
const QPointF& pos)
const
53 bool changed =
_param != par;
68 for (
int i = 0; i <
_marker.size(); i++)
91 double min_Y = std::numeric_limits<double>::max();
92 double max_Y = -min_Y;
93 int visible_points = 0;
95 while (
_marker.size() > curves.size())
101 for (
int i =
_marker.size(); i < curves.size(); i++)
107 double text_X_offset = 0;
109 std::multimap<double, QString> text_lines;
111 for (
int i = 0; i < curves.size(); i++)
120 QColor
color = curve->
pen().color();
122 text_X_offset = rect.width() * 0.02;
131 const QLineF line =
curveLineAt(curve, position.x());
139 double middle_X = (line.p1().x() + line.p2().x()) / 2.0;
141 if (position.x() < middle_X)
148 if (rect.contains(point) &&
_visible)
150 min_Y = std::min(min_Y, point.y());
151 max_Y = std::max(max_Y, point.y());
154 double val = point.y();
160 line = QString(
"<font color=%1>%2</font>").arg(
color.name()).arg(val);
164 QString value = QString::number(val,
'f', 3);
165 int whitespaces = 8 - value.length();
166 while (whitespaces-- > 0)
167 value.prepend(
" ");
169 line = QString(
"<font color=%1>%2 : %3</font>")
175 text_lines.insert(std::make_pair(val, line));
187 QString text_marker_info;
190 for (
auto it = text_lines.rbegin(); it != text_lines.rend(); it++)
192 text_marker_info += it->second;
193 if (
count++ < text_lines.size() - 1)
195 text_marker_info +=
"<br>";
200 QColor background_color =
_plot->palette().background().color();
201 background_color.setAlpha(180);
203 mark_text.
setText(text_marker_info);
205 QFont font = QFontDatabase::systemFont(QFontDatabase::FixedFont);
206 font.setPointSize(9);
216 if (visible_points > 0)
221 double canvas_ratio = rect.width() / double(
_plot->width());
222 double text_width = mark_text.
textSize().width() * canvas_ratio;
241 int index = qwtUpperSampleIndex<QPointF>(*curve->
data(),
x,
compareX());
245 line.setP1(curve->
sample(index - 1));
246 line.setP2(curve->
sample(index));