PDA

View Full Version : Qwt with multi axes support



Uwe
14th November 2013, 08:19
As multi axes support is one of the feature requests that pop up from time to time:

there is a new implementation in a special branch: http://sourceforge.net/p/qwt/code/HEAD/tree/branches/qwt-6.1-multiaxes. Even if not 100% complete ( some layout code issues with long titles + QwtPlotRescaler is not yet working ) it should be much better than any of the patches for earlier versions of Qwt.

The Qwt examples work with this version, so the API changes should be more or less painless for most of the application code. So I'm considering to have it in Qwt 6.2, but I'm not decided yet.

Reporting bugs or commenting the API can be done on the Qwt mailing list ( or here ).

Uwe

liversedge
8th December 2013, 19:22
Dear Uwe,

I am most grateful that you have chosen to pursue this.
I work on the GoldenCheetah project and we have been maintaining our own patched version of QWT.
I am (right now) porting our code to QT 5.1.1 and was preparing to update our maintained QWT to 6.1 + multiaxis patch.

I will go and read the code and try better to understand the new APIs in SVN.

Am I right to assume that this means you can have multiple axes (more than one axis) on the left, right, top and bottom of each plot ?

Thanks,
Mark

Uwe
9th December 2013, 07:09
Am I right to assume that this means you can have multiple axes (more than one axis) on the left, right, top and bottom of each plot ?
As many as you want to.

Uwe

liversedge
10th December 2013, 20:59
Apologies -- I couldn't work out how to delete a post.
I answered my own questions :)

liversedge
11th December 2013, 20:00
Well, after playing with it for a while I am very happy, here is a screenshot of it in action in our program.

9845

Two little things;
- xBottom seems to disappear whenever another pos axis is modified.
- QwtPlot::canvas() doesn't return a QwtPlotCanvas anymore (I needed to static_cast<> to be able to setFrameStyle(QFrame::NoFrame);

But thanks -- this is absolutely brilliant for us in GoldenCheetah !

darkshu
8th October 2014, 11:53
I found a bug
in file qwt_plot_renderer.cpp
in line 555: for ( int i = 0; i < plot->axesCount( i ); i++ )
should be : for ( int i = 0; i < plot->axesCount( axisPos ); i++ )
could you fix this asap, thanks

darkshu
10th October 2014, 07:27
similliar bug
after set few multiaxes (yLeft ) and change their color by using set palette ( with using stylesheet for all widget - without set style everything works fine ) changed is only one scale (color)
call function to set new one ( by push button click - after some part of time - probably event get update)
old scales get change their color but - new added not - replot update etc. in this function do not work.
I workaround this by changing color by set style for scale widget - but in future better way is to set this by paletts.

Uwe
10th October 2014, 16:31
similliar bug
after set few multiaxes (yLeft ) and change their color by using set palette ( with using stylesheet for all widget - without set style everything works fine ) changed is only one scale (color)
call function to set new one ( by push button click - after some part of time - probably event get update)
Not sure how this might be comparable to the bug above.



old scales get change their color but - new added not - replot update etc. in this function do not work.
I workaround this by changing color by set style for scale widget - but in future better way is to set this by paletts.
Setting a palette and how new widgets are initialized is part of the Qt framework. Setting a palette to one scale widget of course doesn't affect the palette of another scale widget, but setting a palette to the parent of the scale widgets ( the plot widget itself ) would have an effect. When also setting a palette to legend and titles ( the canvas usually has its own ) and no palette to the scales, then only the scale widgets - but all of them - would inherit the palette from the plot widget.

When working with style sheets you might be interested in the names of the scale widgets:



"QwtPlotAxisYLeft", "QwtPlotAxisYLeft1", " "QwtPlotAxisYLeft2" ...
"QwtPlotAxisYRight", "QwtPlotAxisYRight1", "QwtPlotAxisYRight2", ...
"QwtPlotAxisXBottom", "QwtPlotAxisXBottom1", "QwtPlotAxisXBottom2", ...
"QwtPlotAxisXTop", "QwtPlotAxisXTop1", "QwtPlotAxisXTop2"



HTH,
Uwe

darkshu
31st October 2014, 06:38
Similiar is that: change get affect only on first ( default scale ), ( eg.
step I:
create plot - set own style sheet on the plot widget, plot is created with default scales, xLeft, yLeft
after create Plot, create Y curves ( set them own color's - from table of colors every uniqe )
step II
call setAxesCount to set for every curve thier own scale and set color of the scale the same as it's curve

QwtScaleWidget *scalewidget = qwtPlot->axisWidget(axisid);
QPalette pal = scalewidget->palette();
pal.setColor(QPalette::Text, pen().color());
scalewidget->setPalette(pal);

efect: only first scale get color changed (so code is good and there is bug)
step III
from pushbutton clicked
change number of curves to Y2 where Y2 > Y
reapeat step II for Y2

efect: change is have afect only for Y number of curves ( not Y2 )


workaround for step II:
QString stylesheet = scalewidget->styleSheet();
..
stylesheet.replace change for style I changed color: #rgb;
..
scalewidget->setStyleSheet(stylesheet);

for end:
first code without using stylesheet on the plot widget works fine, problem occurs while use stylesheet to change overlook and then you what to change from code some details

Uwe
31st October 2014, 09:19
Not sure if I understood everything, but isn't it like this:

a) plot and first scale widget created with application palette
b) setting a stylesheet for the plot, scale widget still using default palette
c) adding new scale widgets, stylesheet now derived from plot widget ( palette disabled )

Call it good or bad - this is how it is defined by Qt. The stylesheet concept has its problems and I would recommend to use style sheets for all or nothing.

Uwe

darkshu
3rd November 2014, 06:15
Not sure if I understood everything, but isn't it like this:

a) plot and first scale widget created with application palette
b) setting a stylesheet for the plot, scale widget still using default palette
c) adding new scale widgets, stylesheet now derived from plot widget ( palette disabled )

Call it good or bad - this is how it is defined by Qt. The stylesheet concept has its problems and I would recommend to use style sheets for all or nothing.

Uwe

a) qapp->setStyleSheet(xxx);
b) qMainWindow
c) plot - there is no own stylesheet - qwtplot get it from qwidget ( background, color, font etc. ) from main style
d) adding new scale widgets with style scheet derivet from parent ( plot widget )
I cant say that palette is disabled becouse part of scaleas react on changing palette - other not, Number of scales that changing palette is depend of previus call setAxesCount
replot, or other ways to update it in that step of time don't get effect
e) changing setScaleCount from qpushbutton action ( click ) change number of scales reacting on set palette ( but always its wrong nuber of it - depend of previus call setAxesCount)
f) in my current project using stylesheet for all is enought, but direct reference to setting gives you more options than offers using stylesheet

Peter111
7th September 2017, 12:30
Hello everyone! How i can hide axis.
enableAxis(yLeft,false); - works for the first left axis only. But i have four yLeft axis.
Thank you.

Uwe
7th September 2017, 16:43
plot->setAxisVisible( QwtAxisId( yLeft, ... ), false );HTH,
Uwe

Peter111
8th September 2017, 11:39
THank you !