|
|
|
|
@@ -155,6 +155,7 @@ void Graphic::timerEvent(QTimerEvent * ) {
|
|
|
|
|
|
|
|
|
|
void Graphic::canvasPaintEvent(QPaintEvent * ) {
|
|
|
|
|
if (is_lines_update) return;
|
|
|
|
|
QMutexLocker ml(&mutex_);
|
|
|
|
|
static int pwid = 0, phei = 0;
|
|
|
|
|
int wid = canvas->width(), hei = canvas->height();
|
|
|
|
|
lastw = wid;
|
|
|
|
|
@@ -446,6 +447,7 @@ void Graphic::setPaused(bool yes) {
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i < graphics.size(); ++i) {
|
|
|
|
|
graphics[i].polyline_pause = graphics[i].polyline;
|
|
|
|
|
graphics[i].polyline_pause.detach();
|
|
|
|
|
graphics[i].max_x_pause = graphics[i].max_x;
|
|
|
|
|
}
|
|
|
|
|
timer_pause = startTimer(40);
|
|
|
|
|
@@ -456,7 +458,7 @@ void Graphic::setHistorySize(double val) {
|
|
|
|
|
history = val;
|
|
|
|
|
double x;
|
|
|
|
|
for (int i = 0; i < graphics.size(); ++i) {
|
|
|
|
|
QList<QPointF> & pol(graphics[i].polyline);
|
|
|
|
|
QPolygonF & pol(graphics[i].polyline);
|
|
|
|
|
if (pol.isEmpty()) continue;
|
|
|
|
|
x = pol.back().x() - history;
|
|
|
|
|
for (int j = pol.size() - 2; j >= 0 ; --j)
|
|
|
|
|
@@ -538,7 +540,7 @@ void Graphic::addPoint(const QPointF & p, int graphic, bool update_) {
|
|
|
|
|
void Graphic::setGraphicData(const QVector<QPointF> & g, int graphic, bool update_) {
|
|
|
|
|
if (graphic >= graphics.size() || graphic < 0) return;
|
|
|
|
|
graphics[graphic].polyline.clear();
|
|
|
|
|
graphics[graphic].polyline = g.toList();
|
|
|
|
|
graphics[graphic].polyline = g;
|
|
|
|
|
if (graphics.at(graphic).polyline.size() == 0) {
|
|
|
|
|
graphics[graphic].max_x = 0.;
|
|
|
|
|
tick(graphic, false, update_);
|
|
|
|
|
@@ -662,7 +664,7 @@ void Graphic::setHistogramData(const QVector<float> & g, int graphic) {
|
|
|
|
|
//if (ci >= ic) ci = ic - 1;
|
|
|
|
|
hist[ci]++;
|
|
|
|
|
}
|
|
|
|
|
QList<QPointF> & cpol(graphics[graphic].polyline);
|
|
|
|
|
QPolygonF & cpol(graphics[graphic].polyline);
|
|
|
|
|
if (hist.size() == 1 || range == 0.) {
|
|
|
|
|
cpol << QPointF(min - 0.5, 0.) << QPointF(min - 0.25, 0.);
|
|
|
|
|
cpol << QPointF(min - 0.25, hist[0]) << QPointF(min + 0.25, hist[0]);
|
|
|
|
|
@@ -684,7 +686,7 @@ void Graphic::findGraphicsRect(double start_x, double end_x, double start_y, dou
|
|
|
|
|
bool isRangeX = (start_x != end_x), isRangeY = (start_y != end_y);
|
|
|
|
|
bool isEmpty = true, anyVisible = false, isTimeLimit = (visible_time > 0.) && !(isRangeX || isRangeY);
|
|
|
|
|
foreach (const GraphicType & t, graphics) {
|
|
|
|
|
const QList<QPointF> & pol(pause_ ? t.polyline_pause : t.polyline);
|
|
|
|
|
const QPolygonF & pol(pause_ ? t.polyline_pause : t.polyline);
|
|
|
|
|
if (!pol.isEmpty()) {
|
|
|
|
|
isEmpty = false;
|
|
|
|
|
break;
|
|
|
|
|
@@ -704,7 +706,7 @@ void Graphic::findGraphicsRect(double start_x, double end_x, double start_y, dou
|
|
|
|
|
vx -= visible_time;
|
|
|
|
|
foreach (const GraphicType & t, graphics) {
|
|
|
|
|
if (!t.visible) continue;
|
|
|
|
|
const QList<QPointF> & pol(pause_ ? t.polyline_pause : t.polyline);
|
|
|
|
|
const QPolygonF & pol(pause_ ? t.polyline_pause : t.polyline);
|
|
|
|
|
for (int i = 0; i < pol.size(); i++) {
|
|
|
|
|
cx = pol[i].x();
|
|
|
|
|
cy = pol[i].y();
|
|
|
|
|
@@ -869,10 +871,10 @@ void Graphic::drawGraphics() {
|
|
|
|
|
QTransform mat = painter->transform();
|
|
|
|
|
painter->resetTransform();
|
|
|
|
|
painter->setWorldMatrixEnabled(false);
|
|
|
|
|
QList<QPointF> cpol;
|
|
|
|
|
QPolygonF cpol;
|
|
|
|
|
for (int i = 0; i < graphics.size(); ++i) {
|
|
|
|
|
GraphicType & t(graphics[i]);
|
|
|
|
|
QList<QPointF> & rpol(pause_ ? t.polyline_pause : t.polyline);
|
|
|
|
|
QPolygonF & rpol(pause_ ? t.polyline_pause : t.polyline);
|
|
|
|
|
if (t.visible && !rpol.isEmpty()) {
|
|
|
|
|
pw = t.pen.widthF();
|
|
|
|
|
if (t.lines) {
|
|
|
|
|
@@ -883,16 +885,16 @@ void Graphic::drawGraphics() {
|
|
|
|
|
painter->setBrush(t.fill_color);
|
|
|
|
|
//cpol.push_front(QPointF(cpol.front().x(), 0.));
|
|
|
|
|
//cpol.push_back(QPointF(cpol.back().x(), 0.));
|
|
|
|
|
painter->drawPolygon(mat.map(QPolygonF(cpol.toVector())));
|
|
|
|
|
painter->drawPolygon(mat.map(cpol));
|
|
|
|
|
} else
|
|
|
|
|
painter->drawPolyline(mat.map(QPolygonF(rpol.toVector())));
|
|
|
|
|
painter->drawPolyline(mat.map(rpol));
|
|
|
|
|
}
|
|
|
|
|
if (t.points) {
|
|
|
|
|
if (qRound(t.pointWidth) == t.pointWidth) t.pen.setWidth(qRound(t.pointWidth));
|
|
|
|
|
else t.pen.setWidthF(t.pointWidth);
|
|
|
|
|
t.pen.setCosmetic(true);
|
|
|
|
|
painter->setPen(t.pen);
|
|
|
|
|
painter->drawPoints(mat.map(QPolygonF(rpol.toVector())));
|
|
|
|
|
painter->drawPoints(mat.map(rpol));
|
|
|
|
|
if (qRound(pw) == pw) t.pen.setWidth(qRound(pw));
|
|
|
|
|
else t.pen.setWidthF(pw);
|
|
|
|
|
}
|
|
|
|
|
@@ -1093,7 +1095,7 @@ void Graphic::on_buttonAutofit_clicked() {
|
|
|
|
|
isFit = true;
|
|
|
|
|
bool isEmpty = true;
|
|
|
|
|
foreach (const GraphicType & t, graphics) {
|
|
|
|
|
const QList<QPointF> & pol(pause_ ? t.polyline_pause : t.polyline);
|
|
|
|
|
const QPolygonF & pol(pause_ ? t.polyline_pause : t.polyline);
|
|
|
|
|
if (!pol.isEmpty()) {
|
|
|
|
|
isEmpty = false;
|
|
|
|
|
break;
|
|
|
|
|
|