From ad171a3257744fa6feb4fd9966bf1df79cced372 Mon Sep 17 00:00:00 2001 From: l_maliakal_d Date: Wed, 10 Oct 2012 15:42:23 +0000 Subject: [PATCH] enhancement:plotting interval changed to red for error git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@88 af1100a4-978c-4157-bff7-07162d2ba061 --- slsDetectorGui/forms/form_tab_plot.ui | 9 ++ slsDetectorGui/include/qTabActions.h | 75 +++++++------ slsDetectorGui/include/qTabMeasurement.h | 1 - slsDetectorGui/include/qTabPlot.h | 134 +++++++++++------------ slsDetectorGui/src/qDetectorMain.cpp | 1 - slsDetectorGui/src/qTabMeasurement.cpp | 8 +- slsDetectorGui/src/qTabPlot.cpp | 93 +++++++++++----- 7 files changed, 182 insertions(+), 139 deletions(-) diff --git a/slsDetectorGui/forms/form_tab_plot.ui b/slsDetectorGui/forms/form_tab_plot.ui index 8ddd673c9..c7533aa53 100644 --- a/slsDetectorGui/forms/form_tab_plot.ui +++ b/slsDetectorGui/forms/form_tab_plot.ui @@ -1095,6 +1095,15 @@ 49 + + <nobr> +Interval between plots has 2 modes. A condition to be satisfied, in order to avoid losing images: +</nobr><br><br><nobr> +<b>Time Interval</b>: (Acquisition Period) * (nth Image) >= 250ms. +</nobr><br><nobr> +<b>Every nth Image</b>: minimum of 250ms. +</nobr> + Interval between Plots diff --git a/slsDetectorGui/include/qTabActions.h b/slsDetectorGui/include/qTabActions.h index 35f955124..bd5a073cd 100644 --- a/slsDetectorGui/include/qTabActions.h +++ b/slsDetectorGui/include/qTabActions.h @@ -50,35 +50,13 @@ public: public slots: -/** Disable Positions - * @param enable true if to disable - * */ -void EnablePositions(bool enable); + /** Disable Positions + * @param enable true if to disable + * */ + void EnablePositions(bool enable); private: - /** Sets up the widget */ - void SetupWidgetWindow(); - - /** Sets up all the slots and signals */ - void Initialization(); - - /** creates the Num Positions object */ - void CreatePositionsWidget(); - - /** Returns the index in each of the classes - * of actionwidget and scanwidget - * @param index the index in the list of all widgets - * returns actual index of the class - */ - int GetActualIndex(int index); - - /** Updates to green color if collapsed and mode not none - */ - void UpdateCollapseColors(); - - - /** The sls detector object */ multiSlsDetector *myDet; @@ -124,21 +102,46 @@ private: QIcon *iconPlus; QIcon *iconMinus; + + /** Sets up the widget */ + void SetupWidgetWindow(); + + /** Sets up all the slots and signals */ + void Initialization(); + + /** creates the Num Positions object */ + void CreatePositionsWidget(); + + /** Returns the index in each of the classes + * of actionwidget and scanwidget + * @param index the index in the list of all widgets + * returns actual index of the class + */ + int GetActualIndex(int index); + + /** Updates to green color if collapsed and mode not none + */ + void UpdateCollapseColors(); + + + + private slots: -/** To Expand the Action Widget - * */ -void Expand(QAbstractButton *button); + /** To Expand the Action Widget + * */ + void Expand(QAbstractButton *button); -/** Sets the positions list and the number of positions - * */ -void SetPosition(); + /** Sets the positions list and the number of positions + * */ + void SetPosition(); + + /** Deletes current position + * */ + void DeletePosition(); -/** Deletes current position - * */ -void DeletePosition(); signals: -void EnableScanBox(); + void EnableScanBox(); }; diff --git a/slsDetectorGui/include/qTabMeasurement.h b/slsDetectorGui/include/qTabMeasurement.h index a77b31664..f4d9ca1e6 100644 --- a/slsDetectorGui/include/qTabMeasurement.h +++ b/slsDetectorGui/include/qTabMeasurement.h @@ -177,7 +177,6 @@ signals: void StartSignal(); void StopSignal(); void CheckPlotIntervalSignal(); - void EnableNthFrameSignal(bool); }; diff --git a/slsDetectorGui/include/qTabPlot.h b/slsDetectorGui/include/qTabPlot.h index cee77ef64..308f0f18f 100644 --- a/slsDetectorGui/include/qTabPlot.h +++ b/slsDetectorGui/include/qTabPlot.h @@ -48,8 +48,43 @@ public: private: + /** The sls detector object */ + multiSlsDetector *myDet; + + /** The Plot widget */ + qDrawPlot *myPlot; + + /** 1d/2d plot */ + bool isOneD; + bool isOrginallyOneD; + + /**is set if its a possible wrong interval between plots*/ + bool wrongInterval; + + QStackedLayout *stackedLayout; + QSpinBox *spinNthFrame; + QDoubleSpinBox *spinTimeGap; + QComboBox *comboTimeGapUnit; + QButtonGroup *btnGroupScan; + + /** some Default Values */ + static QString defaultPlotTitle; + static QString defaultHistXAxisTitle; + static QString defaultHistYAxisTitle; + static QString defaultImageXAxisTitle; + static QString defaultImageYAxisTitle; + static QString defaultImageZAxisTitle; + + /** scans */ + static const QString modeNames[5]; + + /** error palette*/ + QPalette *red; + QString intervalTip; + + + -/** methods */ /** Sets up the widget */ void SetupWidgetWindow(); @@ -66,91 +101,52 @@ private: public slots: -/** Set frequency between plots*/ -void SetFrequency(); -/** Enable Scan box - */ -void EnableScanBox(); + /** Set frequency between plots*/ + void SetFrequency(); -/** a variable is set when timing mode has been changed. - * This variable is also disabled if exptime>acq period to be on safe side - * Its to check whether to enabled nth frame for frequency plot - * @param enable enable/disable - */ -void EnableNthFrame(bool enable){enableNFrame = enable;}; - - - - - -/** Disables scanbox while running - * @param disable true to disable - */ -//void DisableScanBoxWhileRunning(bool disable); + /** Enable Scan box + */ + void EnableScanBox(); private slots: -/** Selects the plot to display, enables/disables widgets - * @param b true to select plot dimension 1, else false to select 2D - */ -void Select1DPlot(bool b); + /** Selects the plot to display, enables/disables widgets + * @param b true to select plot dimension 1, else false to select 2D + */ + void Select1DPlot(bool b); -/**Enables Persistency depending on Superimpose checkbox */ -void EnablePersistency(bool enable); + /**Enables Persistency depending on Superimpose checkbox */ + void EnablePersistency(bool enable); -/**Sets the titles in plot axis */ -void SetTitles(); -/** Enables/Sets default Titles to default */ -void EnableTitles(); -/** Enables range of the axes */ -void EnableRange(); -/** Sets the range of the x and y axes */ -void SetAxesRange(); -/** Sets the range of the z axis */ -void SetZRange(); -/** Enables the range of the z axis */ -void EnableZRange(); -/** Set Plot to none, data graph, histogram*/ -void SetPlot(); + /**Sets the titles in plot axis */ + void SetTitles(); + /** Enables/Sets default Titles to default */ + void EnableTitles(); -private: -/** The sls detector object */ -multiSlsDetector *myDet; + /** Enables range of the axes */ + void EnableRange(); -/** The Plot widget */ -qDrawPlot *myPlot; + /** Sets the range of the x and y axes */ + void SetAxesRange(); -/** 1d/2d plot */ -bool isOneD; -bool isOrginallyOneD; + /** Sets the range of the z axis */ + void SetZRange(); -/**whether to enable nth frame according to timing mode*/ -bool enableNFrame; + /** Enables the range of the z axis */ + void EnableZRange(); -QStackedLayout *stackedLayout; -QSpinBox *spinNthFrame; -QDoubleSpinBox *spinTimeGap; -QComboBox *comboTimeGapUnit; -QButtonGroup *btnGroupScan; + /** Set Plot to none, data graph, histogram*/ + void SetPlot(); -/** some Default Values */ -static QString defaultPlotTitle; -static QString defaultHistXAxisTitle; -static QString defaultHistYAxisTitle; -static QString defaultImageXAxisTitle; -static QString defaultImageYAxisTitle; -static QString defaultImageZAxisTitle; - -/** scans */ -static const QString modeNames[5]; signals: -void DisableZoomSignal(bool); -void SetZRangeSignal(double,double); -void EnableZRangeSignal(bool); + void DisableZoomSignal(bool); + void SetZRangeSignal(double,double); + void EnableZRangeSignal(bool); + }; diff --git a/slsDetectorGui/src/qDetectorMain.cpp b/slsDetectorGui/src/qDetectorMain.cpp index 0e8f4ac00..469c43c83 100644 --- a/slsDetectorGui/src/qDetectorMain.cpp +++ b/slsDetectorGui/src/qDetectorMain.cpp @@ -235,7 +235,6 @@ void qDetectorMain::Initialization(){ connect(tab_measurement, SIGNAL(StartSignal()), this,SLOT(EnableTabs())); connect(tab_measurement, SIGNAL(StopSignal()), myPlot,SLOT(StopAcquisition())); connect(tab_measurement, SIGNAL(CheckPlotIntervalSignal()), tab_plot,SLOT(SetFrequency())); - connect(tab_measurement, SIGNAL(EnableNthFrameSignal(bool)), tab_plot,SLOT(EnableNthFrame(bool))); // Data Output Tab connect(tab_dataoutput, SIGNAL(AngularConversionSignal(bool)), tab_actions,SLOT(EnablePositions(bool))); //enable scanbox( for angles) diff --git a/slsDetectorGui/src/qTabMeasurement.cpp b/slsDetectorGui/src/qTabMeasurement.cpp index 69d239a91..7d9149f68 100644 --- a/slsDetectorGui/src/qTabMeasurement.cpp +++ b/slsDetectorGui/src/qTabMeasurement.cpp @@ -440,17 +440,14 @@ void qTabMeasurement::setAcquisitionPeriod(){ lblPeriod->setToolTip(errPeriodTip); lblPeriod->setPalette(red); lblPeriod->setText("Acquisition Period:*"); - emit EnableNthFrameSignal(false); } else { spinPeriod->setToolTip(acqPeriodTip); lblPeriod->setToolTip(acqPeriodTip); lblPeriod->setPalette(lblTimingMode->palette()); lblPeriod->setText("Acquisition Period:"); - emit EnableNthFrameSignal(true); } - //Check if the interval between plots is ok emit CheckPlotIntervalSignal(); } @@ -709,10 +706,7 @@ void qTabMeasurement::SetTimingMode(int mode){ myPlot->setTriggerEnabled(lblNumTriggers->isEnabled()); - //check if period is enabled and alright, only then the nth frame frequency is enabled - if((lblPeriod->isEnabled())&&(lblPeriod->text()=="Acquisition Period:")) - emit EnableNthFrameSignal(true); - else emit EnableNthFrameSignal(false); + emit CheckPlotIntervalSignal(); return; } diff --git a/slsDetectorGui/src/qTabPlot.cpp b/slsDetectorGui/src/qTabPlot.cpp index 4adce2b2f..63a5f108e 100644 --- a/slsDetectorGui/src/qTabPlot.cpp +++ b/slsDetectorGui/src/qTabPlot.cpp @@ -54,18 +54,10 @@ qTabPlot::~qTabPlot(){ void qTabPlot::SetupWidgetWindow(){ - //check if nth frame should be enabled - enableNFrame = true; - //according to timing mode - slsDetectorDefs::externalCommunicationMode mode = myDet->setExternalCommunicationMode(); - if( (mode==slsDetectorDefs::GATE_FIX_NUMBER)|| - (mode==slsDetectorDefs::TRIGGER_FRAME) || - (mode==slsDetectorDefs::TRIGGER_WINDOW) || - ((mode==slsDetectorDefs::AUTO_TIMING)&&((int)myDet->setTimer(slsDetectorDefs::FRAME_NUMBER,-1)==1)&&((int)myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER,-1)==1)) ) - enableNFrame = false; - //according to if exptime > acq period - if((myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,-1)*(1E-9))>(myDet->setTimer(slsDetectorDefs::FRAME_PERIOD,-1)*(1E-9))) - enableNFrame = false; + //error for interval between plots + red = new QPalette();; + red->setColor(QPalette::Active,QPalette::WindowText,Qt::red); + intervalTip = boxFrequency->toolTip(); @@ -155,6 +147,7 @@ void qTabPlot::SetupWidgetWindow(){ //to check if this should be enabled EnableScanBox(); + } @@ -442,23 +435,43 @@ void qTabPlot::SetFrequency(){ disconnect(comboTimeGapUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); disconnect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); disconnect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); + disconnect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); + double timeMS,acqPeriodMS; double minPlotTimer = myPlot->GetMinimumPlotTimer(); - char cplotms[200]; - sprintf(cplotms,"%f ms",minPlotTimer); + char cMin[200]; + sprintf(cMin,"%f ms",minPlotTimer); stackedLayout->setCurrentIndex(comboFrequency->currentIndex()); switch(comboFrequency->currentIndex()){ case 0: // Get the time interval from gui in ms timeMS = (qDefs::getNSTime((qDefs::timeUnit)comboTimeGapUnit->currentIndex(),spinTimeGap->value()))/(1e6); - if(timeMSInterval between Plots:
" + "Time Interval must be atleast >= 1 ms. Resetting to minimum plotting time interval.","Plot"); spinTimeGap->setValue(minPlotTimer); comboTimeGapUnit->setCurrentIndex(qDefs::MILLISECONDS); + timeMS=minPlotTimer; } + + //show red for warning + if(timeMSInterval between Plots: You might be losing Images!","Plot"); + boxFrequency->setPalette(*red); + boxFrequency->setTitle("Interval between Plots*"); + QString errTip = intervalTip + QString("

" + "Time Interval Condition: min of ")+QString("%1").arg(minPlotTimer)+ + QString("ms.
You might be losing images!
"); + boxFrequency->setToolTip(errTip); + }else{ + boxFrequency->setPalette(boxSnapshot->palette()); + boxFrequency->setTitle("Interval between Plots"); + boxFrequency->setToolTip(intervalTip); + } + //This is done so that its known which one was selected myPlot->SetFrameFactor(0); // Setting the timer value(ms) between plots @@ -469,19 +482,49 @@ void qTabPlot::SetFrequency(){ break; case 1: acqPeriodMS = (myDet->setTimer(slsDetectorDefs::FRAME_PERIOD,-1)*(1E-6)); + + //if period is 0, check exptime, if that is also 0, give warning and set to min timer + if(acqPeriodMS==0){ + acqPeriodMS = (myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,-1)*(1E-6)); + if(acqPeriodMS==0){ + qDefs::Message(qDefs::WARNING,"Interval between Plots:
" + "Every Nth Image: Period betwen Frames and Exposure Time cannot both be 0 ms.
" + "Resetting to minimum plotting time interval","Plot"); + comboFrequency->setCurrentIndex(0); + stackedLayout->setCurrentIndex(comboFrequency->currentIndex()); + spinTimeGap->setValue(minPlotTimer); + comboTimeGapUnit->setCurrentIndex(qDefs::MILLISECONDS); + timeMS=minPlotTimer; + //This is done so that its known which one was selected + myPlot->SetFrameFactor(0); + // Setting the timer value(ms) between plots + myPlot->SetPlotTimer(timeMS); + break; + } + } + // gets the acq period * number of nth frames timeMS = (spinNthFrame->value())*acqPeriodMS; - // To make sure the period between plotting is not less than minimum plot timer in ms + + //Show red to make sure the period between plotting is not less than minimum plot timer in ms if(timeMSPlot Tab: Interval between Plots - The nth Image must be larger.

" - "Condition to be satisfied:\n(Acquisition Period)*(nth Image) >= 250ms." - "

Nth image adjusted to minimum, " - "for the chosen Acquisition Period.","Plot"); - spinNthFrame->setValue(minFrame); + qDefs::Message(qDefs::WARNING,"
Interval between Plots: You might be losing Images!","Plot"); + boxFrequency->setPalette(*red); + boxFrequency->setTitle("Interval between Plots*"); + QString errTip = intervalTip + QString("

" + "Every nth Image Condition: min nth Image for this time period: ")+QString("%1").arg(minFrame)+ + QString(".
You might be losing images!
"); + boxFrequency->setToolTip(errTip); + }else{ + boxFrequency->setPalette(boxSnapshot->palette()); + boxFrequency->setTitle("Interval between Plots"); + boxFrequency->setToolTip(intervalTip); } + // Setting the timer value (nth frames) between plots myPlot->SetFrameFactor(spinNthFrame->value()); + #ifdef VERBOSE cout << "Plotting Frequency: Nth Frame - " << spinNthFrame->value() << endl; #endif @@ -491,12 +534,12 @@ void qTabPlot::SetFrequency(){ connect(comboTimeGapUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); connect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); + connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); } //------------------------------------------------------------------------------------------------------------------------------------------------- - void qTabPlot::EnableScanBox(){ #ifdef VERYVERBOSE cout << "Entering Enable Scan Box()" << endl; @@ -545,7 +588,7 @@ void qTabPlot::EnableScanBox(){ } } } - else EnablingNthFrameFunction(enableNFrame); + else EnablingNthFrameFunction(true); //positions if((positionsExist)&&(chkSuperimpose->isChecked())) chkSuperimpose->setChecked(false);