PDA

View Full Version : Set a picture for the background



Roman Novoselov
16th March 2011, 13:22
Hello everyone,

I novice qwt user and the problem is following
I represented the city map using qwt and I represented some points on the map (for example, bus stops).

I want to set the real city's map image to the background of the plot.
What class of qwt I should use for this?

Thanks a lot in advance!

mazd
16th March 2011, 17:31
Hello everyone,

I novice qwt user and the problem is following
I represented the city map using qwt and I represented some points on the map (for example, bus stops).

I want to set the real city's map image to the background of the plot.
What class of qwt I should use for this?

Thanks a lot in advance!

to set picture, u should insert Qlabel and add your picture under 'pixmap' property or use that property for ur any pixmap supprting wedget(may b wedget u used as bg).

Uwe
16th March 2011, 18:39
I want to set the real city's map image to the background of the plot.
The data displayed on the plot canvas is related to the scales. For an areal photo ( or other images ) this always means some sort of resampling. How to do this depends on your particular situation.

The plot item for displaying raster data ( data that is mapped somehow to an image ) is QwtPlotRasterItem. You need to derive from this class and implement:

virtual QImage YourRasterItem::renderImage(
const QwtScaleMap &xMap,
const QwtScaleMap &yMap,
const QwtDoubleRect &area
) const;

Uwe

Roman Novoselov
17th March 2011, 08:26
Thanks Uwe,

I have the following:

class RasterItem: public QwtPlotRasterItem
{
...
private:
QImage renderImage (const QwtScaleMap & xMap, const QwtScaleMap & yMap, const QwtDoubleRect & area) const;
};

QImage RasterItem::renderImage (const QwtScaleMap & xMap, const QwtScaleMap & yMap, const QwtDoubleRect & area) const
{
if (area.isEmpty ())
return QImage ();

QRect rect = transform (xMap, yMap, area);
QPixmap pixmap (rect.width(), rect.height());
pixmap.load (filename);
return pixmap.convertToImage ();
}



class Plot : public QwtPlot
{
...
};

Plot::Plot(QWidget *parent)
{
...
RasterItem * image = new RasterItem (QString ("Title"));
...
}


Which method of QwtPlot should I use for drawing an image?

Added after 27 minutes:

Thanks all,
I found the method, if it is need somebody else:


image->attach (this);



It remains to solve the problem with zoom
When I change zoom of the city map, curves are changes, but the image of city stays the same size :)

ziXet
9th February 2012, 12:10
Thanks Uwe,

I have the following:




Which method of QwtPlot should I use for drawing an image?

Added after 27 minutes:

Thanks all,
I found the method, if it is need somebody else:



It remains to solve the problem with zoom
When I change zoom of the city map, curves are changes, but the image of city stays the same size :)
Can you put your complete RasterItem class code here?