messages capture config output, still to find a way to capture all cerr output

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@95 af1100a4-978c-4157-bff7-07162d2ba061
This commit is contained in:
l_maliakal_d
2012-10-16 08:29:44 +00:00
parent 863662a5eb
commit e104b1d529
6 changed files with 45 additions and 17 deletions

View File

@ -208,7 +208,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>5</x> <x>5</x>
<y>4</y> <y>5</y>
<width>107</width> <width>107</width>
<height>26</height> <height>26</height>
</rect> </rect>
@ -238,7 +238,7 @@
<x>210</x> <x>210</x>
<y>5</y> <y>5</y>
<width>128</width> <width>128</width>
<height>23</height> <height>26</height>
</rect> </rect>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">

View File

@ -40,9 +40,12 @@ private:
class qDebugStream : public basic_streambuf<char> { class qDebugStream : public basic_streambuf<char> {
public: public:
qDebugStream(ostream &stream, QWidget* w) : m_stream(stream), log_window(w) { qDebugStream(ostream &stream, ostream &estream, QWidget* w) : m_stream(stream), e_stream(estream), log_window(w) {
m_old_buf = stream.rdbuf(); m_old_buf = stream.rdbuf();
stream.rdbuf(this); stream.rdbuf(this);
//e_old_buf = stream.rdbuf();
//estream.rdbuf(this);
}; };
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
@ -57,6 +60,7 @@ public:
#endif #endif
} }
m_stream.rdbuf(m_old_buf); m_stream.rdbuf(m_old_buf);
e_stream.rdbuf(e_old_buf);
} }
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
@ -104,6 +108,8 @@ protected:
private: private:
ostream &m_stream; ostream &m_stream;
streambuf *m_old_buf; streambuf *m_old_buf;
ostream &e_stream;
streambuf *e_old_buf;
string m_string; string m_string;
QWidget* log_window; QWidget* log_window;
}; };

View File

@ -113,8 +113,9 @@ private:
int isDeveloper; int isDeveloper;
/**Sets up the layout of the widget /**Sets up the layout of the widget
* @param fName file name of the config file at start up
* */ * */
void SetUpWidgetWindow(); void SetUpWidgetWindow(const string fName);
/**Sets up detector /**Sets up detector
* @param fName file name of the config file at start up * @param fName file name of the config file at start up

View File

@ -28,14 +28,18 @@ class qTabMessages:public QWidget{
public: public:
/** \short The constructor /** \short The constructor
* @param parent is the parent tab widget * @param parent is the parent tab widget
* @param detector is the detector returned from the detector tab
*/ */
qTabMessages(QWidget *parent,multiSlsDetector*& detector); qTabMessages(QWidget *parent);
/** Destructor /** Destructor
*/ */
~qTabMessages(); ~qTabMessages();
/** Set the detetor reference
* @param det the detector reference
*/
void SetDetectorReference(multiSlsDetector*& detector){myDet = detector;};
private: private:
/** The sls detector object */ /** The sls detector object */
@ -52,6 +56,7 @@ private:
/** This class creates the log */ /** This class creates the log */
qDebugStream *qout; qDebugStream *qout;
//qDebugStream *qerr;
/** methods */ /** methods */
/** Sets up the widget */ /** Sets up the widget */

View File

