118 QPainter painter(
this);
119 painter.setRenderHint(QPainter::Antialiasing);
121 const int w = width();
122 const int h = height();
127 const int plotW = w - mLeft - mRight;
128 const int plotH = h - mTop - mBottom;
132 if (plotW <= 0 || plotH <= 0)
141 QLinearGradient gradient(mLeft, 0, mLeft + plotW, 0);
142 const int steps = 25;
143 double stepLeftMiddle = (middleNorm - leftNorm) / steps;
144 double stepMiddleRight = (rightNorm - middleNorm) / steps;
147 for (
int i = 1; i < steps; ++i) {
148 double pos1 = leftNorm + stepLeftMiddle * i;
149 double val1 =
static_cast<double>(i) * (0.5 /
static_cast<double>(steps));
152 double pos2 = middleNorm + stepMiddleRight * i;
153 double val2 = 0.5 +
static_cast<double>(i) * (0.5 /
static_cast<double>(steps));
158 painter.fillRect(QRect(mLeft, mTop, plotW, plotH), gradient);
162 painter.setPen(QPen(Qt::black, 1));
163 painter.drawLine(mLeft, mTop, mLeft, mTop + plotH);
164 painter.drawLine(mLeft, mTop + plotH, mLeft + plotW, mTop + plotH);
168 const int nYTicks = 5;
169 for (
int i = 0; i <= nYTicks; ++i) {
170 int yVal = maxFreq * i / nYTicks;
171 int y = mTop + plotH - (plotH * i / nYTicks);
172 painter.drawLine(mLeft - 5, y, mLeft, y);
173 painter.drawText(QRect(0, y - 10, mLeft - 8, 20), Qt::AlignRight | Qt::AlignVCenter, QString::number(yVal));
177 const int nXTicks = 5;
178 for (
int i = 0; i <= nXTicks; ++i) {
180 int x = mLeft + plotW * i / nXTicks;
181 painter.drawLine(x, mTop + plotH, x, mTop + plotH + 5);
182 painter.drawText(QRect(x - 30, mTop + plotH + 6, 60, 20), Qt::AlignCenter, QString::number(dataVal,
'g', 3));
196 painter.setBrush(QColor(70, 130, 180));
197 painter.drawEllipse(QPointF(px, py), 3, 3);
200 auto getPoint = [
this](
int idx) -> QPointF {
202 if (idx < 0) idx = 0;
203 if (idx >= count) idx = count - 1;
208 path.moveTo(getPoint(0));
210 for (
int i = 0; i < n - 1; ++i) {
211 QPointF p0 = getPoint(i - 1);
212 QPointF p1 = getPoint(i);
213 QPointF p2 = getPoint(i + 1);
214 QPointF p3 = getPoint(i + 2);
217 QPointF cp1(p1.x() + (p2.x() - p0.x()) / 6.0,
218 p1.y() + (p2.y() - p0.y()) / 6.0);
219 QPointF cp2(p2.x() - (p3.x() - p1.x()) / 6.0,
220 p2.y() - (p3.y() - p1.y()) / 6.0);
222 path.cubicTo(cp1, cp2, p2);
225 painter.setPen(QPen(QColor(70, 130, 180), 2));
226 painter.setBrush(Qt::NoBrush);
227 painter.drawPath(path);
232 auto drawThresholdLine = [&](
double dataX,
const QColor& color) {
235 painter.setPen(QPen(color, 2));
236 painter.drawLine(QPointF(px, mTop), QPointF(px, mTop + plotH));
292 qDebug() <<
"Data set not found.";
301 qDebug() <<
"One or more of the values given are out of the minimum and maximum range. Changed to default thresholds.";
307 double vals[3] = {
static_cast<double>(correctedVectorThreshold.x()),
308 static_cast<double>(correctedVectorThreshold.y()),
309 static_cast<double>(correctedVectorThreshold.z()) };
310 std::sort(vals, vals + 3);