This commit is contained in:
maliakal_d 2019-06-21 18:19:39 +02:00
parent f4bc255f2c
commit 33f5253831
14 changed files with 1474 additions and 2054 deletions

View File

@ -1382,8 +1382,8 @@ Displays minimum, maximum and sum of values for each plot.
<widget class="QGroupBox" name="boxSave"> <widget class="QGroupBox" name="boxSave">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>20</x> <x>11</x>
<y>130</y> <y>124</y>
<width>356</width> <width>356</width>
<height>57</height> <height>57</height>
</rect> </rect>
@ -1400,9 +1400,9 @@ Displays minimum, maximum and sum of values for each plot.
<widget class="QWidget" name="horizontalLayoutWidget"> <widget class="QWidget" name="horizontalLayoutWidget">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>18</x>
<y>22</y> <y>22</y>
<width>342</width> <width>72</width>
<height>35</height> <height>35</height>
</rect> </rect>
</property> </property>
@ -1410,22 +1410,6 @@ Displays minimum, maximum and sum of values for each plot.
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<item>
<widget class="QCheckBox" name="chkSaveAll">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Save All with Automatic File Name</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QPushButton" name="btnSave"> <widget class="QPushButton" name="btnSave">
<property name="sizePolicy"> <property name="sizePolicy">
@ -1501,8 +1485,8 @@ Displays minimum, maximum and sum of values for each plot.
<widget class="QGroupBox" name="boxPlotAxis"> <widget class="QGroupBox" name="boxPlotAxis">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>15</x> <x>11</x>
<y>190</y> <y>187</y>
<width>746</width> <width>746</width>
<height>150</height> <height>150</height>
</rect> </rect>
@ -1522,7 +1506,7 @@ Displays minimum, maximum and sum of values for each plot.
<x>10</x> <x>10</x>
<y>20</y> <y>20</y>
<width>726</width> <width>726</width>
<height>126</height> <height>129</height>
</rect> </rect>
</property> </property>
<layout class="QGridLayout" name="gridLayout" columnstretch="0,0,0,0,0,0,0,0"> <layout class="QGridLayout" name="gridLayout" columnstretch="0,0,0,0,0,0,0,0">
@ -2160,8 +2144,8 @@ Streaming Interval between 2 plots. Default is time interval with 200 ms.
</property> </property>
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>400</x> <x>399</x>
<y>130</y> <y>122</y>
<width>355</width> <width>355</width>
<height>60</height> <height>60</height>
</rect> </rect>
@ -2180,7 +2164,7 @@ Streaming Interval between 2 plots. Default is time interval with 200 ms.
<rect> <rect>
<x>10</x> <x>10</x>
<y>23</y> <y>23</y>
<width>342</width> <width>336</width>
<height>37</height> <height>37</height>
</rect> </rect>
</property> </property>
@ -2315,7 +2299,7 @@ Streaming Interval between 2 plots. Default is time interval with 200 ms.
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>10</width> <width>5</width>
<height>20</height> <height>20</height>
</size> </size>
</property> </property>
@ -2331,7 +2315,7 @@ Streaming Interval between 2 plots. Default is time interval with 200 ms.
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>10</width> <width>5</width>
<height>20</height> <height>20</height>
</size> </size>
</property> </property>
@ -2417,7 +2401,6 @@ Streaming Interval between 2 plots. Default is time interval with 200 ms.
<tabstop>chkInterpolate</tabstop> <tabstop>chkInterpolate</tabstop>
<tabstop>chkContour</tabstop> <tabstop>chkContour</tabstop>
<tabstop>chkLogz</tabstop> <tabstop>chkLogz</tabstop>
<tabstop>chkSaveAll</tabstop>
<tabstop>comboFrequency</tabstop> <tabstop>comboFrequency</tabstop>
<tabstop>chkTitle</tabstop> <tabstop>chkTitle</tabstop>
<tabstop>dispTitle</tabstop> <tabstop>dispTitle</tabstop>

View File

