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
This commit is contained in:
l_maliakal_d 2013-04-10 13:34:52 +00:00
parent d56b2b480b
commit 050bec703d
16 changed files with 121 additions and 42 deletions

View File

@ -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;

View File

@ -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 */

View File

@ -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();

View File

@ -14,7 +14,7 @@
/** Project Class Headers */
class multiSlsDetector;
class qDetectorMain;
/** Qt Include Headers */
#include <QWidget>
#include <QTextEdit>
@ -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;

View File

@ -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

View File

@ -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"<<endl;
tab_messages = new qTabMessages (this); cout<<"Messages ready"<<endl;
//loads the config file at startup
if(!fName.empty()) LoadConfigFile(fName);

View File

@ -31,7 +31,7 @@ using namespace std;
qDrawPlot::qDrawPlot(QWidget *parent,multiSlsDetector*& detector):
QWidget(parent),myDet(detector){
QWidget(parent),myDet(detector),plot1D_hists(0){
SetupWidgetWindow();
Initialization();
StartStopDaqToggle(); //as default
@ -406,6 +406,10 @@ bool qDrawPlot::StartOrStopThread(bool start){
//sets up the measurement parameters
SetupMeasurement();
//refixing all the min and max for 2ds if zoomed in
if (scanArgument != None)
plot2D->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:"<<nPixelsX<<endl;
cout<<"nPixelsY:"<<nPixelsY<<endl;
cout<<"minPixelsY:"<<minPixelsY<<endl;
cout<<"maxPixelsY:"<<maxPixelsY<<endl;
cout<<"startPixel:"<<startPixel<<endl;
cout<<"endPixel:"<<endPixel<<endl<<endl;
*/
UnlockLastImageArray();
}
@ -599,6 +604,11 @@ int qDrawPlot::GetData(detectorData *data,int fIndex){
//set progress
progress=(int)data->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:"<<plot2D->GetPlot()->GetYMinimum()<< "\tymax:"<<plot2D->GetPlot()->GetYMaximum()<<endl;
}
}
//}
@ -1540,4 +1551,16 @@ void qDrawPlot::CalculatePedestal(){
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qDrawPlot::plot2DUnzoom(){
plot2D->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();
}
//-------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -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();

View File

@ -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();
}

View File

@ -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<NumTotalActions;i++){
btnExpand[i]=0;
lblName[i]=0;
}
SetupWidgetWindow();
Initialization();
}

View File

@ -20,7 +20,16 @@ using namespace std;
qTabAdvanced::qTabAdvanced(QWidget *parent,multiSlsDetector*& detector, qDrawPlot*& plot):
QWidget(parent),myDet(detector),myPlot(plot),btnGroup(NULL),isEnergy(false),isAngular(false){
QWidget(parent),myDet(detector),det(0),myPlot(plot),btnGroup(NULL),isEnergy(false),isAngular(false),
lblFromX(0),
spinFromX(0),
lblFromY(0),
spinFromY(0),
lblToX(0),
spinToX(0),
lblToY(0),
spinToY(0),
numRois(0){
setupUi(this);
SetupWidgetWindow();
}
@ -32,6 +41,7 @@ qTabAdvanced::qTabAdvanced(QWidget *parent,multiSlsDetector*& detector, qDrawPlo
qTabAdvanced::~qTabAdvanced(){
delete myDet;
if(det) delete det;
}

View File

@ -21,7 +21,18 @@ using namespace std;
qTabDebugging::qTabDebugging(QWidget *parent,multiSlsDetector*& detector):
QWidget(parent),myDet(detector),treeDet(NULL){
QWidget(parent),
myDet(detector),
det(0),
treeDet(0),
dispFrame(0),
lblDetectorId(0),
lblDetectorSerial(0),
lblDetectorFirmware(0),
lblDetectorSoftware(0),
lblModuleId(0),
lblModuleFirmware(0),
lblModuleSerial(0){
setupUi(this);
SetupWidgetWindow();
Initialization();
@ -33,6 +44,7 @@ qTabDebugging::qTabDebugging(QWidget *parent,multiSlsDetector*& detector):
qTabDebugging::~qTabDebugging(){
delete myDet;
if(det) delete det;
}

View File

@ -24,10 +24,23 @@ int qTabDeveloper::NUM_ADC_WIDGETS(0);
//-------------------------------------------------------------------------------------------------------------------------------------------------
qTabDeveloper::qTabDeveloper(QWidget *parent,multiSlsDetector*& detector):QWidget(parent),myDet(detector){
qTabDeveloper::qTabDeveloper(QWidget *parent,multiSlsDetector*& detector):
QWidget(parent),
myDet(detector),
boxDacs(0),
boxAdcs(0),
lblHV(0),
comboHV(0),
adcTimer(0),
dacLayout(0){
for(int i=0;i<20;i++){
lblDacs[i]=0;
lblAdcs[i]=0;
spinDacs[i]=0;
spinAdcs[i]=0;
}
SetupWidgetWindow();
Initialization();
}

View File

@ -7,9 +7,8 @@
/** Qt Project Class Headers */
#include "qTabMessages.h"
#include "qDetectorMain.h"
/** Project Class Headers */
#include "slsDetector.h"
#include "multiSlsDetector.h"
/** Qt Include Headers */
#include <QGridLayout>
#include <QFile>
@ -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<<endl<<"ERRRORRRR"<<endl<<endl;
QString fName = QString(myDet->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);
}

View File

@ -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();

View File

@ -19,6 +19,8 @@ using namespace std;
qTabSettings::qTabSettings(QWidget *parent,multiSlsDetector*& detector):
QWidget(parent),myDet(detector),expertMode(false){
for(int i=0;i<NumSettings;i++)
item[i]=0;
setupUi(this);
SetupWidgetWindow();
Initialization();