Added a progress bar to NeuroUI
This commit is contained in:
parent
6943fc0116
commit
2b84b8a054
@ -54,6 +54,8 @@ void NetLearner::run()
|
||||
}
|
||||
|
||||
myNet.backProp(targetValues);
|
||||
|
||||
emit progress((double)iteration / (double)numIterations);
|
||||
}
|
||||
}
|
||||
catch (std::exception &ex)
|
||||
|
@ -12,6 +12,7 @@ private:
|
||||
|
||||
signals:
|
||||
void logMessage(const QString &logMessage);
|
||||
void progress(double progress);
|
||||
};
|
||||
|
||||
#endif // NETLEARNER_H
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ private slots:
|
||||
void logMessage(const QString &logMessage);
|
||||
void netLearnerStarted();
|
||||
void netLearnerFinished();
|
||||
void progress(double progress);
|
||||
|
||||
private:
|
||||
Ui::NeuroUI *ui;
|
||||
|
@ -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>
|
||||
|
Reference in New Issue
Block a user