2d pedestal implemented

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@192 af1100a4-978c-4157-bff7-07162d2ba061
This commit is contained in:
l_maliakal_d
2013-05-28 06:45:56 +00:00
parent 1129702738
commit 4f1dfe8b87
4 changed files with 400 additions and 87 deletions

View File

@ -81,7 +81,7 @@
</rect>
</property>
<property name="title">
<string>2D Plot Options</string>
<string>2D Plot Options 1</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
@ -89,88 +89,325 @@
<property name="flat">
<bool>false</bool>
</property>
<widget class="QWidget" name="gridLayoutWidget_5">
<widget class="QStackedWidget" name="stackedWidget_2">
<property name="geometry">
<rect>
<x>8</x>
<y>20</y>
<width>358</width>
<height>26</height>
<x>5</x>
<y>15</y>
<width>361</width>
<height>31</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QCheckBox" name="chkInterpolate">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Interpolate</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QCheckBox" name="chkContour">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Contour</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QCheckBox" name="chkLogz">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Log Scale (Z)</string>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_15">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>33</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="3">
<spacer name="horizontalSpacer_16">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>33</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="page_6">
<widget class="QPushButton" name="btn2DRight">
<property name="geometry">
<rect>
<x>345</x>
<y>0</y>
<width>16</width>
<height>16</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../include/icons.qrc">
<normaloff>:/icons/images/rightArrow.png</normaloff>:/icons/images/rightArrow.png</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
<widget class="QWidget" name="gridLayoutWidget_5">
<property name="geometry">
<rect>
<x>5</x>
<y>5</y>
<width>341</width>
<height>26</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QCheckBox" name="chkInterpolate">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Interpolate</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QCheckBox" name="chkContour">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Contour</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QCheckBox" name="chkLogz">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Log Scale (Z)</string>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_15">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>29</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="3">
<spacer name="horizontalSpacer_16">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>29</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
<widget class="QWidget" name="page_7">
<widget class="QPushButton" name="btn2DRight2">
<property name="geometry">
<rect>
<x>345</x>
<y>0</y>
<width>16</width>
<height>16</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../include/icons.qrc">
<normaloff>:/icons/images/rightArrow.png</normaloff>:/icons/images/rightArrow.png</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton" name="btnResetPedestal_2">
<property name="geometry">
<rect>
<x>5</x>
<y>4</y>
<width>141</width>
<height>25</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="Shadow">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>20</red>
<green>20</green>
<blue>20</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="Shadow">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>20</red>
<green>20</green>
<blue>20</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="Shadow">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>20</red>
<green>20</green>
<blue>20</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>Reset Pedestal</string>
</property>
<property name="icon">
<iconset resource="../include/icons.qrc">
<normaloff>:/icons/images/erase.png</normaloff>:/icons/images/erase.png</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
</widget>
<widget class="QPushButton" name="btnCalPedestal_2">
<property name="geometry">
<rect>
<x>200</x>
<y>4</y>
<width>141</width>
<height>25</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="Shadow">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>20</red>
<green>20</green>
<blue>20</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="Shadow">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>20</red>
<green>20</green>
<blue>20</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="Shadow">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>20</red>
<green>20</green>
<blue>20</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>Calculate Pedestal</string>
</property>
<property name="icon">
<iconset resource="../include/icons.qrc">
<normaloff>:/icons/images/calculate.png</normaloff>:/icons/images/calculate.png</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
</widget>
</widget>
</widget>
</widget>
<widget class="QGroupBox" name="box1D">
@ -201,7 +438,7 @@
</rect>
</property>
<property name="currentIndex">
<number>2</number>
<number>0</number>
</property>
<widget class="QWidget" name="page">
<widget class="QWidget" name="gridLayoutWidget_2">
@ -756,6 +993,9 @@
</size>
</property>
</widget>
<zorder>horizontalLayoutWidget</zorder>
<zorder>btnSave</zorder>
<zorder>gridLayoutWidget_5</zorder>
</widget>
<widget class="QGroupBox" name="boxScan">
<property name="geometry">
@ -1386,7 +1626,7 @@
<property name="geometry">
<rect>
<x>15</x>
<y>137</y>
<y>135</y>
<width>371</width>
<height>49</height>
</rect>
@ -1804,6 +2044,8 @@ Interval between plots has 2 modes. A condition to be satisfied, in order to avo
</item>
</layout>
</widget>
<zorder>gridLayoutWidget_4</zorder>
<zorder>gridLayoutWidget_5</zorder>
</widget>
</widget>
<tabstops>

View File

@ -147,6 +147,9 @@ private slots:
/** Change pages in 1D box*/
void Set1DPage();
/** Change pages in 2D box*/
void Set2DPage();
signals:
void DisableZoomSignal(bool);

View File

