246 lines
7.5 KiB
C++
Executable File
246 lines
7.5 KiB
C++
Executable File
/*
|
|
**
|
|
** @RDE_HEADER@
|
|
** Showing artefacts when drawing 3D map.
|
|
** $Id$
|
|
** $HeadURL$
|
|
** $Author$
|
|
**
|
|
** -----------------------------------------------------------------------------------------------
|
|
**
|
|
** Hardware-Environment: Intel-PC
|
|
** Software-Environment: Windows 7, Linux, Qt 5.9. ArcGISRuntimeQt 100.1
|
|
**
|
|
** Language ........: C++ 11
|
|
**
|
|
** -----------------------------------------------------------------------------------------------
|
|
**
|
|
** Author ...........: Jörg Turla, SPD G, Tel. 3132
|
|
**
|
|
** -----------------------------------------------------------------------------------------------
|
|
**
|
|
** Notes .........:
|
|
**
|
|
** 08.11.2017, JT : Initial
|
|
**
|
|
** -----------------------------------------------------------------------------------------------
|
|
*/
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QtCore/QDir>
|
|
#include <QtCore/QUrl>
|
|
#include <QtCore/QDebug>
|
|
|
|
#include <QtGui/QSurface>
|
|
|
|
#include <QtNetwork/QNetworkProxy>
|
|
|
|
#include <QtWidgets/QApplication>
|
|
#include <QtWidgets/QDesktopWidget>
|
|
#include <QtWidgets/QComboBox>
|
|
#include <QtWidgets/QHBoxLayout>
|
|
#include <QtWidgets/QMessageBox>
|
|
#include <QtWidgets/QPushButton>
|
|
|
|
#include <QtWidgets/QGraphicsScene>
|
|
#include <QtWidgets/QGraphicsProxyWidget>
|
|
|
|
|
|
#include <QtWidgets/QMainWindow>
|
|
|
|
#include <Map.h>
|
|
#include <Scene.h>
|
|
#include <SceneGraphicsView.h>
|
|
#include <GraphicsOverlay.h>
|
|
#include <GeoView.h>
|
|
#include <Basemap.h>
|
|
#include <ArcGISTiledLayer.h>
|
|
#include <Layer.h>
|
|
#include <GraphicsOverlay.h>
|
|
|
|
#include "ViewshedLocation.h"
|
|
|
|
|
|
|
|
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
*
|
|
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
|
|
class MapWindow : public QWidget
|
|
{
|
|
|
|
Esri::ArcGISRuntime::Basemap * m_basemap;
|
|
Esri::ArcGISRuntime::Scene * m_scene;
|
|
Esri::ArcGISRuntime::SceneGraphicsView * m_sceneGraphicsView;
|
|
Esri::ArcGISRuntime::GeoView * m_mapView;
|
|
Esri::ArcGISRuntime::GraphicsOverlay * m_graphicsOverlay;
|
|
|
|
Qt::MouseButton m_pressedMouseButton;
|
|
QPoint m_mouseMoveRefPos;
|
|
Esri::ArcGISRuntime::TaskWatcher m_pickingTask;
|
|
bool m_pendingRequest;
|
|
|
|
public:
|
|
|
|
MapWindow() : QWidget(), m_graphicsOverlay(nullptr), m_pickingTask(), m_pendingRequest(false)
|
|
{
|
|
m_pressedMouseButton = Qt::MouseButton::NoButton;
|
|
m_mouseMoveRefPos = QPoint();
|
|
|
|
m_basemap = new Esri::ArcGISRuntime::Basemap(this);
|
|
m_scene = new Esri::ArcGISRuntime::Scene(m_basemap,this);
|
|
|
|
connect( m_basemap, &Esri::ArcGISRuntime::Map::errorOccurred , this, &MapWindow::onErrorBasemap );
|
|
connect( m_scene , &Esri::ArcGISRuntime::Scene::errorOccurred, this, &MapWindow::onErrorScene );
|
|
connect( m_scene , &Esri::ArcGISRuntime::Scene::doneLoading , this, &MapWindow::onDoneLoading );
|
|
|
|
m_sceneGraphicsView = nullptr;
|
|
try
|
|
{
|
|
m_sceneGraphicsView = new Esri::ArcGISRuntime::SceneGraphicsView(); // no parent,
|
|
m_sceneGraphicsView->setObjectName(QLatin1String("EsriSceneView"));
|
|
m_sceneGraphicsView->setFrameShape(QFrame::NoFrame); // frameless
|
|
}
|
|
catch (std::exception &stdEx)
|
|
{
|
|
const char *what = stdEx.what();
|
|
if (what)
|
|
qCritical()<< "MapWindow init SceneGraphicsView: std Exception " << " what: '" << what << "'";
|
|
else
|
|
qCritical() << "MapWindow init SceneGraphicsView: std Exception";
|
|
|
|
throw; // re-throw
|
|
}
|
|
catch (...)
|
|
{
|
|
qCritical() << "MapWindow init SceneGraphicsView: unknown Exception";
|
|
throw; // re-throw
|
|
}
|
|
|
|
if (!m_sceneGraphicsView)
|
|
return;
|
|
|
|
m_sceneGraphicsView->setArcGISScene(m_scene);
|
|
|
|
QHBoxLayout *layout = new QHBoxLayout(this);
|
|
layout->addWidget(m_sceneGraphicsView);
|
|
|
|
initMapLayer(QLatin1String("http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"));
|
|
initMapLayer(QLatin1String("http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"));
|
|
|
|
Esri::ArcGISRuntime::Camera camera(28.4, 83.9, 10010.0, 10.0, 80.0, 300.0);
|
|
m_sceneGraphicsView->setViewpointCameraAndWait(camera);// set the viewpoint
|
|
|
|
/*
|
|
QPushButton * aButton = new QPushButton(tr("Click me")); // toplevel widget
|
|
QGraphicsProxyWidget *proxy = m_sceneGraphicsView->QGraphicsView::scene()->addWidget(aButton);
|
|
proxy->setOpacity(0.99);
|
|
|
|
connect( aButton, &QPushButton::clicked, this, []() {qCritical() << "A Button has been clicked!";} );
|
|
*/
|
|
|
|
QTimer *timer = new QTimer(this);
|
|
timer->setSingleShot(true);
|
|
timer->setInterval(5000);
|
|
connect(timer, &QTimer::timeout, this, [this]() {
|
|
|
|
qCritical() << "Create viewshed ...";
|
|
ViewshedLocation * vLoc = new ViewshedLocation(this);
|
|
vLoc->init(m_sceneGraphicsView);
|
|
});
|
|
timer->start();
|
|
|
|
|
|
} // MapWindow()
|
|
|
|
|
|
~MapWindow() = default;
|
|
|
|
|
|
void initMapLayer( const QString &mapServiceUrl )
|
|
{
|
|
Esri::ArcGISRuntime::ArcGISTiledLayer *tiledLayer = new Esri::ArcGISRuntime::ArcGISTiledLayer(QUrl(mapServiceUrl), this);
|
|
tiledLayer->setName(mapServiceUrl);
|
|
tiledLayer->setObjectName(tiledLayer->name());
|
|
|
|
m_basemap->baseLayers()->append(tiledLayer);
|
|
|
|
} // void initMapLayer()
|
|
|
|
private:
|
|
|
|
void onDoneLoading(const Esri::ArcGISRuntime::Error &loadError)
|
|
{
|
|
|
|
} // void onDoneLoading(const Esri::ArcGISRuntime::Error &loadError)
|
|
|
|
|
|
void onErrorBasemap(const Esri::ArcGISRuntime::Error &error)
|
|
{
|
|
qCritical() << " ---EsriError,Basemap --- occured: "
|
|
<< " code=" << error.code()
|
|
<< " domain=" << (int)error.domain()
|
|
<< " extendedErrorType=" << (int)error.extendedErrorType()
|
|
<< ", message='" << error.message() << "'";
|
|
} // void onErrorBasemap(const Esri::ArcGISRuntime::Error &error)
|
|
|
|
|
|
void onErrorScene(const Esri::ArcGISRuntime::Error &error)
|
|
{
|
|
qCritical() << " ---EsriError, Scene --- occured: "
|
|
<< " code=" << error.code()
|
|
<< " domain=" << (int)error.domain()
|
|
<< " extendedErrorType=" << (int)error.extendedErrorType()
|
|
<< ", message='" << error.message() << "'";
|
|
} // void onErrorScene(const Esri::ArcGISRuntime::Error &error)
|
|
|
|
|
|
}; // MapWindow
|
|
|
|
|
|
int main(int argc, char* argv[])
|
|
{
|
|
QApplication app(argc,argv);
|
|
|
|
// ESRI :
|
|
#ifdef Q_OS_WIN
|
|
// Force usage of OpenGL ES through ANGLE on Windows
|
|
QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);
|
|
#endif
|
|
// : ESRI
|
|
|
|
#define PROXY
|
|
#ifdef PROXY
|
|
QNetworkProxy proxy;
|
|
proxy.setType(QNetworkProxy::HttpProxy);
|
|
proxy.setHostName(QStringLiteral("proxy-rde"));
|
|
proxy.setPort(8080);
|
|
proxy.setUser(QStringLiteral("norbert.thoden@rheinmetall.com"));
|
|
proxy.setPassword(QStringLiteral("RDEWWW11"));
|
|
QNetworkProxy::setApplicationProxy(proxy);
|
|
#endif
|
|
|
|
MapWindow * mapWin = new MapWindow();
|
|
|
|
QDesktopWidget wid;
|
|
|
|
int width = mapWin->frameGeometry().width();
|
|
int height = mapWin->frameGeometry().height();
|
|
|
|
int screenWidth = wid.screen()->width();
|
|
int screenHeight = wid.screen()->height();
|
|
|
|
mapWin->setGeometry((screenWidth / 2) - (width / 2), (screenHeight / 2) - (height / 2), width, height);
|
|
|
|
mapWin->show();
|
|
|
|
app.setQuitOnLastWindowClosed(true);
|
|
|
|
int retval = app.exec();
|
|
|
|
delete mapWin;
|
|
|
|
return retval;
|
|
|
|
} // main
|