graphic addPoints

This commit is contained in:
2021-09-02 22:49:24 +03:00
parent 56c698c71a
commit 2447ff93ce
2 changed files with 33 additions and 1 deletions

View File

@@ -750,12 +750,40 @@ void Graphic::addPoint(const QPointF & p, int graphic, bool update_) {
if (t.cvrect.left() > p.x()) t.cvrect.setLeft(p.x());
}
if (t.polyline.size() == 0) t.max_x = p.x();
t.polyline << p;
if (t.max_x < p.x()) t.max_x = p.x();
t.polyline << p;
tick(graphic, true, update_);
}
void Graphic::addPoints(const QPolygonF & pts, int graphic, bool update_) {
if (graphic >= graphics.size() || graphic < 0 || pts.isEmpty()) return;
GraphicType & t(graphics[graphic]);
if (!t.cvrect.isNull() && !pause_) {
for(const QPointF & p : pts) {
if (t.cvrect.top() < p.y()) t.cvrect.setTop(p.y());
if (t.cvrect.bottom() > p.y()) t.cvrect.setBottom(p.y());
if (t.cvrect.right() < p.x()) t.cvrect.setRight(p.x());
if (t.cvrect.left() > p.x()) t.cvrect.setLeft(p.x());
}
}
if (t.polyline.size() == 0) t.max_x = pts.at(0).x();
for(const QPointF & p : pts) if (t.max_x < p.x()) t.max_x = p.x();
t.polyline << pts;
tick(graphic, true, update_);
}
void Graphic::addPoints(const QVector<double> & pts, int graphic, bool update_) {
QPolygonF ps;
ps.reserve(pts.size());
double stx = 0;
if (!graphics[curGraphic].polyline.isEmpty()) stx = graphics[curGraphic].max_x;
for (int i=0; i<pts.size(); ++i) ps << QPointF(stx + i*inc_x, pts[i]);
addPoints(ps, graphic, update_);
}
void Graphic::setGraphicData(const QVector<QPointF> & g, int graphic, bool update_) {
if (graphic >= graphics.size() || graphic < 0) return;
GraphicType & t(graphics[graphic]);

View File

@@ -312,6 +312,10 @@ public slots:
void addPoint(double x, double y, bool update = true) {addPoint(QPointF(x, y), update);}
void addPoint(double y, int graphic, bool update = true) {if (graphics[graphic].polyline.isEmpty()) addPoint(QPointF(0.0, y), graphic, update); else addPoint(QPointF(graphics[graphic].max_x + inc_x, y), graphic, update);}
void addPoint(double y, bool update = true) {if (graphics[curGraphic].polyline.isEmpty()) addPoint(QPointF(0.0, y), update); else addPoint(QPointF(graphics[curGraphic].max_x + inc_x, y), update);}
void addPoints(const QPolygonF & pts, int graphic, bool update_ = true);
void addPoints(const QPolygonF & pts, bool update = true) {addPoints(pts, curGraphic, update);}
void addPoints(const QVector<double> & pts, int graphic, bool update_ = true);
void addPoints(const QVector<double> & pts, bool update = true) {addPoints(pts, curGraphic, update);}
void setGraphicData(const QVector<QPointF> & g, int graphic, bool update_ = true);
void setGraphicData(const QVector<QPointF> & g) {setGraphicData(g, curGraphic);}
void setGraphicProperties(const QString & name, const QColor & color = Qt::darkRed, Qt::PenStyle style = Qt::SolidLine, double width = 0., bool visible = true) {setGraphicProperties(curGraphic, name, color, style, width, visible);}