mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 23:10:02 +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:
parent
d2c4827b31
commit
4a7cd051c1
1
RELEASE.txt
Executable file → Normal file
1
RELEASE.txt
Executable file → Normal file
@ -100,6 +100,7 @@ This document describes the differences between v7.0.0 and v6.x.x
|
||||
- jungfrau reset core and usleep removed (fix for 6.1.1 is now fixed in firmware)
|
||||
- g2 change clkdivs 2 3 4 to defaults for burst and cw mode.
|
||||
- ctb and moench: allowing 1g non blocking acquire to send data
|
||||
- gain plot zooming fixed (disabled, acc. to main plot)
|
||||
- ctb, moench, jungfrau (pll reset at start fixed, before no defines)
|
||||
|
||||
2. Resolved Issues
|
||||
|
@ -64,6 +64,8 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
|
||||
private slots:
|
||||
void Zoom1DGainPlot(const QRectF &rect);
|
||||
void Zoom2DGainPlot(const QRectF &rect);
|
||||
void SetSaveFileName(QString val);
|
||||
void UpdatePlot();
|
||||
|
||||
|
@ -169,9 +169,16 @@ class SlsQt1DPlot : public QwtPlot {
|
||||
|
||||
QwtPlotShapeItem *roiBox{nullptr};
|
||||
|
||||
signals:
|
||||
void PlotZoomedSignal(const QRectF &);
|
||||
|
||||
public slots:
|
||||
void SetZoomX(const QRectF &rect);
|
||||
void UnZoom();
|
||||
void Update();
|
||||
|
||||
private slots:
|
||||
void GetPannedCoord(int, int);
|
||||
};
|
||||
|
||||
} // namespace sls
|
||||
|
@ -76,6 +76,13 @@ class SlsQt2DPlot : public QwtPlot {
|
||||
|
||||
public slots:
|
||||
void showSpectrogram(bool on);
|
||||
void SetZoom(const QRectF &rect);
|
||||
|
||||
private slots:
|
||||
void GetPannedCoord(int, int);
|
||||
|
||||
signals:
|
||||
void PlotZoomedSignal(const QRectF &);
|
||||
|
||||
private:
|
||||
void SetupZoom();
|
||||
|
@ -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
|
||||
|
@ -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));
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <QPainter>
|
||||
#include <QResizeEvent>
|
||||
#include <QtConcurrentRun>
|
||||
#include <qwt_scale_engine.h>
|
||||
|
||||
namespace sls {
|
||||
|
||||
@ -170,14 +171,15 @@ void qDrawPlot::SetupPlots() {
|
||||
QList<double> majorTicks({0, 1, 2, 3});
|
||||
QwtScaleDiv div(0, 3, QList<double>(), QList<double>(), majorTicks);
|
||||
gainplot1d->setAxisScaleDiv(QwtPlot::yLeft, div);
|
||||
// gainplot1d->axisScaleDraw(QwtPlot::xBottom)->enableComponent(QwtScaleDraw::Ticks,
|
||||
// false);
|
||||
// gainplot1d->axisScaleDraw(QwtPlot::yLeft)->enableComponent(QwtScaleDraw::Labels,
|
||||
// false);
|
||||
|
||||
gainhist1d->setItemAttribute(QwtPlotItem::Legend, false);
|
||||
gainhist1d->Attach(gainplot1d);
|
||||
gainplot1d->DisableZoom(true);
|
||||
gainplot1d->hide();
|
||||
|
||||
connect(plot1d, SIGNAL(PlotZoomedSignal(const QRectF &)), this,
|
||||
SLOT(Zoom1DGainPlot(const QRectF &)));
|
||||
|
||||
// setup 2d data
|
||||
|
||||
delete[] data2d;
|
||||
@ -226,8 +228,12 @@ void qDrawPlot::SetupPlots() {
|
||||
gainplot2d->enableAxis(QwtPlot::xBottom, false);
|
||||
// set ticks to just 3
|
||||
gainplot2d->setAxisScaleDiv(QwtPlot::yRight, div);
|
||||
gainplot2d->DisableZoom(true);
|
||||
gainplot2d->hide();
|
||||
|
||||
connect(plot2d, SIGNAL(PlotZoomedSignal(const QRectF &)), this,
|
||||
SLOT(Zoom2DGainPlot(const QRectF &)));
|
||||
|
||||
// layout of plots
|
||||
int ratio = qDefs::DATA_GAIN_PLOT_RATIO - 1;
|
||||
plotLayout->addWidget(plot1d, 0, 0, ratio, ratio);
|
||||
@ -237,6 +243,16 @@ void qDrawPlot::SetupPlots() {
|
||||
Qt::AlignRight | Qt::AlignTop);
|
||||
}
|
||||
|
||||
void qDrawPlot::Zoom1DGainPlot(const QRectF &rect) {
|
||||
std::lock_guard<std::mutex> lock(mPlots);
|
||||
gainplot1d->SetZoomX(rect);
|
||||
}
|
||||
|
||||
void qDrawPlot::Zoom2DGainPlot(const QRectF &rect) {
|
||||
std::lock_guard<std::mutex> lock(mPlots);
|
||||
gainplot2d->SetZoom(rect);
|
||||
}
|
||||
|
||||
void qDrawPlot::resizeEvent(QResizeEvent *event) {
|
||||
if (gainplot2d->isVisible()) {
|
||||
gainplot2d->setFixedWidth(plot2d->width() /
|
||||
@ -254,9 +270,9 @@ void qDrawPlot::resizeEvent(QResizeEvent *event) {
|
||||
|
||||
bool qDrawPlot::GetIsRunning() { return isRunning; }
|
||||
|
||||
void qDrawPlot::SetRunning(bool enable) {
|
||||
void qDrawPlot::SetRunning(bool enable) {
|
||||
std::lock_guard<std::mutex> lock(mPlots);
|
||||
isRunning = enable;
|
||||
isRunning = enable;
|
||||
}
|
||||
|
||||
double qDrawPlot::GetProgress() { return progress; }
|
||||
@ -525,6 +541,7 @@ void qDrawPlot::ClonePlot() {
|
||||
h->SetLineColor(iHist);
|
||||
h->setStyleLinesorDots(isLines);
|
||||
h->setSymbolMarkers(isMarkers);
|
||||
h->setItemAttribute(QwtPlotItem::Legend, false);
|
||||
cloneplotHists1D.append(h);
|
||||
h->Attach(cloneplot1D);
|
||||
}
|
||||
@ -545,7 +562,11 @@ void qDrawPlot::ClonePlot() {
|
||||
QList<double> majorTicks({0, 1, 2, 3});
|
||||
QwtScaleDiv div(0, 3, QList<double>(), QList<double>(), majorTicks);
|
||||
clonegainplot1D->setAxisScaleDiv(QwtPlot::yLeft, div);
|
||||
clonegainplot1D->DisableZoom(true);
|
||||
h->Attach(clonegainplot1D);
|
||||
|
||||
connect(cloneplot1D, SIGNAL(PlotZoomedSignal(const QRectF &)),
|
||||
clonegainplot1D, SLOT(SetZoomX(const QRectF &)));
|
||||
}
|
||||
} else {
|
||||
LOG(logDEBUG) << "Cloning 2D Image";
|
||||
@ -586,6 +607,10 @@ void qDrawPlot::ClonePlot() {
|
||||
clonegainplot2D->enableAxis(2, false);
|
||||
clonegainplot2D->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY,
|
||||
-0.5, nPixelsY - 0.5, gainData);
|
||||
clonegainplot2D->DisableZoom(true);
|
||||
|
||||
connect(cloneplot2D, SIGNAL(PlotZoomedSignal(const QRectF &)),
|
||||
clonegainplot2D, SLOT(SetZoom(const QRectF &)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1104,47 +1129,57 @@ void qDrawPlot::Update2dPlot() {
|
||||
void qDrawPlot::Update1dXYRange() {
|
||||
if (!isXYRange[qDefs::XMIN] && !isXYRange[qDefs::XMAX]) {
|
||||
plot1d->EnableXAutoScaling();
|
||||
gainplot1d->EnableXAutoScaling();
|
||||
} else {
|
||||
double xmin = (isXYRange[qDefs::XMIN] ? xyRange[qDefs::XMIN]
|
||||
: plot1d->GetXMinimum());
|
||||
double xmax = (isXYRange[qDefs::XMAX] ? xyRange[qDefs::XMAX]
|
||||
: plot1d->GetXMaximum());
|
||||
plot1d->SetXMinMax(xmin, xmax);
|
||||
gainplot1d->SetXMinMax(xmin, xmax);
|
||||
}
|
||||
|
||||
if (!isXYRange[qDefs::YMIN] && !isXYRange[qDefs::YMAX]) {
|
||||
plot1d->EnableYAutoScaling();
|
||||
gainplot1d->EnableYAutoScaling();
|
||||
} else {
|
||||
double ymin = (isXYRange[qDefs::YMIN] ? xyRange[qDefs::YMIN]
|
||||
: plot1d->GetYMinimum());
|
||||
double ymax = (isXYRange[qDefs::YMAX] ? xyRange[qDefs::YMAX]
|
||||
: plot1d->GetYMaximum());
|
||||
plot1d->SetYMinMax(ymin, ymax);
|
||||
gainplot1d->SetYMinMax(ymin, ymax);
|
||||
}
|
||||
plot1d->Update();
|
||||
gainplot1d->Update();
|
||||
}
|
||||
|
||||
void qDrawPlot::Update2dXYRange() {
|
||||
if (!isXYRange[qDefs::XMIN] && !isXYRange[qDefs::XMAX]) {
|
||||
plot2d->EnableXAutoScaling();
|
||||
gainplot2d->EnableXAutoScaling();
|
||||
} else {
|
||||
double xmin = (isXYRange[qDefs::XMIN] ? xyRange[qDefs::XMIN]
|
||||
: plot2d->GetXMinimum());
|
||||
double xmax = (isXYRange[qDefs::XMAX] ? xyRange[qDefs::XMAX]
|
||||
: plot2d->GetXMaximum());
|
||||
plot2d->SetXMinMax(xmin, xmax);
|
||||
gainplot2d->SetXMinMax(xmin, xmax);
|
||||
}
|
||||
|
||||
if (!isXYRange[qDefs::YMIN] && !isXYRange[qDefs::YMAX]) {
|
||||
plot2d->EnableYAutoScaling();
|
||||
gainplot2d->EnableYAutoScaling();
|
||||
} else {
|
||||
double ymin = (isXYRange[qDefs::YMIN] ? xyRange[qDefs::YMIN]
|
||||
: plot2d->GetYMinimum());
|
||||
double ymax = (isXYRange[qDefs::YMAX] ? xyRange[qDefs::YMAX]
|
||||
: plot2d->GetYMaximum());
|
||||
plot2d->SetYMinMax(ymin, ymax);
|
||||
gainplot2d->SetYMinMax(ymin, ymax);
|
||||
}
|
||||
plot2d->Update();
|
||||
gainplot2d->Update();
|
||||
}
|
||||
|
||||
void qDrawPlot::toDoublePixelData(double *dest, char *source, int size,
|
||||
|
@ -3217,8 +3217,22 @@ void *start_timer(void *arg) {
|
||||
// Generate data
|
||||
char imageData[imagesize];
|
||||
memset(imageData, 0, imagesize);
|
||||
for (int i = 0; i < imagesize; i += sizeof(uint16_t)) {
|
||||
*((uint16_t *)(imageData + i)) = i;
|
||||
const int nchannels = NCHIP * NCHAN;
|
||||
int gainVal = 0;
|
||||
int channelVal = 0;
|
||||
for (int i = 0; i < nchannels; ++i) {
|
||||
if ((i % nchannels) < 400) {
|
||||
gainVal = 1;
|
||||
} else if ((i % nchannels) < 800) {
|
||||
gainVal = 2;
|
||||
} else {
|
||||
gainVal = 3;
|
||||
}
|
||||
channelVal = (i & ~GAIN_VAL_MSK) | (gainVal << GAIN_VAL_OFST);
|
||||
|
||||
*((uint16_t *)(imageData + i * sizeof(uint16_t))) =
|
||||
(uint16_t)channelVal;
|
||||
// LOG(logINFORED, ("[%d]:0x%08x\n", i, channelVal));
|
||||
}
|
||||
char vetoData[vetodatasize];
|
||||
memset(vetoData, 0, sizeof(vetodatasize));
|
||||
|
@ -94,6 +94,9 @@
|
||||
#define DEFAULT_ASIC_DOUT_RDY_SRC (0x5)
|
||||
#define DEFAULT_ASIC_DOUT_RDY_DLY (0x3)
|
||||
|
||||
#define GAIN_VAL_OFST (12)
|
||||
#define GAIN_VAL_MSK (0x3 << GAIN_VAL_OFST)
|
||||
|
||||
#define VETO_DATA_SIZE (160)
|
||||
typedef struct {
|
||||
uint64_t frameNumber;
|
||||
|
@ -2580,13 +2580,21 @@ void *start_timer(void *arg) {
|
||||
{
|
||||
const int npixels = (NCHAN * NCHIP);
|
||||
const int pixelsPerPacket = dataSize / NUM_BYTES_PER_PIXEL;
|
||||
int dataVal = 0;
|
||||
int gainVal = 0;
|
||||
int pixelVal = 0;
|
||||
for (int i = 0; i < npixels; ++i) {
|
||||
// avoiding gain also being divided when gappixels enabled in call
|
||||
// back
|
||||
if (i > 0 && i % pixelsPerPacket == 0) {
|
||||
++pixelVal;
|
||||
if (i % pixelsPerPacket == 0) {
|
||||
++dataVal;
|
||||
}
|
||||
if ((i % 1024) < 300) {
|
||||
gainVal = 1;
|
||||
} else if ((i % 1024) < 600) {
|
||||
gainVal = 2;
|
||||
} else {
|
||||
gainVal = 3;
|
||||
}
|
||||
pixelVal = (dataVal & ~GAIN_VAL_MSK) | (gainVal << GAIN_VAL_OFST);
|
||||
// to debug multi module geometry (row, column) in virtual servers (all pixels
|
||||
// in a module set to particular value)
|
||||
#ifdef TEST_MOD_GEOMETRY
|
||||
|
@ -138,6 +138,9 @@ enum CLKINDEX { RUN_CLK, ADC_CLK, DBIT_CLK, NUM_CLOCKS };
|
||||
#define MAX_PHASE_SHIFTS (240)
|
||||
#define BIT16_MASK (0xFFFF)
|
||||
|
||||
#define GAIN_VAL_OFST (14)
|
||||
#define GAIN_VAL_MSK (0x3 << GAIN_VAL_OFST)
|
||||
|
||||
// pipeline
|
||||
#define ADC_PORT_INVERT_VAL (0x5A5A5A5A)
|
||||
#define ADC_PORT_INVERT_BOARD2_VAL (0x453b2a9c)
|
||||
|
Loading…
x
Reference in New Issue
Block a user