-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
50 lines (43 loc) · 1.34 KB
/
mainwindow.cpp
File metadata and controls
50 lines (43 loc) · 1.34 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
#include "mainwindow.h"
#include "gridwidget.h"
#include "ui_mainwindowform.h"
#include <QHBoxLayout>
#include <QWidget>
#include <QChartView>
#include <vector>
MainWindow570::MainWindow570(QWidget *parent):QMainWindow{parent}, mMainWindowUI{new Ui::MainWindowForm}
{
mMainWindowUI->setupUi(this);
connect(mMainWindowUI->actionExit, SIGNAL(triggered()), this, SLOT(actionExit_triggered()));
connect(mMainWindowUI->actionReset, SIGNAL(triggered()), this, SLOT(reset()));
resize(antWorld.get_world_size() + extraSpace, antWorld.get_world_size() + extraSpace);
create_world();
timer.start(timeStepInMiliSeconds,this);
}
MainWindow570::~MainWindow570()
{
delete mMainWindowUI;
}
void MainWindow570::timerEvent(QTimerEvent *event)
{
if (event->timerId() == timer.timerId()) {
update();
} else {
QWidget::timerEvent(event);
}
}
void MainWindow570::actionExit_triggered()
{
QApplication::quit();
}
void MainWindow570::reset()
{
antWorld.reset();
}
void MainWindow570::create_world()
{
QHBoxLayout* layoutForFoodandAnts = new QHBoxLayout{mMainWindowUI->gridFrame};
antSimulation = new GridWidget{antWorld, mMainWindowUI->gridFrame};
antSimulation->setStyleSheet("background-color:black");
layoutForFoodandAnts->addWidget(antSimulation);
}