mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-22 17:47:59 +02:00
Gainzoom (#556)
* gain plot: dont allow zoom, only zoom on main plot * fixed gain plot zooming * fixing panning for gainplots
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user