void Plot2D::setColorBand( Qt::Orientation orientation // Qt::Vertical ::Horizontal
, double lowerValue, double upperValue
, double transparency ) // 0: fully transparent, 1: fully opaque
{
// use modified files 'qwt_plot_zoneitem.h' and
// 'qwt_plot_zoneitem.cpp' from qwt 6.1.2 as follows:
// 'qwt_plot_zoneitem.h':
// # change
// class QWT_EXPORT QwtPlotZoneItem:public QwtPlotItem to
// class QwtPlotZoneItem:public QwtPlotItem
// # comment out
// virtual int rtti() const;
// # add
// void drawLegendIdentifier( QPainter *, const QRectF & ) const;
// 'qwt_plot_zoneitem.cpp':
// # comment out
// int QwtPlotZoneItem::rtti() const { return QwtPlotItem::Rtti_PlotZone; }
// # add function
// void QwtPlotZoneItem::drawLegendIdentifier(
// QPainter *painter, const QRectF &rect ) const
// {
// const double dim = qMin( rect.width(), rect.height() );
// QRectF r( 0, 0, dim, dim );
// r.moveCenter( rect.center() );
// painter->fillRect( r, d_data->brush );
// }
// check parameters
if ( lowerValue > upperValue )
qSwap( lowerValue, upperValue );
QwtPlotZoneItem* colorBand = new QwtPlotZoneItem;
colorBand->setTitle( bandLabel ); // we overwrite the default label 'zone'
if ( !bandLabel.isEmpty() )
colorBand
->setItemAttribute
( QwtPlotItem::Legend,
true );
// default: false
colorBand->setOrientation( orientation );
colorBand->setInterval( lowerValue, upperValue );
color.setAlphaF( transparency );
colorBand->setBrush( brush );
colorBand->attach( this );
}
void Plot2D::setColorBand( Qt::Orientation orientation // Qt::Vertical ::Horizontal
, double lowerValue, double upperValue
, QColor color, QString bandLabel
, double transparency ) // 0: fully transparent, 1: fully opaque
{
// use modified files 'qwt_plot_zoneitem.h' and
// 'qwt_plot_zoneitem.cpp' from qwt 6.1.2 as follows:
// 'qwt_plot_zoneitem.h':
// # change
// class QWT_EXPORT QwtPlotZoneItem:public QwtPlotItem to
// class QwtPlotZoneItem:public QwtPlotItem
// # comment out
// virtual int rtti() const;
// # add
// void drawLegendIdentifier( QPainter *, const QRectF & ) const;
// 'qwt_plot_zoneitem.cpp':
// # comment out
// int QwtPlotZoneItem::rtti() const { return QwtPlotItem::Rtti_PlotZone; }
// # add function
// void QwtPlotZoneItem::drawLegendIdentifier(
// QPainter *painter, const QRectF &rect ) const
// {
// const double dim = qMin( rect.width(), rect.height() );
// QRectF r( 0, 0, dim, dim );
// r.moveCenter( rect.center() );
// painter->fillRect( r, d_data->brush );
// }
// check parameters
if ( lowerValue > upperValue )
qSwap( lowerValue, upperValue );
QwtPlotZoneItem* colorBand = new QwtPlotZoneItem;
colorBand->setTitle( bandLabel ); // we overwrite the default label 'zone'
if ( !bandLabel.isEmpty() )
colorBand->setItemAttribute( QwtPlotItem::Legend, true ); // default: false
colorBand->setOrientation( orientation );
colorBand->setInterval( lowerValue, upperValue );
color.setAlphaF( transparency );
QBrush brush( color );
colorBand->setBrush( brush );
colorBand->attach( this );
}
To copy to clipboard, switch view to plain text mode
Bookmarks