included pedestal and also moved the frame index out of graph so it doesnt keep moving

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@119 af1100a4-978c-4157-bff7-07162d2ba061
This commit is contained in:
l_maliakal_d 2012-11-30 17:05:06 +00:00
parent 382554afe9
commit bbb6e21607
12 changed files with 350 additions and 28 deletions

View File

@ -162,7 +162,7 @@
<normaloff>:/icons/images/start.png</normaloff>:/icons/images/start.png</iconset>
</property>
<property name="shortcut">
<string>Space</string>
<string>Shift+Space</string>
</property>
<property name="checkable">
<bool>true</bool>

View File

@ -183,7 +183,7 @@
</rect>
</property>
<property name="title">
<string>1D Plot Options</string>
<string>1D Plot Options 1</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
@ -201,7 +201,7 @@
</rect>
</property>
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="page">
<widget class="QWidget" name="gridLayoutWidget_2">
@ -407,7 +407,7 @@
</item>
</layout>
</widget>
<widget class="QPushButton" name="btnLeft">
<widget class="QPushButton" name="btnRight2">
<property name="geometry">
<rect>
<x>345</x>
@ -430,7 +430,194 @@
</property>
<property name="icon">
<iconset resource="../include/icons.qrc">
<normaloff>:/icons/images/leftArrow.png</normaloff>:/icons/images/leftArrow.png</iconset>
<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>
<widget class="QWidget" name="page_3">
<widget class="QPushButton" name="btnResetPedestal">
<property name="geometry">
<rect>
<x>5</x>
<y>5</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/remove.png</normaloff>:/icons/images/remove.png</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
</widget>
<widget class="QPushButton" name="btnCalPedestal">
<property name="geometry">
<rect>
<x>200</x>
<y>5</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/add.png</normaloff>:/icons/images/add.png</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
</widget>
<widget class="QPushButton" name="btnRight3">
<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>
@ -593,7 +780,7 @@
<rect>
<x>10</x>
<y>20</y>
<width>341</width>
<width>348</width>
<height>26</height>
</rect>
</property>

View File

@ -126,6 +126,8 @@ private:
QCheckBox *chkAutoFName;
QCheckBox *chkSaveAll;
QLabel *lblHistTitle;
/** Gets the current time stamp for the window title*/
char* GetCurrentTimeStamp();

View File

@ -149,8 +149,11 @@ void SetScanArgument(int scanArg);
/** sets stop_signal to true */
void StopAcquisition(){ stop_signal = true; };
//pedestal
/** reset pedestal */
void ResetPedestal();
/** Calculate Pedestal */
void CalculatePedestal();
@ -304,6 +307,10 @@ SlsQt2DPlotLayout* plot2D;
QVector<SlsQtH1D*> plot1D_hists;
/**label with frame index for those with many frames per file*/
QLabel *histFrameIndexTitle;
/** Current Measurement */
int currentMeasurement;
/** currentFrame */
@ -464,6 +471,17 @@ bool backwardScanPlot;
bool fileSaveEnable;
//pedstal
/** Number of pedestal frames*/
static const int NUM_PEDESTAL_FRAMES = 20;
/**reset pedestal*/
bool resetPedestal;
/** pedestal values */
double* pedestalVals;
/** count for 20 frames to calculate the pedestal */
int pedestalCount;
signals:
void UpdatingPlotFinished();
void InterpolateSignal(bool);

View File

@ -13,10 +13,11 @@
/** Project Class Headers */
class multiSlsDetector;
class slsDetector;
#include "sls_detector_defs.h"
/** Qt Include Headers */
#include <QTreeWidget>
/** C++ Include Headers */
#include "sls_detector_defs.h"
/**
*@short sets up the Debugging parameters

View File

@ -12,6 +12,7 @@
#include "ui_form_tab_plot.h"
/** Project Class Headers */
class multiSlsDetector;
#include "sls_detector_defs.h"
/** Qt Project Class Headers */
class qDrawPlot;
/** Qt Include Headers */
@ -54,6 +55,7 @@ private:
/** The Plot widget */
qDrawPlot *myPlot;
/** 1d/2d plot */
bool isOneD;
bool isOriginallyOneD;

View File

@ -276,7 +276,7 @@ SlsQt1DPlot::SlsQt1DPlot(QWidget *parent):QwtPlot(parent){
SetupZoom();
// Assign a title
insertLegend(new QwtLegend(), QwtPlot::RightLegend);
insertLegend(new QwtLegend(), QwtPlot::RightLegend);
axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating);
axisScaleEngine(QwtPlot::xBottom)->setAttribute(QwtScaleEngine::Floating);

