-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
74 lines (59 loc) · 2.02 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
#include "backend.h"
//#include <QApplication>
#include <QGuiApplication>
#include <QOpenGLContext>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include "heimapmodel.h"
#include <Qt3DQuickExtras/qt3dquickwindow.h>
#include <Qt3DQuick/QQmlAspectEngine>
void setSurfaceFormat()
{
QSurfaceFormat format;
#ifdef QT_OPENGL_ES_2
format.setRenderableType(QSurfaceFormat::OpenGLES);
#else
if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) {
format.setVersion(4, 3);
format.setProfile(QSurfaceFormat::CoreProfile);
}
#endif
format.setDepthBufferSize(24);
format.setSamples(4);
format.setStencilBufferSize(8);
QSurfaceFormat::setDefaultFormat(format);
}
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
//setSurfaceFormat();
// QSurfaceFormat::setDefaultFormat(QQuick3D::idealSurfaceFormat());
qmlRegisterType<HeiMapModel>("My", 1, 0, "HeiMapModel");
QQmlApplicationEngine engine;
Qt3DExtras::Quick::Qt3DQuickWindow view;
// Expose the window as a context property so we can set the aspect ratio
engine.rootContext()->setContextProperty("_window", &view);
const QUrl url(QStringLiteral("qrc:/QML/main.qml"));
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
&app, [url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
}, Qt::QueuedConnection);
qmlRegisterType<InstanseModel>("My", 1, 0, "InstanseModel");
Backend back;
engine.rootContext()->setContextProperty("backend", &back);
engine.rootContext()->setContextProperty("projectParams", &back.proj);
engine.rootContext()->setContextProperty("searchSettings", &back.proj.searchSetts);
engine.load(url);
back.root = engine.rootObjects().first();
back.loadSettings();
// back.loadImage("D:\\1.tif");
// back.loadImage("D:\\Учеба\\БАР\\Москва\\50_60_1_1_2m_v3.0_reg_dem-002.tif");
// TiffReader img;
// img.open("D:\\1.tif");
// img.close();
// return 0;
back.block = false;
return app.exec();
}