mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-01-16 10:44:39 +01:00
WIP
This commit is contained in:
@@ -40,7 +40,6 @@ set(HEADERS
|
|||||||
slsDetectorPlotting/include/SlsQt2DPlotLayout.h
|
slsDetectorPlotting/include/SlsQt2DPlotLayout.h
|
||||||
slsDetectorPlotting/include/SlsQt2DZoomer.h
|
slsDetectorPlotting/include/SlsQt2DZoomer.h
|
||||||
include/qDefs.h
|
include/qDefs.h
|
||||||
include/qDebugStream.h
|
|
||||||
include/qDetectorMain.h
|
include/qDetectorMain.h
|
||||||
include/qDrawPlot.h
|
include/qDrawPlot.h
|
||||||
include/qCloneWidget.h
|
include/qCloneWidget.h
|
||||||
|
|||||||
@@ -1,95 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <QApplication>
|
|
||||||
#include <QCustomEvent>
|
|
||||||
#include <QString>
|
|
||||||
#include <QWidget>
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <streambuf>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#define STREAMEVENT 60001
|
|
||||||
|
|
||||||
|
|
||||||
class qStreamEvent : public QEvent {
|
|
||||||
public:
|
|
||||||
qStreamEvent(QString s) : QEvent(static_cast<QEvent::Type>(STREAMEVENT)), str(s) {
|
|
||||||
#ifdef PRINT_LOG
|
|
||||||
printf("%s\n", str.toAscii().constData());
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
/** \returns the progress index */
|
|
||||||
QString getString() { return str; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
QString str;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class qDebugStream : public std::basic_streambuf<char> {
|
|
||||||
|
|
||||||
public:
|
|
||||||
qDebugStream(std::ostream &stream, QWidget *w) : m_stream(stream), log_window(w) {
|
|
||||||
pthread_mutex_init(&mutex, NULL);
|
|
||||||
m_old_buf = stream.rdbuf();
|
|
||||||
stream.rdbuf(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
~qDebugStream() {
|
|
||||||
// output anything that is left
|
|
||||||
if (!m_string.empty()) {
|
|
||||||
pthread_mutex_lock(&mutex);
|
|
||||||
const char *c_string = m_string.c_str();
|
|
||||||
QApplication::postEvent(log_window, new qStreamEvent(c_string));
|
|
||||||
pthread_mutex_unlock(&mutex);
|
|
||||||
}
|
|
||||||
m_stream.rdbuf(m_old_buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual int_type overflow(int_type v) {
|
|
||||||
if (v == '\n') {
|
|
||||||
pthread_mutex_lock(&mutex);
|
|
||||||
const char *c_string = m_string.c_str();
|
|
||||||
QApplication::postEvent(log_window, new qStreamEvent(c_string));
|
|
||||||
m_string.erase(m_string.begin(), m_string.end());
|
|
||||||
pthread_mutex_unlock(&mutex);
|
|
||||||
} else
|
|
||||||
m_string += v;
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
virtual std::streamsize xsputn(const char *p, std::streamsize n) {
|
|
||||||
pthread_mutex_lock(&mutex);
|
|
||||||
m_string.append(p, p + n);
|
|
||||||
|
|
||||||
//changed from uint because of 64 bit
|
|
||||||
size_t pos = 0;
|
|
||||||
|
|
||||||
while (pos != std::string::npos) {
|
|
||||||
pos = m_string.find('\n');
|
|
||||||
if (pos != std::string::npos) {
|
|
||||||
std::string tmp(m_string.begin(), m_string.begin() + pos);
|
|
||||||
const char *c_tmp = tmp.c_str();
|
|
||||||
QApplication::postEvent(log_window, new qStreamEvent(c_tmp));
|
|
||||||
m_string.erase(m_string.begin(), m_string.begin() + pos + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pthread_mutex_unlock(&mutex);
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
pthread_mutex_t mutex;
|
|
||||||
std::ostream &m_stream;
|
|
||||||
std::streambuf *m_old_buf;
|
|
||||||
std::string m_string;
|
|
||||||
QWidget *log_window;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "ui_form_tab_messages.h"
|
#include "ui_form_tab_messages.h"
|
||||||
#include "qDebugStream.h"
|
|
||||||
|
|
||||||
class QProcess;
|
class QProcess;
|
||||||
|
|
||||||
@@ -15,7 +14,6 @@ public:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void ExecuteCommand();
|
void ExecuteCommand();
|
||||||
void customEvent(QEvent *e);
|
|
||||||
void SaveLog();
|
void SaveLog();
|
||||||
void ClearLog();
|
void ClearLog();
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#include "qTabMessages.h"
|
#include "qTabMessages.h"
|
||||||
#include "qDefs.h"
|
#include "qDefs.h"
|
||||||
|
|
||||||
#include <QEvent>
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
@@ -28,9 +27,6 @@ void qTabMessages::SetupWidgetWindow() {
|
|||||||
process->setWorkingDirectory(QDir::cleanPath(QDir::currentPath()));
|
process->setWorkingDirectory(QDir::cleanPath(QDir::currentPath()));
|
||||||
PrintNextLine();
|
PrintNextLine();
|
||||||
|
|
||||||
qDebugStream(std::cout, this);
|
|
||||||
qDebugStream(std::cerr, this);
|
|
||||||
|
|
||||||
Initialization();
|
Initialization();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,13 +75,6 @@ void qTabMessages::AppendError() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void qTabMessages::customEvent(QEvent *e) {
|
|
||||||
if (e->type() == (STREAMEVENT)) {
|
|
||||||
QString temp = ((qStreamEvent *)e)->getString();
|
|
||||||
dispLog->append(temp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void qTabMessages::SaveLog() {
|
void qTabMessages::SaveLog() {
|
||||||
QString fName = QDir::cleanPath(QDir::currentPath()) + "/LogFile.txt";
|
QString fName = QDir::cleanPath(QDir::currentPath()) + "/LogFile.txt";
|
||||||
fName = QFileDialog::getSaveFileName(this, tr("Save Snapshot "),
|
fName = QFileDialog::getSaveFileName(this, tr("Save Snapshot "),
|
||||||
|
|||||||
Reference in New Issue
Block a user