diff --git a/slsDetectorGui/forms/form_tab_plot.ui b/slsDetectorGui/forms/form_tab_plot.ui
index 1a5404f05..f50abeb2b 100644
--- a/slsDetectorGui/forms/form_tab_plot.ui
+++ b/slsDetectorGui/forms/form_tab_plot.ui
@@ -2765,6 +2765,123 @@ Interval between plots has 2 modes. A condition to be satisfied, in order to avo
true
+
+
+
+ 410
+ 5
+ 351
+ 51
+
+
+
+ Histogram - X Axis Values
+
+
+ false
+
+
+ false
+
+
+
+
+ 10
+ 20
+ 351
+ 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
@@ -2775,6 +2892,7 @@ Interval between plots has 2 modes. A condition to be satisfied, in order to avo
boxSnapshot
btnRight
btnLeft
+ boxHistogram
radioNoPlot
diff --git a/slsDetectorGui/include/qDefs.h b/slsDetectorGui/include/qDefs.h
index 497a809ba..badb9425d 100644
--- a/slsDetectorGui/include/qDefs.h
+++ b/slsDetectorGui/include/qDefs.h
@@ -281,6 +281,17 @@ static const int64_t GUI_VERSION=0x20121213;
};
+//-------------------------------------------------------------------------------------------------------------------------------------------------
+
+
+ /** histogram arguments*/
+ enum histogramArgumentList{
+ Intensity,
+ histLevel0,
+ histLevel1
+ };
+
+
//-------------------------------------------------------------------------------------------------------------------------------------------------
diff --git a/slsDetectorGui/include/qDrawPlot.h b/slsDetectorGui/include/qDrawPlot.h
index c2210faed..f8266e517 100644
--- a/slsDetectorGui/include/qDrawPlot.h
+++ b/slsDetectorGui/include/qDrawPlot.h
@@ -143,7 +143,7 @@ public:
void SetBinary(bool enable, int from=0, int to=0);
/** Enable/Disable Histogram */
- void SetHistogram(bool enable,int min=0, int max=0, int size=0){histogram = enable;histFrom=min;histTo=max;histSize=size;};
+ void SetHistogram(bool enable,int histArg, int min=0, int max=0, int size=0){histogram = enable;histogramArgument = histArg; histFrom=min;histTo=max;histSize=size;};
public slots:
/** To select 1D or 2D plot
@@ -494,6 +494,9 @@ bool isTriggerEnabled;
/** scan arguments*/
int scanArgument;
+/** histogram arguments*/
+int histogramArgument;
+
/** enable angle plot */
bool anglePlot;
/** prevents err msg displaying twice when detector stopped, "transmitting" */
diff --git a/slsDetectorGui/include/qTabPlot.h b/slsDetectorGui/include/qTabPlot.h
index 58f23a451..016f130d6 100644
--- a/slsDetectorGui/include/qTabPlot.h
+++ b/slsDetectorGui/include/qTabPlot.h
@@ -71,6 +71,7 @@ private:
QComboBox *comboTimeGapUnit;
QButtonGroup *btnGroupScan;
QButtonGroup *btnGroupPlotType;
+ QButtonGroup *btnGroupHistogram;
/** some Default Values */
static QString defaultPlotTitle;
@@ -105,7 +106,7 @@ public slots:
/** Enable Scan box
*/
- void EnableScanBox(bool Histo=false);
+ void EnableScanBox();
private slots:
@@ -147,6 +148,9 @@ private slots:
/** Plot binary plot */
void SetBinary();
+ /** Set histogram options */
+ void SetHistogramOptions();
+
signals:
void DisableZoomSignal(bool);
void SetZRangeSignal(double,double);
diff --git a/slsDetectorGui/src/qDrawPlot.cpp b/slsDetectorGui/src/qDrawPlot.cpp
index 28ab07d52..076e24c7b 100644
--- a/slsDetectorGui/src/qDrawPlot.cpp
+++ b/slsDetectorGui/src/qDrawPlot.cpp
@@ -168,6 +168,7 @@ void qDrawPlot::SetupWidgetWindow(){
isTriggerEnabled = false;
scanArgument = qDefs::None;
+ histogramArgument = qDefs::Intensity;
anglePlot = false;
alreadyDisplayed = false;
@@ -600,7 +601,7 @@ void qDrawPlot::SetScanArgument(int scanArg){
int max = (iloop+1)*histSize + histFrom;
while(min < histTo){
histogramSamples.resize(iloop+1);
- histogramSamples[iloop].interval.setInterval(min,max);
+ histogramSamples[iloop].interval.setInterval(min,max-1);
histogramSamples[iloop].value = 0;
iloop++;
min = max;
@@ -974,15 +975,56 @@ int qDrawPlot::GetData(detectorData *data,int fIndex){
if(originally2D)
numValues = nPixelsX*nPixelsY;
+ //clean up graph
+ if(histogramArgument == qDefs::Intensity){
+ for(int j=0;jvalues[i] <= histFrom) || (data->values[i] >= histTo))
+ continue;
+ //check for intervals, increment if validates
+ for(int j=0;jvalues[i]))
+ histogramSamples[j].value += 1;
+
+ }
+ }
+ //get sum of data pixels
+ else
+ val += data->values[i];
+
+ }
+
+
+ if(histogramArgument != qDefs::Intensity){
+ val /= numValues;
+
+ //find scan value
+ int ci = 0, fi = 0; double cs0 = 0 , cs1 = 0;
+ fileIOStatic::getVariablesFromFileName(string(data->fileName), ci, fi, cs0, cs1);
+
+ int scanval=-1;
+ if(cs0 != -1)
+ scanval = cs0;
+ else scanval = cs1;
+
//ignore outside limits
- if ((data->values[i] <= histFrom) || (data->values[i] >= histTo))
- continue;
+ if ((scanval <= histFrom) || (scanval >= histTo) || (scanval == -1))
+ scanval = -1;
//check for intervals, increment if validates
for(int j=0;jvalues[i]))
- histogramSamples[j].value += 1;
-
+ if(histogramSamples[j].interval.contains(scanval)){
+ histogramSamples[j].value = val;
+ cout << "j:"<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);
+
// Plot Axis
dispTitle->setEnabled(false);
dispXAxis->setEnabled(false);
@@ -181,6 +188,9 @@ void qTabPlot::SetupWidgetWindow(){
//to check if this should be enabled
EnableScanBox();
+ //disable histogram initially
+ boxHistogram->hide();
+
qDefs::checkErrorMessage(myDet,"qTabPlot::SetupWidgetWindow");
}
@@ -273,6 +283,8 @@ void qTabPlot::Select1DPlot(bool b){
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
@@ -522,14 +534,20 @@ void qTabPlot::SetPlot(){
if(radioNoPlot->isChecked()){
cout << " - No Plot" << endl;
+ boxScan->show();
+ boxHistogram->hide();
myPlot->EnablePlot(false);
boxSnapshot->setEnabled(false);
boxSave->setEnabled(false);
boxFrequency->setEnabled(false);
boxPlotAxis->setEnabled(false);
boxScan->setEnabled(false);
+
}else if(radioDataGraph->isChecked()){
cout << " - DataGraph" << endl;
+
+ boxScan->show();
+ boxHistogram->hide();
myPlot->EnablePlot(true);
Select1DPlot(isOriginallyOneD);
boxSnapshot->setEnabled(true);
@@ -538,6 +556,8 @@ void qTabPlot::SetPlot(){
boxPlotAxis->setEnabled(true);
if(!myPlot->isRunning())
EnableScanBox();
+ // To remind the updateplot in qdrawplot to set range after updating plot
+ myPlot->SetXYRange(true);
}
else{
//histogram and 2d scans dont work
@@ -545,10 +565,20 @@ void qTabPlot::SetPlot(){
qDefs::Message(qDefs::WARNING,"Histogram cannot be used together with 2D Scan Plots.
"
"Uncheck 2D Scan plots to plot Histograms", "qTabPlot::SetPlot");
radioDataGraph->setChecked(true);
+ boxScan->show();
+ boxHistogram->hide();
return;
}
cout << " - Histogram" << endl;
+
+ if(radioHistIntensity->isChecked())
+ pageHistogram->setEnabled(true);
+ else
+ pageHistogram->setEnabled(false);
+
+ boxScan->hide();
+ boxHistogram->show();
myPlot->EnablePlot(true);
Select1DPlot(isOriginallyOneD);
boxSnapshot->setEnabled(true);
@@ -556,7 +586,7 @@ void qTabPlot::SetPlot(){
boxFrequency->setEnabled(true);
boxPlotAxis->setEnabled(true);
if(!myPlot->isRunning())
- EnableScanBox(true);
+ EnableScanBox();
qDefs::Message(qDefs::INFORMATION,"Please check the Plot Histogram Options below "
"before Starting Acquitision","qTabPlot::SetPlot");
}
@@ -707,15 +737,18 @@ void qTabPlot::SetFrequency(){
//-------------------------------------------------------------------------------------------------------------------------------------------------
-void qTabPlot::EnableScanBox(bool Histo){
+void qTabPlot::EnableScanBox(){
#ifdef VERBOSE
- cout << "Entering Enable Scan Box, Histo:" << Histo << endl;
+ cout << "Entering Enable Scan Box"<< endl;
#endif
disconnect(btnGroupPlotType,SIGNAL(buttonClicked(int)),this, SLOT(SetPlot()));
disconnect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox()));
int mode0 = myDet->getScanMode(0);
int mode1 = myDet->getScanMode(1);
+
+ radioHistLevel0->setEnabled(mode0);
+ radioHistLevel1->setEnabled(mode1);
int ang;
bool angConvert = myDet->getAngularConversion(ang);
myPlot->EnableAnglePlot(angConvert);
@@ -732,6 +765,9 @@ void qTabPlot::EnableScanBox(bool Histo){
chkBinary_2->setEnabled(true);
}
+
+
+
//if angle plot or originally 2d, uncheck and disable scanbox
if ((angConvert) || (!isOriginallyOneD)){
boxScan->setChecked(false);
@@ -766,18 +802,23 @@ void qTabPlot::EnableScanBox(bool Histo){
pageAccumulate_2->setEnabled(false);
}
-
-
if(angConvert){
boxScan->setToolTip("Only 1D Plots enabled for Angle Plots");
//disable histogram
if(radioHistogram->isChecked()){
radioDataGraph->setChecked(true);
radioHistogram->setEnabled(false);
+ // To remind the updateplot in qdrawplot to set range after updating plot
+ myPlot->SetXYRange(true);
+ boxScan->show();
+ boxHistogram->hide();
}
}
}
+
+
+
//originally1d && not angle plot
else{
boxScan->setToolTip("");
@@ -787,6 +828,16 @@ void qTabPlot::EnableScanBox(bool Histo){
//2d enabled with boxscan
if(boxScan->isChecked()){
+
+ //2d for 1d detctors and histogram dont go
+ if(radioHistogram->isChecked()){
+ radioDataGraph->setChecked(true);
+ // To remind the updateplot in qdrawplot to set range after updating plot
+ myPlot->SetXYRange(true);
+ boxScan->show();
+ boxHistogram->hide();
+ }
+
//read every frame
disconnect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency()));
disconnect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency()));
@@ -814,12 +865,10 @@ void qTabPlot::EnableScanBox(bool Histo){
//histogram
if(radioHistogram->isChecked()){
- //switch back to datagraph
- if(!Histo)
- radioDataGraph->setChecked(true);
-
- pageHistogram->setEnabled(true);
- pageHistogram_2->setEnabled(true);
+ if(radioHistIntensity->isChecked())
+ pageHistogram->setEnabled(true);
+ else
+ pageHistogram->setEnabled(false);
stackedWidget->setCurrentIndex(stackedWidget->count()-1);
stackedWidget_2->setCurrentIndex(stackedWidget_2->count()-1);
box1D->setTitle(QString("1D Plot Options %1 - Histogram").arg(stackedWidget->currentIndex()+1));
@@ -851,7 +900,7 @@ void qTabPlot::EnableScanBox(bool Histo){
}else{
pageHistogram->setEnabled(false);
- pageHistogram_2->setEnabled(false);
+ /*pageHistogram_2->setEnabled(false);*/
}
connect(btnGroupPlotType,SIGNAL(buttonClicked(int)),this, SLOT(SetPlot()));
@@ -888,9 +937,49 @@ void qTabPlot::SetScanArgument(){
//histogram default - set before setscanargument
- myPlot->SetHistogram(radioHistogram->isChecked(),spinHistFrom->value(),spinHistTo->value(),spinHistSize->value());
+ int min = spinHistFrom->value();
+ int max = spinHistTo->value();
+ int size = spinHistSize->value();
+ int histArg = qDefs::Intensity;
if(radioHistogram->isChecked()){
- dispXAxis->setText("Intensity");
+ if(!radioHistIntensity->isChecked()){
+
+ int mode = 0;
+ histArg = qDefs::histLevel0;
+ if(radioHistLevel1->isChecked()){
+ mode = 1;
+ histArg = qDefs::histLevel1;
+ }
+
+
+ int numSteps = myDet->getScanSteps(mode);
+ double *values = NULL;
+ min = 0;max = 1;size = 1;
+
+ if(numSteps > 0){
+ values = new double[numSteps];
+ myDet->getScanSteps(mode,values);
+ min = values[0];
+ max = values[numSteps - 1];
+ size = (max - min)/(numSteps - 1);
+ min -= (size/2);
+ max += (size/2);
+ }
+ }
+
+ }
+
+ cout <<"min:"<SetHistogram(radioHistogram->isChecked(),histArg,min,max,size);
+
+
+ if(radioHistogram->isChecked()){
+ if(radioHistIntensity->isChecked())
+ dispXAxis->setText("Intensity");
+ else if (radioHistLevel0->isChecked())
+ dispXAxis->setText("Level 0");
+ else
+ dispXAxis->setText("Level 1");
dispYAxis->setText("Frequency");
myPlot->SetHistXAxisTitle("Intensity");
myPlot->SetHistYAxisTitle("Frequency");
@@ -941,36 +1030,6 @@ void qTabPlot::SetScanArgument(){
}
-//-------------------------------------------------------------------------------------------------------------------------------------------------
-
-void qTabPlot::Refresh(){
-#ifdef VERBOSE
- cout << endl << "**Updating Plot Tab" << endl;
-#endif
- if(!myPlot->isRunning()){
- if (!radioNoPlot->isChecked())
- boxFrequency->setEnabled(true);
- connect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox()));
- EnableScanBox(true);
- SetFrequency();
-
- }else{
- boxFrequency->setEnabled(false);
- disconnect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox()));
- boxScan->setEnabled(false);
- pageHistogram->setEnabled(false);
- pageHistogram_2->setEnabled(false);
- if(radioHistogram->isChecked())
- radioDataGraph->setEnabled(false);
- else
- radioHistogram->setEnabled(false);
- }
-#ifdef VERBOSE
- cout << "**Updated Plot Tab" << endl << endl;
-#endif
-}
-
-
//-------------------------------------------------------------------------------------------------------------------------------------------------
@@ -1025,3 +1084,47 @@ void qTabPlot::SetBinary(){
//-------------------------------------------------------------------------------------------------------------------------------------------------
+
+
+void qTabPlot::SetHistogramOptions(){
+ if(radioHistIntensity->isChecked()){
+ pageHistogram->setEnabled(true);
+ }else {
+ pageHistogram->setEnabled(false);
+ }
+}
+
+
+
+//-------------------------------------------------------------------------------------------------------------------------------------------------
+
+
+void qTabPlot::Refresh(){
+#ifdef VERBOSE
+ cout << endl << "**Updating Plot Tab" << endl;
+#endif
+ if(!myPlot->isRunning()){
+ if (!radioNoPlot->isChecked())
+ boxFrequency->setEnabled(true);
+ connect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox()));
+ EnableScanBox();
+ SetFrequency();
+
+ }else{
+ boxFrequency->setEnabled(false);
+ disconnect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox()));
+ boxScan->setEnabled(false);
+ pageHistogram->setEnabled(false);
+ if(radioHistogram->isChecked())
+ radioDataGraph->setEnabled(false);
+ else
+ radioHistogram->setEnabled(false);
+ }
+#ifdef VERBOSE
+ cout << "**Updated Plot Tab" << endl << endl;
+#endif
+}
+
+
+//-------------------------------------------------------------------------------------------------------------------------------------------------
+