Quote Originally Posted by Uwe View Post
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

Qt Code:
  1. class SelectionPlotItem : public QwtPlotItem
  2. {
  3. public:
  4. SelectionPlotItem(const QwtText &title=QwtText());
  5. virtual void draw (QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRect &canvasRect) const;
  6.  
  7.  
  8. private:
  9. };
To copy to clipboard, switch view to plain text mode 
and override the draw() method
Qt Code:
  1. void SelectionPlotItem::draw(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRect &canvasRect) const
  2. {
  3. painter->save();
  4. QwtPolygon poly = QwtPolygon(canvasRect);
  5. painter->setPen(QPen(QColor(Qt::blue)));
  6.  
  7. QwtPainter::drawPolygon(painter, poly);
  8. painter->restore();
  9. }
To copy to clipboard, switch view to plain text mode 
but it doesn't seem to do anything
Qt Code:
  1. QRect QwtPlotItem::transform(const QwtScaleMap &xMap,
  2. 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?

Qt Code:
  1. QImage OverlayImagePlot::renderImage(const QwtScaleMap &xMap,
  2. const QwtScaleMap &yMap, const QwtDoubleRect &area) const
  3. {
  4.  
  5.  
  6. return QImage(_filename);
  7. }
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;
};