From 050bec703d21c257ab2ac3770bb7018ed7ac2087 Mon Sep 17 00:00:00 2001 From: l_maliakal_d Date: Wed, 10 Apr 2013 13:34:52 +0000 Subject: [PATCH] defining everything to reduce null pointer errors, fixed zooming problem for scans git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@171 af1100a4-978c-4157-bff7-07162d2ba061 --- slsDetectorGui/include/qCloneWidget.h | 9 -------- slsDetectorGui/include/qDetectorMain.h | 2 ++ slsDetectorGui/include/qDrawPlot.h | 3 +++ slsDetectorGui/include/qTabMessages.h | 11 +++++----- slsDetectorGui/src/qCloneWidget.cpp | 6 +----- slsDetectorGui/src/qDetectorMain.cpp | 6 +++--- slsDetectorGui/src/qDrawPlot.cpp | 29 +++++++++++++++++++++++--- slsDetectorGui/src/qScanWidget.cpp | 1 + slsDetectorGui/src/qServer.cpp | 4 ++-- slsDetectorGui/src/qTabActions.cpp | 22 ++++++++++++++++++- slsDetectorGui/src/qTabAdvanced.cpp | 12 ++++++++++- slsDetectorGui/src/qTabDebugging.cpp | 14 ++++++++++++- slsDetectorGui/src/qTabDeveloper.cpp | 17 +++++++++++++-- slsDetectorGui/src/qTabMessages.cpp | 12 ++++------- slsDetectorGui/src/qTabPlot.cpp | 13 +++++++++++- slsDetectorGui/src/qTabSettings.cpp | 2 ++ 16 files changed, 121 insertions(+), 42 deletions(-) diff --git a/slsDetectorGui/include/qCloneWidget.h b/slsDetectorGui/include/qCloneWidget.h index d83f38e0f..65ae2e550 100644 --- a/slsDetectorGui/include/qCloneWidget.h +++ b/slsDetectorGui/include/qCloneWidget.h @@ -119,15 +119,6 @@ private: QGridLayout *mainLayout; QGroupBox *cloneBox; QGridLayout *gridClone; - QGroupBox *boxSave; - QHBoxLayout *layoutSave; - QLabel *lblFName; - QHBoxLayout *hLayoutSave; - QLineEdit *dispFName; - QComboBox *comboFormat; - QPushButton *btnSave; - QCheckBox *chkAutoFName; - QCheckBox *chkSaveAll; QLabel *lblHistTitle; diff --git a/slsDetectorGui/include/qDetectorMain.h b/slsDetectorGui/include/qDetectorMain.h index 751aaec47..9d9848f7d 100644 --- a/slsDetectorGui/include/qDetectorMain.h +++ b/slsDetectorGui/include/qDetectorMain.h @@ -77,6 +77,8 @@ public: /** Returns progress bar value */ int GetProgress(){return tab_measurement->GetProgress();}; + /** Returns file path */ + QString GetFilePath(){QString s = QString(myDet->getFilePath().c_str());qDefs::checkErrorMessage(myDet); return s;}; private: /** The Qt Application */ diff --git a/slsDetectorGui/include/qDrawPlot.h b/slsDetectorGui/include/qDrawPlot.h index e1ac9536b..1f3b8ad61 100644 --- a/slsDetectorGui/include/qDrawPlot.h +++ b/slsDetectorGui/include/qDrawPlot.h @@ -125,6 +125,8 @@ public: * and this is reset when the gui really starts/stops- to know when to return */ bool GetClientInitiated(){return clientInitiated;}; + /** Unzoom plot 2d as it will affect scans */ + void plot2DUnzoom(); public slots: /** To select 1D or 2D plot @@ -157,6 +159,7 @@ void SetScanArgument(int scanArg); /** sets stop_signal to true */ void StopAcquisition(){ stop_signal = true; }; + //pedestal /** reset pedestal */ void ResetPedestal(); diff --git a/slsDetectorGui/include/qTabMessages.h b/slsDetectorGui/include/qTabMessages.h index 6524f2a52..8dd7f611b 100644 --- a/slsDetectorGui/include/qTabMessages.h +++ b/slsDetectorGui/include/qTabMessages.h @@ -14,7 +14,7 @@ /** Project Class Headers */ -class multiSlsDetector; +class qDetectorMain; /** Qt Include Headers */ #include #include @@ -30,10 +30,9 @@ class qTabMessages:public QWidget{ public: /** \short The constructor - * @param parent is the parent tab widget - * @param det the detector reference + * @param det the qDetectorMain class reference */ - qTabMessages(QWidget *parent,multiSlsDetector* detector); + qTabMessages(qDetectorMain* m); /** Destructor */ @@ -41,8 +40,8 @@ public: private: - /** The sls detector object */ - multiSlsDetector *myDet; + /** The qDetectorMain object */ + qDetectorMain *myMainTab; /** Log of executed commands */ QTextEdit *dispLog; diff --git a/slsDetectorGui/src/qCloneWidget.cpp b/slsDetectorGui/src/qCloneWidget.cpp index 0b4110168..736b6052b 100644 --- a/slsDetectorGui/src/qCloneWidget.cpp +++ b/slsDetectorGui/src/qCloneWidget.cpp @@ -19,7 +19,7 @@ //------------------------------------------------------------------------------------------------------------------------------------------------- qCloneWidget::qCloneWidget(QWidget *parent,int id,QString title,int numDim,SlsQt1DPlot*& plot1D,SlsQt2DPlotLayout*& plot2D,string FilePath): - QMainWindow(parent),id(id),filePath(FilePath){ + QMainWindow(parent),id(id),cloneplot2D(0),cloneplot1D(0),filePath(FilePath){ /** Window title*/ char winTitle[300],currTime[50]; strcpy(currTime,GetCurrentTimeStamp()); @@ -36,7 +36,6 @@ qCloneWidget::~qCloneWidget(){ delete cloneplot1D; delete cloneplot2D; delete cloneBox; - delete boxSave; } //------------------------------------------------------------------------------------------------------------------------------------------------- @@ -82,13 +81,11 @@ void qCloneWidget::SetupWidgetWindow(QString title,int numDim,SlsQt1DPlot*& plot } /** main window widgets */ - //mainLayout->addWidget(boxSave,0,0); mainLayout->addWidget(cloneBox,1,0); setCentralWidget(centralWidget); /** Save */ connect(actionSave,SIGNAL(triggered()),this,SLOT(SavePlot())); - //connect(btnSave, SIGNAL(clicked()), this, SLOT(SavePlot())); setMinimumHeight(300); resize(500,350); @@ -218,7 +215,6 @@ char* qCloneWidget::GetCurrentTimeStamp(){ //------------------------------------------------------------------------------------------------------------------------------------------------- void qCloneWidget::SavePlot(){ - //QString fName = QString(filePath.c_str())+'/'+dispFName->text()+comboFormat->currentText(); char cID[10]; sprintf(cID,"%d",id); //title diff --git a/slsDetectorGui/src/qDetectorMain.cpp b/slsDetectorGui/src/qDetectorMain.cpp index c293bf83e..d22eaaacb 100644 --- a/slsDetectorGui/src/qDetectorMain.cpp +++ b/slsDetectorGui/src/qDetectorMain.cpp @@ -47,7 +47,7 @@ int main (int argc, char **argv) { qDetectorMain::qDetectorMain(int argc, char **argv, QApplication *app, QWidget *parent) : - QMainWindow(parent), theApp(app),myDet(0),detID(0),myPlot(NULL),tabs(NULL),isDeveloper(0){ + QMainWindow(parent), theApp(app),myDet(0),detID(0),myPlot(0),tabs(0),isDeveloper(0){ string configFName = ""; // Getting all the command line arguments @@ -77,7 +77,7 @@ qDetectorMain::qDetectorMain(int argc, char **argv, QApplication *app, QWidget * qDetectorMain::~qDetectorMain(){ - delete myDet; + if(myDet) delete myDet; if (menubar) delete menubar; if (centralwidget) delete centralwidget; } @@ -194,7 +194,7 @@ void qDetectorMain::SetUpDetector(const string fName){ myDet = new multiSlsDetector(detID); //create messages tab to capture config file loading logs - tab_messages = new qTabMessages (this,myDet); cout<<"Messages ready"<GetPlot()->SetZoom(-0.5,startPixel,nPixelsX,endPixel-startPixel); + cout << "Starting new acquisition threadddd ...." << endl; // Start acquiring data from server @@ -434,6 +438,7 @@ void qDrawPlot::SetScanArgument(int scanArg){ if(plot_in_scope==1) Clear1DPlot(); + LockLastImageArray(); @@ -557,14 +562,14 @@ void qDrawPlot::SetupMeasurement(){ endPixel = maxPixelsY + (pixelWidth/2); } } -/* + cout<<"nPixelsX:"<progressIndex; currentFrameIndex = fileIOStatic::getIndicesFromFileName(string(data->fileName),currentFileIndex); + //happens if receiver sends a null and empty file name + if(string(data->fileName).empty()){ + cout << "Received empty file name. Exiting function without updating data for plot." << endl; + return -1; + } #ifdef VERYVERBOSE cout << "progress:" << progress << endl; #endif @@ -1075,6 +1085,7 @@ void qDrawPlot::UpdatePlot(){ XYRangeChanged = false; } if(saveAll) SavePlotAutomatic(); + cout<<"updated 2d plot: ymin:"<GetPlot()->GetYMinimum()<< "\tymax:"<GetPlot()->GetYMaximum()<GetPlot()->SetXMinMax(plot2D->GetPlot()->GetXMinimum(),plot2D->GetPlot()->GetXMaximum()); + plot2D->GetPlot()->SetYMinMax(plot2D->GetPlot()->GetYMinimum(),plot2D->GetPlot()->GetYMaximum()); + + //if(scanArgument!=None)/*if(plot_in_scope==2)*/ + // plot2D->GetPlot()->UnZoom(); +} + + //------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/slsDetectorGui/src/qScanWidget.cpp b/slsDetectorGui/src/qScanWidget.cpp index 7e307625c..48f281a2c 100644 --- a/slsDetectorGui/src/qScanWidget.cpp +++ b/slsDetectorGui/src/qScanWidget.cpp @@ -31,6 +31,7 @@ const string qScanWidget::modeNames[NumModes]={"","energy","threshold","trimbits qScanWidget::qScanWidget(QWidget *parent,multiSlsDetector*& detector): QWidget(parent),myDet(detector),actualNumSteps(0){ setupUi(this); + positions.resize(0); SetupWidgetWindow(); Initialization(); LoadPositions(); diff --git a/slsDetectorGui/src/qServer.cpp b/slsDetectorGui/src/qServer.cpp index 5a25e686d..47fd52ffb 100644 --- a/slsDetectorGui/src/qServer.cpp +++ b/slsDetectorGui/src/qServer.cpp @@ -27,8 +27,8 @@ int qServer::gui_server_thread_running(0); qServer::qServer(qDetectorMain *t): - myMainTab(t), mySocket(NULL),myStopSocket(NULL),port_no(DEFAULT_GUI_PORTNO),lockStatus(0){ - + myMainTab(t), mySocket(NULL),myStopSocket(NULL),port_no(DEFAULT_GUI_PORTNO),lockStatus(0),checkStarted(0),checkStopStarted(0){ + strcpy(mess,""); FunctionTable(); } diff --git a/slsDetectorGui/src/qTabActions.cpp b/slsDetectorGui/src/qTabActions.cpp index 0a6772c89..ff0553f31 100644 --- a/slsDetectorGui/src/qTabActions.cpp +++ b/slsDetectorGui/src/qTabActions.cpp @@ -20,7 +20,27 @@ using namespace std; qTabActions::qTabActions(QWidget *parent,multiSlsDetector*& detector): - QWidget(parent),myDet(detector),positions(NULL){ + QWidget(parent),myDet(detector), + positionWidget(0), + lblNumPos(0), + lblPosList(0), + spinNumPos(0), + comboPos(0), + btnDelete(0), + chkInvert(0), + chkSeparate(0), + chkReturn(0), + positions(0), + iconPlus(0), + iconMinus(0){ + for(int i=0;i<6;i++) + actionWidget[i]=0; + for(int i=0;i<2;i++) + scanWidget[i]=0; + for(int i=0;i #include @@ -24,8 +23,7 @@ using namespace std; //------------------------------------------------------------------------------------------------------------------------------------------------- -qTabMessages::qTabMessages(QWidget *parent,multiSlsDetector* detector):QWidget(parent),qout(0),qerr(0){//myDet(detector), - myDet=detector; +qTabMessages::qTabMessages(qDetectorMain* m):myMainTab(m),qout(0),qerr(0){ SetupWidgetWindow(); Initialization(); } @@ -33,7 +31,7 @@ qTabMessages::qTabMessages(QWidget *parent,multiSlsDetector* detector):QWidget(p //------------------------------------------------------------------------------------------------------------------------------------------------- qTabMessages::~qTabMessages(){ - // delete myDet; + delete myMainTab; delete dispLog; delete qout; delete qerr; @@ -94,7 +92,7 @@ void qTabMessages::customEvent(QEvent *e) { void qTabMessages::SaveLog() { //cerr<getFilePath().c_str()); + QString fName = QString(myMainTab->GetFilePath()); fName = fName+"/LogFile.txt"; fName = QFileDialog::getSaveFileName(this,tr("Save Snapshot "), fName,tr("Text files (*.txt)")); @@ -109,8 +107,6 @@ void qTabMessages::SaveLog() { } else qDefs::Message(qDefs::WARNING,"Attempt to save log file failed.","Messages"); } - - qDefs::checkErrorMessage(myDet); } diff --git a/slsDetectorGui/src/qTabPlot.cpp b/slsDetectorGui/src/qTabPlot.cpp index 2b5a19c43..fc7d7a9d5 100644 --- a/slsDetectorGui/src/qTabPlot.cpp +++ b/slsDetectorGui/src/qTabPlot.cpp @@ -33,7 +33,18 @@ QString qTabPlot::defaultImageZAxisTitle("Intensity"); //------------------------------------------------------------------------------------------------------------------------------------------------- -qTabPlot::qTabPlot(QWidget *parent,multiSlsDetector*& detector, qDrawPlot*& plot):QWidget(parent),myDet(detector),myPlot(plot){ +qTabPlot::qTabPlot(QWidget *parent,multiSlsDetector*& detector, qDrawPlot*& plot): + QWidget(parent), + myDet(detector), + myPlot(plot), + isOneD(false), + isOriginallyOneD(false), + wrongInterval(0), + stackedLayout(0), + spinNthFrame(0), + spinTimeGap(0), + comboTimeGapUnit(0), + btnGroupScan(0){ setupUi(this); SetupWidgetWindow(); Initialization(); diff --git a/slsDetectorGui/src/qTabSettings.cpp b/slsDetectorGui/src/qTabSettings.cpp index 67672e097..4047daf0b 100644 --- a/slsDetectorGui/src/qTabSettings.cpp +++ b/slsDetectorGui/src/qTabSettings.cpp @@ -19,6 +19,8 @@ using namespace std; qTabSettings::qTabSettings(QWidget *parent,multiSlsDetector*& detector): QWidget(parent),myDet(detector),expertMode(false){ + for(int i=0;i