Added a progress bar to NeuroUI

This commit is contained in:
mandlm 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);
emit progress((double)iteration / (double)numIterations);
}
}
catch (std::exception &ex)

View File

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

View File

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