Creating Classes, Libraries and Functions for the Common SLS Detector GUI

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@1 af1100a4-978c-4157-bff7-07162d2ba061
This commit is contained in:
maliakal_d
2012-05-21 16:00:26 +00:00
commit 9f851d6156
49 changed files with 6522 additions and 0 deletions

View File

@ -0,0 +1,58 @@
/*
* qCloneWidget.h
*
* Created on: May 18, 2012
* Author: l_maliakal_d
*/
#ifndef QCLONEWIDGET_H_
#define QCLONEWIDGET_H_
/** Qt Project Class Headers */
class SlsQt1DPlot;
class SlsQt2DPlotLayout;
/** Qt Include Headers */
#include <QFrame>
#include <QCloseEvent>
/**
*@short Sets up the clone plot widget
*/
class qCloneWidget:public QFrame{
Q_OBJECT
public:
/** \short The constructor
*/
qCloneWidget(QWidget *parent,int id,QSize fSize,int numDim,SlsQt1DPlot*& plot1D,SlsQt2DPlotLayout*& plot2D);
/** Destructor
*/
~qCloneWidget();
public slots:
private:
/** clone window id*/
int id;
/** clone 1D Plot */
SlsQt1DPlot* cloneplot1D;
/** clone 2D Plot */
SlsQt2DPlotLayout* cloneplot2D;
protected:
void closeEvent(QCloseEvent* event);
signals:
void CloneClosedSignal(int);
};
#endif /* QCLONEWIDGET_H_ */

View File

@ -0,0 +1,54 @@
/*
* qDefs.h
*
* Created on: May 4, 2012
* Author: l_maliakal_d
*/
#ifndef QDEFS_H
#define QDEFS_H
class qDefs
{
public:
/** Empty Constructor
*/
qDefs(){};
/** unit of time
*/
enum timeUnit{
HOURS, /** hr */
MINUTES, /** min */
SECONDS, /** s */
MILLISECONDS, /** ms */
MICROSECONDS, /** us */
NANOSECONDS /** ns */
};
/** returns the value in ns to send to server.
* @param unit unit of time
* @param value time
* returns time value in ns
*/
static int64_t get64bTime(timeUnit unit, double value){
int64_t value64=value;
switch(unit){
case HOURS: value64*=60;
case MINUTES: value64*=60;
case SECONDS: value64*=1000;
case MILLISECONDS: value64*=1000;
case MICROSECONDS: value64*=1000;
case NANOSECONDS:
default:;
}
return value64;
};
};
#endif /* QDEFS_H */

View File

