PDA

View Full Version : Get y value vertical line



oddytz1989
22nd August 2014, 06:40
Hello, I use the library qwt 6.0.1. Needed know the y-value of when you click on the chart.
An example is shown in the picture. When you click on the chart I need to know the value is not the nearest to the point of clicking, and the nearest of the vertical line. That is, when you click the mouse must be received by the value of point 2, not 1 point.

Before I do so:

int index = _curve1->closestPoint(_picker->trackerPosition());
But in this way I get the value of point 1 and not 2.

Sorry for my English.

10575

Uwe
22nd August 2014, 09:33
Then you have to write some code. Have a look at the playground/curvetracker example in Qwt 6.1.

Uwe

oddytz1989
22nd August 2014, 12:00
Thank you. I used an older version of qwt 6.0.1, because for her there was a patch on the 10 axes y.
Do I have any problems installing the patch to version 6.1.0? Or enough to make changes to source files, or automatically through the app "patch" or manually replacing the lines?

Uwe
22nd August 2014, 12:45
My hint was to have a look at the example in Qwt 6.1 how it could be done. It doesn't mean, that you have to upgrade your Qwt version only to implement something similar with Qwt 6.0.

Concerning the multi axes patch: there is a branch of Qwt 6.1 ( see the svn repository ), that implements multi axes in a much better way. This branch is actively maintained and planned to be released as one of the next versions of Qwt ( 6.3 or 6.4 ).

Uwe

oddytz1989
26th August 2014, 10:42
Hello Uwe. I downloaded a version of qwt 6.1.0-multiaxes. Displayed on the chart two curves, each curve has its own axis-y. Everything works fine.
But when connecting the does not work properly.

I write as follows:


for (;i < axesCount(QwtPlot::yLeft);i++)
{
QwtAxisId axisId(QwtPlot::yLeft,i);

_curve[i] = new QwtPlotCurve();
_curve[i]->setAxes(QwtPlot::xBottom,axisId);
_symbol[i] = new QwtSymbol();
_zoomer[i] = new Zoomer(QwtAxis::xBottom,axisId,this->canvas());
_color[i] = /*QColor(*/trendColors[i]/*)*/;
_curve[i]->setPen(QPen(_color[i]));
_curve[i]->attach(this);
_symbol[i]->setStyle(QwtSymbol::Ellipse);
_symbol[i]->setPen(QColor(_color[i]));
_palette[i].setColor(QPalette::WindowText, _color[i]);
_palette[i].setColor(QPalette::Text, _color[i]);
}

By the number of y-axes I create an object zoomer.
But with the increase of the graph increases is not what I want. Example I tried to show in the picture.

Tell me, please, what I'm doing wrong.

oddytz1989
27th August 2014, 06:02
corrected so:



for (;i < axesCount(QwtPlot::yLeft);i++)
{
QwtAxisId axisId(QwtPlot::yLeft,i);
_curve[i] = new QwtPlotCurve();
_curve[i]->setAxes(QwtAxisId(xBottom),axisId);
_zoomer[i] = new Zoomer(QwtAxisId(xBottom),axisId,this->canvas());
.....
.....
}


I have to chart two curves have a common axis X and each curve has its own Y axis

Сhart increases normally on both y-axes, and the X-axis chart increases with the double force.
That is, if I select the area on the chart axis X from 1 to 2, the screen will show the area from 1.3 to 1.7. On the y axis is zooming as it should.

I understand why this is happening, since the declaration of zoomer object i do increase the axes [X,Y1] and [X,Y2] therefore X axis is increased twice.


I can not understand how can I do so that the increase of the axes working correctly.

Uwe
27th August 2014, 08:22
if ( i == 0 )
_zoomer[i] = new Zoomer(QwtAxisId(xBottom),axisId,this->canvas());
else
_zoomer[i] = new Zoomer(QwtAxisId(xTop),axisId,this->canvas());
Uwe

oddytz1989
27th August 2014, 11:33
Uwe, thanks for the answer.I did as you wrote

The zooming in working very strange. First time with an zooming in any area everything works fine, next if you go back to the original scale, and zooming again the same area of ​​the graph occurs something strange. Scale of the axis is not changed and the graphics are not clear.

If I again return to the original scale, and again zooming graph back all will work fine.

That is, there is a constant alternation of successful and unsuccessful zooming the plot area.

Here is an example of 3 Pictures:
1. Initial scale of the graph.
2. Successful zooming in the plot area.
3. Unsuccessful zooming the plot area.

Can you please tell how to fix it?

oddytz1989
24th September 2014, 07:18
Hello, my problem, I have not decided yet. Somebody tell me how to use Zoomer with multiple y-axes&

Uwe
24th September 2014, 09:07
From showing 3 screenshots you can't expect, that someone knows what is going on on your system - I didn't even get what exactly goes wrong.
Guess you need to upload a small compilable demo application.

Uwe