-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.h
143 lines (114 loc) · 3.36 KB
/
mainwindow.h
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QtGui/QApplication>
#include <QMainWindow>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QGraphicsRectItem>
#include <QGraphicsItemAnimation>
#include <QPushButton>
#include <QWidget>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QList>
#include <QLabel>
#include <QTextEdit>
#include <QRadioButton>
#include <QListView>
#include <QString>
#include <QGraphicsItem>
#include <QStandardItemModel>
#include <QTimer>
#include <QTimeLine>
#include <QObject>
#include <stdlib.h>
#include <iostream>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include "board.h"
#include "puzzle_heur.h"
#include "puzzle_solver.h"
#include "pmminlist.h"
#include "guitile.h"
#define WINDOW_MAX_X 250
#define WINDOW_MAX_Y 250
using namespace std;
class MainWindow : public QWidget {
Q_OBJECT
public:
/** Default constructor \n
* QWidget, window, will be the biggest screen that will save Gridlayout. \n
* This Gridlayout contains all top layout, heuristic layout, solution layout, QGraphicscene etc.
*/
explicit MainWindow();
/** Default destructor */
~MainWindow();
/** Create the board with using all the private variables */
void createBoard();
/** Create the top layout that will be contained in Gridlayout
* @return QHBoxLayout that has boxes for input
*/
QHBoxLayout *createTopLayout();
/** Create the heuristic layout that will be contained in Gridlayout
* @return QHBoxLayout that has radio buttons for starting algorithm
*/
QHBoxLayout *createHeurLayout();
void show();
private:
QGraphicsScene *scene;
QGraphicsView *view;
//Here is my implementation
QWidget *window;
// layouts
QGridLayout *layout; // main layout
QHBoxLayout *topLayout; // top input text board layout
QHBoxLayout *heurLayout; // heuristic radio buttons layout
// etc
QStandardItemModel *model; // for saving solList
QListView *solList; // list for displaying solutions
QTextEdit *errMsg; // get error message
// buttons
QPushButton *startGame;
QPushButton *quitGame;
QPushButton *aAlg;
// text boxes
QTextEdit *boardSize;
QTextEdit *startingMoves;
QTextEdit *seedValue;
// labels for topLayout
QLabel *boardSizeLabel;
QLabel *startingMovesLabel;
QLabel *seedValueLabel;
// radio buttons for heurLayout
QRadioButton *man_heur;
QRadioButton *out_heur;
QTimer *timer;
double timerCnt;
int direction;
int tempTileNum;
int size, initMoves, seed;
Board *b;
QList<GUITile*> Qtiles;
public slots:
/** Slot member fuction for starting the game \n
* In this function, it will check whether there are incorrect or invalid values
*/
void gameStart();
/** Move the tile that has particular number. This is for moving instantly (no sliding)
* @param tileNum number of the tile
*/
void MoveTile(int tileNum);
/** Move the tile that has particular number. This is for moving in sliding
* @param tileNum number of the tile
*/
void AnimateTile(int tileNum);
/** Actual function that will move the tile little by little considering the timer */
void SlidingTile();
/** Function that will show the list of solutions in sequence order */
void Qcheat();
};
#endif // MAINWINDOW_H