QWT 對座標軸縮放拖動

https://forum.qt.io/topic/54848/qwtplot-zooming-logarithmic-scale/2

zoscHello,

i have a QwtPlot with a logarithmic scale on y and time scale on x. That was not the problem, but zooming into the graph.
I have three unwanted effects, but don’t know how to fix:

when use wheel mouse to zoom in i can see on my y-axes only 1000 no other values.
when i zoom out my y-axes goes down to 1E-100 ?
when i use ctrl+LeftMouse to open the RubberBandPan to zoom from 400 to 1000 mbar, i see a lot of values of the y-axes
from 440 to 1000 every 20 mbar.
when i zoom into 1e-5 to 1e-6 dosen’t work, i see y-axes range from 0,01 to 1e-100 ?

QwtLogScaleEngine* axesy = new QwtLogScaleEngine();
ui->plot->setTitle("Plot");
ui->plot->setAxisTitle(QwtPlot::yLeft,QString("Pressure [%1]").arg(QString("mbar")));
ui->plot->setAxisTitle(QwtPlot::xBottom,QString("Time [%1]").arg(QString("s")));
ui->plot->setAxisScaleEngine(QwtPlot::yLeft, axesy);
ui->plot->setAxisMaxMajor( QwtPlot::yLeft, 100);
ui->plot->setAxisMaxMinor( QwtPlot::yLeft, 10);
ui->plot->setAxisScale(QwtPlot::yLeft,1e-10,2000);

// Setting Magnifier
QwtPlotMagnifier* zoom_x = new QwtPlotMagnifier(ui->plot->canvas());
QwtPlotMagnifier* zoom_y = new QwtPlotMagnifier(ui->plot->canvas());
// Shift+MouseWheel --> Magnifier x
zoom_x->setWheelModifiers(Qt::ShiftModifier);
zoom_x->setAxisEnabled(QwtPlot::xBottom, true);
zoom_x->setAxisEnabled(QwtPlot::yLeft, false);
// CTRL + MouseWheel --> Magnifier y
zoom_y->setWheelModifiers(Qt::ControlModifier);
zoom_y->setAxisEnabled(QwtPlot::xBottom,false);
zoom_y->setAxisEnabled(QwtPlot::yLeft,true);

// Left Button for panning
QwtPlotPanner* panner = new QwtPlotPanner (ui->plot->canvas());
panner->setMouseButton(Qt::LeftButton);

//QwtPlotZoomer* zoomer = new QwtPlotZoomer( ui->plot->canvas() );
QwtPlotZoomer* zoomer = new QwtPlotZoomer( QwtPlot::xBottom, QwtPlot::yLeft, ui->plot->canvas()  );
zoomer->setRubberBandPen( QColor( Qt::black ) );
zoomer->setTrackerPen( QColor( Qt::red ) );
// CTRL+LeftButton for the zooming
zoomer->setMousePattern( QwtEventPattern::MouseSelect1, Qt::LeftButton, Qt::ControlModifier);
// CTRL+RightButton back to full size
zoomer->setMousePattern( QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier);

QwtPlotGrid *grid = new QwtPlotGrid();
grid->enableY(true);
grid->enableYMin(true);
grid->setMajorPen( Qt::darkGray, 0, Qt::SolidLine );
grid->setMinorPen( Qt::gray, 0 , Qt::DotLine );
grid->attach(ui->plot);

QwtLegend* legend = new QwtLegend;
legend->setDefaultItemMode(QwtLegendData::Checkable);
ui->plot->insertLegend(legend,QwtPlot::RightLegend);

使用Qwt
在這裏插入圖片描述

在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章