histogram for 2d and s curves

This commit is contained in:
Maliakal Dhanya 2014-08-05 11:30:36 +02:00
parent 8a26eef0bf
commit c33657f04d
6 changed files with 334 additions and 53 deletions

View File

@ -2765,6 +2765,123 @@ Interval between plots has 2 modes. A condition to be satisfied, in order to avo
<bool>true</bool>
</property>
</widget>
<widget class="QGroupBox" name="boxHistogram">
<property name="geometry">
<rect>
<x>410</x>
<y>5</y>
<width>351</width>
<height>51</height>
</rect>
</property>
<property name="title">
<string>Histogram - X Axis Values</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<widget class="QWidget" name="horizontalLayoutWidget_15">
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>351</width>
<height>26</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QRadioButton" name="radioHistIntensity">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;nobr&gt;Enabled only when there is a Scan Level 0&lt;/nobr&gt;</string>
</property>
<property name="text">
<string>Intensity</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_10">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>7</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QRadioButton" name="radioHistLevel0">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;nobr&gt;Enabled only when there is a Scan Level 1&lt;/nobr&gt;</string>
</property>
<property name="text">
<string>Level 0</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_11">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>7</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QRadioButton" name="radioHistLevel1">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;nobr&gt;Enabled only when there is a Scan Level 0 or a Scan Level 1, not both&lt;/nobr&gt;</string>
</property>
<property name="text">
<string>Level 1</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<zorder>box1D</zorder>
<zorder>box2D</zorder>
<zorder>boxSave</zorder>
@ -2775,6 +2892,7 @@ Interval between plots has 2 modes. A condition to be satisfied, in order to avo
<zorder>boxSnapshot</zorder>
<zorder>btnRight</zorder>
<zorder>btnLeft</zorder>
<zorder>boxHistogram</zorder>
</widget>
<tabstops>
<tabstop>radioNoPlot</tabstop>

View File

@ -281,6 +281,17 @@ static const int64_t GUI_VERSION=0x20121213;
};
//-------------------------------------------------------------------------------------------------------------------------------------------------
/** histogram arguments*/
enum histogramArgumentList{
Intensity,
histLevel0,
histLevel1
};
//-------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -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" */

View File

@ -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);

View File

@ -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,7 +975,18 @@ int qDrawPlot::GetData(detectorData *data,int fIndex){
if(originally2D)
numValues = nPixelsX*nPixelsY;
//clean up graph
if(histogramArgument == qDefs::Intensity){
for(int j=0;j<histogramSamples.size();j++){
histogramSamples[j].value = 0;
}
}
int val = 0 ;
for(int i=0;i<numValues;i++){
//frequency of intensity
if(histogramArgument == qDefs::Intensity){
//ignore outside limits
if ((data->values[i] <= histFrom) || (data->values[i] >= histTo))
continue;
@ -985,6 +997,36 @@ int qDrawPlot::GetData(detectorData *data,int fIndex){
}
}
//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 ((scanval <= histFrom) || (scanval >= histTo) || (scanval == -1))
scanval = -1;
//check for intervals, increment if validates
for(int j=0;j<histogramSamples.size();j++){
if(histogramSamples[j].interval.contains(scanval)){
histogramSamples[j].value = val;
cout << "j:"<<j<<" scanval:"<<scanval<<" val:"<<val<<endl;
}
}
}
}
//not histogram

View File

@ -45,7 +45,8 @@ qTabPlot::qTabPlot(QWidget *parent,multiSlsDetector*& detector, qDrawPlot*& plot
spinTimeGap(0),
comboTimeGapUnit(0),
btnGroupScan(0),
btnGroupPlotType(0){
btnGroupPlotType(0),
btnGroupHistogram(0){
setupUi(this);
SetupWidgetWindow();
Initialization();
@ -84,6 +85,12 @@ void qTabPlot::SetupWidgetWindow(){
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);
// 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,"<nobr>Histogram cannot be used together with 2D Scan Plots.</nobr><br>"
"<nobr>Uncheck <b>2D Scan</b> plots to plot <b>Histograms</b></nobr>", "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,"<nobr>Please check the <b>Plot Histogram Options</b> below "
"before <b>Starting Acquitision</b></nobr>","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("<nobr>Only 1D Plots enabled for Angle Plots</nobr>");
//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);
if(radioHistIntensity->isChecked())
pageHistogram->setEnabled(true);
pageHistogram_2->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()){
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:"<<min<<" max:"<<max<<" size:"<<size<<endl;
myPlot->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
}
//-------------------------------------------------------------------------------------------------------------------------------------------------