
Originally Posted by
Uwe
You have to implement a new type of QwtPlotItem, that displays your rectangle/ellipsoid. In YourPlotItem::draw use QwtPainter::drawRect/drawEllipse instead of QPainter::drawRect/Ellipse if you want to use QwtPlot:

rint.
I tried the following
{
public:
private:
};
class SelectionPlotItem : public QwtPlotItem
{
public:
SelectionPlotItem(const QwtText &title=QwtText());
virtual void draw (QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRect &canvasRect) const;
private:
};
To copy to clipboard, switch view to plain text mode
and override the draw() method
{
painter->save();
QwtPolygon poly = QwtPolygon(canvasRect);
painter->restore();
}
void SelectionPlotItem::draw(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRect &canvasRect) const
{
painter->save();
QwtPolygon poly = QwtPolygon(canvasRect);
painter->setPen(QPen(QColor(Qt::blue)));
QwtPainter::drawPolygon(painter, poly);
painter->restore();
}
To copy to clipboard, switch view to plain text mode
but it doesn't seem to do anything
const QwtScaleMap &yMap,
const QwtDoubleRect
& rect
) const
QRect QwtPlotItem::transform(const QwtScaleMap &xMap,
const QwtScaleMap &yMap, const QwtDoubleRect& rect) const
To copy to clipboard, switch view to plain text mode
Uwe
Re/ my 2nd question - but how am I going to iterate through the points on my image to select those point inside the polygon selection?
Perhaps my renderImage is defined incorrectly?
const QwtScaleMap &yMap,
const QwtDoubleRect
&area
) const {
}
QImage OverlayImagePlot::renderImage(const QwtScaleMap &xMap,
const QwtScaleMap &yMap, const QwtDoubleRect &area) const
{
return QImage(_filename);
}
To copy to clipboard, switch view to plain text mode
my custom class was defined as:
class OverlayImagePlot : public QwtPlotRasterItem
{
public:
OverlayImagePlot();
OverlayImagePlot(const QwtText &title);
OverlayImagePlot(const QString &title);
virtual ~OverlayImagePlot();
void setArea(QRect area) {_area = area;}
void setFilename(QString filename);
void setPlot(QwtPlot *plot);
protected:
virtual QImage renderImage(const QwtScaleMap &xMap,
const QwtScaleMap &yMap, const QwtDoubleRect &area) const;
private:
QwtPlot *_plot;
QRect _area;
QString _filename;
};
Bookmarks