@ -64,8 +64,7 @@ qDetectorMain::qDetectorMain(int argc, char **argv, QApplication *app, QWidget *
} }
setupUi(this); setupUi(this);
SetUpDetector(configFName); SetUpWidgetWindow(configFName);
SetUpWidgetWindow();
Initialization(); Initialization();
} }
@ -84,21 +83,29 @@ qDetectorMain::~qDetectorMain(){
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
void qDetectorMain::SetUpWidgetWindow(){ void qDetectorMain::SetUpWidgetWindow(const string fName){
// Layout // Layout
layoutTabs= new QGridLayout; layoutTabs= new QGridLayout;
centralwidget->setLayout(layoutTabs); centralwidget->setLayout(layoutTabs);
// plot setup
myPlot = new qDrawPlot(dockWidgetPlot,myDet);cout<<"DockPlot ready"<<endl;
dockWidgetPlot->setWidget(myPlot);
//tabs setup //tabs setup
tabs = new MyTabWidget(this); tabs = new MyTabWidget(this);
layoutTabs->addWidget(tabs); layoutTabs->addWidget(tabs);
// creating all the tab widgets
tab_messages = new qTabMessages (this, myDet); cout<<"Messages ready"<<endl;
// creating the messages tab before the plots and detector to catch config stdout
tab_messages = new qTabMessages (this); cout<<"Messages ready"<<endl;
// settings up detector
SetUpDetector(fName);
// plot setup
myPlot = new qDrawPlot(dockWidgetPlot,myDet);cout<<"DockPlot ready"<<endl;
dockWidgetPlot->setWidget(myPlot);
//settings messages to have the det reference
tab_messages->SetDetectorReference(myDet);
// creating all the other tab widgets
tab_measurement = new qTabMeasurement (this, myDet,myPlot); cout<<"Measurement ready"<<endl; tab_measurement = new qTabMeasurement (this, myDet,myPlot); cout<<"Measurement ready"<<endl;
tab_dataoutput = new qTabDataOutput (this, myDet); cout<<"DataOutput ready"<<endl; tab_dataoutput = new qTabDataOutput (this, myDet); cout<<"DataOutput ready"<<endl;
tab_plot = new qTabPlot (this, myDet,myPlot); cout<<"Plot ready"<<endl; tab_plot = new qTabPlot (this, myDet,myPlot); cout<<"Plot ready"<<endl;
@ -132,6 +139,7 @@ void qDetectorMain::SetUpWidgetWindow(){
tabs->insertTab(Developer, scroll[Developer], "Developer"); tabs->insertTab(Developer, scroll[Developer], "Developer");
// Prefer this to expand and not have scroll buttons // Prefer this to expand and not have scroll buttons
tabs->insertTab(Messages, tab_messages, "Messages"); tabs->insertTab(Messages, tab_messages, "Messages");
// Default tab color // Default tab color
defaultTabColor = tabs->tabBar()->tabTextColor(DataOutput); defaultTabColor = tabs->tabBar()->tabTextColor(DataOutput);
//Set the current tab(measurement) to blue as it is the current one //Set the current tab(measurement) to blue as it is the current one
@ -267,7 +275,7 @@ void qDetectorMain::Initialization(){
void qDetectorMain::LoadConfigFile(const string fName){ void qDetectorMain::LoadConfigFile(const string fName){
#ifdef VERBOSe #ifdef VERBOSE
cout << "Loading config file at start up:" << fName << endl; cout << "Loading config file at start up:" << fName << endl;
#endif #endif
QString file = QString(fName.c_str());//.section('/',-1); QString file = QString(fName.c_str());//.section('/',-1);

View File

@ -16,6 +16,8 @@
#include <QFile> #include <QFile>
#include <QTextStream> #include <QTextStream>
#include <QFileDialog> #include <QFileDialog>
/** C++ Include Headers */ /** C++ Include Headers */
#include <iostream> #include <iostream>
#include <string> #include <string>
@ -23,7 +25,7 @@ using namespace std;
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
qTabMessages::qTabMessages(QWidget *parent,multiSlsDetector*& detector):QWidget(parent),myDet(detector){ qTabMessages::qTabMessages(QWidget *parent):QWidget(parent),myDet(0){
SetupWidgetWindow(); SetupWidgetWindow();
Initialization(); Initialization();
} }
@ -33,6 +35,7 @@ qTabMessages::qTabMessages(QWidget *parent,multiSlsDetector*& detector):QWidget(
qTabMessages::~qTabMessages(){ qTabMessages::~qTabMessages(){
delete myDet; delete myDet;
delete dispLog; delete dispLog;
delete qout;
} }
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
@ -62,7 +65,11 @@ void qTabMessages::SetupWidgetWindow(){
gridLayout->addItem(new QSpacerItem(15,10,QSizePolicy::Fixed,QSizePolicy::Fixed),2,0); gridLayout->addItem(new QSpacerItem(15,10,QSizePolicy::Fixed,QSizePolicy::Fixed),2,0);
gridLayout->addWidget(dispLog,3,0,1,5); gridLayout->addWidget(dispLog,3,0,1,5);
qout=new qDebugStream(std::cout,this); qout=new qDebugStream(cout,cerr, this);cout<<"working!"<<endl;
//qerr=new qDebugStream(cerr,this);
//qerr=NULL;
//qerr=new qDebugStream(std::cerr,this);cout<<"worked!"<<endl;
} }
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
@ -82,6 +89,7 @@ void qTabMessages::customEvent(QEvent *e) {
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabMessages::SaveLog() { void qTabMessages::SaveLog() {
//cerr<<endl<<"ERRRORRRR"<<endl<<endl;
QString fName = QString(myDet->getFilePath().c_str()); QString fName = QString(myDet->getFilePath().c_str());
fName = fName+"/LogFile.txt"; fName = fName+"/LogFile.txt";
fName = QFileDialog::getSaveFileName(this,tr("Save Snapshot "), fName = QFileDialog::getSaveFileName(this,tr("Save Snapshot "),