* gain plot: dont allow zoom, only zoom on main plot

* fixed gain plot zooming

* fixing panning for gainplots
This commit is contained in:
Dhanya Thattil
2022-10-18 15:27:44 +02:00
committed by GitHub
parent d2c4827b31
commit 4a7cd051c1
11 changed files with 157 additions and 13 deletions

View File

@ -3,6 +3,7 @@
/* TODO! short description */
#include "SlsQt1DPlot.h"
#include "sls/logger.h"
#include <iostream>
#include <qwt_legend.h>
#include <qwt_math.h>
@ -464,6 +465,16 @@ void SlsQt1DPlot::DisableRoiBox() {
}
}
void SlsQt1DPlot::SetZoomX(const QRectF &rect) {
double xmin = 0, xmax = 0, ymin = 0, ymax = 0;
rect.getCoords(&xmin, &ymin, &xmax, &ymax);
LOG(logDEBUG1) << "Zoomed in at " << xmin << "\t" << xmax << "\t" << ymin
<< "\t" << ymax;
SetXMinMax(xmin, xmax);
// SetYMinMax(ymin, ymax);
replot();
}
void SlsQt1DPlot::UnZoom() {
setAxisScale(QwtPlot::xBottom, zoomer->x(), zoomer->x() + zoomer->w());
setAxisScale(QwtPlot::yLeft, zoomer->y(), zoomer->y() + zoomer->h());
@ -480,6 +491,22 @@ void SlsQt1DPlot::SetZoom(double xmin, double ymin, double x_width,
Update();
}
void SlsQt1DPlot::GetPannedCoord(int, int) {
double xmin = invTransform(QwtPlot::xBottom, 0);
double xmax = invTransform(QwtPlot::xBottom, canvas()->rect().width());
double ymax = invTransform(QwtPlot::yLeft, 0);
double ymin = invTransform(QwtPlot::yLeft, canvas()->rect().height());
LOG(logDEBUG1) << "Rect1 " << xmin << "\t" << xmax << "\t" << ymin << "\t"
<< ymax;
QPointF topLeft = QPointF(xmin, ymin);
QPointF bottomRight = QPointF(xmax, ymax);
const QRectF rectf = QRectF(topLeft, bottomRight);
rectf.getCoords(&xmin, &ymin, &xmax, &ymax);
LOG(logDEBUG1) << "RectF " << xmin << "\t" << xmax << "\t" << ymin << "\t"
<< ymax;
emit PlotZoomedSignal(rectf);
}
void SlsQt1DPlot::RemoveHLine() {
if (hline)
hline->detach();
@ -540,6 +567,11 @@ void SlsQt1DPlot::SetupZoom() {
const QColor c(Qt::darkBlue);
zoomer->setRubberBandPen(c);
zoomer->setTrackerPen(c);
connect(zoomer, SIGNAL(zoomed(const QRectF &)), this,
SIGNAL(PlotZoomedSignal(const QRectF &)));
connect(panner, SIGNAL(panned(int, int)), this,
SLOT(GetPannedCoord(int, int)));
}
// Set a plain canvas frame and align the scales to it