View File

@ -71,6 +71,8 @@ void qCloneWidget::SetupWidgetWindow(QString title,int numDim,SlsQt1DPlot*& plot
gridClone->addWidget(cloneplot1D,0,0);
cloneBox->setFlat(false);
cloneBox->setContentsMargins(0,30,0,0);
lblHistTitle = new QLabel("");
mainLayout->addWidget(lblHistTitle,0,0);
}else{
cloneplot2D = plot2D;
@ -128,7 +130,8 @@ void qCloneWidget::SetCloneHists(int nHists,int histNBins,double* histXAxis,doub
#endif
}
//set title and attach plot
k->setTitle(histTitle[hist_num].c_str());
lblHistTitle->setText(QString(histTitle[0].c_str()));
//k->setTitle(histTitle[hist_num].c_str());
k->Attach(cloneplot1D);
}
//cloneplot1D->UnZoom();
@ -171,7 +174,8 @@ void qCloneWidget::SetCloneHists(int nHists,int histNBins,double* histXAxis,doub
#endif
}
//set title and attach plot
k->setTitle(histTitle[hist_num].c_str());
lblHistTitle->setText(QString(histTitle[0].c_str()));
//k->setTitle(histTitle[hist_num].c_str());
k->Attach(cloneplot1D);
}
//cloneplot1D->UnZoom();

View File