@ -0,0 +1,161 @@
/*
* qDetectorMain.h
* Main Window of the GUI
* Created on: Apr 30, 2012
* Author: l_maliakal_d
*/
#ifndef QDETECTORMAIN_H
#define QDETECTORMAIN_H
/** Form Header */
#include "ui_form_detectormain.h"
/** Qt Project Class Headers */
class qDrawPlot;
class qTabMeasurement;
class qTabDataOutput;
class qTabPlot;
class qTabActions;
class qTabAdvanced;
class qTabSettings;
class qTabDebugging;
class qTabDeveloper;
/** Project Class Headers */
class slsDetectorUtils;
#include "sls_detector_defs.h"
/** Qt Include Headers */
#include <QScrollArea>
/**
*@short Main window of the GUI.
*/
class qDetectorMain:public QMainWindow, private Ui::DetectorMainObject{
Q_OBJECT
public:
/** \short Main Window constructor.
* This is mainly used to create detector object and all the tabs
* @param argc number of command line arguments for server options
* @param argv server options
* @param app the qapplication
* @param parent makes the parent window 0 by default
*/
qDetectorMain(int argc, char **argv, QApplication *app, QWidget *parent = 0);
/**Destructor
*/
~qDetectorMain();
private:
/** The Qt Application */
QApplication *theApp;
/** The sls detector object */
slsDetectorUtils *myDet;
/** The Plot widget */
qDrawPlot *myPlot;
/**Tab Widget */
QTabWidget *tabs;
static const int NUMBER_OF_TABS = 8;
/* Scroll Area for the tabs**/
QScrollArea *scroll[NUMBER_OF_TABS];
QScrollArea *scrollMain;
/**Measurement tab */
qTabMeasurement *tab_measurement;
/**DataOutput tab */
qTabDataOutput *tab_dataoutput;
/**Plot tab */
qTabPlot *tab_plot;
/**Actions tab */
qTabActions *tab_actions;
/**Advanced tab */
qTabAdvanced *tab_advanced;
/**Settings tab */
qTabSettings *tab_Settings;
/**Debugging tab */
qTabDebugging *tab_debugging;
/**Developer tab */
qTabDeveloper *tab_developer;
/** enumeration of the tabs */
enum {Measurement, DataOutput, Plot, Actions, Advanced, Settings, Debugging, Developer };
/**Sets up the layout of the widget
*/
void SetUpWidgetWindow();
/**Sets up detector
*/
void SetUpDetector();
/**Sets up the signals and the slots
*/
void Initialization();
/** Enables the developer tab
*/
void SetDeveloperMode();
private slots:
/** Sets/unsets the debug mode i.e. enables/disables the debug tab
* @param b bool TRUE sets, FALSE unsets
*/
void SetDebugMode(bool b);
/** Sets/unsets the beamline mode (at the moment it doesn't do anything)
* @param b bool TRUE sets, FALSE unsets
*/
void SetBeamlineMode(bool b);
/** Sets/unsets the expert mode i.e. enables/disables the advanced and Settings tabs
* @param b bool TRUE sets, FALSE unsets
*/
void SetExpertMode(bool b);
/** Sets/unsets the dockable plot mode
* @param b bool TRUE sets, FALSE unsets
*/
void SetDockableMode(bool b);
/** Refreshes the tab each time the tab is changed. Also displays the next enabled tab */
void refresh(int index);
/** Opens Setup */
void OpenSetup();
/** Saves Setup */
void SaveSetup();
/** Measurement Wizard */
void MeasurementWizard();
/** Open Configuration*/
void OpenConfiguration();
/** Save Configuration */
void SaveConfiguration();
/** Executing Energy Calibration */
void EnergyCalibration();
/** Executing Angular Calibration */
void AngularCalibration();
/** Executing Version */
void Version();
/** Executing About */
void About();
signals:
};
#endif /* QDETECTORMAIN_H */

View File

