chunkstream version fixedleaselication

git-svn-id: svn://db.shs.com.ru/libs@3 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
2015-03-24 11:04:36 +00:00
parent b3e47dfc99
commit b068a301bf
29 changed files with 406 additions and 95 deletions

View File

@@ -456,13 +456,13 @@ void Graphic::setHistorySize(double val) {
history = val;
double x;
for (int i = 0; i < graphics.size(); ++i) {
QPolygonF & pol(graphics[i].polyline);
QList<QPointF> & pol(graphics[i].polyline);
if (pol.isEmpty()) continue;
x = pol.back().x() - history;
for (int j = pol.size() - 2; j >= 0 ; --j)
if (pol[j].x() < x) {
//qDebug() << pol.size() << j;
pol.remove(0, j);
pol.erase(pol.begin(), pol.begin() + j);
break;
}
}
@@ -529,26 +529,26 @@ void Graphic::setButtonsPosition(Graphic::Alignment a) {
void Graphic::addPoint(const QPointF & p, int graphic, bool update_) {
if (graphic >= graphics.size() || graphic < 0) return;
if (graphics.at(graphic).polyline.size() == 0) graphics[graphic].max_x = p.x();
graphics[graphic].polyline.push_back(p);
graphics[graphic].polyline << p;
if (graphics.at(graphic).max_x < p.x()) graphics[graphic].max_x = p.x();
tick(graphic, true, update_);
}
void Graphic::setGraphicData(const QVector<QPointF> & g, int graphic) {
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 = QPolygonF(g);
graphics[graphic].polyline = g.toList();
if (graphics.at(graphic).polyline.size() == 0) {
graphics[graphic].max_x = 0.;
tick(graphic, false);
tick(graphic, false, update_);
return;
}
graphics[graphic].max_x = graphics.at(graphic).polyline[0].x();
for (int i = 1; i < graphics.at(graphic).polyline.size(); ++i)
if (graphics.at(graphic).max_x < graphics.at(graphic).polyline[i].x())
graphics[graphic].max_x = graphics.at(graphic).polyline[i].x();
tick(graphic, false);
tick(graphic, false, update_);
}
@@ -662,7 +662,7 @@ void Graphic::setHistogramData(const QVector<float> & g, int graphic) {
//if (ci >= ic) ci = ic - 1;
hist[ci]++;
}
QPolygonF & cpol(graphics[graphic].polyline);
QList<QPointF> & 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 +684,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 QPolygonF & pol(pause_ ? t.polyline_pause : t.polyline);
const QList<QPointF> & pol(pause_ ? t.polyline_pause : t.polyline);
if (!pol.isEmpty()) {
isEmpty = false;
break;
@@ -704,7 +704,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 QPolygonF & pol(pause_ ? t.polyline_pause : t.polyline);
const QList<QPointF> & 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 +869,10 @@ void Graphic::drawGraphics() {
QTransform mat = painter->transform();
painter->resetTransform();
painter->setWorldMatrixEnabled(false);
QPolygonF cpol;
QList<QPointF> cpol;
for (int i = 0; i < graphics.size(); ++i) {
GraphicType & t(graphics[i]);
QPolygonF & rpol(pause_ ? t.polyline_pause : t.polyline);
QList<QPointF> & rpol(pause_ ? t.polyline_pause : t.polyline);
if (t.visible && !rpol.isEmpty()) {
pw = t.pen.widthF();
if (t.lines) {
@@ -883,16 +883,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(cpol));
painter->drawPolygon(mat.map(QPolygonF(cpol.toVector())));
} else
painter->drawPolyline(mat.map(rpol));
painter->drawPolyline(mat.map(QPolygonF(rpol.toVector())));
}
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(rpol));
painter->drawPoints(mat.map(QPolygonF(rpol.toVector())));
if (qRound(pw) == pw) t.pen.setWidth(qRound(pw));
else t.pen.setWidthF(pw);
}
@@ -1067,13 +1067,13 @@ void Graphic::tick(int index, bool slide, bool update_) {
if (slide) {
mutex.lock();
GraphicType & t(graphics[index]);
if (t.polyline.size() > 1) if (fabs(t.polyline.back().x() - t.polyline.front().x()) > history) {
while (t.polyline.size() > 1) {
if (fabs(t.polyline.back().x() - t.polyline.front().x()) <= history) break;
t.polyline.pop_front();
if (t.polyline.size() > 1) if (fabs(t.polyline.back().x() - t.polyline.front().x()) > history) t.polyline.pop_front();
if (t.polyline.size() > 1) if (fabs(t.polyline.back().x() - t.polyline.front().x()) > history) t.polyline.pop_front();
}
}
if (!update_) {
findGraphicsRect();
mutex.unlock();
return;
}
@@ -1093,7 +1093,7 @@ void Graphic::on_buttonAutofit_clicked() {
isFit = true;
bool isEmpty = true;
foreach (const GraphicType & t, graphics) {
const QPolygonF & pol(pause_ ? t.polyline_pause : t.polyline);
const QList<QPointF> & pol(pause_ ? t.polyline_pause : t.polyline);
if (!pol.isEmpty()) {
isEmpty = false;
break;