@ -35,21 +35,9 @@ class qCloneWidget : public QMainWindow {
* @param lines style of plot if lines or dots * @param lines style of plot if lines or dots
* @param markers style of plot markers or not * @param markers style of plot markers or not
*/ */
void SetCloneHists(int nHists, int histNBins, double *histXAxis, double *histYAxis[], std::string histTitle[], bool lines, bool markers); void SetCloneHists(int nHists, int histNBins, double *histXAxis, std::vector<double*> histYAxis, std::vector<std::string> histTitle, bool lines, bool markers);
/** /**
* Get the 1D hist values to plot for angle plotting
* @param nHists Number of graphs in 1D
* @param histNBins Total Number of X axis values/channels in 1D
* @param histXAxis X Axis value in 1D
* @param histYAxis Y Axis value in 1D
* @param histTitle Title for all the graphs in 1D
* @param lines style of plot if lines or dots
* @param markers style of plot markers or not
*/
void SetCloneHists(int nHists, int histNBins, double *histXAxis, double *histYAxis, std::string histTitle[], bool lines, bool markers);
/**
* Get the 1D hist values to plot for angle plotting * Get the 1D hist values to plot for angle plotting
* @param nbinsx number of bins in x axis * @param nbinsx number of bins in x axis
* @param xmin minimum in x axis * @param xmin minimum in x axis

View File

@ -3,550 +3,224 @@
#include "qDefs.h" #include "qDefs.h"
class detectorData; class detectorData;
class SlsQt1DPlot; class SlsQt1DPlot;
class SlsQtH1D;
class SlsQt2DPlotLayout; class SlsQt2DPlotLayout;
class qCloneWidget; class qCloneWidget;
/*
#include <QWidget> #include "qwt_symbol.h"
#include <QGridLayout> #include <QGridLayout>
#include <QGroupBox> #include <QGroupBox>
#include <QTimer>
#include <QString> #include <QString>
#include "qwt_symbol.h" #include <QTimer>
#include <QWidget>
#include <QVector> #include <QVector>
#include <qwt_series_data.h>
#include <qwt_plot_histogram.h>
#include <qwt_plot_grid.h>
#include <qwt_column_symbol.h>
#include <qpen.h> #include <qpen.h>
#include <qwt_column_symbol.h>
#include <qwt_plot_grid.h>
#include <qwt_plot_histogram.h>
#include <qwt_series_data.h>
#define MAX_1DPLOTS 10 */
class qDrawPlot : public QWidget {
/** Q_OBJECT
*@short Sets up the plot widget
*/ public:
class qDrawPlot:public QWidget{ /** \short The constructor */
Q_OBJECT qDrawPlot(QWidget *parent, multiSlsDetector *detector);
/** Destructor */
~qDrawPlot();
/** If the gui client has started or stopped */
public: void SetClientInitiated();
/** \short The constructor */ bool GetClientInitiated();
qDrawPlot(QWidget *parent, multiSlsDetector* detector); bool isRunning();
/** Destructor */ int GetProgress();
~qDrawPlot(); int GetCurrentFrameIndex();
void SetPlotTitlePrefix(QString title);
void SetXAxisTitle(QString title);
bool isRunning(); void SetYAxisTitle(QString title);
int GetProgress(); void SetZAxisTitle(QString title);
int GetFileIndex(); void DisableZoom(bool disable);
int GetFrameIndex(); void SetXYRange(bool changed);
void SetFileWrite(bool enable); void SetXYRangeValues(double val, qDefs::range xy);
void SetPlotTitlePrefix(QString title); void IsXYRangeValues(bool changed, qDefs::range xy);
void SetXAxisTitle(QString title); double GetXMinimum();
void SetYAxisTitle(QString title); double GetXMaximum();
void SetZAxisTitle(QString title); double GetYMinimum();
void DisableZoom(bool disable); double GetYMaximum();
void EnablePlot(bool enable); void SetDataCallBack(bool enable);
void EnableAnglePlot(bool enable); void SetBinary(bool enable, int from = 0, int to = 0);
/** Starts or stop acquisition
void SetXYRange(bool changed); * Calls startDaq() function
/**Sets the min/max for x/y * @param stop_if_running is 0 to stop acquisition and 1 to start
* @param val is the value to be set * acquisition
* @param xy is xmin,xmax,ymin or ymax */ */
void SetXYRangeValues(double val,qDefs::range xy); void StartStopDaqToggle(bool stop_if_running = 0);
/**Sets if min/max for x/y is enabled
* @param changed is if this has been changed public slots:
* @param xy is xmin,xmax,ymin or ymax */ void StopAcquisition();
void IsXYRangeValues(bool changed,qDefs::range xy); void SetPersistency(int val);
void SetLines(bool enable);
/** Set Plot timer - between plots in ms*/ void SetMarkers(bool enable);
void SetPlotTimer(double time); void SetPedestal(bool enable);
/** Set Plot frame factor - between plots, also for receiver if exists */ void RecalculatePedestal();
void SetFrameFactor(int frame); void SetAccumulate(bool enable);
void ResetAccumulate();
void SetCallBacks(bool enable); void DisplayStatistics(bool enable);
void ClonePlot();
/** Starts or stop acquisition void CloseClones();
* Calls startDaq() function void SaveClones();
* @param stop_if_running is 0 to stop acquisition and 1 to start acquisition void SavePlot();
*/ void Select1DPlot();
void StartStopDaqToggle(bool stop_if_running=0); void Select2DPlot();
/** Set frame enabled
* @param enable enable*/ private slots:
void setFrameEnabled(bool enable); void CloneCloseEvent(int id);
/** Set trigger enabled void EnableGainPlot(bool e);
* @param enable enable */
void setTriggerEnabled(bool enable); void UpdatePlot();
void StartDaq(bool start);
/** Updates the trimbit plot void ShowAcquisitionErrorMessage(QString status);
* @param fromDetector is true if the trimbits should be loaded from detector
* @param Histogram true if histogram, else data graph signals:
* returns ok/fail void UpdatingPlotFinished();
* */ void InterpolateSignal(bool);
int UpdateTrimbitPlot(bool fromDetector,bool Histogram); void ContourSignal(bool);
void LogzSignal(bool);
/** This is set once client initiates start/stop acquisition void LogySignal(bool);
* and this is reset when the gui really starts/stops- to know when to return void ResetZMinZMaxSignal(bool, bool, double, double);
*/ void SetCurrentMeasurementSignal(int);
void SetClientInitiated(); void AcquisitionErrorSignal(QString);
void UpdatePlotSignal();
/** Get client intiated variable. This is set once client initiates start/stop acquisition void GainPlotSignal(bool);
* and this is reset when the gui really starts/stops- to know when to return
*/ private:
bool GetClientInitiated(); void SetupWidgetWindow();
void Initialization();
/** Update all ranges, interpolate etc after cloning void SetupStatistics();
* parameters are if they are checked or not void SetupPlots();
*/ const char *GetTitle1d(int histIndex);
void UpdateAfterCloning(bool points, bool logy, bool interpolate, bool contour, bool logz); double *GetHistYAxis(int histIndex);
void SetStyle(SlsQtH1D *h);
/** set binary range */ void GetStatistics(double &min, double &max, double &sum, double *array, int size);
void SetBinary(bool enable, int from=0, int to=0); void SelectPlot(int i = 2);
void Clear1DPlot();
/** Enable/Disable Histogram */
void SetHistogram(bool enable,int histArg, int min=0, int max=0, double size=0){histogram = enable;histogramArgument = histArg; histFrom=min;histTo=max;histSize=size;};
int LockLastImageArray();
/** Get X Minimum value from plot */ int UnlockLastImageArray();
double GetXMinimum(); int StartDaqForGui();
/** Get X Maximum value from plot */ int StopDaqForGui();
double GetXMaximum(); bool StartOrStopThread(bool start);
/** Get Y Minimum value from plot */ void SetupMeasurement();
double GetYMinimum(); int ResetDaqForGui();
/** Get Y Maximum value from plot */ static void *DataStartAcquireThread(void *this_pointer);
double GetYMaximum(); static int GetDataCallBack(detectorData *data, int fIndex, int subIndex, void *this_pointer);
int GetData(detectorData *data, int fIndex, int subIndex);
public slots: static int GetAcquisitionFinishedCallBack(double currentProgress, int detectorStatus, void *this_pointer);
/** To select 1D or 2D plot int AcquisitionFinished(double currentProgress, int detectorStatus);
@param i is 1 for 1D, else 2D plot */ static int GetMeasurementFinishedCallBack(int currentMeasurementIndex, int fileIndex, void *this_pointer);
void SelectPlot(int i=2); int MeasurementFinished(int currentMeasurementIndex, int fileIndex);
/** To select 1D plot */ static int GetProgressCallBack(double currentProgress, void *this_pointer);
void Select1DPlot(); void toDoublePixelData(double *dest, char *source, int size, int databytes, int dr, double *gaindest = NULL);
/** To select 2D plot */
void Select2DPlot(); static const int NUM_PEDESTAL_FRAMES = 20;
/** To clear plot */ multiSlsDetector *myDet;
void Clear1DPlot(); slsDetectorDefs::detectorType detType;
/** Creates a clone of the plot */
void ClonePlot(); SlsQt1DPlot *plot1d{nullptr};
/** Closes all the clone plots */ QVector<SlsQtH1D *> hists1d;
void CloseClones(); SlsQt2DPlotLayout *plot2d{nullptr};
/** Saves all the clone plots */ SlsQt2DPlotLayout *gainplot2d{nullptr};
void SaveClones();
/** To Save plot */ QGridLayout *layout{nullptr};
void SavePlot(); QGroupBox *boxPlot{nullptr};
/** Save all plots **/ QGridLayout *plotLayout{nullptr};
void SaveAll(bool enable);
/** Sets persistency from plot tab */ bool is1d{true};
void SetPersistency(int val); bool plotEnable{true};
/** sets style of plot to lines*/ bool plotRequired{false};/**?? */
void SetLines(bool enable); bool running{false};
/** sets markers */ int progress{0};
void SetMarkers(bool enable); volatile bool stopSignal{false};
/** sets the scan argument to prepare the plot*/ bool clientInitiated{false};
// void SetScanArgument(int scanArg);
/** sets stop_signal to true */ // titles
void StopAcquisition(); QString plotTitle{""};
/** Set/unset pedestal */ QString plotTitle_prefix{""};
void SetPedestal(bool enable); QLabel *lblFrameIndexTitle1d{nullptr};
/** Recalculate Pedestal */ std::vector<std::string> title1d;
void RecalculatePedestal(); std::string title2d{""};
/** Set/unset accumulate */ QString xTitle1d{"Channel Number"};
void SetAccumulate(bool enable); QString yTitle1d{"Counts"};
/** Reset accumulation */ QString xTitle2d{"Pixel"};
void ResetAccumulate(); QString yTitle2d{"Pixel"};
/** Display Statistics */ QString zTitle2d{"Intensity"};
void DisplayStatistics(bool enable); bool XYRangeChanged{false};
double XYRangeValues[4]{0, 0, 0, 0};
bool isXYRangeEnable[4]{false, false, false, false};
// data
unsigned int nHists{0};
private: int histNBins{0};
/** Initializes all its members and the thread */ double *x1d{nullptr};
void Initialization(); std::vector<double *> y1d;
/** Sets up the widget */ double *image2d{nullptr};
void SetupWidgetWindow();
//options
bool binary{false};
/** Gets the image title */ int binaryFrom{0};
const char* GetImageTitle(); int binaryTo{0};
/** Gets the hist title for a 1D plot */ int persistency0};
const char* GetHistTitle(int i); int currentPersistency0};
/** Gets the y axis value for the hist in 1D plot */ bool isLines{true};
double* GetHistYAxis(int i); bool isMarkers{false};
QwtSymbol *marker{nullptr};
QwtSymbol *noMarker{nullptr};
/** Locks the image to update plot */ bool pedestal{false};
int LockLastImageArray(); double *pedestalVals{nullptr};
/** Unocks the image to update plot */ double *tempPedestalVals{nullptr};
int UnlockLastImageArray(); int pedestalCount{0};
/** Starts the acquisition */ bool startPedestalCal{false};
int StartDaqForGui(); bool accumulate{false};
/** Stops the acquisition */ bool resetAccumulate{false};
int StopDaqForGui(); QWidget *widgetStatistics{nullptr};
QLabel *lblMinDisp{nullptr};
/** Starts/stops Acquisition Thread */ QLabel *lblMaxDisp{nullptr};
bool StartOrStopThread(bool start); QLabel *lblSumDisp{nullptr};
bool displayStatistics{false};
/** Sets up measurement each time std::vector<qCloneWidget *> cloneWidgets;
* */ QString fileSavePath{"/tmp"};
void SetupMeasurement(); QString fileSaveName{"Image"};
double *gainImage{nullptr};
/** Resets the acquisition parameter like lastimagenumber */ bool gainDataExtracted{false};
int ResetDaqForGui(); bool gainDataEnable{false};
/** The function which is called when start acquisition thread is created */ unsigned int nPixelsX{0};
static void* DataStartAcquireThread(void *this_pointer); unsigned int nPixelsY{0};
double minPixelsY{0};
/** This is called by the detector class to copy the data it jus acquired */ double maxPixelsY{0};
static int GetDataCallBack(detectorData *data, int fIndex, int subIndex, void *this_pointer); double startPixel{0};
double endPixel{0};
/** This is called by the GetDataCallBack function to copy the data */ double pixelWidth{0};
int GetData(detectorData *data, int fIndex, int subIndex);
int currentMeasurement{0};
/** This is called by detector class when acquisition is finished int currentFrame{0};
* @param currentProgress current progress of measurement int currentFileIndex{0};
* @param detectorStatus current status of the detector int currentFrameIndex{0};
* @param this_pointer is the pointer pointing to this object pthread_mutex_t lastImageCompleteMutex;
* */ unsigned int lastImageNumber{0};
static int GetAcquisitionFinishedCallBack(double currentProgress,int detectorStatus, void *this_pointer); int numberofFrames{0};
double acquisitionPeriod{0};
/** This is called by static function when acquisition is finished double exposureTime{0};
* @param currentProgress current progress of measurement
* @param detectorStatus current status of the detector /** prevents err msg displaying twice when detector stopped, "transmitting"
* */ */
int AcquisitionFinished(double currentProgress,int detectorStatus); bool alreadyDisplayed{false};
/** This is called by detector class when a measurement is finished const static int npixelsx_jctb = 400;
* @param currentMeasurementIndex current measurement index int npixelsy_jctb{0};
* @param fileIndex current file index
* @param this_pointer is the pointer pointing to this object
* */
static int GetMeasurementFinishedCallBack(int currentMeasurementIndex, int fileIndex, void *this_pointer);
/** This is called by the static function when meausrement is finished
* @param currentMeasurementIndex current measurement index
* @param fileIndex current file index
* */
int MeasurementFinished(int currentMeasurementIndex, int fileIndex);
/** This is called by the detector class to send progress if receiver is online */
static int GetProgressCallBack(double currentProgress, void *this_pointer);
/** Saves all the plots. All sets saveError to true if not saved.*/
void SavePlotAutomatic();
/** Sets the style of the 1d plot */
void SetStyle(SlsQtH1D* h);
/** Find Statistics
* @param min is the minimum value
* @param max is the maximum value
* @param sum is the sum of all values
* @param array is the array to get statistics from
* @param size is the size of the array */
void GetStatistics(double &min, double &max, double &sum, double* array, int size);
/**
* Convert data from char* to double based on bit mode (get gain data from plot if enabled for jungfrau
* @param dest destination double array
* @param source source char array
* @param size number of pixels
* @param databytes number of data bytes
* @param dr dynamic range
* @param gaindest NULL if not required, points to a double array to be filled up if gain data enabled
*
*/
void toDoublePixelData(double* dest, char* source,int size, int databytes, int dr, double* gaindest = NULL);
private slots:
/** To update plot
* */
void UpdatePlot();
/** To start or stop acquisition
* @param start is 1 to start and 0 to stop acquisition
* */
void StartDaq(bool start);
/** To set the reference to zero after closing a clone
* @param id is the id of the clone
* */
void CloneCloseEvent(int id);
/**After a pause, the gui is allowed to collect the data
* this is called when it is over
* */
void UpdatePause();
/** Shows the first save error message while automatic saving
* @param fileName file name of the first file that it tried to save.
* */
void ShowSaveErrorMessage(QString fileName);
/**Shows an error message when acquisition stopped unexpectedly
* @param status is the status of the detector
* */
void ShowAcquisitionErrorMessage(QString status);
/**
* Enable Gain Plot
* @param e true for enable, false for disable
*/
void EnableGainPlot(bool e);
signals:
void UpdatingPlotFinished();
void InterpolateSignal(bool);
void ContourSignal(bool);
void LogzSignal(bool);
void LogySignal(bool);
void ResetZMinZMaxSignal(bool,bool,double,double);
void SetCurrentMeasurementSignal(int);
void saveErrorSignal(QString);
void AcquisitionErrorSignal(QString);
void UpdatePlotSignal();
void GainPlotSignal(bool);
private:
multiSlsDetector *myDet;
slsDetectorDefs::detectorType detType;
SlsQt1DPlot* plot1D;
QVector<SlsQtH1D*> plot1DHists;
SlsQt2DPlotLayout* plot2D;
static const int MAXCloneWindows = 50;
qCloneWidget *cloneWidgets[MAXCloneWindows];
/** Widgets needed to set up plot*/
QGroupBox *boxPlot;
QGridLayout *layout;
QGridLayout *plotLayout;
QLabel *histFrameIndexTitle;
int currentMeasurement;
int currentFrame;
int currentFileIndex;
int currentFrameIndex;
int numberofFrames;
double acquisitionPeriod;
double exposureTime;
volatile bool stop_signal;
pthread_mutex_t last_image_complete_mutex;
/**variables for histograms */
/** X Axis Title in 2D */
QString imageXAxisTitle;
/** Y Axis Title in 2D */
QString imageYAxisTitle;
/** Z Axis Title in 2D */
QString imageZAxisTitle;
/** X Axis Title in 1D */
QString histXAxisTitle;
/** Y Axis Title in 1D */
QString histYAxisTitle;
/** Title for all the graphs in 1D */
std::string histTitle[MAX_1DPLOTS];
/** Title in 2D */
std::string imageTitle;
/** plot Title */
QString plotTitle;
/** plot Title prefix */
QString plotTitle_prefix;
/** 1D or 2D */
unsigned int plot_in_scope;
/** Number of Pixels in X Axis */
unsigned int nPixelsX;
/** Number of angle Pixels in X Axis */
int nAnglePixelsX;
/** Number of pixel bins in Y Axis */
unsigned int nPixelsY;
/** Min Pixel number for Y Axis*/
double minPixelsY;
/** Max Pixel number for Y Axis*/
double maxPixelsY;
/** starting pixel */
double startPixel;
/** end Pixel*/
double endPixel;
/** pixel width */
double pixelWidth;
/** Current Image Number */
unsigned int lastImageNumber;
/** Number of graphs in 1D */
unsigned int nHists;
/** Total Number of X axis values/channels in 1D */
int histNBins;
/** X Axis value in 1D */
double* histXAxis;
/** Y Axis value in 1D */
double* histYAxis[MAX_1DPLOTS];
/** X Axis for angles in 1D */
double* histXAngleAxis;
/** Y Axis for angles in 1D (no persistency) */
double* histYAngleAxis;
/** X Axis for trimbits in 1D */
double* histTrimbits;
/** Current Image Values in 2D */
double* lastImageArray;
/**persistency to be reached*/
int persistency;
/** persistency takes time to reach as it increases per frame
* this is the current one */
int currentPersistency;
/** to update the progress for each getData() so that
* measurement tab can request on a timer basis*/
int progress;
/**If plot is enabled from plot tab*/
bool plotEnable;
/**If plot is dotted */
bool lines;
bool markers;
/** Plot marker */
QwtSymbol *marker;
QwtSymbol *noMarker;
/** Save all plots */
bool saveAll;
/** If error, while automatically saving plots, checks this at the end of an acquistion */
bool saveError;
/** index of last saved image for automatic saving*/
int lastSavedFrame;
/** index of measurement number of last saved image for automatic saving*/
int lastSavedMeasurement;
/**if an acquisition is running, so as not to refresh tab
* and also to update plot only if running (while creating clones)*/
bool running;
/** if the min/max of x and y has been changed,
* to notify while plotting */
bool XYRangeChanged;
/**the specific min/max of x/y*/
double XYRangeValues[4];
/**if the specific min/max of x/y is enabled */
bool IsXYRange[4];
/** Specific timer value between plots */
double timerValue;
/** every nth frame when to plot */
int frameFactor;
/**if frame is enabled in measurement tab */
bool isFrameEnabled;
/**if trigger is enabled in measurement tab */
bool isTriggerEnabled;
/** scan arguments*/
int scanArgument;
/** histogram arguments*/
int histogramArgument;
/** enable angle plot */
bool anglePlot;
/** prevents err msg displaying twice when detector stopped, "transmitting" */
bool alreadyDisplayed;
/**saves the file path and file name, not to access shared memory while running*/
QString filePath;
QString fileName;
/** Max Number of Clone Windows */
static const int TRIM_HISTOGRAM_XMAX = 63;
/**if the values increment backwards*/
bool backwardScanPlot;
/**if files will be saved and index increased*/
bool fileSaveEnable;
/** true of originally 2d */
bool originally2D;
//pedstal
/** Number of pedestal frames*/
static const int NUM_PEDESTAL_FRAMES = 20;
/** set/unset pedestal*/
bool pedestal;
/** pedestal values */
double* pedestalVals;
/** temporary pedestal values to hide while recalculating*/
double* tempPedestalVals;
/** count for 20 frames to calculate the pedestal */
int pedestalCount;
/** start pedestal calculation */
bool startPedestalCal;
//accumulation
/** set/unset accumulation */
bool accumulate;
/** to reset accumulation */
bool resetAccumulate;
/** range for binary plot output */
bool binary;
int binaryFrom;
int binaryTo;
/** this is set when client starts/stops acquisition
* and is reset once the gui really starts/stops */
bool clientInitiated;
/** display statistics widgets */
QWidget *widgetStatistics;
QLabel *lblMinDisp;
QLabel *lblMaxDisp;
QLabel *lblSumDisp;
bool displayStatistics;
/* histogram */
bool histogram;
int histFrom;
int histTo;
double histSize;
QwtPlotGrid *grid;
QwtPlotHistogram *plotHistogram;
QVector<QwtIntervalSample> histogramSamples;
bool plotRequired;
/** 2D object second plot */
SlsQt2DPlotLayout* gainplot2D;
/** Current Image Values in 2D gain plot */
double* gainImageArray;
/** gain plot enable, enabled if gain data has been extracted and is available */
bool gainPlotEnable;
/** gain data enable, enabled if gain data to be extracted from normal data */
bool gainDataEnable;
const static int npixelsx_jctb = 400;
int npixelsy_jctb;
}; };

