From e153c6fd58de6c27c31f9bc6d34e01cbc7e3a0cc Mon Sep 17 00:00:00 2001 From: l_maliakal_d Date: Wed, 8 May 2013 17:32:38 +0000 Subject: [PATCH] fixed zmin zmax bug, automatically online when refreshing advanced tab bug, outdir not checking properly git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@178 af1100a4-978c-4157-bff7-07162d2ba061 --- slsDetectorGui/include/qDrawPlot.h | 2 +- slsDetectorGui/include/qTabPlot.h | 2 +- .../include/SlsQt2DPlotLayout.h | 3 ++ .../src/SlsQt2DPlotLayout.cxx | 36 +++++++++++++++++-- slsDetectorGui/src/qDrawPlot.cpp | 2 +- slsDetectorGui/src/qTabAdvanced.cpp | 26 ++++++++++---- slsDetectorGui/src/qTabDataOutput.cpp | 16 +++++++-- slsDetectorGui/src/qTabPlot.cpp | 7 ++-- 8 files changed, 77 insertions(+), 17 deletions(-) diff --git a/slsDetectorGui/include/qDrawPlot.h b/slsDetectorGui/include/qDrawPlot.h index ebb9485c3..f590cf29a 100644 --- a/slsDetectorGui/include/qDrawPlot.h +++ b/slsDetectorGui/include/qDrawPlot.h @@ -506,7 +506,7 @@ void ContourSignal(bool); void LogzSignal(bool); void LogySignal(bool); void SetZRangeSignal(double,double); -void EnableZRangeSignal(bool); +void ResetZMinZMaxSignal(bool,bool,double,double); void SetCurrentMeasurementSignal(int); void saveErrorSignal(QString); void AcquisitionErrorSignal(QString); diff --git a/slsDetectorGui/include/qTabPlot.h b/slsDetectorGui/include/qTabPlot.h index 0705d0ec4..6d822cf15 100644 --- a/slsDetectorGui/include/qTabPlot.h +++ b/slsDetectorGui/include/qTabPlot.h @@ -151,7 +151,7 @@ private slots: signals: void DisableZoomSignal(bool); void SetZRangeSignal(double,double); - void EnableZRangeSignal(bool); + void ResetZMinZMaxSignal(bool,bool,double,double); }; diff --git a/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlotLayout.h b/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlotLayout.h index 5948b2fb3..2d2315f77 100644 --- a/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlotLayout.h +++ b/slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlotLayout.h @@ -5,6 +5,7 @@ * 19.06.2012 All modifications with the Ian flag has been made since * z_range_ne and the buttons are defined in another class. * Logz button and z_range_ne have wrappers to connect them + * 05.05.2013 Added ResetZMinZMax */ @@ -67,6 +68,8 @@ void ResetRange(); #ifndef IAN void SetZRange(double,double); void EnableZRange(bool enable); +void ResetZMinZMax(bool zmin, bool zmax, double min, double max); + #endif signals: diff --git a/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlotLayout.cxx b/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlotLayout.cxx index c27f46c9f..eb722b1cd 100644 --- a/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlotLayout.cxx +++ b/slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlotLayout.cxx @@ -99,12 +99,12 @@ void SlsQt2DPlotLayout::ConnectSignalsAndSlots(){ void SlsQt2DPlotLayout::UpdateNKeepSetRangeIfSet(){ #ifdef IAN if(z_range_ne->CheckBoxState()){ -#else - if(zRangeChecked){ #endif //just reset histogram range before update the_plot->SetZMinMax(z_range_ne->GetValue(0),z_range_ne->GetValue(1)); +#ifdef IAN } +#endif the_plot->Update(); } @@ -131,6 +131,37 @@ void SlsQt2DPlotLayout::ResetRange(){ } +void SlsQt2DPlotLayout::ResetZMinZMax(bool zmin, bool zmax, double min, double max){ + z_range_ne->SetNumber(min,0); + z_range_ne->SetNumber(max,1); + + //refind z limits + the_plot->SetZMinMax(); + if(btnLogz->isChecked()) the_plot->SetZMinimumToFirstGreaterThanZero(); + + //first time check validity + if(zmax) z_range_ne->SetValue(max,0); + else z_range_ne->SetValue(the_plot->GetZMaximum(),1); + + if(zmin) z_range_ne->SetValue(min,0); + else z_range_ne->SetValue(the_plot->GetZMinimum(),0); + + if(zmin && zmax){ + bool same = (z_range_ne->GetValue(0)==z_range_ne->GetValue(1)) ? 1:0; + if(!z_range_ne->IsValueOk(0)||same) z_range_ne->SetValue(the_plot->GetZMinimum(),0); + if(!z_range_ne->IsValueOk(1)||same) z_range_ne->SetValue(the_plot->GetZMaximum(),1); + } + + z_range_ne->SetRange(the_plot->GetZMinimum(),z_range_ne->GetValue(1),0); + z_range_ne->SetRange(z_range_ne->GetValue(0),the_plot->GetZMaximum(),1); + + //set histogram range + the_plot->SetZMinMax(z_range_ne->GetValue(0),z_range_ne->GetValue(1)); + + the_plot->Update(); +} + + void SlsQt2DPlotLayout::SetZScaleToLog(bool yes){ #ifndef IAN #ifdef VERBOSE @@ -190,5 +221,6 @@ void SlsQt2DPlotLayout::EnableZRange(bool enable){ #endif zRangeChecked = enable; ResetRange(); + } #endif diff --git a/slsDetectorGui/src/qDrawPlot.cpp b/slsDetectorGui/src/qDrawPlot.cpp index ab783fcea..91eed1436 100644 --- a/slsDetectorGui/src/qDrawPlot.cpp +++ b/slsDetectorGui/src/qDrawPlot.cpp @@ -278,7 +278,7 @@ void qDrawPlot::Initialization(){ connect(this, SIGNAL(ContourSignal(bool)), plot2D, SIGNAL(ContourSignal(bool))); connect(this, SIGNAL(LogzSignal(bool)), plot2D, SLOT(SetZScaleToLog(bool))); connect(this, SIGNAL(LogySignal(bool)), plot1D, SLOT(SetLogY(bool))); - connect(this, SIGNAL(EnableZRangeSignal(bool)),plot2D, SLOT(EnableZRange(bool))); + connect(this, SIGNAL(ResetZMinZMaxSignal(bool,bool,double,double)),plot2D, SLOT(ResetZMinZMax(bool,bool,double,double))); connect(this, SIGNAL(SetZRangeSignal(double,double)), plot2D, SLOT(SetZRange(double,double))); diff --git a/slsDetectorGui/src/qTabAdvanced.cpp b/slsDetectorGui/src/qTabAdvanced.cpp index 6819e7c16..741f493f2 100644 --- a/slsDetectorGui/src/qTabAdvanced.cpp +++ b/slsDetectorGui/src/qTabAdvanced.cpp @@ -140,8 +140,10 @@ void qTabAdvanced::SetupWidgetWindow(){ //check if its online and set it to red if offline - det->checkOnline(); - det->checkReceiverOnline(); + if(det->setOnline()==slsDetectorDefs::ONLINE_FLAG) + det->checkOnline(); + if(det->setReceiverOnline()==slsDetectorDefs::ONLINE_FLAG) + det->checkReceiverOnline(); comboOnline->setCurrentIndex(det->setOnline()); comboRxrOnline->setCurrentIndex(det->setReceiverOnline()); if(!comboOnline->currentIndex()){ @@ -571,7 +573,10 @@ void qTabAdvanced::SetReceiverOnline(int index){ cout << "Setting Reciever Online to :" << index << endl; #endif disconnect(comboRxrOnline, SIGNAL(currentIndexChanged(int)), this, SLOT(SetReceiverOnline(int))); - comboRxrOnline->setCurrentIndex(det->setReceiverOnline(index)); + if(index) + SetReceiver(); + else + comboRxrOnline->setCurrentIndex(det->setReceiverOnline(index)); qDefs::checkErrorMessage(det); connect(comboRxrOnline, SIGNAL(currentIndexChanged(int)), this, SLOT(SetReceiverOnline(int))); //highlight in red if offline @@ -648,8 +653,11 @@ void qTabAdvanced::SetReceiver(){ #ifdef VERBOSE cout << "Setting Receiver" << endl; #endif + string outdir = myDet->getFilePath(); dispRxrHostname->setText(QString(det->setReceiver(dispRxrHostname->text().toAscii().constData()))); qDefs::checkErrorMessage(det); + det->setFilePath(outdir); + qDefs::checkErrorMessage(det); Refresh(); } @@ -909,8 +917,10 @@ void qTabAdvanced::SetDetector(int index){ //check if its online and set it to red if offline - det->checkOnline(); - det->checkReceiverOnline(); + if(det->setOnline()==slsDetectorDefs::ONLINE_FLAG) + det->checkOnline(); + if(det->setReceiverOnline()==slsDetectorDefs::ONLINE_FLAG) + det->checkReceiverOnline(); comboOnline->setCurrentIndex(det->setOnline()); comboRxrOnline->setCurrentIndex(det->setReceiverOnline()); //highlight in red if detector or receiver is offline @@ -1026,7 +1036,8 @@ void qTabAdvanced::Refresh(){ disconnect(comboOnline, SIGNAL(currentIndexChanged(int)), this, SLOT(SetOnline(int))); //so that updated status - det->checkOnline(); + if(det->setOnline()==slsDetectorDefs::ONLINE_FLAG) + det->checkOnline(); comboOnline->setCurrentIndex(det->setOnline()); spinControlPort->setValue(det->getControlPort()); spinStopPort->setValue(det->getStopPort()); @@ -1053,7 +1064,8 @@ void qTabAdvanced::Refresh(){ dispMAC->setText(det->getDetectorMAC()); //so that updated status - det->checkReceiverOnline(); + if(det->setReceiverOnline()==slsDetectorDefs::ONLINE_FLAG) + det->checkReceiverOnline(); comboRxrOnline->setCurrentIndex(det->setReceiverOnline()); dispRxrHostname->setText(det->getReceiver()); diff --git a/slsDetectorGui/src/qTabDataOutput.cpp b/slsDetectorGui/src/qTabDataOutput.cpp index d9b16e699..097859ddd 100644 --- a/slsDetectorGui/src/qTabDataOutput.cpp +++ b/slsDetectorGui/src/qTabDataOutput.cpp @@ -166,6 +166,7 @@ void qTabDataOutput::setOutputDir(){ for(int i=0;igetNumberOfDetectors();i++){ slsDetector *det = myDet->getSlsDetector(i); qDefs::checkErrorMessage(myDet); + oldPath = det->getFilePath(); det->setFilePath(string(path.toAscii().constData())); qDefs::checkErrorMessage(det); if(det->getFilePath()!=(string(path.toAscii().constData()))){ @@ -187,9 +188,20 @@ void qTabDataOutput::setOutputDir(){ myDet->setFilePath(string(path.toAscii().constData())); } else { - myDet->setFilePath(string(path.toAscii().constData())); + for(int i=0;igetNumberOfDetectors();i++){ + slsDetector *det = myDet->getSlsDetector(i); + qDefs::checkErrorMessage(myDet); + det->setFilePath(string(path.toAscii().constData())); + qDefs::checkErrorMessage(det); + if(det->getFilePath()!=(string(path.toAscii().constData()))){ + error=true; + qDefs::checkErrorMessage(det); + break; + } + } + /* myDet->setFilePath(string(path.toAscii().constData())); if(myDet->getFilePath()!=(string(path.toAscii().constData()))) - error=true; + error=true;*/ } if(!error){ diff --git a/slsDetectorGui/src/qTabPlot.cpp b/slsDetectorGui/src/qTabPlot.cpp index d2c269b8a..507fd9f5a 100644 --- a/slsDetectorGui/src/qTabPlot.cpp +++ b/slsDetectorGui/src/qTabPlot.cpp @@ -261,7 +261,7 @@ void qTabPlot::Initialization(){ connect(chkYMax, SIGNAL(toggled(bool)), this, SLOT(EnableRange())); connect(chkZMin, SIGNAL(toggled(bool)), this, SLOT(EnableZRange())); connect(chkZMax, SIGNAL(toggled(bool)), this, SLOT(EnableZRange())); - connect(this, SIGNAL(EnableZRangeSignal(bool)), myPlot, SIGNAL(EnableZRangeSignal(bool))); + connect(this, SIGNAL(ResetZMinZMaxSignal(bool,bool,double,double)), myPlot, SIGNAL(ResetZMinZMaxSignal(bool,bool,double,double))); connect(dispXMin, SIGNAL(editingFinished()), this, SLOT(SetAxesRange())); connect(dispXMax, SIGNAL(editingFinished()), this, SLOT(SetAxesRange())); @@ -418,7 +418,8 @@ void qTabPlot::SetAxesRange(){ void qTabPlot::SetZRange(){ - emit SetZRangeSignal(dispZMin->text().toDouble(),dispZMax->text().toDouble()); +// emit SetZRangeSignal(dispZMin->text().toDouble(),dispZMax->text().toDouble()); + emit ResetZMinZMaxSignal(chkZMin->isChecked(),chkZMax->isChecked(),dispZMin->text().toDouble(),dispZMax->text().toDouble()); } @@ -428,7 +429,7 @@ void qTabPlot::SetZRange(){ void qTabPlot::EnableZRange(){ dispZMin->setEnabled(chkZMin->isChecked()); dispZMax->setEnabled(chkZMax->isChecked()); - emit EnableZRangeSignal((chkZMin->isChecked())||(chkZMax->isChecked())); + emit ResetZMinZMaxSignal(chkZMin->isChecked(),chkZMax->isChecked(),dispZMin->text().toDouble(),dispZMax->text().toDouble()); }