Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
add new GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
MPIBR-tushevg committed Dec 21, 2018
1 parent b69a4b9 commit 8d8ff91
Show file tree
Hide file tree
Showing 6 changed files with 485 additions and 243 deletions.
6 changes: 4 additions & 2 deletions BrainATUMtome/BrainATUMtome.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
47 changes: 47 additions & 0 deletions BrainATUMtome/eventlog.cpp
Original file line number Diff line number Diff line change
@@ -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);
}
29 changes: 29 additions & 0 deletions BrainATUMtome/eventlog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#ifndef EVENTLOG_H
#define EVENTLOG_H

#include <QObject>
#include <QWidget>
#include <QPlainTextEdit>
#include <QScrollBar>
#include <QDateTime>


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
78 changes: 3 additions & 75 deletions BrainATUMtome/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{

}
15 changes: 1 addition & 14 deletions BrainATUMtome/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 8d8ff91

Please sign in to comment.