mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 01:58:00 +02:00
no plot histogram, messages work
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@16 af1100a4-978c-4157-bff7-07162d2ba061
This commit is contained in:
@ -72,9 +72,6 @@ void SetScript(int index);
|
||||
* Options: constant size,specific values,values from file */
|
||||
void EnableSizeWidgets();
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
|
||||
|
113
slsDetectorGui/include/qDebugStream.h
Normal file
113
slsDetectorGui/include/qDebugStream.h
Normal file
@ -0,0 +1,113 @@
|
||||
/*
|
||||
* qDebugStream.h
|
||||
*
|
||||
* Created on: Jun 28, 2012
|
||||
* Author: Anna Bergamaschi
|
||||
*/
|
||||
|
||||
#ifndef QDEBUGSTREAM_H_
|
||||
#define QDEBUGSTREAM_H_
|
||||
|
||||
|
||||
#include <QApplication>
|
||||
#include <QWidget>
|
||||
#include <QString>
|
||||
#include <QEvent>
|
||||
#include <QCustomEvent>
|
||||
|
||||
#include <iostream>
|
||||
#include <streambuf>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
#define STREAMEVENT 60001
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
class qStreamEvent:public QEvent{
|
||||
public:
|
||||
qStreamEvent(QString s):QEvent(static_cast<QEvent::Type>(STREAMEVENT)) {str=s;};
|
||||
/** \returns the progress index */
|
||||
QString getString() {return str;};
|
||||
private:
|
||||
QString str;
|
||||
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
class qDebugStream : public basic_streambuf<char> {
|
||||
|
||||
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_ */
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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);
|
||||
|
||||
|
||||
|
||||
|
@ -37,6 +37,10 @@ public:
|
||||
*/
|
||||
~qTabActions();
|
||||
|
||||
/** To refresh and update widgets
|
||||
*/
|
||||
void Refresh();
|
||||
|
||||
|
||||
private:
|
||||
/** The sls detector object */
|
||||
|
@ -30,6 +30,10 @@ public:
|
||||
*/
|
||||
~qTabAdvanced();
|
||||
|
||||
/** To refresh and update widgets
|
||||
*/
|
||||
void Refresh();
|
||||
|
||||
|
||||
private:
|
||||
/** The sls detector object */
|
||||
|
@ -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
|
||||
|
@ -30,6 +30,9 @@ public:
|
||||
*/
|
||||
~qTabDebugging();
|
||||
|
||||
/** To refresh and update widgets
|
||||
*/
|
||||
void Refresh();
|
||||
|
||||
private:
|
||||
/** The sls detector object */
|
||||
|
@ -30,6 +30,9 @@ public:
|
||||
*/
|
||||
~qTabDeveloper();
|
||||
|
||||
/** To refresh and update widgets
|
||||
*/
|
||||
void Refresh();
|
||||
|
||||
private:
|
||||
/** The sls detector object */
|
||||
|
@ -36,6 +36,10 @@ public:
|
||||
*/
|
||||
~qTabMeasurement();
|
||||
|
||||
/** To refresh and update widgets
|
||||
*/
|
||||
void Refresh();
|
||||
|
||||
|
||||
private:
|
||||
/** The sls detector object */
|
||||
|
@ -15,7 +15,9 @@ class slsDetectorUtils;
|
||||
/** Qt Include Headers */
|
||||
#include <QWidget>
|
||||
#include <QTextEdit>
|
||||
#include <QLineEdit>
|
||||
#include <QEvent>
|
||||
#include <QPushButton>
|
||||
#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();
|
||||
|
||||
};
|
||||
|
||||
|
@ -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);
|
||||
|
@ -34,6 +34,10 @@ public:
|
||||
*/
|
||||
~qTabSettings();
|
||||
|
||||
/** To refresh and update widgets
|
||||
*/
|
||||
void Refresh();
|
||||
|
||||
|
||||
private:
|
||||
/** The sls detector object */
|
||||
|
Reference in New Issue
Block a user