Added a progress bar to NeuroUI

This commit is contained in:
Michael Mandl 2015-10-25 09:51:09 +01:00
parent 6943fc0116
commit 2b84b8a054
5 changed files with 18 additions and 0 deletions

View file

@ -54,6 +54,8 @@ void NetLearner::run()
} }
myNet.backProp(targetValues); myNet.backProp(targetValues);
emit progress((double)iteration / (double)numIterations);
} }
} }
catch (std::exception &ex) catch (std::exception &ex)

View file

@ -12,6 +12,7 @@ private:
signals: signals:
void logMessage(const QString &logMessage); void logMessage(const QString &logMessage);
void progress(double progress);
}; };
#endif // NETLEARNER_H #endif // NETLEARNER_H

View file

@ -23,6 +23,7 @@ void NeuroUI::on_runButton_clicked()
} }
connect(m_netLearner.get(), &NetLearner::logMessage, this, &NeuroUI::logMessage); connect(m_netLearner.get(), &NetLearner::logMessage, this, &NeuroUI::logMessage);
connect(m_netLearner.get(), &NetLearner::progress, this, &NeuroUI::progress);
connect(m_netLearner.get(), &NetLearner::started, this, &NeuroUI::netLearnerStarted); connect(m_netLearner.get(), &NetLearner::started, this, &NeuroUI::netLearnerStarted);
connect(m_netLearner.get(), &NetLearner::finished, this, &NeuroUI::netLearnerFinished); connect(m_netLearner.get(), &NetLearner::finished, this, &NeuroUI::netLearnerFinished);
@ -39,9 +40,19 @@ void NeuroUI::logMessage(const QString &logMessage)
void NeuroUI::netLearnerStarted() void NeuroUI::netLearnerStarted()
{ {
ui->runButton->setEnabled(false); ui->runButton->setEnabled(false);
ui->progressBar->setValue(0);
} }
void NeuroUI::netLearnerFinished() void NeuroUI::netLearnerFinished()
{ {
ui->runButton->setEnabled(true); ui->runButton->setEnabled(true);
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);
} }

View file

@ -27,6 +27,7 @@ private slots:
void logMessage(const QString &logMessage); void logMessage(const QString &logMessage);
void netLearnerStarted(); void netLearnerStarted();
void netLearnerFinished(); void netLearnerFinished();
void progress(double progress);
private: private:
Ui::NeuroUI *ui; Ui::NeuroUI *ui;

View file

@ -22,6 +22,9 @@
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QProgressBar" name="progressBar"> <widget class="QProgressBar" name="progressBar">
<property name="maximum">
<number>1000</number>
</property>
<property name="value"> <property name="value">
<number>0</number> <number>0</number>
</property> </property>