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

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>748</width>
<height>339</height>
<width>775</width>
<height>345</height>
</rect>
</property>
<property name="sizePolicy">
@ -31,18 +31,344 @@
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QPushButton" name="pushButton">
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>69</x>
<y>229</y>
<width>75</width>
<height>25</height>
<x>25</x>
<y>83</y>
<width>740</width>
<height>93</height>
</rect>
</property>
<property name="text">
<string>PushButton</string>
<property name="title">
<string>Files:</string>
</property>
<layout class="QGridLayout" name="gridLayout_2" rowstretch="0,0,0">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<property name="horizontalSpacing">
<number>-1</number>
</property>
<property name="verticalSpacing">
<number>9</number>
</property>
<item row="1" column="0">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Trimbit File:</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="pushButton_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Load</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QPushButton" name="pushButton_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
<item row="1" column="4">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>120</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="5">
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Calibration File:</string>
</property>
</widget>
</item>
<item row="1" column="6">
<widget class="QPushButton" name="pushButton_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Load</string>
</property>
</widget>
</item>
<item row="1" column="7">
<widget class="QPushButton" name="pushButton_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
<item row="1" column="8">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1" colspan="7">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Output File:</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLineEdit" name="lineEdit"/>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QGroupBox" name="groupBox_2">
<property name="geometry">
<rect>
<x>25</x>
<y>200</y>
<width>726</width>
<height>58</height>
</rect>
</property>
<property name="title">
<string>Trimming Method</string>
</property>
<widget class="QWidget" name="horizontalLayoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>711</width>
<height>31</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>15</number>
</property>
<item>
<widget class="QRadioButton" name="radioButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>None</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Adjust to Fix Count Level</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Equalize to Median</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Optimize Settings</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Offline Improvement</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_3">
<property name="geometry">
<rect>
<x>25</x>
<y>20</y>
<width>726</width>
<height>58</height>
</rect>
</property>
<property name="title">
<string>Calibration Logs</string>
</property>
<widget class="QWidget" name="horizontalLayoutWidget_2">
<property name="geometry">
<rect>
<x>35</x>
<y>20</y>
<width>626</width>
<height>31</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>15</number>
</property>
<item>
<widget class="QCheckBox" name="checkBox_3">
<property name="text">
<string>Energy Calibration</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_4">
<property name="text">
<string>Angular Calibration</string>
</property>
</widget>
</item>
</layout>
</widget>
<zorder>horizontalLayoutWidget_2</zorder>
<zorder>checkBox_3</zorder>
</widget>
</widget>
<resources/>

View File

@ -34,9 +34,9 @@
<widget class="QWidget" name="horizontalLayoutWidget">
<property name="geometry">
<rect>
<x>265</x>
<y>30</y>
<width>251</width>
<x>30</x>
<y>50</y>
<width>321</width>
<height>36</height>
</rect>
</property>
@ -75,7 +75,7 @@
<property name="geometry">
<rect>
<x>30</x>
<y>165</y>
<y>140</y>
<width>321</width>
<height>156</height>
</rect>
@ -126,9 +126,9 @@
<widget class="QPushButton" name="btnGetInfo">
<property name="geometry">
<rect>
<x>265</x>
<y>95</y>
<width>251</width>
<x>425</x>
<y>55</y>
<width>316</width>
<height>25</height>
</rect>
</property>
@ -140,7 +140,7 @@
<property name="geometry">
<rect>
<x>425</x>
<y>165</y>
<y>140</y>
<width>321</width>
<height>156</height>
</rect>

View File

@ -487,13 +487,13 @@
</rect>
</property>
<property name="title">
<string>Scan - Y Axis Values</string>
<string>2D Scan - Y Axis Values</string>
</property>
<property name="checkable">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
<bool>true</bool>
</property>
<widget class="QWidget" name="horizontalLayoutWidget_3">
<property name="geometry">
@ -1443,7 +1443,7 @@
</spacer>
</item>
<item row="0" column="4">
<widget class="QPushButton" name="btnCloseClones_2">
<widget class="QPushButton" name="btnSaveClones">
<property name="enabled">
<bool>true</bool>
</property>

View File

@ -65,6 +65,11 @@ public:
* */
void SetCloneHists(int nHists,int histNBins,double* histXAxis,double* histYAxis[],string histTitle[]);
public slots:
/** Save Plots automatically by save all clones
* returns -1 if fail*/
int SavePlotAutomatic();
private:
/** clone window id*/

