the scans work

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@38 af1100a4-978c-4157-bff7-07162d2ba061
This commit is contained in:
l_maliakal_d
2012-08-27 14:11:58 +00:00
parent 73152572a5
commit ee3a54601c
18 changed files with 852 additions and 319 deletions

View File

@ -66,7 +66,7 @@ void qCloneWidget::SetupWidgetWindow(QString title,int numDim,SlsQt1DPlot*& plot
cloneBox->setContentsMargins(0,0,0,0);
cloneBox->setTitle(title);
cloneBox->setAlignment(Qt::AlignHCenter);
cloneBox->setFont(QFont("Sans Serif",11,QFont::Bold));
cloneBox->setFont(QFont("Sans Serif",11,QFont::Normal));
/** According to dimensions, create appropriate 1D or 2Dplot */
if(numDim==1){
cloneplot1D = plot1D;
@ -82,49 +82,6 @@ void qCloneWidget::SetupWidgetWindow(QString title,int numDim,SlsQt1DPlot*& plot
cloneBox->setContentsMargins(0,5,0,0);
}
/** Save group box */
/*
boxSave = new QGroupBox("Save Image",this);
boxSave->setFixedHeight(45);
boxSave->setContentsMargins(0,8,0,0);
layoutSave = new QHBoxLayout;
boxSave->setLayout(layoutSave);
* Label file name
lblFName = new QLabel("File Name:",this);
layoutSave->addWidget(lblFName);
* To get 0 spacing between the next 2 widgets file name and file format
hLayoutSave = new QHBoxLayout();
layoutSave->addLayout(hLayoutSave);
hLayoutSave->setSpacing(0);
* file name
dispFName = new QLineEdit(this);
dispFName->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
hLayoutSave->addWidget(dispFName);
* file format
comboFormat = new QComboBox(this);
comboFormat->setFrame(true);
comboFormat->addItem(".gif");
comboFormat->addItem(".pdf");
comboFormat->addItem(".png");
comboFormat->addItem(".gif+");
comboFormat->addItem(".jpg");
comboFormat->addItem(".ps");
comboFormat->addItem(".eps");
comboFormat->addItem(".xpm");
comboFormat->addItem(".C");
hLayoutSave->addWidget(comboFormat);
* save button
btnSave = new QPushButton("Save",this);
btnSave->setFocusPolicy(Qt::NoFocus);
layoutSave->addWidget(btnSave);
* automatic file name check box
chkAutoFName = new QCheckBox("Automatic File Name",this);
layoutSave->addWidget(chkAutoFName);
* automatic save all check box
chkSaveAll = new QCheckBox("Save All",this);
layoutSave->addWidget(chkSaveAll);
*/
/** main window widgets */
//mainLayout->addWidget(boxSave,0,0);
mainLayout->addWidget(cloneBox,1,0);
@ -192,6 +149,22 @@ void qCloneWidget::SavePlot(){
"Formats: .png, .jpg, .xpm.","Snapshot");
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
int qCloneWidget::SavePlotAutomatic(){
char cID[10];
sprintf(cID,"%d",id);
QString fName = QString(filePath.c_str())+"/Snapshot_"+QString(cID)+".png";
QImage img(cloneBox->size().width(),cloneBox->size().height(),QImage::Format_RGB32);
QPainter painter(&img);
cloneBox->render(&painter);
if(img.save(fName))
return 0;
else return -1;
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qCloneWidget::closeEvent(QCloseEvent* event){

View File

@ -223,10 +223,12 @@ void qDetectorMain::Initialization(){
connect(tab_measurement, SIGNAL(StopSignal()), this,SLOT(EnableTabs()));
connect(tab_measurement, SIGNAL(CheckPlotIntervalSignal()), tab_plot,SLOT(SetFrequency()));
connect(tab_measurement, SIGNAL(EnableNthFrameSignal(bool)), tab_plot,SLOT(EnableNthFrame(bool)));
// Data Output Tab
connect(tab_dataoutput, SIGNAL(AngularConversionSignal(bool)), tab_actions,SLOT(EnablePositions(bool)));
// Plot tab
connect(tab_plot, SIGNAL(DisableZoomSignal(bool)), this,SLOT(SetZoomToolTip(bool)));
// Actions tab
connect(tab_actions, SIGNAL(EnableScanBox(int,int)), tab_plot,SLOT(EnableScanBox(int,int)));
connect(tab_actions, SIGNAL(EnableScanBox()), tab_plot,SLOT(EnableScanBox()));
// Plotting
// When the acquisition is finished, must update the meas tab
connect(myPlot, SIGNAL(UpdatingPlotFinished()), this, SLOT(EnableTabs()));
@ -269,7 +271,6 @@ void qDetectorMain::EnableModes(QAction *action){
else if(action==actionExpert){
enable = actionExpert->isChecked();
tabs->setTabEnabled(Advanced,enable);
tab_settings->EnableExpertMode(enable);
#ifdef VERBOSE
cout << "Setting Expert Mode to " << enable << endl;
#endif

View File

@ -66,7 +66,7 @@ void qDrawPlot::SetupWidgetWindow(){
nPixelsX = myDet->getTotalNumberOfChannels();
nPixelsY = 100;
minPixelsY = 0;
lastImageArray = 0;
image_data = 0;
//1d
@ -77,12 +77,12 @@ void qDrawPlot::SetupWidgetWindow(){
currentPersistency = 0;
progress = 0;
plotEnable=true;
saveAll = false;
plotDotted = false;
XYRangeChanged = false;
timerValue = PLOT_TIMER_MS;
frameFactor=0;
oldCopy = false;
oldFrameNumber = 0;
data_pause_over = true;//to get the first image
isFrameEnabled = false;
isTriggerEnabled = false;
@ -177,38 +177,36 @@ void qDrawPlot::StartStopDaqToggle(bool stop_if_running){
//to get the first image
data_pause_over = true;
// Number of Exposures
int numFrames = (isFrameEnabled)*((int)myDet->setTimer(slsDetectorDefs::FRAME_NUMBER,-1));
int numTriggers = (isTriggerEnabled)*((int)myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER,-1));
numFrames = ((numFrames==0)?1:numFrames);
numTriggers = ((numTriggers==0)?1:numTriggers);
number_of_exposures = numFrames * numTriggers;
//cout << "\tNumber of Exposures:" << number_of_exposures << endl;
/* have to also look at vector created using npixelsy as size*/
if(scanArgument==AllFrames)
nPixelsY = number_of_exposures;
else nPixelsY = 100;
number_of_frames = numFrames * numTriggers;
cout << "\tNumber of Frames per Scan/Measurement:" << number_of_frames << endl;
//get #pos and #scansets for level 0 and level 1
int numPos = myDet->getPositions(); numPos = ((numPos==0)?1:numPos);
//get #scansets for level 0 and level 1
int numScan0 = myDet->getScanSteps(0); numScan0 = ((numScan0==0)?1:numScan0);
int numScan1 = myDet->getScanSteps(1); numScan1 = ((numScan1==0)?1:numScan1);
number_of_exposures = number_of_exposures * numPos * numScan0 * numScan1;
number_of_exposures = number_of_frames * numScan0 * numScan1;
cout << "\tNumber of Exposures:" << number_of_exposures << endl;
// ExposureTime
exposureTime= ((double)(myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,-1))*1E-9);
cout << "\tExposure Time:" << setprecision (10) << exposureTime << endl;
// Acquisition Period
acquisitionPeriod= ((double)(myDet->setTimer(slsDetectorDefs::FRAME_PERIOD,-1))*1E-9);
cout << "\tAcquisition Period:" << setprecision (10) << acquisitionPeriod << endl;
// Current Index
currentIndex = myDet->getFileIndex();
cout << "\tCurrent Index:" << currentIndex << endl;
//for save automatically,
saveError = false;
lastSavedFrame = -1;
lastSavedMeasurement = -1;
StartDaq(true);
running=!running;
@ -266,21 +264,74 @@ bool qDrawPlot::StartOrStopThread(bool start){
progress = 0;
currentFrame = 0;
stop_signal = 0;
oldFrameNumber = 0;
//for 2d scans
int currentIndex = myDet->getFileIndex();
currentScanValue = 0;
currentScanDivLevel = 0;
if(scanArgument!=None){
if(scanArgument==AllFrames){
maxPixelsY = currentIndex + number_of_exposures - 1;
minPixelsY = currentIndex;
nPixelsY = number_of_exposures;
}else if(scanArgument==FileIndex){
maxPixelsY = currentIndex + number_of_frames - 1;
minPixelsY = currentIndex;
nPixelsY = number_of_frames;
}else if(scanArgument==Level0){
//no need to check if numsteps=0,cuz otherwise this mode wont be set in plot tab
int numSteps = myDet->getScanSteps(0);
//if(values) delete [] values;
double *values = new double[numSteps];
myDet->getScanSteps(0,values);
maxPixelsY = values[numSteps-1];
minPixelsY = values[0];
nPixelsY = numSteps;
currentScanValue = values[0];
}
pixelWidth = (maxPixelsY -minPixelsY)/(nPixelsY-1);
startPixel = minPixelsY -(pixelWidth/2);
endPixel = maxPixelsY + (pixelWidth/2);
}else{//no scan
nPixelsY = number_of_exposures;
maxPixelsY = 100;
minPixelsY = 0;
startPixel = -0.5;
endPixel = nPixelsY-0.5;
}
cout<<"nPixelsY:"<<nPixelsY<<endl;
cout<<"minPixelsY:"<<minPixelsY<<endl;
cout<<"maxPixelsY:"<<maxPixelsY<<endl;
cout<<"startPixel:"<<startPixel<<endl;
cout<<"endPixel:"<<endPixel<<endl;
//1d
histNBins = nPixelsX;
if(histXAxis) delete [] histXAxis; histXAxis = new double [nPixelsX];
if(histYAxis[0]) delete [] histYAxis[0];histYAxis[0] = new double [nPixelsX];
//2d
if(lastImageArray) delete [] lastImageArray; lastImageArray = new double[nPixelsY*nPixelsX];
//sorta useless
if(yvalues[0]) delete [] yvalues[0]; yvalues[0] = new double [nPixelsX];
if(image_data) delete [] image_data; image_data = new double[nPixelsY*nPixelsX];
//initializing 1d xaxis
for(unsigned int px=0;px<nPixelsX;px++)
histXAxis[px] = px+10;
//initializing 2d array
for(int py=0;py<nPixelsY;py++)
for(int px=0;px<nPixelsX;px++)
lastImageArray[py*nPixelsX+px] = 0;
/**delete it if it exists and create again and for originally 1d, initalize it with all 0*/
if(image_data) delete [] image_data;
image_data = new double[nPixelsY*nPixelsX];
//if(!image_data) image_data = new double[nPixelsY*nPixelsX];
//if(!lastImageArray) lastImageArray = new double[nPixelsY*nPixelsX];
if(lastImageArray) delete [] lastImageArray;
lastImageArray = new double[nPixelsY*nPixelsX];
if(!histXAxis) histXAxis = new double [nPixelsX];
for(unsigned int px=0;px<nPixelsX;px++) histXAxis[px] = px+10;
if(!yvalues[0]) yvalues[0] = new double [nPixelsX];
if(!histYAxis[0]) histYAxis[0] = new double [nPixelsX];
if(plot_in_scope==1) Clear1DPlot();
@ -324,91 +375,114 @@ int qDrawPlot::GetData(detectorData *data){
cout << "Entering GetDatafunction" << endl;
#endif
if(!stop_signal){
/** all frames shouldnt go in here */
if(scanArgument!=AllFrames){
//not frame factor
if(!frameFactor){
//if the time is not over, RETURN
if(!data_pause_over){
//lastImageNumber= currentFrame+1;
currentFrame++;
currentIndex++;
return 0;
}
data_pause_over=false;
data_pause_timer->start((int)(PLOT_TIMER_MS/2));
}//if frame factor or last frame of last measurement... for all other factors, RETURN
else{
if(((currentFrame+1==number_of_exposures)&&(currentMeasurement+1==number_of_measurements))
||(!((currentFrame)%frameFactor)))
oldCopy = false;//if this works, then we forget old data
else{
//lastImageNumber= currentFrame+1;
currentFrame++;
currentIndex++;
progress=(int)data->progressIndex;
//if theres an old copy, try to get lock again
if(oldCopy){
#ifdef VERBOSE
cout << "Copying old data: " << oldFrameNumber << endl;
#endif
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
char temp_title[2000];
// only if you got the lock, do u need to remember lastimagenumber to plot
lastImageNumber= currentFrame;
//1d
if(plot_in_scope==1){
// Titles
sprintf(temp_title,"Frame Index%d",oldFrameNumber); histTitle[0] = temp_title;
// copy data//memcpy(histXAxis, xvalues,nPixelsX*sizeof(double));
for(int i=currentPersistency;i>0;i--)
memcpy(histYAxis[i],yvalues[i-1],nPixelsX*sizeof(double));
memcpy(histYAxis[0],yvalues[0],nPixelsX*sizeof(double));
}//2d
else{
// Titles
sprintf(temp_title,"Image Index %d",oldFrameNumber);
imageTitle = temp_title;
// copy data
//memcpy(lastImageArray,image_data,nPixelsX*nPixelsY*sizeof(double));
}
pthread_mutex_unlock(&(last_image_complete_mutex));
}
}
return 0;
}
}
}
//if plot disabled, RETURN
//Plot Disabled
if(!plotEnable) {
progress=(int)data->progressIndex;
//lastImageNumber= currentFrame+1;
currentFrame++;
currentIndex++;
return 0;
}
//Nth Frame
if(frameFactor){
//when to copy data
if(((currentFrame+1==number_of_exposures)&&(currentMeasurement+1==number_of_measurements))
||(!((currentFrame)%frameFactor)));
//return if not
else{
progress=(int)data->progressIndex;
currentFrame++;
return 0;
}
}
//Not Nth Frame, Not time out yet
else{
//if the time is not over, RETURN
if(!data_pause_over){
progress=(int)data->progressIndex;
currentFrame++;
return 0;
}
data_pause_over=false;
data_pause_timer->start((int)(PLOT_TIMER_MS/2));
}
//what comes here has plot enabled AND (frame factor OR data pause over )
progress=(int)data->progressIndex;
//current index
currentIndex = myDet->getFileIndexFromFileName(string(data->fileName));
//scan variable
int currentScanVariable0 = myDet->getCurrentScanVariable(0);
int currentScanVariable1 = myDet->getCurrentScanVariable(1);
if((currentFrame)<(number_of_exposures)){
#ifdef VERYVERBOSE
cout << "Reading in image: " << currentIndex << endl;
#endif
//if scan argument is all frames
if(scanArgument==AllFrames){
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
lastImageNumber= currentFrame+1;
char temp_title[2000]; sprintf(temp_title,"Image Index %d",currentIndex); imageTitle = temp_title;
memcpy(lastImageArray+(currentFrame*nPixelsX),data->values,nPixelsX*sizeof(double));
pthread_mutex_unlock(&(last_image_complete_mutex));
//if scan argument is 2d
if(scanArgument!=None){
if(scanArgument==AllFrames){
/*title should include which scan, also by measurement tab*/
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
lastImageNumber= currentFrame+1;
char temp_title[2000]; sprintf(temp_title,"Image Index %d",currentIndex); imageTitle = temp_title;
memcpy(lastImageArray+(currentScanDivLevel*nPixelsX),data->values,nPixelsX*sizeof(double));
pthread_mutex_unlock(&(last_image_complete_mutex));
}
currentFrame++;
currentScanDivLevel++;
return 0;
}
currentFrame++;
currentIndex++;
return 0;
else if(scanArgument==FileIndex){
/*title should include which scan, also by measurement tab*/
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
if(currentIndex == minPixelsY) currentScanDivLevel = 0;
lastImageNumber= currentFrame+1;
char temp_title[2000]; sprintf(temp_title,"Image Index %d",currentIndex); imageTitle = temp_title;
//memcpy(lastImageArray+(currentIndex*nPixelsX),data->values,nPixelsX*sizeof(double));
for(unsigned int px=0;px<nPixelsX;px++) lastImageArray[currentScanDivLevel*nPixelsX+px] += data->values[px];
pthread_mutex_unlock(&(last_image_complete_mutex));
}
currentFrame++;
currentScanDivLevel++;
return 0;
}
else if(scanArgument==Level0){
/*title should include which scan, also by measurement tab*/
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
if(currentScanVariable0!=currentScanValue) currentScanDivLevel++;
currentScanValue = currentScanVariable0;
lastImageNumber= currentFrame+1;
char temp_title[2000]; sprintf(temp_title,"Image Index %d",currentIndex); imageTitle = temp_title;
//memcpy(lastImageArray+(currentIndex*nPixelsX),data->values,nPixelsX*sizeof(double));
//for(int i=values[currentScan];i<values[currentScan+1];i++)
//memcpy(lastImageArray+(currentScanVariable0-1*nPixelsX),data->values,nPixelsX*sizeof(double));
//memcpy(lastImageArray+(currentScanDivLevel*nPixelsX),data->values,nPixelsX*sizeof(double));
for(unsigned int px=0;px<nPixelsX;px++) lastImageArray[currentScanDivLevel*nPixelsX+px] += data->values[px];
cout<<"lastImageArray[0*1280+500]:"<<lastImageArray[currentScanDivLevel*nPixelsX+500]<<endl;
//lastImageArray + ((pixelWidth/2) + currentScanDivLevel * pixelWidth) * nPixelsX + px += data->values[px];
pthread_mutex_unlock(&(last_image_complete_mutex));
}
currentFrame++;
return 0;
}
}
//normal measurement or 1d scans
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
char temp_title[2000];
// only if you got the lock, do u need to remember lastimagenumber to plot
@ -443,29 +517,8 @@ int qDrawPlot::GetData(detectorData *data){
//SHOULD BE memcpy(lastImageArray,data->values,nPixelsX*nPixelsY*sizeof(double));
}
pthread_mutex_unlock(&(last_image_complete_mutex));
}//copies old data only if its frame factor
else if(frameFactor){
oldCopy = true;
oldFrameNumber = currentIndex;
//1D
if(plot_in_scope==1){
// Persistency
if(currentPersistency < persistency)currentPersistency++;
else currentPersistency=persistency;
nHists = currentPersistency+1;
// copy old data
for(int i=currentPersistency;i>0;i--)
memcpy(yvalues[i],yvalues[i-1],nPixelsX*sizeof(double));
nHists = currentPersistency+1;
memcpy(yvalues[0],data->values,nPixelsX*sizeof(double));
}//2D
else{
// copy old data
//memcpy(image_data,data->values,nPixelsX*nPixelsY*sizeof(double));
}
}
currentFrame++;
currentIndex++;
}
}
#ifdef VERYVERBOSE
@ -548,6 +601,7 @@ void qDrawPlot::UpdatePlot(){
plot1D->SetYMinMax(XYRangeValues[qDefs::YMINIMUM],XYRangeValues[qDefs::YMAXIMUM]);
XYRangeChanged = false;
}
if(saveAll) SavePlotAutomatic();
}
}
//2-d plot stuff
@ -555,7 +609,8 @@ void qDrawPlot::UpdatePlot(){
if(lastImageArray){
if(lastImageNumber&&last_plot_number!=(int)lastImageNumber && //there is a new plot
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,-0.5,nPixelsY-0.5,lastImageArray);
plot2D->GetPlot()->SetData(nPixelsX,-0.5,nPixelsX-0.5,nPixelsY,startPixel,endPixel,lastImageArray);
plot2D->setTitle(GetImageTitle());
plot2D->SetXTitle(imageXAxisTitle);
plot2D->SetYTitle(imageYAxisTitle);
@ -572,6 +627,7 @@ void qDrawPlot::UpdatePlot(){
plot2D->GetPlot()->SetYMinMax(XYRangeValues[qDefs::YMINIMUM],XYRangeValues[qDefs::YMAXIMUM]);
XYRangeChanged = false;
}
if(saveAll) SavePlotAutomatic();
}
}
last_plot_number=lastImageNumber;
@ -595,7 +651,6 @@ void qDrawPlot::UpdatePlot(){
}// To start the next measurement
else{
emit SetCurrentMeasurementSignal(currentMeasurement);
currentIndex++;
StopDaqForGui();
StartDaq(true);
}
@ -659,6 +714,27 @@ void qDrawPlot::ClonePlot(){
connect(winClone[i], SIGNAL(CloneClosedSignal(int)),this, SLOT(CloneCloseEvent(int)));
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qDrawPlot::SaveClones(){
char errID[200];
string errMessage= "The Snapshots with ID's: ";
bool success = true;
for(int i=0;i<MAXCloneWindows;i++)
if(winClone[i]){
if(winClone[i]->SavePlotAutomatic()){
success = false;
sprintf(errID,"%d",i);
errMessage.append(string(errID)+string(", "));
}
}
if(success)
qDefs::InfoMessage("The Snapshots have all been saved successfully in .png.","Dock");
else
qDefs::WarningMessage(errMessage + string("were not saved."),"Dock");
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qDrawPlot::CloseClones(){
@ -697,6 +773,57 @@ void qDrawPlot::SavePlot(){
"Formats: .png, .jpg, .xpm.","Dock");
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qDrawPlot::SaveAll(bool enable){
string msg = string("The Files will be saved as:\n")+
string(myDet->getFilePath().c_str())+string("/")+
string(myDet->getFileName().c_str())+string("_[File Index].png");
qDefs::InfoMessage(msg,"Dock");
saveAll = enable;
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qDrawPlot::SavePlotAutomatic(){
//no need to save the same plot many times
if((currentFrame>lastSavedFrame)&&(currentMeasurement>=lastSavedMeasurement)){
lastSavedFrame = currentFrame;
lastSavedMeasurement = currentMeasurement;
char cID[10];
sprintf(cID,"%d",lastSavedFrame);
QString fName = QString(myDet->getFilePath().c_str())+QString("/")+
QString(myDet->getFileName().c_str())+QString("_")+
QString(cID)+".png";
QImage img(size().width(),size().height(),QImage::Format_RGB32);
QPainter painter(&img);
render(&painter);
//if error while saving
if(!img.save(fName)){
//mention the error only the first time
if(!saveError){
//so it doesnt repeat again
saveError = true;
connect(this,SIGNAL(saveErrorSignal(QString)),this,SLOT(ShowSaveErrorMessage(QString)));
emit saveErrorSignal(fName);
}
}
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qDrawPlot::ShowSaveErrorMessage(QString fileName){
qDefs::WarningMessage(string("Automatic Saving: Could not save the first file:\n")+
string(fileName.toAscii().constData()) + string("\n\nNote: Will not show future file save errors for this acquisition."),"Dock");
}
//-------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -385,7 +385,7 @@ int qScanWidget::SetScan(int mode){
}
}
emit EnableScanBox(actualMode,id);
emit EnableScanBox();
return qDefs::OK;
}

View File

@ -81,13 +81,6 @@ void qTabActions::SetupWidgetWindow(){
btnExpand[i]->setToolTip(tip);
group->addButton(btnExpand[i],i);
//Number of positions is only for mythen or gotthard
slsDetectorDefs::detectorType detType = myDet->getDetectorsType();
if((detType == slsDetectorDefs::EIGER) || (detType == slsDetectorDefs::AGIPD)) {
lblName[NumPositions]->setEnabled(false);
btnExpand[NumPositions]->setEnabled(false);
}
//add the widgets to the layout , depending on the type create the widgets
gridLayout->addWidget(btnExpand[i],(i*2),0);
gridLayout->addWidget(lblName[i],(i*2),1);
@ -111,6 +104,21 @@ void qTabActions::SetupWidgetWindow(){
}
//Number of positions is only for mythen or gotthard
detType = myDet->getDetectorsType();
if((detType == slsDetectorDefs::EIGER) || (detType == slsDetectorDefs::AGIPD)) {
lblName[NumPositions]->setEnabled(false);
btnExpand[NumPositions]->setEnabled(false);
}else{
//disable positions if angular conversion is enabled
int ang;
if(!myDet->getAngularConversion(ang)){
lblName[NumPositions]->setEnabled(false);
btnExpand[NumPositions]->setEnabled(false);
}
}
}
@ -181,7 +189,7 @@ void qTabActions::Initialization(){
connect(group, SIGNAL(buttonClicked(QAbstractButton*)), this,SLOT(Expand(QAbstractButton*)));
//enable scan box in plot tab
for(int i=0;i<qScanWidget::NUM_SCAN_WIDGETS;i++)
connect(scanWidget[i], SIGNAL(EnableScanBox(int,int)), this,SIGNAL(EnableScanBox(int,int)));
connect(scanWidget[i], SIGNAL(EnableScanBox()), this,SIGNAL(EnableScanBox()));
//positions
connect(comboPos, SIGNAL(currentIndexChanged(int)), this, SLOT(SetPosition()));
connect(spinNumPos, SIGNAL(valueChanged(int)), this, SLOT(SetPosition()));
@ -301,6 +309,27 @@ void qTabActions::DeletePosition(){
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabActions::EnablePositions(bool enable){
#ifdef VERBOSE
cout << "\nEnable Positions: " << enable << endl;
#endif
if(enable){
lblName[NumPositions]->setEnabled(true);
btnExpand[NumPositions]->setEnabled(true);
}else{
//to collapse if it was expanded
if(btnExpand[NumPositions]->text()=="-")
Expand(group->button(NumPositions));
comboPos->clear();
lblName[NumPositions]->setPalette(lblName[NumPositions-1]->palette());
lblName[NumPositions]->setEnabled(false);
btnExpand[NumPositions]->setEnabled(false);
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
@ -308,38 +337,43 @@ void qTabActions::Refresh(){
#ifdef VERBOSE
cout << "\nUpdating all action widgets " << endl;
#endif
if(lblName[NumPositions]->isEnabled()){
//delete existing positions
if (positions) delete [] positions;
//get number of positions
int numPos=myDet->getPositions();
comboPos->setMaxCount(numPos);
if((detType == slsDetectorDefs::MYTHEN) || (detType == slsDetectorDefs::GOTTHARD)){
//positions is enabled only if angular conversion is enabled
int ang; if(!myDet->getAngularConversion(ang)) EnablePositions(false);
//set the number of positions in the gui
disconnect(spinNumPos, SIGNAL(valueChanged(int)), this, SLOT(SetPosition()));
spinNumPos->setValue(numPos);
connect(spinNumPos, SIGNAL(valueChanged(int)), this, SLOT(SetPosition()));
if(lblName[NumPositions]->isEnabled()){
//delete existing positions
if (positions) delete [] positions;
//get number of positions
int numPos=myDet->getPositions();
comboPos->setMaxCount(numPos);
positions=new double[numPos];
//load the positions
myDet->getPositions(positions);
//set the number of positions in the gui
disconnect(spinNumPos, SIGNAL(valueChanged(int)), this, SLOT(SetPosition()));
spinNumPos->setValue(numPos);
connect(spinNumPos, SIGNAL(valueChanged(int)), this, SLOT(SetPosition()));
//delete the combolist and reload it
disconnect(comboPos,SIGNAL(currentIndexChanged(int)), this, SLOT(SetPosition()));
comboPos->setEnabled(numPos);
lblPosList->setEnabled(numPos);
lblPosList->setText("List of Positions: ");
lblPosList->setPalette(normal);
for(int i=0;i<comboPos->count();i++)
comboPos->removeItem(i);
for(int i=0;i<numPos;i++)
comboPos->insertItem(i,QString("%1").arg(positions[i]));
connect(comboPos, SIGNAL(currentIndexChanged(int)), this, SLOT(SetPosition()));
positions=new double[numPos];
//load the positions
myDet->getPositions(positions);
//delete the combolist and reload it
disconnect(comboPos,SIGNAL(currentIndexChanged(int)), this, SLOT(SetPosition()));
comboPos->setEnabled(numPos);
lblPosList->setEnabled(numPos);
lblPosList->setText("List of Positions: ");
lblPosList->setPalette(normal);
for(int i=0;i<comboPos->count();i++)
comboPos->removeItem(i);
for(int i=0;i<numPos;i++)
comboPos->insertItem(i,QString("%1").arg(positions[i]));
connect(comboPos, SIGNAL(currentIndexChanged(int)), this, SLOT(SetPosition()));
#ifdef VERBOSE
cout << "Updated position widget\tnum:" << numPos << endl << endl;
cout << "Updated position widget\tnum:" << numPos << endl << endl;
#endif
}
}
for(int i=0;i<qScanWidget::NUM_SCAN_WIDGETS;i++)
scanWidget[i]->Refresh();

View File

@ -343,16 +343,21 @@ void qTabDataOutput::SetAngularCorrection(){
cout << "Entering Set Angular Correction function" << endl;
#endif
if(chkAngular->isChecked()){
myDet->setAngularConversionFile("default");
if(myDet->setAngularConversionFile("default")){
#ifdef VERBOSE
cout << "Setting angular conversion to default" << endl;
#endif
}else{
qDefs::WarningMessage("Angular Conversion could not be set.","Data Output");
chkAngular->setChecked(false);
}
}else{
myDet->setAngularConversionFile("");
#ifdef VERBOSE
cout << "Unsetting angular correction" << endl;
#endif
}
emit AngularConversionSignal(chkAngular->isChecked());
}
@ -393,6 +398,7 @@ void qTabDataOutput::Refresh(){
int ang;
if(myDet->getAngularConversion(ang))
chkAngular->setChecked(true);
emit AngularConversionSignal(chkAngular->isChecked());
}
//discard bad channels from server
if(myDet->getBadChannelCorrection()) chkDiscardBad->setChecked(true);

View File

@ -94,6 +94,20 @@ void qTabPlot::SetupWidgetWindow(){
dispYMax->setValidator(new QDoubleValidator(dispYMax));
dispZMax->setValidator(new QDoubleValidator(dispZMax));
//default titles
dispTitle->setText(defaultPlotTitle);
myPlot->SetPlotTitle(defaultPlotTitle);
dispXAxis->setText(defaultHistXAxisTitle);
dispYAxis->setText(defaultHistYAxisTitle);
myPlot->SetHistXAxisTitle(defaultHistXAxisTitle);
myPlot->SetHistYAxisTitle(defaultHistYAxisTitle);
dispXAxis->setText(defaultImageXAxisTitle);
dispYAxis->setText(defaultImageYAxisTitle);
dispZAxis->setText(defaultImageZAxisTitle);
myPlot->SetImageXAxisTitle(defaultImageXAxisTitle);
myPlot->SetImageYAxisTitle(defaultImageYAxisTitle);
myPlot->SetImageZAxisTitle(defaultImageZAxisTitle);
// Plotting Frequency
stackedLayout = new QStackedLayout;
@ -147,18 +161,12 @@ void qTabPlot::SetupWidgetWindow(){
void qTabPlot::Select1DPlot(bool b){
isOneD = b;
dispTitle->setText(defaultPlotTitle);
myPlot->SetPlotTitle(defaultPlotTitle);
if(b){
box1D->show();
box2D->hide();
chkZAxis->setEnabled(false);
chkZMin->setEnabled(false);
chkZMax->setEnabled(false);
dispXAxis->setText(defaultHistXAxisTitle);
dispYAxis->setText(defaultHistYAxisTitle);
myPlot->SetHistXAxisTitle(defaultHistXAxisTitle);
myPlot->SetHistYAxisTitle(defaultHistYAxisTitle);
myPlot->Select1DPlot();
}else{
box1D->hide();
@ -166,15 +174,8 @@ void qTabPlot::Select1DPlot(bool b){
chkZAxis->setEnabled(true);
chkZMin->setEnabled(true);
chkZMax->setEnabled(true);
dispXAxis->setText(defaultImageXAxisTitle);
dispYAxis->setText(defaultImageYAxisTitle);
dispZAxis->setText(defaultImageZAxisTitle);
myPlot->SetImageXAxisTitle(defaultImageXAxisTitle);
myPlot->SetImageYAxisTitle(defaultImageYAxisTitle);
myPlot->SetImageZAxisTitle(defaultImageZAxisTitle);
myPlot->Select2DPlot();
}
}
@ -188,9 +189,11 @@ void qTabPlot::Initialization(){
connect(radioDataGraph, SIGNAL(toggled(bool)),this, SLOT(SetPlot()));
// Scan box
connect(btnGroupScan, SIGNAL(buttonClicked(QAbstractButton *)),this, SLOT(SetScanArgument()));
connect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox()));
// Snapshot box
connect(btnClone, SIGNAL(clicked()),myPlot, SLOT(ClonePlot()));
connect(btnCloseClones, SIGNAL(clicked()),myPlot, SLOT(CloseClones()));
connect(btnSaveClones, SIGNAL(clicked()),myPlot, SLOT(SaveClones()));
// 1D Plot box
connect(chkSuperimpose, SIGNAL(toggled(bool)), this, SLOT(EnablePersistency(bool)));
connect(spinPersistency,SIGNAL(valueChanged(int)), myPlot,SLOT(SetPersistency(int)));
@ -228,12 +231,14 @@ void qTabPlot::Initialization(){
connect(dispYMax, SIGNAL(returnPressed()), this, SLOT(SetAxesRange()));
connect(dispZMin, SIGNAL(returnPressed()), this, SLOT(SetZRange()));
connect(dispZMax, SIGNAL(returnPressed()), this, SLOT(SetZRange()));
// Save
connect(btnSave, SIGNAL(clicked()), myPlot, SLOT(SavePlot()));
connect(chkSaveAll, SIGNAL(toggled(bool)), myPlot, SLOT(SaveAll(bool)));
connect(this,SIGNAL(SetZRangeSignal(double,double)),myPlot, SIGNAL(SetZRangeSignal(double,double)));
// Common Buttons
// Save
connect(btnSave, SIGNAL(clicked()), myPlot, SLOT(SavePlot()));
}
@ -485,7 +490,7 @@ void qTabPlot::SetFrequency(){
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabPlot::EnableScanBox(int mode,int id){
void qTabPlot::EnableScanBox(){
#ifdef VERYVERBOSE
cout << "Entering Enable Scan Box() \t mode:" << mode << " \t id:" << id << endl;
#endif
@ -493,25 +498,42 @@ void qTabPlot::EnableScanBox(int mode,int id){
int mode0 = myDet->getScanMode(0);
int mode1 = myDet->getScanMode(1);
//if it was checked before or disabled before, it remembers to check it again
bool checkedBefore = (boxScan->isChecked()||(!boxScan->isEnabled()));
//only now enable/disable
boxScan->setEnabled(mode0||mode1);
//if there are scan
if(boxScan->isEnabled()){
//make sure nth frame frequency plot is disabled
EnablingNthFrameFunction(false);
//if level0 or 1, check argument to find which scan enabled last from actions tab
if((btnGroupScan->checkedId()!=2)&&(btnGroupScan->checkedId()!=3)){
cout<<"mode:"<<mode<<" id:"<<id<<endl;
//if mode is not none(doesnt check them if called form refresh)
if(mode>0){
if(!id) radioLevel0->setChecked(true);
else radioLevel1->setChecked(true);
//if 2d is chosen or not for scan
if(boxScan->isChecked()){
boxScan->setChecked(checkedBefore);
//make sure nth frame frequency plot is disabled
EnablingNthFrameFunction(false);
//
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
if((radioLevel0->isChecked())||(radioLevel1->isChecked())){
if(mode0) radioLevel0->setChecked(true);
if(mode1) radioLevel1->setChecked(true);
}
}
}
else EnablingNthFrameFunction(enableNFrame);
radioLevel0->setEnabled(mode0);
radioLevel1->setEnabled(mode1);
}else EnablingNthFrameFunction(enableNFrame);
//sets the scan argument
SetScanArgument();
@ -542,13 +564,13 @@ void qTabPlot::EnablingNthFrameFunction(bool enable){
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
/** What happens for 2d????*/
void qTabPlot::SetScanArgument(){
//as default from histogram and default titles are set here if scanbox is disabled
Select1DPlot(isOrginallyOneD);
//this function is also called just to update, could be no scan
//if scans
if(boxScan->isEnabled()){
//setting the title according to the scans
@ -556,52 +578,58 @@ void qTabPlot::SetScanArgument(){
QString(" | Level 1 : ") + modeNames[myDet->getScanMode(1)] + QString("");
dispTitle->setText(mainTitle);
myPlot->SetPlotTitle(mainTitle);
}else{
dispTitle->setText(defaultPlotTitle);
myPlot->SetPlotTitle(defaultPlotTitle);
dispXAxis->setText(defaultHistXAxisTitle);
dispYAxis->setText(defaultHistYAxisTitle);
myPlot->SetHistXAxisTitle(defaultHistXAxisTitle);
myPlot->SetHistYAxisTitle(defaultHistYAxisTitle);
dispXAxis->setText(defaultImageXAxisTitle);
dispYAxis->setText(defaultImageYAxisTitle);
dispZAxis->setText(defaultImageZAxisTitle);
myPlot->SetImageXAxisTitle(defaultImageXAxisTitle);
myPlot->SetImageYAxisTitle(defaultImageYAxisTitle);
myPlot->SetImageZAxisTitle(defaultImageZAxisTitle);
}
//for 2d
if((boxScan->isEnabled())&&(boxScan->isChecked())){
//let qdrawplot know which scan argument
myPlot->SetScanArgument(btnGroupScan->checkedId()+1);
/** What happens for 2d????*/
//settings the x and y titles
//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()){
//level0
case 0:
dispXAxis->setText("Channel Number");
case 0://level0
dispYAxis->setText("Scan Level 0");
myPlot->SetHistXAxisTitle("Channel Number");
myPlot->SetHistYAxisTitle("Scan Level 0");
myPlot->Select1DPlot();
myPlot->SetImageYAxisTitle("Scan Level 0");
break;
//level1
case 1:
dispXAxis->setText("Channel Number");
case 1://level1
dispYAxis->setText("Scan Level 1");
myPlot->SetHistXAxisTitle("Channel Number");
myPlot->SetHistYAxisTitle("Scan Level 1");
myPlot->Select1DPlot();
myPlot->SetImageYAxisTitle("Scan Level 1");
break;
//file index
case 2:
dispXAxis->setText("Channel Number");
break;
case 2://file index
dispYAxis->setText("File Index");
myPlot->SetHistXAxisTitle("Channel Number");
myPlot->SetHistYAxisTitle("File Index");
myPlot->Select1DPlot();
myPlot->SetImageYAxisTitle("File Index");
break;
//all frames
case 3:
Select1DPlot(false);
dispXAxis->setText("Channel Number");
dispYAxis->setText("Threshold");
dispZAxis->setText("Intensity");
myPlot->SetImageXAxisTitle("Channel Number");
myPlot->SetImageYAxisTitle("Threshold");
myPlot->SetImageZAxisTitle("Intensity");
myPlot->Select2DPlot();
case 3://all frames
dispYAxis->setText("All Frames");
myPlot->SetImageYAxisTitle("All Frames");
break;
}
//set plot to 2d
Select1DPlot(false);
myPlot->Select2DPlot();
}else //done here so that it isnt set by default each time
myPlot->SetScanArgument(0);

View File

@ -17,7 +17,7 @@ using namespace std;
//-------------------------------------------------------------------------------------------------------------------------------------------------
qTabSettings::qTabSettings(QWidget *parent,multiSlsDetector*& detector,int detID):
QWidget(parent),myDet(detector),detID(detID), expertMode(false){
QWidget(parent),myDet(detector),detID(detID){
setupUi(this);
SetupWidgetWindow();
@ -172,9 +172,9 @@ void qTabSettings::setSettings(int index){
lblThreshold->setEnabled(false);
spinThreshold->setEnabled(false);
}else{
lblThreshold->setEnabled(expertMode);
spinThreshold->setEnabled(expertMode);
if(expertMode) SetEnergy();
lblThreshold->setEnabled(true);
spinThreshold->setEnabled(true);
SetEnergy();
}
}
}
@ -273,9 +273,9 @@ void qTabSettings::Refresh(){
lblThreshold->setEnabled(false);
spinThreshold->setEnabled(false);
}else{
lblThreshold->setEnabled(expertMode);
spinThreshold->setEnabled(expertMode);
if(expertMode) SetEnergy();
lblThreshold->setEnabled(true);
spinThreshold->setEnabled(true);
SetEnergy();
}
}