View File

@ -56,7 +56,6 @@ private:
bool isOneD; bool isOneD;
QButtonGroup *btnGroupPlotType; QButtonGroup *btnGroupPlotType;
/** interval between plots */
QStackedLayout *stackedLayout; QStackedLayout *stackedLayout;
QSpinBox *spinNthFrame; QSpinBox *spinNthFrame;
QDoubleSpinBox *spinTimeGap; QDoubleSpinBox *spinTimeGap;

View File

@ -23,7 +23,9 @@
#include <QPainter> #include <QPainter>
qCloneWidget::qCloneWidget(QWidget *parent, int id, QString title, QString xTitle, QString yTitle, QString zTitle, qCloneWidget::qCloneWidget(QWidget *parent, int id, QString title, QString xTitle, QString yTitle, QString zTitle,
int numDim, std::string FilePath, bool displayStats, QString min, QString max, QString sum) : QMainWindow(parent), id(id), filePath(FilePath), cloneplot1D(0), cloneplot2D(0) { int numDim, std::string FilePath, bool displayStats, QString min, QString max, QString sum) :
QMainWindow(parent), id(id), filePath(FilePath), cloneplot1D(nullptr), cloneplot2D(nullptr),
marker(nullptr), nomarker(nullptr), mainLayout(nullptr), cloneBox(nullptr), lblHistTitle(nullptr) {
// Window title // Window title
char winTitle[300], currTime[50]; char winTitle[300], currTime[50];
strcpy(currTime, GetCurrentTimeStamp()); strcpy(currTime, GetCurrentTimeStamp());
@ -41,10 +43,21 @@ qCloneWidget::qCloneWidget(QWidget *parent, int id, QString title, QString xTitl
} }
qCloneWidget::~qCloneWidget() { qCloneWidget::~qCloneWidget() {
delete cloneplot1D; if (cloneplot1D)
delete cloneplot2D; delete cloneplot1D;
delete cloneBox; if (cloneplot2D)
cloneplot1D_hists.clear(); delete cloneplot2D;
cloneplot1D_hists.clear();
if (marker)
delete marker;
if (nomarker)
delete nomarker;
if (mainLayout)
delete mainLayout;
if (cloneBox)
delete cloneBox;
if (lblHistTitle)
delete lblHistTitle;
} }
SlsQt1DPlot* qCloneWidget::Get1dPlot() { SlsQt1DPlot* qCloneWidget::Get1dPlot() {
@ -110,7 +123,7 @@ void qCloneWidget::SetupWidgetWindow(QString title, QString xTitle, QString yTit
resize(500, 350); resize(500, 350);
} }
void qCloneWidget::SetCloneHists(int nHists, int histNBins, double *histXAxis, double *histYAxis[], std::string histTitle[], bool lines, bool markers) { void qCloneWidget::SetCloneHists(int nHists, int histNBins, double *histXAxis, std::vector<double*> histYAxis, std::vector<std::string> histTitle, bool lines, bool markers) {
//for each plot, create hists //for each plot, create hists
for (int hist_num = 0; hist_num < nHists; ++hist_num) { for (int hist_num = 0; hist_num < nHists; ++hist_num) {
SlsQtH1D *k; SlsQtH1D *k;
@ -146,45 +159,6 @@ void qCloneWidget::SetCloneHists(int nHists, int histNBins, double *histXAxis, d
} }
} }
void qCloneWidget::SetCloneHists(int nHists, int histNBins, double *histXAxis, double *histYAxis, std::string histTitle[], bool lines, bool markers) {
// for each plot create hists
for (int hist_num = 0; hist_num < nHists; ++hist_num) {
SlsQtH1D *k;
if (hist_num + 1 > cloneplot1D_hists.size()) {
cloneplot1D_hists.append(k = new SlsQtH1D("1d plot", histNBins, histXAxis, histYAxis));
k->SetLineColor(hist_num + 1);
} else {
k = cloneplot1D_hists.at(hist_num);
k->SetData(histNBins, histXAxis, histYAxis);
}
//style of plot
if (lines)
k->setStyle(QwtPlotCurve::Lines);
else
k->setStyle(QwtPlotCurve::Dots);
if (markers) {
QwtSymbol *marker = new QwtSymbol();
marker->setStyle(QwtSymbol::Cross);
marker->setSize(5, 5);
#if QWT_VERSION < 0x060000
k->setSymbol(*marker);
#else
k->setSymbol(marker);
#endif
} else {
QwtSymbol *noMarker = new QwtSymbol();
#if QWT_VERSION < 0x060000
k->setSymbol(*noMarker);
#else
k->setSymbol(noMarker);
#endif
}
//set title and attach plot
lblHistTitle->setText(QString(histTitle[0].c_str()));
k->Attach(cloneplot1D);
}
}
void qCloneWidget::SetCloneHists2D(int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, double *d) { void qCloneWidget::SetCloneHists2D(int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, double *d) {
cloneplot2D->GetPlot()->SetData(nbinsx, xmin, xmax, nbinsy, ymin, ymax, d); cloneplot2D->GetPlot()->SetData(nbinsx, xmin, xmax, nbinsy, ymin, ymax, d);
cloneplot2D->KeepZRangeIfSet(); cloneplot2D->KeepZRangeIfSet();

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,18 @@ QWidget(parent), myDet(detector) {
FILE_LOG(logDEBUG) << "Advanced ready"; FILE_LOG(logDEBUG) << "Advanced ready";
} }
qTabAdvanced::~qTabAdvanced(){} qTabAdvanced::~qTabAdvanced(){
for (int i = 0; i < lblFromX.size(); ++i) {
delete lblFromX[i];
delete lblFromY[i];
delete lblToX[i];
delete lblToY[i];
delete spinFromX[i];
delete spinFromY[i];
delete spinToX[i];
delete spinToY[i];
}
}
void qTabAdvanced::SetupWidgetWindow(){ void qTabAdvanced::SetupWidgetWindow(){
// palette // palette

View File

@ -10,13 +10,16 @@
#include <string> #include <string>
qTabDataOutput::qTabDataOutput(QWidget *parent, multiSlsDetector *detector) : QWidget(parent), myDet(detector) { qTabDataOutput::qTabDataOutput(QWidget *parent, multiSlsDetector *detector) : QWidget(parent), myDet(detector), btnGroupRate(nullptr) {
setupUi(this); setupUi(this);
SetupWidgetWindow(); SetupWidgetWindow();
FILE_LOG(logDEBUG) << "DataOutput ready"; FILE_LOG(logDEBUG) << "DataOutput ready";
} }
qTabDataOutput::~qTabDataOutput() {} qTabDataOutput::~qTabDataOutput() {
if (btnGroupRate)
delete btnGroupRate;
}
void qTabDataOutput::SetupWidgetWindow() { void qTabDataOutput::SetupWidgetWindow() {
// button group for rate // button group for rate

View File

@ -8,13 +8,22 @@
#include <iostream> #include <iostream>
qTabDebugging::qTabDebugging(QWidget *parent, multiSlsDetector *detector) : qTabDebugging::qTabDebugging(QWidget *parent, multiSlsDetector *detector) :
QWidget(parent), myDet(detector), treeDet(0), lblDetectorHostname(0), lblDetectorFirmware(0), lblDetectorSoftware(0) { QWidget(parent), myDet(detector), treeDet(nullptr), lblDetectorHostname(nullptr), lblDetectorFirmware(nullptr), lblDetectorSoftware(nullptr) {
setupUi(this); setupUi(this);
SetupWidgetWindow(); SetupWidgetWindow();
FILE_LOG(logDEBUG) << "Debugging ready"; FILE_LOG(logDEBUG) << "Debugging ready";
} }
qTabDebugging::~qTabDebugging() {} qTabDebugging::~qTabDebugging() {
if (treeDet)
delete treeDet;
if (lblDetectorHostname)
delete lblDetectorHostname;
if (lblDetectorFirmware)
delete lblDetectorFirmware;
if (lblDetectorSoftware)
delete lblDetectorSoftware;
}
void qTabDebugging::SetupWidgetWindow() { void qTabDebugging::SetupWidgetWindow() {

View File

@ -21,13 +21,39 @@
qTabDeveloper::qTabDeveloper(QWidget *parent, multiSlsDetector *detector) : qTabDeveloper::qTabDeveloper(QWidget *parent, multiSlsDetector *detector) :
QWidget(parent), myDet(detector), detType(slsDetectorDefs::GENERIC), numDACWidgets(0), numADCWidgets(0), QWidget(parent), myDet(detector), detType(slsDetectorDefs::GENERIC), numDACWidgets(0), numADCWidgets(0),
boxDacs(nullptr), boxAdcs(nullptr), lblHV(nullptr), comboHV(nullptr), dacLayout(nullptr), comboDetector(nullptr) { boxDacs(nullptr), boxAdcs(nullptr), lblHV(nullptr), comboHV(nullptr), spinHV(nullptr), dacLayout(nullptr), comboDetector(nullptr), layout(nullptr) {
SetupWidgetWindow(); SetupWidgetWindow();
Initialization(); Initialization();
FILE_LOG(logDEBUG) << "Developer ready"; FILE_LOG(logDEBUG) << "Developer ready";
} }
qTabDeveloper::~qTabDeveloper() {} qTabDeveloper::~qTabDeveloper() {
for (int i = 0; i < lblDacs.size(); ++i) {
delete lblDacs[i];
delete lblDacsmV[i];
delete spinDacs[i];
}
for (int i = 0; i < lblAdcs.size(); ++i) {
delete lblAdcs[i];
delete spinAdcs[i];
}
if (boxDacs)
delete boxDacs;
if (boxAdcs)
delete boxAdcs;
if (lblHV)
delete lblHV;
if (comboHV)
delete comboHV;
if (spinHV)
delete spinHV;
if (dacLayout)
delete dacLayout;
if (comboDetector)
delete comboDetector;
if (layout)
delete layout;
}
void qTabDeveloper::SetupWidgetWindow() { void qTabDeveloper::SetupWidgetWindow() {
detType = myDet->getDetectorTypeAsEnum(); detType = myDet->getDetectorTypeAsEnum();

View File

@ -8,13 +8,17 @@
#include <iostream> #include <iostream>
qTabMeasurement::qTabMeasurement(QWidget *parent, multiSlsDetector *detector, qDrawPlot *plot) : QWidget(parent), myDet(detector), myPlot(plot) { qTabMeasurement::qTabMeasurement(QWidget *parent, multiSlsDetector *detector, qDrawPlot *plot) : QWidget(parent), myDet(detector), myPlot(plot),
progressTimer(nullptr) {
setupUi(this); setupUi(this);
SetupWidgetWindow(); SetupWidgetWindow();
FILE_LOG(logDEBUG) << "Measurement ready"; FILE_LOG(logDEBUG) << "Measurement ready";
} }
qTabMeasurement::~qTabMeasurement() {} qTabMeasurement::~qTabMeasurement() {
if (progressTimer)
delete progressTimer;
}
bool qTabMeasurement::GetStartStatus(){ bool qTabMeasurement::GetStartStatus(){
return (!btnStart->isEnabled()); return (!btnStart->isEnabled());
@ -523,8 +527,6 @@ void qTabMeasurement::SetFileWrite(bool val) {
try { try {
myDet->setFileWrite(val); myDet->setFileWrite(val);
// for file save enable
myPlot->SetFileWrite(val);
dispFileName->setEnabled(chkFile->isChecked()); dispFileName->setEnabled(chkFile->isChecked());
} catch (const sls::NonCriticalError &e) { } catch (const sls::NonCriticalError &e) {
qDefs::ExceptionMessage("Could not set file write enable.", e.what(), "qTabMeasurement::SetFileWrite"); qDefs::ExceptionMessage("Could not set file write enable.", e.what(), "qTabMeasurement::SetFileWrite");
@ -602,7 +604,7 @@ void qTabMeasurement::ResetProgress() {
void qTabMeasurement::UpdateProgress() { void qTabMeasurement::UpdateProgress() {
FILE_LOG(logDEBUG) << "Updating progress"; FILE_LOG(logDEBUG) << "Updating progress";
progressBar->setValue(myPlot->GetProgress()); progressBar->setValue(myPlot->GetProgress());
lblCurrentFrame->setText(QString::number(myPlot->GetFrameIndex())); lblCurrentFrame->setText(QString::number(myPlot->GetCurrentFrameIndex()));
} }
int qTabMeasurement::VerifyOutputDirectoryError() { int qTabMeasurement::VerifyOutputDirectoryError() {

View File

@ -13,14 +13,19 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
qTabMessages::qTabMessages(QWidget *parent) : QWidget(parent) { qTabMessages::qTabMessages(QWidget *parent) : QWidget(parent),
dispLog(nullptr), btnSave(nullptr), btnClear(nullptr) {
SetupWidgetWindow(); SetupWidgetWindow();
Initialization();
FILE_LOG(logDEBUG) << "Messages ready"; FILE_LOG(logDEBUG) << "Messages ready";
} }
qTabMessages::~qTabMessages() { qTabMessages::~qTabMessages() {
delete dispLog; if (dispLog)
delete dispLog;
if (btnSave)
delete btnSave;
if (btnClear)
delete btnClear;
} }
void qTabMessages::SetupWidgetWindow() { void qTabMessages::SetupWidgetWindow() {
@ -49,6 +54,8 @@ void qTabMessages::SetupWidgetWindow() {
qDebugStream(std::cout, this); qDebugStream(std::cout, this);
qDebugStream(std::cerr, this); qDebugStream(std::cerr, this);
Initialization();
} }
void qTabMessages::Initialization() { void qTabMessages::Initialization() {

View File

@ -27,7 +27,18 @@ qTabPlot::qTabPlot(QWidget *parent, multiSlsDetector *detector, qDrawPlot *plot)
FILE_LOG(logDEBUG) << "Plot ready"; FILE_LOG(logDEBUG) << "Plot ready";
} }
qTabPlot::~qTabPlot() {} qTabPlot::~qTabPlot() {
if (btnGroupPlotType)
delete btnGroupPlotType;
if (stackedLayout)
delete stackedLayout;
if (spinNthFrame)
delete spinNthFrame;
if (spinTimeGap)
delete spinTimeGap;
if (comboTimeGapUnit)
delete comboTimeGapUnit;
}
void qTabPlot::SetupWidgetWindow() { void qTabPlot::SetupWidgetWindow() {
// button group for plot type // button group for plot type
@ -157,7 +168,6 @@ void qTabPlot::Initialization() {
// Save // Save
connect(btnSave, SIGNAL(clicked()), myPlot, SLOT(SavePlot())); connect(btnSave, SIGNAL(clicked()), myPlot, SLOT(SavePlot()));
connect(chkSaveAll, SIGNAL(toggled(bool)), myPlot, SLOT(SaveAll(bool)));
// Snapshot box // Snapshot box
connect(btnClone, SIGNAL(clicked()), myPlot, SLOT(ClonePlot())); connect(btnClone, SIGNAL(clicked()), myPlot, SLOT(ClonePlot()));
@ -236,6 +246,8 @@ void qTabPlot::SetPlot() {
SetZRange(); SetZRange();
} }
} }
myPlot->SetDataCallBack(plotEnable);
} }
void qTabPlot::Set1DPlotOptionsRight() { void qTabPlot::Set1DPlotOptionsRight() {

View File

@ -4091,8 +4091,13 @@ void multiSlsDetector::registerDataCallback(int (*userCallback)(detectorData *,
dataReady = userCallback; dataReady = userCallback;
pCallbackArg = pArg; pCallbackArg = pArg;
if (setReceiverOnline() == slsDetectorDefs::ONLINE_FLAG) { if (setReceiverOnline() == slsDetectorDefs::ONLINE_FLAG) {
enableDataStreamingToClient(1); if (dataReady == nullptr) {
enableDataStreamingFromReceiver(1); enableDataStreamingToClient(0);
enableDataStreamingFromReceiver(0);
} else {
enableDataStreamingToClient(1);
enableDataStreamingFromReceiver(1);
}
} }
} }