View File

@ -27,6 +27,7 @@ class qCloneWidget;
/** C++ Include Headers */
#define MAX_1DPLOTS 10
@ -120,8 +121,12 @@ void Clear1DPlot();
void ClonePlot();
/** Closes all the clone plots */
void CloseClones();
/** Saves all the clone plots */
void SaveClones();
/** To Save plot */
void SavePlot();
/** Save all plots **/
void SaveAll(bool enable);
/** Sets persistency from plot tab */
void SetPersistency(int val);
/** sets style of plot to dotted */
@ -168,9 +173,8 @@ static void* DataStartAcquireThread(void *this_pointer);
static int GetDataCallBack(detectorData *data, void *this_pointer);
/** This is called by the GetDataCallBack function to copy the data */
int GetData(detectorData *data);
/** Saves all the plots. All sets saveError to true if not saved.*/
void SavePlotAutomatic();
@ -187,9 +191,12 @@ void StartDaq(bool start);
/** To set the reference to zero after closing a clone
* @param id is the id of the clone */
void CloneCloseEvent(int id);
/**After a pause, the gui is allowed to collect the data
* this is called when it is over */
void UpdatePause(){data_pause_over=true;};
/** Shows the first save error message while automatic saving
* @param fileName file name of the first file that it tried to save.*/
void ShowSaveErrorMessage(QString fileName);
@ -233,14 +240,21 @@ int currentMeasurement;
int currentFrame;
/** current Index */
int currentIndex;
/** current Scan Division Level */
int currentScanDivLevel;
/** current scan Value */
double currentScanValue;
/** Number of Exposures */
int number_of_exposures;
/** Number of Frames Per Measurement */
int number_of_frames;
/** Duration between Exposures */
double acquisitionPeriod;
/** Acquisition Time */
double exposureTime;
/**variables for threads */
/** */
volatile bool stop_signal;
@ -266,8 +280,19 @@ std::string imageTitle;
unsigned int plot_in_scope;
/** Number of Pixels in X Axis */
unsigned int nPixelsX;
/** Number of Pixels in Y Axis */
unsigned int nPixelsY;
/** Number of pixel bins in Y Axis */
int nPixelsY;
/** Min Pixel number for Y Axis*/
double minPixelsY;
/** Max Pixel number for Y Axis*/
double maxPixelsY;
/** starting pixel */
double startPixel;
/** end Pixel*/
double endPixel;
/** pixel width */
double pixelWidth;
/** Current Image Number */
unsigned int lastImageNumber;
int last_plot_number;
@ -299,8 +324,14 @@ int progress;
bool plotEnable;
/**If plot is dotted */
bool plotDotted;
/** Save all plots */
bool saveAll;
/** If error, while automatically saving plots, checks this at the end of an acquistion */
bool saveError;
/** index of last saved image for automatic saving*/
int lastSavedFrame;
/** index of measurement number of last saved image for automatic saving*/
int lastSavedMeasurement;
/**if an acquisition is running, so as not to refresh tab
* and also to update plot only if running (while creating clones)*/
bool running;
@ -319,9 +350,6 @@ static const double PLOT_TIMER_MS = 250;
double timerValue;
/** every nth frame when to plot */
int frameFactor;
/** old data that did not get lock(for frame factor)**/
bool oldCopy;
int oldFrameNumber;
/**if frame is enabled in measurement tab */
bool isFrameEnabled;
/**if trigger is enabled in measurement tab */
@ -341,6 +369,7 @@ void LogzSignal(bool);
void SetZRangeSignal(double,double);
void EnableZRangeSignal(bool);
void SetCurrentMeasurementSignal(int);
void saveErrorSignal(QString);
};

View File

@ -145,7 +145,7 @@ void BrowseFileStepsPath();
signals:
void EnableScanBox(int,int);
void EnableScanBox();
};

View File

@ -12,9 +12,9 @@
/* Qt Project Class Headers */
#include "qActionsWidget.h"
#include "qScanWidget.h"
/** Project Class Headers */
/** C++ Project Class Headers */
class multiSlsDetector;
class qActionsWidget;
#include "sls_detector_defs.h"
/** Qt Include Headers */
#include <QWidget>
#include <QPushButton>
@ -48,11 +48,19 @@ public:
*/
void Refresh();
public slots:
/** Disable Positions
* @param enable true if to disable
* */
void EnablePositions(bool enable);
private:
/** The sls detector object */
multiSlsDetector *myDet;
slsDetectorDefs::detectorType detType;
enum actionIndex{Scan0=1, Scan1, NumPositions=4, NumTotalActions=9};
QGridLayout *gridLayout;
@ -111,7 +119,7 @@ void SetPosition();
void DeletePosition();
signals:
void EnableScanBox(int,int);
void EnableScanBox();
};

