diff --git a/slsDetectorGui/forms/form_detectormain.ui b/slsDetectorGui/forms/form_detectormain.ui index aec8c9c4a..7ded9699e 100644 --- a/slsDetectorGui/forms/form_detectormain.ui +++ b/slsDetectorGui/forms/form_detectormain.ui @@ -200,10 +200,26 @@ Sans Serif 11 - 75 - true + 50 + false + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<table border="0" style="-qt-table-type: root; margin-top:4px; margin-bottom:4px; margin-left:4px; margin-right:4px;"> +<tr> +<td style="border: none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#00007f;">Left Click :zoom in</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#00007f;">Righ</span><span style=" color:#00007f;">t Click </span><span style=" color:#00007f;">: zoom out by 1</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#00007f;">Middle Click : panning</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#00007f;">Ctrl+Right Click : zoom out to full size</span></p></td></tr></table></body></html> + + + + QDockWidget::NoDockWidgetFeatures @@ -275,8 +291,8 @@ 9 - 75 - true + 50 + false diff --git a/slsDetectorGui/forms/form_tab_measurement.ui b/slsDetectorGui/forms/form_tab_measurement.ui index 34f62b022..106f1831b 100644 --- a/slsDetectorGui/forms/form_tab_measurement.ui +++ b/slsDetectorGui/forms/form_tab_measurement.ui @@ -229,7 +229,7 @@ Qt::NoFocus - Starts Acquisition + Starts or Stops Acquisition Start diff --git a/slsDetectorGui/forms/form_tab_plot.ui b/slsDetectorGui/forms/form_tab_plot.ui index ae96c559c..1f8f3ba8d 100644 --- a/slsDetectorGui/forms/form_tab_plot.ui +++ b/slsDetectorGui/forms/form_tab_plot.ui @@ -37,7 +37,7 @@ 10 135 751 - 141 + 136 @@ -62,44 +62,284 @@ QLayout::SetNoConstraint - - + + 0 + + + - X Axis: + Title: - - + + + + + + + true + - - 2 + + 0 0 + + + 50 + 0 + + + + + + + + + 0 + 0 + + + + Z Max: + + + + + + + + 0 + 0 + + + + + 50 + 0 + + + + + + + + + 0 + 0 + + + + Y Max: + + + + + + + + 0 + 0 + + + + X Max: + + + + + + + + 0 + 0 + + + + + 50 + 0 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + Z Min: + + + + + + + + 0 + 0 + + + + + 50 + 0 + + - + 0 0 - X min: + X Min: + + + 0 + 0 + + + + + 50 + 0 + + + + Qt::ImhDigitsOnly + + + + + 0 0 + + Y Min: + + + + + + + + 0 + 0 + + + + + 50 + 0 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + X Axis: + + + + + + + + 0 + 0 + + + + + 250 + 0 + + + + Qt::ImhDigitsOnly + + + + + + + + 0 + 0 + + + + Y Axis: + + + + + + + + 0 + 0 + + 20 @@ -111,113 +351,23 @@ - - - - X max: - - - - - - - - 0 - 0 - - - - - - - - Y Axis: - - - - - - - - 2 - 0 - - - - - - - - - 0 - 0 - - - - Y min: - - - - - + + 0 0 - - - 20 - 0 - - - - - - - - Y max: - - - - - - - - 0 - 0 - - - - - - Z Axis: - - - - - + + - - 0 - 0 - - - - Z min: - - - - - - - + 0 0 @@ -228,64 +378,18 @@ 0 - - - - - - true - - - Z max: + + Qt::ImhDigitsOnly - - - - true - - - - 0 - 0 - - - - - 0 - 0 - - - - - - - - Qt::Horizontal - - - - 20 - 20 - - - - - - - - Title: - - - - - - + + true + 150 @@ -308,7 +412,7 @@ 10 20 - 451 + 496 22 @@ -380,124 +484,6 @@ 46 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - - - 183 - 183 - 183 - - - - - - - 171 - 171 - 171 - - - - - - - 179 - 179 - 179 - - - - - - - 154 - 154 - 154 - - - - - - 1D Plot Options @@ -512,74 +498,23 @@ 10 20 - 371 - 21 + 254 + 23 - + Superimpose - - - - - - - 0 - 0 - - - - Qt::NoFocus - - - Clear - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 10 - - - - - - - + false - - - 0 - 0 - - - - 1 - - - 10 - - - 1 - - + false @@ -604,24 +539,74 @@ - - - - Qt::Horizontal + + + + false - - QSizePolicy::Fixed + + + 0 + 0 + - + - 10 - 10 + 60 + 16777215 - + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 1 + + + 10 + + + 1 + + + + + + 420 + 12 + 40 + 28 + + + + + 0 + 0 + + + + + 40 + 16777215 + + + + Qt::NoFocus + + + Clear + + + true + + + gridLayoutWidget_3 + btnClear + btnClear + btnClear @@ -671,51 +656,21 @@ true - - - .gif - - - - - .pdf - - .png - - - .gif+ - - .jpg - - - .ps - - - - - .eps - - .xpm - - - .C - - @@ -762,7 +717,7 @@ 655 10 106 - 101 + 106 @@ -779,8 +734,8 @@ 5 19 - 101 - 76 + 96 + 81 @@ -810,6 +765,9 @@ Create + + false + @@ -840,7 +798,7 @@ 10 10 106 - 101 + 106 @@ -856,14 +814,14 @@ 10 - 20 - 91 - 44 + 14 + 93 + 96 - + None @@ -876,6 +834,13 @@ + + + + Histogram + + + diff --git a/slsDetectorGui/include/qDetectorMain.h b/slsDetectorGui/include/qDetectorMain.h index de6fb44ce..f8f318896 100644 --- a/slsDetectorGui/include/qDetectorMain.h +++ b/slsDetectorGui/include/qDetectorMain.h @@ -77,6 +77,7 @@ private: enum {Measurement, Settings, DataOutput, Plot, Actions, Advanced, Debugging, Developer, NumberOfTabs }; QColor defaultTabColor; + QString zoomToolTip; /* Scroll Area for the tabs**/ QScrollArea *scroll[NumberOfTabs]; @@ -173,10 +174,12 @@ void About(); */ void ResizeMainWindow(bool b); -/** Enables/disables tabs depending on if acquisition is currently in progress - */ +/** Enables/disables tabs depending on if acquisition is currently in progress */ void EnableTabs(); +/** Set the tool tip of mouse controlled zooming depening on if its enabled/disabled*/ +void SetZoomToolTip(bool disable); + protected: void resizeEvent(QResizeEvent* event); diff --git a/slsDetectorGui/include/qDrawPlot.h b/slsDetectorGui/include/qDrawPlot.h index 910e893b4..c66389660 100644 --- a/slsDetectorGui/include/qDrawPlot.h +++ b/slsDetectorGui/include/qDrawPlot.h @@ -10,8 +10,9 @@ /** Project Class Headers */ class slsDetectorUtils; +#include "detectorData.h" /** Qt Project Class Headers */ -class SlsQtH1D; +#include "SlsQt1DPlot.h" class SlsQt1DPlot; class SlsQt2DPlotLayout; class qCloneWidget; @@ -60,19 +61,27 @@ public: /** 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; - /** Number of Measurements */ - int numberOfMeasurements; - /** Number of Exposures */ - int number_of_exposures; - /** Duration between Exposures */ - double framePeriod; - /** Acquisition Time */ - double acquisitionTime; /** Widgets needed to plot the clone */ /** Max Number of Clone Windows */ @@ -97,17 +106,26 @@ private: 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; /** */ - pthread_mutex_t last_image_complete_mutex; + static pthread_mutex_t last_image_complete_mutex; /**variables for histograms */ - /** 1D or 2D */ - unsigned int plot_in_scope; - /** Current Image Number */ - unsigned int lastImageNumber; /** Title in 2D */ std::string imageTitle; /** X Axis Title in 2D */ @@ -116,26 +134,40 @@ private: QString imageYAxisTitle; /** Z Axis Title in 2D */ QString imageZAxisTitle; - /** Number of Pixels in X Axis */ - unsigned int nPixelsX; - /** Number of Pixels in Y Axis */ - unsigned int nPixelsY; - /** Current Image Values in 1D */ - double* lastImageArray; - /** Number of graphs in 1D */ - unsigned int nHists; /** Title for all the graphs in 1D */ - std::string histTitle[MAX_1DPLOTS]; + 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 */ - int histNBins; + static int histNBins; /** X Axis value in 1D */ - double* histXAxis; + static double* histXAxis; /** Y Axis value in 1D */ - double* histYAxis[MAX_1DPLOTS]; + 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; /** */ @@ -168,10 +200,12 @@ private: /**acquisition thread stuff */ /** */ bool StartOrStopThread(bool start); + /** */ - static void* DataAcquisionThread(void *this_pointer); + static void* DataStartAcquireThread(void *this_pointer); + /** */ - void* AcquireImages(); + static int GetDataCallBack(detectorData *data); public slots: @@ -210,6 +244,14 @@ void CloseClones(); * */ void SavePlot(QString FName); +/** Sets persistency from plot tab */ +void SetPersistency(int val); + +/** Enables plot */ +void EnablePlot(bool enable); + + + private slots: /** To update plot */ @@ -228,6 +270,8 @@ void StartDaq(bool start); * @param id is the id of the clone */ void CloneCloseEvent(int id); + + signals: void UpdatingPlotFinished(); @@ -236,6 +280,7 @@ void ContourSignal(bool); void LogzSignal(bool); + }; diff --git a/slsDetectorGui/include/qTabMeasurement.h b/slsDetectorGui/include/qTabMeasurement.h index a2084615c..082fe62e7 100644 --- a/slsDetectorGui/include/qTabMeasurement.h +++ b/slsDetectorGui/include/qTabMeasurement.h @@ -46,7 +46,7 @@ private: enum{None, Auto, Gated, Trigger_Exp_Series, Trigger_Frame, Trigger_Readout, Gated_Start, Trigger_Window, NumTimingModes}; - + QTimer *progressTimer; /** methods */ /** Sets up the widget @@ -132,6 +132,9 @@ void setNumGates(int val); */ void setNumProbes(int val); +/** Update progress*/ +void UpdateProgress(); + signals: void StartSignal(); diff --git a/slsDetectorGui/include/qTabPlot.h b/slsDetectorGui/include/qTabPlot.h index 9ba147f72..84c206201 100644 --- a/slsDetectorGui/include/qTabPlot.h +++ b/slsDetectorGui/include/qTabPlot.h @@ -49,7 +49,6 @@ private: static QString defaultImageYAxisTitle; static QString defaultImageZAxisTitle; - /** methods */ /** Sets up the widget */ @@ -65,6 +64,8 @@ private: + + public slots: @@ -77,20 +78,24 @@ private slots: */ void Select1DPlot(bool b); -/**Sets the titles in plot axis - */ +/**Enables Persistency depending on Superimpose checkbox */ +void EnablePersistency(bool enable); + +/**Sets the titles in plot axis */ void SetTitles(); - -/** Enables/Sets Titles to default - */ +/** Enables/Sets default Titles to default */ void EnableTitles(); +/** Enables range of the axes */ +void EnableRange(); +/** Sets the range of the axes */ +void SetAxesRange(); -/** Save Plot - */ +/** Save Plot */ void SavePlot(); -signals: +signals: +void DisableZoomSignal(bool); }; diff --git a/slsDetectorGui/slsDetectorPlotting/include/SlsQt1DPlot.h b/slsDetectorGui/slsDetectorPlotting/include/SlsQt1DPlot.h index 43dc7781c..262322f7c 100644 --- a/slsDetectorGui/slsDetectorPlotting/include/SlsQt1DPlot.h +++ b/slsDetectorGui/slsDetectorPlotting/include/SlsQt1DPlot.h @@ -10,7 +10,7 @@ #include #include #include - +#include #include "SlsQt1DZoomer.h" class QPen; @@ -104,6 +104,15 @@ class SlsQt1DPlot:public QwtPlot{ void InsertVLine(double v); void RemoveVLine(); + void DisableZoom(bool disableZoom); + + void SetXAxisScale(double min,double max){setAxisScale(QwtPlot::xBottom,min,max);}; + void SetYAxisScale(double min,double max){setAxisScale(QwtPlot::yLeft,min,max);}; + double GetXAxisLowerBound(){return axisScaleDiv(QwtPlot::xBottom)->lowerBound();}; + double GetXAxisUpperBound(){return axisScaleDiv(QwtPlot::xBottom)->upperBound();}; + double GetYAxisLowerBound(){return axisScaleDiv(QwtPlot::yLeft)->lowerBound();}; + double GetYAxisUpperBound(){return axisScaleDiv(QwtPlot::yLeft)->upperBound(); }; + void SetZoom(double xmin,double ymin,double x_width,double y_width); void SetZoomBase(double xmin,double ymin,double x_width, double y_width){ zoomer->SetZoomBase(xmin,ymin,x_width,y_width);} diff --git a/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cxx b/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cxx index d4c355c88..b8ece1400 100644 --- a/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cxx +++ b/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cxx @@ -52,9 +52,22 @@ int SlsQtH1D::SetLineColor(int c){ static int last_color = 1; if(c<0) c=(last_color+1)%3; - if(c==0) pen_ptr->setColor(Qt::black); + switch(c){ + case 0: pen_ptr->setColor(Qt::black); break; + case 1: pen_ptr->setColor(Qt::red); break; + case 2: pen_ptr->setColor(Qt::blue); break; + case 3: pen_ptr->setColor(Qt::green); break; + case 4: pen_ptr->setColor(Qt::magenta); break; + case 5: pen_ptr->setColor(Qt::cyan); break; + case 6: pen_ptr->setColor(Qt::darkYellow); break; + case 7: pen_ptr->setColor(Qt::gray); break; + case 8: pen_ptr->setColor(Qt::darkBlue); break; + case 9: pen_ptr->setColor(Qt::darkGreen); break; + case 10: pen_ptr->setColor(Qt::darkMagenta); break; + } +/* if(c==0) pen_ptr->setColor(Qt::black); else if(c==1) pen_ptr->setColor(Qt::red); - else pen_ptr->setColor(Qt::blue); + else pen_ptr->setColor(Qt::blue);*/ setPen(*pen_ptr); @@ -281,7 +294,8 @@ void SlsQt1DPlot::CalculateNResetZoomBase(){ void SlsQt1DPlot::NewHistogramAttached(SlsQtH1D* h){ hist_list->Add(h); CalculateNResetZoomBase(); - if(!hist_list->Next()) UnZoom(); + //commented out by dhanya to take off zooming every hist in 1d plots + //if(!hist_list->Next()) UnZoom(); Update(); } @@ -300,10 +314,14 @@ void SlsQt1DPlot::SetTitle(const char* title){ } void SlsQt1DPlot::SetXTitle(const char* title){ - setAxisTitle(QwtPlot::xBottom,title); + QwtText t(title); + t.setFont(QFont("Sans Serif",11,QFont::Normal)); + setAxisTitle(QwtPlot::xBottom,t); } void SlsQt1DPlot::SetYTitle(const char* title){ - setAxisTitle(QwtPlot::yLeft,title); + QwtText t(title); + t.setFont(QFont("Sans Serif",11,QFont::Normal)); + setAxisTitle(QwtPlot::yLeft,t); } void SlsQt1DPlot::SetLogX(bool yes){ SetLog(QwtPlot::xBottom,yes);} @@ -438,3 +456,37 @@ void SlsQt1DPlot::UnknownStuff(){ #endif } + +void SlsQt1DPlot::DisableZoom(bool disableZoom){ +#ifdef VERBOSE + if(disableZoom) cout<<"Disabling zoom"<setMousePattern(QwtEventPattern::MouseSelect1,Qt::NoButton); +#if QT_VERSION < 0x040000 + zoomer->setMousePattern(QwtEventPattern::MouseSelect2,Qt::NoButton, Qt::ControlButton); +#else + 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); +#if QT_VERSION < 0x040000 + zoomer->setMousePattern(QwtEventPattern::MouseSelect2,Qt::RightButton, Qt::ControlButton); +#else + zoomer->setMousePattern(QwtEventPattern::MouseSelect2,Qt::RightButton, Qt::ControlModifier); +#endif + zoomer->setMousePattern(QwtEventPattern::MouseSelect3,Qt::RightButton); + } + if(panner) panner->setMouseButton(Qt::MidButton); + } +} + + + + diff --git a/slsDetectorGui/src/qCloneWidget.cpp b/slsDetectorGui/src/qCloneWidget.cpp index 7903d4950..941aa9b39 100644 --- a/slsDetectorGui/src/qCloneWidget.cpp +++ b/slsDetectorGui/src/qCloneWidget.cpp @@ -141,7 +141,7 @@ for(int hist_num=0;hist_numsetTitle(histTitle[hist_num].c_str()); k->Attach(cloneplot1D); } -cloneplot1D->UnZoom(); +//cloneplot1D->UnZoom(); } diff --git a/slsDetectorGui/src/qDetectorMain.cpp b/slsDetectorGui/src/qDetectorMain.cpp index 640456d64..e1347fd16 100644 --- a/slsDetectorGui/src/qDetectorMain.cpp +++ b/slsDetectorGui/src/qDetectorMain.cpp @@ -169,7 +169,7 @@ void qDetectorMain::Initialization(){ connect(tabs,SIGNAL(currentChanged(int)),this, SLOT(refresh(int)));//( QWidget*))); /** Measurement tab*/ /** Plot tab */ - + connect(tab_plot,SIGNAL(DisableZoomSignal(bool)),this, SLOT(SetZoomToolTip(bool))); /** Plotting */ /** When the acquisition is finished, must update the meas tab */ @@ -202,6 +202,7 @@ void qDetectorMain::Initialization(){ heightCentralWidget = centralwidget->size().height(); defaultTabColor = tabs->tabBar()->tabTextColor(DataOutput); + zoomToolTip = dockWidgetPlot->toolTip(); } @@ -364,8 +365,11 @@ void qDetectorMain::resizeEvent(QResizeEvent* event){ void qDetectorMain::EnableTabs(){ +#ifdef VERBOSE + cout<<"Entering EnableTabs function"<isTabEnabled(DataOutput)?false:true); + enable=!(tabs->isTabEnabled(DataOutput)); // or use the Enable/Disable button /** normal tabs*/ @@ -389,3 +393,12 @@ void qDetectorMain::EnableTabs(){ tabs->setTabEnabled(Developer,enable); } } + + + +void qDetectorMain::SetZoomToolTip(bool disable){ + if(disable) + dockWidgetPlot->setToolTip("To Enable mouse-controlled zooming capabilities,\ndisable min and max for all axes. "); + else + dockWidgetPlot->setToolTip(zoomToolTip); +} diff --git a/slsDetectorGui/src/qDrawPlot.cpp b/slsDetectorGui/src/qDrawPlot.cpp index 954f5b3c1..18d70f5b2 100644 --- a/slsDetectorGui/src/qDrawPlot.cpp +++ b/slsDetectorGui/src/qDrawPlot.cpp @@ -7,11 +7,11 @@ /** Qt Project Class Headers */ #include "qDrawPlot.h" #include "qCloneWidget.h" -#include "SlsQt1DPlot.h" #include "SlsQt2DPlotLayout.h" /** Project Class Headers */ #include "slsDetector.h" #include "multiSlsDetector.h" +#include "postProcessing.h" /** Qt Include Headers */ #include #include @@ -19,12 +19,41 @@ /** C++ Include Headers */ #include #include +#include using namespace std; #define Detector_Index 0 + + +//int numberOfMeasurements; +int qDrawPlot::currentFrame; +int qDrawPlot::number_of_exposures; +//double framePeriod; +//double acquisitionTime; +pthread_mutex_t qDrawPlot::last_image_complete_mutex; +//std::string imageTitle; +std::string qDrawPlot::histTitle[MAX_1DPLOTS]; +unsigned int qDrawPlot::plot_in_scope; +unsigned int qDrawPlot::nPixelsX; +unsigned int qDrawPlot::nPixelsY; +unsigned int qDrawPlot::lastImageNumber; +unsigned int qDrawPlot::nHists; +int qDrawPlot::histNBins; +double* qDrawPlot::histXAxis; +double* qDrawPlot::histYAxis[MAX_1DPLOTS]; +double* qDrawPlot::lastImageArray; +double* qDrawPlot::yvalues[MAX_1DPLOTS]; +double* qDrawPlot::image_data; +bool qDrawPlot::gui_acquisition_thread_running; +int qDrawPlot::persistency; +int qDrawPlot::currentPersistency; +int qDrawPlot::progress; +bool qDrawPlot::plotEnable; + + qDrawPlot::qDrawPlot(QWidget *parent,slsDetectorUtils*& detector):QWidget(parent),myDet(detector),numberOfMeasurements(1){ if(myDet) { SetupWidgetWindow(); @@ -52,40 +81,52 @@ void qDrawPlot::SetupWidgetWindow(){ #endif stop_signal = 0; pthread_mutex_init(&last_image_complete_mutex,NULL); - + gui_acquisition_thread_running = 0; + /** Default Plotting*/ plot_in_scope = 0; + /**2d*/ lastImageNumber = 0; - nPixelsX = 0; - nPixelsY = 0; - lastImageArray = 0; + + nPixelsX = 1280; nPixelsY = 100; + + lastImageArray = 0; + image_data = 0; + /**1d*/ nHists = 0; histNBins = 0; histXAxis = 0; - for(int i=0;isetLayout(layout); - + this->setLayout(layout); boxPlot = new QGroupBox("Measurement"); - layout->addWidget(boxPlot,1,1); - boxPlot->setAlignment(Qt::AlignHCenter); - boxPlot->setFont(QFont("Sans Serif",11,QFont::Bold)); - + layout->addWidget(boxPlot,1,1); + boxPlot->setAlignment(Qt::AlignHCenter); + boxPlot->setFont(QFont("Sans Serif",11,QFont::Normal)); plot_update_timer = new QTimer(this); connect(plot_update_timer, SIGNAL(timeout()), this, SLOT(UpdatePlot())); - /** Defaults - only for the initial picture*/ + /** Default titles- only for the initial picture*/ histXAxisTitle="Channel Number"; histYAxisTitle="Counts"; - for(int i=0;isetFont(QFont("Sans Serif",9,QFont::Normal)); - plot1D->SetXTitle(histXAxisTitle.toAscii().constData()); - plot1D->SetYTitle(histYAxisTitle.toAscii().constData()); - plot1D->hide(); + plot1D->setFont(QFont("Sans Serif",9,QFont::Normal)); + plot1D->SetXTitle(histXAxisTitle.toAscii().constData()); + plot1D->SetYTitle(histYAxisTitle.toAscii().constData()); + plot1D->hide(); plot2D = new SlsQt2DPlotLayout(boxPlot); - plot2D->setFont(QFont("Sans Serif",9,QFont::Normal)); - plot2D->setTitle(GetImageTitle()); - plot2D->SetXTitle(imageXAxisTitle); - plot2D->SetYTitle(imageYAxisTitle); - plot2D->SetZTitle(imageZAxisTitle); - plot2D->setAlignment(Qt::AlignLeft); + plot2D->setFont(QFont("Sans Serif",9,QFont::Normal)); + plot2D->setTitle(GetImageTitle()); + plot2D->SetXTitle(imageXAxisTitle); + plot2D->SetYTitle(imageYAxisTitle); + plot2D->SetZTitle(imageZAxisTitle); + plot2D->setAlignment(Qt::AlignLeft); boxPlot->setFlat(true); - - //QSizePolicy sizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred); - //boxPlot->setSizePolicy(sizePolicy); + boxPlot->setContentsMargins(0,15,0,0); plotLayout = new QGridLayout(boxPlot); - plotLayout->addWidget(plot1D,1,1,1,1); - plotLayout->addWidget(plot2D,1,1,1,1); - - boxPlot->setContentsMargins(0,15,0,0); + plotLayout->addWidget(plot1D,1,1,1,1); + plotLayout->addWidget(plot2D,1,1,1,1); } @@ -188,8 +225,8 @@ int qDrawPlot::ResetDaqForGui(){ bool qDrawPlot::StartOrStopThread(bool start){ - static bool gui_acquisition_thread_running = 0; static pthread_t gui_acquisition_thread; + static pthread_t gui_start_acquire_thread; static pthread_mutex_t gui_acquisition_start_stop_mutex = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_lock(&gui_acquisition_start_stop_mutex); @@ -197,129 +234,112 @@ bool qDrawPlot::StartOrStopThread(bool start){ if(gui_acquisition_thread_running){ cout<<"Stopping current acquisition thread ...."<stopAcquisition(); + //pthread_join(gui_acquisition_thread,NULL); //wait until he's finished, ie. exits gui_acquisition_thread_running = 0; } //start part if(start){ + /** Defaults */ + currentFrame = 0; stop_signal = 0; + histNBins = nPixelsX; + if(!image_data) image_data = new double[nPixelsX*nPixelsY]; + if(!lastImageArray) lastImageArray = new double[nPixelsX*nPixelsY]; + if(!histXAxis) histXAxis = new double [nPixelsX]; + for(unsigned int px=0;pxacquire(1);//acquiring + /** Setting the callback function to get data from software client*/ + myDet->registerDataCallback(&(GetDataCallBack)); + /** Start acquiring data from server */ + pthread_create(&gui_start_acquire_thread, NULL,DataStartAcquireThread, (void*) this); + gui_acquisition_thread_running=1; + cout<<"Started acquiring"<AcquireImages(); +void* qDrawPlot::DataStartAcquireThread(void *this_pointer){ + ((qDrawPlot*)this_pointer)->myDet->acquire(1); return this_pointer; } +int qDrawPlot::GetDataCallBack(detectorData *data){ +#ifdef VERYVERBOSE + cout<<"Entering GetDataCallBack function"<progressIndex; -void* qDrawPlot::AcquireImages(){ - //send data to detector - - static unsigned int nx=1280,ny=100; - static double* image_data = new double[nx*ny]; - if(!lastImageArray) lastImageArray = new double[nx*ny]; - static double* xvalues = new double [nx]; - static double* yvalues0 = new double [nx]; - static double* yvalues1 = new double [nx]; - if(!histXAxis) histXAxis = new double [nx]; - if(!histYAxis[0]) histYAxis[0] = new double [nx]; - if(!histYAxis[1]) histYAxis[1] = new double [nx]; - - - -// char cIndex[200]; - - //string filePath = myDet->getFilePath()+'/'+myDet->getFileName()+'_'; - //cout<<"filePath:"<readDataFile(fileName,arg)==-1); - - - ///////// - - - //readout detector - //fill and write data here - for(unsigned int px=0;px0;i--) + memcpy(yvalues[i],yvalues[i-1],nPixelsX*sizeof(double)); + nHists = currentPersistency+1; + /** Get data from client */ + memcpy(yvalues[0],data->values,nPixelsX*sizeof(double)); + + /**1d*/ + // if(plot_in_scope==1){ + if((currentFrame)<(number_of_exposures)){ +#ifdef VERYVERBOSE + cout<<"Reading in image: "<0;i--) + memcpy(histYAxis[i],histYAxis[i-1],nPixelsX*sizeof(double)); + memcpy(histYAxis[0],yvalues[0],nPixelsX*sizeof(double)); + pthread_mutex_unlock(&(last_image_complete_mutex)); + } + + currentFrame++; + } + //} + ///**2d*/ + //else{ + // ; + //} + +#ifdef VERYVERBOSE + cout<<"Exiting GetDataCallBack function"<stop(); + if(plotEnable){ + LockLastImageArray(); + //1-d plot stuff + if(lastImageNumber){ + if(histNBins){ +#ifdef VERYVERBOSE + cout<<"Last Image Number: "<SetXTitle(histXAxisTitle.toAscii().constData()); + plot1D->SetYTitle(histYAxisTitle.toAscii().constData()); + for(int hist_num=0;hist_numplot1D_hists.size()){ + plot1D_hists.append(h=new SlsQtH1D("1d plot",histNBins,histXAxis,GetHistYAxis(hist_num))); + h->SetLineColor(hist_num+1); + }else{ + h=plot1D_hists.at(hist_num); + h->SetData(histNBins,histXAxis,GetHistYAxis(hist_num)); + } + h->setTitle(GetHistTitle(hist_num)); + h->Attach(plot1D); + + } + //plot1D->UnZoom(); + //if(first){plot1D->UnZoom();first = !first;} + //plot1D->SetZoom(double xmin,double ymin,double x_width,double y_width); - LockLastImageArray(); - //1-d plot stuff - if(histNBins){ - plot1D->SetXTitle(histXAxisTitle.toAscii().constData()); - plot1D->SetYTitle(histYAxisTitle.toAscii().constData()); - for(int hist_num=0;hist_numplot1D_hists.size()){ - plot1D_hists.append(h=new SlsQtH1D("1d plot",histNBins,histXAxis,GetHistYAxis(hist_num))); - h->SetLineColor(hist_num+1); - }else{ - h=plot1D_hists.at(hist_num); - h->SetData(histNBins,histXAxis,GetHistYAxis(hist_num)); } - h->setTitle(GetHistTitle(hist_num)); - h->Attach(plot1D); } - plot1D->UnZoom(); - } - //2-d plot stuff - static int last_plot_number = 0; - if(lastImageArray){ - if(lastImageNumber&&last_plot_number!=lastImageNumber && //there is a new plot - nPixelsX>0&&nPixelsY>0){ - plot2D->GetPlot()->SetData(nPixelsX,-0.5,nPixelsX-0.5,nPixelsY,-0.5,nPixelsY-0.5,lastImageArray); - //as it inherits a widget - plot2D->setTitle(GetImageTitle()); - plot2D->SetXTitle(imageXAxisTitle); - plot2D->SetYTitle(imageYAxisTitle); - plot2D->SetZTitle(imageZAxisTitle); - plot2D->UpdateNKeepSetRangeIfSet(); //this will keep a "set" z range, and call Plot()->Update(); + //2-d plot stuff + if(lastImageArray){ + if(lastImageNumber&&last_plot_number!=lastImageNumber && //there is a new plot + nPixelsX>0&&nPixelsY>0){ + plot2D->GetPlot()->SetData(nPixelsX,-0.5,nPixelsX-0.5,nPixelsY,-0.5,nPixelsY-0.5,lastImageArray); + //as it inherits a widget + plot2D->setTitle(GetImageTitle()); + plot2D->SetXTitle(imageXAxisTitle); + plot2D->SetYTitle(imageYAxisTitle); + plot2D->SetZTitle(imageZAxisTitle); + plot2D->UpdateNKeepSetRangeIfSet(); //this will keep a "set" z range, and call Plot()->Update(); + } } } last_plot_number=lastImageNumber; - UnlockLastImageArray(); - -/* if(plot_in_scope==1) SelectPlot(1); + if(plotEnable) UnlockLastImageArray(); + /* if(plot_in_scope==1) SelectPlot(1); else if(plot_in_scope==2) SelectPlot(2);*/ if(number_of_exposures==last_plot_number){ + gui_acquisition_thread_running=0; StartStopDaqToggle(1); emit UpdatingPlotFinished(); }else{ @@ -498,3 +529,24 @@ void qDrawPlot::SavePlot(QString FName){ render(&painter); img.save(FName); } + + + +void qDrawPlot::EnablePlot(bool enable){ +#ifdef VERBOSE + cout<<"Plotting set to:"<DisableZoom(disable); +///disable zoom + +} diff --git a/slsDetectorGui/src/qTabMeasurement.cpp b/slsDetectorGui/src/qTabMeasurement.cpp index 39d86fbf0..170a8127d 100644 --- a/slsDetectorGui/src/qTabMeasurement.cpp +++ b/slsDetectorGui/src/qTabMeasurement.cpp @@ -48,6 +48,8 @@ qTabMeasurement::~qTabMeasurement(){ void qTabMeasurement::SetupWidgetWindow(){ + progressTimer = new QTimer(this); + //btnStartStop->setStyleSheet("color:green"); /** Exp Time **/ float time = (float)(myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,-1)*(1E-9)); spinExpTime->setValue(time); @@ -106,7 +108,7 @@ void qTabMeasurement::SetupWidgetWindow(){ } } - + progressBar->setValue(0); //get timing mode from client @@ -127,6 +129,8 @@ void qTabMeasurement::Initialization(int timingChange){ connect(btnStartStop,SIGNAL(clicked()), this, SLOT(startStopAcquisition())); /** Timing Mode **/ connect(comboTimingMode,SIGNAL(currentIndexChanged(int)), this, SLOT(setTimingMode(int)));// + + connect(progressTimer, SIGNAL(timeout()), this, SLOT(UpdateProgress())); } /** Number of Frames**/ connect(spinNumFrames,SIGNAL(valueChanged(int)), this, SLOT(setNumFrames(int))); @@ -189,15 +193,17 @@ void qTabMeasurement::Enable(bool enable){ void qTabMeasurement::UpdateFinished(){ disconnect(btnStartStop,SIGNAL(clicked()),this,SLOT(startStopAcquisition())); btnStartStop->setText("Start"); + //btnStartStop->setStyleSheet("color:green"); + //btnStartStop->setStyleSheet("background:rgb(239,239,239)"); Enable(1); connect(btnStartStop,SIGNAL(clicked()),this,SLOT(startStopAcquisition())); + UpdateProgress(); + progressTimer->stop(); } void qTabMeasurement::setFileName(const QString& fName){ - // emit fileNameChanged(fName); - // thred-->fileName=s;myDet->setFileName(fName.ascii()); myDet->setFileName(fName.toAscii().data()); #ifdef VERBOSE cout<<"Setting File name to " << myDet->getFileName()<setFileIndex(index); + lblProgressIndex->setText(QString::number(index)); #ifdef VERBOSE cout<<"Setting File Index to " << myDet->getFileIndex()<setStyleSheet("color:red"); btnStartStop->setText("Stop"); Enable(0); + progressBar->setValue(0); + progressTimer->start(200); + emit StartSignal(); }else{ #ifdef VERBOSE cout<<"Stopping Acquisition"<setStyleSheet("color:green"); + //btnStartStop->setStyleSheet("background:rgb(239,239,239)"); + progressTimer->stop(); btnStartStop->setText("Start"); Enable(1); emit StopSignal(); @@ -270,8 +284,6 @@ void qTabMeasurement::setExposureTime(){ lblPeriod->setText("Acquisition Period"); } } - //float t=exptimeNS; - //emit acquisitionTimeChanged(t/(100E+6)); ?????????????????????? } @@ -297,10 +309,6 @@ void qTabMeasurement::setAcquisitionPeriod(){ lblPeriod->setPalette(lblNumFrames->palette()); lblPeriod->setText("Acquisition Period"); } - - - //float t=exptimeNS; - //emit acquisitionTimeChanged(t/(100E+6)); ?????????????????????? } @@ -348,6 +356,12 @@ void qTabMeasurement::setNumProbes(int val){ } +void qTabMeasurement::UpdateProgress(){ + progressBar->setValue(myPlot->GetProgress()); + lblProgressIndex->setText(QString::number(myDet->getFileIndex())); +} + + void qTabMeasurement::setTimingMode(int mode){ diff --git a/slsDetectorGui/src/qTabPlot.cpp b/slsDetectorGui/src/qTabPlot.cpp index f1393b91b..e8d9c2081 100644 --- a/slsDetectorGui/src/qTabPlot.cpp +++ b/slsDetectorGui/src/qTabPlot.cpp @@ -36,6 +36,7 @@ qTabPlot::qTabPlot(QWidget *parent,slsDetectorUtils*& detector, qDrawPlot*& plot //This also selects the text if unchecked //includes setupwidgetwindow //SelectPlot(1); + //switch(myDet->detectorytype) Select1DPlot(true); Initialization(); } @@ -66,9 +67,12 @@ void qTabPlot::SetupWidgetWindow(){ dispXMax->setEnabled(false); dispYMax->setEnabled(false); dispZMax->setEnabled(false); - - //dispFName->setText(QString(myDet->getFilePath().c_str())+'/'); - +/* dispXMin->setValidator(new QDoubleValidator(dispXMin)); + dispYMin->setValidator(new QDoubleValidator(dispYMin)); + dispZMin->setValidator(new QDoubleValidator(dispZMin)); + dispXMax->setValidator(new QDoubleValidator(dispXMax)); + dispYMax->setValidator(new QDoubleValidator(dispYMax)); + dispZMax->setValidator(new QDoubleValidator(dispZMax));*/ } @@ -103,9 +107,14 @@ void qTabPlot::Select1DPlot(bool b){ void qTabPlot::Initialization(){ -/** Plot box*/ +/** Plot arguments box*/ + connect(chkNoPlot, SIGNAL(toggled(bool)),myPlot, SLOT(EnablePlot(bool))); +/** Snapshot box*/ connect(btnClone, SIGNAL(clicked()),myPlot, SLOT(ClonePlot())); connect(btnCloseClones, SIGNAL(clicked()),myPlot, SLOT(CloseClones())); +/** 1D Plot box*/ + connect(chkSuperimpose, SIGNAL(toggled(bool)),this, SLOT(EnablePersistency(bool))); + connect(spinPersistency,SIGNAL(valueChanged(int)),myPlot,SLOT(SetPersistency(int))); /** 2D Plot box*/ connect(chkInterpolate, SIGNAL(toggled(bool)),myPlot, SIGNAL(InterpolateSignal(bool))); connect(chkContour, SIGNAL(toggled(bool)),myPlot, SIGNAL(ContourSignal(bool))); @@ -119,13 +128,26 @@ void qTabPlot::Initialization(){ connect(dispXAxis, SIGNAL(textChanged(const QString&)), this, SLOT(SetTitles())); connect(dispYAxis, SIGNAL(textChanged(const QString&)), this, SLOT(SetTitles())); connect(dispZAxis, SIGNAL(textChanged(const QString&)), this, SLOT(SetTitles())); + + connect(chkXMin, SIGNAL(toggled(bool)), this, SLOT(EnableRange())); + connect(chkXMax, SIGNAL(toggled(bool)), this, SLOT(EnableRange())); + connect(chkYMin, SIGNAL(toggled(bool)), this, SLOT(EnableRange())); + connect(chkYMax, SIGNAL(toggled(bool)), this, SLOT(EnableRange())); + connect(chkZMin, SIGNAL(toggled(bool)), this, SLOT(EnableRange())); + connect(chkZMax, SIGNAL(toggled(bool)), this, SLOT(EnableRange())); + + connect(dispXMin, SIGNAL(returnPressed()), this, SLOT(SetAxesRange())); + connect(dispXMax, SIGNAL(returnPressed()), this, SLOT(SetAxesRange())); + connect(dispYMin, SIGNAL(returnPressed()), this, SLOT(SetAxesRange())); + connect(dispYMax, SIGNAL(returnPressed()), this, SLOT(SetAxesRange())); + connect(dispZMin, SIGNAL(returnPressed()), this, SLOT(SetAxesRange())); + connect(dispZMax, SIGNAL(returnPressed()), this, SLOT(SetAxesRange())); + /** Common Buttons*/ connect(btnClear, SIGNAL(clicked()), myPlot, SLOT(Clear1DPlot())); /** Save */ connect(btnSave, SIGNAL(clicked()), this, SLOT(SavePlot())); -/** test for 1D*/ - connect(chktest1D, SIGNAL(toggled(bool)), this, SLOT(Select1DPlot(bool))); } @@ -138,6 +160,16 @@ void qTabPlot::Enable(bool enable){ boxPlotAxis->setEnabled(enable); } +void qTabPlot::EnablePersistency(bool enable){ + lblPersistency->setEnabled(enable); + spinPersistency->setEnabled(enable); + if(enable) myPlot->SetPersistency(spinPersistency->value()); + else myPlot->SetPersistency(0); + +} + + + void qTabPlot::SetTitles(){ int oneD = box1D->isEnabled(); /** Plot Title*/ @@ -159,6 +191,7 @@ void qTabPlot::SetTitles(){ } + void qTabPlot::EnableTitles(){ int oneD = box1D->isEnabled(); /** Plot Title*/ @@ -199,7 +232,91 @@ void qTabPlot::EnableTitles(){ } + + +void qTabPlot::EnableRange(){ + bool disableZoom = false; + if(!chkXMin->isChecked()) {dispXMin->setText(""); dispXMin->setEnabled(false);} + else {disableZoom = true; dispXMin->setEnabled(true); } + if(!chkXMax->isChecked()) {dispXMax->setText(""); dispXMax->setEnabled(false);} + else {disableZoom = true; dispXMax->setEnabled(true); } + if(!chkYMin->isChecked()) {dispYMin->setText(""); dispYMin->setEnabled(false);} + else {disableZoom = true; dispYMin->setEnabled(true); } + if(!chkYMax->isChecked()) {dispYMax->setText(""); dispYMax->setEnabled(false);} + else {disableZoom = true; dispYMax->setEnabled(true); } + if(!chkZMin->isChecked()) {dispZMin->setText(""); dispZMin->setEnabled(false);} + else {disableZoom = true; dispZMin->setEnabled(true); } + if(!chkZMax->isChecked()) {dispZMax->setText(""); dispZMax->setEnabled(false);} + else {disableZoom = true; dispZMax->setEnabled(true); } + myPlot->DisableZoom(disableZoom); + emit DisableZoomSignal(disableZoom); +} + + + +void qTabPlot::SetAxesRange(){ + double xmin,xmax,ymin,ymax,zmin,zmax; + int oneD = box1D->isEnabled(); + //should be filled for 2d as well + if(!dispXMin->text().isEmpty()) xmin = dispXMin->text().toDouble(); + else { if(oneD) xmin = myPlot->GetHistXAxisLowerBound();} + if(!dispXMax->text().isEmpty()) xmax = dispXMax->text().toDouble(); + else { if(oneD) xmax = myPlot->GetHistXAxisUpperBound();} + if(!dispYMin->text().isEmpty()) ymin = dispYMin->text().toDouble(); + else { if(oneD) ymin = myPlot->GetHistYAxisLowerBound();} + if(!dispYMax->text().isEmpty()) ymax = dispYMax->text().toDouble(); + else { if(oneD) ymax = myPlot->GetHistYAxisUpperBound();} + if(!dispZMin->text().isEmpty()) zmin = dispZMin->text().toDouble(); + if(!dispZMax->text().isEmpty()) zmax = dispZMax->text().toDouble(); + //should be filled for 2d as well + if(oneD){ + myPlot->SetHistXAxisScale(xmin,xmax); + myPlot->SetHistYAxisScale(ymin,ymax); + } +} + + void qTabPlot::SavePlot(){ QString fullFileName = QString(myDet->getFilePath().c_str())+'/'+dispFName->text()+comboFormat->currentText(); myPlot->SavePlot(fullFileName); } + + + + + + +//dispzmin... when unchecked, unzoom and get lower and upper bound... when checked just set lower and upper bound + +/* + +#include "SlsQtValidators.h" + +class QDoubleValidator; +SlsQtDoubleValidator* validator_double[2]; + + + + +validator_double = new SlsQtDoubleValidator(num_field); +num_field->setValidator(validator_double); +//default settings +validator_double->setDecimals(3); +double v= num_field->text().toDouble(ok);); +is ok 1? for correct conversion + +QString s = QString::number(v); +validator_double->fixup(s); +num_field->setText(s); + + +num_field[i]->setAlignment(Qt::AlignRight); + + + +connect(num_field[i],SIGNAL(lostFocus()),this,SLOT(FirstValueEntered())); + +*/ + + +