histogram included, improved ready every frame, and other stuff.. a working version

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@230 af1100a4-978c-4157-bff7-07162d2ba061
This commit is contained in:
l_maliakal_d
2013-08-27 15:47:07 +00:00
parent d9444121b7
commit 22de76c8b0
6 changed files with 685 additions and 340 deletions

View File

@ -99,7 +99,7 @@
</rect> </rect>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>4</number> <number>5</number>
</property> </property>
<widget class="QWidget" name="page_6"> <widget class="QWidget" name="page_6">
<widget class="QWidget" name="gridLayoutWidget_5"> <widget class="QWidget" name="gridLayoutWidget_5">
@ -186,7 +186,7 @@
</layout> </layout>
</widget> </widget>
</widget> </widget>
<widget class="QWidget" name="page_4"> <widget class="QWidget" name="pageAccumulate_2">
<widget class="QWidget" name="horizontalLayoutWidget_6"> <widget class="QWidget" name="horizontalLayoutWidget_6">
<property name="geometry"> <property name="geometry">
<rect> <rect>
@ -294,7 +294,7 @@
</property> </property>
</widget> </widget>
</widget> </widget>
<widget class="QWidget" name="page_7"> <widget class="QWidget" name="pagePedestal_2">
<widget class="QWidget" name="horizontalLayoutWidget_5"> <widget class="QWidget" name="horizontalLayoutWidget_5">
<property name="geometry"> <property name="geometry">
<rect> <rect>
@ -580,6 +580,167 @@ Displays minimum, maximum and sum of values for each plot.
</layout> </layout>
</widget> </widget>
</widget> </widget>
<widget class="QWidget" name="pageHistogram_2">
<property name="enabled">
<bool>true</bool>
</property>
<widget class="QWidget" name="horizontalLayoutWidget_14">
<property name="geometry">
<rect>
<x>25</x>
<y>5</y>
<width>311</width>
<height>26</height>
</rect>
</property>
<layout class="QHBoxLayout" name="layoutThreshold_4">
<property name="spacing">
<number>1</number>
</property>
<item>
<widget class="QLabel" name="lblHistFrom_2">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>from </string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinHistFrom_2">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>16777215</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblHistTo_2">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string> to </string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinHistTo_2">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>16777215</number>
</property>
<property name="value">
<number>10000</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblHistSize_2">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string> size </string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinHistSize_2">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>16777215</number>
</property>
<property name="value">
<number>1000</number>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</widget> </widget>
</widget> </widget>
<widget class="QGroupBox" name="box1D"> <widget class="QGroupBox" name="box1D">
@ -610,7 +771,7 @@ Displays minimum, maximum and sum of values for each plot.
</rect> </rect>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>6</number>
</property> </property>
<widget class="QWidget" name="page"> <widget class="QWidget" name="page">
<widget class="QWidget" name="gridLayoutWidget_2"> <widget class="QWidget" name="gridLayoutWidget_2">
@ -782,7 +943,7 @@ Displays minimum, maximum and sum of values for each plot.
</layout> </layout>
</widget> </widget>
</widget> </widget>
<widget class="QWidget" name="page_5"> <widget class="QWidget" name="pageAccumulate">
<widget class="QPushButton" name="btnResetAccumulate"> <widget class="QPushButton" name="btnResetAccumulate">
<property name="geometry"> <property name="geometry">
<rect> <rect>
@ -890,7 +1051,7 @@ Displays minimum, maximum and sum of values for each plot.
</layout> </layout>
</widget> </widget>
</widget> </widget>
<widget class="QWidget" name="page_3"> <widget class="QWidget" name="pagePedestal">
<widget class="QWidget" name="horizontalLayoutWidget_8"> <widget class="QWidget" name="horizontalLayoutWidget_8">
<property name="geometry"> <property name="geometry">
<rect> <rect>
@ -1186,6 +1347,167 @@ Displays minimum, maximum and sum of values for each plot.
</layout> </layout>
</widget> </widget>
</widget> </widget>
<widget class="QWidget" name="pageHistogram">
<property name="enabled">
<bool>true</bool>
</property>
<widget class="QWidget" name="horizontalLayoutWidget_13">
<property name="geometry">
<rect>
<x>25</x>
<y>5</y>
<width>311</width>
<height>26</height>
</rect>
</property>
<layout class="QHBoxLayout" name="layoutThreshold_3">
<property name="spacing">
<number>1</number>
</property>
<item>
<widget class="QLabel" name="lblHistFrom">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>from </string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinHistFrom">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>16777215</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblHistTo">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string> to </string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinHistTo">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>16777215</number>
</property>
<property name="value">
<number>10000</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblHistSize">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string> size </string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinHistSize">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>16777215</number>
</property>
<property name="value">
<number>1000</number>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</widget> </widget>
</widget> </widget>
<widget class="QGroupBox" name="boxSave"> <widget class="QGroupBox" name="boxSave">
@ -1336,7 +1658,7 @@ Displays minimum, maximum and sum of values for each plot.
<rect> <rect>
<x>10</x> <x>10</x>
<y>20</y> <y>20</y>
<width>341</width> <width>342</width>
<height>26</height> <height>26</height>
</rect> </rect>
</property> </property>
@ -1902,7 +2224,7 @@ Displays minimum, maximum and sum of values for each plot.
<item row="0" column="2"> <item row="0" column="2">
<widget class="QRadioButton" name="radioHistogram"> <widget class="QRadioButton" name="radioHistogram">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>true</bool>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
@ -2443,6 +2765,16 @@ Interval between plots has 2 modes. A condition to be satisfied, in order to avo
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
<zorder>box1D</zorder>
<zorder>box2D</zorder>
<zorder>boxSave</zorder>
<zorder>boxScan</zorder>
<zorder>boxPlotAxis</zorder>
<zorder>groupBox_3</zorder>
<zorder>boxFrequency</zorder>
<zorder>boxSnapshot</zorder>
<zorder>btnRight</zorder>
<zorder>btnLeft</zorder>
</widget> </widget>
<tabstops> <tabstops>
<tabstop>radioNoPlot</tabstop> <tabstop>radioNoPlot</tabstop>

View File

