Something like this ?
{
public:
protected:
virtual void drawRubberBand
(QPainter*) const;
virtual QwtText trackerText
(const QwtDoublePoint
& pos
) const;
};
{
/*
We don't have a picker for a line, but the rectangle
selection is also selection of 2 points, so all we
have to do is to change the rubberband.
*/
setRubberBand(PolygonRubberBand);
}
void DistancePicker
::drawRubberBand(QPainter *painter
) const {
painter->drawPolygon(selection());
}
QwtText DistancePicker
::trackerText(const QwtDoublePoint
&pos
) const {
QwtText text
( " selection() as distance string " );
bg.setAlpha(180);
text.
setBackgroundBrush(QBrush(bg
));
return text;
}
class DistancePicker : public QwtPlotPicker
{
public:
DistancePicker( QwtPlotCanvas*);
protected:
virtual void drawRubberBand(QPainter*) const;
virtual QwtText trackerText(const QwtDoublePoint& pos) const;
};
DistancePicker::DistancePicker(QwtPlotCanvas* canvas):
QwtPlotPicker(canvas),
{
/*
We don't have a picker for a line, but the rectangle
selection is also selection of 2 points, so all we
have to do is to change the rubberband.
*/
setSelectionFlags(QwtPicker::RectSelection);
setRubberBand(PolygonRubberBand);
setTrackerMode(QwtPicker::ActiveOnly);
}
void DistancePicker::drawRubberBand(QPainter *painter) const
{
painter->drawPolygon(selection());
}
QwtText DistancePicker::trackerText(const QwtDoublePoint &pos) const
{
QwtText text( " selection() as distance string " );
QColor bg(Qt::white);
bg.setAlpha(180);
text.setBackgroundBrush(QBrush(bg));
return text;
}
To copy to clipboard, switch view to plain text mode
Bookmarks