PDA

View Full Version : Resizing QwtSymbol during zoom in QwtPlot



oliver_mpt
20th November 2012, 15:28
Hello,

I am drawing a curve using QwtPlotCurve in a derived QwtPlot class, and I display some markers and symbols at given locations to show particular points of the curve. I am using rectangle as symbols, and I want these rectangle to have a defined height, starting at the bottom x axis, to represent some value.

So, I calculate the symbol size QSize(nx,ny) with :
int ny = (int)abs(transform(QwtPlot::yLeft,ym) - transform(QwtPlot::yLeft,0));
and this works perfectly well. BUT, when I zoom in the graph, the symbol are not resized accordingly to the new zoomed window and everything is messed up.

Digging a bit on the forum, I have read that I could overload QwtSymbol::drawSymbols to get the job done. However, this is a virtual const function, and qtcreator/gcc does not allow me to modify the symbol size (object data) within the overloaded function. Removing the const qualifier just changes the signature and the overloaded function is not called.

Any help warmly welcomed,

best regards

Oliver

Uwe
20th November 2012, 16:45
Well the size of a symbol is in paint device coordinates and is not intended to be scalable. Sounds like you want don't want to display a curve or markers ( points ) - instead it seems to be something, according to rectangles.

Could you elaborate your use case ( what you want to display - not how you have implemented it so far ) ?

Uwe

oliver_mpt
21st November 2012, 12:34
Hi Uwe,

Thanks for the fast reply. Your reply draw my attention to the fact that I might have misused QwtSymbol, so I went back to the documentation and found that painting rectangles with QwtPlotItem would do it much better. I implemented it and it work perfectly.

thanks for your help and best regards

Oliver