37 : QWidget(parent), m_mode(
PlotMode::
LINE), m_numPoints(0), m_minX(0), m_maxX(1000)
59 float max = points[0], min = points[0];
60 for (
int i = 0; i < numPoints; i++)
99 QPainter painter(
this);
101 painter.setPen(QColor(255, 255, 255));
102 painter.setBrush(QColor(255, 255, 255));
104 painter.drawRect(0, 0, width(), height());
106 painter.setPen(QColor(0, 0, 0));
107 painter.setBrush(QColor(0, 0, 0));
110 painter.drawText(0, 0, width(), height(), Qt::AlignTop, QString(
"%1").arg(
m_max), &rect);
111 int leftMargin = rect.width() + 1;
113 painter.drawText(0, 0, width(), height(), Qt::AlignBottom, QString(
"%1").arg(
m_min), &rect);
114 leftMargin = rect.width() + 1 > leftMargin ? rect.width() + 1 : leftMargin;
116 painter.drawLine(leftMargin, 0, leftMargin, height());
118 float drawWidth = width() - leftMargin;
121 int count = width() / 70;
122 for (
int i = 0; i < count; i++)
124 float new_x = i * drawWidth / count + leftMargin;
125 painter.drawText(new_x, height() - 20, width(), height(), Qt::AlignTop, QString(
"%1").arg(i * (
m_maxX -
m_minX) / count +
m_minX), &rect);
128 int botMargin = rect.height() + 1;
129 float drawHeight = height() - botMargin;
131 painter.drawLine(0, drawHeight, width(), drawHeight);
133 painter.setPen(QColor(255, 0, 0));
134 painter.setBrush(QColor(255, 0, 0));
136 float old_x = leftMargin;
142 float new_x = i * drawWidth /
m_numPoints + leftMargin;
147 painter.drawLine(old_x, drawHeight - old_y, new_x, drawHeight - new_y);
152 painter.setPen(QColor(0, 0, 255));
153 while(old_x <= new_x)
155 painter.drawLine(old_x, drawHeight - old_y, old_x, drawHeight);