Restore colored zones code to QWT curve

This fragment was missing from #4497
Also commented not used features from qwtconfig.pri.in
to reduce ci build time.
Fixes #4639
This commit is contained in:
Alejandro Martinez
2025-04-24 15:15:38 -03:00
parent c6fd1db980
commit a97cc9aea0
2 changed files with 26 additions and 3 deletions

View File

@@ -137,7 +137,7 @@ win32 {
# Otherwise you have to build them from the examples directory.
######################################################################
QWT_CONFIG += QwtExamples
#QWT_CONFIG += QwtExamples
######################################################################
# The playground is primarily intended for the Qwt development
@@ -148,14 +148,14 @@ QWT_CONFIG += QwtExamples
# Otherwise you have to build them from the playground directory.
######################################################################
QWT_CONFIG += QwtPlayground
#QWT_CONFIG += QwtPlayground
######################################################################
# If you want to auto build the tests, enable the line below
# Otherwise you have to build them from the tests directory.
######################################################################
QWT_CONFIG += QwtTests
#QWT_CONFIG += QwtTests
######################################################################
# When Qt has been built as framework qmake wants

View File

@@ -902,6 +902,8 @@ void QwtPlotCurve::fillCurve( QPainter* painter,
if ( polygon.count() <= 2 ) // a line can't be filled
return;
double avg=(yMap.invTransform(polygon[0].y())+yMap.invTransform(polygon[1].y())) / 2.00;
QBrush brush = m_data->brush;
if ( !brush.color().isValid() )
brush.setColor( m_data->pen.color() );
@@ -917,6 +919,27 @@ void QwtPlotCurve::fillCurve( QPainter* painter,
painter->setPen( Qt::NoPen );
painter->setBrush( brush );
// if we have zones we need to process the polygon point by point...
if (m_data->zones.count()>0 && polygon.count() == 4) {
// we need to set color based upon zone
double alpha = m_data->brush.color().alphaF();
QColor color = m_data->brush.color();
if (avg < 1) color=Qt::black;
else {
for(int i=0; i<m_data->zones.count(); i++) {
if (avg < m_data->zones[i].lim) {
color = m_data->zones[i].color;
color.setAlphaF(alpha);
break;
}
}
}
brush.setColor(color);
painter->setBrush(brush);
}
QwtPainter::drawPolygon( painter, polygon );
painter->restore();