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

View File

@ -147,6 +147,9 @@ private slots:
/** Change pages in 1D box*/ /** Change pages in 1D box*/
void Set1DPage(); void Set1DPage();
/** Change pages in 2D box*/
void Set2DPage();
signals: signals:
void DisableZoomSignal(bool); 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); 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 // 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)); pthread_mutex_unlock(&(last_image_complete_mutex));
} }
@ -1578,9 +1622,9 @@ void qDrawPlot::CalculatePedestal(){
while(1){ while(1){
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){ if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
//create array //create array
if(pedestalVals) delete [] pedestalVals; pedestalVals = new double[nPixelsX]; if(pedestalVals) delete [] pedestalVals; pedestalVals = new double[nPixelsX*nPixelsY];
//reset all values //reset all values
for(unsigned int px=0;px<nPixelsX;px++) for(unsigned int px=0;px<(nPixelsX*nPixelsY);px++)
pedestalVals[px] = 0; pedestalVals[px] = 0;
pedestalCount = 0; pedestalCount = 0;

View File

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