Skip drawing the line for negative values

This commit is contained in:
Ondřej Čertík 2019-11-26 13:40:05 -07:00
parent 5133d4ab51
commit 10edc6b0ac

View File

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