Neuro/gui/NeuroUI/neuroui.cpp

64 lines
1.5 KiB
C++
Raw Normal View History

2015-10-24 12:44:33 +00:00
#include "neuroui.h"
#include "ui_neuroui.h"
NeuroUI::NeuroUI(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::NeuroUI)
{
ui->setupUi(this);
ui->logView->addItem("Ready.");
2015-10-24 12:44:33 +00:00
}
NeuroUI::~NeuroUI()
{
delete ui;
}
void NeuroUI::on_runButton_clicked()
{
ui->logView->clear();
ui->errorPlotter->clear();
if (m_netLearner == nullptr)
{
m_netLearner.reset(new NetLearner);
}
connect(m_netLearner.get(), &NetLearner::logMessage, this, &NeuroUI::logMessage);
2015-10-25 08:51:09 +00:00
connect(m_netLearner.get(), &NetLearner::progress, this, &NeuroUI::progress);
connect(m_netLearner.get(), &NetLearner::started, this, &NeuroUI::netLearnerStarted);
connect(m_netLearner.get(), &NetLearner::finished, this, &NeuroUI::netLearnerFinished);
connect(m_netLearner.get(), &NetLearner::currentNetError, ui->errorPlotter, &ErrorPlotter::addErrorValue);
m_netLearner->start();
}
void NeuroUI::logMessage(const QString &logMessage)
{
ui->logView->addItem(logMessage);
ui->logView->scrollToBottom();
}
void NeuroUI::netLearnerStarted()
{
ui->runButton->setEnabled(false);
2015-10-25 08:51:09 +00:00
ui->progressBar->setValue(0);
}
void NeuroUI::netLearnerFinished()
{
ui->runButton->setEnabled(true);
2015-10-25 08:51:09 +00:00
ui->progressBar->setValue(0);
}
void NeuroUI::progress(double progress)
{
double range = ui->progressBar->maximum() - ui->progressBar->minimum();
int value = ui->progressBar->minimum() + (int)(progress * range);
ui->progressBar->setValue(value);
}