@ -0,0 +1,225 @@
/*
* qDrawPlot.h
*
* Created on: May 7, 2012
* Author: Ian Johnson
*/
#ifndef QDRAWPLOT_H
#define QDRAWPLOT_H
/** Form Header */
#include "ui_form_drawplot.h"
/** Project Class Headers */
class slsDetectorUtils;
/** Qt Project Class Headers */
class SlsQtH1D;
class SlsQt1DPlot;
class SlsQt2DPlotLayout;
class qCloneWidget;
/** Qt Include Headers */
class QTimer;
class QGridLayout;
/**
*@short Sets up the plot widget
*/
class qDrawPlot:public QWidget, private Ui::DrawPlotObject{
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);
public slots:
/** To select 1D or 2D plot
* @param i is 1 for 1D, else 2D plot
*/
void SelectPlot(int i=2);
/** To select 1D plot
*/
void Select1DPlot() {SelectPlot(1);}
/** To select 2D plot
*/
void Select2DPlot() {SelectPlot(2);}
/** To clear plot
*/
void Clear1DPlot();
/** Creates a clone of the plot
* */
void ClonePlot();
/** Closes all the clone plots
* */
void CloseClones();
private:
/** The sls detector object */
slsDetectorUtils *myDet;
/** Number of Exposures */
int number_of_exposures;
/** Duration between Exposures */
double framePeriod;
/** Acquisition Time */
double acquisitionTime;
/** Widgets needed to plot the clone */
static const int MAXCloneWindows = 50;
/** */
qCloneWidget *winClone[MAXCloneWindows];
/** */
QTimer* plot_update_timer;
/** */
SlsQt1DPlot* plot1D;
/** */
SlsQt2DPlotLayout* plot2D;
/** */
QVector<SlsQtH1D*> plot1D_hists;
/**variables for threads */
/** */
volatile bool stop_signal;
/** */
pthread_mutex_t last_image_complete_mutex;
/**variables for histograms */
/** */
unsigned int plot_in_scope;
/** */
unsigned int lastImageNumber;
/** */
std::string imageTitle;
/** */
std::string imageXAxisTitle;
/** */
std::string imageYAxisTitle;
/** */
std::string imageZAxisTitle;
/** */
unsigned int nPixelsX;
/** */
unsigned int nPixelsY;
/** */
double* lastImageArray;
/** */
unsigned int nHists;
/** */
std::string histTitle[10];
/** */
std::string histXAxisTitle;
/** */
std::string histYAxisTitle;
/** */
int histNBins;
/** */
double* histXAxis;
/** */
double* histYAxis[10];
/** */
int LockLastImageArray() {return pthread_mutex_lock(&last_image_complete_mutex); }
/** */
int UnlockLastImageArray() {return pthread_mutex_unlock(&last_image_complete_mutex);}
/** */
SlsQt1DPlot* Get1DPlotPtr() {return plot1D;}
/** */
SlsQt2DPlotLayout* Get2DPlotPtr() {return plot2D;}
/** */
int StartDaqForGui() {return StartOrStopThread(1) ? 1:0;}
/** */
int StopDaqForGui() {return StartOrStopThread(0) ? 0:1;}
/** */
unsigned int PlotInScope() {return plot_in_scope;}
/** */
unsigned int GetLastImageNumber() {return lastImageNumber;}
/** */
const char* GetImageTitle() {return imageTitle.c_str();}
/** */
const char* GetImageXAxisTitle() {return imageXAxisTitle.c_str();}
/** */
const char* GetImageYAxisTitle() {return imageYAxisTitle.c_str();}
/** */
const char* GetImageZAxisTitle() {return imageZAxisTitle.c_str();}
/** */
unsigned int GetNPixelsX() {return nPixelsX;}
/** */
unsigned int GetNPixelsY() {return nPixelsY;}
/** */
double* GetLastImageArray() {return lastImageArray;}
/** */
unsigned int GetNHists() {return nHists;}
/** */
const char* GetHistTitle(int i) {return (i>=0&&i<10) ? histTitle[i].c_str():0;} //int for hist number
/** */
const char* GetHistXAxisTitle() {return histXAxisTitle.c_str();}
/** */
const char* GetHistYAxisTitle() {return histYAxisTitle.c_str();}
/** */
unsigned int GetHistNBins() {return histNBins;}
/** */
double* GetHistXAxis() {return histXAxis;}
/** */
double* GetHistYAxis(int i) {return (i>=0&&i<10) ? histYAxis[i]:0;} //int for hist number
/** Initializes all its members and the thread */
void Initialization();
/** Sets up the widget */
void SetupWidgetWindow();
/** */
int ResetDaqForGui();
/**acquisition thread stuff */
/** */
bool StartOrStopThread(bool start);
/** */
static void* DataAcquisionThread(void *this_pointer);
/** */
void* AcquireImages();
private slots:
/** To update plot
*/
void UpdatePlot();
/** To stop updating plot
*/
void StopUpdatePlot();
/** To start or stop acquisition
* @param start is 1 to start and 0 to stop acquisition
*/
void StartDaq(bool start);
void CloneCloseEvent(int id);
signals:
void UpdatingPlotFinished();
void InterpolateSignal(bool);
void ContourSignal(bool);
void LogzSignal(bool);
};
#endif /* QDRAWPLOT_H */

View File

@ -0,0 +1,52 @@
/*
* qTabActions.h
*
* Created on: May 10, 2012
* Author: l_maliakal_d
*/
#ifndef QTABACTIONS_H_
#define QTABACTIONS_H_
/** Form Header */
#include "ui_form_tab_actions.h"
/** Project Class Headers */
class slsDetectorUtils;
/**
*@short sets up the acions parameters
*/
class qTabActions:public QWidget, private Ui::TabActionsObject{
Q_OBJECT
public:
/** \short The constructor
* @param parent is the parent tab widget
* @param detector is the detector returned from the detector tab
*/
qTabActions(QWidget *parent,slsDetectorUtils*& detector);
/** Destructor
*/
~qTabActions();
private:
/** The sls detector object */
slsDetectorUtils *myDet;
/** Sets up the widget
*/
void SetupWidgetWindow();
/** Sets up all the slots and signals
*/
void Initialization();
/** Enables/Disables all the widgets
*/
void Enable(bool enable);
};
#endif /* QTABACTIONS_H_ */

View File

