-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_window.h
More file actions
97 lines (80 loc) · 1.91 KB
/
Copy pathmain_window.h
File metadata and controls
97 lines (80 loc) · 1.91 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include "ui_main_window.h"
#include "petri_dish.h"
#include "histogramdialog.h"
#include <QTimer>
#include <QTime>
#include <QAction>
#include <QString>
#include <QThread>
#include <QPoint>
class MainWindow: public QMainWindow, public Ui::MainWindow {
Q_OBJECT
public:
MainWindow(QWidget *parent = 0, Qt::WFlags flags = 0);
virtual ~MainWindow();
bool isRunning();
public slots:
void set_stats();
void start_stop();
void start();
void stop();
void check_integrity();
void step();
void updt();
void new_world();
void load_world();
void save_world();
void save_as_world();
void autosave_world();
void change_world();
void enableIdleDetect(bool enable);
void checkIdle();
void edit_bug(int x, int y);
protected:
class UpdateThread: public QThread {
public:
UpdateThread(MainWindow *mw, QObject *parent = 0): QThread(parent), done(false), win(mw) {}
~UpdateThread() {
finish();
wait();
}
void finish() {done = true;}
void run() {
QTime midnight(0, 0, 0);
qsrand(midnight.secsTo(QTime::currentTime()));
unsigned int counter = 0;
done = false;
while(!done) {
counter++;
win->updt();
if((counter % 10) == 0)
usleep(1);
//sleep(0);
}
}
protected:
bool done;
MainWindow *win;
};
bool write_to_stream(QDataStream &out);
PetriDish petri_dish;
HistogramDialog *histogramDialog;
int last_time;
QTimer timer, idleTimer;
QPoint last_mouse;
QDateTime idleTime;
QTime update_time;
float updates_per_sec;
QString filename;
bool changed;
bool auto_save;
QTimer autosave_timer;
UpdateThread update_thread;
private slots:
void on_btnHist_clicked();
void histogramClosed();
void on_spinDNAVal_valueChanged(int);
void on_horizontalSlider_valueChanged(int value);
private:
void load_from_file(const QString &fn, bool &running);
};