mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-13 13:27:14 +02:00
fixed bug when trimming
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@250 af1100a4-978c-4157-bff7-07162d2ba061
This commit is contained in:
@ -30,10 +30,9 @@ using namespace std;
|
|||||||
|
|
||||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
int main (int argc, char **argv) {
|
int main (int argc, char **argv) {
|
||||||
|
MyApplication *theApp = new MyApplication(argc, argv);
|
||||||
QApplication *theApp = new QApplication(argc, argv);
|
// QApplication *theApp = new QApplication(argc, argv);
|
||||||
theApp->setStyle(new QPlastiqueStyle);//not default when desktop is windows
|
theApp->setStyle(new QPlastiqueStyle);//not default when desktop is windows
|
||||||
theApp->setWindowIcon(QIcon( ":/icons/images/mountain.png" ));
|
theApp->setWindowIcon(QIcon( ":/icons/images/mountain.png" ));
|
||||||
qDetectorMain *det=new qDetectorMain(argc, argv, theApp,0);
|
qDetectorMain *det=new qDetectorMain(argc, argv, theApp,0);
|
||||||
|
@ -630,8 +630,9 @@ void qDrawPlot::SetupMeasurement(){
|
|||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "SetupMeasurement function:" << running << endl;
|
cout << "SetupMeasurement function:" << running << endl;
|
||||||
#endif
|
#endif
|
||||||
|
cout<<"begnPixelsX:"<<nPixelsX<<endl;
|
||||||
LockLastImageArray();
|
cout<<"begnPixelsY:"<<nPixelsY<<endl;
|
||||||
|
LockLastImageArray();cout<<"after lockimage"<<endl;
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "locklastimagearray" << endl;
|
cout << "locklastimagearray" << endl;
|
||||||
@ -644,13 +645,14 @@ void qDrawPlot::SetupMeasurement(){
|
|||||||
//for 2d scans
|
//for 2d scans
|
||||||
currentScanDivLevel = 0;
|
currentScanDivLevel = 0;
|
||||||
//if(plot_in_scope==2)
|
//if(plot_in_scope==2)
|
||||||
if(!running) lastImageNumber = 0;/**Just now */
|
if(!running)
|
||||||
|
lastImageNumber = 0;/**Just now */
|
||||||
|
cout<<"before 2d"<<endl;
|
||||||
//initializing 2d array
|
//initializing 2d array
|
||||||
for(int py=0;py<(int)nPixelsY;py++)
|
for(int py=0;py<(int)nPixelsY;py++)
|
||||||
for(int px=0;px<(int)nPixelsX;px++)
|
for(int px=0;px<(int)nPixelsX;px++)
|
||||||
lastImageArray[py*nPixelsX+px] = 0;
|
lastImageArray[py*nPixelsX+px] = 0;
|
||||||
|
cout<<"end of 2d"<<endl;
|
||||||
//1d with no scan
|
//1d with no scan
|
||||||
if ((!originally2D) && (scanArgument==qDefs::None)){
|
if ((!originally2D) && (scanArgument==qDefs::None)){
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
@ -662,7 +664,7 @@ void qDrawPlot::SetupMeasurement(){
|
|||||||
minPixelsY = 0;
|
minPixelsY = 0;
|
||||||
startPixel = -0.5;
|
startPixel = -0.5;
|
||||||
endPixel = nPixelsY-0.5;
|
endPixel = nPixelsY-0.5;
|
||||||
}
|
}else cout<<"correct palce"<<endl;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
@ -715,7 +717,7 @@ void qDrawPlot::SetupMeasurement(){
|
|||||||
cout<<"startPixel:"<<startPixel<<endl;
|
cout<<"startPixel:"<<startPixel<<endl;
|
||||||
cout<<"endPixel:"<<endPixel<<endl<<endl;
|
cout<<"endPixel:"<<endPixel<<endl<<endl;
|
||||||
*/
|
*/
|
||||||
UnlockLastImageArray();
|
UnlockLastImageArray();cout<<"out of setupmeasure"<<endl;
|
||||||
|
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
@ -760,7 +762,7 @@ int qDrawPlot::GetData(detectorData *data,int fIndex){
|
|||||||
cout << "angle " << data->angles << endl;
|
cout << "angle " << data->angles << endl;
|
||||||
//#endif
|
//#endif
|
||||||
if(!stop_signal){
|
if(!stop_signal){
|
||||||
|
cout<<"before progress"<<endl;
|
||||||
//set progress
|
//set progress
|
||||||
progress=(int)data->progressIndex;
|
progress=(int)data->progressIndex;
|
||||||
currentFrameIndex = fileIOStatic::getIndicesFromFileName(string(data->fileName),currentFileIndex);
|
currentFrameIndex = fileIOStatic::getIndicesFromFileName(string(data->fileName),currentFileIndex);
|
||||||
@ -769,10 +771,9 @@ int qDrawPlot::GetData(detectorData *data,int fIndex){
|
|||||||
cout << "Received empty file name. Exiting function without updating data for plot." << endl;
|
cout << "Received empty file name. Exiting function without updating data for plot." << endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#ifdef VERYVERBOSE
|
//#ifdef VERYVERBOSE
|
||||||
cout << "progress:" << progress << endl;
|
cout << "progress:" << progress << endl;
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
// secondary title necessary to differentiate between frames when not saving data
|
// secondary title necessary to differentiate between frames when not saving data
|
||||||
char temp_title[2000];
|
char temp_title[2000];
|
||||||
//findex is used because in the receiver, you cannot know the frame index as many frames are in 1 file.
|
//findex is used because in the receiver, you cannot know the frame index as many frames are in 1 file.
|
||||||
@ -788,7 +789,7 @@ int qDrawPlot::GetData(detectorData *data,int fIndex){
|
|||||||
//Plot Disabled
|
//Plot Disabled
|
||||||
if(!plotEnable) return 0;
|
if(!plotEnable) return 0;
|
||||||
|
|
||||||
|
cout<<"before entering angleplot"<<endl;
|
||||||
//angle plotting
|
//angle plotting
|
||||||
if(anglePlot){
|
if(anglePlot){
|
||||||
LockLastImageArray();
|
LockLastImageArray();
|
||||||
@ -853,33 +854,33 @@ int qDrawPlot::GetData(detectorData *data,int fIndex){
|
|||||||
|
|
||||||
//Nth Frame
|
//Nth Frame
|
||||||
if(frameFactor){
|
if(frameFactor){
|
||||||
//plots if numfactor becomes 0
|
//plots if numfactor becomes 0
|
||||||
if(!numFactor) numFactor=frameFactor-1;
|
if(!numFactor) numFactor=frameFactor-1;
|
||||||
//return if not
|
//return if not
|
||||||
else{
|
else{
|
||||||
numFactor--;
|
numFactor--;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Not Nth Frame, to check time out(NOT for Scans and angle plots)
|
//Not Nth Frame, to check time out(NOT for Scans and angle plots)
|
||||||
else{
|
else{
|
||||||
if (scanArgument == qDefs::None) {
|
if (scanArgument == qDefs::None) {
|
||||||
//if the time is not over, RETURN
|
//if the time is not over, RETURN
|
||||||
if(!data_pause_over){
|
if(!data_pause_over){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
data_pause_over=false;
|
data_pause_over=false;
|
||||||
data_pause_timer->start((int)(PLOT_TIMER_MS/2));
|
data_pause_timer->start((int)(PLOT_TIMER_MS/2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//if scan
|
//if scan
|
||||||
//alframes
|
//alframes
|
||||||
if(scanArgument==qDefs::AllFrames){
|
if(scanArgument==qDefs::AllFrames){
|
||||||
LockLastImageArray();
|
LockLastImageArray();
|
||||||
@ -964,10 +965,10 @@ int qDrawPlot::GetData(detectorData *data,int fIndex){
|
|||||||
|
|
||||||
//normal measurement or 1d scans
|
//normal measurement or 1d scans
|
||||||
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
|
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
|
||||||
//set title
|
//set title
|
||||||
plotTitle=QString(plotTitle_prefix)+QString(data->fileName).section('/',-1);
|
plotTitle=QString(plotTitle_prefix)+QString(data->fileName).section('/',-1);
|
||||||
// only if you got the lock, do u need to remember lastimagenumber to plot
|
// only if you got the lock, do u need to remember lastimagenumber to plot
|
||||||
lastImageNumber= currentFrame+1;
|
lastImageNumber= currentFrame+1;
|
||||||
|
|
||||||
//1d
|
//1d
|
||||||
if(plot_in_scope==1){
|
if(plot_in_scope==1){
|
||||||
@ -1051,7 +1052,7 @@ int qDrawPlot::GetData(detectorData *data,int fIndex){
|
|||||||
histYAxis[0][px] = temp;
|
histYAxis[0][px] = temp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//2d
|
//2d
|
||||||
else{
|
else{
|
||||||
@ -1135,9 +1136,9 @@ int qDrawPlot::AcquisitionFinished(double currentProgress, int detectorStatus){
|
|||||||
#endif
|
#endif
|
||||||
QString status = QString(slsDetectorBase::runStatusType(slsDetectorDefs::runStatus(detectorStatus)).c_str());
|
QString status = QString(slsDetectorBase::runStatusType(slsDetectorDefs::runStatus(detectorStatus)).c_str());
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << status.toAscii().constData() << " and progress " << currentProgress << endl;
|
cout << status.toAscii().constData() << " and progress " << currentProgress << endl;
|
||||||
#endif
|
#endif
|
||||||
//error or stopped
|
//error or stopped
|
||||||
if((stop_signal)||(detectorStatus==slsDetectorDefs::ERROR)){
|
if((stop_signal)||(detectorStatus==slsDetectorDefs::ERROR)){
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "Error in Acquisition" << endl << endl;
|
cout << "Error in Acquisition" << endl << endl;
|
||||||
@ -1325,8 +1326,9 @@ void qDrawPlot::UpdatePlot(){
|
|||||||
firstPlot = false;
|
firstPlot = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// update range if required
|
// update range if required
|
||||||
if(XYRangeChanged){
|
if(XYRangeChanged){
|
||||||
if(!IsXYRange[qDefs::XMINIMUM]) XYRangeValues[qDefs::XMINIMUM]= plot1D->GetXMinimum();
|
if(!IsXYRange[qDefs::XMINIMUM]) XYRangeValues[qDefs::XMINIMUM]= plot1D->GetXMinimum();
|
||||||
@ -1709,8 +1711,10 @@ int qDrawPlot::UpdateTrimbitPlot(bool fromDetector,bool Histogram){
|
|||||||
|
|
||||||
//get trimbits
|
//get trimbits
|
||||||
actualPixelsX = myDet->getTotalNumberOfChannels(slsDetectorDefs::X);
|
actualPixelsX = myDet->getTotalNumberOfChannels(slsDetectorDefs::X);
|
||||||
if(histTrimbits) delete [] histTrimbits; histTrimbits = new double[actualPixelsX];
|
if(histTrimbits) delete [] histTrimbits;
|
||||||
|
histTrimbits = new double[actualPixelsX];
|
||||||
ret = myDet->getChanRegs(histTrimbits,fromDetector);
|
ret = myDet->getChanRegs(histTrimbits,fromDetector);
|
||||||
|
// cout << "got it!" << endl;
|
||||||
if(!ret){
|
if(!ret){
|
||||||
qDefs::Message(qDefs::WARNING,"No Trimbit data found in shared memory.","qDrawPlot::UpdateTrimbitPlot");
|
qDefs::Message(qDefs::WARNING,"No Trimbit data found in shared memory.","qDrawPlot::UpdateTrimbitPlot");
|
||||||
UnlockLastImageArray();
|
UnlockLastImageArray();
|
||||||
|
@ -584,14 +584,15 @@ void qTabAdvanced::StartTrimming(){
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
cout << "Should never come here. Start Trimming will have only 2 methods. Trimming Method:" << trimmingMode << endl;
|
cout << "Should never come here. Start Trimming will have only 2 methods. Trimming Method:" << trimmingMode << endl;
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//execute
|
//execute
|
||||||
int ret = myDet->executeTrimming(trimmingMode,parameter1,parameter2,-1);
|
int ret = myDet->executeTrimming(trimmingMode,parameter1,parameter2,-1);
|
||||||
|
|
||||||
if((ret!=slsDetectorDefs::FAIL)&&(ret!=-1));
|
if((ret!=slsDetectorDefs::FAIL)&&(ret!=-1));
|
||||||
else
|
else
|
||||||
qDefs::Message(qDefs::WARNING,"Atleast 1 channel could not be trimmed.","qTabAdvanced::StartTrimming");
|
qDefs::Message(qDefs::WARNING,"Atleast 1 channel could not be trimmed.","qTabAdvanced::StartTrimming");
|
||||||
//save trim file
|
//save trim file
|
||||||
ret = myDet->saveSettingsFile(string(dispFile->text().toAscii().constData()),-1);
|
ret = myDet->saveSettingsFile(string(dispFile->text().toAscii().constData()),-1);
|
||||||
if((ret!=slsDetectorDefs::FAIL)&&(ret!=-1)){
|
if((ret!=slsDetectorDefs::FAIL)&&(ret!=-1)){
|
||||||
|
Reference in New Issue
Block a user