@ -25,6 +25,14 @@ class qCloneWidget;
#include <QString> #include <QString>
#include "qwt_symbol.h" #include "qwt_symbol.h"
#include <QVector>
#include <qwt_series_data.h>
#include <qwt_plot_histogram.h>
#include <qwt_plot_grid.h>
#include <qwt_column_symbol.h>
#include <qpen.h>
/** C++ Include Headers */ /** C++ Include Headers */
@ -134,6 +142,9 @@ public:
/** set binary range */ /** set binary range */
void SetBinary(bool enable, int from=0, int to=0); 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;};
public slots: public slots:
/** To select 1D or 2D plot /** To select 1D or 2D plot
@param i is 1 for 1D, else 2D plot */ @param i is 1 for 1D, else 2D plot */
@ -545,6 +556,17 @@ QLabel *lblSumDisp;
bool displayStatistics; bool displayStatistics;
/* histogram */
bool histogram;
int histFrom;
int histTo;
int histSize;
QwtPlotGrid *grid;
QwtPlotHistogram *plotHistogram;
QVector<QwtIntervalSample> histogramSamples;
signals: signals:
void UpdatingPlotFinished(); void UpdatingPlotFinished();

View File

@ -70,6 +70,7 @@ private:
QDoubleSpinBox *spinTimeGap; QDoubleSpinBox *spinTimeGap;
QComboBox *comboTimeGapUnit; QComboBox *comboTimeGapUnit;
QButtonGroup *btnGroupScan; QButtonGroup *btnGroupScan;
QButtonGroup *btnGroupPlotType;
/** some Default Values */ /** some Default Values */
static QString defaultPlotTitle; static QString defaultPlotTitle;
@ -97,12 +98,6 @@ private:
*/ */
void Initialization(); void Initialization();
/** This enabled/disables the nth frame from frequency plot
* @param enable enable/disable
*/
void EnablingNthFrameFunction(bool enable);
public slots: public slots:
/** Set frequency between plots*/ /** Set frequency between plots*/
@ -110,7 +105,7 @@ public slots:
/** Enable Scan box /** Enable Scan box
*/ */
void EnableScanBox(); void EnableScanBox(bool Histo=false);
/** Update all ranges, interpolate etc after cloning /** Update all ranges, interpolate etc after cloning
*/ */

View File

@ -2,10 +2,10 @@
#define SVNURL "file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui" #define SVNURL "file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui"
//#define SVNREPPATH "" //#define SVNREPPATH ""
#define SVNREPUUID "af1100a4-978c-4157-bff7-07162d2ba061" #define SVNREPUUID "af1100a4-978c-4157-bff7-07162d2ba061"
//#define SVNREV 0x226 //#define SVNREV 0x229
//#define SVNKIND "" //#define SVNKIND ""
//#define SVNSCHED "" //#define SVNSCHED ""
#define SVNAUTH "l_maliakal_d" #define SVNAUTH "l_maliakal_d"
#define SVNREV 0x226 #define SVNREV 0x229
#define SVNDATE 0x20130813 #define SVNDATE 0x20130816
// //

View File

