In one of the Qwt support channels I posted once a complete implementation of such a thing ( basically it was a picker with a QwtPickerTrackerMachine, where the append and move calls were set manually instead of being triggered by user input ). Of course this is a hack - but check the archives.
Today I would recommend to use QwtPlotOverlay from SVN trunk ( copy it to your code when you want to use Qwt 6.0 ):
class YourIndicator: public QwtPlotOverlay
{
public:
void setPosition( double x )
{
m_position = x;
updateOverlay();
}
virtual void drawOverlay
( QPainter *painter
) const {
const QwtPlot *plot
= dynamic_cast<const
QwtPlot *>
( parent
()->parent
() );
const double x
= plot
->canvasMap
( QwtPlot::xBottom ).
transform( m_position
);
painter->setPen( ... );
painter->drawLine( x, 0, x, height() );
}
private:
double m_position;
}
class YourIndicator: public QwtPlotOverlay
{
public:
void setPosition( double x )
{
m_position = x;
updateOverlay();
}
virtual void drawOverlay( QPainter *painter ) const
{
const QwtPlot *plot = dynamic_cast<const QwtPlot *>( parent()->parent() );
const double x = plot->canvasMap( QwtPlot::xBottom ).transform( m_position );
painter->setPen( ... );
painter->drawLine( x, 0, x, height() );
}
private:
double m_position;
}
To copy to clipboard, switch view to plain text mode
When it is time I will add something like above to the examples.
HTH,
Uwe
Bookmarks