Skip to content
Permalink
Browse files
initial implementation
  • Loading branch information
NEDJIMAbelgacem authored and nyalldawson committed Jan 12, 2022
1 parent 6d6b062 commit f49a268fd043ddccc57ff22ed3eb7a7abbf4e6ae
@@ -213,6 +213,11 @@ Qgs3DMapCanvasDockWidget::Qgs3DMapCanvasDockWidget( QWidget *parent )

setWidget( contentsWidget );

connect( this, &Qgs3DMapCanvasDockWidget::closed, [&]()
{
emit widgetClosed( this->windowTitle() );
} );

onTotalPendingJobsCountChanged();
}

@@ -475,3 +480,9 @@ void Qgs3DMapCanvasDockWidget::currentMapThemeRenamed( const QString &theme, con
mCanvas->map()->setTerrainMapTheme( newTheme );
}
}

void Qgs3DMapCanvasDockWidget::setName( const QString &name )
{
setWindowTitle( name );
mapCanvas3D()->setObjectName( name );
}
@@ -51,6 +51,11 @@ class APP_EXPORT Qgs3DMapCanvasDockWidget : public QgsDockWidget

Qgs3DMapToolMeasureLine *measurementLineTool() { return mMapToolMeasureLine; }

void setName( const QString &name );

signals:
void widgetClosed( const QString &name );

private slots:
void resetView();
void configure();
@@ -0,0 +1,126 @@
#include "qgs3dviewsmanager.h"

#include "qgs3dmapcanvasdockwidget.h"
#include <QDebug>
#include "qgsnewnamedialog.h"
#include "qgisapp.h"

Qgs3DViewsManager::Qgs3DViewsManager( QWidget *parent, Qt::WindowFlags f )
: QDialog( parent, f )
{
setupUi( this );
m3DViewsListView->setModel( &mListModel );

m3DViewsListView->setEditTriggers( QAbstractItemView::NoEditTriggers );
m3DViewsListView->setSelectionMode( QAbstractItemView::SingleSelection );

connect( m3DViewsListView, &QListView::clicked, [&]( const QModelIndex & index )
{
mSelectedViewIndex = index.row();
} );

connect( mShowButton, &QToolButton::clicked, [&]()
{
if ( mSelectedViewIndex == -1 )
return;
QString viewName = mListModel.stringList()[ mSelectedViewIndex ];
Qgs3DMapCanvasDockWidget *widget = m3DMapViewsWidgets->value( viewName, nullptr );
if ( !widget )
{
widget = QgisApp::instance()->open3DMapView( viewName );
}
if ( widget )
{
widget->show();
widget->activateWindow();
widget->raise();
}
} );

connect( mRenameButton, &QToolButton::clicked, [&]()
{
if ( mSelectedViewIndex == -1 )
return;
QString oldTitle = mListModel.stringList()[ mSelectedViewIndex ];

QString newTitle;
QgsNewNameDialog dlg( QStringLiteral( "3D view" ), newTitle, QStringList(), m3DMapViewsDom->keys(), Qt::CaseSensitive, this );
dlg.setWindowTitle( "Title" );
dlg.setHintString( "" );
dlg.setOverwriteEnabled( false );
dlg.setAllowEmptyName( false );
dlg.setConflictingNameWarning( tr( "Title already exists!" ) );

if ( dlg.exec() != QDialog::Accepted )
return;
newTitle = dlg.name();

QDomElement dom = m3DMapViewsDom->value( oldTitle );
m3DMapViewsDom->remove( oldTitle );
m3DMapViewsDom->insert( newTitle, dom );
Qgs3DMapCanvasDockWidget *widget = m3DMapViewsWidgets->value( oldTitle, nullptr );
if ( widget )
{
m3DMapViewsWidgets->remove( oldTitle );
m3DMapViewsWidgets->insert( newTitle, widget );
widget->setName( newTitle );
}
reloadListModel();
} );

connect( mDuplicateButton, &QToolButton::clicked, [&]()
{
if ( mSelectedViewIndex == -1 )
return;

QString viewName = mListModel.stringList()[ mSelectedViewIndex ] + "_";

Qgs3DMapCanvasDockWidget *widget = QgisApp::instance()->duplicate3DMapView( mListModel.stringList()[ mSelectedViewIndex ] );
if ( widget )
{
widget->show();
widget->activateWindow();
widget->raise();
}
reloadListModel();
} );

connect( mRemoveButton, &QToolButton::clicked, [&]()
{
if ( mSelectedViewIndex == -1 )
return;
QString viewName = mListModel.stringList()[ mSelectedViewIndex ];
m3DMapViewsDom->remove( viewName );
Qgs3DMapCanvasDockWidget *w = ( *m3DMapViewsWidgets )[ viewName ];
m3DMapViewsWidgets->remove( viewName );
w->close();
reloadListModel();
} );
}

Qgs3DViewsManager::~Qgs3DViewsManager()
{
}

void Qgs3DViewsManager::reload()
{
if ( !m3DMapViewsDom || !m3DMapViewsWidgets )
return;
reloadListModel();
}

void Qgs3DViewsManager::set3DMapViewsDom( QMap<QString, QDomElement> &mapViews3DDom )
{
m3DMapViewsDom = &mapViews3DDom;
reloadListModel();
}

void Qgs3DViewsManager::set3DMapViewsWidgets( QMap<QString, Qgs3DMapCanvasDockWidget *> &mapViews3DWidgets )
{
m3DMapViewsWidgets = &mapViews3DWidgets;
}

void Qgs3DViewsManager::reloadListModel()
{
mListModel.setStringList( m3DMapViewsDom->keys() );
}
@@ -0,0 +1,34 @@
#ifndef QGS3DVIEWSMANAGER_H
#define QGS3DVIEWSMANAGER_H

#include "ui_qgs3dviewsmanager.h"

#include <QDialog>
#include <QStringListModel>
#include <QDomElement>

class Qgs3DMapCanvasDockWidget;

class Qgs3DViewsManager : public QDialog, private Ui::Qgs3DViewsManager
{
Q_OBJECT

public:
explicit Qgs3DViewsManager( QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags() );
~Qgs3DViewsManager();

void reload();

void set3DMapViewsDom( QMap<QString, QDomElement> &mapViews3DDom );
void set3DMapViewsWidgets( QMap<QString, Qgs3DMapCanvasDockWidget *> &mapViews3DWidgets );
private:
QStringListModel mListModel;
int mSelectedViewIndex = -1;

QMap<QString, QDomElement> *m3DMapViewsDom = nullptr;
QMap<QString, Qgs3DMapCanvasDockWidget *> *m3DMapViewsWidgets = nullptr;

void reloadListModel();
};

#endif // QGS3DVIEWSMANAGER_H
@@ -326,6 +326,7 @@ if (WITH_3D)
3d/qgsshadowrenderingsettingswidget.cpp
3d/qgspointcloud3dsymbolwidget.cpp
3d/qgspointcloudlayer3drendererwidget.cpp
3d/qgs3dviewsmanager.cpp
)
endif()

0 comments on commit f49a268

Please sign in to comment.