Use QwtPlotZoneItems instead of QwtPlotShapeItems for formations

This commit is contained in:
Gaute Lindkvist 2019-10-09 20:25:25 +02:00
parent af72538516
commit 3a90bf1e76

View File

@ -25,7 +25,7 @@
#include "cvfMath.h" #include "cvfMath.h"
#include "qwt_plot.h" #include "qwt_plot.h"
#include "qwt_plot_shapeitem.h" #include "qwt_plot_zoneitem.h"
#include <QString> #include <QString>
@ -84,21 +84,14 @@ void RiuPlotAnnotationTool::attachNamedRegions( QwtPlot*
cvf::Color3ub cvfColor = catMapper.mapToColor( static_cast<double>( i ) ); cvf::Color3ub cvfColor = catMapper.mapToColor( static_cast<double>( i ) );
QColor shadingColor( cvfColor.r(), cvfColor.g(), cvfColor.b(), shadingAlphaByte ); QColor shadingColor( cvfColor.r(), cvfColor.g(), cvfColor.b(), shadingAlphaByte );
QwtPlotShapeItem* shading = new QwtPlotShapeItem( name ); QwtPlotZoneItem* shading = new QwtPlotZoneItem();
shading->setOrientation( Qt::Horizontal );
QwtInterval axisInterval = m_plot->axisInterval( QwtPlot::xBottom ); shading->setInterval( yPositions[i].first, yPositions[i].second );
QRectF shadingRect( axisInterval.minValue(),
yPositions[i].first,
axisInterval.width(),
yPositions[i].second - yPositions[i].first );
shading->setRect( shadingRect );
shading->setPen( shadingColor, 0.0, Qt::NoPen ); shading->setPen( shadingColor, 0.0, Qt::NoPen );
shading->setBrush( QBrush( shadingColor ) ); shading->setBrush( QBrush( shadingColor ) );
shading->attach( m_plot ); shading->attach( m_plot );
shading->setZ( -100.0 ); shading->setZ( -100.0 );
shading->setXAxis( QwtPlot::xBottom ); shading->setXAxis( QwtPlot::xTop );
m_markers.push_back( std::move( shading ) ); m_markers.push_back( std::move( shading ) );
} }