@ -0,0 +1,62 @@
/*
* qTabAdvanced.h
*
* Created on: May 10, 2012
* Author: l_maliakal_d
*/
#ifndef QTABADVANCED_H_
#define QTABADVANCED_H_
/** Form Header */
#include "ui_form_tab_advanced.h"
/** Project Class Headers */
class slsDetectorUtils;
/**
*@short sets up the advanced parameters
*/
class qTabAdvanced:public QWidget, private Ui::TabAdvancedObject{
Q_OBJECT
public:
/** \short The constructor
* @param parent is the parent tab widget
* @param detector is the detector returned from the detector tab
*/
qTabAdvanced(QWidget *parent,slsDetectorUtils*& detector);
/** Destructor
*/
~qTabAdvanced();
private:
/** The sls detector object */
slsDetectorUtils *myDet;
/** The sls detector object type*/
int myDetType;
/** Sets up the widget
*/
void SetupWidgetWindow();
/** Sets up all the slots and signals
*/
void Initialization();
/** Enables/Disables all the widgets
*/
void Enable(bool enable);
private slots:
/** Get Temperature data
*/
void getTemperature();
};
#endif /* QTABADVANCED_H_ */

View File

@ -0,0 +1,54 @@
/*
* qTabDataOutput.h
*
* Created on: May 10, 2012
* Author: l_maliakal_d
*/
#ifndef QTABDATAOUTPUT_H_
#define QTABDATAOUTPUT_H_
/** Form Header */
#include "ui_form_tab_dataoutput.h"
/** Project Class Headers */
class slsDetectorUtils;
/**
*@short sets up the DataOutput parameters
*/
class qTabDataOutput:public QWidget, private Ui::TabDataOutputObject{
Q_OBJECT
public:
/** \short The constructor
* @param parent is the parent tab widget
* @param detector is the detector returned from the detector tab
*/
qTabDataOutput(QWidget *parent,slsDetectorUtils*& detector);
/** Destructor
*/
~qTabDataOutput();
private:
/** The sls detector object */
slsDetectorUtils *myDet;
/** Sets up the widget
*/
void SetupWidgetWindow();
/** Sets up all the slots and signals
*/
void Initialization();
/** Enables/Disables all the widgets
*/
void Enable(bool enable);
};
#endif /* QTABDATAOUTPUT_H_ */

View File

@ -0,0 +1,54 @@
/*
* qTabDebugging.h
*
* Created on: May 10, 2012
* Author: l_maliakal_d
*/
#ifndef QTABDEBUGGING_H_
#define QTABDEBUGGING_H_
/** Form Header */
#include "ui_form_tab_debugging.h"
/** Project Class Headers */
class slsDetectorUtils;
/**
*@short sets up the Debugging parameters
*/
class qTabDebugging:public QWidget, private Ui::TabDebuggingObject{
Q_OBJECT
public:
/** \short The constructor
* @param parent is the parent tab widget
* @param detector is the detector returned from the detector tab
*/
qTabDebugging(QWidget *parent,slsDetectorUtils*& detector);
/** Destructor
*/
~qTabDebugging();
private:
/** The sls detector object */
slsDetectorUtils *myDet;
/** Sets up the widget
*/
void SetupWidgetWindow();
/** Sets up all the slots and signals
*/
void Initialization();
/** Enables/Disables all the widgets
*/
void Enable(bool enable);
};
#endif /* QTABDEBUGGING_H_ */

View File

@ -0,0 +1,54 @@
/*
* qTabDeveloper.h
*
* Created on: May 10, 2012
* Author: l_maliakal_d
*/
#ifndef QTABDEVELOPER_H_
#define QTABDEVELOPER_H_
/** Form Header */
#include "ui_form_tab_developer.h"
/** Project Class Headers */
class slsDetectorUtils;
/**
*@short sets up the Developer parameters
*/
class qTabDeveloper:public QWidget, private Ui::TabDeveloperObject{
Q_OBJECT
public:
/** \short The constructor
* @param parent is the parent tab widget
* @param detector is the detector returned from the detector tab
*/
qTabDeveloper(QWidget *parent,slsDetectorUtils*& detector);
/** Destructor
*/
~qTabDeveloper();
private:
/** The sls detector object */
slsDetectorUtils *myDet;
/** Sets up the widget
*/
void SetupWidgetWindow();
/** Sets up all the slots and signals
*/
void Initialization();
/** Enables/Disables all the widgets
*/
void Enable(bool enable);
};
#endif /* QTABDEVELOPER_H_ */

View File

