47 #include <QGridLayout>
48 #include <QtCharts/QLegendMarker>
49 #include <QtCharts/QChartView>
60 using namespace DISPLIB;
61 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
62 using namespace QtCharts;
73 , m_pLeftThreshold(new QLineSeries())
74 , m_pMiddleThreshold(new QLineSeries())
75 , m_pRightThreshold(new QLineSeries())
76 , m_iMaximumFrequency(0)
81 m_pChart->setAnimationOptions(QChart::SeriesAnimations);
82 m_pChart->setAcceptHoverEvents(
false);
84 QChartView *chartView =
new QChartView(
m_pChart);
85 chartView->setRenderHint(QPainter::Antialiasing);
86 QGridLayout* layout =
new QGridLayout();
87 layout->addWidget(chartView, 0, 0);
88 this->setLayout(layout);
97 qDebug() <<
"Data set not found.";
102 QXYSeries *shadowSeries = qobject_cast<QXYSeries *>(sender());
103 QLineSeries *verticalLine =
new QLineSeries();
104 QPointF point =
event->pos();
105 QPointF pointY = point;
107 pointY.setY(pointY.y()-10.5);
108 point.setX(point.x()-10.5);
111 QPointF localX =
m_pChart->mapToValue(point, shadowSeries);
112 QPointF localY =
m_pChart->mapToValue(pointY, shadowSeries);
113 verticalLine->append(localX.x(), 0);
115 double boundaryX = double(localX.x());
116 double boundaryY = double(localY.y());
130 if (event->buttons() == Qt::LeftButton)
132 leftPoint = verticalLine->pointsVector();
133 if((leftPoint[0].x() < middlePoint[0].x()) && (leftPoint[0].x() < rightPoint[0].x()))
144 if (event->buttons() == Qt::MiddleButton)
146 middlePoint = verticalLine->pointsVector();
147 if((middlePoint[0].x() > leftPoint[0].x()) && (middlePoint[0].x() < rightPoint[0].x()))
158 if (event->buttons() == Qt::RightButton)
160 rightPoint = verticalLine->pointsVector();
161 if((rightPoint[0].x() > leftPoint[0].x()) && (rightPoint[0].x() > middlePoint[0].x()))
181 float leftThresholdValue = vecThresholdValues.x();
182 float middleThresholdValue = vecThresholdValues.y();
183 float rightThresholdValue = vecThresholdValues.z();
189 qDebug() <<
"Data set not found.";
195 qDebug() <<
"One or more of the values given are out of the minimum and maximum range. Changed to default thresholds.";
202 if ((correctedVectorThreshold.x() < correctedVectorThreshold.y()) && (correctedVectorThreshold.x() < correctedVectorThreshold.z()))
204 leftThresholdValue = correctedVectorThreshold.x();
205 if(correctedVectorThreshold.y() < correctedVectorThreshold.z())
207 middleThresholdValue = correctedVectorThreshold.y();
208 rightThresholdValue = correctedVectorThreshold.z();
212 middleThresholdValue = correctedVectorThreshold.z();
213 rightThresholdValue = correctedVectorThreshold.y();
216 if ((correctedVectorThreshold.y() < correctedVectorThreshold.x()) && (correctedVectorThreshold.y() < correctedVectorThreshold.z()))
218 leftThresholdValue = correctedVectorThreshold.y();
220 if(correctedVectorThreshold.x() < correctedVectorThreshold.z())
222 middleThresholdValue = correctedVectorThreshold.x();
223 rightThresholdValue = correctedVectorThreshold.z();
227 middleThresholdValue = correctedVectorThreshold.z();
228 rightThresholdValue = correctedVectorThreshold.x();
231 if ((correctedVectorThreshold.z() < correctedVectorThreshold.x()) && (correctedVectorThreshold.z() < correctedVectorThreshold.y()))
233 leftThresholdValue = correctedVectorThreshold.z();
235 if(correctedVectorThreshold.x() < correctedVectorThreshold.y())
237 middleThresholdValue = correctedVectorThreshold.x();
238 rightThresholdValue = correctedVectorThreshold.y();
242 middleThresholdValue = correctedVectorThreshold.y();
243 rightThresholdValue = correctedVectorThreshold.x();
248 QPointF leftThresholdPoint;
249 QPointF middleThresholdPoint;
250 QPointF rightThresholdPoint;
252 leftThresholdPoint.setX(leftThresholdValue);
253 middleThresholdPoint.setX(middleThresholdValue);
254 rightThresholdPoint.setX(rightThresholdValue);
273 if (lineSeries->name() ==
"left")
275 lineSeries->setColor(
"red");
277 else if (lineSeries->name() ==
"middle")
279 lineSeries->setColor(
"green");
281 else if (lineSeries->name() ==
"right")
283 lineSeries->setColor(
"blue");
287 qDebug()<<
"Error: lineSeries->name() is not 'left', 'middle' or 'right'.";
289 lineSeries->setVisible(
true);
291 m_pChart->legend()->markers().at(
m_pChart->legend()->markers().size()-1)->setVisible(
false);
303 int stepsNumber = 25;
304 double stepsSizeLeftMiddle = (middleThresholdValue - leftThresholdValue) / stepsNumber;
305 double stepsSizeMiddleRight = (rightThresholdValue - middleThresholdValue) / stepsNumber;
306 QLinearGradient plotAreaGradient;
307 plotAreaGradient.setStart(QPointF(0, 0));
308 plotAreaGradient.setFinalStop(QPointF(1, 0));
312 for (
int i = 1; i < stepsNumber; ++i)
314 plotAreaGradient.setColorAt(leftThresholdValue + (stepsSizeLeftMiddle * i),
ColorMap::valueToColor((
double)i * (0.5 / (
double)stepsNumber), colorMap));
315 plotAreaGradient.setColorAt(middleThresholdValue + (stepsSizeMiddleRight * i),
ColorMap::valueToColor((
double)0.5 + (i * (0.5 / (
double)stepsNumber)), colorMap));
320 plotAreaGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
321 m_pChart->setPlotAreaBackgroundBrush(plotAreaGradient);
322 m_pChart->setPlotAreaBackgroundVisible(
true);
332 float emitLeft = leftPoint[0].x();
333 float emitMiddle = middlePoint[0].x();
334 float emitRight = rightPoint[0].x();
335 QVector3D originalVector;
336 originalVector.setX(emitLeft);
337 originalVector.setY(emitMiddle);
338 originalVector.setZ(emitRight);
347 QVector3D returnCorrectedVector;
351 if (upOrDown ==
"up")
366 else if (upOrDown ==
"down")
383 qDebug() <<
"Spline::correctionDisplayTrueValue error.";
386 returnCorrectedVector.setX(vecOriginalValues.x() * (pow(10, exponent)));
387 returnCorrectedVector.setY(vecOriginalValues.y() * (pow(10, exponent)));
388 returnCorrectedVector.setZ(vecOriginalValues.z() * (pow(10, exponent)));
391 return returnCorrectedVector;