From 8d8ff91cb6a0e2d70136b14e45b8c178b3ef81ae Mon Sep 17 00:00:00 2001 From: Georgi Tushev Date: Fri, 21 Dec 2018 10:38:28 +0100 Subject: [PATCH] add new GUI --- BrainATUMtome/BrainATUMtome.pro | 6 +- BrainATUMtome/eventlog.cpp | 47 +++ BrainATUMtome/eventlog.h | 29 ++ BrainATUMtome/mainwindow.cpp | 78 +---- BrainATUMtome/mainwindow.h | 15 +- BrainATUMtome/mainwindow.ui | 553 +++++++++++++++++++++++--------- 6 files changed, 485 insertions(+), 243 deletions(-) create mode 100644 BrainATUMtome/eventlog.cpp create mode 100644 BrainATUMtome/eventlog.h diff --git a/BrainATUMtome/BrainATUMtome.pro b/BrainATUMtome/BrainATUMtome.pro index cfc54d0..4fcf917 100644 --- a/BrainATUMtome/BrainATUMtome.pro +++ b/BrainATUMtome/BrainATUMtome.pro @@ -26,10 +26,12 @@ CONFIG += c++11 SOURCES += \ main.cpp \ - mainwindow.cpp + mainwindow.cpp \ + eventlog.cpp HEADERS += \ - mainwindow.h + mainwindow.h \ + eventlog.h FORMS += \ mainwindow.ui diff --git a/BrainATUMtome/eventlog.cpp b/BrainATUMtome/eventlog.cpp new file mode 100644 index 0000000..bf48855 --- /dev/null +++ b/BrainATUMtome/eventlog.cpp @@ -0,0 +1,47 @@ +#include "eventlog.h" + +EventLog::EventLog(QWidget *parent) : QPlainTextEdit (parent), + m_useTimestamp(true) +{ + +} + + +void EventLog::setTimestamp(bool state) +{ + m_useTimestamp = state; +} + + +void EventLog::addMessageToBoard(const QString &message, QBrush brush) +{ + QTextCharFormat textFormat = this->currentCharFormat(); + textFormat.setForeground(brush); + this->setCurrentCharFormat(textFormat); + this->appendPlainText(message); + this->verticalScrollBar()->setValue(this->verticalScrollBar()->maximum()); +} + + +void EventLog::on_log(EventLogType type, const QString &message) +{ + auto brush = QBrush(); + + if (type == EventLogType::Notify) { + brush.setColor(Qt::black); + } + else if (type == EventLogType::Log) { + brush.setColor(Qt::gray); + } + else if (type == EventLogType::Warn) { + brush.setColor(Qt::red); + } + + QString logMessage = message; + if (m_useTimestamp) { + QString timestamp = QDateTime::currentDateTime().toString("[yyyyMMdd hh:mm:ss]"); + logMessage = timestamp + " " + logMessage; + } + + addMessageToBoard(logMessage, brush); +} diff --git a/BrainATUMtome/eventlog.h b/BrainATUMtome/eventlog.h new file mode 100644 index 0000000..85b4331 --- /dev/null +++ b/BrainATUMtome/eventlog.h @@ -0,0 +1,29 @@ +#ifndef EVENTLOG_H +#define EVENTLOG_H + +#include +#include +#include +#include +#include + + +enum class EventLogType {Notify, Log, Warn}; + +class EventLog : public QPlainTextEdit +{ + Q_OBJECT + +public: + explicit EventLog(QWidget *parent = nullptr); + void setTimestamp(bool state); + +private: + bool m_useTimestamp; + void addMessageToBoard(const QString &message, QBrush brush); + +public slots: + void on_log(EventLogType type, const QString &message); +}; + +#endif // EVENTLOG_H diff --git a/BrainATUMtome/mainwindow.cpp b/BrainATUMtome/mainwindow.cpp index 1e2668a..538acfc 100644 --- a/BrainATUMtome/mainwindow.cpp +++ b/BrainATUMtome/mainwindow.cpp @@ -8,89 +8,17 @@ MainWindow::MainWindow(QWidget *parent) : m_epos_velocity_upper(0) { ui->setupUi(this); -} - -MainWindow::~MainWindow() -{ - delete ui; -} - - -void MainWindow::configure_epos() -{ - auto checkVelocity = new QIntValidator(100, 15000, this); - ui->lineEdit_epos_lower_rpm->setValidator(checkVelocity); - ui->lineEdit_epos_upper_rpm->setValidator(checkVelocity); - -} - - -void MainWindow::on_lineEdit_epos_lower_rpm_editingFinished() -{ - qDebug() << "FINISHED"; -} - - -void MainWindow::on_radioButton_epos_lower_off_toggled(bool checked) -{ - if (!checked) - return; - qDebug() << "OFF " << checked; - ui->radioButton_epos_tension_on->toggle(); -} - -void MainWindow::on_radioButton_epos_lower_ccw_toggled(bool checked) -{ - if (!checked) - return; - emit ui->lineEdit_epos_lower_rpm->editingFinished(); - qDebug() << "CCW " << checked; -} - -void MainWindow::on_radioButton_epos_lower_cw_toggled(bool checked) -{ - if (!checked) - return; - emit ui->lineEdit_epos_lower_rpm->editingFinished(); - qDebug() << "CW " << checked; -} - -void MainWindow::on_lineEdit_epos_upper_rpm_editingFinished() -{ - -} -void MainWindow::on_radioButton_epos_upper_off_toggled(bool checked) -{ - -} - -void MainWindow::on_radioButton_epos_upper_ccw_toggled(bool checked) -{ } -void MainWindow::on_radioButton_epos_upper_cw_toggled(bool checked) -{ - -} - -void MainWindow::on_radioButton_epos_tension_off_toggled(bool checked) -{ - qDebug() << "TENSION_OFF " << checked; -} - -void MainWindow::on_radioButton_epos_tension_on_toggled(bool checked) +MainWindow::~MainWindow() { - qDebug() << "TENSION_ON " << checked; + delete ui; } -void MainWindow::on_radioButton_epos_sync_off_toggled(bool checked) -{ - -} -void MainWindow::on_radioButton_epos_sync_on_toggled(bool checked) +void MainWindow::on_groupBox_epos_tension_toggled(bool arg1) { } diff --git a/BrainATUMtome/mainwindow.h b/BrainATUMtome/mainwindow.h index e2c5360..a17e820 100644 --- a/BrainATUMtome/mainwindow.h +++ b/BrainATUMtome/mainwindow.h @@ -18,28 +18,15 @@ class MainWindow : public QMainWindow private slots: - void on_lineEdit_epos_lower_rpm_editingFinished(); - void on_radioButton_epos_lower_off_toggled(bool checked); - void on_radioButton_epos_lower_ccw_toggled(bool checked); - void on_radioButton_epos_lower_cw_toggled(bool checked); - void on_lineEdit_epos_upper_rpm_editingFinished(); - void on_radioButton_epos_upper_off_toggled(bool checked); - void on_radioButton_epos_upper_ccw_toggled(bool checked); - void on_radioButton_epos_upper_cw_toggled(bool checked); - void on_radioButton_epos_tension_off_toggled(bool checked); - void on_radioButton_epos_tension_on_toggled(bool checked); - - void on_radioButton_epos_sync_off_toggled(bool checked); - void on_radioButton_epos_sync_on_toggled(bool checked); + void on_groupBox_epos_tension_toggled(bool arg1); private: Ui::MainWindow *ui; int m_epos_velocity_lower; int m_epos_velocity_upper; - void configure_epos(); signals: void uirequest_epos_velocity(int motorid, int velocity); diff --git a/BrainATUMtome/mainwindow.ui b/BrainATUMtome/mainwindow.ui index 93c7c08..73f603f 100644 --- a/BrainATUMtome/mainwindow.ui +++ b/BrainATUMtome/mainwindow.ui @@ -6,178 +6,427 @@ 0 0 - 574 - 413 + 1000 + 720 MainWindow - - - - 10 - 20 - 376 - 254 - - - - EPOS - - - - - - MotorLower - - + + + + + - - - CW + + + EPOS + + + + + MotorLower + + + + + + velocity [rpm] + + + + + + + 100 + + + 15000 + + + 1 + + + 1000 + + + + + + + OFF + + + true + + + + + + + CCW + + + + + + + CW + + + + + + + + + + MotorUpper + + + + + + velocity [rpm] + + + + + + + 100 + + + 15000 + + + 1 + + + 1000 + + + + + + + OFF + + + true + + + + + + + CCW + + + + + + + CW + + + + + + + + + + Tension + + + false + + + false + + + + + + OFF + + + true + + + + + + + ON + + + + + + + + + + Sync + + + + + + OFF + + + true + + + + + + + ON + + + + + + + - - - CCW + + + Microtome + + + + + + + cutting speed [um/sec] + + + + + + + 50 + + + 100000 + + + 100 + + + + + + + return speed [um/sec] + + + + + + + + 10000 + + + + + 30000 + + + + + 50000 + + + + + + + + feed step [nm] + + + + + + + false + + + 1 + + + 15000 + + + 30 + + + + + + + sections + + + + + + + 0 + + + true + + + + + + + advance remaining + + + + + + + 0 + + + true + + + + + + + + + + + Cut + + + + + + + Stop + + + + + + - - - OFF - - - true - - - - - - - 1000 - - - - - - - rpm - - - - - - - - - - MotorUpper - - - - - - CW - - - - - - - CCW - - - - - - - OFF - - - true - - - - - - - 1000 - - - - - - - rpm - - - - - - - - - - Tension - - - - - - ON - - - - - - - OFF - - - true - - - - - - - - - - Sync - - - - - - ON - - - - - - - OFF - - - true - - + + + + + Syringe + + + + + + Pump + + + + + + + auto + + + + + + + + + + Camera + + + + + + Snap + + + + + + + Record + + + + + + + - - - - + + + + + + + + + + + FRAME + + + + + + + + + + + + + + + + + + + + + + + + + EventLog + QWidget +
eventlog.h
+ 1 +
+