/
main.cpp
147 lines (115 loc) · 3.01 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
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
144
145
146
147
#include <cstdlib>
#include <time.h> // init rand
#include "tests.h"
#include "MainWindow.h"
#include "LevelDesignerModel.h"
#include "LevelDesignerScribbleView.h"
#include "GameInfo.h"
#include "LevelInfo.h"
#include <QtQml>
#define TESTPOINT 0
#define TESTVECTOR 0
#define TESTPOLYGON 0
#define TESTMODELVIEW 0
#define XML 0
#define GUI 1
#define GNUPLOT 0
#define QML 0
#define Thumbnail 0
#define PORTAL 0
#if Thumbnail
# include "ThumbnailCreator.h"
# include <QLabel>
#endif
#if QML
# include <QGuiApplication>
# include <QQmlApplicationEngine>
#endif
#if GUI
# include <QApplication>
#endif
#if PORTAL
# include "Portal.h"
#endif
int main(int argc, char** argv) {
srand(time(NULL)); // init rand;
#if PORTAL
Portal p(Segment(10, 40, 10, 20), Segment(40, 10, 20, 10));
std::vector<Segment> lines(p.deviateLine(Segment(20, 40, 0, 30)));
for (const Segment& line: lines)
std::cerr << line << std::endl;
#endif
#if Thumbnail
QApplication app(argc, argv);
PolygonList polygonList;
//polygonList << poc::Polygon(30, 250, 21, 260, 5);
poc::Polygon polygon;
polygon << Point2d(55, 55)
<< Point2d(455, 55)
<< Point2d(455, 455)
<< Point2d(155, 455)
<< Point2d(155, 255)
<< Point2d(255, 255)
<< Point2d(255, 355)
<< Point2d(355, 355)
<< Point2d(355, 155)
<< Point2d(55, 155);
polygonList << polygon;
qDebug() << polygonList;
ThumbnailCreator thumbnailCreator(polygonList);
QImage thumbnail = thumbnailCreator.makeThumbnail();
QLabel* label = new QLabel;
label->setPixmap(QPixmap::fromImage(thumbnail));
label->show();
return app.exec();
#endif
#if TESTPOINT
Test::test<< Point2d();
#endif
#if TESTVECTOR
Test::testVector2d();
#endif
#if TESTPOLYGON
Test::testPolygon();
#endif
#if GUI
QApplication app(argc, argv);
// QFontDatabase::addApplicationFont("../PieceOfCake/fonts/edosz.ttf");
// QFontDatabase::addApplicationFont("../PieceOfCake/fonts/watermark.ttf");
qmlRegisterType<GameInfo>("gameinfo", 1, 0, "GameInfo");
qmlRegisterType<LevelInfo>("levelinfo", 1, 0, "LevelInfo");
MainWindow window;
window.show();
return app.exec();
#endif
#if QML
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
return app.exec();
#endif
#if GNUPLOT
// poc::Polygon polygon;
// polygon << << Point2d() << << Point2d(0, 1) << << Point2d(1, 1) << << Point2d(1);
poc::Polygon polygon(0, 100, 0, 100, 7);
// std::vector<Point2d> vertices = polygon.getVertices();
// for (unsigned int k = 0; k < vertices.size(); ++k)
// std::cerr << vertices.at(k).getX() << " " << vertices.at(k).getY() << " " << -10 << std::endl;
float size = 300;
float delta = 10;
int max = size/delta;
float** matrix = polygon.surface(size, delta);
for (int i = 0; i < max; ++i) {
for (int j = 0; j < max; ++j) {
std::cerr << i << " " << j << " " << matrix[i][j] << std::endl;
}
delete[] matrix[i];
}
delete[] matrix;
#endif
#if XML
Test::testXML();
#else
return EXIT_SUCCESS;
#endif
}