@ -258,7 +258,7 @@ void qDetectorMain::Initialization(){
connect(tab_plot, SIGNAL(DisableZoomSignal(bool)), this,SLOT(SetZoomToolTip(bool)));
// Actions tab (only for scan)
connect(tab_actions, SIGNAL(EnableScanBox()), tab_plot,SLOT(EnableScanBox()));
//settings to advanced tab(int=id is always 0 to only refresh)
//settings to advanced tab(int is always 0 to only refresh)
connect(tab_settings, SIGNAL(UpdateTrimbitSignal(int)), tab_advanced,SLOT(UpdateTrimbitPlot(int)));
// Plotting
// When the acquisition is finished, must update the meas tab

View File

@ -123,10 +123,14 @@ void qDrawPlot::SetupWidgetWindow(){
setFont(QFont("Sans Serif",9));
layout = new QGridLayout;
this->setLayout(layout);
histFrameIndexTitle= histFrameIndexTitle = new QLabel("");
boxPlot = new QGroupBox("");
layout->addWidget(boxPlot,1,1);
boxPlot->setAlignment(Qt::AlignHCenter);
boxPlot->setFont(QFont("Sans Serif",11,QFont::Normal));
plot_update_timer = new QTimer(this);
connect(plot_update_timer, SIGNAL(timeout()), this, SLOT(UpdatePlot()));
data_pause_timer = new QTimer(this);
@ -190,6 +194,14 @@ void qDrawPlot::SetupWidgetWindow(){
fileSaveEnable= myDet->enableWriteToFile();
//pedestal
resetPedestal = true;
pedestalVals = 0;
pedestalCount = -1;
if(myDet->getDetectorsType()==slsDetectorDefs::GOTTHARD)
pedestalCount = 0;
// Setting the callback function to get data from detector class
myDet->registerDataCallback(&(GetDataCallBack),this);
@ -555,8 +567,8 @@ int qDrawPlot::GetData(detectorData *data,int fIndex){
currentFrameIndex=fIndex;
sprintf(temp_title,"#%d",fIndex);
}else{
if(fileSaveEnable) strcpy(temp_title,"");
else sprintf(temp_title,"#%d",currentFrame);
if(fileSaveEnable) strcpy(temp_title,"#%d");
else sprintf(temp_title,"",currentFrame);
}
@ -748,10 +760,37 @@ int qDrawPlot::GetData(detectorData *data,int fIndex){
else currentPersistency=persistency;
nHists = currentPersistency+1;
histNBins = nPixelsX;
// copy data
for(int i=currentPersistency;i>0;i--)
memcpy(histYAxis[i],histYAxis[i-1],nPixelsX*sizeof(double));
memcpy(histYAxis[0],data->values,nPixelsX*sizeof(double));
//normal data
if(resetPedestal)
memcpy(histYAxis[0],data->values,nPixelsX*sizeof(double));
else{
//start adding frames to get to the pedestal value
if(pedestalCount<NUM_PEDESTAL_FRAMES){
for(unsigned int px=0;px<nPixelsX;px++)
pedestalVals[px] += data->values[px];
memcpy(histYAxis[0],data->values,nPixelsX*sizeof(double));
}
//calculate the pedestal value
else if(pedestalCount==NUM_PEDESTAL_FRAMES){
cout << "Pedestal Calculated" << endl;
for(unsigned int px=0;px<nPixelsX;px++)
pedestalVals[px] = pedestalVals[px]/(double)NUM_PEDESTAL_FRAMES;
memcpy(histYAxis[0],data->values,nPixelsX*sizeof(double));
}
//use this pedestal value henceforth
else{
for(unsigned int px=0;px<nPixelsX;px++)
histYAxis[0][px] = data->values[px] - (pedestalVals[px]);
}
pedestalCount++;
}
}
//2d
else{cout<<endl<<"****************************IN HERE-2D*******************************************"<<endl<<endl;
@ -887,6 +926,7 @@ void qDrawPlot::SelectPlot(int i){ //1 for 1D otherwise 2D
plot2D->hide();
boxPlot->setFlat(false);
plot_in_scope=1;
layout->addWidget(histFrameIndexTitle,0,0);
}else{
plot2D->SetXTitle(imageXAxisTitle);
plot2D->SetYTitle(imageYAxisTitle);
@ -895,6 +935,9 @@ void qDrawPlot::SelectPlot(int i){ //1 for 1D otherwise 2D
plot2D->show();
boxPlot->setFlat(true);
plot_in_scope=2;
histFrameIndexTitle->setText("");
layout->removeWidget(histFrameIndexTitle);
}
}
@ -936,9 +979,9 @@ void qDrawPlot::UpdatePlot(){
SlsQtH1D* h;
if(hist_num+1>plot1D_hists.size()){
if(anglePlot)
plot1D_hists.append(h=new SlsQtH1D("1d plot",histNBins,histXAngleAxis,histYAngleAxis));
plot1D_hists.append(h=new SlsQtH1D("",histNBins,histXAngleAxis,histYAngleAxis));
else
plot1D_hists.append(h=new SlsQtH1D("1d plot",histNBins,histXAxis,GetHistYAxis(hist_num)));
plot1D_hists.append(h=new SlsQtH1D("",histNBins,histXAxis,GetHistYAxis(hist_num)));
h->SetLineColor(hist_num+1);
}else{
h=plot1D_hists.at(hist_num);
@ -948,7 +991,8 @@ void qDrawPlot::UpdatePlot(){
h->SetData(histNBins,histXAxis,GetHistYAxis(hist_num));
}
SetStyle(h);
h->setTitle(GetHistTitle(hist_num));
histFrameIndexTitle->setText(GetHistTitle(0));
//h->setTitle(GetHistTitle(hist_num));
h->Attach(plot1D);
}
// update range if required
@ -1318,7 +1362,7 @@ int qDrawPlot::UpdateTrimbitPlot(bool fromDetector,bool Histogram){
plot1D->SetYTitle("Trimbits");
//set plot parameters
SlsQtH1D* h;
plot1D_hists.append(h=new SlsQtH1D("1d plot",nPixelsX,histXAxis,histYAxis[0]));
plot1D_hists.append(h=new SlsQtH1D("",nPixelsX,histXAxis,histYAxis[0]));
h->SetLineColor(1);
h->setTitle(GetHistTitle(0));
//attach plot
@ -1347,7 +1391,7 @@ int qDrawPlot::UpdateTrimbitPlot(bool fromDetector,bool Histogram){
plot1D->SetYTitle("Frequency");
//set plot parameters
SlsQtH1D* h;
plot1D_hists.append(h=new SlsQtH1D("1d plot",nPixelsX,histXAxis,histYAxis[0]));
plot1D_hists.append(h=new SlsQtH1D("",nPixelsX,histXAxis,histYAxis[0]));
h->SetLineColor(1);
h->setTitle(GetHistTitle(0));
//attach plot
@ -1398,4 +1442,47 @@ int qDrawPlot::UpdateTrimbitPlot(bool fromDetector,bool Histogram){
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qDrawPlot::ResetPedestal(){
#ifdef VERBOSE
cout << "Resetting Pedestal" << endl;
#endif
while(1){
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
pedestalVals = 0;
pedestalCount = 0;
resetPedestal = true;
pthread_mutex_unlock(&(last_image_complete_mutex));
break;
}
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qDrawPlot::CalculatePedestal(){
#ifdef VERBOSE
cout << "Calculating Pedestal" << endl;
#endif
while(1){
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
//create array
if(pedestalVals) delete [] pedestalVals; pedestalVals = new double[nPixelsX];
//reset all values
for(unsigned int px=0;px<nPixelsX;px++)
pedestalVals[px] = 0;
pedestalCount = 0;
resetPedestal = false;
pthread_mutex_unlock(&(last_image_complete_mutex));
break;
}
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -261,7 +261,7 @@ void qTabMeasurement::Enable(bool enable){
frameNotTimeResolved->setEnabled(enable);
//Enable this always
if(!enable) btnStartStop->setEnabled(true);
btnStartStop->setShortcut(QApplication::translate("TabMeasurementObject", "Space", 0, QApplication::UnicodeUTF8));
btnStartStop->setShortcut(QApplication::translate("TabMeasurementObject", "Shift+Space", 0, QApplication::UnicodeUTF8));
}

View File

@ -60,7 +60,6 @@ void qTabPlot::SetupWidgetWindow(){
intervalTip = boxFrequency->toolTip();
//scan arguments
btnGroupScan = new QButtonGroup(this);
btnGroupScan->addButton(radioLevel0,0);
@ -148,6 +147,13 @@ void qTabPlot::SetupWidgetWindow(){
//to check if this should be enabled
EnableScanBox();
stackedWidget->setCurrentIndex(0);
if(myDet->getDetectorsType()!=slsDetectorDefs::GOTTHARD){
btnCalPedestal->setEnabled(false);
btnResetPedestal->setEnabled(false);
}
}
@ -156,10 +162,19 @@ void qTabPlot::SetupWidgetWindow(){
void qTabPlot::Set1DPage(){
QPushButton *clickedButton = qobject_cast<QPushButton *>(sender());
if(clickedButton->icon().pixmap(QSize(16,16)).toImage()==btnLeft->icon().pixmap(QSize(16,16)).toImage())
stackedWidget->setCurrentIndex(0);
else
if(stackedWidget->currentIndex()==0){
//if(clickedButton->icon().pixmap(QSize(16,16)).toImage()==btnLeft->icon().pixmap(QSize(16,16)).toImage())
stackedWidget->setCurrentIndex(1);
box1D->setTitle("1D Plot Options 2");
}
else if(stackedWidget->currentIndex()==1){
stackedWidget->setCurrentIndex(2);
box1D->setTitle("1D Plot Options 3");
}
else{
stackedWidget->setCurrentIndex(0);
box1D->setTitle("1D Plot Options 1");
}
}
@ -206,8 +221,9 @@ void qTabPlot::Initialization(){
connect(chkLines, SIGNAL(toggled(bool)), myPlot, SLOT(SetLines(bool)));
connect(chk1DLog, SIGNAL(toggled(bool)), myPlot, SIGNAL(LogySignal(bool)));
//to change pages
connect(btnLeft, SIGNAL(clicked()), this, SLOT(Set1DPage()));
connect(btnRight, SIGNAL(clicked()), this, SLOT(Set1DPage()));
connect(btnRight2, SIGNAL(clicked()), this, SLOT(Set1DPage()));
connect(btnRight3, SIGNAL(clicked()), this, SLOT(Set1DPage()));
// 2D Plot box
connect(chkInterpolate, SIGNAL(toggled(bool)),myPlot, SIGNAL(InterpolateSignal(bool)));
connect(chkContour, SIGNAL(toggled(bool)),myPlot, SIGNAL(ContourSignal(bool)));
@ -247,6 +263,9 @@ void qTabPlot::Initialization(){
connect(this,SIGNAL(SetZRangeSignal(double,double)),myPlot, SIGNAL(SetZRangeSignal(double,double)));
//pedstal
connect(btnResetPedestal, SIGNAL(clicked()),myPlot, SLOT(ResetPedestal()));
connect(btnCalPedestal, SIGNAL(clicked()),myPlot, SLOT(CalculatePedestal()));
}
@ -796,6 +815,7 @@ void qTabPlot::Refresh(){
connect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox()));
EnableScanBox();
SetFrequency();
}else{
disconnect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox()));
boxScan->setEnabled(false);
@ -803,6 +823,7 @@ void qTabPlot::Refresh(){
if(radioHistogram->isChecked())
radioDataGraph->setEnabled(false);
radioHistogram->setEnabled(false);
}
#ifdef VERBOSE
cout << "**Updated Plot Tab" << endl << endl;