@ -9,7 +9,6 @@
#include "qCloneWidget.h" #include "qCloneWidget.h"
#include "slsDetector.h" #include "slsDetector.h"
#include"fileIOStatic.h" #include"fileIOStatic.h"
// Project Class Headers // Project Class Headers
#include "slsDetector.h" #include "slsDetector.h"
#include "multiSlsDetector.h" #include "multiSlsDetector.h"
@ -19,6 +18,8 @@
#include <QImage> #include <QImage>
#include <QPainter> #include <QPainter>
#include <QFileDialog> #include <QFileDialog>
//#include "qwt_double_interval.h"
#include "qwt_series_data.h"
// C++ Include Headers // C++ Include Headers
#include <iostream> #include <iostream>
#include <string> #include <string>
@ -195,6 +196,20 @@ void qDrawPlot::SetupWidgetWindow(){
binaryFrom = 0; binaryFrom = 0;
binaryTo = 0; binaryTo = 0;
//histogram
histogram = false;
histFrom = 0;
histTo = 0;
histSize = 0;
grid = new QwtPlotGrid;
grid->enableXMin(true);
grid->enableYMin(true);
grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
grid->setMinPen(QPen(Qt::gray, 0 , Qt::DotLine));
plotHistogram = new QwtPlotHistogram();
plotHistogram->setStyle(QwtPlotHistogram::Columns);
//widget related initialization //widget related initialization
@ -464,9 +479,10 @@ bool qDrawPlot::StartOrStopThread(bool start){
//refixing all the min and max for all scans //refixing all the min and max for all scans
if (scanArgument == qDefs::None); if (scanArgument == qDefs::None);
else else{
plot2D->GetPlot()->UnZoom();
plot2D->GetPlot()->SetZoom(-0.5,startPixel,nPixelsX,endPixel-startPixel); plot2D->GetPlot()->SetZoom(-0.5,startPixel,nPixelsX,endPixel-startPixel);
}
cout << "Starting new acquisition thread ...." << endl; cout << "Starting new acquisition thread ...." << endl;
// Start acquiring data from server // Start acquiring data from server
@ -498,11 +514,6 @@ void qDrawPlot::SetScanArgument(int scanArg){
if(plot_in_scope==1) Clear1DPlot(); if(plot_in_scope==1) Clear1DPlot();
maxPixelsY = 0;
minPixelsY = 0;
nPixelsX = myDet->getTotalNumberOfChannels(slsDetectorDefs::X);
nPixelsY = myDet->getTotalNumberOfChannels(slsDetectorDefs::Y);
// Number of Exposures - must be calculated here to get npixelsy for allframes/frameindex scans // Number of Exposures - must be calculated here to get npixelsy for allframes/frameindex scans
int numFrames = (isFrameEnabled)*((int)myDet->setTimer(slsDetectorDefs::FRAME_NUMBER,-1)); int numFrames = (isFrameEnabled)*((int)myDet->setTimer(slsDetectorDefs::FRAME_NUMBER,-1));
int numTriggers = (isTriggerEnabled)*((int)myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER,-1)); int numTriggers = (isTriggerEnabled)*((int)myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER,-1));
@ -519,6 +530,12 @@ void qDrawPlot::SetScanArgument(int scanArg){
if(anglePlot) number_of_exposures = numScan0 * numScan1;// * numPos; if(anglePlot) number_of_exposures = numScan0 * numScan1;// * numPos;
cout << "\tNumber of Exposures Per Measurement:" << number_of_exposures << endl; cout << "\tNumber of Exposures Per Measurement:" << number_of_exposures << endl;
maxPixelsY = 0;
minPixelsY = 0;
nPixelsX = myDet->getTotalNumberOfChannels(slsDetectorDefs::X);
nPixelsY = myDet->getTotalNumberOfChannels(slsDetectorDefs::Y);
//cannot do this in between measurements , so update instantly //cannot do this in between measurements , so update instantly
if(scanArgument==qDefs::Level0){ if(scanArgument==qDefs::Level0){
//no need to check if numsteps=0,cuz otherwise this mode wont be set in plot tab //no need to check if numsteps=0,cuz otherwise this mode wont be set in plot tab
@ -569,6 +586,30 @@ void qDrawPlot::SetScanArgument(int scanArg){
lastImageArray[py*nPixelsX+px] = 0; lastImageArray[py*nPixelsX+px] = 0;
//histogram
if(histogram){
histogramSamples.resize(0);
int iloop = 0;
int min = iloop*histSize + histFrom;
int max = (iloop+1)*histSize + histFrom;
while(min < histTo){
histogramSamples.resize(iloop+1);
histogramSamples[iloop].interval.setInterval(min,max);
histogramSamples[iloop].value = 0;
iloop++;
min = max;
max = (iloop+1)*histSize + histFrom;
if(max>histTo)
max = histTo;
}
//print values
cout << "Histogram Intervals:" << endl;
for(int j=0;j<histogramSamples.size();j++){
cout<<j<<":\tmin:"<<histogramSamples[j].interval.minValue()<<""
"\tmax:"<<histogramSamples[j].interval.maxValue()<<"\t:"<<histogramSamples[j].value<<endl;
}
}
UnlockLastImageArray(); UnlockLastImageArray();
qDefs::checkErrorMessage(myDet,"qDrawPlot::SetScanArgument"); qDefs::checkErrorMessage(myDet,"qDrawPlot::SetScanArgument");
@ -816,8 +857,6 @@ int qDrawPlot::GetData(detectorData *data,int fIndex){
lastImageNumber= currentFrame+1; lastImageNumber= currentFrame+1;
//title //title
imageTitle = temp_title; imageTitle = temp_title;
cout<<"lastImageNumber:"<<lastImageNumber<<endl;
cout<<"currentScanDivLevel:"<<currentScanDivLevel<<endl;
//copy data //copy data
for(unsigned int px=0;px<nPixelsX;px++) lastImageArray[currentScanDivLevel*nPixelsX+px] += data->values[px]; for(unsigned int px=0;px<nPixelsX;px++) lastImageArray[currentScanDivLevel*nPixelsX+px] += data->values[px];
UnlockLastImageArray(); UnlockLastImageArray();
@ -885,54 +924,80 @@ int qDrawPlot::GetData(detectorData *data,int fIndex){
if(plot_in_scope==1){ if(plot_in_scope==1){
// Titles // Titles
histTitle[0] = temp_title; histTitle[0] = temp_title;
// Persistency
if(currentPersistency < persistency)currentPersistency++;
else currentPersistency=persistency;
nHists = currentPersistency+1;
histNBins = nPixelsX;
// copy data //histogram
for(int i=currentPersistency;i>0;i--) if(histogram){
memcpy(histYAxis[i],histYAxis[i-1],nPixelsX*sizeof(double));
//recalculating pedestal
if(startPedestalCal){
//start adding frames to get to the pedestal value
if(pedestalCount<NUM_PEDESTAL_FRAMES){
for(unsigned int px=0;px<nPixelsX;px++)
tempPedestalVals[px] += data->values[px];
memcpy(histYAxis[0],data->values,nPixelsX*sizeof(double));
pedestalCount++;
}
//calculate the pedestal value
if(pedestalCount==NUM_PEDESTAL_FRAMES){
cout << "Pedestal Calculated" << endl;
for(unsigned int px=0;px<nPixelsX;px++)
tempPedestalVals[px] = tempPedestalVals[px]/(double)NUM_PEDESTAL_FRAMES;
memcpy(pedestalVals,tempPedestalVals,nPixelsX*sizeof(double));
startPedestalCal = 0;
}
}
//normal data
if(((!pedestal)&(!accumulate)) || (resetAccumulate)){
memcpy(histYAxis[0],data->values,nPixelsX*sizeof(double));
resetAccumulate = false; resetAccumulate = false;
lastImageNumber= currentFrame+1;
int numValues = nPixelsX;
if(originally2D)
numValues = nPixelsX*nPixelsY;
for(int i=0;i<numValues;i++){
//ignore outside limits
if ((data->values[i] <= histFrom) || (data->values[i] >= histTo))
continue;
//check for intervals, increment if validates
for(int j=0;j<histogramSamples.size();j++){
if(histogramSamples[j].interval.contains(data->values[i]))
histogramSamples[j].value += 1;
}
}
} }
//pedestal or accumulate //not histogram
else{ else{
for(unsigned int px=0;px<(nPixelsX*nPixelsY);px++){ // Persistency
if(accumulate) if(currentPersistency < persistency)currentPersistency++;
histYAxis[0][px] += data->values[px]; else currentPersistency=persistency;
else nHists = currentPersistency+1;
histYAxis[0][px] = data->values[px]; histNBins = nPixelsX;
if(pedestal)
histYAxis[0][px] = histYAxis[0][px] - (pedestalVals[px]); // copy data
if(binary) { for(int i=currentPersistency;i>0;i--)
if ((histYAxis[0][px] >= binaryFrom) && (histYAxis[0][px] <= binaryTo)) memcpy(histYAxis[i],histYAxis[i-1],nPixelsX*sizeof(double));
histYAxis[0][px] = 1;
//recalculating pedestal
if(startPedestalCal){
//start adding frames to get to the pedestal value
if(pedestalCount<NUM_PEDESTAL_FRAMES){
for(unsigned int px=0;px<nPixelsX;px++)
tempPedestalVals[px] += data->values[px];
memcpy(histYAxis[0],data->values,nPixelsX*sizeof(double));
pedestalCount++;
}
//calculate the pedestal value
if(pedestalCount==NUM_PEDESTAL_FRAMES){
cout << "Pedestal Calculated" << endl;
for(unsigned int px=0;px<nPixelsX;px++)
tempPedestalVals[px] = tempPedestalVals[px]/(double)NUM_PEDESTAL_FRAMES;
memcpy(pedestalVals,tempPedestalVals,nPixelsX*sizeof(double));
startPedestalCal = 0;
}
}
//normal data
if(((!pedestal)&(!accumulate)) || (resetAccumulate)){
memcpy(histYAxis[0],data->values,nPixelsX*sizeof(double));
resetAccumulate = false;
}
//pedestal or accumulate
else{
for(unsigned int px=0;px<(nPixelsX*nPixelsY);px++){
if(accumulate)
histYAxis[0][px] += data->values[px];
else else
histYAxis[0][px] = 0; histYAxis[0][px] = data->values[px];
if(pedestal)
histYAxis[0][px] = histYAxis[0][px] - (pedestalVals[px]);
if(binary) {
if ((histYAxis[0][px] >= binaryFrom) && (histYAxis[0][px] <= binaryTo))
histYAxis[0][px] = 1;
else
histYAxis[0][px] = 0;
}
} }
} }
} }
@ -955,7 +1020,6 @@ int qDrawPlot::GetData(detectorData *data,int fIndex){
cout << "Pedestal Calculated" << endl; cout << "Pedestal Calculated" << endl;
for(unsigned int px=0;px<(nPixelsX*nPixelsY);px++) for(unsigned int px=0;px<(nPixelsX*nPixelsY);px++)
tempPedestalVals[px] = tempPedestalVals[px]/(double)NUM_PEDESTAL_FRAMES; tempPedestalVals[px] = tempPedestalVals[px]/(double)NUM_PEDESTAL_FRAMES;
memcpy(pedestalVals,tempPedestalVals,nPixelsX*nPixelsY*sizeof(double)); memcpy(pedestalVals,tempPedestalVals,nPixelsX*nPixelsY*sizeof(double));
startPedestalCal = 0; startPedestalCal = 0;
} }
@ -1012,9 +1076,9 @@ int qDrawPlot::GetAcquisitionFinishedCallBack(double currentProgress,int detecto
int qDrawPlot::AcquisitionFinished(double currentProgress, int detectorStatus){ int qDrawPlot::AcquisitionFinished(double currentProgress, int detectorStatus){
//#ifdef VERBOSE #ifdef VERBOSE
cout << "\nEntering Acquisition Finished with status " ; cout << "\nEntering Acquisition Finished with status " ;
//#endif #endif
QString status = QString(slsDetectorBase::runStatusType(slsDetectorDefs::runStatus(detectorStatus)).c_str()); QString status = QString(slsDetectorBase::runStatusType(slsDetectorDefs::runStatus(detectorStatus)).c_str());
#ifdef VERBOSE #ifdef VERBOSE
cout << status.toAscii().constData() << " and progress " << currentProgress << endl; cout << status.toAscii().constData() << " and progress " << currentProgress << endl;
@ -1078,9 +1142,9 @@ int qDrawPlot::GetMeasurementFinishedCallBack(int currentMeasurementIndex, int f
int qDrawPlot::MeasurementFinished(int currentMeasurementIndex, int fileIndex){ int qDrawPlot::MeasurementFinished(int currentMeasurementIndex, int fileIndex){
//#ifdef VERBOSE #ifdef VERBOSE
cout << "Entering Measurement Finished with currentMeasurement " << currentMeasurementIndex << " and fileIndex " << fileIndex << endl; cout << "Entering Measurement Finished with currentMeasurement " << currentMeasurementIndex << " and fileIndex " << fileIndex << endl;
//#endif #endif
//to make sure it plots the last frame before setting lastimagearray all to 0 //to make sure it plots the last frame before setting lastimagearray all to 0
//if(plot_in_scope==2) //if(plot_in_scope==2)
usleep(500000); usleep(500000);
@ -1130,8 +1194,10 @@ void qDrawPlot::SelectPlot(int i){ //1 for 1D otherwise 2D
void qDrawPlot::Clear1DPlot(){ void qDrawPlot::Clear1DPlot(){
for(QVector<SlsQtH1D*>::iterator h = plot1D_hists.begin(); for(QVector<SlsQtH1D*>::iterator h = plot1D_hists.begin(); h!=plot1D_hists.end();h++)
h!=plot1D_hists.end();h++) (*h)->Detach(plot1D); //clear plot (*h)->Detach(plot1D);
plotHistogram->detach();
} }
@ -1153,31 +1219,46 @@ void qDrawPlot::UpdatePlot(){
if(plot_in_scope==1){ if(plot_in_scope==1){
if(lastImageNumber){ if(lastImageNumber){
#ifdef VERYVERBOSE #ifdef VERYVERBOSE
cout << "*Last Image Number:" << lastImageNumber << endl; cout << "Last Image Number:" << lastImageNumber << endl;
#endif #endif
if(histNBins){ if(histNBins){
Clear1DPlot(); Clear1DPlot();
plot1D->SetXTitle(histXAxisTitle.toAscii().constData()); plot1D->SetXTitle(histXAxisTitle.toAscii().constData());
plot1D->SetYTitle(histYAxisTitle.toAscii().constData()); plot1D->SetYTitle(histYAxisTitle.toAscii().constData());
for(int hist_num=0;hist_num<(int)nHists;hist_num++){
SlsQtH1D* h; //histogram
if(hist_num+1>plot1D_hists.size()){ if(histogram){
if(anglePlot) plotHistogram->setData(new QwtIntervalSeriesData(histogramSamples));
plot1D_hists.append(h=new SlsQtH1D("",histNBins,histXAngleAxis,histYAngleAxis)); plotHistogram->setPen(QPen(Qt::red));
else plotHistogram->setBrush(QBrush(Qt::red,Qt::Dense4Pattern));//Qt::SolidPattern
plot1D_hists.append(h=new SlsQtH1D("",histNBins,histXAxis,GetHistYAxis(hist_num)));
h->SetLineColor(hist_num+1);
}else{
h=plot1D_hists.at(hist_num);
if(anglePlot)
h->SetData(histNBins,histXAngleAxis,histYAngleAxis);
else
h->SetData(histNBins,histXAxis,GetHistYAxis(hist_num));
}
SetStyle(h);
histFrameIndexTitle->setText(GetHistTitle(0)); histFrameIndexTitle->setText(GetHistTitle(0));
//h->setTitle(GetHistTitle(hist_num)); plotHistogram->attach(plot1D);
h->Attach(plot1D); plot1D->SetZoomBase(plotHistogram->boundingRect().left(),0,
plotHistogram->boundingRect().width(),plotHistogram->boundingRect().height());
}
//not histogram
else{
for(int hist_num=0;hist_num<(int)nHists;hist_num++){
SlsQtH1D* h;
if(hist_num+1>plot1D_hists.size()){
if(anglePlot)
plot1D_hists.append(h=new SlsQtH1D("",histNBins,histXAngleAxis,histYAngleAxis));
else
plot1D_hists.append(h=new SlsQtH1D("",histNBins,histXAxis,GetHistYAxis(hist_num)));
h->SetLineColor(hist_num+1);
}else{
h=plot1D_hists.at(hist_num);
if(anglePlot)
h->SetData(histNBins,histXAngleAxis,histYAngleAxis);
else
h->SetData(histNBins,histXAxis,GetHistYAxis(hist_num));
}
SetStyle(h);
histFrameIndexTitle->setText(GetHistTitle(0));
//h->setTitle(GetHistTitle(hist_num));
h->Attach(plot1D);
}
plot1D->Update();
} }
// update range if required // update range if required
if(XYRangeChanged){ if(XYRangeChanged){
@ -1209,13 +1290,15 @@ void qDrawPlot::UpdatePlot(){
if(lastImageArray){ if(lastImageArray){
if(lastImageNumber&&last_plot_number!=(int)lastImageNumber && //there is a new plot if(lastImageNumber&&last_plot_number!=(int)lastImageNumber && //there is a new plot
nPixelsX>0&&nPixelsY>0){ nPixelsX>0&&nPixelsY>0){
//plot2D->GetPlot()->SetData(nPixelsX,-0.5,nPixelsX-0.5,nPixelsY,-0.5,nPixelsY-0.5,lastImageArray);
plot2D->GetPlot()->SetData(nPixelsX,-0.5,nPixelsX-0.5,nPixelsY,startPixel,endPixel,lastImageArray); plot2D->GetPlot()->SetData(nPixelsX,-0.5,nPixelsX-0.5,nPixelsY,startPixel,endPixel,lastImageArray);
plot2D->setTitle(GetImageTitle()); plot2D->setTitle(GetImageTitle());
plot2D->SetXTitle(imageXAxisTitle); plot2D->SetXTitle(imageXAxisTitle);
plot2D->SetYTitle(imageYAxisTitle); plot2D->SetYTitle(imageYAxisTitle);
plot2D->SetZTitle(imageZAxisTitle); plot2D->SetZTitle(imageZAxisTitle);
plot2D->UpdateNKeepSetRangeIfSet(); //this will keep a "set" z range, and call Plot()->Update(); plot2D->UpdateNKeepSetRangeIfSet(); //keep a "set" z range, and call Update();
//to solve the problems regarding zooming out and zoom in
//plot2D->GetPlot()->SetZoom(-0.5,startPixel,nPixelsX,endPixel-startPixel);
} }
// update range if required // update range if required
if(XYRangeChanged){ if(XYRangeChanged){
@ -1227,6 +1310,7 @@ void qDrawPlot::UpdatePlot(){
plot2D->GetPlot()->SetYMinMax(XYRangeValues[qDefs::YMINIMUM],XYRangeValues[qDefs::YMAXIMUM]); plot2D->GetPlot()->SetYMinMax(XYRangeValues[qDefs::YMINIMUM],XYRangeValues[qDefs::YMAXIMUM]);
XYRangeChanged = false; XYRangeChanged = false;
} }
plot2D->GetPlot()->Update();
//Display Statistics //Display Statistics
if(displayStatistics){ if(displayStatistics){
double min=0,max=0,sum=0; double min=0,max=0,sum=0;
@ -1238,16 +1322,14 @@ void qDrawPlot::UpdatePlot(){
if(saveAll) SavePlotAutomatic(); if(saveAll) SavePlotAutomatic();
} }
} }
//}
last_plot_number=lastImageNumber; last_plot_number=lastImageNumber;
//set plot title //set plot title
boxPlot->setTitle(plotTitle); boxPlot->setTitle(plotTitle);
} }
UnlockLastImageArray(); UnlockLastImageArray();
} }
//if acqq stopped before this line, it continues from here, shouldnt restart plotting timer //if acq stopped before this line, it continues from here, shouldnt restart plotting timer
if(!stop_signal){ if(!stop_signal){
if(!frameFactor) if(!frameFactor)
plot_update_timer->start((int)timerValue); plot_update_timer->start((int)timerValue);

View File

@ -44,7 +44,8 @@ qTabPlot::qTabPlot(QWidget *parent,multiSlsDetector*& detector, qDrawPlot*& plot
spinNthFrame(0), spinNthFrame(0),
spinTimeGap(0), spinTimeGap(0),
comboTimeGapUnit(0), comboTimeGapUnit(0),
btnGroupScan(0){ btnGroupScan(0),
btnGroupPlotType(0){
setupUi(this); setupUi(this);
SetupWidgetWindow(); SetupWidgetWindow();
Initialization(); Initialization();
@ -77,6 +78,12 @@ void qTabPlot::SetupWidgetWindow(){
btnGroupScan->addButton(radioFileIndex,2); btnGroupScan->addButton(radioFileIndex,2);
btnGroupScan->addButton(radioAllFrames,3); btnGroupScan->addButton(radioAllFrames,3);
//plot type
btnGroupPlotType = new QButtonGroup(this);
btnGroupPlotType->addButton(radioNoPlot,0);
btnGroupPlotType->addButton(radioDataGraph,1);
btnGroupPlotType->addButton(radioHistogram,2);
// Plot Axis // Plot Axis
dispTitle->setEnabled(false); dispTitle->setEnabled(false);
dispXAxis->setEnabled(false); dispXAxis->setEnabled(false);
@ -146,19 +153,15 @@ void qTabPlot::SetupWidgetWindow(){
switch(myDet->getDetectorsType()){ switch(myDet->getDetectorsType()){
case slsDetectorDefs::MYTHEN: case slsDetectorDefs::MYTHEN:
isOriginallyOneD = true; isOriginallyOneD = true;
chkPedestal->setEnabled(false); pagePedestal->setEnabled(false);
btnRecalPedestal->setEnabled(false); pagePedestal_2->setEnabled(false);
chkPedestal_2->setEnabled(false);
btnRecalPedestal_2->setEnabled(false);
chkBinary->setEnabled(false); chkBinary->setEnabled(false);
chkBinary_2->setEnabled(false); chkBinary_2->setEnabled(false);
break; break;
case slsDetectorDefs::EIGER: case slsDetectorDefs::EIGER:
isOriginallyOneD = false; isOriginallyOneD = false;
chkPedestal->setEnabled(false); pagePedestal->setEnabled(false);
btnRecalPedestal->setEnabled(false); pagePedestal_2->setEnabled(false);
chkPedestal_2->setEnabled(false);
btnRecalPedestal_2->setEnabled(false);
chkBinary->setEnabled(false); chkBinary->setEnabled(false);
chkBinary_2->setEnabled(false); chkBinary_2->setEnabled(false);
break; break;
@ -231,6 +234,12 @@ void qTabPlot::SetPlotOptionsLeftPage(){
void qTabPlot::Select1DPlot(bool b){ void qTabPlot::Select1DPlot(bool b){
#ifdef VERBOSE
if(b)
cout << "Selecting 1D Plot" << endl;
else
cout << "Selecting 2D Plot" << endl;
#endif
isOneD = b; isOneD = b;
lblFrom->setEnabled(false); lblFrom->setEnabled(false);
lblTo->setEnabled(false); lblTo->setEnabled(false);
@ -263,11 +272,9 @@ void qTabPlot::Select1DPlot(bool b){
void qTabPlot::Initialization(){ void qTabPlot::Initialization(){
// Plot arguments box // Plot arguments box
connect(radioNoPlot, SIGNAL(toggled(bool)),this, SLOT(SetPlot())); connect(btnGroupPlotType,SIGNAL(buttonClicked(int)),this, SLOT(SetPlot()));
connect(radioHistogram, SIGNAL(toggled(bool)),this, SLOT(SetPlot()));
connect(radioDataGraph, SIGNAL(toggled(bool)),this, SLOT(SetPlot()));
// Scan box // Scan box
connect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox())); connect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox()));
// Snapshot box // Snapshot box
connect(btnClone, SIGNAL(clicked()),myPlot, SLOT(ClonePlot())); connect(btnClone, SIGNAL(clicked()),myPlot, SLOT(ClonePlot()));
connect(btnCloseClones, SIGNAL(clicked()),myPlot, SLOT(CloseClones())); connect(btnCloseClones, SIGNAL(clicked()),myPlot, SLOT(CloseClones()));
@ -350,6 +357,12 @@ void qTabPlot::Initialization(){
void qTabPlot::EnablePersistency(bool enable){ void qTabPlot::EnablePersistency(bool enable){
#ifdef VERBOSE
if(enable)
cout << "Enabling Persistency" << endl;
else
cout << "Disabling Persistency" << endl;
#endif
lblPersistency->setEnabled(enable); lblPersistency->setEnabled(enable);
spinPersistency->setEnabled(enable); spinPersistency->setEnabled(enable);
if(enable) myPlot->SetPersistency(spinPersistency->value()); if(enable) myPlot->SetPersistency(spinPersistency->value());
@ -362,6 +375,9 @@ void qTabPlot::EnablePersistency(bool enable){
void qTabPlot::SetTitles(){ void qTabPlot::SetTitles(){
#ifdef VERBOSE
cout << "Setting Plot Titles" << endl;
#endif
// Plot Title // Plot Title
if(dispTitle->isEnabled()) if(dispTitle->isEnabled())
myPlot->SetPlotTitlePrefix(dispTitle->text()); myPlot->SetPlotTitlePrefix(dispTitle->text());
@ -512,12 +528,8 @@ void qTabPlot::SetPlot(){
boxFrequency->setEnabled(false); boxFrequency->setEnabled(false);
boxPlotAxis->setEnabled(false); boxPlotAxis->setEnabled(false);
boxScan->setEnabled(false); boxScan->setEnabled(false);
}else { }else if(radioDataGraph->isChecked()){
if(radioDataGraph->isChecked()) cout << " - DataGraph" << endl;
cout << " - DataGraph" << endl;
else
cout << " - Histogram" << endl;
myPlot->EnablePlot(true); myPlot->EnablePlot(true);
Select1DPlot(isOriginallyOneD); Select1DPlot(isOriginallyOneD);
boxSnapshot->setEnabled(true); boxSnapshot->setEnabled(true);
@ -527,19 +539,40 @@ void qTabPlot::SetPlot(){
if(!myPlot->isRunning()) if(!myPlot->isRunning())
EnableScanBox(); EnableScanBox();
} }
else{
//histogram and 2d scans dont work
if(boxScan->isChecked()){
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);
return;
}
cout << " - Histogram" << endl;
myPlot->EnablePlot(true);
Select1DPlot(isOriginallyOneD);
boxSnapshot->setEnabled(true);
boxSave->setEnabled(true);
boxFrequency->setEnabled(true);
boxPlotAxis->setEnabled(true);
if(!myPlot->isRunning())
EnableScanBox(true);
qDefs::Message(qDefs::INFORMATION,"<nobr>Please check the <b>Plot Histogram Options</b> below "
"before <b>Starting Acquitision</b></nobr>","qTabPlot::SetPlot");
}
} }
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabPlot::SetFrequency(){ void qTabPlot::SetFrequency(){
#ifdef VERBOSE
cout << "Setting Plot Interval Frequency" << endl;
#endif
disconnect(comboTimeGapUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); disconnect(comboTimeGapUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency()));
disconnect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); disconnect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetFrequency()));
disconnect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); disconnect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency()));
disconnect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); disconnect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency()));
double timeMS,acqPeriodMS; double timeMS,acqPeriodMS;
double minPlotTimer = myPlot->GetMinimumPlotTimer(); double minPlotTimer = myPlot->GetMinimumPlotTimer();
char cMin[200]; char cMin[200];
@ -665,80 +698,89 @@ void qTabPlot::SetFrequency(){
connect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); connect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetFrequency()));
connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency()));
connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency()));
qDefs::checkErrorMessage(myDet,"qTabPlot::SetFrequency"); qDefs::checkErrorMessage(myDet,"qTabPlot::SetFrequency");
} }
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabPlot::EnableScanBox(){ void qTabPlot::EnableScanBox(bool Histo){
#ifdef VERBOSE #ifdef VERBOSE
cout << "Entering Enable Scan Box()" << endl; cout << "Entering Enable Scan Box, Histo:" << Histo << endl;
#endif #endif
disconnect(radioNoPlot, SIGNAL(toggled(bool)),this, SLOT(SetPlot())); disconnect(btnGroupPlotType,SIGNAL(buttonClicked(int)),this, SLOT(SetPlot()));
disconnect(radioHistogram, SIGNAL(toggled(bool)),this, SLOT(SetPlot())); disconnect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox()));
disconnect(radioDataGraph, SIGNAL(toggled(bool)),this, SLOT(SetPlot()));
disconnect(boxScan, SIGNAL(toggled(bool)),this, SLOT(EnableScanBox()));
int mode0 = myDet->getScanMode(0); int mode0 = myDet->getScanMode(0);
int mode1 = myDet->getScanMode(1); int mode1 = myDet->getScanMode(1);
int ang; int ang;
bool angConvert = myDet->getAngularConversion(ang); bool angConvert = myDet->getAngularConversion(ang);
//enabling it after it was plotted
radioDataGraph->setEnabled(true); radioDataGraph->setEnabled(true);
radioHistogram->setEnabled(true);
chkSuperimpose->setEnabled(true);
pageAccumulate->setEnabled(true);
pageAccumulate_2->setEnabled(true);
if((myDet->getDetectorsType() == slsDetectorDefs::GOTTHARD) || (myDet->getDetectorsType() == slsDetectorDefs::MOENCH)){
pagePedestal->setEnabled(true);
pagePedestal_2->setEnabled(true);
chkBinary->setEnabled(true);
chkBinary_2->setEnabled(true);
}
//if angle plot or originally 2d, uncheck and disable scanbox //if angle plot or originally 2d, uncheck and disable scanbox
if ((angConvert) || (!isOriginallyOneD)){ if ((angConvert) || (!isOriginallyOneD)){
boxScan->setChecked(false); boxScan->setChecked(false);
boxScan->setEnabled(false); boxScan->setEnabled(false);
//disable histogram
radioHistogram->setEnabled(false); //persistency, accumulate, pedestal, binary
if(radioHistogram->isChecked()) if(angConvert){
radioDataGraph->setChecked(true); if(chkSuperimpose->isChecked()) chkSuperimpose->setChecked(false);
//angle only if(chkPedestal->isChecked()) chkPedestal->setChecked(false);
if((angConvert)&&(chkSuperimpose->isChecked())) if(chkPedestal_2->isChecked()) chkPedestal_2->setChecked(false);
chkSuperimpose->setChecked(false); if(chkAccumulate->isChecked()) chkAccumulate->setChecked(false);
chkSuperimpose->setEnabled(!angConvert); if(chkAccumulate_2->isChecked())chkAccumulate_2->setChecked(false);
if(chkBinary->isChecked()) chkBinary->setChecked(false);
if(chkBinary_2->isChecked()) chkBinary_2->setChecked(false);
pagePedestal->setEnabled(false);
pagePedestal_2->setEnabled(false);
chkBinary->setEnabled(false);
chkBinary_2->setEnabled(false);
pageAccumulate->setEnabled(false);
pageAccumulate_2->setEnabled(false);
}
myPlot->EnableAnglePlot(angConvert); myPlot->EnableAnglePlot(angConvert);
if(angConvert) if(angConvert){
boxScan->setToolTip("<nobr>Only 1D Plots enabled for Angle Plots</nobr>"); boxScan->setToolTip("<nobr>Only 1D Plots enabled for Angle Plots</nobr>");
//disable histogram
if(radioHistogram->isChecked()){
radioDataGraph->setChecked(true);
radioHistogram->setEnabled(false);
}
}
} }
//originally1d && not angle plot //originally1d && not angle plot
else{ else{
boxScan->setToolTip(""); boxScan->setToolTip("");
boxScan->setEnabled(true); boxScan->setEnabled(true);
if(mode0 || mode1) /*if(mode0 || mode1)
boxScan->setChecked(true); boxScan->setChecked(true);*/
//still 1d
if(!boxScan->isChecked()){
radioHistogram->setEnabled(true);
/*if(radioHistogram->isChecked())
EnablingNthFrameFunction(false);//just this
else EnablingNthFrameFunction(true); */
}
//2d enabled with boxscan //2d enabled with boxscan
else{ if(boxScan->isChecked()){
//read every frame
disconnect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); disconnect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency()));
disconnect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); disconnect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency()));
comboFrequency->setCurrentIndex(1); comboFrequency->setCurrentIndex(1);
spinNthFrame->setValue(1); spinNthFrame->setValue(1);
SetFrequency(); SetFrequency();
connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency()));
connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency()));
//disable histogram for 2d
radioHistogram->setEnabled(false);
if(radioHistogram->isChecked())
radioDataGraph->setChecked(true);
/*//make sure nth frame frequency plot is disabled
EnablingNthFrameFunction(false);
*/
//enabling options //enabling options
radioFileIndex->setEnabled(mode0||mode1); radioFileIndex->setEnabled(mode0||mode1);
if(mode0 && mode1){ if(mode0 && mode1){
@ -751,119 +793,57 @@ void qTabPlot::EnableScanBox(){
//default is allframes if checked button is disabled //default is allframes if checked button is disabled
if(!btnGroupScan->checkedButton()->isEnabled()) if(!btnGroupScan->checkedButton()->isEnabled())
radioAllFrames->setChecked(true); radioAllFrames->setChecked(true);
connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency()));
connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency()));
} }
} }
connect(radioNoPlot, SIGNAL(toggled(bool)),this, SLOT(SetPlot()));
connect(radioHistogram, SIGNAL(toggled(bool)),this, SLOT(SetPlot()));
connect(radioDataGraph, SIGNAL(toggled(bool)),this, SLOT(SetPlot()));
connect(boxScan, SIGNAL(toggled(bool)),this, SLOT(EnableScanBox()));
/* //histogram
int mode0 = myDet->getScanMode(0); if(radioHistogram->isChecked()){
int mode1 = myDet->getScanMode(1); //switch back to datagraph
if(!Histo)
//if it was checked before or disabled before, it remembers to check it again
bool checkedBefore = boxScan->isChecked();//||(!boxScan->isEnabled()));
int ang;
//none of these scan plotting options make sense if positions exists
bool positionsExist = myDet->getAngularConversion(ang);//myDet->getPositions();
qDefs::checkErrorMessage(myDet,"qTabPlot::EnableScanBox");
//only now enable/disable
boxScan->setEnabled((mode0||mode1)&&(!positionsExist));
//after plotting, enable datagraph if it was disabled while plotting(refresh)
radioDataGraph->setEnabled(true);
//if there are scan
if(boxScan->isEnabled()){
//disable histogram
if(radioHistogram->isChecked())
radioDataGraph->setChecked(true); radioDataGraph->setChecked(true);
radioHistogram->setEnabled(false);
//make sure nth frame frequency plot is disabled pageHistogram->setEnabled(true);
EnablingNthFrameFunction(false); pageHistogram_2->setEnabled(true);
stackedWidget->setCurrentIndex(stackedWidget->count()-1);
stackedWidget_2->setCurrentIndex(stackedWidget_2->count()-1);
box1D->setTitle(QString("1D Plot Options %1 - Histogram").arg(stackedWidget->currentIndex()+1));
box2D->setTitle(QString("2D Plot Options %1 - Histogram").arg(stackedWidget_2->currentIndex()+1));
//if 2d is chosen or not for scan if(chkSuperimpose->isChecked()) chkSuperimpose->setChecked(false);
if(boxScan->isChecked()){ if(chkPedestal->isChecked()) chkPedestal->setChecked(false);
if(chkPedestal_2->isChecked()) chkPedestal_2->setChecked(false);
if(chkAccumulate->isChecked()) chkAccumulate->setChecked(false);
if(chkAccumulate_2->isChecked())chkAccumulate_2->setChecked(false);
if(chkBinary->isChecked()) chkBinary->setChecked(false);
if(chkBinary_2->isChecked()) chkBinary_2->setChecked(false);
pagePedestal->setEnabled(false);
pagePedestal_2->setEnabled(false);
chkBinary->setEnabled(false);
chkBinary_2->setEnabled(false);
pageAccumulate->setEnabled(false);
pageAccumulate_2->setEnabled(false);
boxScan->setChecked(checkedBefore); //read every frame
//make sure nth frame frequency plot is disabled disconnect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency()));
EnablingNthFrameFunction(false); disconnect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency()));
comboFrequency->setCurrentIndex(1);
spinNthFrame->setValue(1);
SetFrequency();
connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency()));
connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency()));
//
if(mode0 && mode1){
if(!radioFileIndex->isChecked()) radioAllFrames->setChecked(true);
radioLevel0->setEnabled(false);
radioLevel1->setEnabled(false);
}else{
radioLevel0->setEnabled(mode0);
radioLevel1->setEnabled(mode1);
}
//only if level0 or level1 is checked }else{
if((radioLevel0->isChecked())||(radioLevel1->isChecked())){ pageHistogram->setEnabled(false);
if(mode0) radioLevel0->setChecked(true); pageHistogram_2->setEnabled(false);
if(mode1) radioLevel1->setChecked(true);
}
}
}
else{
//histogram for 1d
if(isOriginallyOneD){
radioHistogram->setEnabled(true);
if(radioHistogram->isChecked())
EnablingNthFrameFunction(false);
else
EnablingNthFrameFunction(true);
}
} }
connect(btnGroupPlotType,SIGNAL(buttonClicked(int)),this, SLOT(SetPlot()));
//positions connect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox()));
if((positionsExist)&&(chkSuperimpose->isChecked())) chkSuperimpose->setChecked(false);
chkSuperimpose->setEnabled(!positionsExist);
//box frequency should be enabled cuz its a normal 1d plot
//boxFrequency->setEnabled(positionsExist);
myPlot->EnableAnglePlot(positionsExist);
*/
} }
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabPlot::EnablingNthFrameFunction(bool enable){
#ifdef VERYVERBOSE
cout << "Enabling Nth Frame : " << enable << endl;
#endif
QStandardItemModel* model = qobject_cast<QStandardItemModel*>(comboFrequency->model());
QStandardItem* item = model->itemFromIndex(model->index(1, comboFrequency->modelColumn(), comboFrequency->rootModelIndex()));
//enabling/disabling is easy if it wasnt selected anyway
if(comboFrequency->currentIndex()!=1)
item->setEnabled(enable);
else{
//only when it was enabled before and now to disable is a problem
if(!enable){
spinTimeGap->setValue(myPlot->GetMinimumPlotTimer());
comboFrequency->setCurrentIndex(0);
item->setEnabled(false);
}
}
}
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabPlot::SetScanArgument(){ void qTabPlot::SetScanArgument(){
@ -891,6 +871,15 @@ void qTabPlot::SetScanArgument(){
} }
//histogram default - set before setscanargument
myPlot->SetHistogram(radioHistogram->isChecked(),spinHistFrom->value(),spinHistTo->value(),spinHistSize->value());
if(radioHistogram->isChecked()){
dispXAxis->setText("Intensity");
dispYAxis->setText("Frequency");
myPlot->SetHistXAxisTitle("Intensity");
myPlot->SetHistYAxisTitle("Frequency");
Select1DPlot(true);
}
//angles (1D) //angles (1D)
int ang; int ang;
@ -900,12 +889,9 @@ void qTabPlot::SetScanArgument(){
Select1DPlot(true); Select1DPlot(true);
} }
/* bool histogram = radioHistogram->isChecked();
* else if(histogram)*/
//1d with scan //1d with scan
if(boxScan->isChecked()){ if(boxScan->isChecked()){
myPlot->SetScanArgument(btnGroupScan->checkedId()+1); myPlot->SetScanArgument(btnGroupScan->checkedId()+1);
switch(btnGroupScan->checkedId()){ switch(btnGroupScan->checkedId()){
@ -931,79 +917,6 @@ void qTabPlot::SetScanArgument(){
}else }else
myPlot->SetScanArgument(qDefs::None); myPlot->SetScanArgument(qDefs::None);
/*
Select1DPlot(isOriginallyOneD);
int ang;
//if scans(1D or 2D)
if((boxScan->isEnabled())||(histogram)){
//setting the title according to the scans
Select1DPlot(isOriginallyOneD);
}//angles (1D)
else if(myDet->getAngularConversion(ang)){
dispXAxis->setText("Angles");
myPlot->SetHistXAxisTitle("Angles");
Select1DPlot(true);
}
//histogram
if(histogram){
//allFrames
myPlot->SetScanArgument(qDefs::AllFrames);
//default titles for 2d scan
dispXAxis->setText("Channel Number");
myPlot->SetImageXAxisTitle("Channel Number");
dispZAxis->setText("Counts");
myPlot->SetImageZAxisTitle("Counts");
dispYAxis->setText("All Frames");
myPlot->SetImageYAxisTitle("All Frames");
//set plot to 2d
Select1DPlot(false);
}
//2d
else if((boxScan->isEnabled())&&(boxScan->isChecked())){
//let qdrawplot know which scan argument
myPlot->SetScanArgument(btnGroupScan->checkedId()+1);
//default titles for 2d scan
dispXAxis->setText("Channel Number");
myPlot->SetImageXAxisTitle("Channel Number");
dispZAxis->setText("Counts");
myPlot->SetImageZAxisTitle("Counts");
//titles for y of 2d scan
switch(btnGroupScan->checkedId()){
case 0://level0
dispYAxis->setText("Scan Level 0");
myPlot->SetImageYAxisTitle("Scan Level 0");
break;
case 1://level1
dispYAxis->setText("Scan Level 1");
myPlot->SetImageYAxisTitle("Scan Level 1");
break;
break;
case 2://file index
dispYAxis->setText("Frame Index");
myPlot->SetImageYAxisTitle("Frame Index");
break;
case 3://all frames
dispYAxis->setText("All Frames");
myPlot->SetImageYAxisTitle("All Frames");
break;
}
//set plot to 2d
Select1DPlot(false);
}else //done here so that it isnt set by default each time
myPlot->SetScanArgument(qDefs::None);
*/
qDefs::checkErrorMessage(myDet,"qTabPlot::SetScanArgument"); qDefs::checkErrorMessage(myDet,"qTabPlot::SetScanArgument");
} }
@ -1019,18 +932,19 @@ void qTabPlot::Refresh(){
if (!radioNoPlot->isChecked()) if (!radioNoPlot->isChecked())
boxFrequency->setEnabled(true); boxFrequency->setEnabled(true);
connect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox())); connect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox()));
EnableScanBox(); EnableScanBox(true);
SetFrequency(); SetFrequency();
}else{ }else{
boxFrequency->setEnabled(false); boxFrequency->setEnabled(false);
disconnect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox())); disconnect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox()));
boxScan->setEnabled(false); boxScan->setEnabled(false);
//to toggle between no plot and the plot mode chosen while pltting pageHistogram->setEnabled(false);
pageHistogram_2->setEnabled(false);
if(radioHistogram->isChecked()) if(radioHistogram->isChecked())
radioDataGraph->setEnabled(false); radioDataGraph->setEnabled(false);
radioHistogram->setEnabled(false); else
radioHistogram->setEnabled(false);
} }
#ifdef VERBOSE #ifdef VERBOSE
cout << "**Updated Plot Tab" << endl << endl; cout << "**Updated Plot Tab" << endl << endl;