1 Attachment(s)
One QwtScaleDraw to Rule-Them-All?
Attachment 12018
Hello,
I have a vertical QwtScaleDraw on the left along with several qwt Plots in a QtBoxLayout. Each of the Qwt Plots has a title and a bottom axis which are the same units, width, etc. (see the attached image). In the interest of preserving screen real-estate, I would like them to share one QwtScaleDraw vertically on the left, which has a range from 0 to 360 degrees. My question is how can I make the scale on the left match the contents of the qwt plots and *not* include the title and bottom-scales on the individual qwt plots?
I hope that makes sense?
Thanks,
Craig Steury
Re: One QwtScaleDraw to Rule-Them-All?
Maybe check the plotmatrix example.
Uwe
Re: One QwtScaleDraw to Rule-Them-All?
The plot matrix example was my starting point (the example programs are very helpful, BTW). I started by putting all the individual plots in a layout and only enabling the axis for the leftmost plot. In this case the left axis was aligned perfectly with the plot-data The problem here was that the axis took some of the real-estate from the leftmost plot, so that it had less width than the other plots, even though it represents the same horizontal distance. At this point I decided to try adding an 'independent' QwtScaleWidget to the layout which would correspond to the other plots/channels data. However the scale no longer corresponds to the data as can be seen in the image. I've experimented with QwtScaleWidget::setBorderDist and can get pretty close by eyeballing it. I would like to get the appropriate 'BorderDist' by querying the top/bottom titles for their size(height), bounding-box or something like that so that when the plot is resized it will adjust appropriately. So this brings me to my main question: Can anyone recommend a good way to do that?
Since these plots are supposed to represent a flattened pipe-line (and the boxes 'features' on the pipeline), the next thing will be to add a scrollbar, wheel, slider etc so that the view will scroll-around the pipe. My initial thought was to draw from -360 to 720 degrees and then draw the features in triplicate so that features that 'straddle' the seam will be drawn correctly (and not be cutoff at 0 or 360 degrees). In that case the views will represent a 'window' on the larger drawing. In that case I would like to update the QwtScaleWidget axis to match the current window of data. (say from -100 to 260 degrees)
In any case, thanks in advance for any suggestions or comments.
cs
Re: One QwtScaleDraw to Rule-Them-All?
Quote:
Originally Posted by
csteury
The problem here was that the axis took some of the real-estate from the leftmost plot, so that it had less width than the other plots, even though it represents the same horizontal distance
Calculating the horizontal layout manually ( simply overloading the resizeEvent from the parent ) with taking care of some extra space for the leftmost scale sounds like a much easier approach to me than trying to add an external vertical scale. The extra space should correspond to the width of the left scale widget.
Should be much easier, than your approach what more or less means, that you have to reimplement parts of the layout engine. But if you want to go this route check the code in QwtPlotLayout.
Uwe
Re: One QwtScaleDraw to Rule-Them-All?
Ok - easier is definitely a virtue - I will try that first.
Thanks for the suggestion!
cs