void PlotZoomer::zoom(int up) { // FIXME: Save the current zoom window in case it's been panned. int zoomIndex = zoomRectIndex(); if (zoomIndex > 0) { QStack<QRectF> stack = zoomStack(); if (zoomIndex < stack.size()) { QRectF r = scaleRect(); stack[zoomIndex] = r; setZoomStack(stack, zoomIndex); } } Super::zoom(up); if (zoomRectIndex() == 0) { if (QwtPlot *plotter = plot()) { plotter->setAxisAutoScale(AxisX); plotter->setAxisAutoScale(AxisY); plotter->updateAxes(); } } }
void PlotZoomer::saveSettings(QSettings &settings) { settings.beginGroup("zoom"); settings.setValue("mode", int(_zoomMode)); settings.setValue("index", zoomRectIndex()); settings.beginWriteArray("stack", zoomStack().size()); int i = 0; for (const QRectF &zoom : zoomStack()) { settings.setArrayIndex(i++); write(settings, zoom); } settings.endArray(); settings.endGroup(); }
LogPlotZoomer::LogPlotZoomer(QWidget *canvas) : QwtPlotZoomer(canvas) #else LogPlotZoomer::LogPlotZoomer(QwtPlotCanvas *canvas): QwtPlotZoomer(canvas) #endif {} #if QWT_VERSION > 0x060000 QwtText LogPlotZoomer::trackerTextF(const QwtDoublePoint &pos) const #else QwtText LogPlotZoomer::trackerText(const QwtDoublePoint &pos) const #endif { switch (rubberBand()) { case HLineRubberBand: return QString().sprintf("%.4g", pos.y()); case VLineRubberBand: return QString().sprintf("%.4g", pos.x()); default: return QString().sprintf("%.4g, %.4g", pos.x(), pos.y()); } return QwtText(); // make some dumb compilers happy } /*void QwtPlotZoomer::move(double x, double y) { x = qwtMax(x, zoomBase().left()); x = qwtMin(x, zoomBase().right() - zoomRect().width()); y = qwtMax(y, zoomBase().top()); y = qwtMin(y, zoomBase().bottom() - zoomRect().height()); if (x != zoomRect().left() || y != zoomRect().top()) { d_data->zoomStack[d_data->zoomRectIndex].moveTo(x, y); rescale(); } }*/ #if QWT_VERSION > 0x060000 void LogPlotZoomer::moveTo(const QPointF & pos) { double x = pos.x(); double y = pos.y(); #else void LogPlotZoomer::move(double x, double y) { #endif //QwtPlotZoomer::move(x,y); x = qwtMax(x, (double)zoomBase().left()); x = qwtMin(x, (double)(zoomBase().right() - zoomRect().width())); y = qwtMax(y, (double)zoomBase().top()); y = qwtMin(y, (double)(zoomBase().bottom() - zoomRect().height())); if (x != zoomRect().left() || y != zoomRect().top()) { //zoomStack()[zoomRectIndex()].moveTo(x, y); QwtDoubleRect & rect = const_cast<QwtDoubleRect &>(zoomStack()[zoomRectIndex()]); //handle x axis const int xAxis = QwtPlotZoomer::xAxis(); const QwtScaleEngine *sex = plot()->axisScaleEngine(xAxis); #if QWT_VERSION > 0x060000 if (dynamic_cast<const QwtLogScaleEngine*>(sex)) #else if (dynamic_cast<const QwtLog10ScaleEngine*>(sex)) #endif { //logarithmic double factor = rect.right() / rect.left(); rect.setRight(x * factor); rect.setLeft(x); } else { rect.moveLeft(x); } const int yAxis = QwtPlotZoomer::yAxis(); const QwtScaleEngine *sey = plot()->axisScaleEngine(yAxis); #if QWT_VERSION > 0x060000 if (dynamic_cast<const QwtLogScaleEngine*>(sey)) #else if (dynamic_cast<const QwtLog10ScaleEngine*>(sey)) #endif { //logarithmic double factor = rect.bottom() / rect.top(); rect.setBottom(y * factor); rect.setTop(y); } else { rect.moveTop(y); } //zoomStack()[zoomRectIndex()].moveTo(x, y); rescale(); } }