17 #include <QFontDatabase>
22 inline bool operator()(
const double x,
const QPointF& pos)
const
54 bool changed =
_param != par;
69 for (
int i = 0; i <
_marker.size(); i++)
92 double min_Y = std::numeric_limits<double>::max();
93 double max_Y = -min_Y;
94 int visible_points = 0;
96 while (
_marker.size() > curves.size())
102 for (
int i =
_marker.size(); i < curves.size(); i++)
108 double text_X_offset = 0;
110 std::multimap<double, QString> text_lines;
112 for (
int i = 0; i < curves.size(); i++)
121 QColor
color = curve->
pen().color();
123 text_X_offset = rect.width() * 0.02;
132 const QLineF line =
curveLineAt(curve, position.x());
140 double middle_X = (line.p1().x() + line.p2().x()) / 2.0;
142 if (position.x() < middle_X)
149 if (rect.contains(point) &&
_visible)
151 min_Y = std::min(min_Y, point.y());
152 max_Y = std::max(max_Y, point.y());
155 double val = point.y();
160 int prec = settings.value(
"Preferences::precision", 3).toInt();
164 line = QString(
"<font color=%1>%2</font>").arg(
color.name()).arg(val);
168 QString value = QString::number(val,
'f', prec);
169 int whitespaces = 8 - value.length();
170 while (whitespaces-- > 0)
171 value.prepend(
" ");
173 line = QString(
"<font color=%1>%2 : %3</font>")
179 text_lines.insert(std::make_pair(val, line));
191 QString text_marker_info;
194 for (
auto it = text_lines.rbegin(); it != text_lines.rend(); it++)
196 text_marker_info += it->second;
197 if (
count++ < text_lines.size() - 1)
199 text_marker_info +=
"<br>";
204 QColor background_color =
_plot->palette().background().color();
205 background_color.setAlpha(180);
207 mark_text.
setText(text_marker_info);
209 QFont font = QFontDatabase::systemFont(QFontDatabase::FixedFont);
210 font.setPointSize(9);
220 if (visible_points > 0)
225 double canvas_ratio = rect.width() / double(
_plot->width());
226 double text_width = mark_text.
textSize().width() * canvas_ratio;
245 int index = qwtUpperSampleIndex<QPointF>(*curve->
data(),
x,
compareX());
249 line.setP1(curve->
sample(index - 1));
250 line.setP2(curve->
sample(index));