@ -0,0 +1,108 @@
/*
* qTabMeasurement.h
*
* Created on: May 2, 2012
* Author: l_maliakal_d
*/
#ifndef QTABMEASUREMENT
#define QTABMEASUREMENT
/** Form Header */
#include "ui_form_tab_measurement.h"
/** Project Class Headers */
class slsDetectorUtils;
/** Qt Project Class Headers */
class qDrawPlot;
/**
*@short sets up the measurement parameters
*/
class qTabMeasurement:public QWidget, private Ui::TabMeasurementObject{
Q_OBJECT
public:
/** \short The constructor
* This tab allows to change the detector settings, the threshold, the number of (non real time) measurements,
* the acquisition time, the file name, the start run index and shows the current progress of the measurement
* via a progress bar and labels inidicating the current position, scan variable, frame number etc.
* Contains the start and stop acquisition button
* @param parent is the parent tab widget
* @param detector is the detector returned from the detector tab
* @param plot plot object reference
*/
qTabMeasurement(QWidget *parent,slsDetectorUtils*& detector, qDrawPlot*& plot);
/** Destructor
*/
~qTabMeasurement();
private:
/** The sls detector object */
slsDetectorUtils *myDet;
/** The Plot widget */
qDrawPlot *myPlot;
/** methods */
/** Sets up the widget
*/
void SetupWidgetWindow();
/** Sets up all the slots and signals
*/
void Initialization();
/** Enables/Disables all the widgets
*/
void Enable(bool enable);
public slots:
/** update plot is finished,
* changes start/stop text and enables/disables all widgets
*/
void UpdateFinished();
private slots:
/** Set settings according to selection
* @param index index of selection
*/
void setSettings(int index);
/** Set number of frames
* @param val number of frames to be set
*/
void setNumFrames(int val);
/** Set acquisition time
*/
void setAcquisitionTime();
/** Set frame period between exposures
*/
void setFramePeriod();
/** Set file name
* @param fName name of file
*/
void setFileName(const QString& fName);
/** Set index of file name
* @param index index of selection
*/
void setRunIndex(int index);
/** starts/stops Acquisition
*/
void startStopAcquisition();
signals:
};
#endif /* QTABMEASUREMENT */

View File

@ -0,0 +1,74 @@
/*
* qTabPlot.h
*
* Created on: May 10, 2012
* Author: l_maliakal_d
*/
#ifndef QTABPLOT_H_
#define QTABPLOT_H_
/** Form Header */
#include "ui_form_tab_plot.h"
/** Project Class Headers */
class slsDetectorUtils;
/** Qt Project Class Headers */
class qDrawPlot;
/**
*@short sets up the Plot parameters
*/
class qTabPlot:public QWidget, private Ui::TabPlotObject{
Q_OBJECT
public:
/** \short The constructor
* @param parent is the parent tab widget
* @param detector is the detector returned from the detector tab
* @param plot plot object reference
*/
qTabPlot(QWidget *parent,slsDetectorUtils*& detector, qDrawPlot*& plot);
/** Destructor
*/
~qTabPlot();
private:
/** The sls detector object */
slsDetectorUtils *myDet;
/** The Plot widget */
qDrawPlot *myPlot;
/** methods */
/** Sets up the widget
*/
void SetupWidgetWindow();
/** Sets up all the slots and signals
*/
void Initialization();
/** Enables/Disables all the widgets
*/
void Enable(bool enable);
public slots:
private slots:
signals:
};
#endif /* QTABPLOT_H_ */

View File

@ -0,0 +1,54 @@
/*
* qTabSettings.h
*
* Created on: May 10, 2012
* Author: l_maliakal_d
*/
#ifndef QTABSETTINGS_H_
#define QTABSETTINGS_H_
/** Form Header */
#include "ui_form_tab_settings.h"
/** Project Class Headers */
class slsDetectorUtils;
/**
*@short sets up the Settings parameters
*/
class qTabSettings:public QWidget, private Ui::TabSettingsObject{
Q_OBJECT
public:
/** \short The constructor
* @param parent is the parent tab widget
* @param detector is the detector returned from the detector tab
*/
qTabSettings(QWidget *parent,slsDetectorUtils*& detector);
/** Destructor
*/
~qTabSettings();
private:
/** The sls detector object */
slsDetectorUtils *myDet;
/** Sets up the widget
*/
void SetupWidgetWindow();
/** Sets up all the slots and signals
*/
void Initialization();
/** Enables/Disables all the widgets
*/
void Enable(bool enable);
};
#endif /* QTABSETTINGS_H_ */