/* * qDrawPlot.h * * Created on: May 7, 2012 * Author: Ian Johnson */ #ifndef QDRAWPLOT_H #define QDRAWPLOT_H /** Project Class Headers */ class slsDetectorUtils; #include "detectorData.h" /** Qt Project Class Headers */ #include "SlsQt1DPlot.h" class SlsQt1DPlot; class SlsQt2DPlotLayout; class qCloneWidget; /** Qt Include Headers */ #include #include #include #include #include #define MAX_1DPLOTS 10 /** *@short Sets up the plot widget */ class qDrawPlot:public QWidget{ Q_OBJECT public: /** \short The constructor */ qDrawPlot(QWidget *parent,slsDetectorUtils*& detector); /** Destructor */ ~qDrawPlot(); /** Starts or stop acquisition * Calls startDaq() function * @param stop_if_running is 0 to stop acquisition and 1 to start acquisition */ void StartStopDaqToggle(bool stop_if_running=0); /** sets plot Title */ void SetPlotTitle(QString title) {boxPlot->setTitle(title);} /** sets 1D X Axis Title */ void SetHistXAxisTitle(QString title) {histXAxisTitle = title;} /** sets 1D Y Axis Title */ void SetHistYAxisTitle(QString title) {histYAxisTitle = title;} /** sets 2D X Axis Title */ void SetImageXAxisTitle(QString title) {imageXAxisTitle = title;} /** sets 2D Y Axis Title */ void SetImageYAxisTitle(QString title) {imageYAxisTitle = title;} /** sets 2D Z Axis Title */ void SetImageZAxisTitle(QString title) {imageZAxisTitle = title;} void SetHistXAxisScale(double min,double max){plot1D->SetXAxisScale(min,max);}; void SetHistYAxisScale(double min,double max){plot1D->SetYAxisScale(min,max);}; int GetPixelsX(){return nPixelsX;}; int GetPixelsY(){return nPixelsY;}; void Unzoom1D(){plot1D->UnZoom();}; double GetHistXAxisLowerBound(){return plot1D->GetXAxisLowerBound();}; double GetHistXAxisUpperBound(){return plot1D->GetXAxisUpperBound();}; double GetHistYAxisLowerBound(){return plot1D->GetYAxisLowerBound();}; double GetHistYAxisUpperBound(){return plot1D->GetYAxisUpperBound();}; /** Disables zoom if any of the axes range are checked and fixed with a value */ void DisableZoom(bool disable); /** gets the progress of acquisition to the measurement tab*/ int GetProgress(){return progress;}; private: /** The sls detector object */ slsDetectorUtils *myDet; /** Widgets needed to plot the clone */ /** Max Number of Clone Windows */ static const int MAXCloneWindows = 50; /** Array of clone window widget pointers */ qCloneWidget *winClone[MAXCloneWindows]; /** Widgets needed to set up plot*/ QGroupBox *boxPlot; QGridLayout *layout; QGridLayout *plotLayout; /** Timer to update plot */ QTimer* plot_update_timer; /** 1D object */ SlsQt1DPlot* plot1D; /** 2D object */ SlsQt2DPlotLayout* plot2D; /** vector of 1D hist values */ QVector plot1D_hists; /** Number of Measurements */ int numberOfMeasurements; /** currentFrame */ static int currentFrame; /** Number of Exposures */ static int number_of_exposures; /** Duration between Exposures */ double framePeriod; /** Acquisition Time */ double acquisitionTime; /**variables for threads */ /** */ volatile bool stop_signal; /** */ static pthread_mutex_t last_image_complete_mutex; /**variables for histograms */ /** Title in 2D */ std::string imageTitle; /** X Axis Title in 2D */ QString imageXAxisTitle; /** Y Axis Title in 2D */ QString imageYAxisTitle; /** Z Axis Title in 2D */ QString imageZAxisTitle; /** Title for all the graphs in 1D */ static std::string histTitle[MAX_1DPLOTS]; /** X Axis Title in 1D */ QString histXAxisTitle; /** Y Axis Title in 1D */ QString histYAxisTitle; /** 1D or 2D */ static unsigned int plot_in_scope; /** Number of Pixels in X Axis */ static unsigned int nPixelsX; /** Number of Pixels in Y Axis */ static unsigned int nPixelsY; /** Current Image Number */ static unsigned int lastImageNumber; /** Number of graphs in 1D */ static unsigned int nHists; /** Total Number of X axis values/channels in 1D */ static int histNBins; /** X Axis value in 1D */ static double* histXAxis; /** Y Axis value in 1D */ static double* histYAxis[MAX_1DPLOTS]; /** Current Image Values in 2D */ static double* lastImageArray; /** temporary Y Axis value in 1D */ static double* yvalues[MAX_1DPLOTS]; /** temporary Image Values in 2D */ static double* image_data; static bool gui_acquisition_thread_running; static int persistency; static int currentPersistency; static int progress; static bool plotEnable; /** */ int LockLastImageArray() {return pthread_mutex_lock(&last_image_complete_mutex); } /** */ int UnlockLastImageArray() {return pthread_mutex_unlock(&last_image_complete_mutex);} /** */ int StartDaqForGui() {return StartOrStopThread(1) ? 1:0;} /** */ int StopDaqForGui() {return StartOrStopThread(0) ? 0:1;} /** */ const char* GetImageTitle() {return imageTitle.c_str();} /** */ const char* GetHistTitle(int i) {return (i>=0&&i=0&&i