mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-02-08 09:48:41 +01: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:
@@ -1,7 +1,7 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#include "SlsQt2DPlot.h"
|
||||
// #include "sls/ansi.h"
|
||||
#include "sls/logger.h"
|
||||
|
||||
#include <qlist.h>
|
||||
#include <qprinter.h>
|
||||
@@ -141,6 +141,12 @@ void SlsQt2DPlot::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)));
|
||||
}
|
||||
|
||||
void SlsQt2DPlot::UnZoom(bool replot) {
|
||||
@@ -153,6 +159,32 @@ void SlsQt2DPlot::UnZoom(bool replot) {
|
||||
// zoomer->zoom(0);
|
||||
}
|
||||
|
||||
void SlsQt2DPlot::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 SlsQt2DPlot::SetZoom(const QRectF &rect) {
|
||||
double xmin = 0, xmax = 0, ymin = 0, ymax = 0;
|
||||
rect.getCoords(&xmin, &ymin, &xmax, &ymax);
|
||||
LOG(logDEBUG1) << "Plot zooming in to " << xmin << " " << xmax << " "
|
||||
<< ymin << " " << ymax;
|
||||
SetXMinMax(xmin, xmax);
|
||||
SetYMinMax(ymin, ymax);
|
||||
replot();
|
||||
}
|
||||
|
||||
void SlsQt2DPlot::SetZoom(double xmin, double ymin, double x_width,
|
||||
double y_width) {
|
||||
zoomer->setZoomBase(QRectF(xmin, ymin, x_width, y_width));
|
||||
|
||||
Reference in New Issue
Block a user