diff --git a/slsDetectorGui/forms/form_tab_plot.ui b/slsDetectorGui/forms/form_tab_plot.ui index e16c6ae46..596c11aef 100755 --- a/slsDetectorGui/forms/form_tab_plot.ui +++ b/slsDetectorGui/forms/form_tab_plot.ui @@ -74,10 +74,10 @@ - 15 - 70 - 371 - 51 + 400 + 61 + 351 + 67 @@ -89,13 +89,13 @@ false - + - 5 - 15 - 361 - 31 + 12 + 22 + 334 + 39 @@ -105,10 +105,10 @@ - 20 - 5 - 336 - 26 + 8 + 0 + 317 + 36 @@ -125,7 +125,7 @@ - + @@ -138,7 +138,7 @@ - + @@ -151,38 +151,6 @@ - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 15 - 20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - @@ -190,10 +158,10 @@ - 25 - 5 - 100 - 26 + 9 + 0 + 314 + 35 @@ -216,92 +184,102 @@ + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 30 + 20 + + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + + + + + 20 + 20 + 20 + + + + + + + + + 20 + 20 + 20 + + + + + + + + + 20 + 20 + 20 + + + + + + + + Qt::NoFocus + + + Reset Accumulation + + + + :/icons/images/calculate.png:/icons/images/calculate.png + + + + 24 + 24 + + + + - - - - 175 - 3 - 156 - 26 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - - - - - 20 - 20 - 20 - - - - - - - - - 20 - 20 - 20 - - - - - - - - - 20 - 20 - 20 - - - - - - - - Qt::NoFocus - - - Reset Accumulation - - - - :/icons/images/calculate.png:/icons/images/calculate.png - - - - 16 - 16 - - - - 20 - 5 - 81 - 26 + 8 + 0 + 316 + 35 @@ -324,92 +302,102 @@ + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 60 + 20 + + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + + + + + 20 + 20 + 20 + + + + + + + + + 20 + 20 + 20 + + + + + + + + + 20 + 20 + 20 + + + + + + + + Qt::NoFocus + + + Recalculate Pedestal + + + + :/icons/images/calculate.png:/icons/images/calculate.png + + + + 24 + 24 + + + + - - - - 160 - 3 - 171 - 26 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - - - - - 20 - 20 - 20 - - - - - - - - - 20 - 20 - 20 - - - - - - - - - 20 - 20 - 20 - - - - - - - - Qt::NoFocus - - - Recalculate Pedestal - - - - :/icons/images/calculate.png:/icons/images/calculate.png - - - - 16 - 16 - - - - 25 - 5 - 311 - 26 + 10 + 0 + 313 + 36 @@ -439,7 +427,7 @@ - 20 + 10 20 @@ -546,10 +534,10 @@ - 25 - 5 - 335 - 26 + 9 + 0 + 318 + 35 @@ -569,7 +557,7 @@ <nobr> -Displays minimum, maximum and sum of values for each plot. +Displays statistics, ie. minimum, maximum and sum of values for each plot. <nobr> @@ -577,22 +565,6 @@ Displays minimum, maximum and sum of values for each plot. - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 10 - - - - @@ -614,22 +586,6 @@ Displays minimum, maximum and sum of values for each plot. - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 10 - - - - @@ -661,10 +617,10 @@ Displays minimum, maximum and sum of values for each plot. - 25 - 5 - 311 - 26 + 9 + 0 + 315 + 35 @@ -816,14 +772,84 @@ Displays minimum, maximum and sum of values for each plot. + + + + 2 + 31 + 16 + 16 + + + + + 0 + 0 + + + + Qt::NoFocus + + + + + + + :/icons/images/leftArrow.png:/icons/images/leftArrow.png + + + + 16 + 16 + + + + true + + + + + + 337 + 32 + 16 + 16 + + + + + 0 + 0 + + + + Qt::NoFocus + + + + + + + :/icons/images/rightArrow.png:/icons/images/rightArrow.png + + + + 16 + 16 + + + + true + + - 15 - 70 + 12 + 61 371 - 51 + 64 @@ -835,30 +861,30 @@ Displays minimum, maximum and sum of values for each plot. false - + - 4 - 15 - 366 - 31 + 12 + 22 + 355 + 40 - 5 + 2 - + - 25 - 5 - 108 - 26 + 5 + 0 + 333 + 35 - - + + @@ -874,21 +900,22 @@ Displays minimum, maximum and sum of values for each plot. - - - - - - 210 - 5 - 128 - 26 - - - - - 1 - + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 30 + 20 + + + + @@ -918,7 +945,7 @@ Displays minimum, maximum and sum of values for each plot. - 40 + 16777215 16777215 @@ -943,10 +970,10 @@ Displays minimum, maximum and sum of values for each plot. - 25 - 5 - 321 - 26 + 6 + 0 + 330 + 36 @@ -1018,88 +1045,13 @@ Displays minimum, maximum and sum of values for each plot. - - - - 175 - 3 - 161 - 26 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - - - - - 20 - 20 - 20 - - - - - - - - - 20 - 20 - 20 - - - - - - - - - 20 - 20 - 20 - - - - - - - - Qt::NoFocus - - - Reset Accumulation - - - - :/icons/images/calculate.png:/icons/images/calculate.png - - - - 16 - 16 - - - - 25 - 5 - 100 - 26 + 8 + 0 + 329 + 35 @@ -1122,6 +1074,91 @@ Displays minimum, maximum and sum of values for each plot. + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 30 + 20 + + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + + + + + 20 + 20 + 20 + + + + + + + + + 20 + 20 + 20 + + + + + + + + + 20 + 20 + 20 + + + + + + + + Qt::NoFocus + + + Reset Accumulation + + + + :/icons/images/calculate.png:/icons/images/calculate.png + + + + 24 + 24 + + + + @@ -1129,10 +1166,10 @@ Displays minimum, maximum and sum of values for each plot. - 25 - 5 - 81 - 26 + 6 + 0 + 331 + 36 @@ -1155,83 +1192,93 @@ Displays minimum, maximum and sum of values for each plot. + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 60 + 20 + + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + + + + + 20 + 20 + 20 + + + + + + + + + 20 + 20 + 20 + + + + + + + + + 20 + 20 + 20 + + + + + + + + Qt::NoFocus + + + Recalculate Pedestal + + + + :/icons/images/calculate.png:/icons/images/calculate.png + + + + 24 + 24 + + + + - - - - 165 - 3 - 171 - 26 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - - - - - 20 - 20 - 20 - - - - - - - - - 20 - 20 - 20 - - - - - - - - - 20 - 20 - 20 - - - - - - - - Qt::NoFocus - - - Recalculate Pedestal - - - - :/icons/images/calculate.png:/icons/images/calculate.png - - - - 16 - 16 - - - @@ -1242,10 +1289,10 @@ All values between <b>from</b> and <b>to</b> will be res - 25 - 5 - 311 - 26 + 8 + 0 + 327 + 36 @@ -1387,10 +1434,10 @@ All values between <b>from</b> and <b>to</b> will be res - 25 - 5 - 132 - 26 + 6 + 0 + 140 + 35 @@ -1428,10 +1475,10 @@ Displays minimum, maximum and sum of values for each plot. - 25 - 5 - 311 - 26 + 5 + 0 + 331 + 36 @@ -1583,14 +1630,84 @@ Displays minimum, maximum and sum of values for each plot. + + + + 0 + 30 + 16 + 16 + + + + + 0 + 0 + + + + Qt::NoFocus + + + + + + + :/icons/images/leftArrow.png:/icons/images/leftArrow.png + + + + 16 + 16 + + + + true + + + + + + 351 + 31 + 16 + 16 + + + + + 0 + 0 + + + + Qt::NoFocus + + + + + + + :/icons/images/rightArrow.png:/icons/images/rightArrow.png + + + + 16 + 16 + + + + true + + - 410 - 70 - 351 - 51 + 20 + 130 + 356 + 57 @@ -1606,9 +1723,9 @@ Displays minimum, maximum and sum of values for each plot. 10 - 20 - 233 - 26 + 22 + 342 + 35 @@ -1631,231 +1748,73 @@ Displays minimum, maximum and sum of values for each plot. - - - - - - 264 - 19 - 76 - 25 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - - - - - 20 - 20 - 20 - - - - - - - - - 20 - 20 - 20 - - - - - - - - - 20 - 20 - 20 - - - - - - - - Qt::NoFocus - - - Save - - - - :/icons/images/save.png:/icons/images/save.png - - - - 16 - 16 - - - - - - - - 410 - 5 - 351 - 51 - - - - 2D Scan - Y Axis Values - - - true - - - false - - - - - 10 - 20 - 357 - 26 - - - - - 0 - - + - + 0 0 - - <nobr>Enabled only when there is a Scan Level 0</nobr> - - - Level 0 - - - true - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - + - 7 - 10 + 16777215 + 16777215 - - - - - - - 0 - 0 - + + + + + + + 20 + 20 + 20 + + + + + + + + + 20 + 20 + 20 + + + + + + + + + 20 + 20 + 20 + + + + + - - <nobr>Enabled only when there is a Scan Level 1</nobr> + + Qt::NoFocus - Level 1 + Save - - - - - - Qt::Horizontal + + + :/icons/images/save.png:/icons/images/save.png - - QSizePolicy::Fixed - - + - 7 - 10 + 24 + 24 - - - - - - - 0 - 0 - - - - <nobr>Enabled only when there is a Scan Level 0 or a Scan Level 1, not both</nobr> - - - Frame Index - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 7 - 10 - - - - - - - - - 0 - 0 - - - - <nobr>Disabled only for Angle Plots, Moench and Eiger Detectors</nobr> - - - All Frames - - - false - @@ -1865,9 +1824,9 @@ Displays minimum, maximum and sum of values for each plot. 15 - 200 + 190 746 - 141 + 149 @@ -1883,9 +1842,9 @@ Displays minimum, maximum and sum of values for each plot. 10 - 15 + 20 726 - 121 + 125 @@ -2261,7 +2220,7 @@ Displays minimum, maximum and sum of values for each plot. - Plot Arguments + Plot Type Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter @@ -2275,7 +2234,7 @@ Displays minimum, maximum and sum of values for each plot. 10 20 355 - 26 + 27 @@ -2362,19 +2321,19 @@ Displays minimum, maximum and sum of values for each plot. - 15 - 135 - 371 - 49 + 400 + 5 + 357 + 58 <nobr> -Interval between plots has 2 modes. A condition to be satisfied, in order to avoid losing images: +Streaming Interval between 2 plots. Default is time interval with 200 ms. </nobr><br><br><nobr> -<b>Time Interval</b>: (Acquisition Period) * (nth Image) >= 250ms. +<b>Time Interval</b>: Streaming time interval when an image should be streamed. </nobr><br><nobr> -<b>Every nth Image</b>: minimum of 250ms. +<b>Every nth Image</b>: Only every nth image is streamed. </nobr> @@ -2390,9 +2349,9 @@ Interval between plots has 2 modes. A condition to be satisfied, in order to avo 10 - 16 - 351 - 26 + 19 + 340 + 32 @@ -2539,10 +2498,10 @@ Interval between plots has 2 modes. A condition to be satisfied, in order to avo - 410 - 135 + 400 + 130 351 - 51 + 60 @@ -2558,9 +2517,9 @@ Interval between plots has 2 modes. A condition to be satisfied, in order to avo 10 - 12 - 365 - 36 + 23 + 339 + 37 @@ -2694,7 +2653,7 @@ Interval between plots has 2 modes. A condition to be satisfied, in order to avo - 20 + 10 20 @@ -2710,7 +2669,7 @@ Interval between plots has 2 modes. A condition to be satisfied, in order to avo - 20 + 10 20 @@ -2782,214 +2741,18 @@ Interval between plots has 2 modes. A condition to be satisfied, in order to avo - - - - 362 - 95 - 16 - 16 - - - - - 0 - 0 - - - - Qt::NoFocus - - - - - - - :/icons/images/rightArrow.png:/icons/images/rightArrow.png - - - - 16 - 16 - - - - true - - - - - - 23 - 94 - 16 - 16 - - - - - 0 - 0 - - - - Qt::NoFocus - - - - - - - :/icons/images/leftArrow.png:/icons/images/leftArrow.png - - - - 16 - 16 - - - - true - - - - - - 410 - 5 - 351 - 51 - - - - Histogram - X Axis Values - - - false - - - false - - - - - 10 - 20 - 331 - 26 - - - - - 0 - - - - - - 0 - 0 - - - - <nobr>Enabled only when there is a Scan Level 0</nobr> - - - Intensity - - - true - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 7 - 10 - - - - - - - - - 0 - 0 - - - - <nobr>Enabled only when there is a Scan Level 1</nobr> - - - Level 0 - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 7 - 10 - - - - - - - - - 0 - 0 - - - - <nobr>Enabled only when there is a Scan Level 0 or a Scan Level 1, not both</nobr> - - - Level 1 - - - - - - box1D box2D boxSave - boxScan boxPlotAxis groupBox_3 boxFrequency boxSnapshot - btnRight - btnLeft - boxHistogram radioNoPlot radioHistogram radioDataGraph - boxScan - radioLevel0 - radioLevel1 - radioFileIndex - radioAllFrames chkInterpolate chkContour chkLogz @@ -3015,11 +2778,9 @@ Interval between plots has 2 modes. A condition to be satisfied, in order to avo dispZMin chkZMax dispZMax - spinPersistency chk1DLog chkPoints chkLines - chkSuperimpose diff --git a/slsDetectorGui/include/qDrawPlot.h b/slsDetectorGui/include/qDrawPlot.h index b286febbc..cd45afaee 100755 --- a/slsDetectorGui/include/qDrawPlot.h +++ b/slsDetectorGui/include/qDrawPlot.h @@ -67,18 +67,27 @@ public: * file index wont increase and so you need secondary titles to differentitate between plots*/ void SetFileWrite(bool enable){fileSaveEnable = enable;}; + /** sets plot Title prefix*/ void SetPlotTitlePrefix(QString title) {plotTitle_prefix = 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;} + + void SetXAxisTitle(QString title) { + if(plot_in_scope==1) { + histXAxisTitle = title; + } else { + imageXAxisTitle = title; + } + } + + void SetYAxisTitle(QString title) { + if(plot_in_scope==1) { + histYAxisTitle = title; + } else { + imageYAxisTitle = title; + } + } /** sets 2D Z Axis Title */ - void SetImageZAxisTitle(QString title) {imageZAxisTitle = title;} + void SetZAxisTitle(QString title) {imageZAxisTitle = title;} /** Disables zoom if any of the axes range are checked and fixed with a value */ void DisableZoom(bool disable); /** Enables plot from the plot tab*/ @@ -98,8 +107,6 @@ public: * @param xy is xmin,xmax,ymin or ymax */ void IsXYRangeValues(bool changed,qDefs::range xy){IsXYRange[xy]=changed;}; - /** Get minimum Plot timer - between plots */ - double GetMinimumPlotTimer(){return PLOT_TIMER_MS;}; /** Set Plot timer - between plots in ms*/ void SetPlotTimer(double time); /** Set Plot frame factor - between plots, also for receiver if exists */ @@ -500,9 +507,6 @@ double XYRangeValues[4]; /**if the specific min/max of x/y is enabled */ bool IsXYRange[4]; -/** Default timer between plots*/ -static const double PLOT_TIMER_MS; - /** Specific timer value between plots */ double timerValue; /** every nth frame when to plot */ diff --git a/slsDetectorGui/include/qTabPlot.h b/slsDetectorGui/include/qTabPlot.h index 91a29ec0a..0fef0feb1 100755 --- a/slsDetectorGui/include/qTabPlot.h +++ b/slsDetectorGui/include/qTabPlot.h @@ -24,36 +24,39 @@ public: public slots: void SetFrequency(); - void EnableScanBox(); + void EnableScanBox(); private slots: - void Select1DPlot(bool b); - /**Enables Persistency depending on Superimpose checkbox */ +xxxxxxxxxxxxxxx + void Set1DPlotOptionsRight(); + void Set1DPlotOptionsLeft(); + void Set2DPlotOptionsRight(); + void Set2DPlotOptionsLeft(); void EnablePersistency(bool enable); - void SetTitles(); - void EnableTitles(); - void checkAspectRatio(); - - /** maintain aspect ratio - * @param axis axis to be changed: 0 for x(y axis values changed), 1 for y (xaxis values changes), -1 for the larger one (aspect ratio checked) - */ - void maintainAspectRatio(int axis); - void EnableXRange(); - void EnableYRange(); - void EnableRange(); - void SetXAxisRange(); - void SetYAxisRange(); - void SetAxesRange(); - void SetZRange(); - void EnableZRange(); - bool CheckZRange(QString value); - void SetPlot(); - void SetPlotOptionsRightPage(); - void SetPlotOptionsLeftPage(); void SetBinary(); - void SetHistogramOptions(); - void EnableGapPixels(bool enable); + void SetGapPixels(bool enable); + void SetTitles(); + void SetXRange(); + void SetYRange(); + void CheckAspectRatio(); + void SetXYRange(); + /** + * Maintain aspect ratio + */ + void MaintainAspectRatio(int dimension); + void SetZRange(); + + + + + void Select1DPlot(bool b); + void SetPlot(); + + + + + signals: void DisableZoomSignal(bool); @@ -62,36 +65,30 @@ signals: private: void SetupWidgetWindow(); void Initialization(); + void GetGapPixels(); + void EnableRange(); + void SetAxesRange(); + bool CheckZRange(QString value); multiSlsDetector *myDet; qDrawPlot *myPlot; bool isOneD; bool isOriginallyOneD; - /**is set if its a possible wrong interval between plots*/ - bool wrongInterval; - + QButtonGroup *btnGroupPlotType; + /** interval between plots */ QStackedLayout *stackedLayout; QSpinBox *spinNthFrame; QDoubleSpinBox *spinTimeGap; QComboBox *comboTimeGapUnit; - QButtonGroup *btnGroupScan; - QButtonGroup *btnGroupPlotType; - QButtonGroup *btnGroupHistogram; - QPalette *red; - QString intervalTip; - /** some Default Values */ + /** default plot and axis titles */ static QString defaultPlotTitle; static QString defaultHistXAxisTitle; static QString defaultHistYAxisTitle; static QString defaultImageXAxisTitle; static QString defaultImageYAxisTitle; static QString defaultImageZAxisTitle; - - /** scans */ - static const QString modeNames[5]; - }; diff --git a/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlotLayout.cxx b/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlotLayout.cxx index 805dac109..4714aec7f 100755 --- a/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlotLayout.cxx +++ b/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlotLayout.cxx @@ -22,10 +22,8 @@ SlsQt2DPlotLayout::SlsQt2DPlotLayout(QWidget *parent):QGroupBox(parent){ z_range_ne = new SlsQtNumberEntry(this,1,(char*)"Set the z axis range from",2,(char*)"to",2); z_range_ne->setFixedWidth(402); -#ifndef IAN zRangeChecked = false; z_range_ne->hide(); -#endif CreateTheButtons(); Layout(); @@ -43,69 +41,32 @@ SlsQt2DPlotLayout::~SlsQt2DPlotLayout(){ 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); -#ifdef IAN - the_layout->addWidget(btnInterpolate,1,1); - the_layout->addWidget(btnContour,1,2); - the_layout->addWidget(btnLogz,1,3); - the_layout->addWidget(the_plot,2,1,3,3); - the_layout->addWidget(z_range_ne,5,1,1,3); - the_layout->setMargin(12); -#else the_layout->addWidget(the_plot,2,0,3,3); the_layout->addWidget(z_range_ne,5,0,1,3); -#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))); -#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(){ -#ifdef IAN - if(z_range_ne->CheckBoxState()){ -#endif //just reset histogram range before update the_plot->SetZMinMax(z_range_ne->GetValue(0),z_range_ne->GetValue(1)); -#ifdef IAN - } -#endif the_plot->Update(); } @@ -113,11 +74,7 @@ void SlsQt2DPlotLayout::ResetRange(){ //refind z limits the_plot->SetZMinMax(); if(btnLogz->isChecked()) the_plot->SetZMinimumToFirstGreaterThanZero(); -#ifdef IAN - if(z_range_ne->CheckBoxState()){ -#else if(zRangeChecked){ -#endif //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); @@ -175,49 +132,34 @@ void SlsQt2DPlotLayout::ResetZMinZMax(bool zmin, bool zmax, double min, double m void SlsQt2DPlotLayout::SetZScaleToLog(bool yes){ -#ifndef IAN #ifdef VERBOSE cout<<"Setting ZScale to log:"<setChecked(yes); -#endif the_plot->LogZ(yes); ResetRange(); } void SlsQt2DPlotLayout::SetXTitle(QString 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){ -#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){ -#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 } -#ifndef IAN void SlsQt2DPlotLayout::SetZRange(double zmin, double zmax){ #ifdef VERBOSE cout<<"zmin:"< #include - - QString qTabPlot::defaultPlotTitle(""); QString qTabPlot::defaultHistXAxisTitle("Channel Number"); QString qTabPlot::defaultHistYAxisTitle("Counts"); @@ -21,76 +19,62 @@ QString qTabPlot::defaultImageYAxisTitle("Pixel"); QString qTabPlot::defaultImageZAxisTitle("Intensity"); -qTabPlot::qTabPlot(QWidget *parent, multiSlsDetector *detector, qDrawPlot *plot) : QWidget(parent), - myDet(detector), - myPlot(plot), - isOneD(false), - isOriginallyOneD(false), - wrongInterval(0), - stackedLayout(0), - spinNthFrame(0), - spinTimeGap(0), - comboTimeGapUnit(0), - btnGroupScan(0), - btnGroupPlotType(0), - btnGroupHistogram(0) { +qTabPlot::qTabPlot(QWidget *parent, multiSlsDetector *detector, qDrawPlot *plot) : + QWidget(parent), myDet(detector), myPlot(plot), isOneD(false), isOriginallyOneD(false), wrongInterval(0), + stackedLayout(nullptr), spinNthFrame(nullptr), spinTimeGap(nullptr), comboTimeGapUnit(nullptr), + btnGroupPlotType(0) { setupUi(this); SetupWidgetWindow(); - Initialization(); FILE_LOG(logDEBUG) << "Plot ready"; } - -qTabPlot::~qTabPlot() { - delete myDet; - delete myPlot; -} +qTabPlot::~qTabPlot() {} void qTabPlot::SetupWidgetWindow() { - //error for interval between plots - red = new QPalette(); - ; - red->setColor(QPalette::Active, QPalette::WindowText, Qt::red); - intervalTip = boxFrequency->toolTip(); - - //scan arguments - btnGroupScan = new QButtonGroup(this); - btnGroupScan->addButton(radioLevel0, 0); - btnGroupScan->addButton(radioLevel1, 1); - btnGroupScan->addButton(radioFileIndex, 2); - btnGroupScan->addButton(radioAllFrames, 3); - - //plot type + // button group for plot type btnGroupPlotType = new QButtonGroup(this); btnGroupPlotType->addButton(radioNoPlot, 0); btnGroupPlotType->addButton(radioDataGraph, 1); btnGroupPlotType->addButton(radioHistogram, 2); - - //histogram arguments - btnGroupHistogram = new QButtonGroup(this); - btnGroupHistogram->addButton(radioHistIntensity, 0); - btnGroupHistogram->addButton(radioHistLevel0, 1); - btnGroupHistogram->addButton(radioHistLevel1, 2); - + // Plotting Frequency + stackedLayout = new QStackedLayout; + stackedLayout->setSpacing(0); + spinNthFrame = new QSpinBox; + spinNthFrame->setMinimum(1); + spinNthFrame->setMaximum(2000000000); + spinNthFrame->setValue(1); + spinTimeGap = new QDoubleSpinBox; + spinTimeGap->setMinimum(0); + spinTimeGap->setDecimals(3); + spinTimeGap->setMaximum(999999); + spinTimeGap->setValue(DEFAULT_STREAMING_TIMER_IN_MS); + comboTimeGapUnit = new QComboBox; + comboTimeGapUnit->addItem("hr"); + comboTimeGapUnit->addItem("min"); + comboTimeGapUnit->addItem("s"); + comboTimeGapUnit->addItem("ms"); + comboTimeGapUnit->setCurrentIndex(3); + QWidget *wTimeInterval = new QWidget; + QHBoxLayout *h1 = new QHBoxLayout; + wTimeInterval->setLayout(h1); + h1->setContentsMargins(0, 0, 0, 0); + h1->setSpacing(3); + h1->addWidget(spinTimeGap); + h1->addWidget(comboTimeGapUnit); + stackedLayout->addWidget(wTimeInterval); + stackedLayout->addWidget(spinNthFrame); + stackWidget->setLayout(stackedLayout); + // 1D and 2D options + stackedWidget1D->setCurrentIndex(0); + stackedWidget2D->setCurrentIndex(0); // Plot Axis - dispTitle->setEnabled(false); - dispXAxis->setEnabled(false); - dispYAxis->setEnabled(false); - dispZAxis->setEnabled(false); - dispXMin->setEnabled(false); - dispYMin->setEnabled(false); - dispZMin->setEnabled(false); - dispXMax->setEnabled(false); - dispYMax->setEnabled(false); - dispZMax->setEnabled(false); 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)); - - //default titles + // Plot titles dispTitle->setText(""); myPlot->SetPlotTitlePrefix(""); dispXAxis->setText(defaultHistXAxisTitle); @@ -104,165 +88,50 @@ void qTabPlot::SetupWidgetWindow() { myPlot->SetImageYAxisTitle(defaultImageYAxisTitle); myPlot->SetImageZAxisTitle(defaultImageZAxisTitle); - // Plotting Frequency - - stackedLayout = new QStackedLayout; - stackedLayout->setSpacing(0); - spinNthFrame = new QSpinBox; - spinNthFrame->setMinimum(1); - spinNthFrame->setMaximum(2000000000); - spinTimeGap = new QDoubleSpinBox; - spinTimeGap->setMinimum(0); - spinTimeGap->setDecimals(3); - spinTimeGap->setMaximum(999999); - spinTimeGap->setValue(myPlot->GetMinimumPlotTimer()); - comboTimeGapUnit = new QComboBox; - comboTimeGapUnit->addItem("hr"); - comboTimeGapUnit->addItem("min"); - comboTimeGapUnit->addItem("s"); - comboTimeGapUnit->addItem("ms"); - comboTimeGapUnit->setCurrentIndex(3); - QWidget *w = new QWidget; - QHBoxLayout *h1 = new QHBoxLayout; - w->setLayout(h1); - h1->setContentsMargins(0, 0, 0, 0); - h1->setSpacing(3); - h1->addWidget(spinTimeGap); - h1->addWidget(comboTimeGapUnit); - - stackedLayout->addWidget(w); - stackedLayout->addWidget(spinNthFrame); - stackWidget->setLayout(stackedLayout); - - stackedWidget->setCurrentIndex(0); - stackedWidget_2->setCurrentIndex(0); - - // Depending on whether the detector is 1d or 2d - switch (myDet->getDetectorTypeAsEnum()) { + // enabling according to det type + switch(myDet->getDetectorTypeAsEnum()) { + case slsDetectorDefs::GOTTHARD: + isOriginallyOneD = true; + break; case slsDetectorDefs::EIGER: isOriginallyOneD = false; pagePedestal->setEnabled(false); pagePedestal_2->setEnabled(false); - chkBinary->setEnabled(false); - chkBinary_2->setEnabled(false); chkGapPixels->setEnabled(true); break; - case slsDetectorDefs::GOTTHARD: - isOriginallyOneD = true; - break; case slsDetectorDefs::JUNGFRAU: case slsDetectorDefs::MOENCH: isOriginallyOneD = false; chkGainPlot->setEnabled(true); break; default: - cout << "ERROR: Detector Type is Generic" << endl; - exit(-1); + break; } Select1DPlot(isOriginallyOneD); - //to check if this should be enabled - // EnableScanBox(); + Initialization(); - //disable histogram initially - boxHistogram->hide(); - - if (chkGapPixels->isEnabled()) { - int ret = myDet->enableGapPixels(-1); - qDefs::checkErrorMessage(myDet, "qTabPlot::SetupWidgetWindow"); - chkGapPixels->setChecked((ret == 1) ? true : false); - } - - qDefs::checkErrorMessage(myDet, "qTabPlot::SetupWidgetWindow"); -} - - -void qTabPlot::SetPlotOptionsRightPage() { - if (isOneD) { - int i = stackedWidget->currentIndex(); - if (i == (stackedWidget->count() - 1)) - stackedWidget->setCurrentIndex(0); - else - stackedWidget->setCurrentIndex(i + 1); - box1D->setTitle(QString("1D Plot Options %1").arg(stackedWidget->currentIndex() + 1)); - } else { - int i = stackedWidget_2->currentIndex(); - if (i == (stackedWidget_2->count() - 1)) - stackedWidget_2->setCurrentIndex(0); - else - stackedWidget_2->setCurrentIndex(i + 1); - box2D->setTitle(QString("2D Plot Options %1").arg(stackedWidget_2->currentIndex() + 1)); - } -} - -void qTabPlot::SetPlotOptionsLeftPage() { - if (isOneD) { - int i = stackedWidget->currentIndex(); - if (i == 0) - stackedWidget->setCurrentIndex(stackedWidget->count() - 1); - else - stackedWidget->setCurrentIndex(i - 1); - box1D->setTitle(QString("1D Plot Options %1").arg(stackedWidget->currentIndex() + 1)); - } else { - int i = stackedWidget_2->currentIndex(); - if (i == 0) - stackedWidget_2->setCurrentIndex(stackedWidget_2->count() - 1); - else - stackedWidget_2->setCurrentIndex(i - 1); - box2D->setTitle(QString("2D Plot Options %1").arg(stackedWidget_2->currentIndex() + 1)); - } -} - -void qTabPlot::Select1DPlot(bool b) { -#ifdef VERBOSE - if (b) - cout << "Selecting 1D Plot" << endl; - else - cout << "Selecting 2D Plot" << endl; -#endif - isOneD = b; - lblFrom->setEnabled(false); - lblTo->setEnabled(false); - lblFrom_2->setEnabled(false); - lblTo_2->setEnabled(false); - spinFrom->setEnabled(false); - spinFrom_2->setEnabled(false); - spinTo->setEnabled(false); - spinTo_2->setEnabled(false); - if (b) { - box1D->show(); - box2D->hide(); - chkZAxis->setEnabled(false); - chkZMin->setEnabled(false); - chkZMax->setEnabled(false); - myPlot->Select1DPlot(); - } else { - box1D->hide(); - box2D->show(); - chkZAxis->setEnabled(true); - chkZMin->setEnabled(true); - chkZMax->setEnabled(true); - myPlot->Select2DPlot(); - } + Refresh(); } void qTabPlot::Initialization() { // Plot arguments box connect(btnGroupPlotType, SIGNAL(buttonClicked(int)), this, SLOT(SetPlot())); - // Histogram arguments box - connect(btnGroupHistogram, SIGNAL(buttonClicked(int)), this, SLOT(SetHistogramOptions())); - // Scan box - // connect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox())); - // Snapshot box - connect(btnClone, SIGNAL(clicked()), myPlot, SLOT(ClonePlot())); - connect(btnCloseClones, SIGNAL(clicked()), myPlot, SLOT(CloseClones())); - connect(btnSaveClones, SIGNAL(clicked()), myPlot, SLOT(SaveClones())); - // 1D Plot box - //to change pages - connect(btnRight, SIGNAL(clicked()), this, SLOT(SetPlotOptionsRightPage())); - connect(btnLeft, SIGNAL(clicked()), this, SLOT(SetPlotOptionsLeftPage())); + // Plotting frequency box + connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); + connect(comboTimeGapUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); + connect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); + connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); + + // navigation buttons for options + connect(btnRight1D, SIGNAL(clicked()), this, SLOT(Set1DPlotOptionsRight())); + connect(btnLeft1D, SIGNAL(clicked()), this, SLOT(Set1DPlotOptionsLeft())); + connect(btnRight2D, SIGNAL(clicked()), this, SLOT(Set2DPlotOptionsRight())); + connect(btnLeft2D, SIGNAL(clicked()), this, SLOT(Set2DPlotOptionsLeft())); + + // 1D options connect(chkSuperimpose, SIGNAL(toggled(bool)), this, SLOT(EnablePersistency(bool))); connect(spinPersistency, SIGNAL(valueChanged(int)), myPlot, SLOT(SetPersistency(int))); connect(chkPoints, SIGNAL(toggled(bool)), myPlot, SLOT(SetMarkers(bool))); @@ -275,52 +144,16 @@ void qTabPlot::Initialization() { connect(chkContour, SIGNAL(toggled(bool)), myPlot, SIGNAL(ContourSignal(bool))); connect(chkLogz, SIGNAL(toggled(bool)), myPlot, SIGNAL(LogzSignal(bool))); connect(chkStatistics_2, SIGNAL(toggled(bool)), myPlot, SLOT(DisplayStatistics(bool))); - // Plotting frequency box - connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); - connect(comboTimeGapUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); - connect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); - connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); - // Plot Axis * - connect(chkTitle, SIGNAL(toggled(bool)), this, SLOT(EnableTitles())); - connect(chkXAxis, SIGNAL(toggled(bool)), this, SLOT(EnableTitles())); - connect(chkYAxis, SIGNAL(toggled(bool)), this, SLOT(EnableTitles())); - connect(chkZAxis, SIGNAL(toggled(bool)), this, SLOT(EnableTitles())); - connect(dispTitle, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles())); - 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(EnableXRange())); - connect(chkXMax, SIGNAL(toggled(bool)), this, SLOT(EnableXRange())); - connect(chkYMin, SIGNAL(toggled(bool)), this, SLOT(EnableYRange())); - connect(chkYMax, SIGNAL(toggled(bool)), this, SLOT(EnableYRange())); - connect(chkZMin, SIGNAL(toggled(bool)), this, SLOT(EnableZRange())); - connect(chkZMax, SIGNAL(toggled(bool)), this, SLOT(EnableZRange())); - connect(chkAspectRatio, SIGNAL(toggled(bool)), this, SLOT(checkAspectRatio())); - connect(this, SIGNAL(ResetZMinZMaxSignal(bool, bool, double, double)), myPlot, SIGNAL(ResetZMinZMaxSignal(bool, bool, double, double))); - - connect(dispXMin, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); - connect(dispXMax, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); - connect(dispYMin, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); - connect(dispYMax, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); - connect(dispZMin, SIGNAL(editingFinished()), this, SLOT(SetZRange())); - connect(dispZMax, SIGNAL(editingFinished()), this, SLOT(SetZRange())); - // Save - connect(btnSave, SIGNAL(clicked()), myPlot, SLOT(SavePlot())); - connect(chkSaveAll, SIGNAL(toggled(bool)), myPlot, SLOT(SaveAll(bool))); - //pedstal connect(chkPedestal, SIGNAL(toggled(bool)), myPlot, SLOT(SetPedestal(bool))); connect(btnRecalPedestal, SIGNAL(clicked()), myPlot, SLOT(RecalculatePedestal())); connect(chkPedestal_2, SIGNAL(toggled(bool)), myPlot, SLOT(SetPedestal(bool))); connect(btnRecalPedestal_2, SIGNAL(clicked()), myPlot, SLOT(RecalculatePedestal())); - //accumulate connect(chkAccumulate, SIGNAL(toggled(bool)), myPlot, SLOT(SetAccumulate(bool))); connect(btnResetAccumulate, SIGNAL(clicked()), myPlot, SLOT(ResetAccumulate())); connect(chkAccumulate_2, SIGNAL(toggled(bool)), myPlot, SLOT(SetAccumulate(bool))); connect(btnResetAccumulate_2, SIGNAL(clicked()), myPlot, SLOT(ResetAccumulate())); - //binary connect(chkBinary, SIGNAL(toggled(bool)), this, SLOT(SetBinary())); connect(chkBinary_2, SIGNAL(toggled(bool)), this, SLOT(SetBinary())); @@ -328,223 +161,387 @@ void qTabPlot::Initialization() { connect(spinFrom_2, SIGNAL(valueChanged(int)), this, SLOT(SetBinary())); connect(spinTo, SIGNAL(valueChanged(int)), this, SLOT(SetBinary())); connect(spinTo_2, SIGNAL(valueChanged(int)), this, SLOT(SetBinary())); - //gainplot if (chkGainPlot->isEnabled()) connect(chkGainPlot, SIGNAL(toggled(bool)), myPlot, SIGNAL(GainPlotSignal(bool))); - // gap pixels if (chkGapPixels->isEnabled()) - connect(chkGapPixels, SIGNAL(toggled(bool)), this, SLOT(EnableGapPixels(bool))); + connect(chkGapPixels, SIGNAL(toggled(bool)), this, SLOT(SetGapPixels(bool))); + + // Save + connect(btnSave, SIGNAL(clicked()), myPlot, SLOT(SavePlot())); + connect(chkSaveAll, SIGNAL(toggled(bool)), myPlot, SLOT(SaveAll(bool))); + + // Snapshot box + connect(btnClone, SIGNAL(clicked()), myPlot, SLOT(ClonePlot())); + connect(btnCloseClones, SIGNAL(clicked()), myPlot, SLOT(CloseClones())); + connect(btnSaveClones, SIGNAL(clicked()), myPlot, SLOT(SaveClones())); + + // Plot Axis + connect(chkTitle, SIGNAL(toggled(bool)), this, SLOT(SetTitles())); + connect(chkXAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles())); + connect(chkYAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles())); + connect(chkZAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles())); + connect(dispTitle, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles())); + 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(SetXRange())); + connect(chkXMax, SIGNAL(toggled(bool)), this, SLOT(SetXRange())); + connect(chkYMin, SIGNAL(toggled(bool)), this, SLOT(SetYRange())); + connect(chkYMax, SIGNAL(toggled(bool)), this, SLOT(SetYRange())); + connect(dispXMin, SIGNAL(editingFinished()), this, SLOT(SetXRange())); + connect(dispXMax, SIGNAL(editingFinished()), this, SLOT(SetXRange())); + connect(dispYMin, SIGNAL(editingFinished()), this, SLOT(SetYRange())); + connect(dispYMax, SIGNAL(editingFinished()), this, SLOT(SetYRange())); + connect(chkAspectRatio, SIGNAL(toggled(bool)), this, SLOT(CheckAspectRatio())); + + connect(chkZMin, SIGNAL(toggled(bool)), this, SLOT(SetZRange())); + connect(chkZMax, SIGNAL(toggled(bool)), this, SLOT(SetZRange())); + connect(dispZMin, SIGNAL(editingFinished()), this, SLOT(SetZRange())); + connect(dispZMax, SIGNAL(editingFinished()), this, SLOT(SetZRange())); + connect(this, SIGNAL(ResetZMinZMaxSignal(bool, bool, double, double)), myPlot, SIGNAL(ResetZMinZMaxSignal(bool, bool, double, double))); +} + +xxxxxxxxxxxxxxx + +void qTabPlot::Set1DPlotOptionsRight() { + FILE_LOG(logDEBUG) << "1D Options Right"; + int i = stackedWidget->currentIndex(); + if (i == (stackedWidget->count() - 1)) + stackedWidget->setCurrentIndex(0); + else + stackedWidget->setCurrentIndex(i + 1); + box1D->setTitle(QString("1D Plot Options %1").arg(stackedWidget->currentIndex() + 1)); +} + +void qTabPlot::Set1DPlotOptionsLeft() { + FILE_LOG(logDEBUG) << "1D Options Left"; + int i = stackedWidget->currentIndex(); + if (i == 0) + stackedWidget->setCurrentIndex(stackedWidget->count() - 1); + else + stackedWidget->setCurrentIndex(i - 1); + box1D->setTitle(QString("1D Plot Options %1").arg(stackedWidget->currentIndex() + 1)); +} + +void qTabPlot::Set2DPlotOptionsRight() { + FILE_LOG(logDEBUG) << "2D Options Right"; + int i = stackedWidget_2->currentIndex(); + if (i == (stackedWidget_2->count() - 1)) + stackedWidget_2->setCurrentIndex(0); + else + stackedWidget_2->setCurrentIndex(i + 1); + box2D->setTitle(QString("2D Plot Options %1").arg(stackedWidget_2->currentIndex() + 1)); +} + +void qTabPlot::Set2DPlotOptionsLeft() { + FILE_LOG(logDEBUG) << "2D Options Left"; + int i = stackedWidget_2->currentIndex(); + if (i == 0) + stackedWidget_2->setCurrentIndex(stackedWidget_2->count() - 1); + else + stackedWidget_2->setCurrentIndex(i - 1); + box2D->setTitle(QString("2D Plot Options %1").arg(stackedWidget_2->currentIndex() + 1)); } void qTabPlot::EnablePersistency(bool enable) { -#ifdef VERBOSE - if (enable) - cout << "Enabling Persistency" << endl; - else - cout << "Disabling Persistency" << endl; -#endif - lblPersistency->setEnabled(enable); - spinPersistency->setEnabled(enable); + FILE_LOG(logINFO) << "Superimpose " << (enable ? "enabled" : "disabled"); + lblPersistency->setEnabled(val); + spinPersistency->setEnabled(val); if (enable) myPlot->SetPersistency(spinPersistency->value()); else myPlot->SetPersistency(0); } +void qTabPlot::SetBinary() { + bool binary1D = chkBinary->isChecked(); + bool binary2D = chkBinary_2->isChecked(); + if (isOneD) { + FILE_LOG(logINFO) << "Binary Plot " << (binary1D ? "enabled" : "disabled"); + lblFrom->setEnabled(binary1D); + lblTo->setEnabled(binary1D); + spinFrom->setEnabled(binary1D); + spinTo->setEnabled(binary1D); + myPlot->SetBinary(binary1D, spinFrom->value(), spinTo->value()); + } else { + FILE_LOG(logINFO) << "Binary Plot " << (binary2D ? "enabled" : "disabled"); + lblFrom_2->setEnabled(binary2D); + lblTo_2->setEnabled(binary2D); + spinFrom_2->setEnabled(binary2D); + spinTo_2->setEnabled(binary2D); + myPlot->SetBinary(binary2D, spinFrom_2->value(), spinTo_2->value()); + } +} + +void qTabPlot::GetGapPixels() { + FILE_LOG(logDEBUG) << "Getting gap pixels"; + disconnect(chkGapPixels, SIGNAL(toggled(bool)), this, SLOT(SetGapPixels(bool))); + + try { + auto retval = myDet->enableGapPixels(-1); + if (retval == -1) { + qDefs::Message(qDefs::WARNING, "Gap pixels enable is inconsistent for all detectors.", "qTabPlot::GetGapPixels"); + } else { + chkGapPixels->setChecked(retval == 0 ? false : true); + } + } catch (const sls::NonCriticalError &e) { + qDefs::ExceptionMessage("Could not get gap pixels enable.", e.what(), "qTabPlot::GetGapPixels"); + } + + connect(chkGapPixels, SIGNAL(toggled(bool)), this, SLOT(SetGapPixels(bool))); +} + +void qTabPlot::SetGapPixels(bool enable) { + FILE_LOG(logINFO) << "Setting Gap Pixels Enable to " << enable; + + try { + myDet->enableGapPixels(enable); + } catch (const sls::NonCriticalError &e) { + qDefs::ExceptionMessage("Could not set gap pixels enable.", e.what(), "qTabPlot::SetGapPixels"); + GetGapPixels(); + } +} + void qTabPlot::SetTitles() { -#ifdef VERBOSE - cout << "Setting Plot Titles" << endl; -#endif - // Plot Title - if (dispTitle->isEnabled()) - myPlot->SetPlotTitlePrefix(dispTitle->text()); - // X Axis - if (dispXAxis->isEnabled()) { - if (isOneD) - myPlot->SetHistXAxisTitle(dispXAxis->text()); - else - myPlot->SetImageXAxisTitle(dispXAxis->text()); - } - // Y Axis - if (dispYAxis->isEnabled()) { - if (isOneD) - myPlot->SetHistYAxisTitle(dispYAxis->text()); - else - myPlot->SetImageYAxisTitle(dispYAxis->text()); - } - // Z Axis - if (dispZAxis->isEnabled()) - myPlot->SetImageZAxisTitle(dispZAxis->text()); -} + FILE_LOG(logDEBUG) << "Setting Plot Titles"; + disconnect(chkTitle, SIGNAL(toggled(bool)), this, SLOT(SetTitles())); + disconnect(chkXAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles())); + disconnect(chkYAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles())); + disconnect(chkZAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles())); + disconnect(dispTitle, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles())); + disconnect(dispXAxis, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles())); + disconnect(dispYAxis, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles())); + disconnect(dispZAxis, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles())); -void qTabPlot::EnableTitles() { - // Plot Title - dispTitle->setEnabled(chkTitle->isChecked()); - if (!chkTitle->isChecked()) { + // title + if (!chkTitle->isChecked() || dispTitle->text().isEmpty()) { myPlot->SetPlotTitlePrefix(""); - dispTitle->setText(""); + dispTitle->setText(""); + } else { + myPlot->SetPlotTitlePrefix(dispTitle->text()); } - // X Axis - dispXAxis->setEnabled(chkXAxis->isChecked()); - if (!chkXAxis->isChecked()) { - if (isOneD) { - myPlot->SetHistXAxisTitle(defaultHistXAxisTitle); - dispXAxis->setText(defaultHistXAxisTitle); - } else { - myPlot->SetImageXAxisTitle(defaultImageXAxisTitle); - dispXAxis->setText(defaultImageXAxisTitle); - } - } - // Y Axis - dispYAxis->setEnabled(chkYAxis->isChecked()); - if (!chkYAxis->isChecked()) { - if (isOneD) { - myPlot->SetHistYAxisTitle(defaultHistYAxisTitle); - dispYAxis->setText(defaultHistYAxisTitle); - } else { - myPlot->SetImageYAxisTitle(defaultImageYAxisTitle); - dispYAxis->setText(defaultImageYAxisTitle); - } - } - // Z Axis - dispZAxis->setEnabled(chkZAxis->isChecked()); - if (!chkZAxis->isChecked()) { - myPlot->SetImageZAxisTitle(defaultImageZAxisTitle); + // x + if (!chkXAxis->isChecked() || dispXAxis->text().isEmpty()) { + dispXAxis->setText(isOneD ? defaultHistXAxisTitle : defaultImageXAxisTitle); + myPlot->SetXAxisTitle(isOneD ? defaultHistXAxisTitle : defaultImageXAxisTitle); + } else { + myPlot->SetXAxisTitle(dispXAxis->text()); + } + // y + if (!chkYAxis->isChecked() || dispYAxis->text().isEmpty()) { + dispYAxis->setText(isOneD ? defaultHistYAxisTitle : defaultImageYAxisTitle); + myPlot->SetYAxisTitle(isOneD ? defaultHistYAxisTitle : defaultImageYAxisTitle); + } else { + myPlot->SetYAxisTitle(dispYAxis->text()); + } + // z + if (!chkZAxis->isChecked() || dispZAxis->text().isEmpty()) { + myPlot->SetZAxisTitle(defaultImageZAxisTitle); dispZAxis->setText(defaultImageZAxisTitle); + } else { + myPlot->SetZAxisTitle(dispZAxis->text()); } + + connect(chkTitle, SIGNAL(toggled(bool)), this, SLOT(SetTitles())); + connect(chkXAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles())); + connect(chkYAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles())); + connect(chkZAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles())); + connect(dispTitle, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles())); + 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())); } -void qTabPlot::checkAspectRatio() { +void qTabPlot::SetXRange() { + FILE_LOG(logDEBUG) << "Enable X axis range"; + if (chkAspectRatio->isChecked()) { - maintainAspectRatio(-1); + MaintainAspectRatio(static_cast(slsDetectorDefs::Y)); + } else { + SetXYRange(); } } +void qTabPlot::SetYRange() { + FILE_LOG(logDEBUG) << "Enable Y axis range"; -void qTabPlot::maintainAspectRatio(int axis) { -#ifdef VERBOSE - cout << "Maintaining Aspect Ratio" << endl; -#endif - disconnect(chkXMin, SIGNAL(toggled(bool)), this, SLOT(EnableXRange())); - disconnect(chkXMax, SIGNAL(toggled(bool)), this, SLOT(EnableXRange())); - disconnect(chkYMin, SIGNAL(toggled(bool)), this, SLOT(EnableYRange())); - disconnect(chkYMax, SIGNAL(toggled(bool)), this, SLOT(EnableYRange())); - disconnect(dispXMin, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); - disconnect(dispXMax, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); - disconnect(dispYMin, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); - disconnect(dispYMax, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); + if (chkAspectRatio->isChecked()) { + MaintainAspectRatio(static_cast(slsDetectorDefs::X)); + } else { + SetXYRange(); + } +} +void qTabPlot::CheckAspectRatio() { + if (chkAspectRatio->isChecked()) { + MaintainAspectRatio(-1); + } else { + SetXYRange(); + } +} + +void qTabPlot::SetXYRange() { + FILE_LOG(LOGDEBUG) << "Set XY Range"; + disconnect(dispXMin, SIGNAL(editingFinished()), this, SLOT(SetXRange())); + disconnect(dispXMax, SIGNAL(editingFinished()), this, SLOT(SetXRange())); + disconnect(dispYMin, SIGNAL(editingFinished()), this, SLOT(SetYRange())); + disconnect(dispYMax, SIGNAL(editingFinished()), this, SLOT(SetYRange())); + + bool disablezoom = false; + + // xmin + // if unchecked, empty or invalid (set to false so it takes the min/max of plot) + if (!chkXMin->isChecked() || dispXMin->text().isEmpty()) { + myPlot->IsXYRangeValues(false, qDefs::XMINIMUM); + } else if (dispXMin->text().toDouble() < myPlot->GetXMinimum()) { + qDefs::Message(qDefs::WARNING, "XMin Outside Plot Range", "qTabPlot::SetXRange"); + dispXMin->setText(""); + myPlot->IsXYRangeValues(false, qDefs::XMINIMUM); + } else { + myPlot->SetXYRangeValues(dispXMin->text().toDouble(), qDefs::XMINIMUM); + myPlot->IsXYRangeValues(true, qDefs::XMINIMUM); + disablezoom = true; + } + + //xmax + if (!chkXMax->isChecked() || dispXMax->text().isEmpty()) { + myPlot->IsXYRangeValues(false, qDefs::XMAXIMUM); + } else if (dispXMax->text().toDouble() < myPlot->GetXMaximum()) { + qDefs::Message(qDefs::WARNING, "XMax Outside Plot Range", "qTabPlot::SetXYRange"); + dispXMax->setText(""); + myPlot->IsXYRangeValues(false, qDefs::XMAXIMUM); + } else { + myPlot->SetXYRangeValues(dispXMax->text().toDouble(), qDefs::XMAXIMUM); + myPlot->IsXYRangeValues(true, qDefs::XMAXIMUM); + disablezoom = true; + } + + // ymin + if (!chkYMin->isChecked() || dispYMin->text().isEmpty()) { + myPlot->IsXYRangeValues(false, qDefs::YMINIMUM); + } else if (dispYMin->text().toDouble() < myPlot->GetYMinimum()) { + qDefs::Message(qDefs::WARNING, "YMin Outside Plot Range", "qTabPlot::SetXYRange"); + dispYMin->setText(""); + myPlot->IsXYRangeValues(false, qDefs::YMINIMUM); + } else { + myPlot->SetXYRangeValues(dispYMin->text().toDouble(), qDefs::YMINIMUM); + myPlot->IsXYRangeValues(true, qDefs::YMINIMUM); + disablezoom = true; + } + + //ymax + if (!chkYMax->isChecked() || dispYMax->text().isEmpty()) { + myPlot->IsXYRangeValues(false, qDefs::YMAXIMUM); + } else if (dispYMax->text().toDouble() < myPlot->GetYMaximum()) { + qDefs::Message(qDefs::WARNING, "YMax Outside Plot Range", "qTabPlot::SetXYRange"); + dispYMax->setText(""); + myPlot->IsXYRangeValues(false, qDefs::YMAXIMUM); + } else { + myPlot->SetXYRangeValues(dispYMax->text().toDouble(), qDefs::YMAXIMUM); + myPlot->IsXYRangeValues(true, qDefs::YMAXIMUM); + disablezoom = true; + } + + connect(dispXMin, SIGNAL(editingFinished()), this, SLOT(SetXRange())); + connect(dispXMax, SIGNAL(editingFinished()), this, SLOT(SetXRange())); + connect(dispYMin, SIGNAL(editingFinished()), this, SLOT(SetYRange())); + connect(dispYMax, SIGNAL(editingFinished()), this, SLOT(SetYRange())); + + // to update plot with range + myPlot->SetXYRange(true); + myPlot->DisableZoom(disablezoom); + emit DisableZoomSignal(disablezoom); +} + +void qTabPlot::MaintainAspectRatio(int dimension) { + FILE_LOG(logDEBUG) << "Maintaining Aspect Ratio"; + + disconnect(chkXMin, SIGNAL(toggled(bool)), this, SLOT(SetXRange())); + disconnect(chkXMax, SIGNAL(toggled(bool)), this, SLOT(SetXRange())); + disconnect(chkYMin, SIGNAL(toggled(bool)), this, SLOT(SetYRange())); + disconnect(chkYMax, SIGNAL(toggled(bool)), this, SLOT(SetYRange())); + disconnect(dispXMin, SIGNAL(editingFinished()), this, SLOT(SetXRange())); + disconnect(dispXMax, SIGNAL(editingFinished()), this, SLOT(SetXRange())); + disconnect(dispYMin, SIGNAL(editingFinished()), this, SLOT(SetYRange())); + disconnect(dispYMax, SIGNAL(editingFinished()), this, SLOT(SetYRange())); + + // check all, fill all + chkXMin->setChecked(true); + chkXMax->setChecked(true); + chkYMin->setChecked(true); + chkYMax->setChecked(true); + if (dispXMin->text().isEmpty()) + dispXMin->setText(QString::number(myPlot->GetXMinimum())); + if (dispXMax->text().isEmpty()) + dispXMax->setText(QString::number(myPlot->GetXMaximum())); + if (dispYMin->text().isEmpty()) + dispYMin->setText(QString::number(myPlot->GetYMinimum())); + if (dispYMax->text().isEmpty()) + dispYMax->setText(QString::number(myPlot->GetYMaximum())); + + // calculate ideal aspect ratio with previous limits double ranges[4]; - //get previous plot limits ranges[qDefs::XMINIMUM] = myPlot->GetXMinimum(); ranges[qDefs::XMAXIMUM] = myPlot->GetXMaximum(); ranges[qDefs::YMINIMUM] = myPlot->GetYMinimum(); ranges[qDefs::YMAXIMUM] = myPlot->GetYMaximum(); -#ifdef VERYVERBOSE - cprintf(BLUE, "ideal values: xmin:%f, xmax:%f ymin:%f ymax:%f\n", ranges[qDefs::XMINIMUM], ranges[qDefs::XMAXIMUM], ranges[qDefs::YMINIMUM], ranges[qDefs::YMAXIMUM]); -#endif double idealAspectratio = (ranges[qDefs::XMAXIMUM] - ranges[qDefs::XMINIMUM]) / (ranges[qDefs::YMAXIMUM] - ranges[qDefs::YMINIMUM]); - - // enable all - chkXMin->setChecked(true); - dispXMin->setEnabled(true); - chkXMax->setChecked(true); - dispXMax->setEnabled(true); - chkYMin->setChecked(true); - dispYMin->setEnabled(true); - chkYMax->setChecked(true); - dispYMax->setEnabled(true); - - // if any empty, set it to previous plots boundaries - if (dispXMin->text().isEmpty()) - dispXMin->setText(QString::number(myPlot->GetXMinimum())); - if (dispXMax->text().isEmpty()) - dispXMax->setText(QString::number(myPlot->GetXMaximum())); - if (dispYMin->text().isEmpty()) - dispYMin->setText(QString::number(myPlot->GetYMinimum())); - if (dispYMax->text().isEmpty()) - dispYMax->setText(QString::number(myPlot->GetYMaximum())); - - //get actual limits + FILE_LOG(logDEBUG) << "Ideal Aspect ratio: %f for x(%f - %f), y(%f - %f)\n", idealAspectratio, ranges[qDefs::XMINIMUM], ranges[qDefs::XMAXIMUM], ranges[qDefs::YMINIMUM], ranges[qDefs::YMAXIMUM]); + + // calculate current aspect ratio ranges[qDefs::XMINIMUM] = dispXMin->text().toDouble(); ranges[qDefs::XMAXIMUM] = dispXMax->text().toDouble(); ranges[qDefs::YMINIMUM] = dispYMin->text().toDouble(); ranges[qDefs::YMAXIMUM] = dispYMax->text().toDouble(); -#ifdef VERYVERBOSE - cprintf(BLUE, "new limits: xmin:%f, xmax:%f ymin:%f ymax:%f\n", ranges[qDefs::XMINIMUM], ranges[qDefs::XMAXIMUM], ranges[qDefs::YMINIMUM], ranges[qDefs::YMAXIMUM]); -#endif - // calcualte new aspect ratio - double newAspectRatio = (ranges[qDefs::XMAXIMUM] - ranges[qDefs::XMINIMUM]) / (ranges[qDefs::YMAXIMUM] - ranges[qDefs::YMINIMUM]); + double currentAspectRatio = (ranges[qDefs::XMAXIMUM] - ranges[qDefs::XMINIMUM]) / (ranges[qDefs::YMAXIMUM] - ranges[qDefs::YMINIMUM]); + FILE_LOG(logDEBUG) << "Current Aspect ratio: %f for x(%f - %f), y(%f - %f)\n", currentAspectRatio, ranges[qDefs::XMINIMUM], ranges[qDefs::XMAXIMUM], ranges[qDefs::YMINIMUM], ranges[qDefs::YMAXIMUM]); - // if not ideal aspect ratio if (newAspectRatio != idealAspectratio) { - - // find the larger difference - if (axis == -1) { - if ((ranges[qDefs::XMAXIMUM] - ranges[qDefs::XMINIMUM]) > (ranges[qDefs::YMAXIMUM] - ranges[qDefs::YMINIMUM])) { - //change x - axis = 0; - } else { - //change y - axis = 1; - } + // dimension: 1(x changed: y adjusted), 0(y changed: x adjusted), -1(aspect ratio clicked: larger one adjusted) + if (dimension == -1) { + dimension = ((ranges[qDefs::XMAXIMUM] - ranges[qDefs::XMINIMUM]) > (ranges[qDefs::YMAXIMUM] - ranges[qDefs::YMINIMUM])) + ? static_cast(slsDetectorDefs::X) : static_cast(slsDetectorDefs::Y); } - // if x changed: y adjusted, y changed: x adjusted, aspect ratio clicked: larger one adjusted + // calculate new value to maintain aspect ratio + // adjust x double newval = 0; - switch (axis) { - case 0: - //change x + if (dimension == static_cast(slsDetectorDefs::X)) { newval = idealAspectratio * (ranges[qDefs::YMAXIMUM] - ranges[qDefs::YMINIMUM]) + ranges[qDefs::XMINIMUM]; if (newval <= myPlot->GetXMaximum()) { dispXMax->setText(QString::number(newval)); -#ifdef VERYVERBOSE - cprintf(BLUE, "new xmax: %f\n", newval); -#endif + FILE_LOG(logDEBUG) << "New XMax: " << newval; } else { newval = ranges[qDefs::XMAXIMUM] - (idealAspectratio * (ranges[qDefs::YMAXIMUM] - ranges[qDefs::YMINIMUM])); dispXMin->setText(QString::number(newval)); -#ifdef VERYVERBOSE - cprintf(BLUE, "new xmin: %f\n", newval); -#endif + FILE_LOG(logDEBUG) << "New XMin: " << newval; } - - break; - case 1: - // change y + } + // adjust y + else { newval = ((ranges[qDefs::XMAXIMUM] - ranges[qDefs::XMINIMUM]) / idealAspectratio) + ranges[qDefs::YMINIMUM]; if (newval <= myPlot->GetYMaximum()) { dispYMax->setText(QString::number(newval)); - //#ifdef VERYVERBOSE - cprintf(BLUE, "new ymax: %f\n", newval); - //#endif + FILE_LOG(logDEBUG) << "New YMax: " << newval; } else { newval = ranges[qDefs::YMAXIMUM] - ((ranges[qDefs::XMAXIMUM] - ranges[qDefs::XMINIMUM]) / idealAspectratio); dispYMin->setText(QString::number(newval)); -#ifdef VERYVERBOSE - cprintf(BLUE, "new ymin: %f\n", newval); -#endif + FILE_LOG(logDEBUG) << "New YMax: " << newval; } - break; - default: - break; } } - connect(chkXMin, SIGNAL(toggled(bool)), this, SLOT(EnableXRange())); - connect(chkXMax, SIGNAL(toggled(bool)), this, SLOT(EnableXRange())); - connect(chkYMin, SIGNAL(toggled(bool)), this, SLOT(EnableYRange())); - connect(chkYMax, SIGNAL(toggled(bool)), this, SLOT(EnableYRange())); - connect(dispXMin, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); - connect(dispXMax, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); - connect(dispYMin, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); - connect(dispYMax, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); - - // disable mouse zooming if any checked - myPlot->DisableZoom(true); - emit DisableZoomSignal(true); + connect(chkXMin, SIGNAL(toggled(bool)), this, SLOT(SetXRange())); + connect(chkXMax, SIGNAL(toggled(bool)), this, SLOT(SetXRange())); + connect(chkYMin, SIGNAL(toggled(bool)), this, SLOT(SetYRange())); + connect(chkYMax, SIGNAL(toggled(bool)), this, SLOT(SetYRange())); + connect(dispXMin, SIGNAL(editingFinished()), this, SLOT(SetXRange())); + connect(dispXMax, SIGNAL(editingFinished()), this, SLOT(SetXRange())); + connect(dispYMin, SIGNAL(editingFinished()), this, SLOT(SetYRange())); + connect(dispYMax, SIGNAL(editingFinished()), this, SLOT(SetYRange())); // set XY values in plot myPlot->SetXYRangeValues(dispXMin->text().toDouble(), qDefs::XMINIMUM); @@ -557,188 +554,10 @@ void qTabPlot::maintainAspectRatio(int axis) { myPlot->IsXYRangeValues(true, qDefs::YMINIMUM); myPlot->IsXYRangeValues(true, qDefs::YMAXIMUM); - // To remind the updateplot in qdrawplot to set range after updating plot - myPlot->SetXYRange(true); -} - -void qTabPlot::EnableXRange() { -#ifdef VERBOSE - cout << "Enable X Axis Range" << endl; -#endif - // keeping aspect ratio - if (chkAspectRatio->isChecked()) { - maintainAspectRatio(1); - return; - } - disconnect(dispXMin, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); - disconnect(dispXMax, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); - - // enable/disable lineedit - if (chkXMin->isChecked()) { - dispXMin->setEnabled(true); - // if any empty, set it to previous plots boundaries - if (dispXMin->text().isEmpty()) - dispXMin->setText(QString::number(myPlot->GetXMinimum())); - } else { - dispXMin->setEnabled(false); - } - // enable/disable lineedit - if (chkXMax->isChecked()) { - dispXMax->setEnabled(true); - // if any empty, set it to previous plots boundaries - if (dispXMax->text().isEmpty()) - dispXMax->setText(QString::number(myPlot->GetXMaximum())); - } else { - dispXMax->setEnabled(false); - } - - connect(dispXMin, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); - connect(dispXMax, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); - - EnableRange(); -} - -void qTabPlot::EnableYRange() { -#ifdef VERBOSE - cout << "Enable Y Axis Range" << endl; -#endif - // keeping aspect ratio - if (chkAspectRatio->isChecked()) { - maintainAspectRatio(0); - return; - } - disconnect(dispYMin, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); - disconnect(dispYMax, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); - - // enable/disable lineedit - if (chkYMin->isChecked()) { - dispYMin->setEnabled(true); - // if any empty, set it to previous plots boundaries - if (dispYMin->text().isEmpty()) - dispYMin->setText(QString::number(myPlot->GetYMinimum())); - } else { - dispYMin->setEnabled(false); - } - // enable/disable lineedit - if (chkYMax->isChecked()) { - dispYMax->setEnabled(true); - // if any empty, set it to previous plots boundaries - if (dispYMax->text().isEmpty()) - dispYMax->setText(QString::number(myPlot->GetYMaximum())); - } else { - dispYMax->setEnabled(false); - } - - connect(dispYMin, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); - connect(dispYMax, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); - - EnableRange(); -} - -void qTabPlot::EnableRange() { -#ifdef VERBOSE - cout << "Enable Axes Range" << endl; -#endif - // disable mouse zooming if any checked - bool disableZoom = false; - if (chkYMin->isChecked() || chkYMax->isChecked() || chkYMin->isChecked() || chkYMax->isChecked()) - disableZoom = true; - emit DisableZoomSignal(disableZoom); - SetAxesRange(); -} - -void qTabPlot::SetXAxisRange() { -#ifdef VERBOSE - cout << "Setting X Axis Range" << endl; -#endif - - disconnect(dispXMin, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); - disconnect(dispXMax, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); - - if (dispXMin->text().toDouble() < myPlot->GetXMinimum()) { - qDefs::Message(qDefs::WARNING, "Outside Plot Range", "qTabPlot::CheckZRange"); - dispXMin->setText(QString::number(myPlot->GetXMinimum())); - } - - if (dispXMax->text().toDouble() > myPlot->GetXMaximum()) { - qDefs::Message(qDefs::WARNING, "Outside Plot Range", "qTabPlot::CheckZRange"); - dispXMax->setText(QString::number(myPlot->GetXMaximum())); - } - - connect(dispXMin, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); - connect(dispXMax, SIGNAL(editingFinished()), this, SLOT(SetXAxisRange())); - - // keeping aspect ratio - if (chkAspectRatio->isChecked()) { - maintainAspectRatio(1); - return; - } - - SetAxesRange(); -} - -void qTabPlot::SetYAxisRange() { -#ifdef VERBOSE - cout << "Setting Y Axis Range" << endl; -#endif - - disconnect(dispYMin, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); - disconnect(dispYMax, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); - - if (dispYMin->text().toDouble() < myPlot->GetYMinimum()) { - qDefs::Message(qDefs::WARNING, "Outside Plot Range", "qTabPlot::CheckZRange"); - dispYMin->setText(QString::number(myPlot->GetYMinimum())); - } - - if (dispYMax->text().toDouble() > myPlot->GetYMaximum()) { - qDefs::Message(qDefs::WARNING, "Outside Plot Range", "qTabPlot::CheckZRange"); - dispYMax->setText(QString::number(myPlot->GetYMaximum())); - } - - connect(dispYMin, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); - connect(dispYMax, SIGNAL(editingFinished()), this, SLOT(SetYAxisRange())); - - // keeping aspect ratio - if (chkAspectRatio->isChecked()) { - maintainAspectRatio(0); - return; - } - - SetAxesRange(); -} - -void qTabPlot::SetAxesRange() { -#ifdef VERBOSE - cout << "Setting Axes Range" << endl; -#endif - - // x min - if (dispXMin->isEnabled()) { - myPlot->SetXYRangeValues(dispXMin->text().toDouble(), qDefs::XMINIMUM); - myPlot->IsXYRangeValues(true, qDefs::XMINIMUM); - } else - myPlot->IsXYRangeValues(false, qDefs::XMINIMUM); - // x max - if (dispXMax->isEnabled()) { - myPlot->SetXYRangeValues(dispXMax->text().toDouble(), qDefs::XMAXIMUM); - myPlot->IsXYRangeValues(true, qDefs::XMAXIMUM); - } else - myPlot->IsXYRangeValues(false, qDefs::XMAXIMUM); - // y min - if (dispYMin->isEnabled()) { - myPlot->SetXYRangeValues(dispYMin->text().toDouble(), qDefs::YMINIMUM); - myPlot->IsXYRangeValues(true, qDefs::YMINIMUM); - } else - myPlot->IsXYRangeValues(false, qDefs::YMINIMUM); - // y max - if (dispYMax->isEnabled()) { - myPlot->SetXYRangeValues(dispYMax->text().toDouble(), qDefs::YMAXIMUM); - myPlot->IsXYRangeValues(true, qDefs::YMAXIMUM); - } else - myPlot->IsXYRangeValues(false, qDefs::YMAXIMUM); - - // To remind the updateplot in qdrawplot to set range after updating plot + // to update plot with range myPlot->SetXYRange(true); + myPlot->DisableZoom(true); + emit DisableZoomSignal(true); } @@ -786,6 +605,131 @@ bool qTabPlot::CheckZRange(QString value) { } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +void qTabPlot::Select1DPlot(bool b) { +#ifdef VERBOSE + if (b) + cout << "Selecting 1D Plot" << endl; + else + cout << "Selecting 2D Plot" << endl; +#endif + isOneD = b; + lblFrom->setEnabled(false); + lblTo->setEnabled(false); + lblFrom_2->setEnabled(false); + lblTo_2->setEnabled(false); + spinFrom->setEnabled(false); + spinFrom_2->setEnabled(false); + spinTo->setEnabled(false); + spinTo_2->setEnabled(false); + if (b) { + box1D->show(); + box2D->hide(); + chkZAxis->setEnabled(false); + chkZMin->setEnabled(false); + chkZMax->setEnabled(false); + myPlot->Select1DPlot(); + } else { + box1D->hide(); + box2D->show(); + chkZAxis->setEnabled(true); + chkZMin->setEnabled(true); + chkZMax->setEnabled(true); + myPlot->Select2DPlot(); + } +} + + + + + + + + + + + + + + void qTabPlot::SetPlot() { #ifdef VERBOSE cout << "Entering Set Plot()"; @@ -1293,58 +1237,7 @@ void qTabPlot::SetFrequency() { } -void qTabPlot::SetBinary() { - //1d - if (isOneD) { - if (chkBinary->isChecked()) { -#ifdef VERBOSE - cout << endl - << "Enabling Binary" << endl; -#endif - lblFrom->setEnabled(true); - lblTo->setEnabled(true); - spinFrom->setEnabled(true); - spinTo->setEnabled(true); - myPlot->SetBinary(true, spinFrom->value(), spinTo->value()); - } else { -#ifdef VERBOSE - cout << endl - << "Disabling Binary" << endl; -#endif - lblFrom->setEnabled(false); - lblTo->setEnabled(false); - spinFrom->setEnabled(false); - spinTo->setEnabled(false); - myPlot->SetBinary(false); - } - } - //2d - else { - if (chkBinary_2->isChecked()) { -#ifdef VERBOSE - cout << endl - << "Enabling Binary" << endl; -#endif - lblFrom_2->setEnabled(true); - lblTo_2->setEnabled(true); - spinFrom_2->setEnabled(true); - spinTo_2->setEnabled(true); - myPlot->SetBinary(true, spinFrom_2->value(), spinTo_2->value()); - } else { -#ifdef VERBOSE - cout << endl - << "Disabling Binary" << endl; -#endif - - lblFrom_2->setEnabled(false); - lblTo_2->setEnabled(false); - spinFrom_2->setEnabled(false); - spinTo_2->setEnabled(false); - myPlot->SetBinary(false); - } - } -} void qTabPlot::SetHistogramOptions() { @@ -1358,22 +1251,11 @@ void qTabPlot::SetHistogramOptions() { } -void qTabPlot::EnableGapPixels(bool enable) { -#ifdef VERBOSE - cout << "Setting Gap pixels to " << enable << endl; -#endif - disconnect(chkGapPixels, SIGNAL(toggled(bool)), this, SLOT(EnableGapPixels(bool))); - - myDet->enableGapPixels(enable); - int ret = myDet->enableGapPixels(-1); - qDefs::checkErrorMessage(myDet, "qTabPlot::SetScanArgument"); - chkGapPixels->setChecked((ret == 1) ? true : false); - - connect(chkGapPixels, SIGNAL(toggled(bool)), this, SLOT(EnableGapPixels(bool))); -} - void qTabPlot::Refresh() { + + + #ifdef VERBOSE cout << endl << "**Updating Plot Tab" << endl; @@ -1382,13 +1264,9 @@ void qTabPlot::Refresh() { if (!radioNoPlot->isChecked()) boxFrequency->setEnabled(true); SetFrequency(); - + if (chkGapPixels->isEnabled()) { - disconnect(chkGapPixels, SIGNAL(toggled(bool)), this, SLOT(EnableGapPixels(bool))); - int ret = myDet->enableGapPixels(-1); - qDefs::checkErrorMessage(myDet, "qTabPlot::Refresh"); - chkGapPixels->setChecked((ret == 1) ? true : false); - connect(chkGapPixels, SIGNAL(toggled(bool)), this, SLOT(EnableGapPixels(bool))); + GetGapPixels(); } } else {