diff --git a/slsDetectorGui/forms/form_detectormain.ui b/slsDetectorGui/forms/form_detectormain.ui index 7ded9699e..0f2049a6b 100644 --- a/slsDetectorGui/forms/form_detectormain.ui +++ b/slsDetectorGui/forms/form_detectormain.ui @@ -159,43 +159,6 @@ 524287 - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 0 - 0 - - - - - - - - - 119 - 119 - 119 - - - - - - Sans Serif @@ -220,6 +183,9 @@ p, li { white-space: pre-wrap; } + + Qt::LeftToRight + QDockWidget::NoDockWidgetFeatures diff --git a/slsDetectorGui/forms/form_tab_plot.ui b/slsDetectorGui/forms/form_tab_plot.ui index 9fc9064d3..fdd0b5018 100644 --- a/slsDetectorGui/forms/form_tab_plot.ui +++ b/slsDetectorGui/forms/form_tab_plot.ui @@ -411,9 +411,9 @@ - 315 + 430 70 - 446 + 331 51 @@ -431,7 +431,7 @@ 10 20 - 496 + 321 22 @@ -449,7 +449,7 @@ - + @@ -462,7 +462,7 @@ - + @@ -475,8 +475,8 @@ - - + + Qt::Horizontal @@ -485,7 +485,23 @@ - 180 + 10 + 20 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 20 @@ -497,9 +513,9 @@ - 315 - 10 - 446 + 10 + 70 + 391 51 @@ -517,13 +533,19 @@ 10 20 - 254 + 376 21 + + + 0 + 0 + + Superimpose @@ -532,16 +554,6 @@ - - - - false - - - Persistency: - - - @@ -558,77 +570,111 @@ - - - - false - + + - + 0 0 - - - 60 - 16777215 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1 - - - 10 - - - 1 + + Line + + + + + 0 + 0 + + + + Points + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 10 + + + + + + + + 1 + + + + + false + + + + 0 + 0 + + + + Persistency: + + + + + + + false + + + + 0 + 0 + + + + + 40 + 16777215 + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + 1 + + + 10 + + + 1 + + + + + - - - - 395 - 15 - 40 - 28 - - - - - 0 - 0 - - - - - 40 - 16777215 - - - - Qt::NoFocus - - - Clear - - - true - - 10 135 - 751 + 391 51 @@ -646,69 +692,11 @@ 10 15 - 741 + 382 31 - - - - - 0 - 0 - - - - File Name: - - - - - - - 0 - - - - - - 0 - 0 - - - - - 250 - 0 - - - - - - - - true - - - - .png - - - - - .jpg - - - - - .xpm - - - - - - @@ -748,6 +736,22 @@ + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + @@ -758,15 +762,15 @@ - + true - 10 - 70 - 261 + 430 + 135 + 331 51 @@ -782,10 +786,10 @@ - 5 - 21 - 251 - 21 + 10 + 15 + 311 + 31 @@ -804,11 +808,11 @@ Create - true + false - + @@ -823,11 +827,11 @@ Close All - true + false - + @@ -842,10 +846,42 @@ Save All - true + false + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 30 + 20 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 30 + 20 + + + + @@ -857,7 +893,7 @@ 10 10 - 261 + 391 51 @@ -875,32 +911,222 @@ 10 20 - 246 - 21 + 381 + 23 - + + + + 0 + 0 + + - None + No Plot - - + + + + + 0 + 0 + + Data Graph + + true + - + + + + 0 + 0 + + Histogram + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 50 + 10 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 50 + 10 + + + + + + + + + + + 430 + 10 + 331 + 51 + + + + Scan - Y Axis Values + + + true + + + false + + + + + 11 + 20 + 316 + 23 + + + + + 0 + + + + + + 0 + 0 + + + + Level 0 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 5 + 10 + + + + + + + + + 0 + 0 + + + + Level 1 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 5 + 10 + + + + + + + + + 0 + 0 + + + + File Index + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 5 + 10 + + + + + + + + + 0 + 0 + + + + All Frames + + + true + + + diff --git a/slsDetectorGui/forms/form_tab_settings.ui b/slsDetectorGui/forms/form_tab_settings.ui index 89d6214fe..f7184ebdd 100644 --- a/slsDetectorGui/forms/form_tab_settings.ui +++ b/slsDetectorGui/forms/form_tab_settings.ui @@ -139,7 +139,18 @@ - + + + + 16 + + + + + 32 + + + diff --git a/slsDetectorGui/include/qActionsWidget.h b/slsDetectorGui/include/qActionsWidget.h index edb4fdc08..501a1a5ff 100644 --- a/slsDetectorGui/include/qActionsWidget.h +++ b/slsDetectorGui/include/qActionsWidget.h @@ -72,9 +72,6 @@ void SetScript(int index); * Options: constant size,specific values,values from file */ void EnableSizeWidgets(); - - -protected: }; diff --git a/slsDetectorGui/include/qDebugStream.h b/slsDetectorGui/include/qDebugStream.h new file mode 100644 index 000000000..bb4607691 --- /dev/null +++ b/slsDetectorGui/include/qDebugStream.h @@ -0,0 +1,113 @@ +/* + * qDebugStream.h + * + * Created on: Jun 28, 2012 + * Author: Anna Bergamaschi + */ + +#ifndef QDEBUGSTREAM_H_ +#define QDEBUGSTREAM_H_ + + +#include +#include +#include +#include +#include + +#include +#include +#include +using namespace std; + +#define STREAMEVENT 60001 + + +//------------------------------------------------------------------------------------------------------------------------------------------------- + +class qStreamEvent:public QEvent{ +public: + qStreamEvent(QString s):QEvent(static_cast(STREAMEVENT)) {str=s;}; + /** \returns the progress index */ + QString getString() {return str;}; +private: + QString str; + +}; + +//------------------------------------------------------------------------------------------------------------------------------------------------- + +class qDebugStream : public basic_streambuf { + +public: + qDebugStream(ostream &stream, QWidget* w) : m_stream(stream), log_window(w) { + m_old_buf = stream.rdbuf(); + stream.rdbuf(this); + }; + +//------------------------------------------------------------------------------------------------------------------------------------------------- + + ~qDebugStream(){ + // output anything that is left + if (!m_string.empty()) { + qStreamEvent *ce=new qStreamEvent(m_string.c_str()); + QApplication::postEvent(log_window, ce); +#ifdef VERBOSE + cerr << m_string << endl; +#endif + } + m_stream.rdbuf(m_old_buf); + } + +//------------------------------------------------------------------------------------------------------------------------------------------------- + +protected: + virtual int_type overflow(int_type v){ + if (v == '\n'){ + qStreamEvent *ce=new qStreamEvent(m_string.c_str()); + QApplication::postEvent(log_window, ce); +#ifdef VERBOSE + cerr << m_string << endl; +#endif + m_string.erase(m_string.begin(), m_string.end()); + } + else + m_string += v; + return v; + } + +//------------------------------------------------------------------------------------------------------------------------------------------------- + + virtual streamsize xsputn(const char *p, streamsize n) { + m_string.append(p, p + n); + uint pos = 0; + + while (pos != string::npos) + { + pos = m_string.find('\n'); + if (pos != string::npos) + { + string tmp(m_string.begin(), m_string.begin() + pos); + qStreamEvent *ce=new qStreamEvent(tmp.c_str()); + QApplication::postEvent(log_window, ce); +#ifdef VERBOSE + cerr << tmp << endl; +#endif + m_string.erase(m_string.begin(), m_string.begin() + pos + 1); + } + } + return n; + } + +//------------------------------------------------------------------------------------------------------------------------------------------------- + +private: + ostream &m_stream; + streambuf *m_old_buf; + string m_string; + QWidget* log_window; +}; + +//------------------------------------------------------------------------------------------------------------------------------------------------- + +#endif /* QDEBUGSTREAM_H_ */ diff --git a/slsDetectorGui/include/qDefs.h b/slsDetectorGui/include/qDefs.h index f75af62a2..5167465a4 100644 --- a/slsDetectorGui/include/qDefs.h +++ b/slsDetectorGui/include/qDefs.h @@ -35,7 +35,24 @@ public: //------------------------------------------------------------------------------------------------------------------------------------------------- - /** returns the value in ns to send to server. + /** returns the unit in words + * @param unit is the time unit + */ + static string getUnitString(timeUnit unit){ + switch(unit){ + case HOURS: return string("hrs"); + case MINUTES: return string("min"); + case SECONDS: return string("sec"); + case MILLISECONDS: return string("msec"); + case MICROSECONDS: return string("usec"); + case NANOSECONDS: return string("nsec"); + default: return string("error"); + } + }; +//------------------------------------------------------------------------------------------------------------------------------------------------- + + /** returns the value in ns to send to server as the + * server class slsdetector accepts in ns. * @param unit unit of time * @param value time * returns time value in ns @@ -95,9 +112,22 @@ public: * @param source is the tab or the source of the error * */ static void ErrorMessage(string errorMessage,char source[]) + { + static QMessageBox* errorBox; + errorBox= new QMessageBox(QMessageBox::Warning,source,tr(errorMessage.c_str()),QMessageBox::Ok, errorBox); + errorBox->exec(); + } + +//------------------------------------------------------------------------------------------------------------------------------------------------- + + /**displays an information message + * @param infoMessage the message to be displayed + * @param source is the tab or the source of the information + * */ + static void InfoMessage(string infoMessage,char source[]) { static QMessageBox* msgBox; - msgBox= new QMessageBox(QMessageBox::Warning,source,tr(errorMessage.c_str()),QMessageBox::Ok, msgBox); + msgBox= new QMessageBox(QMessageBox::Information,source,tr(infoMessage.c_str()),QMessageBox::Ok, msgBox); msgBox->exec(); } diff --git a/slsDetectorGui/include/qDetectorMain.h b/slsDetectorGui/include/qDetectorMain.h index ed1307d7a..b1807f2b4 100644 --- a/slsDetectorGui/include/qDetectorMain.h +++ b/slsDetectorGui/include/qDetectorMain.h @@ -52,10 +52,11 @@ public: * @param argv server options * @param app the qapplication * @param parent makes the parent window 0 by default - */ + * */ qDetectorMain(int argc, char **argv, QApplication *app, QWidget *parent = 0); - /**Destructor */ + /**Destructor + * */ ~qDetectorMain(); private: @@ -103,88 +104,55 @@ private: /**Messages tab */ qTabMessages *tab_messages; /**if the developer tab should be enabled,known from command line */ - int isDeveloper; + + /**Sets up the layout of the widget - */ + * */ void SetUpWidgetWindow(); /**Sets up detector - */ + * */ void SetUpDetector(); /**Sets up the signals and the slots - */ + * */ void Initialization(); - /** Sets/unsets the developer mode (developer tab) - * @param b bool TRUE sets, FALSE unsets\ - */ - void SetDeveloperMode(bool b); private slots: -/** Sets/unsets the debug mode i.e. enables/disables the debug tab - * @param b bool TRUE sets, FALSE unsets - */ -void SetDebugMode(bool b); +/** Enables modes as selected -Debug, Beamline, Expert, Dockable(calls setdockablemode()) + * */ +void EnableModes(QAction *action); -/** Sets/unsets the beamline mode (at the moment it doesn't do anything) - * @param b bool TRUE sets, FALSE unsets - */ -void SetBeamlineMode(bool b); +/** Executes actions in the utilities menu as selected + * */ +void ExecuteUtilities(QAction *action); -/** Sets/unsets the expert mode i.e. enables/disables the advanced and Settings tabs - * @param b bool TRUE sets, FALSE unsets - */ -void SetExpertMode(bool b); +/** Executes actions in the utilities menu as selected + * */ +void ExecuteHelp(QAction *action); -/** Sets/unsets the dockable plot mode - * @param b bool TRUE sets, FALSE unsets - */ -void SetDockableMode(bool b); - -/** Refreshes the tab each time the tab is changed. Also displays the next enabled tab */ -void refresh(int index); - -/** Opens Setup */ -void OpenSetup(); - -/** Saves Setup */ -void SaveSetup(); - -/** Measurement Wizard */ -void MeasurementWizard(); - -/** Open Configuration*/ -void OpenConfiguration(); - -/** Save Configuration */ -void SaveConfiguration(); - -/** Executing Energy Calibration */ -void EnergyCalibration(); - -/** Executing Angular Calibration */ -void AngularCalibration(); - -/** Executing Version */ -void Version(); - -/** Executing About */ -void About(); +/** Refreshes the tab each time the tab is changed. Also displays the next enabled tab + * */ +void Refresh(int index); /** Resizes the main window if the plot is docked/undocked * @param b bool TRUE if undocked(outside main window), FALSE docked - */ + * */ void ResizeMainWindow(bool b); -/** Enables/disables tabs depending on if acquisition is currently in progress */ +/** Enables/disables tabs depending on if acquisition is currently in progress + * */ void EnableTabs(); -/** Set the tool tip of mouse controlled zooming depening on if its enabled/disabled*/ +/** Set the tool tip of mouse controlled zooming depening on if its enabled/disabled + * */ void SetZoomToolTip(bool disable); protected: +/** Adjust the resizing to resize plot, except for actions tab + * */ void resizeEvent(QResizeEvent* event); signals: diff --git a/slsDetectorGui/include/qDrawPlot.h b/slsDetectorGui/include/qDrawPlot.h index 57bfe31b6..7dccad63c 100644 --- a/slsDetectorGui/include/qDrawPlot.h +++ b/slsDetectorGui/include/qDrawPlot.h @@ -40,6 +40,8 @@ public: /** Destructor */ ~qDrawPlot(); + bool isRunning(){return running;}; + /** Number of x axis pixels */ int GetPixelsX(){return nPixelsX;}; /** Number of y axis pixels */ @@ -72,7 +74,10 @@ public: void DisableZoom(bool disable); /** gets the progress of acquisition to the measurement tab*/ int GetProgress(){return progress;}; - + /** Enables plot from the plot tab*/ + void EnablePlot(bool enable); + /** To know whether 1d started*/ + bool DoesPlotExist(){return plotExists;}; /** Starts or stop acquisition * Calls startDaq() function @@ -171,6 +176,8 @@ private: int currentPersistency; int progress; bool plotEnable; + bool plotExists; + bool running; /** Initializes all its members and the thread */ void Initialization(); @@ -223,13 +230,10 @@ void Clear1DPlot(); void ClonePlot(); /** Closes all the clone plots */ void CloseClones(); -/** To Save plot - @param FName full name of file */ -void SavePlot(QString FName); +/** To Save plot */ +void SavePlot(); /** Sets persistency from plot tab */ void SetPersistency(int val); -/** Enables plot */ -void EnablePlot(bool enable); diff --git a/slsDetectorGui/include/qTabActions.h b/slsDetectorGui/include/qTabActions.h index 7f4c13e67..6c8b14c7e 100644 --- a/slsDetectorGui/include/qTabActions.h +++ b/slsDetectorGui/include/qTabActions.h @@ -37,6 +37,10 @@ public: */ ~qTabActions(); + /** To refresh and update widgets + */ + void Refresh(); + private: /** The sls detector object */ diff --git a/slsDetectorGui/include/qTabAdvanced.h b/slsDetectorGui/include/qTabAdvanced.h index 86cf27e8c..101d6cfd3 100644 --- a/slsDetectorGui/include/qTabAdvanced.h +++ b/slsDetectorGui/include/qTabAdvanced.h @@ -30,6 +30,10 @@ public: */ ~qTabAdvanced(); + /** To refresh and update widgets + */ + void Refresh(); + private: /** The sls detector object */ diff --git a/slsDetectorGui/include/qTabDataOutput.h b/slsDetectorGui/include/qTabDataOutput.h index 1a0781ae0..37dd81317 100644 --- a/slsDetectorGui/include/qTabDataOutput.h +++ b/slsDetectorGui/include/qTabDataOutput.h @@ -33,14 +33,16 @@ public: */ ~qTabDataOutput(); + /** To refresh and update widgets + */ + void Refresh(); + + private: /** The sls detector object */ slsDetectorUtils *myDet; - /** Output Directory */ - QString outputDir; - /** methods */ /** Sets up the widget */ void SetupWidgetWindow(); @@ -48,9 +50,6 @@ private: /** Sets up all the slots and signals */ void Initialization(); - /** Enables/Disables all the widgets */ - void Enable(bool enable); - private slots: /** Sets the output directory diff --git a/slsDetectorGui/include/qTabDebugging.h b/slsDetectorGui/include/qTabDebugging.h index a51e84c7d..8d399a6d0 100644 --- a/slsDetectorGui/include/qTabDebugging.h +++ b/slsDetectorGui/include/qTabDebugging.h @@ -30,6 +30,9 @@ public: */ ~qTabDebugging(); + /** To refresh and update widgets + */ + void Refresh(); private: /** The sls detector object */ diff --git a/slsDetectorGui/include/qTabDeveloper.h b/slsDetectorGui/include/qTabDeveloper.h index 94c4e5b2b..d5baf5e99 100644 --- a/slsDetectorGui/include/qTabDeveloper.h +++ b/slsDetectorGui/include/qTabDeveloper.h @@ -30,6 +30,9 @@ public: */ ~qTabDeveloper(); + /** To refresh and update widgets + */ + void Refresh(); private: /** The sls detector object */ diff --git a/slsDetectorGui/include/qTabMeasurement.h b/slsDetectorGui/include/qTabMeasurement.h index c43b808d7..ee133c581 100644 --- a/slsDetectorGui/include/qTabMeasurement.h +++ b/slsDetectorGui/include/qTabMeasurement.h @@ -36,6 +36,10 @@ public: */ ~qTabMeasurement(); + /** To refresh and update widgets + */ + void Refresh(); + private: /** The sls detector object */ diff --git a/slsDetectorGui/include/qTabMessages.h b/slsDetectorGui/include/qTabMessages.h index e61eecb9d..972160300 100644 --- a/slsDetectorGui/include/qTabMessages.h +++ b/slsDetectorGui/include/qTabMessages.h @@ -15,7 +15,9 @@ class slsDetectorUtils; /** Qt Include Headers */ #include #include -#include +#include +#include +#include "qDebugStream.h" /** *@short sets up the Messages parameters @@ -42,11 +44,14 @@ private: /** Log of executed commands */ QTextEdit *dispLog; - /** Command display */ - QLineEdit *dispCommand; + /** To save the log to file */ + QPushButton *btnSave; - /** Path display */ - QLineEdit *dispPath; + /** To clear the log to file */ + QPushButton *btnClear; + + /** This class creates the log */ + qDebugStream *qout; /** methods */ /** Sets up the widget */ @@ -55,9 +60,15 @@ private: /** Sets up all the slots and signals */ void Initialization(); - private slots: - void executeCommand(); +/** Stream log to textedit in GUI */ +void customEvent(QEvent *e); + +/** Save Log to File*/ +void SaveLog(); + +/** Clear Log to File*/ +void ClearLog(); }; diff --git a/slsDetectorGui/include/qTabPlot.h b/slsDetectorGui/include/qTabPlot.h index cb789c116..957347e30 100644 --- a/slsDetectorGui/include/qTabPlot.h +++ b/slsDetectorGui/include/qTabPlot.h @@ -34,6 +34,7 @@ public: ~qTabPlot(); + private: /** The sls detector object */ slsDetectorUtils *myDet; @@ -41,6 +42,9 @@ private: /** The Plot widget */ qDrawPlot *myPlot; + /** 1d/2d plot */ + bool isOneD; + /** some Default Values */ static QString defaultPlotTitle; static QString defaultHistXAxisTitle; @@ -58,11 +62,6 @@ private: */ void Initialization(); - /** Enables/Disables all the widgets - */ - void Enable(bool enable); - - @@ -93,9 +92,10 @@ void SetAxesRange(); void SetZRange(); /** Enables the range of the z axis */ void EnableZRange(); -/** Save Plot */ -void SavePlot(); - +/** Set Plot to none, data graph, histogram*/ +void SetPlot(); +/** Enable Histogram */ +void EnableHistogram(bool enable); signals: void DisableZoomSignal(bool); diff --git a/slsDetectorGui/include/qTabSettings.h b/slsDetectorGui/include/qTabSettings.h index 0a587022b..5729e5c41 100644 --- a/slsDetectorGui/include/qTabSettings.h +++ b/slsDetectorGui/include/qTabSettings.h @@ -34,6 +34,10 @@ public: */ ~qTabSettings(); + /** To refresh and update widgets + */ + void Refresh(); + private: /** The sls detector object */ diff --git a/slsDetectorGui/slsDetectorGui.pro b/slsDetectorGui/slsDetectorGui.pro index 10f51bafc..6c1474409 100644 --- a/slsDetectorGui/slsDetectorGui.pro +++ b/slsDetectorGui/slsDetectorGui.pro @@ -71,6 +71,7 @@ HEADERS = \ slsDetectorPlotting/include/SlsQtValidators.h\ slsDetectorPlotting/include/SlsQtNumberEntry.h\ include/qDefs.h\ + include/qDebugStream.h\ include/qDetectorMain.h\ include/qDrawPlot.h\ include/qCloneWidget.h\ diff --git a/slsDetectorGui/src/qCloneWidget.cpp b/slsDetectorGui/src/qCloneWidget.cpp index ae8d385a8..52bb930f2 100644 --- a/slsDetectorGui/src/qCloneWidget.cpp +++ b/slsDetectorGui/src/qCloneWidget.cpp @@ -141,7 +141,7 @@ void qCloneWidget::SetupWidgetWindow(QString title,int numDim,SlsQt1DPlot*& plot //------------------------------------------------------------------------------------------------------------------------------------------------- void qCloneWidget::SetCloneHists(int nHists,int histNBins,double* histXAxis,double* histYAxis[],string histTitle[]){ - /** for each plot*/ + /** for each plot*/cout<<"qclone nhists:"<render(&painter); - fName = QFileDialog::getSaveFileName(this,tr("Save Snapshot "), - fName,tr("Images (*.png *.xpm *.jpg)")); + fName = QFileDialog::getSaveFileName(this,tr("Save Snapshot "),fName,tr("Images (*.png *.xpm *.jpg)"),0,QFileDialog::ShowDirsOnly); if (!fName.isEmpty()) - if(!(img.save(fName))) - qDefs::ErrorMessage("ERROR: Attempt to save snapshot failed","Snapshot: WARNING"); + if((img.save(fName))) + qDefs::InfoMessage("The SnapShot has been successfully saved","Snapshot: Information"); + else + qDefs::ErrorMessage("ERROR: Attempt to save snapshot failed. Wrong Format","Snapshot: WARNING"); } //------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/slsDetectorGui/src/qDetectorMain.cpp b/slsDetectorGui/src/qDetectorMain.cpp index aaebe0f3b..5da201b2a 100644 --- a/slsDetectorGui/src/qDetectorMain.cpp +++ b/slsDetectorGui/src/qDetectorMain.cpp @@ -17,6 +17,7 @@ #include "sls_detector_defs.h" /** Qt Include Headers */ #include +#include /** C++ Include Headers */ #include #include @@ -25,6 +26,7 @@ using namespace std; //------------------------------------------------------------------------------------------------------------------------------------------------- + int main (int argc, char **argv) { QApplication *theApp = new QApplication(argc, argv); @@ -35,8 +37,10 @@ int main (int argc, char **argv) { return theApp->exec(); } + //------------------------------------------------------------------------------------------------------------------------------------------------- + qDetectorMain::qDetectorMain(int argc, char **argv, QApplication *app, QWidget *parent) : QMainWindow(parent), theApp(app),myDet(0),detID(0),myPlot(NULL),tabs(NULL),isDeveloper(0){ @@ -61,23 +65,26 @@ qDetectorMain::qDetectorMain(int argc, char **argv, QApplication *app, QWidget * } + //------------------------------------------------------------------------------------------------------------------------------------------------- + qDetectorMain::~qDetectorMain(){ delete myDet; if (menubar) delete menubar; if (centralwidget) delete centralwidget; } + //------------------------------------------------------------------------------------------------------------------------------------------------- + void qDetectorMain::SetUpWidgetWindow(){ /** Layout */ layoutTabs= new QGridLayout; centralwidget->setLayout(layoutTabs); - /** plot setup*/ myPlot = new qDrawPlot(dockWidgetPlot,myDet); dockWidgetPlot->setWidget(myPlot); @@ -86,6 +93,7 @@ void qDetectorMain::SetUpWidgetWindow(){ tabs = new MyTabWidget(this); layoutTabs->addWidget(tabs); /** creating all the tab widgets */ + tab_messages = new qTabMessages (this, myDet); tab_measurement = new qTabMeasurement (this, myDet,myPlot); tab_dataoutput = new qTabDataOutput (this, myDet); tab_plot = new qTabPlot (this, myDet,myPlot); @@ -94,7 +102,6 @@ void qDetectorMain::SetUpWidgetWindow(){ tab_advanced = new qTabAdvanced (this, myDet); tab_debugging = new qTabDebugging (this, myDet); tab_developer = new qTabDeveloper (this, myDet); - tab_messages = new qTabMessages (this, myDet); /** creating the scroll area widgets for the tabs */ for(int i=0;isetWidget(tab_advanced); scroll[Debugging] ->setWidget(tab_debugging); scroll[Developer] ->setWidget(tab_developer); - - /** inserting all the tabs*/ tabs->insertTab(Measurement, scroll[Measurement], "Measurement"); tabs->insertTab(DataOutput, scroll[DataOutput], "Data Output"); @@ -122,21 +127,38 @@ void qDetectorMain::SetUpWidgetWindow(){ tabs->insertTab(Developer, scroll[Developer], "Developer"); /** Prefer this to expand and not have scroll buttons*/ tabs->insertTab(Messages, tab_messages, "Messages"); + /** Default tab color*/ + defaultTabColor = tabs->tabBar()->tabTextColor(DataOutput); + /**Set the current tab(measurement) to blue as it is the current one*/ + tabs->tabBar()->setTabTextColor(0,QColor(0,0,200,255)); + /** increase the width so it uses all the empty space for the tab titles*/ + tabs->tabBar()->setFixedWidth(width()+61); /** mode setup - to set up the tabs initially as disabled, not in form so done here */ - SetDebugMode(false); - SetBeamlineMode(false); - SetExpertMode(false); - SetDeveloperMode(false); - SetDeveloperMode(isDeveloper); - - tabs->tabBar()->setTabTextColor(0,QColor(0,0,200,255)); - +#ifdef VERBOSE + cout<<"Setting Debug Mode to 0\nSetting Beamline Mode to 0\n" + "Setting Expert Mode to 0\nSetting Dockable Mode to false\n" + "Setting Developer Mode to "<setTabEnabled(Debugging,false); + //beamline mode to false + tabs->setTabEnabled(Advanced,false); + dockWidgetPlot->setFloating(false); + dockWidgetPlot->setFeatures(QDockWidget::NoDockWidgetFeatures); + tabs->setTabEnabled(Developer,isDeveloper); +/** Other setup*/ + /**Height of plot and central widget*/ + heightPlotWindow = dockWidgetPlot->size().height(); + heightCentralWidget = centralwidget->size().height(); + /** Default zoom Tool Tip */ + zoomToolTip = dockWidgetPlot->toolTip(); } + //------------------------------------------------------------------------------------------------------------------------------------------------- + void qDetectorMain::SetUpDetector(){ @@ -178,14 +200,16 @@ void qDetectorMain::SetUpDetector(){ } } + //------------------------------------------------------------------------------------------------------------------------------------------------- + void qDetectorMain::Initialization(){ /** Dockable Plot*/ connect(dockWidgetPlot,SIGNAL(topLevelChanged(bool)),this,SLOT(ResizeMainWindow(bool))); /** tabs */ - connect(tabs,SIGNAL(currentChanged(int)),this, SLOT(refresh(int)));//( QWidget*))); + connect(tabs,SIGNAL(currentChanged(int)),this, SLOT(Refresh(int)));//( QWidget*))); /** Measurement tab*/ /** Plot tab */ connect(tab_plot,SIGNAL(DisableZoomSignal(bool)),this, SLOT(SetZoomToolTip(bool))); @@ -200,166 +224,187 @@ void qDetectorMain::Initialization(){ /** menubar */ /** Modes Menu */ - connect(actionDebug, SIGNAL(toggled(bool)),this,SLOT(SetDebugMode(bool))); - connect(actionBeamline, SIGNAL(toggled(bool)),this,SLOT(SetBeamlineMode(bool))); - connect(actionExpert, SIGNAL(toggled(bool)),this,SLOT(SetExpertMode(bool))); - connect(actionDockable, SIGNAL(toggled(bool)),this,SLOT(SetDockableMode(bool))); - - + connect(menuModes,SIGNAL(triggered(QAction*)),SLOT(EnableModes(QAction*))); /** Utilities Menu */ - connect(actionOpenSetup,SIGNAL(triggered()),this,SLOT(OpenSetup())); - connect(actionSaveSetup,SIGNAL(triggered()),this,SLOT(SaveSetup())); - connect(actionMeasurementWizard,SIGNAL(triggered()),this,SLOT(MeasurementWizard())); - connect(actionOpenConfiguration,SIGNAL(triggered()),this,SLOT(OpenConfiguration())); - connect(actionSaveConfiguration,SIGNAL(triggered()),this,SLOT(SaveConfiguration())); - connect(actionEnergyCalibration,SIGNAL(triggered()),this,SLOT(EnergyCalibration())); - connect(actionAngularCalibration,SIGNAL(triggered()),this,SLOT(AngularCalibration())); - connect(actionAbout,SIGNAL(triggered()),this,SLOT(About())); - connect(actionVersion,SIGNAL(triggered()),this,SLOT(Version())); - - heightPlotWindow = dockWidgetPlot->size().height(); - heightCentralWidget = centralwidget->size().height(); - - defaultTabColor = tabs->tabBar()->tabTextColor(DataOutput); - zoomToolTip = dockWidgetPlot->toolTip(); + connect(menuUtilities,SIGNAL(triggered(QAction*)),SLOT(ExecuteUtilities(QAction*))); + /** Help Menu */ + connect(menuHelp,SIGNAL(triggered(QAction*)),SLOT(ExecuteHelp(QAction*))); } + //------------------------------------------------------------------------------------------------------------------------------------------------- -void qDetectorMain::SetDeveloperMode(bool b){ + +void qDetectorMain::EnableModes(QAction *action){ + bool enable; + + /**Set DebugMode */ + if(action==actionDebug){ + enable = actionDebug->isChecked(); + tabs->setTabEnabled(Debugging,enable); #ifdef VERBOSE - cout<<"Setting Developer Mode to "<setTabEnabled(Developer,b); -} + } -//------------------------------------------------------------------------------------------------------------------------------------------------- - -void qDetectorMain::SetDebugMode(bool b){ + /**Set BeamlineMode */ + else if(action==actionBeamline){ + enable = actionBeamline->isChecked(); #ifdef VERBOSE - cout<<"Setting Debug Mode to "<setTabEnabled(Debugging,b); -} + } -//------------------------------------------------------------------------------------------------------------------------------------------------- - -void qDetectorMain::SetBeamlineMode(bool b){ + /**Set ExpertMode */ + else if(action==actionExpert){ + enable = actionExpert->isChecked(); + tabs->setTabEnabled(Advanced,enable); #ifdef VERBOSE - cout<<"Setting Beamline Mode to "<isChecked(); + if(enable) + dockWidgetPlot->setFeatures(QDockWidget::DockWidgetFloatable); + else{ + dockWidgetPlot->setFloating(false); + dockWidgetPlot->setFeatures(QDockWidget::NoDockWidgetFeatures); + } #ifdef VERBOSE - cout<<"Setting Expert Mode to "<setTabEnabled(Advanced,b); + } } + //------------------------------------------------------------------------------------------------------------------------------------------------- -void qDetectorMain::refresh(int index){ + +void qDetectorMain::ExecuteUtilities(QAction *action){ + + if(action==actionOpenSetup){ +#ifdef VERBOSE + cout<<"Opening Setup"<getFilePath().c_str()); + fName = QFileDialog::getOpenFileName(this, + tr("Load Detector Setup"),fName, + tr("Detector Setup files (*.det)")); + /** Gets called when cancelled as well*/ + if (!fName.isEmpty()){ + myDet->retrieveDetectorSetup(string(fName.toAscii().constData())); + qDefs::InfoMessage("The parameters have been successfully setup.","Main: Information"); + } + } + else if(action==actionSaveSetup){ +#ifdef VERBOSE + cout<<"Saving Setup"<getFilePath().c_str()); + fName = QFileDialog::getSaveFileName(this, + tr("Save Current Detector Setup"),fName, + tr("Detector Setup files (*.det) ")); + /** Gets called when cancelled as well*/ + if (!fName.isEmpty()){ + myDet->dumpDetectorSetup(string(fName.toAscii().constData())); + qDefs::InfoMessage("The setup parameters have been successfully saved.","Main: Information"); + } + } + else if(action==actionMeasurementWizard){ +#ifdef VERBOSE + cout<<"Measurement Wizard"<getFilePath().c_str()); + fName = QFileDialog::getOpenFileName(this, + tr("Load Detector Configuration"),fName, + tr("Configuration files (*.config)")); + /** Gets called when cancelled as well*/ + if (!fName.isEmpty()){ + myDet->readConfigurationFile(string(fName.toAscii().constData())); + qDefs::InfoMessage("The parameters have been successfully configured.","Main: Information"); + } + } + else if(action==actionSaveConfiguration){ +#ifdef VERBOSE + cout<<"Saving Configuration"<getFilePath().c_str()); + fName = QFileDialog::getSaveFileName(this, + tr("Save Current Detector Configuration"),fName, + tr("Configuration files (*.config) ")); + /** Gets called when cancelled as well*/ + if (!fName.isEmpty()){ + myDet->writeConfigurationFile(string(fName.toAscii().constData())); + qDefs::InfoMessage("The configuration parameters have been successfully saved.","Main: Information"); + } + } + else if(action==actionEnergyCalibration){ +#ifdef VERBOSE + cout<<"Executing Energy Calibration"<currentIndex()); +} + + +//------------------------------------------------------------------------------------------------------------------------------------------------- + + +void qDetectorMain::ExecuteHelp(QAction *action){ + if(action==actionVersion){ +#ifdef VERBOSE + cout<<"Version"<isTabEnabled(index)) tabs->setCurrentIndex((index++)<(tabs->count()-1)?index:Measurement); else{ -; + switch(tabs->currentIndex()){ + case Measurement: if(!myPlot->isRunning()) tab_measurement->Refresh(); break; + case Settings: tab_settings->Refresh(); break; + case DataOutput: tab_dataoutput->Refresh(); break; + case Plot: break; + case Actions: tab_actions->Refresh(); break; + case Advanced: tab_advanced->Refresh(); break; + case Debugging: tab_debugging->Refresh(); break; + case Developer: tab_developer->Refresh(); break; + case Messages: break; + } } for(int i=0;itabBar()->setTabTextColor(i,defaultTabColor); tabs->tabBar()->setTabTextColor(index,QColor(0,0,200,255)); } -//------------------------------------------------------------------------------------------------------------------------------------------------- - -void qDetectorMain::SetDockableMode(bool b){ -#ifdef VERBOSE - cout<<"Setting Dockable Mode to "<setFeatures(QDockWidget::DockWidgetFloatable); - else{ - dockWidgetPlot->setFloating(false); - dockWidgetPlot->setFeatures(QDockWidget::NoDockWidgetFeatures); - } -} //------------------------------------------------------------------------------------------------------------------------------------------------- -void qDetectorMain::OpenSetup(){ -#ifdef VERBOSE - cout<<"Opening Setup"<isFloating()){ if(tabs->currentIndex()== Actions){ @@ -394,8 +442,10 @@ void qDetectorMain::resizeEvent(QResizeEvent* event){ event->accept(); } + //------------------------------------------------------------------------------------------------------------------------------------------------- + void qDetectorMain::EnableTabs(){ #ifdef VERBOSE cout<<"Entering EnableTabs function"<setToolTip(zoomToolTip); } + //------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/slsDetectorGui/src/qDrawPlot.cpp b/slsDetectorGui/src/qDrawPlot.cpp index 537c8b986..568829b24 100644 --- a/slsDetectorGui/src/qDrawPlot.cpp +++ b/slsDetectorGui/src/qDrawPlot.cpp @@ -7,6 +7,8 @@ /** Qt Project Class Headers */ #include "qDrawPlot.h" #include "qCloneWidget.h" +#include "qDefs.h" +#include "slsDetector.h" /** Project Class Headers */ #include "slsDetector.h" #include "multiSlsDetector.h" @@ -15,6 +17,7 @@ #include #include #include +#include /** C++ Include Headers */ #include #include @@ -22,7 +25,6 @@ using namespace std; - //------------------------------------------------------------------------------------------------------------------------------------------------- qDrawPlot::qDrawPlot(QWidget *parent,slsDetectorUtils*& detector):QWidget(parent),myDet(detector){ @@ -73,6 +75,9 @@ void qDrawPlot::SetupWidgetWindow(){ currentPersistency = 0; progress = 0; plotEnable=true; + plotExists=false; + /** This is so that it initially stop and plots */ + running = 1; for(int i=0;iregisterDataCallback(&(GetDataCallBack),this); /** Start acquiring data from server */ + if(!firstTime) pthread_join(gui_acquisition_thread,NULL);//wait until he's finished, ie. exits pthread_create(&gui_acquisition_thread, NULL,DataStartAcquireThread, (void*) this); + firstTime = false; /** This is set here and later reset to zero when all the plotting is done * This is manually done instead of keeping track of thread because * this thread returns immediately after executing the acquire command*/ gui_acquisition_thread_running=1; - cout<<"Started acquiring threaddd"<progressIndex; @@ -332,6 +340,9 @@ int qDrawPlot::GetData(detectorData *data){ void qDrawPlot::setNumMeasurements(int num){ number_of_measurements = num; +#ifdef VERBOSE + cout<<"Setting Number of Measurements to " <stop(); if(plotEnable){ LockLastImageArray(); @@ -392,6 +402,8 @@ void qDrawPlot::UpdatePlot(){ h->Attach(plot1D); } + /**plot exists is false in the beginning, right after cloning and when no plot is checked*/ + plotExists=true; } } @@ -407,14 +419,15 @@ void qDrawPlot::UpdatePlot(){ plot2D->SetZTitle(imageZAxisTitle); plot2D->UpdateNKeepSetRangeIfSet(); //this will keep a "set" z range, and call Plot()->Update(); } + /**plot exists is false in the beginning, right after cloning and when no plot is checked*/ + plotExists=true; } } last_plot_number=lastImageNumber; if(plotEnable) UnlockLastImageArray(); - /** Measurement not over, continue*/ - if(number_of_exposures!=last_plot_number){ + if(number_of_exposures!=currentFrame){//las plot number? plot_update_timer->start(500); } /** if a measurement is over */ @@ -428,7 +441,6 @@ void qDrawPlot::UpdatePlot(){ }/** To start the next measurement*/ else{ StopDaqForGui(); - //StartDaq(false); StartDaq(true); } } @@ -457,7 +469,10 @@ void qDrawPlot::ClonePlot(){ } /** save height to keep maintain same height of plot */ int preheight = height(); + /** create clone */ + /** plotexists is true after calling updateplot*/ + plotExists=false; winClone[i] = new qCloneWidget(this,i,boxPlot->title(),(int)plot_in_scope,plot1D,plot2D,myDet->getFilePath()); if(plot_in_scope==1){ plot1D = new SlsQt1DPlot(boxPlot); @@ -465,7 +480,7 @@ void qDrawPlot::ClonePlot(){ plot1D->SetXTitle(histXAxisTitle.toAscii().constData()); plot1D->SetYTitle(histYAxisTitle.toAscii().constData()); plotLayout->addWidget(plot1D,1,1,1,1); - winClone[i]->SetCloneHists((int)nHists,histNBins,histXAxis,histYAxis,histTitle); + if(running) winClone[i]->SetCloneHists((int)nHists,histNBins,histXAxis,histYAxis,histTitle); } else{ plot2D = new SlsQt2DPlotLayout(boxPlot); @@ -478,8 +493,9 @@ void qDrawPlot::ClonePlot(){ } setMinimumHeight(preheight); resize(width(),preheight); - /** update the actual plot */ - UpdatePlot(); + + /** update the actual plot only if running, else it doesnt know when its over*/ + if(running) UpdatePlot(); connect(this, SIGNAL(InterpolateSignal(bool)), plot2D, SIGNAL(InterpolateSignal(bool))); connect(this, SIGNAL(ContourSignal(bool)), plot2D, SIGNAL(ContourSignal(bool))); connect(this, SIGNAL(LogzSignal(bool)), plot2D, SLOT(SetZScaleToLog(bool))); @@ -509,11 +525,21 @@ void qDrawPlot::CloneCloseEvent(int id){ //------------------------------------------------------------------------------------------------------------------------------------------------- -void qDrawPlot::SavePlot(QString FName){ +void qDrawPlot::SavePlot(){ + /** render image */ QImage img(size().width(),size().height(),QImage::Format_RGB32); QPainter painter(&img); render(&painter); - img.save(FName); + + /** save image*/ + QString fName = QString(myDet->getFilePath().c_str())+"/Image.png"; + fName = QFileDialog::getSaveFileName(this,tr("Save Image"),fName,tr("Images (*.png *.xpm *.jpg)")); + if (!fName.isEmpty()) + if(img.save(fName)) + qDefs::InfoMessage("The Image has been successfully saved","Dock: Information"); + else + qDefs::ErrorMessage("ERROR: Attempt to save image failed. Wrong Format","Dock: WARNING"); + } //------------------------------------------------------------------------------------------------------------------------------------------------- @@ -532,7 +558,10 @@ void qDrawPlot::EnablePlot(bool enable){ #ifdef VERBOSE cout<<"Plotting set to:"<text(),"+")){ */ +//------------------------------------------------------------------------------------------------------------------------------------------------- + +void qTabActions::Refresh(){ + +} + +//------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/slsDetectorGui/src/qTabAdvanced.cpp b/slsDetectorGui/src/qTabAdvanced.cpp index 34e30f2d6..f01985140 100644 --- a/slsDetectorGui/src/qTabAdvanced.cpp +++ b/slsDetectorGui/src/qTabAdvanced.cpp @@ -76,4 +76,13 @@ void qTabAdvanced::getTemperature(){ #endif } +//------------------------------------------------------------------------------------------------------------------------------------------------- + + +void qTabAdvanced::Refresh(){ + +} + + +//------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/slsDetectorGui/src/qTabDataOutput.cpp b/slsDetectorGui/src/qTabDataOutput.cpp index b51904a23..f860b8541 100644 --- a/slsDetectorGui/src/qTabDataOutput.cpp +++ b/slsDetectorGui/src/qTabDataOutput.cpp @@ -17,6 +17,7 @@ using namespace std; +//------------------------------------------------------------------------------------------------------------------------------------------------- qTabDataOutput::qTabDataOutput(QWidget *parent,slsDetectorUtils*& detector): @@ -27,6 +28,7 @@ qTabDataOutput::qTabDataOutput(QWidget *parent,slsDetectorUtils*& detector): } +//------------------------------------------------------------------------------------------------------------------------------------------------- qTabDataOutput::~qTabDataOutput(){ @@ -34,14 +36,16 @@ qTabDataOutput::~qTabDataOutput(){ } +//------------------------------------------------------------------------------------------------------------------------------------------------- void qTabDataOutput::SetupWidgetWindow(){ - outputDir= QString(myDet->getFilePath().c_str()); - dispOutputDir->setText(outputDir); + dispOutputDir->setText(QString(myDet->getFilePath().c_str())); } +//------------------------------------------------------------------------------------------------------------------------------------------------- + void qTabDataOutput::Initialization(){ connect(dispOutputDir, SIGNAL(textChanged(const QString&)), this, SLOT(setOutputDir(const QString&))); @@ -49,22 +53,29 @@ void qTabDataOutput::Initialization(){ } - -void qTabDataOutput::Enable(bool enable){ - layoutOutput->setEnabled(enable); - boxCorrection->setEnabled(enable); -} +//------------------------------------------------------------------------------------------------------------------------------------------------- void qTabDataOutput::setOutputDir(const QString& path){ - outputDir = path; - myDet->setFilePath(string(outputDir.toAscii().constData())); + myDet->setFilePath(string(path.toAscii().constData())); #ifdef VERBOSE cout<<"Output Directory changed to :"<getFilePath()<setText(QString(myDet->getFilePath().c_str())); +} + + +//------------------------------------------------------------------------------------------------------------------------------------------------- + + void qTabDataOutput::browseOutputDir() { QString directory = QFileDialog::getExistingDirectory(this,tr("Choose Output Directory "),dispOutputDir->text()); @@ -73,3 +84,4 @@ void qTabDataOutput::browseOutputDir() } +//------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/slsDetectorGui/src/qTabDebugging.cpp b/slsDetectorGui/src/qTabDebugging.cpp index 8c797b30b..2fa080cc2 100644 --- a/slsDetectorGui/src/qTabDebugging.cpp +++ b/slsDetectorGui/src/qTabDebugging.cpp @@ -48,3 +48,13 @@ void qTabDebugging::Enable(bool enable){ } +//------------------------------------------------------------------------------------------------------------------------------------------------- + + +void qTabDebugging::Refresh(){ + +} + + +//------------------------------------------------------------------------------------------------------------------------------------------------- + diff --git a/slsDetectorGui/src/qTabDeveloper.cpp b/slsDetectorGui/src/qTabDeveloper.cpp index b987fff82..b0fcd68a9 100644 --- a/slsDetectorGui/src/qTabDeveloper.cpp +++ b/slsDetectorGui/src/qTabDeveloper.cpp @@ -41,5 +41,14 @@ void qTabDeveloper::SetupWidgetWindow(){ void qTabDeveloper::Initialization(){ } +//------------------------------------------------------------------------------------------------------------------------------------------------- + + +void qTabDeveloper::Refresh(){ + +} + + +//------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/slsDetectorGui/src/qTabMeasurement.cpp b/slsDetectorGui/src/qTabMeasurement.cpp index b0da22efe..f434ad6b3 100644 --- a/slsDetectorGui/src/qTabMeasurement.cpp +++ b/slsDetectorGui/src/qTabMeasurement.cpp @@ -302,7 +302,7 @@ void qTabMeasurement::setExposureTime(){ /** Get the value of timer in ns **/ exptimeNS = (int64_t)qDefs::getNSTime((qDefs::timeUnit)comboExpUnit->currentIndex(),spinExpTime->value()); #ifdef VERBOSE - cout<<"Setting acquisition time to " << exptimeNS << " clocks" << endl; + cout<<"Setting acquisition time to " << exptimeNS << " clocks" << "/"<value()<currentIndex())<setTimer(slsDetectorDefs::ACQUISITION_TIME,exptimeNS); @@ -312,12 +312,12 @@ void qTabMeasurement::setExposureTime(){ if(exptimeNS>acqtimeNS) { lblNote->show(); lblPeriod->setPalette(lblNote->palette()); - lblPeriod->setText("* Acquisition Period"); + lblPeriod->setText("Acquisition Period:*"); } else { lblNote->hide(); lblPeriod->setPalette(lblNumFrames->palette()); - lblPeriod->setText("Acquisition Period"); + lblPeriod->setText("Acquisition Period:"); } } } @@ -329,7 +329,7 @@ void qTabMeasurement::setAcquisitionPeriod(){ /** Get the value of timer in ns **/ acqtimeNS = (int64_t)qDefs::getNSTime((qDefs::timeUnit)comboPeriodUnit->currentIndex(),spinPeriod->value()); #ifdef VERBOSE - cout<<"Setting frame period between exposures to " << acqtimeNS << " clocks" << endl; + cout<<"Setting frame period between exposures to " << acqtimeNS << " clocks"<< "/"<value()<currentIndex())<setTimer(slsDetectorDefs::FRAME_PERIOD,acqtimeNS); @@ -338,12 +338,12 @@ void qTabMeasurement::setAcquisitionPeriod(){ if(exptimeNS>acqtimeNS){ lblNote->show(); lblPeriod->setPalette(lblNote->palette()); - lblPeriod->setText("* Acquisition Period"); + lblPeriod->setText("Acquisition Period:*"); } else { lblNote->hide(); lblPeriod->setPalette(lblNumFrames->palette()); - lblPeriod->setText("Acquisition Period"); + lblPeriod->setText("Acquisition Period:"); } } @@ -363,7 +363,7 @@ void qTabMeasurement::setDelay(){ /** Get the value of timer in ns **/ exptimeNS = (int64_t)qDefs::getNSTime((qDefs::timeUnit)comboDelayUnit->currentIndex(),spinDelay->value()); #ifdef VERBOSE - cout<<"Setting delay after trigger to " << exptimeNS << " clocks" << endl; + cout<<"Setting delay after trigger to " << exptimeNS << " clocks"<< "/"<value()<currentIndex())<setTimer(slsDetectorDefs::DELAY_AFTER_TRIGGER,exptimeNS); } @@ -496,7 +496,7 @@ void qTabMeasurement::setTimingMode(int mode){ if(lblExpTime->isEnabled()){ time = qDefs::getCorrectTime(unit,((float)(myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,-1)*(1E-9)))); #ifdef VERBOSE - cout<<"Getting acquisition time : " << time << "s" << endl; + cout<<"Getting acquisition time : " << time << qDefs::getUnitString(unit) << endl; #endif spinExpTime->setValue(time); comboExpUnit->setCurrentIndex((int)unit); @@ -506,7 +506,7 @@ void qTabMeasurement::setTimingMode(int mode){ if(lblPeriod->isEnabled()){ time = qDefs::getCorrectTime(unit,((float)(myDet->setTimer(slsDetectorDefs::FRAME_PERIOD,-1)*(1E-9)))); #ifdef VERBOSE - cout<<"Getting frame period between exposures : " << time << "s" << endl; + cout<<"Getting frame period between exposures : " << time << qDefs::getUnitString(unit) << endl; #endif spinPeriod->setValue(time); comboPeriodUnit->setCurrentIndex((int)unit); @@ -517,17 +517,17 @@ void qTabMeasurement::setTimingMode(int mode){ if(exptimeNS>acqtimeNS) { lblNote->show(); lblPeriod->setPalette(lblNote->palette()); - lblPeriod->setText("* Acquisition Period"); + lblPeriod->setText("Acquisition Period:*"); } else { lblNote->hide(); lblPeriod->setPalette(lblNumFrames->palette()); - lblPeriod->setText("Acquisition Period"); + lblPeriod->setText("Acquisition Period:"); } }else { lblNote->hide(); lblPeriod->setPalette(lblNumFrames->palette()); - lblPeriod->setText("Acquisition Period"); + lblPeriod->setText("Acquisition Period:"); } /**Number of Triggers */ @@ -543,7 +543,7 @@ void qTabMeasurement::setTimingMode(int mode){ if(lblDelay->isEnabled()){ time = qDefs::getCorrectTime(unit,((float)(myDet->setTimer(slsDetectorDefs::DELAY_AFTER_TRIGGER,-1)*(1E-9)))); #ifdef VERBOSE - cout<<"Getting delay after trigger : " << time << "s" << endl; + cout<<"Getting delay after trigger : " << time << qDefs::getUnitString(unit) << endl; #endif spinDelay->setValue(time); comboDelayUnit->setCurrentIndex((int)unit); @@ -574,4 +574,22 @@ void qTabMeasurement::setTimingMode(int mode){ } + +//------------------------------------------------------------------------------------------------------------------------------------------------- + + +void qTabMeasurement::Refresh(){ + /** File Name **/ + dispFileName->setText(QString(myDet->getFileName().c_str())); + /** File Index **/ + spinIndex->setValue(myDet->getFileIndex()); + /** progress label index **/ + lblProgressIndex->setText(QString::number(myDet->getFileIndex())); + /** Progress bar **/ + progressBar->setValue(myDet->getCurrentProgress()); + /** Timing mode**/ + SetupTimingMode();//comboTimingMode->setCurrentIndex((int)myDet->setExternalCommunicationMode()); +} + + //------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/slsDetectorGui/src/qTabMessages.cpp b/slsDetectorGui/src/qTabMessages.cpp index 25894f492..7b1022922 100644 --- a/slsDetectorGui/src/qTabMessages.cpp +++ b/slsDetectorGui/src/qTabMessages.cpp @@ -5,25 +5,26 @@ * Author: l_maliakal_d */ +/** Qt Project Class Headers */ #include "qTabMessages.h" +#include "qDefs.h" /** Project Class Headers */ #include "slsDetector.h" #include "multiSlsDetector.h" /** Qt Include Headers */ #include -#include -#include -#include -#include -#include +#include +#include +#include +#include /** C++ Include Headers */ #include +#include using namespace std; //------------------------------------------------------------------------------------------------------------------------------------------------- -qTabMessages::qTabMessages(QWidget *parent,slsDetectorUtils*& detector): - QWidget(parent),myDet(detector){ +qTabMessages::qTabMessages(QWidget *parent,slsDetectorUtils*& detector):QWidget(parent),myDet(detector){ SetupWidgetWindow(); Initialization(); } @@ -33,8 +34,6 @@ qTabMessages::qTabMessages(QWidget *parent,slsDetectorUtils*& detector): qTabMessages::~qTabMessages(){ delete myDet; delete dispLog; - delete dispCommand; - delete dispPath; } //------------------------------------------------------------------------------------------------------------------------------------------------- @@ -42,88 +41,71 @@ qTabMessages::~qTabMessages(){ void qTabMessages::SetupWidgetWindow(){ /** Layout */ QGridLayout *gridLayout = new QGridLayout(this); - QLabel *lblCommand = new QLabel("System Command:",this); - QLabel *lblPath = new QLabel("Working Directory:",this); - QSpacerItem *hSpacer= new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Minimum); - dispLog = new QTextEdit(this); - dispCommand = new QLineEdit(this); - dispPath = new QLineEdit(this); - dispLog->setReadOnly(true); - dispPath->setReadOnly(true); - dispLog->setFocusPolicy(Qt::NoFocus); - dispPath->setFocusPolicy(Qt::NoFocus); - gridLayout->addWidget(dispLog, 0, 0, 1, 3); - gridLayout->addWidget(lblCommand, 1, 0, 1, 1); - gridLayout->addItem(hSpacer, 1, 1, 1, 1); - gridLayout->addWidget(dispCommand, 1, 2, 1, 1); - gridLayout->addWidget(lblPath, 2, 0, 1, 1); - gridLayout->addWidget(dispPath, 2, 2, 1, 1); - /** Command & Path*/ - dispCommand->setText("Insert your command here"); - dispPath->setText(QDir("./").absolutePath()); + dispLog = new QTextEdit(this); + dispLog->setReadOnly(true); + dispLog->setFocusPolicy(Qt::NoFocus); + + QSizePolicy sizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); + + btnSave = new QPushButton("Save Log",this); + btnSave->setFocusPolicy(Qt::NoFocus); + btnSave->setSizePolicy(sizePolicy); + + btnClear = new QPushButton("Clear",this); + btnClear->setFocusPolicy(Qt::NoFocus); + btnClear->setSizePolicy(sizePolicy); + + gridLayout->addWidget(btnSave,0,0,1,1); + gridLayout->addWidget(btnClear,0,4,1,1); + gridLayout->addWidget(dispLog,1,0,1,5); + + qout=new qDebugStream(std::cout,this); } //------------------------------------------------------------------------------------------------------------------------------------------------- void qTabMessages::Initialization(){ - connect(dispCommand,SIGNAL(returnPressed()),this,SLOT(executeCommand())); + connect(btnSave,SIGNAL(clicked()),this,SLOT(SaveLog())); + connect(btnClear,SIGNAL(clicked()),this,SLOT(ClearLog())); } //------------------------------------------------------------------------------------------------------------------------------------------------- -void qTabMessages::executeCommand(){ -#ifdef VERBOSE - cout<<"Calling: "<< dispCommand->text().toAscii().constData()<text()).absolutePath()); -#ifdef VERBOSE - //std::cout <<"working directory is " << proc.workingDirectory().absPath() << std::endl; - cout<<"Current Working Directory: "<text())); -#ifdef VERBOSE -/* QStringList list = proc.arguments(); - QStringList::Iterator it = list.begin(); - while( it != list.end() ) { - cout<<*it<type() == STREAMEVENT) + dispLog->append(((qStreamEvent*)e)->getString()); } +//------------------------------------------------------------------------------------------------------------------------------------------------- + +void qTabMessages::SaveLog() { + QString fName = QString(myDet->getFilePath().c_str()); + fName = fName+"/LogFile.txt"; + fName = QFileDialog::getSaveFileName(this,tr("Save Snapshot "), + fName,tr("Text files (*.txt)")); + if (!fName.isEmpty()){ + QFile outfile; + outfile.setFileName(fName); + if(outfile.open(QIODevice::WriteOnly | QIODevice::Text)){//Append + QTextStream out(&outfile); + out<toPlainText() << endl; + qDefs::InfoMessage(string("The Log has been successfully saved to " + "")+fName.toAscii().constData(),"Messages: Information"); + } + else qDefs::ErrorMessage("ERROR: Attempt to save log file failed.","Messages: WARNING"); + } +} + + +//------------------------------------------------------------------------------------------------------------------------------------------------- + +void qTabMessages::ClearLog() { + dispLog->clear(); +#ifdef VERBOSE + cout<<"Log Cleared"< #include using namespace std; +//------------------------------------------------------------------------------------------------------------------------------------------------- QString qTabPlot::defaultPlotTitle("Measurement"); @@ -26,6 +28,9 @@ QString qTabPlot::defaultImageYAxisTitle("Pixel"); QString qTabPlot::defaultImageZAxisTitle("Intensity"); +//------------------------------------------------------------------------------------------------------------------------------------------------- + + qTabPlot::qTabPlot(QWidget *parent,slsDetectorUtils*& detector, qDrawPlot*& plot):QWidget(parent),myDet(detector),myPlot(plot){ setupUi(this); SetupWidgetWindow(); @@ -42,6 +47,7 @@ qTabPlot::qTabPlot(QWidget *parent,slsDetectorUtils*& detector, qDrawPlot*& plot } +//------------------------------------------------------------------------------------------------------------------------------------------------- qTabPlot::~qTabPlot(){ @@ -50,6 +56,7 @@ qTabPlot::~qTabPlot(){ } +//------------------------------------------------------------------------------------------------------------------------------------------------- void qTabPlot::SetupWidgetWindow(){ @@ -75,8 +82,11 @@ void qTabPlot::SetupWidgetWindow(){ } +//------------------------------------------------------------------------------------------------------------------------------------------------- + + void qTabPlot::Select1DPlot(bool b){ - SetupWidgetWindow(); + isOneD = b; if(b){ box1D->setEnabled(true); box2D->setEnabled(false); @@ -105,9 +115,16 @@ void qTabPlot::Select1DPlot(bool b){ } +//------------------------------------------------------------------------------------------------------------------------------------------------- + + void qTabPlot::Initialization(){ /** Plot arguments box*/ - connect(chkNoPlot, SIGNAL(toggled(bool)),myPlot, SLOT(EnablePlot(bool))); + connect(radioNoPlot, SIGNAL(clicked()),this, SLOT(SetPlot())); + connect(radioHistogram, SIGNAL(clicked()),this, SLOT(SetPlot())); + connect(radioDataGraph, SIGNAL(clicked()),this, SLOT(SetPlot())); +/** Scan box*/ + //connect(radioNoPlot, SIGNAL(toggled(bool)),this, SLOT(EnablePlot(bool))); /** Snapshot box*/ connect(btnClone, SIGNAL(clicked()),myPlot, SLOT(ClonePlot())); connect(btnCloseClones, SIGNAL(clicked()),myPlot, SLOT(CloseClones())); @@ -147,21 +164,13 @@ void qTabPlot::Initialization(){ connect(this, SIGNAL(SetZRangeSignal(double,double)),myPlot, SIGNAL(SetZRangeSignal(double,double))); /** Common Buttons*/ - connect(btnClear, SIGNAL(clicked()), myPlot, SLOT(Clear1DPlot())); /** Save */ - connect(btnSave, SIGNAL(clicked()), this, SLOT(SavePlot())); - + connect(btnSave, SIGNAL(clicked()), myPlot, SLOT(SavePlot())); } +//------------------------------------------------------------------------------------------------------------------------------------------------- -void qTabPlot::Enable(bool enable){ - btnClone->setEnabled(enable); - btnCloseClones->setEnabled(enable); - box1D->setEnabled(enable); - box2D->setEnabled(enable); - boxPlotAxis->setEnabled(enable); -} void qTabPlot::EnablePersistency(bool enable){ lblPersistency->setEnabled(enable); @@ -172,19 +181,21 @@ void qTabPlot::EnablePersistency(bool enable){ } +//------------------------------------------------------------------------------------------------------------------------------------------------- + + void qTabPlot::SetTitles(){ - int oneD = box1D->isEnabled(); /** Plot Title*/ if(dispTitle->isEnabled()) myPlot->SetPlotTitle(dispTitle->text()); /** X Axis */ if(dispXAxis->isEnabled()){ - if(oneD) myPlot->SetHistXAxisTitle(dispXAxis->text()); + if(isOneD) myPlot->SetHistXAxisTitle(dispXAxis->text()); else myPlot->SetImageXAxisTitle(dispXAxis->text()); } /** Y Axis */ if(dispYAxis->isEnabled()){ - if(oneD) myPlot->SetHistYAxisTitle(dispYAxis->text()); + if(isOneD) myPlot->SetHistYAxisTitle(dispYAxis->text()); else myPlot->SetImageYAxisTitle(dispYAxis->text()); } /** Z Axis */ @@ -193,9 +204,10 @@ void qTabPlot::SetTitles(){ } +//------------------------------------------------------------------------------------------------------------------------------------------------- + void qTabPlot::EnableTitles(){ - int oneD = box1D->isEnabled(); /** Plot Title*/ dispTitle->setEnabled(chkTitle->isChecked()); if(!chkTitle->isChecked()){ @@ -205,7 +217,7 @@ void qTabPlot::EnableTitles(){ /** X Axis */ dispXAxis->setEnabled(chkXAxis->isChecked()); if(!chkXAxis->isChecked()){ - if(oneD){ + if(isOneD){ myPlot->SetHistXAxisTitle(defaultHistXAxisTitle); dispXAxis->setText(defaultHistXAxisTitle); } @@ -217,7 +229,7 @@ void qTabPlot::EnableTitles(){ /** Y Axis */ dispYAxis->setEnabled(chkYAxis->isChecked()); if(!chkYAxis->isChecked()){ - if(oneD){ + if(isOneD){ myPlot->SetHistYAxisTitle(defaultHistYAxisTitle); dispYAxis->setText(defaultHistYAxisTitle); }else{ @@ -234,6 +246,7 @@ void qTabPlot::EnableTitles(){ } +//------------------------------------------------------------------------------------------------------------------------------------------------- void qTabPlot::EnableRange(){ @@ -253,6 +266,8 @@ void qTabPlot::EnableRange(){ } +//------------------------------------------------------------------------------------------------------------------------------------------------- + void qTabPlot::SetAxesRange(){ double xmin=0,xmax=0,ymin=0,ymax=0; @@ -260,28 +275,40 @@ void qTabPlot::SetAxesRange(){ /** If disabled, get the min or max range of the plot as default */ if((dispXMin->isEnabled())&&(!dispXMin->text().isEmpty())) xmin = dispXMin->text().toDouble(); - else xmin = myPlot->GetXMinimum(); + else if(myPlot->DoesPlotExist()) + xmin = myPlot->GetXMinimum(); if((dispXMax->isEnabled())&&(!dispXMax->text().isEmpty())) xmax = dispXMax->text().toDouble(); - else xmax = myPlot->GetXMaximum(); + else if(myPlot->DoesPlotExist()) + xmax = myPlot->GetXMaximum(); if((dispYMin->isEnabled())&&(!dispYMin->text().isEmpty())) ymin = dispYMin->text().toDouble(); - else ymin = myPlot->GetYMinimum(); + else if(myPlot->DoesPlotExist()) + ymin = myPlot->GetYMinimum(); if((dispYMax->isEnabled())&&(!dispYMax->text().isEmpty())) ymax = dispYMax->text().toDouble(); - else ymax = myPlot->GetYMaximum(); + else if(myPlot->DoesPlotExist()) + ymax = myPlot->GetYMaximum(); /** Setting the range*/ - myPlot->SetXMinMax(xmin,xmax); - myPlot->SetYMinMax(ymin,ymax); + if(myPlot->DoesPlotExist()){ + myPlot->SetXMinMax(xmin,xmax); + myPlot->SetYMinMax(ymin,ymax); + } } +//------------------------------------------------------------------------------------------------------------------------------------------------- + void qTabPlot::SetZRange(){ emit SetZRangeSignal(dispZMin->text().toDouble(),dispZMax->text().toDouble()); } + +//------------------------------------------------------------------------------------------------------------------------------------------------- + + void qTabPlot::EnableZRange(){ dispZMin->setEnabled(chkZMin->isChecked()); dispZMax->setEnabled(chkZMax->isChecked()); @@ -289,9 +316,48 @@ void qTabPlot::EnableZRange(){ } +//------------------------------------------------------------------------------------------------------------------------------------------------- -void qTabPlot::SavePlot(){ - QString fullFileName = QString(myDet->getFilePath().c_str())+'/'+dispFName->text()+comboFormat->currentText(); - myPlot->SavePlot(fullFileName); + +void qTabPlot::SetPlot(){ + if(radioNoPlot->isChecked()){ + myPlot->EnablePlot(false); + /**if enable is true, disable everything */ + box1D->setEnabled(false); + box2D->setEnabled(false); + boxSnapshot->setEnabled(false); + boxSave->setEnabled(false); + boxPlotAxis->setEnabled(false); + boxScan->setEnabled(false); + }else if(radioHistogram->isChecked()){ + myPlot->EnablePlot(true); + /**if enable is true, disable everything */ + box1D->setEnabled(true); + box2D->setEnabled(true); + boxSnapshot->setEnabled(true); + boxSave->setEnabled(true); + boxPlotAxis->setEnabled(true); + boxScan->setEnabled(false); + }else{ + myPlot->EnablePlot(true); + /**if enable is true, disable everything */ + box1D->setEnabled(true); + box2D->setEnabled(true); + boxSnapshot->setEnabled(true); + boxSave->setEnabled(true); + boxPlotAxis->setEnabled(true); + boxScan->setEnabled(true); + } } + +//------------------------------------------------------------------------------------------------------------------------------------------------- + + +void qTabPlot::EnableHistogram(bool enable){ + //boxScan->setEnabled(false); +} + + +//------------------------------------------------------------------------------------------------------------------------------------------------- + diff --git a/slsDetectorGui/src/qTabSettings.cpp b/slsDetectorGui/src/qTabSettings.cpp index 19f0be9ed..8624b70b5 100644 --- a/slsDetectorGui/src/qTabSettings.cpp +++ b/slsDetectorGui/src/qTabSettings.cpp @@ -148,3 +148,13 @@ void qTabSettings::setSettings(int index){ } //------------------------------------------------------------------------------------------------------------------------------------------------- + + +void qTabSettings::Refresh(){ + /** Settings */ + SetupDetectorSettings(); + comboSettings->setCurrentIndex(myDet->getSettings(detID)); +} + + +//-------------------------------------------------------------------------------------------------------------------------------------------------