@ -892,7 +892,51 @@ int qDrawPlot::GetData(detectorData *data,int fIndex){
lastImageArray[py*nPixelsX+px] = sqrt(pow(currentFrame+1,2)*pow(double(px)-nPixelsX/2,2)/pow(nPixelsX/2,2)/pow(number_of_exposures+1,2) + pow(double(py)-nPixelsY/2,2)/pow(nPixelsY/2,2))/sqrt(2);
*/
// copy data
memcpy(lastImageArray,data->values,nPixelsX*nPixelsY*sizeof(double));
/*memcpy(lastImageArray,data->values,nPixelsX*nPixelsY*sizeof(double));*/
//normal data
if(resetPedestal){
memcpy(lastImageArray,data->values,nPixelsX*nPixelsY*sizeof(double));
}else{
//start adding frames to get to the pedestal value
if(pedestalCount<NUM_PEDESTAL_FRAMES){
for(unsigned int px=0;px<(nPixelsX*nPixelsY);px++)
pedestalVals[px] += data->values[px];
memcpy(lastImageArray,data->values,nPixelsX*nPixelsY*sizeof(double));
}
//calculate the pedestal value
else if(pedestalCount==NUM_PEDESTAL_FRAMES){
cout << "Pedestal Calculated" << endl;
for(unsigned int px=0;px<(nPixelsX*nPixelsY);px++)
pedestalVals[px] = pedestalVals[px]/(double)NUM_PEDESTAL_FRAMES;
memcpy(lastImageArray,data->values,nPixelsX*nPixelsY*sizeof(double));
}
//use this pedestal value henceforth
else{
for(unsigned int px=0;px<(nPixelsX*nPixelsY);px++)
lastImageArray[px] = data->values[px] - (pedestalVals[px]);
}
pedestalCount++;
}
}
pthread_mutex_unlock(&(last_image_complete_mutex));
}
@ -1578,9 +1622,9 @@ void qDrawPlot::CalculatePedestal(){
while(1){
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
//create array
if(pedestalVals) delete [] pedestalVals; pedestalVals = new double[nPixelsX];
if(pedestalVals) delete [] pedestalVals; pedestalVals = new double[nPixelsX*nPixelsY];
//reset all values
for(unsigned int px=0;px<nPixelsX;px++)
for(unsigned int px=0;px<(nPixelsX*nPixelsY);px++)
pedestalVals[px] = 0;
pedestalCount = 0;

View File

@ -159,11 +159,15 @@ void qTabPlot::SetupWidgetWindow(){
EnableScanBox();
stackedWidget->setCurrentIndex(0);
stackedWidget_2->setCurrentIndex(0);
if(myDet->getDetectorsType()!=slsDetectorDefs::GOTTHARD){
btnCalPedestal->setEnabled(false);
btnResetPedestal->setEnabled(false);
}
if(myDet->getDetectorsType()!=slsDetectorDefs::MOENCH){
btnCalPedestal_2->setEnabled(false);
btnResetPedestal_2->setEnabled(false);
}
qDefs::checkErrorMessage(myDet);
}
@ -172,8 +176,24 @@ void qTabPlot::SetupWidgetWindow(){
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabPlot::Set2DPage(){
//QPushButton *clickedButton = qobject_cast<QPushButton *>(sender());
if(stackedWidget_2->currentIndex()==0){
stackedWidget_2->setCurrentIndex(1);
box2D->setTitle("2D Plot Options 2");
}
else{
stackedWidget_2->setCurrentIndex(0);
box2D->setTitle("2D Plot Options 1");
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabPlot::Set1DPage(){
QPushButton *clickedButton = qobject_cast<QPushButton *>(sender());
//QPushButton *clickedButton = qobject_cast<QPushButton *>(sender());
if(stackedWidget->currentIndex()==0){
//if(clickedButton->icon().pixmap(QSize(16,16)).toImage()==btnLeft->icon().pixmap(QSize(16,16)).toImage())
stackedWidget->setCurrentIndex(1);
@ -240,6 +260,9 @@ void qTabPlot::Initialization(){
connect(chkInterpolate, SIGNAL(toggled(bool)),myPlot, SIGNAL(InterpolateSignal(bool)));
connect(chkContour, SIGNAL(toggled(bool)),myPlot, SIGNAL(ContourSignal(bool)));
connect(chkLogz, SIGNAL(toggled(bool)),myPlot, SIGNAL(LogzSignal(bool)));
//to change pages
connect(btn2DRight, SIGNAL(clicked()), this, SLOT(Set2DPage()));
connect(btn2DRight2, SIGNAL(clicked()), this, SLOT(Set2DPage()));
// Plotting frequency box
connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency()));
connect(comboTimeGapUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency()));
@ -278,7 +301,8 @@ void qTabPlot::Initialization(){
//pedstal
connect(btnResetPedestal, SIGNAL(clicked()),myPlot, SLOT(ResetPedestal()));
connect(btnCalPedestal, SIGNAL(clicked()),myPlot, SLOT(CalculatePedestal()));
connect(btnResetPedestal_2, SIGNAL(clicked()),myPlot, SLOT(ResetPedestal()));
connect(btnCalPedestal_2, SIGNAL(clicked()),myPlot, SLOT(CalculatePedestal()));
}