Originally Posted by
qmonkey
I'm thinking of drawing histogram and qwtPlotCurve on the same plot, but not sure if it is doable
In general you can have as many plot items as you want on a plot, but I recommend to implement a new plot item instead of misusing a histogram:
{
public:
RangeMarker()
{
setZ( ... );
}
void setInterval( QwtInterval& interval )
{
m_interval = interval;
}
const QRectF &canvasRect
) const {
int x1 = qRound( xMap.transform( m_interval.minValue() ) );
int x2 = qRound( xMap.transform( m_interval.maxValue() );
painter
->fillRect
( QRect( x1, canvasRect.
top(), x2
- x1, canvasRect.
height() ), ...
);
}
};
class RangeMarker: public QwtPlotItem
{
public:
RangeMarker()
{
setZ( ... );
}
void setInterval( QwtInterval& interval )
{
m_interval = interval;
}
virtual void draw( QPainter *painter,
const QwtScaleMap &xMap, const QwtScaleMap &,
const QRectF &canvasRect ) const
{
int x1 = qRound( xMap.transform( m_interval.minValue() ) );
int x2 = qRound( xMap.transform( m_interval.maxValue() );
painter->fillRect( QRect( x1, canvasRect.top(), x2 - x1, canvasRect.height() ), ... );
}
};
To copy to clipboard, switch view to plain text mode
HTH,
Uwe
Bookmarks