Use a vector of QPolygonF directly

This commit is contained in:
Ondřej Čertík 2019-11-28 20:30:57 -07:00
parent 10edc6b0ac
commit ae722e8c33

View File

@ -34,11 +34,7 @@
template<typename T, typename... Args>
std::unique_ptr<T> make_unique(Args&&... args)
{
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
@ -98,8 +94,8 @@ void JKQTPXYLineGraph::draw(JKQTPEnhancedPainter& painter) {
//double yold=-1; //double yold=-1;
//bool first=false; //bool first=false;
//QVector<QLineF> lines; //QVector<QLineF> lines;
std::vector<std::unique_ptr<QPolygonF>> linesP; std::vector<QPolygonF> linesP;
linesP.push_back(make_unique<QPolygonF>()); linesP.push_back(QPolygonF());
intSortData(); intSortData();
for (int iii=imin; iii<imax; iii++) { for (int iii=imin; iii<imax; iii++) {
int i=qBound(imin, getDataIndex(iii), imax); int i=qBound(imin, getDataIndex(iii), imax);
@ -116,25 +112,25 @@ void JKQTPXYLineGraph::draw(JKQTPEnhancedPainter& painter) {
if ((!parent->getXAxis()->isLogAxis() || xv>0.0) && (!parent->getYAxis()->isLogAxis() || yv>0.0) ) { if ((!parent->getXAxis()->isLogAxis() || xv>0.0) && (!parent->getYAxis()->isLogAxis() || yv>0.0) ) {
plotStyledSymbol(parent, painter, x, y); plotStyledSymbol(parent, painter, x, y);
if (drawLine) { if (drawLine) {
(*linesP[linesP.size()-1])<<QPointF(x,y); linesP[linesP.size()-1] << QPointF(x,y);
} }
} else { } else {
linesP.push_back(make_unique<QPolygonF>()); linesP.push_back(QPolygonF());
} }
} }
} }
//qDebug()<<"JKQTPXYLineGraph::draw(): "<<4<<" lines="<<lines.size(); //qDebug()<<"JKQTPXYLineGraph::draw(): "<<4<<" lines="<<lines.size();
//qDebug()<<"JKQTPXYLineGraph::draw(): "<<5<<" p="<<painter.pen(); //qDebug()<<"JKQTPXYLineGraph::draw(): "<<5<<" p="<<painter.pen();
for (auto &lines : linesP) { for (auto &lines : linesP) {
if (lines->size()>0) { if (lines.size()>0) {
if (isHighlighted()) { if (isHighlighted()) {
painter.setPen(penSelection); painter.setPen(penSelection);
//painter.drawLines(lines); //painter.drawLines(lines);
painter.drawPolyline(*lines); painter.drawPolyline(lines);
} }
painter.setPen(p); painter.setPen(p);
//painter.drawLines(lines); //painter.drawLines(lines);
painter.drawPolyline(*lines); painter.drawPolyline(lines);
} }
} }
//qDebug()<<"JKQTPXYLineGraph::draw(): "<<6; //qDebug()<<"JKQTPXYLineGraph::draw(): "<<6;