From 69e65005224529104d51c7e7df577f33bec8fb2a Mon Sep 17 00:00:00 2001 From: l_maliakal_d Date: Tue, 19 Jun 2012 15:01:40 +0000 Subject: [PATCH] All the ranges of the axes work properly without zooming in and out each time git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@11 af1100a4-978c-4157-bff7-07162d2ba061 --- slsDetectorGui/forms/form_tab_measurement.ui | 12 +- slsDetectorGui/forms/form_tab_plot.ui | 6 +- slsDetectorGui/include/qDrawPlot.h | 186 +++++++---------- slsDetectorGui/include/qTabActions.h | 3 - slsDetectorGui/include/qTabDeveloper.h | 3 - slsDetectorGui/include/qTabMeasurement.h | 2 +- slsDetectorGui/include/qTabPlot.h | 10 +- slsDetectorGui/slsDetectorGui.pro | 1 + .../slsDetectorPlotting/include/SlsQt1DPlot.h | 28 ++- .../slsDetectorPlotting/include/SlsQt2DPlot.h | 20 +- .../include/SlsQt2DPlotLayout.h | 33 ++- .../slsDetectorPlotting/src/SlsQt1DPlot.cxx | 2 + .../slsDetectorPlotting/src/SlsQt2DHist.cxx | 1 - .../slsDetectorPlotting/src/SlsQt2DPlot.cxx | 40 +++- .../src/SlsQt2DPlotLayout.cxx | 190 +++++++++++++----- .../src/SlsQtNumberEntry.cxx | 6 +- slsDetectorGui/src/qDetectorMain.cpp | 3 +- slsDetectorGui/src/qDrawPlot.cpp | 124 +++++++----- slsDetectorGui/src/qTabActions.cpp | 8 - slsDetectorGui/src/qTabDeveloper.cpp | 6 - slsDetectorGui/src/qTabMeasurement.cpp | 102 +++++----- slsDetectorGui/src/qTabPlot.cpp | 147 ++++++-------- 22 files changed, 521 insertions(+), 412 deletions(-) diff --git a/slsDetectorGui/forms/form_tab_measurement.ui b/slsDetectorGui/forms/form_tab_measurement.ui index 106f1831b..dfc25baf8 100644 --- a/slsDetectorGui/forms/form_tab_measurement.ui +++ b/slsDetectorGui/forms/form_tab_measurement.ui @@ -520,12 +520,7 @@ - Gated - - - - - Trigger Exposure + Trigger Exposure Series @@ -538,6 +533,11 @@ Trigger Readout + + + Gated with Fixed Number + + Gated with Start Trigger diff --git a/slsDetectorGui/forms/form_tab_plot.ui b/slsDetectorGui/forms/form_tab_plot.ui index 1f8f3ba8d..f8b21cde4 100644 --- a/slsDetectorGui/forms/form_tab_plot.ui +++ b/slsDetectorGui/forms/form_tab_plot.ui @@ -37,7 +37,7 @@ 10 135 751 - 136 + 141 @@ -603,10 +603,6 @@ true - gridLayoutWidget_3 - btnClear - btnClear - btnClear diff --git a/slsDetectorGui/include/qDrawPlot.h b/slsDetectorGui/include/qDrawPlot.h index c66389660..10544e51e 100644 --- a/slsDetectorGui/include/qDrawPlot.h +++ b/slsDetectorGui/include/qDrawPlot.h @@ -13,6 +13,7 @@ class slsDetectorUtils; #include "detectorData.h" /** Qt Project Class Headers */ #include "SlsQt1DPlot.h" +#include "SlsQt2DPlotLayout.h" class SlsQt1DPlot; class SlsQt2DPlotLayout; class qCloneWidget; @@ -34,50 +35,51 @@ class qDrawPlot:public QWidget{ Q_OBJECT public: - /** \short The constructor - */ + /** \short The constructor */ qDrawPlot(QWidget *parent,slsDetectorUtils*& detector); - - /** Destructor - */ + /** Destructor */ ~qDrawPlot(); + /** Number of x axis pixels */ + int GetPixelsX(){return nPixelsX;}; + /** Number of y axis pixels */ + int GetPixelsY(){return nPixelsY;}; + /** 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;} + /** Sets X min and max */ + void SetXMinMax(double min,double max) {if(plot_in_scope==1)plot1D->SetXMinMax(min,max); else plot2D->GetPlot()->SetXMinMax(min,max);}; + /** Sets Y min and max */ + void SetYMinMax(double min,double max) {if(plot_in_scope==1)plot1D->SetYMinMax(min,max); else plot2D->GetPlot()->SetYMinMax(min,max);}; + /** Gets X min */ + double GetXMinimum(){if(plot_in_scope==1)return plot1D->GetXMinimum(); else return plot2D->GetPlot()->GetXMinimum();}; + /** Gets X max */ + double GetXMaximum(){if(plot_in_scope==1)return plot1D->GetXMaximum(); else return plot2D->GetPlot()->GetXMaximum();}; + /** Gets Y min */ + double GetYMinimum(){if(plot_in_scope==1)return plot1D->GetYMinimum(); else return plot2D->GetPlot()->GetYMinimum();}; + /** Gets Y max */ + double GetYMaximum(){if(plot_in_scope==1)return plot1D->GetYMaximum(); else return plot2D->GetPlot()->GetYMaximum();}; + /** 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;}; + + /** 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; @@ -97,7 +99,6 @@ private: QTimer* plot_update_timer; - /** 1D object */ SlsQt1DPlot* plot1D; /** 2D object */ @@ -106,7 +107,6 @@ private: QVector plot1D_hists; - /** Number of Measurements */ int numberOfMeasurements; /** currentFrame */ @@ -126,20 +126,20 @@ private: 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; + /** Title for all the graphs in 1D */ + static std::string histTitle[MAX_1DPLOTS]; + /** Title in 2D */ + static std::string imageTitle; /** 1D or 2D */ static unsigned int plot_in_scope; /** Number of Pixels in X Axis */ @@ -169,117 +169,85 @@ private: 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=0&&i=0&&i #include #include "SlsQt1DZoomer.h" +#include +using namespace std; class QPen; class SlsQt1DPlot; @@ -104,14 +112,18 @@ 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(); }; + /** This group of functions have been added by Dhanya on 19.06.2012 to be able to + use zooming functionality without mouse control*/ + void DisableZoom(bool disableZoom); + void SetXMinMax(double min,double max){setAxisScale(QwtPlot::xBottom,min,max);}; + void SetYMinMax(double min,double max){setAxisScale(QwtPlot::yLeft,min,max);}; + double GetXMinimum(){return hist_list->Hist()->GetXMin();}; + double GetXMaximum(){return hist_list->Hist()->GetXMax();}; + double GetYMinimum(){return hist_list->Hist()->GetYMin();}; + double GetYMaximum(){return hist_list->Hist()->GetYMax();}; + /**---*/ + 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/include/SlsQt2DPlot.h b/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlot.h index cc6db7ea3..f2a1eaf77 100644 --- a/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlot.h +++ b/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlot.h @@ -2,6 +2,12 @@ /** * @author Ian Johnson * @version 1.0 + * Modifications: + * 19.06.2012: {Some functions have been added by Dhanya to enable zooming in and out + * without using mouse control: + * DisableZoom, + * SetXMinMax,SetYMinMax, + * GetXMinimum,GetXMaximum,GetYMinimum,GetYMaximum} */ @@ -43,10 +49,22 @@ public: SlsQt2DPlot(QWidget * = NULL); // SlsQt2DHist *GetHistogram(){ return hist; } - void UnZoom(); void SetZoom(double xmin,double ymin,double x_width,double y_width); + + /** This group of functions have been added by Dhanya on 19.06.2012 to be able to + use zooming functionality without mouse control*/ + void DisableZoom(bool disableZoom); + void SetXMinMax(double min,double max){setAxisScale(QwtPlot::xBottom,min,max);}; + void SetYMinMax(double min,double max){setAxisScale(QwtPlot::yLeft,min,max);}; + double GetXMinimum(){return hist->GetXMin();}; + double GetXMaximum(){return hist->GetXMax();}; + double GetYMinimum(){return hist->GetYMin();}; + double GetYMaximum(){return hist->GetYMax();}; + /**---*/ + + double GetZMinimum(){ return hist->GetMinimum();} double GetZMaximum(){ return hist->GetMaximum();} void SetZMinMax(double zmin=0,double zmax=-1); diff --git a/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlotLayout.h b/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlotLayout.h index 1104daf3c..47c82bdae 100644 --- a/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlotLayout.h +++ b/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlotLayout.h @@ -1,6 +1,10 @@ /** * @author Ian Johnson * @version 1.0 + * @comments + * 19.06.2012 All modifications with the Ian flag has been made since + * z_range_ne and the buttons are defined in another class. + * Logz button and z_range_ne have wrappers to connect them */ @@ -15,7 +19,7 @@ class QGridLayout; class QString; - +class QToolButton; class SlsQt2DPlotLayout: public QGroupBox{ @@ -26,33 +30,42 @@ public: SlsQt2DPlotLayout(QWidget * = NULL); ~SlsQt2DPlotLayout(); - SlsQt2DPlot* GetPlot() {return the_plot;} + SlsQt2DPlot* GetPlot(){return the_plot;} void SetXTitle(QString st); void SetYTitle(QString st); void SetZTitle(QString st); + void UpdateNKeepSetRangeIfSet(); - void UpdateNKeepSetRangeIfSet(); private: - QGridLayout* the_layout; - SlsQt2DPlot* the_plot; + QGridLayout* the_layout; + QToolButton* btnInterpolate; + QToolButton* btnContour; + QToolButton* btnLogz; + SlsQt2DPlot* the_plot; + SlsQtNumberEntry* z_range_ne; - SlsQtNumberEntry* z_range_ne; - - bool logsChecked; +#ifndef IAN + bool zRangeChecked; +#endif + void CreateTheButtons(); void ConnectSignalsAndSlots(); - void Layout(); public slots: void SetZScaleToLog(bool yes); void ResetRange(); -void SetTitle(QString st); + +#ifndef IAN +void SetZRange(double,double); +void EnableZRange(bool enable); +#endif signals: void InterpolateSignal(bool); void ContourSignal(bool); + }; #endif diff --git a/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cxx b/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cxx index b8ece1400..0fd8af9c7 100644 --- a/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cxx +++ b/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cxx @@ -457,6 +457,8 @@ void SlsQt1DPlot::UnknownStuff(){ } + +//Added by Dhanya on 19.06.2012 to disable zooming when any of the axes range has been set void SlsQt1DPlot::DisableZoom(bool disableZoom){ #ifdef VERBOSE if(disableZoom) cout<<"Disabling zoom"<setTrackerPen(c); } +/*void SlsQt2DPlot::CompletelyUnZoom(){ + setAxisScale(QwtPlot::xBottom,hist->GetXMin(),hist->GetXMin()+(hist->GetXMax()-hist->GetXMin())); + setAxisScale(QwtPlot::yLeft,hist->GetYMin(),hist->GetYMin()+(hist->GetYMax()-hist->GetYMin())); + zoomer->setZoomBase(); + //replot(); +}*/ + void SlsQt2DPlot::UnZoom(){ - zoomer->setZoomBase(QwtDoubleRect(hist->GetXMin(),hist->GetYMin(),hist->GetXMax()-hist->GetXMin(),hist->GetYMax()-hist->GetYMin())); zoomer->setZoomBase();//Call replot for the attached plot before initializing the zoomer with its scales. @@ -147,7 +153,7 @@ void SlsQt2DPlot::SetZMinMax(double zmin,double zmax){ void SlsQt2DPlot::Update(){ - rightAxis->setColorMap(d_spectrogram->data().range(),d_spectrogram->colorMap()); + rightAxis->setColorMap(d_spectrogram->data().range(),d_spectrogram->colorMap()); if(!zoomer->zoomRectIndex()) UnZoom(); setAxisScale(QwtPlot::yRight,d_spectrogram->data().range().minValue(), d_spectrogram->data().range().maxValue()); @@ -190,6 +196,36 @@ void SlsQt2DPlot::LogZ(bool on){ } +//Added by Dhanya on 19.06.2012 to disable zooming when any of the axes range has been set +void SlsQt2DPlot::DisableZoom(bool disableZoom){ +#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/slsDetectorPlotting/src/SlsQt2DPlotLayout.cxx b/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlotLayout.cxx index 032ac27bb..65c6e6725 100644 --- a/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlotLayout.cxx +++ b/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlotLayout.cxx @@ -6,7 +6,7 @@ #include - +#include #include #include #include @@ -17,96 +17,180 @@ using namespace std; SlsQt2DPlotLayout::SlsQt2DPlotLayout(QWidget *parent):QGroupBox(parent){ - the_layout=0; - the_plot = new SlsQt2DPlot(this); + the_layout=0; + the_plot = new SlsQt2DPlot(this); - z_range_ne = new SlsQtNumberEntry(this,1,"Set the z axis range from",2,"to",2); - // z_range_ne->SetNDecimalsOfDoubleValidators(2); - z_range_ne->setFixedWidth(402); - z_range_ne->hide(); + z_range_ne = new SlsQtNumberEntry(this,1,"Set the z axis range from",2,"to",2); + z_range_ne->setFixedWidth(402); +#ifndef IAN + zRangeChecked = false; + z_range_ne->hide(); +#endif - logsChecked = false; - - Layout(); - ConnectSignalsAndSlots(); + CreateTheButtons(); + Layout(); + ConnectSignalsAndSlots(); } SlsQt2DPlotLayout::~SlsQt2DPlotLayout(){ - if(the_layout) delete the_layout; + if(the_layout) delete the_layout; - delete the_plot; - delete z_range_ne; + delete the_plot; + delete z_range_ne; +} + + +void SlsQt2DPlotLayout::CreateTheButtons(){ + /** Dhanya: All these buttons are already in another class, logz is used and a wrapper around it*/ +#ifdef IAN + btnInterpolate = new QToolButton(this); + btnInterpolate->setText("Interpolate"); + btnInterpolate->setCheckable(true); + btnInterpolate->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); + + btnContour = new QToolButton(this); + btnContour->setText("Contour"); + btnContour->setCheckable(true); + btnContour->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); +#endif + btnLogz = new QToolButton(this); + btnLogz->setText("Log Scale (Z)"); + btnLogz->setCheckable(true); + btnLogz->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); +#ifndef IAN + btnLogz->hide(); +#endif } void SlsQt2DPlotLayout::Layout(){ - if(the_layout) delete the_layout; - the_layout = new QGridLayout(this); - the_layout->addWidget(the_plot,2,1,3,3); - the_layout->addWidget(z_range_ne,5,1,1,3); + if(the_layout) delete the_layout; + the_layout = new QGridLayout(this); +#ifdef IAN + the_layout->addWidget(btnInterpolate,1,1); + the_layout->addWidget(btnContour,1,2); + the_layout->addWidget(btnLogz,1,3); +#endif + the_layout->addWidget(the_plot,2,1,3,3); + the_layout->addWidget(z_range_ne,5,1,1,3); +#ifdef IAN + the_layout->setMargin(12); +#endif } void SlsQt2DPlotLayout::ConnectSignalsAndSlots(){ +#ifndef IAN connect(this, SIGNAL(InterpolateSignal(bool)), the_plot, SLOT(InterpolatedPlot(bool))); connect(this, SIGNAL(ContourSignal(bool)), the_plot, SLOT(showContour(bool))); - connect(z_range_ne, SIGNAL(CheckBoxChanged(bool)), this, SLOT(ResetRange())); - connect(z_range_ne, SIGNAL(AValueChanged(SlsQtNumberEntry*)), this, SLOT(ResetRange())); - +#else + connect(btnInterpolate, SIGNAL(toggled(bool)),the_plot, SLOT(InterpolatedPlot(bool))); + connect(btnContour, SIGNAL(toggled(bool)),the_plot, SLOT(showContour(bool))); + connect(btnLogz, SIGNAL(toggled(bool)),this,SLOT(SetZScaleToLog(bool))); + btnInterpolate->setChecked(false); + btnContour->setChecked(false); +#endif + connect(z_range_ne, SIGNAL(CheckBoxChanged(bool)), this, SLOT(ResetRange())); + connect(z_range_ne, SIGNAL(AValueChanged(SlsQtNumberEntry*)), this, SLOT(ResetRange())); + btnLogz->setChecked(false); } void SlsQt2DPlotLayout::UpdateNKeepSetRangeIfSet(){ - if(z_range_ne->CheckBoxState()){ - //just reset histogram range before update - the_plot->SetZMinMax(z_range_ne->GetValue(0),z_range_ne->GetValue(1)); - } - - the_plot->Update(); +#ifdef IAN + if(z_range_ne->CheckBoxState()){ +#else + if(zRangeChecked){ +#endif + //just reset histogram range before update + the_plot->SetZMinMax(z_range_ne->GetValue(0),z_range_ne->GetValue(1)); + } + the_plot->Update(); } void SlsQt2DPlotLayout::ResetRange(){ - //refind z limits - the_plot->SetZMinMax(); - if(logsChecked) the_plot->SetZMinimumToFirstGreaterThanZero(); + //refind z limits + the_plot->SetZMinMax(); + if(btnLogz->isChecked()) the_plot->SetZMinimumToFirstGreaterThanZero(); +#ifdef IAN + if(z_range_ne->CheckBoxState()){ +#else + if(zRangeChecked){cout<<"entering:"<GetValue(0)<<"\t"<GetValue(1)<GetValue(0)==z_range_ne->GetValue(1)) ? 1:0; + if(!z_range_ne->IsValueOk(0)||same) z_range_ne->SetValue(the_plot->GetZMinimum(),0);cout<<"isok 0:"<GetValue(0)<<"\t"<GetValue(1)<IsValueOk(1)||same) z_range_ne->SetValue(the_plot->GetZMaximum(),1);cout<<"isok1:"<GetValue(0)<<"\t"<GetValue(1)<SetRange(the_plot->GetZMinimum(),z_range_ne->GetValue(1),0); cout<<"setrange:"<GetValue(0)<<"\t"<GetValue(1)<SetRange(z_range_ne->GetValue(0),the_plot->GetZMaximum(),1); cout<<"setrange:"<GetValue(0)<<"\t"<GetValue(1)<CheckBoxState()){ - //first time check validity - bool same = (z_range_ne->GetValue(0)==z_range_ne->GetValue(1)) ? 1:0; - if(!z_range_ne->IsValueOk(0)||same) z_range_ne->SetValue(the_plot->GetZMinimum(),0); - if(!z_range_ne->IsValueOk(1)||same) z_range_ne->SetValue(the_plot->GetZMaximum(),1); - - z_range_ne->SetRange(the_plot->GetZMinimum(),z_range_ne->GetValue(1),0); - z_range_ne->SetRange(z_range_ne->GetValue(0),the_plot->GetZMaximum(),1); - - //set histogram range - the_plot->SetZMinMax(z_range_ne->GetValue(0),z_range_ne->GetValue(1)); - } - - the_plot->Update(); + //set histogram range + the_plot->SetZMinMax(z_range_ne->GetValue(0),z_range_ne->GetValue(1)); cout<<"setminmax:"<GetValue(0)<<"\t"<GetValue(1)<Update(); } - void SlsQt2DPlotLayout::SetZScaleToLog(bool yes){ - logsChecked=yes; - the_plot->LogZ(yes); - ResetRange(); +#ifndef IAN +#ifdef VERBOSE + cout<<"Setting ZScale to log:"<setChecked(yes); +#endif + the_plot->LogZ(yes); + ResetRange(); } void SlsQt2DPlotLayout::SetXTitle(QString st){ - GetPlot()->axisWidget(QwtPlot::xBottom)->setTitle(st); +#ifndef IAN + QwtText title(st); + title.setFont(QFont("Sans Serif",11,QFont::Normal)); + GetPlot()->axisWidget(QwtPlot::xBottom)->setTitle(title); +#else + GetPlot()->axisWidget(QwtPlot::xBottom)->setTitle(st); +#endif } void SlsQt2DPlotLayout::SetYTitle(QString st){ - GetPlot()->axisWidget(QwtPlot::yLeft)->setTitle(st); +#ifndef IAN + QwtText title(st); + title.setFont(QFont("Sans Serif",11,QFont::Normal)); + GetPlot()->axisWidget(QwtPlot::yLeft)->setTitle(title); +#else + GetPlot()->axisWidget(QwtPlot::yLeft)->setTitle(st); +#endif } void SlsQt2DPlotLayout::SetZTitle(QString st){ - GetPlot()->axisWidget(QwtPlot::yRight)->setTitle(st); +#ifndef IAN + QwtText title(st); + title.setFont(QFont("Sans Serif",11,QFont::Normal)); + GetPlot()->axisWidget(QwtPlot::yRight)->setTitle(title); +#else + GetPlot()->axisWidget(QwtPlot::yRight)->setTitle(st); +#endif } -void SlsQt2DPlotLayout::SetTitle(QString st){ - setTitle(st); + +#ifndef IAN +void SlsQt2DPlotLayout::SetZRange(double zmin, double zmax){ +#ifdef VERBOSE + cout<<"zmin:"<SetNumber(zmin,0); + z_range_ne->SetNumber(zmax,1); + cout<<"\n\nthe valuessssssssssssssss:"<GetValue(0)<<"\t"<GetValue(1)<GetValue(0)<<"\t"<GetValue(1)<fixup(s); + validator_double[i]->fixup(s); num_field[i]->setText(s); } }else if(spin_box[i]){ @@ -267,7 +267,7 @@ double SlsQtNumberEntry::SetNumber(double v,int which_number_field){ void SlsQtNumberEntry::SetRange(int min, int max,int which_number_field){ int i = (which_number_field<0||which_number_field>1) ? 0:which_number_field; if(min>max){ - cout<<"Waring: SetRange(int,int) no effect min > max"< max"<setRange(min,max); if(validator_double[i]) validator_double[i]->setRange(min,max,validator_double[i]->decimals()); @@ -280,7 +280,7 @@ void SlsQtNumberEntry::SetRange(int min, int max,int which_number_field){ void SlsQtNumberEntry::SetRange(double min, double max,int which_number_field){ int i = (which_number_field<0||which_number_field>1) ? 0:which_number_field; if(min>max){ - cout<<"Waring: SetRange(double,double) no effect min >= max"<= max"<setRange(min,max,validator_double[i]->decimals()); diff --git a/slsDetectorGui/src/qDetectorMain.cpp b/slsDetectorGui/src/qDetectorMain.cpp index e1347fd16..84f79921f 100644 --- a/slsDetectorGui/src/qDetectorMain.cpp +++ b/slsDetectorGui/src/qDetectorMain.cpp @@ -27,7 +27,7 @@ int main (int argc, char **argv) { QApplication *theApp = new QApplication(argc, argv); qDetectorMain *det=new qDetectorMain(argc, argv, theApp,0); det->show(); - theApp->connect( theApp, SIGNAL(lastWindowClosed()), theApp, SLOT(quit())); + //theApp->connect( theApp, SIGNAL(lastWindowClosed()), theApp, SLOT(quit())); return theApp->exec(); } @@ -355,6 +355,7 @@ void qDetectorMain::resizeEvent(QResizeEvent* event){ centralwidget->setMaximumHeight(heightCentralWidget); } } + event->accept(); #ifdef VERBOSE cout<<"height:"<height()<stopAcquisition(); - //pthread_join(gui_acquisition_thread,NULL); //wait until he's finished, ie. exits + pthread_join(gui_acquisition_thread,NULL); //wait until he's finished, ie. exits gui_acquisition_thread_running = 0; } @@ -253,12 +260,13 @@ bool qDrawPlot::StartOrStopThread(bool start){ if(!histYAxis[0]) histYAxis[0] = new double [nPixelsX]; - Clear1DPlot(); + if(plot_in_scope==1) Clear1DPlot(); cout<<"Starting new acquisition thread ...."<registerDataCallback(&(GetDataCallBack)); /** Start acquiring data from server */ - pthread_create(&gui_start_acquire_thread, NULL,DataStartAcquireThread, (void*) this); + pthread_create(&gui_acquisition_thread, NULL,DataStartAcquireThread, (void*) this); + /** This is later reset to zero when all the plotting is done */ gui_acquisition_thread_running=1; cout<<"Started acquiring"<myDet->acquire(1); return this_pointer; @@ -274,6 +283,7 @@ void* qDrawPlot::DataStartAcquireThread(void *this_pointer){ + int qDrawPlot::GetDataCallBack(detectorData *data){ #ifdef VERYVERBOSE cout<<"Entering GetDataCallBack function"<0;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)); - + /** Get data from client */ /**1d*/ - // if(plot_in_scope==1){ + if(plot_in_scope==1){ + /** Persistency */ + if(currentPersistency < persistency)currentPersistency++; + else currentPersistency=persistency; + for(int i=currentPersistency;i>0;i--) + memcpy(yvalues[i],yvalues[i-1],nPixelsX*sizeof(double)); + nHists = currentPersistency+1; + memcpy(yvalues[0],data->values,nPixelsX*sizeof(double)); + } + /**2d*/ + else{ + for(unsigned int px=0;px0;i--) - memcpy(histYAxis[i],histYAxis[i-1],nPixelsX*sizeof(double)); - memcpy(histYAxis[0],yvalues[0],nPixelsX*sizeof(double)); + /**1d*/ + if(plot_in_scope==1){ + /** Titles*/ + sprintf(temp_title,"Frame %d",currentFrame); histTitle[0] = temp_title; + /** copy data*/ + //memcpy(histXAxis, xvalues,nPixelsX*sizeof(double)); + for(int i=currentPersistency;i>0;i--) + memcpy(histYAxis[i],histYAxis[i-1],nPixelsX*sizeof(double)); + memcpy(histYAxis[0],yvalues[0],nPixelsX*sizeof(double)); + } + /**2d*/ + else{ + sprintf(temp_title,"Image Number %d",currentFrame); imageTitle = temp_title; + memcpy(lastImageArray,image_data,nPixelsX*nPixelsY*sizeof(double)); + } pthread_mutex_unlock(&(last_image_complete_mutex)); } currentFrame++; } - //} - ///**2d*/ - //else{ - // ; - //} - #ifdef VERYVERBOSE cout<<"Exiting GetDataCallBack function"<stop(); @@ -395,7 +404,7 @@ void qDrawPlot::UpdatePlot(){ Clear1DPlot(); 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))); @@ -408,16 +417,12 @@ void qDrawPlot::UpdatePlot(){ h->Attach(plot1D); } - //plot1D->UnZoom(); - //if(first){plot1D->UnZoom();first = !first;} - //plot1D->SetZoom(double xmin,double ymin,double x_width,double y_width); - } } //2-d plot stuff if(lastImageArray){ - if(lastImageNumber&&last_plot_number!=lastImageNumber && //there is a new plot + if(lastImageNumber&&last_plot_number!=(int)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 @@ -532,6 +537,17 @@ void qDrawPlot::SavePlot(QString FName){ +void qDrawPlot::SetPersistency(int val){ + for(int i=0;i<=val;i++){ + if(!yvalues[i]) yvalues[i] = new double [nPixelsX]; + if(!histYAxis[i]) histYAxis[i] = new double [nPixelsX]; + } + persistency = val; +} + + + + void qDrawPlot::EnablePlot(bool enable){ #ifdef VERBOSE cout<<"Plotting set to:"<DisableZoom(disable); -///disable zoom - + else + plot2D->GetPlot()->DisableZoom(disable); } diff --git a/slsDetectorGui/src/qTabActions.cpp b/slsDetectorGui/src/qTabActions.cpp index 10fd7ea2f..90fddab74 100644 --- a/slsDetectorGui/src/qTabActions.cpp +++ b/slsDetectorGui/src/qTabActions.cpp @@ -102,14 +102,6 @@ void qTabActions::Initialization(){ - -void qTabActions::Enable(bool enable){ - - -} - - - void qTabActions::Expand(QAbstractButton *button ){ int index = group->id(button); /** Collapse */ diff --git a/slsDetectorGui/src/qTabDeveloper.cpp b/slsDetectorGui/src/qTabDeveloper.cpp index 6914431ae..777a76c7f 100644 --- a/slsDetectorGui/src/qTabDeveloper.cpp +++ b/slsDetectorGui/src/qTabDeveloper.cpp @@ -47,9 +47,3 @@ void qTabDeveloper::Initialization(){ -void qTabDeveloper::Enable(bool enable){ - //this->setEnabled(enable); - -} - - diff --git a/slsDetectorGui/src/qTabMeasurement.cpp b/slsDetectorGui/src/qTabMeasurement.cpp index 170a8127d..04cbaf7c8 100644 --- a/slsDetectorGui/src/qTabMeasurement.cpp +++ b/slsDetectorGui/src/qTabMeasurement.cpp @@ -76,32 +76,29 @@ void qTabMeasurement::SetupWidgetWindow(){ switch(myDet->getDetectorsType()){ case slsDetectorDefs::MYTHEN: - item[(int)Gated]->setEnabled(true); item[(int)Trigger_Exp_Series]->setEnabled(true); item[(int)Trigger_Frame]->setEnabled(false); item[(int)Trigger_Readout]->setEnabled(true); + item[(int)Gated]->setEnabled(true); item[(int)Gated_Start]->setEnabled(true); item[(int)Trigger_Window]->setEnabled(false); break; case slsDetectorDefs::EIGER: - item[(int)Gated]->setEnabled(false); item[(int)Trigger_Exp_Series]->setEnabled(true); item[(int)Trigger_Frame]->setEnabled(true); item[(int)Trigger_Readout]->setEnabled(false); + item[(int)Gated]->setEnabled(false); item[(int)Gated_Start]->setEnabled(false); item[(int)Trigger_Window]->setEnabled(true); break; case slsDetectorDefs::GOTTHARD: - item[(int)Gated]->setEnabled(false); item[(int)Trigger_Exp_Series]->setEnabled(true); item[(int)Trigger_Frame]->setEnabled(false); item[(int)Trigger_Readout]->setEnabled(false); + item[(int)Gated]->setEnabled(false); item[(int)Gated_Start]->setEnabled(false); item[(int)Trigger_Window]->setEnabled(false); break; -/* case slsDetectorDefs::PICASSO: - case slsDetectorDefs::PILATUS: - case slsDetectorDefs::AGIPD:*/ default: cout<<"ERROR: Detector Type is Generic"<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){ myDet->setFileName(fName.toAscii().data()); #ifdef VERBOSE @@ -252,6 +236,29 @@ void qTabMeasurement::startStopAcquisition(){ +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::UpdateProgress(){ + progressBar->setValue(myPlot->GetProgress()); + lblProgressIndex->setText(QString::number(myDet->getFileIndex())); +} + + + + + + void qTabMeasurement::setNumFrames(int val){ myDet->setTimer(slsDetectorDefs::FRAME_NUMBER,val); #ifdef VERBOSE @@ -263,8 +270,8 @@ void qTabMeasurement::setNumFrames(int val){ void qTabMeasurement::setExposureTime(){ int64_t exptimeNS; - /** Get the 64 bit value of timer**/ - exptimeNS = qDefs::getNSTime((qDefs::timeUnit)comboExpUnit->currentIndex(),spinExpTime->value()); + /** Get the value of timer in ns **/ + exptimeNS = (int64_t)qDefs::getNSTime((qDefs::timeUnit)comboExpUnit->currentIndex(),spinExpTime->value()); #ifdef VERBOSE cout<<"Setting acquisition time to " << exptimeNS << " clocks" << endl; #endif @@ -272,7 +279,7 @@ void qTabMeasurement::setExposureTime(){ if(lblPeriod->isEnabled()){ int64_t acqtimeNS; - acqtimeNS = qDefs::getNSTime((qDefs::timeUnit)comboPeriodUnit->currentIndex(),spinPeriod->value()); + acqtimeNS = (int64_t)qDefs::getNSTime((qDefs::timeUnit)comboPeriodUnit->currentIndex(),spinPeriod->value()); if(exptimeNS>acqtimeNS) { lblNote->show(); lblPeriod->setPalette(lblNote->palette()); @@ -290,15 +297,15 @@ void qTabMeasurement::setExposureTime(){ void qTabMeasurement::setAcquisitionPeriod(){ int64_t acqtimeNS; - /** Get the 64 bit value of timer**/ - acqtimeNS = qDefs::getNSTime((qDefs::timeUnit)comboPeriodUnit->currentIndex(),spinPeriod->value()); + /** Get the value of timer in ns **/ + acqtimeNS = (int64_t)qDefs::getNSTime((qDefs::timeUnit)comboPeriodUnit->currentIndex(),spinPeriod->value()); #ifdef VERBOSE cout<<"Setting frame period between exposures to " << acqtimeNS << " clocks" << endl; #endif myDet->setTimer(slsDetectorDefs::FRAME_PERIOD,acqtimeNS); int64_t exptimeNS; - exptimeNS = qDefs::getNSTime((qDefs::timeUnit)comboExpUnit->currentIndex(),spinExpTime->value()); + exptimeNS = (int64_t)qDefs::getNSTime((qDefs::timeUnit)comboExpUnit->currentIndex(),spinExpTime->value()); if(exptimeNS>acqtimeNS){ lblNote->show(); lblPeriod->setPalette(lblNote->palette()); @@ -327,8 +334,8 @@ void qTabMeasurement::setNumTriggers(int val){ void qTabMeasurement::setDelay(){ int64_t exptimeNS; - /** Get the 64 bit value of timer**/ - exptimeNS = qDefs::getNSTime((qDefs::timeUnit)comboDelayUnit->currentIndex(),spinDelay->value()); + /** Get the value of timer in ns **/ + exptimeNS = (int64_t)qDefs::getNSTime((qDefs::timeUnit)comboDelayUnit->currentIndex(),spinDelay->value()); #ifdef VERBOSE cout<<"Setting delay after trigger to " << exptimeNS << " clocks" << endl; #endif @@ -356,13 +363,6 @@ void qTabMeasurement::setNumProbes(int val){ } -void qTabMeasurement::UpdateProgress(){ - progressBar->setValue(myPlot->GetProgress()); - lblProgressIndex->setText(QString::number(myDet->getFileIndex())); -} - - - void qTabMeasurement::setTimingMode(int mode){ #ifdef VERBOSE @@ -381,43 +381,43 @@ void qTabMeasurement::setTimingMode(int mode){ switch(mode){ - case None: + case None:/** Exposure Time */ lblExpTime->setEnabled(true); spinExpTime->setEnabled(true); comboExpUnit->setEnabled(true); break; - case Auto: + case Auto:/** Number of Frames, Exposure Time, Acquisition Period */ lblNumFrames->setEnabled(true); spinNumFrames->setEnabled(true); lblExpTime->setEnabled(true); spinExpTime->setEnabled(true); comboExpUnit->setEnabled(true); lblPeriod->setEnabled(true); spinPeriod->setEnabled(true); comboPeriodUnit->setEnabled(true); break; - case Gated: - lblNumFrames->setEnabled(true); spinNumFrames->setEnabled(true); - lblNumGates->setEnabled(true); spinNumGates->setEnabled(true); - break; - case Trigger_Exp_Series: + case Trigger_Exp_Series:/** Number of Frames, Exposure Time, Acquisition Period, Number of Triggers, Delay */ lblNumFrames->setEnabled(true); spinNumFrames->setEnabled(true); lblExpTime->setEnabled(true); spinExpTime->setEnabled(true); comboExpUnit->setEnabled(true); lblPeriod->setEnabled(true); spinPeriod->setEnabled(true); comboPeriodUnit->setEnabled(true); lblNumTriggers->setEnabled(true); spinNumTriggers->setEnabled(true); lblDelay->setEnabled(true); spinDelay->setEnabled(true); comboDelayUnit->setEnabled(true); break; - case Trigger_Readout: + case Trigger_Frame:/** Exposure Time, Number of Triggers */ + lblExpTime->setEnabled(true); spinExpTime->setEnabled(true); comboExpUnit->setEnabled(true); + lblNumTriggers->setEnabled(true); spinNumTriggers->setEnabled(true); + break; + case Trigger_Readout:/** Number of Frames, Exposure Time, Acquisition Period, Delay */ lblNumFrames->setEnabled(true); spinNumFrames->setEnabled(true); lblExpTime->setEnabled(true); spinExpTime->setEnabled(true); comboExpUnit->setEnabled(true); lblPeriod->setEnabled(true); spinPeriod->setEnabled(true); comboPeriodUnit->setEnabled(true); lblDelay->setEnabled(true); spinDelay->setEnabled(true); comboDelayUnit->setEnabled(true); break; - case Gated_Start: + case Gated:/** Number of Frames, Number of Gates */ + lblNumFrames->setEnabled(true); spinNumFrames->setEnabled(true); + lblNumGates->setEnabled(true); spinNumGates->setEnabled(true); + break; + case Gated_Start:/** Number of Frames, Exposure Time, Acquisition Period, Number of Triggers, Number of Gates */ lblNumFrames->setEnabled(true); spinNumFrames->setEnabled(true); lblExpTime->setEnabled(true); spinExpTime->setEnabled(true); comboExpUnit->setEnabled(true); lblPeriod->setEnabled(true); spinPeriod->setEnabled(true); comboPeriodUnit->setEnabled(true); lblNumTriggers->setEnabled(true); spinNumTriggers->setEnabled(true); lblNumGates->setEnabled(true); spinNumGates->setEnabled(true); break; - case Trigger_Frame: - lblExpTime->setEnabled(true); spinExpTime->setEnabled(true); comboExpUnit->setEnabled(true); - lblNumTriggers->setEnabled(true); spinNumTriggers->setEnabled(true); - break; - case Trigger_Window: + case Trigger_Window:/** Number of Triggers */ lblNumTriggers->setEnabled(true); spinNumTriggers->setEnabled(true); break; default: @@ -425,7 +425,7 @@ void qTabMeasurement::setTimingMode(int mode){ exit(-1); } - if(mode!=None){ + if(mode!=None){/** Number of Probes */ if(myDet->getDetectorsType()==slsDetectorDefs::MYTHEN){ lblNumProbes->setEnabled(true); spinNumProbes->setEnabled(true); } @@ -466,8 +466,8 @@ void qTabMeasurement::setTimingMode(int mode){ comboPeriodUnit->setCurrentIndex(qDefs::SECONDS); int64_t exptimeNS,acqtimeNS; - exptimeNS = qDefs::getNSTime((qDefs::timeUnit)comboExpUnit->currentIndex(),spinExpTime->value()); - acqtimeNS = qDefs::getNSTime((qDefs::timeUnit)comboPeriodUnit->currentIndex(),spinPeriod->value()); + exptimeNS = (int64_t)qDefs::getNSTime((qDefs::timeUnit)comboExpUnit->currentIndex(),spinExpTime->value()); + acqtimeNS = (int64_t)qDefs::getNSTime((qDefs::timeUnit)comboPeriodUnit->currentIndex(),spinPeriod->value()); if(exptimeNS>acqtimeNS) { lblNote->show(); lblPeriod->setPalette(lblNote->palette()); diff --git a/slsDetectorGui/src/qTabPlot.cpp b/slsDetectorGui/src/qTabPlot.cpp index e8d9c2081..9ab78a281 100644 --- a/slsDetectorGui/src/qTabPlot.cpp +++ b/slsDetectorGui/src/qTabPlot.cpp @@ -30,14 +30,17 @@ QString qTabPlot::defaultImageZAxisTitle("Intensity"); qTabPlot::qTabPlot(QWidget *parent,slsDetectorUtils*& detector, qDrawPlot*& plot):QWidget(parent),myDet(detector),myPlot(plot){ setupUi(this); - if(myDet) - { - // wherever you choose plot do all these steps - //This also selects the text if unchecked - //includes setupwidgetwindow - //SelectPlot(1); - //switch(myDet->detectorytype) - Select1DPlot(true); + if(myDet){ + SetupWidgetWindow(); + /** Depending on whether the detector is 1d or 2d*/ + switch(myDet->getDetectorsType()){ + case slsDetectorDefs::MYTHEN: Select1DPlot(true); break; + case slsDetectorDefs::EIGER: Select1DPlot(false);break; + case slsDetectorDefs::GOTTHARD: Select1DPlot(true);break; + default: + cout<<"ERROR: Detector Type is Generic"<setEnabled(false); dispYMax->setEnabled(false); dispZMax->setEnabled(false); -/* dispXMin->setValidator(new QDoubleValidator(dispXMin)); + 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));*/ + dispZMax->setValidator(new QDoubleValidator(dispZMax)); } @@ -119,6 +122,8 @@ void qTabPlot::Initialization(){ connect(chkInterpolate, SIGNAL(toggled(bool)),myPlot, SIGNAL(InterpolateSignal(bool))); connect(chkContour, SIGNAL(toggled(bool)),myPlot, SIGNAL(ContourSignal(bool))); connect(chkLogz, SIGNAL(toggled(bool)),myPlot, SIGNAL(LogzSignal(bool))); + + /** Plot Axis **/ connect(chkTitle, SIGNAL(toggled(bool)), this, SLOT(EnableTitles())); connect(chkXAxis, SIGNAL(toggled(bool)), this, SLOT(EnableTitles())); @@ -133,15 +138,17 @@ void qTabPlot::Initialization(){ 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(chkZMin, SIGNAL(toggled(bool)), this, SLOT(EnableZRange())); + connect(chkZMax, SIGNAL(toggled(bool)), this, SLOT(EnableZRange())); + connect(this, SIGNAL(EnableZRangeSignal(bool)), myPlot, SIGNAL(EnableZRangeSignal(bool))); 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())); + connect(dispZMin, SIGNAL(returnPressed()), this, SLOT(SetZRange())); + connect(dispZMax, SIGNAL(returnPressed()), this, SLOT(SetZRange())); + connect(this, SIGNAL(SetZRangeSignal(double,double)),myPlot, SIGNAL(SetZRangeSignal(double,double))); /** Common Buttons*/ connect(btnClear, SIGNAL(clicked()), myPlot, SLOT(Clear1DPlot())); @@ -169,7 +176,6 @@ void qTabPlot::EnablePersistency(bool enable){ } - void qTabPlot::SetTitles(){ int oneD = box1D->isEnabled(); /** Plot Title*/ @@ -236,87 +242,60 @@ 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); } + if(!chkXMin->isChecked()) dispXMin->setEnabled(false); + else{disableZoom = true; dispXMin->setEnabled(true); } + if(!chkXMax->isChecked()) dispXMax->setEnabled(false); + else{disableZoom = true; dispXMax->setEnabled(true); } + if(!chkYMin->isChecked()) dispYMin->setEnabled(false); + else{disableZoom = true; dispYMin->setEnabled(true); } + if(!chkYMax->isChecked()) dispYMax->setEnabled(false); + else{disableZoom = true; dispYMax->setEnabled(true); } + myPlot->DisableZoom(disableZoom); emit DisableZoomSignal(disableZoom); + SetAxesRange(); } 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); - } + double xmin=0,xmax=0,ymin=0,ymax=0; + + /** If disabled, get the min or max range of the plot as default */ + if((dispXMin->isEnabled())&&(!dispXMin->text().isEmpty())) + xmin = dispXMin->text().toDouble(); + else xmin = myPlot->GetXMinimum(); + if((dispXMax->isEnabled())&&(!dispXMax->text().isEmpty())) + xmax = dispXMax->text().toDouble(); + else xmax = myPlot->GetXMaximum(); + if((dispYMin->isEnabled())&&(!dispYMin->text().isEmpty())) + ymin = dispYMin->text().toDouble(); + else ymin = myPlot->GetYMinimum(); + if((dispYMax->isEnabled())&&(!dispYMax->text().isEmpty())) + ymax = dispYMax->text().toDouble(); + else ymax = myPlot->GetYMaximum(); + + /** Setting the range*/ + myPlot->SetXMinMax(xmin,xmax); + myPlot->SetYMinMax(ymin,ymax); } + +void qTabPlot::SetZRange(){ + emit SetZRangeSignal(dispZMin->text().toDouble(),dispZMax->text().toDouble()); +} + +void qTabPlot::EnableZRange(){ + dispZMin->setEnabled(chkZMin->isChecked()); + dispZMax->setEnabled(chkZMax->isChecked()); + emit EnableZRangeSignal((chkZMin->isChecked())||(chkZMax->isChecked())); +} + + + 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())); - -*/ - - -