View File

@ -92,6 +92,10 @@ void SetAngularCorrection();
/**discard bad channels*/
void DiscardBadChannels();
signals:
/**signal to enable/disable positions in Actions*/
void AngularConversionSignal(bool);
};

View File

@ -97,10 +97,8 @@ public slots:
/** Set frequency between plots*/
void SetFrequency();
/** Enable Scan box
* @param enable to enable the scan group box
* @param id is 0 if its scan level 0 or scan level 1
*/
void EnableScanBox(int mode=-1,int id=-1);
void EnableScanBox();
/** a variable is set when timing mode has been changed.
* This variable is also disabled if exptime>acq period to be on safe side

View File

@ -38,12 +38,6 @@ public:
*/
void Refresh();
/** enable expert mode
* @param enable true if expert mode is enabled
*/
void EnableExpertMode(bool enable){expertMode=enable;Refresh();};
private:
/** The sls detector object */
@ -55,7 +49,7 @@ private:
/** detector type */
slsDetectorDefs::detectorType detType;
bool expertMode;
enum{Standard,Fast,HighGain,DynamicGain,LowGain,MediumGain,VeryHighGain,Undefined,Uninitialized,NumSettings};

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){
//Plot Disabled
if(!plotEnable) {
progress=(int)data->progressIndex;
currentFrame++;
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){
//lastImageNumber= currentFrame+1;
progress=(int)data->progressIndex;
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
if(!plotEnable) {
progress=(int)data->progressIndex;
//lastImageNumber= currentFrame+1;
currentFrame++;
currentIndex++;
return 0;
}
//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 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+(currentFrame*nPixelsX),data->values,nPixelsX*sizeof(double));
memcpy(lastImageArray+(currentScanDivLevel*nPixelsX),data->values,nPixelsX*sizeof(double));
pthread_mutex_unlock(&(last_image_complete_mutex));
}
currentFrame++;
currentScanDivLevel++;
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++;
currentIndex++;
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,6 +337,10 @@ void qTabActions::Refresh(){
#ifdef VERBOSE
cout << "\nUpdating all action widgets " << endl;
#endif
if((detType == slsDetectorDefs::MYTHEN) || (detType == slsDetectorDefs::GOTTHARD)){
//positions is enabled only if angular conversion is enabled
int ang; if(!myDet->getAngularConversion(ang)) EnablePositions(false);
if(lblName[NumPositions]->isEnabled()){
//delete existing positions
if (positions) delete [] positions;
@ -341,6 +374,7 @@ void qTabActions::Refresh(){
cout << "Updated position widget\tnum:" << numPos << endl << endl;
#endif
}
}
for(int i=0;i<qScanWidget::NUM_SCAN_WIDGETS;i++)
scanWidget[i]->Refresh();
for(int i=0;i<qActionsWidget::NUM_ACTION_WIDGETS;i++)

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);
}else EnablingNthFrameFunction(enableNFrame);
}
//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);
//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
switch(btnGroupScan->checkedId()){
//level0
case 0:
dispXAxis->setText("Channel Number");
dispYAxis->setText("Scan Level 0");
myPlot->SetHistXAxisTitle("Channel Number");
myPlot->SetHistYAxisTitle("Scan Level 0");
myPlot->Select1DPlot();
break;
//level1
case 1:
//default titles for 2d scan
dispXAxis->setText("Channel Number");
dispYAxis->setText("Scan Level 1");
myPlot->SetHistXAxisTitle("Channel Number");
myPlot->SetHistYAxisTitle("Scan Level 1");
myPlot->Select1DPlot();
break;
//file index
case 2:
dispXAxis->setText("Channel Number");
dispYAxis->setText("File Index");
myPlot->SetHistXAxisTitle("Channel Number");
myPlot->SetHistYAxisTitle("File Index");
myPlot->Select1DPlot();
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();
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("File Index");
myPlot->SetImageYAxisTitle("File Index");
break;
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();
}
}