-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.cpp
109 lines (83 loc) · 3.5 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
// Copyright 2019 ESRI
//
// All rights reserved under the copyright laws of the United States
// and applicable international laws, treaties, and conventions.
//
// You may freely redistribute and use this sample code, with or
// without modification, provided you include the original copyright
// notice and use restrictions.
//
// See the Sample code usage restrictions document for further information.
//
#ifdef Q_OS_WIN
#include <Windows.h>
#endif
#include "AppInfo.h"
#include "RDT.h"
#include "ArcGISRuntimeEnvironment.h"
#include "MapQuickView.h"
#include <QDir>
#include <QGuiApplication>
#include <QMessageBox>
#include <QSettings>
#include <QQmlApplicationEngine>
//------------------------------------------------------------------------------
#define kSettingsFormat QSettings::IniFormat
//------------------------------------------------------------------------------
#define STRINGIZE(x) #x
#define QUOTE(x) STRINGIZE(x)
//------------------------------------------------------------------------------
using namespace Esri::ArcGISRuntime;
int main(int argc, char *argv[])
{
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
QCoreApplication::setApplicationName(kApplicationName);
QCoreApplication::setApplicationVersion(kApplicationVersion);
QCoreApplication::setOrganizationName(kOrganizationName);
#ifdef Q_OS_MAC
QCoreApplication::setOrganizationDomain(kOrganizationName);
#else
QCoreApplication::setOrganizationDomain(kOrganizationDomain);
#endif
QSettings::setDefaultFormat(kSettingsFormat);
// Before initializing ArcGIS Runtime, first set the
// ArcGIS Runtime license setting required for your application.
// ArcGISRuntimeEnvironment::setLicense("Place license string in here");
// use this code to check for initialization errors
// QObject::connect(ArcGISRuntimeEnvironment::instance(), &ArcGISRuntimeEnvironment::errorOccurred, [](const Error& error){
// QMessageBox msgBox;
// msgBox.setText(error.message);
// msgBox.exec();
// });
// if (ArcGISRuntimeEnvironment::initialize() == false)
// {
// application.quit();
// return 1;
// }
// Register the map view for QML
qmlRegisterType<MapQuickView>("SimCenter.RDT", 1, 0, "MapView");
// Register the RDT (QQuickItem) for QML
qmlRegisterType<RDT>("SimCenter.RDT", 1, 0, "RDT");
// Initialize application view
QQmlApplicationEngine engine;
// Add the import Path
engine.addImportPath(QDir(QCoreApplication::applicationDirPath()).filePath("qml"));
QString arcGISRuntimeImportPath = QUOTE(ARCGIS_RUNTIME_IMPORT_PATH);
QString arcGISToolkitImportPath = QUOTE(ARCGIS_TOOLKIT_IMPORT_PATH);
#if defined(LINUX_PLATFORM_REPLACEMENT)
// on some linux platforms the string 'linux' is replaced with 1
// fix the replacement paths which were created
QString replaceString = QUOTE(LINUX_PLATFORM_REPLACEMENT);
arcGISRuntimeImportPath = arcGISRuntimeImportPath.replace(replaceString, "linux", Qt::CaseSensitive);
arcGISToolkitImportPath = arcGISToolkitImportPath.replace(replaceString, "linux", Qt::CaseSensitive);
#endif
// Add the Runtime and Extras path
engine.addImportPath(arcGISRuntimeImportPath);
// Add the Toolkit path
engine.addImportPath(arcGISToolkitImportPath);
// Set the source
engine.load(QUrl(kApplicationSourceUrl));
return app.exec();
}
//------------------------------------------------------------------------------