PDA

View Full Version : Qwt: Using QwtPlotPicker on multiple plots



y.shan
2nd October 2007, 14:37
Hi,

i'm looking for solution for the following problem:

i have some qwtplots lined vertically that have the same x-axis-scaling, but different y-axis.

now i have a qwtplotpicker on each plot-canvas attached and when i select a point for example in the first plot (i get a crossrubberband, like in the bode example), i want to have a vertical rubberband in the other inactive plots shown at the same x coordinate.

i found a solution for qwt 4.2.0 which used the outline pen, but that's obsolete.

my current approach is to connect the qwtplotpicker::moved signal to a slot which iterates through all plots and sends a update() to the paintevent where i tried to draw the rubberband using picker->drawRubberBand(), which didn't worked.

is there a solution without deriving qwtplotpicker?

Uwe
2nd October 2007, 16:49
What about using a QwtPlotMarker ( VLine style ) ?

Uwe

baray98
23rd October 2007, 22:54
hi y.shan and uwe and all,

I was wondering if you could help me with these.

My problem is to make two qwtplots lined vertically that have the same x-axis-scaling, but different y-axis.

How did you implement this?

baray98

Uwe
24th October 2007, 06:54
Have a look at the implementation of PlotMatrix::alignVAxes in the plot matrix example; http://qwt.svn.sourceforge.net/viewvc/qwt/trunk/qwt/examples/plotmatrix/plotmatrix.cpp?view=markup.

The trick is to calculate the maximum extent of all vertical axes and to assign it to all of them.

HTH,
Uwe

PS: Please start a new thread, when you ask for something completely different.

y.shan
25th October 2007, 12:23
yeah, that plotmatrix example also helped me alot,
i had the same problem with aligning my plots vertically (if that is the problem you have) and i solved it like this way




void myPlotFrame::paintEvent(QPaintEvent *pe)
{
QListIterator<QwtPlot*> it(myPlots); //i have a QList<QwtPlot*> for my plots
QwtPlot *current_plot;
int maxExtent = 0;

while (it.hasNext())
{
current_plot = it.next();

QwtScaleWidget *scaleWidget = current_plot->axisWidget(QwtPlot::yLeft);
QwtScaleDraw *sd = scaleWidget->scaleDraw();
sd->setMinimumExtent(0);

const int extent = sd->extent(
QPen(Qt::black, scaleWidget->penWidth()),
scaleWidget->font() );
if ( extent > maxExtent )
maxExtent = extent;
}

it.toFront();
while (it.hasNext())
{
current_plot = it.next();
QwtScaleWidget *scaleWidget = current_plot->axisWidget(QwtPlot::yLeft);
scaleWidget->scaleDraw()->setMinimumExtent(maxExtent);
}
}