100 QPainter painter(
this);
101 painter.setRenderHint(QPainter::Antialiasing);
103 const int w = width();
104 const int h = height();
109 const int plotW = w - mLeft - mRight;
110 const int plotH = h - mTop - mBottom;
114 if (plotW <= 0 || plotH <= 0)
123 QLinearGradient gradient(mLeft, 0, mLeft + plotW, 0);
124 const int steps = 25;
125 double stepLeftMiddle = (middleNorm - leftNorm) / steps;
126 double stepMiddleRight = (rightNorm - middleNorm) / steps;
129 for (
int i = 1; i < steps; ++i) {
130 double pos1 = leftNorm + stepLeftMiddle * i;
131 double val1 =
static_cast<double>(i) * (0.5 /
static_cast<double>(steps));
134 double pos2 = middleNorm + stepMiddleRight * i;
135 double val2 = 0.5 +
static_cast<double>(i) * (0.5 /
static_cast<double>(steps));
140 painter.fillRect(QRect(mLeft, mTop, plotW, plotH), gradient);
144 painter.setPen(QPen(Qt::black, 1));
145 painter.drawLine(mLeft, mTop, mLeft, mTop + plotH);
146 painter.drawLine(mLeft, mTop + plotH, mLeft + plotW, mTop + plotH);
150 const int nYTicks = 5;
151 for (
int i = 0; i <= nYTicks; ++i) {
152 int yVal = maxFreq * i / nYTicks;
153 int y = mTop + plotH - (plotH * i / nYTicks);
154 painter.drawLine(mLeft - 5, y, mLeft, y);
155 painter.drawText(QRect(0, y - 10, mLeft - 8, 20), Qt::AlignRight | Qt::AlignVCenter, QString::number(yVal));
159 const int nXTicks = 5;
160 for (
int i = 0; i <= nXTicks; ++i) {
162 int x = mLeft + plotW * i / nXTicks;
163 painter.drawLine(x, mTop + plotH, x, mTop + plotH + 5);
164 painter.drawText(QRect(x - 30, mTop + plotH + 6, 60, 20), Qt::AlignCenter, QString::number(dataVal,
'g', 3));
178 painter.setBrush(QColor(70, 130, 180));
179 painter.drawEllipse(QPointF(px, py), 3, 3);
182 auto getPoint = [
this](
int idx) -> QPointF {
192 path.moveTo(getPoint(0));
194 for (
int i = 0; i < n - 1; ++i) {
195 QPointF p0 = getPoint(i - 1);
196 QPointF p1 = getPoint(i);
197 QPointF p2 = getPoint(i + 1);
198 QPointF p3 = getPoint(i + 2);
201 QPointF cp1(p1.x() + (p2.x() - p0.x()) / 6.0,
202 p1.y() + (p2.y() - p0.y()) / 6.0);
203 QPointF cp2(p2.x() - (p3.x() - p1.x()) / 6.0,
204 p2.y() - (p3.y() - p1.y()) / 6.0);
206 path.cubicTo(cp1, cp2, p2);
209 painter.setPen(QPen(QColor(70, 130, 180), 2));
210 painter.setBrush(Qt::NoBrush);
211 painter.drawPath(path);
216 auto drawThresholdLine = [&](
double dataX,
const QColor& color) {
219 painter.setPen(QPen(color, 2));
220 painter.drawLine(QPointF(px, mTop), QPointF(px, mTop + plotH));
276 qDebug() <<
"Data set not found.";
285 qDebug() <<
"One or more of the values given are out of the minimum and maximum range. Changed to default thresholds.";
293 double vals[3] = {
static_cast<double>(correctedVectorThreshold.x()),
294 static_cast<double>(correctedVectorThreshold.y()),
295 static_cast<double>(correctedVectorThreshold.z())};
296 std::sort(vals, vals + 3);