Skip to content

Commit

Permalink
Add GUI for adding Quantized Mesh layers
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdkon committed Sep 10, 2024
1 parent 6a9fad7 commit 9f3b5fb
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 23 deletions.
11 changes: 8 additions & 3 deletions src/gui/tiledscene/qgstiledscenedataitemguiprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
***************************************************************************/

#include "qgstiledscenedataitemguiprovider.h"
#include "qgsquantizedmeshdataprovider.h"
#include "qgstiledscenedataitems.h"
#include "qgstiledsceneconnection.h"
#include "qgstiledsceneconnectiondialog.h"
Expand Down Expand Up @@ -52,9 +53,13 @@ void QgsTiledSceneDataItemGuiProvider::populateContextMenu( QgsDataItem *item, Q
if ( QgsTiledSceneRootItem *rootItem = qobject_cast< QgsTiledSceneRootItem * >( item ) )
{
QAction *actionNewCesium = new QAction( tr( "New Cesium 3D Tiles Connection…" ), menu );
connect( actionNewCesium, &QAction::triggered, this, [rootItem] { newCesium3dTilesConnection( rootItem ); } );
connect( actionNewCesium, &QAction::triggered, this, [rootItem] { newConnection( rootItem, "cesiumtiles" ); } );
menu->addAction( actionNewCesium );

QAction *actionNewQM = new QAction( tr( "New Quantized Mesh Connection…" ), menu );
connect( actionNewQM, &QAction::triggered, this, [rootItem] { newConnection( rootItem, "quantizedmesh" ); } );
menu->addAction( actionNewQM );

menu->addSeparator();

QAction *actionSave = new QAction( tr( "Save Connections…" ), menu );
Expand Down Expand Up @@ -100,14 +105,14 @@ void QgsTiledSceneDataItemGuiProvider::duplicateConnection( QgsDataItem *item )
item->parent()->refreshConnections();
}

void QgsTiledSceneDataItemGuiProvider::newCesium3dTilesConnection( QgsDataItem *item )
void QgsTiledSceneDataItemGuiProvider::newConnection( QgsDataItem *item, QString provider )
{
QgsTiledSceneConnectionDialog dlg;
if ( !dlg.exec() )
return;

QgsTiledSceneProviderConnection::Data conn = QgsTiledSceneProviderConnection::decodedUri( dlg.connectionUri() );
conn.provider = QStringLiteral( "cesiumtiles" );
conn.provider = provider;

QgsTiledSceneProviderConnection::addConnection( dlg.connectionName(), conn );

Expand Down
2 changes: 1 addition & 1 deletion src/gui/tiledscene/qgstiledscenedataitemguiprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class QgsTiledSceneDataItemGuiProvider : public QObject, public QgsDataItemGuiPr
private:
static void editConnection( QgsDataItem *item );
static void duplicateConnection( QgsDataItem *item );
static void newCesium3dTilesConnection( QgsDataItem *item );
static void newConnection( QgsDataItem *item, QString provider );
static void saveConnections();
static void loadConnections( QgsDataItem *item );

Expand Down
39 changes: 22 additions & 17 deletions src/gui/tiledscene/qgstiledscenesourceselect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ QgsTiledSceneSourceSelect::QgsTiledSceneSourceSelect( QWidget *parent, Qt::Windo
QMenu *newMenu = new QMenu( btnNew );

QAction *actionNew = new QAction( tr( "New Cesium 3D Tiles Connection…" ), this );
connect( actionNew, &QAction::triggered, this, &QgsTiledSceneSourceSelect::btnNewCesium3DTiles_clicked );
connect( actionNew, &QAction::triggered, this, [ this ]() { newConnection( "cesiumtiles" ); } );
newMenu->addAction( actionNew );

actionNew = new QAction( tr( "New Quantized Mesh Connection…" ), this );
connect( actionNew, &QAction::triggered, this, [ this ]() { newConnection( "quantizedmesh" ); } );
newMenu->addAction( actionNew );

btnNew->setMenu( newMenu );
Expand All @@ -83,22 +87,6 @@ QgsTiledSceneSourceSelect::QgsTiledSceneSourceSelect( QWidget *parent, Qt::Windo
} );
}

void QgsTiledSceneSourceSelect::btnNewCesium3DTiles_clicked()
{
QgsTiledSceneConnectionDialog nc( this );
if ( nc.exec() )
{
QgsTiledSceneProviderConnection::Data connectionData = QgsTiledSceneProviderConnection::decodedUri( nc.connectionUri() );
connectionData.provider = QStringLiteral( "cesiumtiles" );

QgsTiledSceneProviderConnection::addConnection( nc.connectionName(), connectionData );
populateConnectionList();
QgsTiledSceneProviderConnection::setSelectedConnection( nc.connectionName() );
setConnectionListPosition();
emit connectionsChanged();
}
}

void QgsTiledSceneSourceSelect::btnEdit_clicked()
{
const QgsTiledSceneProviderConnection::Data connection = QgsTiledSceneProviderConnection::connection( cmbConnections->currentText() );
Expand Down Expand Up @@ -181,6 +169,23 @@ void QgsTiledSceneSourceSelect::addButtonClicked()
}
}

void QgsTiledSceneSourceSelect::newConnection( QString provider )
{
QgsTiledSceneConnectionDialog nc( this );
if ( nc.exec() )
{
QgsTiledSceneProviderConnection::Data connectionData = QgsTiledSceneProviderConnection::decodedUri( nc.connectionUri() );
connectionData.provider = provider;

QgsTiledSceneProviderConnection::addConnection( nc.connectionName(), connectionData );
populateConnectionList();
QgsTiledSceneProviderConnection::setSelectedConnection( nc.connectionName() );
setConnectionListPosition();
emit connectionsChanged();
}
}


void QgsTiledSceneSourceSelect::populateConnectionList()
{
cmbConnections->blockSignals( true );
Expand Down
4 changes: 2 additions & 2 deletions src/gui/tiledscene/qgstiledscenesourceselect.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ class QgsTiledSceneSourceSelect : public QgsAbstractDataSourceWidget, private Ui

private slots:

//! Opens the create connection dialog to build a new connection
void btnNewCesium3DTiles_clicked();
//! Opens a dialog to edit an existing connection
void btnEdit_clicked();
//! Deletes the selected connection
Expand All @@ -62,6 +60,8 @@ class QgsTiledSceneSourceSelect : public QgsAbstractDataSourceWidget, private Ui
void showHelp();

private:
//! Opens the create connection dialog to build a new connection
void newConnection( QString provider );
void populateConnectionList();
void setConnectionListPosition();
};
Expand Down

0 comments on commit 9f3b5fb

Please sign in to comment.