diff --git a/libs/graphic/graphic.cpp b/libs/graphic/graphic.cpp index ff86110..81ff32b 100644 --- a/libs/graphic/graphic.cpp +++ b/libs/graphic/graphic.cpp @@ -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 & 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 & g, int graphic, bool update_) { if (graphic >= graphics.size() || graphic < 0) return; GraphicType & t(graphics[graphic]); diff --git a/libs/graphic/graphic.h b/libs/graphic/graphic.h index e6d28ea..63c85b5 100644 --- a/libs/graphic/graphic.h +++ b/libs/graphic/graphic.h @@ -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 & pts, int graphic, bool update_ = true); + void addPoints(const QVector & pts, bool update = true) {addPoints(pts, curGraphic, update);} void setGraphicData(const QVector & g, int graphic, bool update_ = true); void setGraphicData(const QVector & 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);}