Before recommending any solution I need to know the answer to my standard questions ...
Uwe
Before recommending any solution I need to know the answer to my standard questions ...
Uwe
Data is represented as a vector of values which are follow each other after some interval. For each temporal discrete I must plot square with value typed inside if value != 0 (I use QwtPlotMarker for it) or plot nothing if value equals zero (actually I do it with making QwtPlotIntervalCurve's pen's color equal to canvas' color). Every square that represents value of the same vector must be placed at the same Y coordinate. But if I change Y axis' scale, actual size of square must be same (like at the picture I attached in my previous post)
Yes, there is value typed in centre of square.
Size must not be smaller than text inside the square (all markers have the same font size which is not mutable). Actually later it will be necessary to change square size but according to text size, not to axis' scale.
I just need to understand how can I get real square's height to compare it with text's size.
Well then the size of the square depends on some QFontMetrics and is of course in widget coordinates.
This is something you can do with symbols - in you case ( as you need to draw a value inside ) it would be a symbol made of a QPixmap or QwtGraphic ( what would give nicer results in a PDF document ). All geometries of a symbol are in widget coordinates, what means, that a square remains a square ( but don't you have this already using QwtPlotMarker ? ).
Another option would be to derive from QwtPlotItem and do the squares for each vector in YourItem::draw(). Implementing such an item wouldn't be hard - simply translating the center into widget coordinates, then doing a QPainter::fillRect() followed by a QPainter::drawText().
Uwe
Toniy (17th August 2015)
Thanks! I almost get it. One more question: are coordinates on canvas widget and coordinates that shown at QwtScaleDraw not the same (coordinates that shown at QwtScaleDraw are converted coordinates of canvas widget)? I mean if, for example, our Y axis has 100 as min value and 200 for max value and X axis has the same limits, then is point [0;0] of canvas widget (top-left corner) the same as point [200, 100] of our graph (or it is more complicated)?
The widget coordinates are usually bounded by plot->canvas()->contentsRect() ( = QWidget::rect() without margins ). Then it depends on your configuration how the scales are aligned to the canvas - f.e. there might be extra margins to have some space for the tick labels ( see QwtPlotLayout ). The necessary space depends on some factors f.e if a horizontal scale can be extended below a vertical scale etc.
So the answer is yes - usually it is more complicated. Better use QwtPlot::canvasMap() to translate between plot ( = what is spanned by the scales ) and paint device coordinates ( = widget ).
Uwe
Toniy (18th August 2015)
Bookmarks