PDA

View Full Version : Multiscale plot



blelump
22nd May 2008, 14:04
Hi,

I am new on this forum and in Qt/Qwt as well.
I would like to know if is there any possibility to make a multiscale plot these days? By 'these days' I mean that I have seen this topic: http://www.qtcentre.org/forum/f-qwt-23/t-my-own-scale-widget-in-qwt-2604.html/?highlight=plots and Uwe wrote that it's not actually possible but it was 2 year's ago. So I'm asking now, can it be done? Multiscale plot has to be probably the most important feature in my project so I need to know that. Otherwise I have to write my own solution, but I'm getting headache when I'm thinking about it. Would be better to use the Qwt library.

Thank you in advance for any help.

blelump
22nd May 2008, 20:17
I've actually found, let's say, a partial solution (the QwtPlotScaleItem class, which has been introduced in 5.1.0 version), but now I don't know how to change the colour of scale or the values. When I try methods such as setPalette or scaleDiv (which I think is for scale change) there is no effect.

Uwe
23rd May 2008, 11:03
The scale item has its own palette, that is assigned with scaleItem->setPalette(). Backbone and ticks are painted with the foreground color, the labels are painted with the text color ( as long as YourScaleDraw::label doesn't return a text object with an individual color ).

Some time ago a user had sent me a patch that allows having 8 axes ( 2 in each direction ). I will have a look at it this weekend. If it can be ported to Qwt 5.1 I will add it to the patches section on the Qwt project page. I guess it should be possible to modify it to support more axes too.

Uwe

blelump
23rd May 2008, 12:47
Thank you for your reply. It helped me a lot. I guess the QwtPlotScaleItem class will be enough for me for now.


Here's also a couple lines of code for those who might look for the solution:


QPalette *p = new QPalette();
p->setBrush(QPalette::Text, QBrush(Qt::red));
p->setBrush(QPalette::WindowText, QBrush(Qt::red));
QwtPlotScaleItem *scaleItem = new QwtPlotScaleItem();
scaleItem->setPalette(*p);
scaleItem->setFont(QFont (tr("blabla"), 10, 1, TRUE));
scaleItem->setScaleDivFromAxis(FALSE);
scaleItem->setScaleDiv((new QwtLinearScaleEngine())->divideScale(-28, 440, 5, 5));
scaleItem->setBorderDistance(2);
scaleItem->attach(myPlot);

which generates a red scale with red labels from -28 to 440.

blelump
2nd June 2008, 18:49
Some time ago a user had sent me a patch that allows having 8 axes ( 2 in each direction ). I will have a look at it this weekend. If it can be ported to Qwt 5.1 I will add it to the patches section on the Qwt project page. I guess it should be possible to modify it to support more axes too.

Uwe

I just would like to ask, how goes the thing with more than 2 scales per axis? I've checked the newest 5.1.1 version and I haven't seen any changes.

thanks in advance for info.

Uwe
3rd June 2008, 06:44
The patch (http://sourceforge.net/tracker/?atid=313693&group_id=13693&func=browse) is available, but I don't know myself how useful it is.

Uwe

blelump
5th June 2008, 15:20
The patch (http://sourceforge.net/tracker/?atid=313693&group_id=13693&func=browse) is available, but I don't know myself how useful it is.

Uwe

Thanks for your reply, but I need some more infos.:confused:

The patch is for six new Y-axes and I reimplemented it for 10 new X-axes (because I need more X instead of Y) so there's 12 X-axes for now and it even works.
But there's a small bug cause when I try to enable some new axis, then every axis is in the same place (like on the stack). I suppose it is problem with computing new coordinates for axes. Could you tell me where I could find a method which computes coordinates for every axis or better how to fix this?