mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-22 22:40:02 +02:00

* roi structure expanded to have ymin and ymax * compile with 'detector roi' * wip * wip, rx_roi, rx_clearroi * wip rxroi * rxroi wip * wip rxroi * merge fix * wip * rx_roi works, impl wip, test * tests in, impl left * wip, rxroi impl * wip, rxroi impl * wip * setrx_Roi works, getrx_roi, wip * rx_roi impl done * wip, rxroi * wip, getrx_roi rxr ports * fix ports * wip * wip * fix positions on server side * wip * numports wip * wip * jungfrau top inner interface row increment * x, y detpos, wip * removed eiger row indices flipping in gui (bottom flipping maintained) * wip * wip, jungfrau numinterfaces2 * jungfrau virtual works * eiger, jungfrau, g2 virtual server works * eiger positions fix, wip * binaries in * minor printout * binaries in * merge fix * merge fix * removing getposition * setrxroi wip * set upto port * get messed, wip * roi multi to module works, wip * wip * roi dont return -1 * added rxroi metadata in master file * added rxroifromshm, not yet in detector * rx roi in gui with box, also for gap pixels (gappixels for jungfrau mess) * fix for segfault in gui with detaching roi box in gui * wip * m3 gui: slave timing modes should be discarded when squashing * fixed m3 virtual data, and fixed counters in gui asthetics * m3 roi works * wip, g2 * wip * handling g225um boards, and showing roi for gainplot as well * udpate python functions * fix for 1d and a2d roi written * fixed actual roi written to file * no virtual hdf5 when handling rx roi * test * minor * binarie in
174 lines
4.7 KiB
C++
174 lines
4.7 KiB
C++
// SPDX-License-Identifier: LGPL-3.0-or-other
|
|
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
|
#ifndef SLSQT1DPLOT_H
|
|
#define SLSQT1DPLOT_H
|
|
|
|
#include "SlsQt1DZoomer.h"
|
|
#include "sls/ansi.h"
|
|
#include <qwt_plot.h>
|
|
#include <qwt_plot_curve.h>
|
|
#include <qwt_plot_marker.h>
|
|
#include <qwt_scale_div.h>
|
|
#include <qwt_plot_shapeitem.h>
|
|
|
|
class QPen;
|
|
class SlsQt1DPlot;
|
|
class QwtSymbol;
|
|
|
|
class SlsQtH1D : public QwtPlotCurve {
|
|
|
|
public:
|
|
SlsQtH1D(QString title, int n, double xmin, double xmax, double *data = 0);
|
|
SlsQtH1D(QString title, int n, double *data_x, double *data_y);
|
|
~SlsQtH1D();
|
|
|
|
void Attach(SlsQt1DPlot *p);
|
|
void Detach(SlsQt1DPlot *p);
|
|
|
|
int SetLineColor(int c = -1);
|
|
int SetLineWidth(int w = 1);
|
|
void SetLineStyle(int s = 0);
|
|
void setStyleLinesorDots(bool isLines);
|
|
void setSymbolMarkers(bool isMarker);
|
|
|
|
void SetData(int n, double xmin, double xmax, double *d = 0);
|
|
void SetData(int n, double *dx, double *dy);
|
|
|
|
double *GetX() { return x; }
|
|
double *GetY() { return y; }
|
|
int GetNBinsX() { return ndata; }
|
|
|
|
double FillBin(int bx, double v = 1);
|
|
double Fill(double x, double v = 1);
|
|
double SetBinContent(int bx, double v);
|
|
double SetContent(double x, double v);
|
|
int FindBinIndex(double px);
|
|
|
|
double GetXMin() { return x[0]; }
|
|
double GetFirstXgtZero() { return firstXgt0; }
|
|
double GetXMax() { return x[ndata - 1]; }
|
|
double GetYMin() { return ymin; }
|
|
double GetFirstYgtZero() { return firstYgt0; }
|
|
double GetYMax() { return ymax; }
|
|
|
|
SlsQtH1D *Add(double v);
|
|
|
|
private:
|
|
int ndata;
|
|
int n_array;
|
|
double dx;
|
|
double *x{nullptr}, *y{nullptr};
|
|
double ymin, ymax;
|
|
double firstXgt0, firstYgt0;
|
|
void Initailize();
|
|
int SetUpArrays(int n);
|
|
int CheckIndex(int bx);
|
|
|
|
QPen *pen_ptr{nullptr};
|
|
};
|
|
|
|
class SlsQtH1DList {
|
|
public:
|
|
SlsQtH1DList(SlsQtH1D *hist = 0);
|
|
~SlsQtH1DList();
|
|
|
|
SlsQtH1D *Add(SlsQtH1D *h);
|
|
void Remove(SlsQtH1D *h);
|
|
void Print();
|
|
|
|
SlsQtH1D *Hist() { return the_hist; } // if no hist returns 0
|
|
SlsQtH1DList *Next() { return the_next; }
|
|
|
|
private:
|
|
SlsQtH1DList *the_next;
|
|
SlsQtH1D *the_hist;
|
|
};
|
|
|
|
class SlsQt1DPlot : public QwtPlot {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
SlsQt1DPlot(QWidget * = NULL);
|
|
~SlsQt1DPlot();
|
|
|
|
void SetTitle(QString title);
|
|
void SetXTitle(QString title);
|
|
void SetYTitle(QString title);
|
|
void SetTitleFont(const QFont &f);
|
|
void SetXFont(const QFont &f);
|
|
void SetYFont(const QFont &f);
|
|
|
|
void InsertHLine(double y);
|
|
void RemoveHLine();
|
|
void InsertVLine(double v);
|
|
void RemoveVLine();
|
|
|
|
/** This group of functions have been added by Dhanya on 19.06.2012 to be
|
|
able to use zooming functionality without mouse control*/
|
|
void DisableZoom(bool disable);
|
|
void EnableXAutoScaling() {
|
|
setAxisAutoScale(QwtPlot::xBottom, true);
|
|
Update();
|
|
};
|
|
void EnableYAutoScaling() {
|
|
setAxisAutoScale(QwtPlot::yLeft, true);
|
|
Update();
|
|
};
|
|
void SetYStep(int step) { ystep = step; };
|
|
void SetXMinMax(double min, double max) {
|
|
setAxisScale(QwtPlot::xBottom, min, max);
|
|
};
|
|
void SetYMinMax(double min, double max) {
|
|
setAxisScale(QwtPlot::yLeft, min, max);
|
|
};
|
|
double GetXMinimum() { return hist_list->Hist()->GetXMin(); };
|
|
double GetXMaximum() { return hist_list->Hist()->GetXMax(); };
|
|
double GetYMinimum() { return hist_list->Hist()->GetYMin(); };
|
|
double GetYMaximum() { return hist_list->Hist()->GetYMax(); };
|
|
/**---*/
|
|
|
|
void SetZoom(double xmin, double ymin, double x_width, double y_width);
|
|
void SetZoomBase(double xmin, double ymin, double x_width, double y_width) {
|
|
zoomer->SetZoomBase(xmin, ymin, x_width, y_width);
|
|
}
|
|
|
|
void alignScales();
|
|
|
|
void SetLogX(bool yes = 1);
|
|
void SetLogY(bool yes = 1);
|
|
|
|
void EnableRoiBox(std::array<int, 4> roi);
|
|
void DisableRoiBox();
|
|
|
|
private:
|
|
SlsQtH1DList *hist_list{nullptr};
|
|
SlsQt1DZoomer *zoomer{nullptr};
|
|
QwtPlotPanner *panner{nullptr};
|
|
|
|
QwtPlotMarker *hline{nullptr};
|
|
QwtPlotMarker *vline{nullptr};
|
|
bool disableZoom{false};
|
|
int ystep{0};
|
|
|
|
void SetupZoom();
|
|
void UnknownStuff();
|
|
// void alignScales();
|
|
|
|
void CalculateNResetZoomBase();
|
|
void NewHistogramAttached(SlsQtH1D *h);
|
|
void HistogramDetached(SlsQtH1D *h);
|
|
|
|
void SetLog(int axisId, bool yes);
|
|
|
|
friend void SlsQtH1D::Attach(SlsQt1DPlot *p);
|
|
friend void SlsQtH1D::Detach(SlsQt1DPlot *p);
|
|
|
|
QwtPlotShapeItem *roiBox{nullptr};
|
|
|
|
public slots:
|
|
void UnZoom();
|
|
void Update();
|
|
};
|
|
|
|
#endif
|