mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-28 17:10:03 +02:00
WIP
This commit is contained in:
parent
8ac7d96ef3
commit
0e0e5db7c5
@ -26,8 +26,7 @@ class qCloneWidget : public QMainWindow {
|
||||
|
||||
void SetupWidgetWindow(QString title, QString xTitle, QString yTitle, QString zTitle, int numDim);
|
||||
void SetCloneHists(unsigned int nHists, int histNBins, double *histXAxis, std::vector<double*> histYAxis, QString histTitle, bool lines, bool markers);
|
||||
void SetCloneHists2D(int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, double *d, QString frameIndexTitle);
|
||||
void SetRange(bool IsXYRange[], double XYRange[]);
|
||||
void SetCloneHists2D(int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, double *d, QString frameIndexTitle, bool isZmax, bool isZmin, double zmin, double zmax);
|
||||
SlsQt1DPlot *Get1dPlot();
|
||||
|
||||
public slots:
|
||||
|
@ -27,15 +27,12 @@ class qDrawPlot : public QWidget {
|
||||
void SetXAxisTitle(QString title);
|
||||
void SetYAxisTitle(QString title);
|
||||
void SetZAxisTitle(QString title);
|
||||
void DisableZoom(bool disable);
|
||||
void SetXYRangeChanged();
|
||||
void SetXYRangeValues(double val, qDefs::range xy);
|
||||
void IsXYRangeValues(bool changed, qDefs::range xy);
|
||||
void SetXYRangeChanged(bool disable, double* xy, bool* isXY);
|
||||
void SetZRange(double* z, bool* isZ);
|
||||
double GetXMinimum();
|
||||
double GetXMaximum();
|
||||
double GetYMinimum();
|
||||
double GetYMaximum();
|
||||
void SetZRange(bool isZmin, bool isZmax, double zmin, double zmax);
|
||||
void SetDataCallBack(bool enable);
|
||||
void SetBinary(bool enable, int from = 0, int to = 0);
|
||||
void StartAcquisition();
|
||||
@ -78,7 +75,7 @@ class qDrawPlot : public QWidget {
|
||||
void SetupPlots();
|
||||
int LockLastImageArray();
|
||||
int UnlockLastImageArray();
|
||||
void SetStyle(SlsQtH1D *h);
|
||||
void SetStyleandSymbol(SlsQtH1D *h);
|
||||
void GetStatistics(double &min, double &max, double &sum);
|
||||
void DetachHists();
|
||||
static void GetProgressCallBack(double currentProgress, void *this_pointer);
|
||||
@ -122,9 +119,11 @@ class qDrawPlot : public QWidget {
|
||||
QString zTitle2d{"Intensity"};
|
||||
QString plotTitle{""};
|
||||
QString indexTitle{""};
|
||||
bool XYRangeChanged{false};
|
||||
double XYRange[4]{0, 0, 0, 0};
|
||||
bool xyRangeChanged{false};
|
||||
double xyRange[4]{0, 0, 0, 0};
|
||||
bool isXYRange[4]{false, false, false, false};
|
||||
double zRange[2]{0, 1};
|
||||
bool isZRange[2]{false, false};
|
||||
|
||||
// data
|
||||
unsigned int nHists{1};
|
||||
@ -159,11 +158,13 @@ class qDrawPlot : public QWidget {
|
||||
std::vector<qCloneWidget *> cloneWidgets;
|
||||
QString fileSavePath{"/tmp"};
|
||||
QString fileSaveName{"Image"};
|
||||
bool isGainDataExtracted{false};
|
||||
bool hasGainData{false};
|
||||
bool isGainDataExtracted{false};
|
||||
bool disableZoom{false};
|
||||
|
||||
int progress{0};
|
||||
int64_t currentFrame{0};
|
||||
mutable std::mutex mPlots;
|
||||
pthread_mutex_t lastImageCompleteMutex;
|
||||
|
||||
unsigned int nPixelsX{0};
|
||||
|
@ -119,7 +119,7 @@ class SlsQt1DPlot:public QwtPlot{
|
||||
|
||||
/** 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 disableZoom);
|
||||
void DisableZoom(bool disable);
|
||||
void EnableXAutoScaling() {setAxisAutoScale(QwtPlot::xBottom, true);};
|
||||
void EnableYAutoScaling() {setAxisAutoScale(QwtPlot::yLeft, true);};
|
||||
void SetXMinMax(double min,double max){setAxisScale(QwtPlot::xBottom,min,max);};
|
||||
@ -146,6 +146,7 @@ class SlsQt1DPlot:public QwtPlot{
|
||||
|
||||
QwtPlotMarker *hline;
|
||||
QwtPlotMarker *vline;
|
||||
bool disableZoom{false};
|
||||
|
||||
void SetupZoom();
|
||||
void UnknownStuff();
|
||||
|
@ -49,6 +49,7 @@ private:
|
||||
QList<double> contourLevelsLinear;
|
||||
QList<double> contourLevelsLog;
|
||||
#endif
|
||||
bool disableZoom{false};
|
||||
|
||||
void SetupZoom();
|
||||
void SetupColorMap();
|
||||
@ -69,7 +70,7 @@ public:
|
||||
|
||||
/** 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 disableZoom);
|
||||
void DisableZoom(bool disable);
|
||||
void EnableXAutoScaling() {setAxisAutoScale(QwtPlot::xBottom, true);};
|
||||
void EnableYAutoScaling() {setAxisAutoScale(QwtPlot::yLeft, true);};
|
||||
void SetXMinMax(double min,double max){setAxisScale(QwtPlot::xBottom,min,max);};
|
||||
|
@ -22,12 +22,8 @@ class SlsQt2DPlotLayout : public QGroupBox {
|
||||
void SetZTitle(QString st);
|
||||
void SetInterpolate(bool enable);
|
||||
void SetContour(bool enable);
|
||||
void SetLogz(bool enable);
|
||||
void KeepZRangeIfSet();
|
||||
// recalculate zmin and zmax from plot and update z range
|
||||
void SetLogz(bool enable, bool isMin, bool isMax, double min, double max);
|
||||
void SetZRange(bool isMin, bool isMax, double min, double max);
|
||||
public slots:
|
||||
void UpdateZRange(double min, double max);
|
||||
|
||||
private:
|
||||
void Layout();
|
||||
@ -39,8 +35,4 @@ class SlsQt2DPlotLayout : public QGroupBox {
|
||||
SlsQt2DPlot *the_plot;
|
||||
|
||||
bool isLog;
|
||||
double zmin;
|
||||
double zmax;
|
||||
bool isZmin;
|
||||
bool isZmax;
|
||||
};
|
||||
|
@ -535,36 +535,39 @@ void SlsQt1DPlot::UnknownStuff() {
|
||||
}
|
||||
|
||||
//Added by Dhanya on 19.06.2012 to disable zooming when any of the axes range has been set
|
||||
void SlsQt1DPlot::DisableZoom(bool disableZoom) {
|
||||
void SlsQt1DPlot::DisableZoom(bool disable) {
|
||||
if (disableZoom != disable) {
|
||||
disableZoom = disable;
|
||||
#ifdef VERBOSE
|
||||
if (disableZoom)
|
||||
std::cout << "Disabling zoom\n";
|
||||
else
|
||||
std::cout << "Enabling zoom\n";
|
||||
if (disable)
|
||||
std::cout << "Disabling zoom\n";
|
||||
else
|
||||
std::cout << "Enabling zoom\n";
|
||||
#endif
|
||||
if (disableZoom) {
|
||||
if (zoomer) {
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::NoButton);
|
||||
if (disable) {
|
||||
if (zoomer) {
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::NoButton);
|
||||
#if QT_VERSION < 0x040000
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::NoButton, Qt::ControlButton);
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::NoButton, Qt::ControlButton);
|
||||
#else
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::NoButton, Qt::ControlModifier);
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::NoButton, Qt::ControlModifier);
|
||||
#endif
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::NoButton);
|
||||
}
|
||||
if (panner)
|
||||
panner->setMouseButton(Qt::NoButton);
|
||||
} else {
|
||||
if (zoomer) {
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton);
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::NoButton);
|
||||
}
|
||||
if (panner)
|
||||
panner->setMouseButton(Qt::NoButton);
|
||||
} else {
|
||||
if (zoomer) {
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton);
|
||||
#if QT_VERSION < 0x040000
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlButton);
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlButton);
|
||||
#else
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier);
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier);
|
||||
#endif
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton);
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton);
|
||||
}
|
||||
if (panner)
|
||||
panner->setMouseButton(Qt::MidButton);
|
||||
}
|
||||
if (panner)
|
||||
panner->setMouseButton(Qt::MidButton);
|
||||
}
|
||||
}
|
||||
|
@ -304,37 +304,41 @@ void SlsQt2DPlot::LogZ(bool on) {
|
||||
}
|
||||
|
||||
//Added by Dhanya on 19.06.2012 to disable zooming when any of the axes range has been set
|
||||
void SlsQt2DPlot::DisableZoom(bool disableZoom) {
|
||||
void SlsQt2DPlot::DisableZoom(bool disable) {
|
||||
if (disableZoom != disable) {
|
||||
disableZoom = disable;
|
||||
|
||||
#ifdef VERBOSE
|
||||
if (disableZoom)
|
||||
std::cout << "Disabling zoom\n";
|
||||
else
|
||||
std::cout << "Enabling zoom\n";
|
||||
if (disable)
|
||||
std::cout << "Disabling zoom\n";
|
||||
else
|
||||
std::cout << "Enabling zoom\n";
|
||||
#endif
|
||||
if (disableZoom) {
|
||||
if (zoomer) {
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::NoButton);
|
||||
if (disable) {
|
||||
if (zoomer) {
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::NoButton);
|
||||
#if QT_VERSION < 0x040000
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::NoButton, Qt::ControlButton);
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::NoButton, Qt::ControlButton);
|
||||
#else
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::NoButton, Qt::ControlModifier);
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::NoButton, Qt::ControlModifier);
|
||||
#endif
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::NoButton);
|
||||
}
|
||||
if (panner)
|
||||
panner->setMouseButton(Qt::NoButton);
|
||||
} else {
|
||||
if (zoomer) {
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton);
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::NoButton);
|
||||
}
|
||||
if (panner)
|
||||
panner->setMouseButton(Qt::NoButton);
|
||||
} else {
|
||||
if (zoomer) {
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton);
|
||||
#if QT_VERSION < 0x040000
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlButton);
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlButton);
|
||||
#else
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier);
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier);
|
||||
#endif
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton);
|
||||
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton);
|
||||
}
|
||||
if (panner)
|
||||
panner->setMouseButton(Qt::MidButton);
|
||||
}
|
||||
if (panner)
|
||||
panner->setMouseButton(Qt::MidButton);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,10 +13,6 @@ SlsQt2DPlotLayout::SlsQt2DPlotLayout(QWidget *parent):QGroupBox(parent){
|
||||
the_layout=0;
|
||||
the_plot = new SlsQt2DPlot(this);
|
||||
isLog = false;
|
||||
zmin = 0;
|
||||
zmax = 0;
|
||||
isZmin = false;
|
||||
isZmax = false;
|
||||
Layout();
|
||||
}
|
||||
|
||||
@ -55,10 +51,10 @@ void SlsQt2DPlotLayout::SetContour(bool enable) {
|
||||
the_plot->showContour(enable);
|
||||
}
|
||||
|
||||
void SlsQt2DPlotLayout::SetLogz(bool enable) {
|
||||
void SlsQt2DPlotLayout::SetLogz(bool enable, bool isMin, bool isMax, double min, double max) {
|
||||
isLog = enable;
|
||||
the_plot->LogZ(enable);
|
||||
SetZRange(isZmin, isZmax, zmin, zmax);
|
||||
SetZRange(isMin, isMax, min, max);
|
||||
}
|
||||
|
||||
void SlsQt2DPlotLayout::Layout(){
|
||||
@ -67,34 +63,19 @@ void SlsQt2DPlotLayout::Layout(){
|
||||
the_layout->addWidget(the_plot,2,0,3,3);
|
||||
}
|
||||
|
||||
void SlsQt2DPlotLayout::KeepZRangeIfSet() {
|
||||
UpdateZRange(zmin, zmax);
|
||||
}
|
||||
|
||||
void SlsQt2DPlotLayout::SetZRange(bool isMin, bool isMax, double min, double max){
|
||||
isZmin = isMin;
|
||||
isZmax = isMax;
|
||||
// reset zmin and zmax first (recalculate from plot)
|
||||
the_plot->SetZMinMax();
|
||||
|
||||
UpdateZRange(min, max);
|
||||
}
|
||||
|
||||
void SlsQt2DPlotLayout::UpdateZRange(double min, double max) {
|
||||
if(isLog) {
|
||||
the_plot->SetZMinimumToFirstGreaterThanZero();
|
||||
}
|
||||
|
||||
// set zmin and zmax
|
||||
if (isZmin || isZmax) {
|
||||
zmin = (isZmin ? min : the_plot->GetZMinimum());
|
||||
zmax = (isZmax ? max : the_plot->GetZMaximum());
|
||||
// if it is the same values, we should reset it to plots min and max (not doing this now: not foolproof now)
|
||||
// setting the range of values possible in the dispZMin and dispZMax (not doin this now: not foolproof)
|
||||
if (isMin || isMax) {
|
||||
double zmin = (isMin ? min : the_plot->GetZMinimum());
|
||||
double zmax = (isMax ? max : the_plot->GetZMaximum());
|
||||
the_plot->SetZMinMax(zmin, zmax);
|
||||
} else {
|
||||
zmin = 0;
|
||||
zmax = -1;
|
||||
}
|
||||
|
||||
the_plot->Update();
|
||||
|
||||
}
|
||||
|
||||
|
@ -142,23 +142,13 @@ void qCloneWidget::SetCloneHists(unsigned int nHists, int histNBins, double *his
|
||||
}
|
||||
}
|
||||
|
||||
void qCloneWidget::SetCloneHists2D(int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, double *d, QString frameIndexTitle) {
|
||||
void qCloneWidget::SetCloneHists2D(int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, double *d, QString frameIndexTitle, bool isZmax, bool isZmin, double zmin, double zmax) {
|
||||
cloneplot2D->GetPlot()->SetData(nbinsx, xmin, xmax, nbinsy, ymin, ymax, d);
|
||||
cloneplot2D->KeepZRangeIfSet();
|
||||
cloneplot2D->setTitle(frameIndexTitle.toAscii().constData());
|
||||
cloneplot2D->SetZRange(isZmin, isZmax, zmin, zmax);
|
||||
}
|
||||
|
||||
void qCloneWidget::SetRange(bool IsXYRange[], double XYRange[]) {
|
||||
if (cloneplot1D) {
|
||||
cloneplot1D->SetXMinMax(XYRange[qDefs::XMIN], XYRange[qDefs::XMAX]);
|
||||
cloneplot1D->SetYMinMax(XYRange[qDefs::YMIN], XYRange[qDefs::YMAX]);
|
||||
cloneplot1D->Update();
|
||||
} else {
|
||||
cloneplot2D->GetPlot()->SetXMinMax(XYRange[qDefs::XMIN], XYRange[qDefs::XMAX]);
|
||||
cloneplot2D->GetPlot()->SetYMinMax(XYRange[qDefs::YMIN], XYRange[qDefs::YMAX]);
|
||||
cloneplot2D->GetPlot()->Update();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void qCloneWidget::SavePlot() {
|
||||
char cID[10];
|
||||
|
@ -206,7 +206,7 @@ void qDrawPlot::SetupPlots() {
|
||||
DetachHists();
|
||||
SlsQtH1D *h = new SlsQtH1D("", nPixelsX, datax1d, datay1d[0]);
|
||||
h->SetLineColor(0);
|
||||
SetStyle(h);
|
||||
SetStyleandSymbol(h);
|
||||
hists1d.append(h);
|
||||
|
||||
// setup 2d plot
|
||||
@ -278,8 +278,7 @@ int64_t qDrawPlot::GetCurrentFrameIndex() {
|
||||
}
|
||||
|
||||
void qDrawPlot::Select1dPlot(bool enable) {
|
||||
LockLastImageArray();
|
||||
if (enable) {
|
||||
if (enable) {
|
||||
// DetachHists(); it clears the last measurement
|
||||
plot1d->SetXTitle(xTitle1d.toAscii().constData());
|
||||
plot1d->SetYTitle(yTitle1d.toAscii().constData());
|
||||
@ -301,74 +300,50 @@ void qDrawPlot::Select1dPlot(bool enable) {
|
||||
layout->removeWidget(lblFrameIndexTitle1d);
|
||||
plotLayout->setContentsMargins(0, 0, 0, 0);
|
||||
}
|
||||
UnlockLastImageArray();
|
||||
}
|
||||
|
||||
void qDrawPlot::SetPlotTitlePrefix(QString title) {
|
||||
LockLastImageArray();
|
||||
FILE_LOG(logINFO) << "Setting Title to " << title.toAscii().constData();
|
||||
plotTitlePrefix = title;
|
||||
UnlockLastImageArray();
|
||||
}
|
||||
|
||||
void qDrawPlot::SetXAxisTitle(QString title) {
|
||||
LockLastImageArray();
|
||||
FILE_LOG(logINFO) << "Setting X Axis Title to " << title.toAscii().constData();
|
||||
if (is1d) {
|
||||
xTitle1d = title;
|
||||
} else {
|
||||
xTitle2d = title;
|
||||
}
|
||||
UnlockLastImageArray();
|
||||
}
|
||||
|
||||
void qDrawPlot::SetYAxisTitle(QString title) {
|
||||
LockLastImageArray();
|
||||
FILE_LOG(logINFO) << "Setting Y Axis Title to " << title.toAscii().constData();
|
||||
if (is1d) {
|
||||
yTitle1d = title;
|
||||
} else {
|
||||
yTitle2d = title;
|
||||
}
|
||||
UnlockLastImageArray();
|
||||
}
|
||||
|
||||
void qDrawPlot::SetZAxisTitle(QString title) {
|
||||
LockLastImageArray();
|
||||
FILE_LOG(logINFO) << "Setting Z Axis Title to " << title.toAscii().constData();
|
||||
zTitle2d = title;
|
||||
UnlockLastImageArray();
|
||||
}
|
||||
|
||||
void qDrawPlot::DisableZoom(bool disable) {
|
||||
LockLastImageArray();
|
||||
FILE_LOG(logINFO) << "Setting Disable zoom to " << std::boolalpha << disable << std::noboolalpha;
|
||||
if (is1d)
|
||||
plot1d->DisableZoom(disable);
|
||||
else
|
||||
plot2d->GetPlot()->DisableZoom(disable);
|
||||
UnlockLastImageArray();
|
||||
}
|
||||
|
||||
void qDrawPlot::SetXYRangeChanged() {
|
||||
LockLastImageArray();
|
||||
void qDrawPlot::SetXYRangeChanged(bool disable, double* xy, bool* isXY) {
|
||||
std::lock_guard<std::mutex> lock(mPlots);
|
||||
FILE_LOG(logINFO) << "XY Range has changed";
|
||||
XYRangeChanged = true;
|
||||
UnlockLastImageArray();
|
||||
xyRangeChanged = true;
|
||||
std::copy(xy, xy + 4, xyRange);
|
||||
std::copy(isXY, isXY + 4, isXYRange);
|
||||
|
||||
FILE_LOG(logDEBUG) << "Setting Disable zoom to " << std::boolalpha << disable << std::noboolalpha;
|
||||
disableZoom = disable;
|
||||
}
|
||||
|
||||
void qDrawPlot::SetXYRangeValues(double val, qDefs::range xy) {
|
||||
LockLastImageArray();
|
||||
FILE_LOG(logDEBUG) << "Setting " << qDefs::getRangeAsString(xy) << " to " << val;
|
||||
XYRange[xy] = val;
|
||||
UnlockLastImageArray();
|
||||
}
|
||||
|
||||
void qDrawPlot::IsXYRangeValues(bool changed, qDefs::range xy) {
|
||||
LockLastImageArray();
|
||||
FILE_LOG(logDEBUG) << "Setting " << qDefs::getRangeAsString(xy) << " to " << std::boolalpha << changed << std::noboolalpha;;
|
||||
isXYRange[xy] = changed;
|
||||
UnlockLastImageArray();
|
||||
void qDrawPlot::SetZRange(double* z, bool* isZ) {
|
||||
std::copy(z, z + 2, zRange);
|
||||
std::copy(isZ, isZ + 2, isZRange);
|
||||
}
|
||||
|
||||
double qDrawPlot::GetXMinimum() {
|
||||
@ -399,17 +374,7 @@ double qDrawPlot::GetYMaximum() {
|
||||
return plot2d->GetPlot()->GetYMaximum();
|
||||
}
|
||||
|
||||
void qDrawPlot::SetZRange(bool isZmin, bool isZmax, double zmin, double zmax) {
|
||||
LockLastImageArray();
|
||||
FILE_LOG(logINFO) << std::boolalpha << "Setting Z Range to "
|
||||
"Zmin (" << isZmin << ", " << zmin << ") "
|
||||
"Zmax (" << isZmax << ", " << zmax << ")";
|
||||
plot2d->SetZRange(isZmin, isZmax, zmin, zmax);
|
||||
UnlockLastImageArray();
|
||||
}
|
||||
|
||||
void qDrawPlot::SetDataCallBack(bool enable) {
|
||||
LockLastImageArray();
|
||||
FILE_LOG(logINFO) << "Setting data call back to " << std::boolalpha << enable << std::noboolalpha;
|
||||
if (enable) {
|
||||
isPlot = true;
|
||||
@ -418,138 +383,99 @@ void qDrawPlot::SetDataCallBack(bool enable) {
|
||||
isPlot = false;
|
||||
myDet->registerDataCallback(nullptr, this);
|
||||
}
|
||||
UnlockLastImageArray();
|
||||
|
||||
}
|
||||
|
||||
void qDrawPlot::SetBinary(bool enable, int from, int to) {
|
||||
LockLastImageArray();
|
||||
FILE_LOG(logINFO) << (enable ? "Enabling" : "Disabling") << " Binary output from " << from << " to " << to;
|
||||
isBinary = enable;
|
||||
binaryFrom = from;
|
||||
binaryTo = to;
|
||||
UnlockLastImageArray();
|
||||
isBinary = enable;
|
||||
}
|
||||
|
||||
void qDrawPlot::SetPersistency(int val) {
|
||||
LockLastImageArray();
|
||||
FILE_LOG(logINFO) << "Setting Persistency to " << val;
|
||||
persistency = val;
|
||||
for(int i = datay1d.size(); i <= val; ++i) {
|
||||
datay1d[i] = new double [nPixelsX];
|
||||
SlsQtH1D* h = new SlsQtH1D("", nPixelsX, datax1d, datay1d[i]);
|
||||
h->SetLineColor(i);
|
||||
hists1d.append(h);
|
||||
}
|
||||
UnlockLastImageArray();
|
||||
}
|
||||
|
||||
void qDrawPlot::SetLines(bool enable) {
|
||||
LockLastImageArray();
|
||||
std::lock_guard<std::mutex> lock(mPlots);
|
||||
FILE_LOG(logINFO) << "Setting Lines to " << std::boolalpha << enable << std::noboolalpha;
|
||||
isLines = enable;
|
||||
UnlockLastImageArray();
|
||||
for (unsigned int i = 0; i < nHists; ++i) {
|
||||
SlsQtH1D* h = hists1d.at(i);
|
||||
SetStyleandSymbol(h);
|
||||
}
|
||||
}
|
||||
|
||||
void qDrawPlot::SetMarkers(bool enable) {
|
||||
LockLastImageArray();
|
||||
std::lock_guard<std::mutex> lock(mPlots);
|
||||
FILE_LOG(logINFO) << "Setting Markers to " << std::boolalpha << enable << std::noboolalpha;
|
||||
isMarkers = enable;
|
||||
UnlockLastImageArray();
|
||||
for (unsigned int i = 0; i < nHists; ++i) {
|
||||
SlsQtH1D* h = hists1d.at(i);
|
||||
SetStyleandSymbol(h);
|
||||
}
|
||||
}
|
||||
|
||||
void qDrawPlot::Set1dLogY(bool enable) {
|
||||
LockLastImageArray();
|
||||
std::lock_guard<std::mutex> lock(mPlots);
|
||||
FILE_LOG(logINFO) << "Setting Log Y to " << std::boolalpha << enable << std::noboolalpha;
|
||||
plot1d->SetLogY(enable);
|
||||
UnlockLastImageArray();
|
||||
}
|
||||
|
||||
void qDrawPlot::SetInterpolate(bool enable) {
|
||||
LockLastImageArray();
|
||||
std::lock_guard<std::mutex> lock(mPlots);
|
||||
FILE_LOG(logINFO) << "Setting Interpolate to " << std::boolalpha << enable << std::noboolalpha;
|
||||
plot2d->SetInterpolate(enable);
|
||||
UnlockLastImageArray();
|
||||
}
|
||||
|
||||
void qDrawPlot::SetContour(bool enable) {
|
||||
LockLastImageArray();
|
||||
std::lock_guard<std::mutex> lock(mPlots);
|
||||
FILE_LOG(logINFO) << "Setting Countour to " << std::boolalpha << enable << std::noboolalpha;
|
||||
plot2d->SetContour(enable);
|
||||
UnlockLastImageArray();
|
||||
}
|
||||
|
||||
void qDrawPlot::SetLogz(bool enable) {
|
||||
LockLastImageArray();
|
||||
std::lock_guard<std::mutex> lock(mPlots);
|
||||
FILE_LOG(logINFO) << "Setting Log Z to " << std::boolalpha << enable << std::noboolalpha;
|
||||
plot2d->SetLogz(enable);
|
||||
UnlockLastImageArray();
|
||||
plot2d->SetLogz(enable, isZRange[0], isZRange[1], zRange[0], zRange[1]);
|
||||
}
|
||||
|
||||
void qDrawPlot::SetPedestal(bool enable) {
|
||||
LockLastImageArray();
|
||||
std::lock_guard<std::mutex> lock(mPlots);
|
||||
FILE_LOG(logINFO) << (enable ? "Enabling" : "Disabling") << " Pedestal";
|
||||
if (enable) {
|
||||
isPedestal = true;
|
||||
if (pedestalVals == nullptr)
|
||||
RecalculatePedestal();
|
||||
} else {
|
||||
isPedestal = false;
|
||||
}
|
||||
UnlockLastImageArray();
|
||||
isPedestal = enable;
|
||||
resetPedestal = true;
|
||||
}
|
||||
|
||||
void qDrawPlot::RecalculatePedestal() {
|
||||
LockLastImageArray();
|
||||
std::lock_guard<std::mutex> lock(mPlots);
|
||||
FILE_LOG(logDEBUG) << "Recalculating Pedestal";
|
||||
|
||||
resetPedestal = true;
|
||||
pedestalCount = 0;
|
||||
|
||||
if (pedestalVals != nullptr)
|
||||
delete [] pedestalVals;
|
||||
int nPixels = nPixelsX * nPixelsY;
|
||||
pedestalVals = new double[nPixels];
|
||||
std::fill(pedestalVals, pedestalVals + nPixels, 0);
|
||||
|
||||
if (tempPedestalVals != nullptr)
|
||||
delete [] tempPedestalVals;
|
||||
tempPedestalVals = new double[nPixels];
|
||||
std::fill(tempPedestalVals, tempPedestalVals + nPixels, 0);
|
||||
UnlockLastImageArray();
|
||||
}
|
||||
|
||||
void qDrawPlot::SetAccumulate(bool enable) {
|
||||
LockLastImageArray();
|
||||
std::lock_guard<std::mutex> lock(mPlots);
|
||||
FILE_LOG(logINFO) << (enable ? "Enabling" : "Disabling") << " Accumulation";
|
||||
isAccumulate = enable;
|
||||
UnlockLastImageArray();
|
||||
resetAccumulate = true;
|
||||
}
|
||||
|
||||
void qDrawPlot::ResetAccumulate() {
|
||||
LockLastImageArray();
|
||||
std::lock_guard<std::mutex> lock(mPlots);
|
||||
FILE_LOG(logDEBUG) << "Resetting Accumulation";
|
||||
resetAccumulate = true;
|
||||
UnlockLastImageArray();
|
||||
}
|
||||
|
||||
void qDrawPlot::DisplayStatistics(bool enable) {
|
||||
LockLastImageArray();
|
||||
FILE_LOG(logINFO) << (enable ? "Enabling" : "Disabling") << " Statistics Display";
|
||||
if (!enable)
|
||||
widgetStatistics->hide();
|
||||
// shown when calculated
|
||||
displayStatistics = enable;
|
||||
lblMinDisp->setText("-");
|
||||
lblMaxDisp->setText("-");
|
||||
lblSumDisp->setText("-");
|
||||
UnlockLastImageArray();
|
||||
}
|
||||
|
||||
void qDrawPlot::EnableGainPlot(bool enable) {
|
||||
LockLastImageArray();
|
||||
FILE_LOG(logINFO) << (enable ? "Enabling" : "Disabling") << " Gain Plot";
|
||||
hasGainData = enable;
|
||||
UnlockLastImageArray();
|
||||
}
|
||||
|
||||
void qDrawPlot::SetSaveFileName(QString val) {
|
||||
@ -558,7 +484,8 @@ void qDrawPlot::SetSaveFileName(QString val) {
|
||||
}
|
||||
|
||||
void qDrawPlot::ClonePlot() {
|
||||
LockLastImageArray();
|
||||
std::lock_guard<std::mutex> lock(mPlots);
|
||||
|
||||
int index = 0;
|
||||
if (is1d) {
|
||||
FILE_LOG(logINFO) << "Cloning 1D Image";
|
||||
@ -580,13 +507,9 @@ void qDrawPlot::ClonePlot() {
|
||||
index = cloneWidgets.size();
|
||||
cloneWidgets[index]->SetCloneHists2D(nPixelsX, -0.5, nPixelsX - 0.5,
|
||||
nPixelsY, -0.5, nPixelsY - 0.5,
|
||||
data2d, plot2d->title());
|
||||
data2d, plot2d->title(), isZRange[0], isZRange[1], zRange[0], zRange[1]);
|
||||
}
|
||||
|
||||
if (isXYRange[qDefs::XMIN] || isXYRange[qDefs::XMAX] ||isXYRange[qDefs::YMIN] ||isXYRange[qDefs::YMAX]) {
|
||||
cloneWidgets[index]->SetRange(isXYRange, XYRange);
|
||||
}
|
||||
UnlockLastImageArray();
|
||||
cloneWidgets[index]->show();
|
||||
|
||||
// to remember which all clone widgets were closed
|
||||
@ -651,15 +574,7 @@ void qDrawPlot::SavePlot() {
|
||||
}
|
||||
}
|
||||
|
||||
int qDrawPlot::LockLastImageArray() {
|
||||
return pthread_mutex_lock(&lastImageCompleteMutex);
|
||||
}
|
||||
|
||||
int qDrawPlot::UnlockLastImageArray() {
|
||||
return pthread_mutex_unlock(&lastImageCompleteMutex);
|
||||
}
|
||||
|
||||
void qDrawPlot::SetStyle(SlsQtH1D *h) {
|
||||
void qDrawPlot::SetStyleandSymbol(SlsQtH1D *h) {
|
||||
h->setStyle(isLines ? QwtPlotCurve::Lines : QwtPlotCurve::Dots);
|
||||
#if QWT_VERSION < 0x060000
|
||||
h->setSymbol(isMarkers ? *marker : *noMarker);
|
||||
@ -720,18 +635,13 @@ void qDrawPlot::StartAcquisition() {
|
||||
}
|
||||
|
||||
// refixing all the zooming
|
||||
XYRangeChanged = true;
|
||||
/*
|
||||
plot2d->GetPlot()->SetXMinMax(-0.5, nPixelsX + 0.5);
|
||||
plot2d->GetPlot()->SetYMinMax(-0.5, nPixelsY + 0.5);
|
||||
plot2d->GetPlot()->SetZoom(-0.5, -0.5, nPixelsX, nPixelsY);
|
||||
if (boxPlot->title() == "Sample Plot")
|
||||
plot2d->GetPlot()->UnZoom();
|
||||
else
|
||||
plot2d->GetPlot()->UnZoom(false);
|
||||
*/
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mPlots);
|
||||
pedestalCount = 0;
|
||||
xyRangeChanged = true;
|
||||
}
|
||||
|
||||
// acquisition in another thread
|
||||
// acquisition in another thread
|
||||
QFuture<std::string> future = QtConcurrent::run(this, &qDrawPlot::AcquireThread);
|
||||
acqResultWatcher->setFuture(future);
|
||||
|
||||
@ -792,8 +702,7 @@ void qDrawPlot::AcquisitionFinished(double currentProgress, int detectorStatus)
|
||||
}
|
||||
|
||||
void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex, uint32_t subFrameIndex) {
|
||||
LockLastImageArray();
|
||||
|
||||
std::lock_guard<std::mutex> lock(mPlots);
|
||||
FILE_LOG(logDEBUG)
|
||||
<< "* GetData Callback *" << std::endl
|
||||
<< " frame index: " << frameIndex << std::endl
|
||||
@ -819,8 +728,10 @@ void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex, uint32_t subFra
|
||||
double* rawData = new double[nPixels];
|
||||
if (hasGainData) {
|
||||
toDoublePixelData(rawData, data->data, nPixels, data->databytes, data->dynamicRange, gainData);
|
||||
isGainDataExtracted = true;
|
||||
} else {
|
||||
toDoublePixelData(rawData, data->data, nPixels, data->databytes, data->dynamicRange);
|
||||
isGainDataExtracted = false;
|
||||
}
|
||||
|
||||
// title and frame index titles
|
||||
@ -830,8 +741,21 @@ void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex, uint32_t subFra
|
||||
indexTitle = QString("%1 %2").arg(frameIndex, subFrameIndex);
|
||||
}
|
||||
|
||||
// calculate pedestal
|
||||
// reset pedestal
|
||||
if (resetPedestal) {
|
||||
pedestalCount = 0;
|
||||
if (pedestalVals != nullptr)
|
||||
delete [] pedestalVals;
|
||||
pedestalVals = new double[nPixels];
|
||||
std::fill(pedestalVals, pedestalVals + nPixels, 0);
|
||||
if (tempPedestalVals != nullptr)
|
||||
delete [] tempPedestalVals;
|
||||
tempPedestalVals = new double[nPixels];
|
||||
std::fill(tempPedestalVals, tempPedestalVals + nPixels, 0);
|
||||
resetPedestal = false;
|
||||
}
|
||||
|
||||
if (isPedestal) {
|
||||
// add pedestals frames
|
||||
if (pedestalCount < NUM_PEDESTAL_FRAMES) {
|
||||
for (unsigned int px = 0; px < nPixels; ++px)
|
||||
@ -844,7 +768,6 @@ void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex, uint32_t subFra
|
||||
for (unsigned int px = 0; px < nPixels; ++px)
|
||||
tempPedestalVals[px] = tempPedestalVals[px] / (double)NUM_PEDESTAL_FRAMES;
|
||||
memcpy(pedestalVals, tempPedestalVals, nPixels * sizeof(double));
|
||||
resetPedestal = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -855,11 +778,11 @@ void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex, uint32_t subFra
|
||||
}
|
||||
|
||||
FILE_LOG(logDEBUG) << "End of Get Data";
|
||||
UnlockLastImageArray();
|
||||
emit UpdateSignal();
|
||||
}
|
||||
|
||||
void qDrawPlot::Get1dData(double* rawData) {
|
||||
|
||||
// persistency
|
||||
if (currentPersistency < persistency)
|
||||
currentPersistency++;
|
||||
@ -867,6 +790,14 @@ void qDrawPlot::Get1dData(double* rawData) {
|
||||
currentPersistency = persistency; // when reducing persistency
|
||||
nHists = currentPersistency + 1;
|
||||
if (currentPersistency) {
|
||||
// allocate
|
||||
for(int i = datay1d.size(); i <= persistency; ++i) {
|
||||
datay1d[i] = new double [nPixelsX];
|
||||
SlsQtH1D* h = new SlsQtH1D("", nPixelsX, datax1d, datay1d[i]);
|
||||
h->SetLineColor(i);
|
||||
SetStyleandSymbol(h);
|
||||
hists1d.append(h);
|
||||
}
|
||||
// copy previous data
|
||||
for (int i = currentPersistency; i > 0; --i)
|
||||
memcpy(datay1d[i], datay1d[i - 1], nPixelsX * sizeof(double));
|
||||
@ -879,17 +810,20 @@ void qDrawPlot::Get1dData(double* rawData) {
|
||||
}
|
||||
// accumulate
|
||||
if (resetAccumulate) {
|
||||
std::fill(datay1d[0], datay1d[0] + nPixelsX, 0);
|
||||
resetAccumulate = false;
|
||||
}
|
||||
else if (isAccumulate) {
|
||||
if (isAccumulate) {
|
||||
for (unsigned int px = 0; px < nPixelsX; ++px) {
|
||||
rawData[px] += datay1d[0][px];
|
||||
}
|
||||
}
|
||||
// binary
|
||||
if (isBinary) {
|
||||
int lBinaryFrom = binaryFrom;
|
||||
int lBinaryTo = binaryTo;
|
||||
for (unsigned int px = 0; px < nPixelsX; ++px) {
|
||||
if ((rawData[px] >= binaryFrom) && (rawData[px] <= binaryTo))
|
||||
if ((rawData[px] >= lBinaryFrom) && (rawData[px] <= lBinaryTo))
|
||||
rawData[px] = 1;
|
||||
else
|
||||
rawData[px] = 0;
|
||||
@ -908,17 +842,20 @@ void qDrawPlot::Get2dData(double* rawData) {
|
||||
}
|
||||
// accumulate
|
||||
if (resetAccumulate) {
|
||||
std::fill(data2d, data2d + nPixels, 0);
|
||||
resetAccumulate = false;
|
||||
}
|
||||
else if (isAccumulate) {
|
||||
if (isAccumulate) {
|
||||
for (unsigned int px = 0; px < nPixels; ++px) {
|
||||
rawData[px] += data2d[px];
|
||||
}
|
||||
}
|
||||
// binary
|
||||
if (isBinary) {
|
||||
int lBinaryFrom = binaryFrom;
|
||||
int lBinaryTo = binaryTo;
|
||||
for (unsigned int px = 0; px < nPixels; ++px) {
|
||||
if ((rawData[px] >= binaryFrom) && (rawData[px] <= binaryTo))
|
||||
if ((rawData[px] >= lBinaryFrom) && (rawData[px] <= lBinaryTo))
|
||||
rawData[px] = 1;
|
||||
else
|
||||
rawData[px] = 0;
|
||||
@ -928,17 +865,19 @@ void qDrawPlot::Get2dData(double* rawData) {
|
||||
}
|
||||
|
||||
void qDrawPlot::Update1dPlot() {
|
||||
// Plot data
|
||||
DetachHists();
|
||||
plot1d->SetXTitle(xTitle1d.toAscii().constData());
|
||||
plot1d->SetYTitle(yTitle1d.toAscii().constData());
|
||||
for (unsigned int i = 0; i < nHists; ++i) {
|
||||
SlsQtH1D* h = hists1d.at(i);
|
||||
h->SetData(nPixelsX, datax1d, datay1d[i]);
|
||||
SetStyle(h);
|
||||
h->Attach(plot1d);
|
||||
}
|
||||
Update1dXYRange();
|
||||
if (xyRangeChanged) {
|
||||
Update1dXYRange();
|
||||
xyRangeChanged = false;
|
||||
}
|
||||
plot1d->DisableZoom(disableZoom);
|
||||
}
|
||||
|
||||
void qDrawPlot::Update2dPlot() {
|
||||
@ -947,8 +886,7 @@ void qDrawPlot::Update2dPlot() {
|
||||
plot2d->SetZTitle(zTitle2d);
|
||||
plot2d->GetPlot()->SetData(nPixelsX, -0.5, nPixelsX - 0.5,
|
||||
nPixelsY, -0.5, nPixelsY - 0.5, data2d);
|
||||
plot2d->KeepZRangeIfSet();
|
||||
if (hasGainData) {
|
||||
if (isGainDataExtracted) {
|
||||
gainplot2d->GetPlot()->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY,
|
||||
-0.5, nPixelsY - 0.5, gainData);
|
||||
gainplot2d->setFixedWidth(plot2d->width() / 4);
|
||||
@ -957,59 +895,50 @@ void qDrawPlot::Update2dPlot() {
|
||||
} else {
|
||||
gainplot2d->hide();
|
||||
}
|
||||
Update2dXYRange();
|
||||
if (xyRangeChanged) {
|
||||
Update2dXYRange();
|
||||
xyRangeChanged = false;
|
||||
}
|
||||
plot2d->GetPlot()->DisableZoom(disableZoom);
|
||||
plot2d->SetZRange(isZRange[0], isZRange[1], zRange[0], zRange[1]);
|
||||
}
|
||||
|
||||
void qDrawPlot::Update1dXYRange() {
|
||||
if (XYRangeChanged) {
|
||||
if (!isXYRange[qDefs::XMIN] && !isXYRange[qDefs::XMAX]) {
|
||||
plot1d->EnableXAutoScaling();
|
||||
} else {
|
||||
if (!isXYRange[qDefs::XMIN])
|
||||
XYRange[qDefs::XMIN] = plot1d->GetXMinimum();
|
||||
if (!isXYRange[qDefs::XMAX])
|
||||
XYRange[qDefs::XMAX] = plot1d->GetXMaximum();
|
||||
plot1d->SetXMinMax(XYRange[qDefs::XMIN], XYRange[qDefs::XMAX]);
|
||||
}
|
||||
|
||||
if (!isXYRange[qDefs::YMIN] && !isXYRange[qDefs::YMAX]) {
|
||||
plot1d->EnableYAutoScaling();
|
||||
} else {
|
||||
if (!isXYRange[qDefs::YMIN])
|
||||
XYRange[qDefs::YMIN] = plot1d->GetYMinimum();
|
||||
if (!isXYRange[qDefs::YMAX])
|
||||
XYRange[qDefs::YMAX] = plot1d->GetYMaximum();
|
||||
plot1d->SetYMinMax(XYRange[qDefs::YMIN], XYRange[qDefs::YMAX]);
|
||||
}
|
||||
XYRangeChanged = false;
|
||||
plot1d->Update();
|
||||
if (!isXYRange[qDefs::XMIN] && !isXYRange[qDefs::XMAX]) {
|
||||
plot1d->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);
|
||||
}
|
||||
|
||||
if (!isXYRange[qDefs::YMIN] && !isXYRange[qDefs::YMAX]) {
|
||||
plot1d->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);
|
||||
}
|
||||
plot1d->Update();
|
||||
}
|
||||
|
||||
void qDrawPlot::Update2dXYRange() {
|
||||
if (XYRangeChanged) {
|
||||
if (!isXYRange[qDefs::XMIN] && !isXYRange[qDefs::XMAX]) {
|
||||
plot2d->GetPlot()->EnableXAutoScaling();
|
||||
} else {
|
||||
if (!isXYRange[qDefs::XMIN])
|
||||
XYRange[qDefs::XMIN] = plot2d->GetPlot()->GetXMinimum();
|
||||
if (!isXYRange[qDefs::XMAX])
|
||||
XYRange[qDefs::XMAX] = plot2d->GetPlot()->GetXMaximum();
|
||||
plot2d->GetPlot()->SetXMinMax(XYRange[qDefs::XMIN], XYRange[qDefs::XMAX]);
|
||||
}
|
||||
|
||||
if (!isXYRange[qDefs::YMIN] && !isXYRange[qDefs::YMAX]) {
|
||||
plot2d->GetPlot()->EnableYAutoScaling();
|
||||
} else {
|
||||
if (!isXYRange[qDefs::YMIN])
|
||||
XYRange[qDefs::YMIN] = plot2d->GetPlot()->GetYMinimum();
|
||||
if (!isXYRange[qDefs::YMAX])
|
||||
XYRange[qDefs::YMAX] = plot2d->GetPlot()->GetYMaximum();
|
||||
plot2d->GetPlot()->SetYMinMax(XYRange[qDefs::YMIN], XYRange[qDefs::YMAX]);
|
||||
}
|
||||
XYRangeChanged = false;
|
||||
plot2d->GetPlot()->Update();
|
||||
if (!isXYRange[qDefs::XMIN] && !isXYRange[qDefs::XMAX]) {
|
||||
plot2d->GetPlot()->EnableXAutoScaling();
|
||||
} else {
|
||||
double xmin = (isXYRange[qDefs::XMIN] ? xyRange[qDefs::XMIN] : plot2d->GetPlot()->GetXMinimum());
|
||||
double xmax = (isXYRange[qDefs::XMAX] ? xyRange[qDefs::XMAX] : plot2d->GetPlot()->GetXMaximum());
|
||||
plot2d->GetPlot()->SetXMinMax(xmin, xmax);
|
||||
}
|
||||
|
||||
if (!isXYRange[qDefs::YMIN] && !isXYRange[qDefs::YMAX]) {
|
||||
plot2d->GetPlot()->EnableYAutoScaling();
|
||||
} else {
|
||||
double ymin = (isXYRange[qDefs::YMIN] ? xyRange[qDefs::YMIN] : plot2d->GetPlot()->GetYMinimum());
|
||||
double ymax = (isXYRange[qDefs::YMAX] ? xyRange[qDefs::YMAX] : plot2d->GetPlot()->GetYMaximum());
|
||||
plot2d->GetPlot()->SetYMinMax(ymin, ymax);
|
||||
}
|
||||
plot2d->GetPlot()->Update();
|
||||
}
|
||||
|
||||
void qDrawPlot::toDoublePixelData(double *dest, char *source, int size, int databytes, int dr, double *gaindest) {
|
||||
@ -1084,7 +1013,7 @@ void qDrawPlot::toDoublePixelData(double *dest, char *source, int size, int data
|
||||
|
||||
|
||||
void qDrawPlot::UpdatePlot() {
|
||||
LockLastImageArray();
|
||||
std::lock_guard<std::mutex> lock(mPlots);
|
||||
FILE_LOG(logDEBUG) << "Update Plot";
|
||||
|
||||
boxPlot->setTitle(plotTitle);
|
||||
@ -1093,7 +1022,7 @@ void qDrawPlot::UpdatePlot() {
|
||||
Update1dPlot();
|
||||
} else {
|
||||
plot2d->setTitle(indexTitle.toAscii().constData());
|
||||
if (hasGainData)
|
||||
if (isGainDataExtracted)
|
||||
gainplot2d->setTitle(indexTitle.toAscii().constData());
|
||||
Update2dPlot();
|
||||
}
|
||||
@ -1104,8 +1033,10 @@ void qDrawPlot::UpdatePlot() {
|
||||
lblMinDisp->setText(QString("%1").arg(min));
|
||||
lblMaxDisp->setText(QString("%1").arg(max));
|
||||
lblSumDisp->setText(QString("%1").arg(sum));
|
||||
widgetStatistics->show();
|
||||
} else {
|
||||
widgetStatistics->hide();
|
||||
}
|
||||
|
||||
FILE_LOG(logDEBUG) << "End of Update Plot";
|
||||
UnlockLastImageArray();
|
||||
}
|
||||
|
@ -383,78 +383,24 @@ void qTabPlot::CheckAspectRatio() {
|
||||
|
||||
void qTabPlot::SetXYRange() {
|
||||
FILE_LOG(logDEBUG) << "Set XY Range";
|
||||
disconnect(dispXMin, SIGNAL(editingFinished()), this, SLOT(SetXRange()));
|
||||
disconnect(dispXMax, SIGNAL(editingFinished()), this, SLOT(SetXRange()));
|
||||
disconnect(dispYMin, SIGNAL(editingFinished()), this, SLOT(SetYRange()));
|
||||
disconnect(dispYMax, SIGNAL(editingFinished()), this, SLOT(SetYRange()));
|
||||
|
||||
bool disablezoom = false;
|
||||
bool isRange[4]{false, false, false, false};
|
||||
double xyRange[4]{0, 0, 0, 0};
|
||||
|
||||
// xmin
|
||||
// if unchecked, empty or invalid (set to false so it takes the min/max of plot)
|
||||
if (!chkXMin->isChecked() || dispXMin->text().isEmpty()) {
|
||||
myPlot->IsXYRangeValues(false, qDefs::XMIN);
|
||||
} else if (dispXMin->text().toDouble() < myPlot->GetXMinimum()) {
|
||||
qDefs::Message(qDefs::WARNING, "XMin Outside Plot Range", "qTabPlot::SetXRange");
|
||||
FILE_LOG(logWARNING) << "Xmin entered " << dispXMin->text().toDouble() << " outside xmin range " << myPlot->GetXMinimum();
|
||||
dispXMin->setText("");
|
||||
myPlot->IsXYRangeValues(false, qDefs::XMIN);
|
||||
} else {
|
||||
myPlot->SetXYRangeValues(dispXMin->text().toDouble(), qDefs::XMIN);
|
||||
myPlot->IsXYRangeValues(true, qDefs::XMIN);
|
||||
disablezoom = true;
|
||||
QString dispVal[4] {dispXMin->text(), dispXMax->text(), dispYMin->text(), dispYMax->text()};
|
||||
bool chkVal[4] {chkXMin->isChecked(), chkXMax->isChecked(), chkYMin->isChecked(), chkYMax->isChecked()};
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
if (chkVal[i] && !dispVal[i].isEmpty()) {
|
||||
double val = dispVal[i].toDouble();
|
||||
FILE_LOG(logDEBUG) << "Setting " << qDefs::getRangeAsString(static_cast<qDefs::range>(i)) << " to " << val;
|
||||
xyRange[i] = val;
|
||||
isRange[i] = true;
|
||||
disablezoom = true;
|
||||
}
|
||||
}
|
||||
|
||||
//xmax
|
||||
if (!chkXMax->isChecked() || dispXMax->text().isEmpty()) {
|
||||
myPlot->IsXYRangeValues(false, qDefs::XMAX);
|
||||
} else if (dispXMax->text().toDouble() > myPlot->GetXMaximum()) {
|
||||
qDefs::Message(qDefs::WARNING, "XMax Outside Plot Range", "qTabPlot::SetXYRange");
|
||||
FILE_LOG(logWARNING) << "Xmax entered " << dispXMax->text().toDouble() << " outside xmax range " << myPlot->GetXMaximum();
|
||||
dispXMax->setText("");
|
||||
myPlot->IsXYRangeValues(false, qDefs::XMAX);
|
||||
} else {
|
||||
myPlot->SetXYRangeValues(dispXMax->text().toDouble(), qDefs::XMAX);
|
||||
myPlot->IsXYRangeValues(true, qDefs::XMAX);
|
||||
disablezoom = true;
|
||||
}
|
||||
|
||||
// ymin
|
||||
if (!chkYMin->isChecked() || dispYMin->text().isEmpty()) {
|
||||
myPlot->IsXYRangeValues(false, qDefs::YMIN);
|
||||
} else if (dispYMin->text().toDouble() < myPlot->GetYMinimum()) {
|
||||
qDefs::Message(qDefs::WARNING, "YMin Outside Plot Range", "qTabPlot::SetXYRange");
|
||||
FILE_LOG(logWARNING) << "Ymin entered " << dispYMin->text().toDouble() << " outside ymin range " << myPlot->GetYMinimum();
|
||||
dispYMin->setText("");
|
||||
myPlot->IsXYRangeValues(false, qDefs::YMIN);
|
||||
} else {
|
||||
myPlot->SetXYRangeValues(dispYMin->text().toDouble(), qDefs::YMIN);
|
||||
myPlot->IsXYRangeValues(true, qDefs::YMIN);
|
||||
disablezoom = true;
|
||||
}
|
||||
|
||||
//ymax
|
||||
if (!chkYMax->isChecked() || dispYMax->text().isEmpty()) {
|
||||
myPlot->IsXYRangeValues(false, qDefs::YMAX);
|
||||
} else if (dispYMax->text().toDouble() > myPlot->GetYMaximum()) {
|
||||
qDefs::Message(qDefs::WARNING, "YMax Outside Plot Range", "qTabPlot::SetXYRange");
|
||||
FILE_LOG(logWARNING) << "Ymax entered " << dispYMax->text().toDouble() << " outside ymax range " << myPlot->GetYMaximum();
|
||||
dispYMax->setText("");
|
||||
myPlot->IsXYRangeValues(false, qDefs::YMAX);
|
||||
} else {
|
||||
myPlot->SetXYRangeValues(dispYMax->text().toDouble(), qDefs::YMAX);
|
||||
myPlot->IsXYRangeValues(true, qDefs::YMAX);
|
||||
disablezoom = true;
|
||||
}
|
||||
|
||||
connect(dispXMin, SIGNAL(editingFinished()), this, SLOT(SetXRange()));
|
||||
connect(dispXMax, SIGNAL(editingFinished()), this, SLOT(SetXRange()));
|
||||
connect(dispYMin, SIGNAL(editingFinished()), this, SLOT(SetYRange()));
|
||||
connect(dispYMax, SIGNAL(editingFinished()), this, SLOT(SetYRange()));
|
||||
|
||||
// to update plot with range
|
||||
myPlot->SetXYRangeChanged();
|
||||
myPlot->DisableZoom(disablezoom);
|
||||
myPlot->SetXYRangeChanged(disablezoom, xyRange, isRange);
|
||||
emit DisableZoomSignal(disablezoom);
|
||||
}
|
||||
|
||||
@ -514,10 +460,12 @@ void qTabPlot::MaintainAspectRatio(int dimension) {
|
||||
if (dimension == static_cast<int>(slsDetectorDefs::X)) {
|
||||
newval = idealAspectratio * (ranges[qDefs::YMAX] - ranges[qDefs::YMIN]) + ranges[qDefs::XMIN];
|
||||
if (newval <= myPlot->GetXMaximum()) {
|
||||
ranges[qDefs::XMAX] = newval;
|
||||
dispXMax->setText(QString::number(newval));
|
||||
FILE_LOG(logDEBUG) << "New XMax: " << newval;
|
||||
} else {
|
||||
newval = ranges[qDefs::XMAX] - (idealAspectratio * (ranges[qDefs::YMAX] - ranges[qDefs::YMIN]));
|
||||
ranges[qDefs::XMIN] = newval;
|
||||
dispXMin->setText(QString::number(newval));
|
||||
FILE_LOG(logDEBUG) << "New XMin: " << newval;
|
||||
}
|
||||
@ -526,10 +474,12 @@ void qTabPlot::MaintainAspectRatio(int dimension) {
|
||||
else {
|
||||
newval = ((ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) / idealAspectratio) + ranges[qDefs::YMIN];
|
||||
if (newval <= myPlot->GetYMaximum()) {
|
||||
ranges[qDefs::YMAX] = newval;
|
||||
dispYMax->setText(QString::number(newval));
|
||||
FILE_LOG(logDEBUG) << "New YMax: " << newval;
|
||||
} else {
|
||||
newval = ranges[qDefs::YMAX] - ((ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) / idealAspectratio);
|
||||
ranges[qDefs::YMIN] = newval;
|
||||
dispYMin->setText(QString::number(newval));
|
||||
FILE_LOG(logDEBUG) << "New YMax: " << newval;
|
||||
}
|
||||
@ -545,34 +495,26 @@ void qTabPlot::MaintainAspectRatio(int dimension) {
|
||||
connect(dispYMin, SIGNAL(editingFinished()), this, SLOT(SetYRange()));
|
||||
connect(dispYMax, SIGNAL(editingFinished()), this, SLOT(SetYRange()));
|
||||
|
||||
// set XY values in plot
|
||||
myPlot->SetXYRangeValues(dispXMin->text().toDouble(), qDefs::XMIN);
|
||||
myPlot->SetXYRangeValues(dispXMax->text().toDouble(), qDefs::XMAX);
|
||||
myPlot->SetXYRangeValues(dispYMin->text().toDouble(), qDefs::YMIN);
|
||||
myPlot->SetXYRangeValues(dispYMax->text().toDouble(), qDefs::YMAX);
|
||||
|
||||
myPlot->IsXYRangeValues(true, qDefs::XMIN);
|
||||
myPlot->IsXYRangeValues(true, qDefs::XMAX);
|
||||
myPlot->IsXYRangeValues(true, qDefs::YMIN);
|
||||
myPlot->IsXYRangeValues(true, qDefs::YMAX);
|
||||
|
||||
// to update plot with range
|
||||
myPlot->SetXYRangeChanged();
|
||||
myPlot->DisableZoom(true);
|
||||
bool isRange[4] {true, true, true, true};
|
||||
myPlot->SetXYRangeChanged(true, ranges, isRange);
|
||||
emit DisableZoomSignal(true);
|
||||
}
|
||||
|
||||
void qTabPlot::SetZRange() {
|
||||
bool isZmin = chkZMin->isChecked();
|
||||
bool isZmax = chkZMax->isChecked();
|
||||
double zmin = 0, zmax = 1;
|
||||
if (!dispZMin->text().isEmpty()) {
|
||||
zmin = dispZMin->text().toDouble();
|
||||
bool isZRange[2] {chkZMin->isChecked(), chkZMax->isChecked()};
|
||||
double zRange[2] {0 , 0};
|
||||
|
||||
if (isZRange[0] && !dispZMin->text().isEmpty()) {
|
||||
double val = dispZMin->text().toDouble();
|
||||
FILE_LOG(logDEBUG) << "Setting zmin to " << val;
|
||||
zRange[0] = val;
|
||||
}
|
||||
if (!dispZMax->text().isEmpty()) {
|
||||
zmax = dispZMax->text().toDouble();
|
||||
if (isZRange[1] && !dispZMax->text().isEmpty()) {
|
||||
double val = dispZMax->text().toDouble();
|
||||
FILE_LOG(logDEBUG) << "Setting zmax to " << val;
|
||||
zRange[1] = val;
|
||||
}
|
||||
myPlot->SetZRange(isZmin, isZmax, zmin, zmax);
|
||||
myPlot->SetZRange(zRange, isZRange);
|
||||
}
|
||||
|
||||
void qTabPlot::GetStreamingFrequency() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user