-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
52 lines (38 loc) · 1.42 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "mainwindow.h"
#include <QApplication>
#include <QLocale>
#include <QTranslator>
#include <QThread>
#include <QTime>
#include "evolutionmachine.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
app.setOrganizationName("HAJ");
app.setApplicationName("Drawin");
QTranslator translator;
if (translator.load(QLocale::system(), ""))
app.installTranslator(&translator);
qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
EvolutionMachine *evolutionMachine = new EvolutionMachine;
#ifdef USE_THREAD
QThread workerThread;
evolutionMachine->moveToThread(&workerThread);
workerThread.start();
#endif
MainWindow window;
QObject::connect(evolutionMachine, SIGNAL(newSolutionGenerated(QImage)),
&window, SLOT (updateImage (QImage)));
QObject::connect(&window, SIGNAL(mutationRateChanged(double)),
evolutionMachine, SLOT (setMutationRate (double)));
QObject::connect(&window, SIGNAL(requestNewSolution (QString)),
evolutionMachine, SLOT (resetAndStartNewSolutionGeneration(QString)));
window.show();
int returnCode = app.exec();
#ifdef USE_THREAD
workerThread.quit();
workerThread.wait();
#endif
delete evolutionMachine; evolutionMachine = Q_NULLPTR;
return returnCode;
}