Skip to content
Permalink
Browse files
Initial support for 3D map item in print layouts GUI
The GUI logic is not working yet, just getting the new files ready.

Many thanks to @nirvn for the icon!
  • Loading branch information
wonder-sk committed Aug 21, 2018
1 parent eb220ed commit d4a3f68eb1c5d3936d9accadc60a96d2c6c6b4a2
Show file tree
Hide file tree
Showing 10 changed files with 463 additions and 1 deletion.
@@ -702,6 +702,7 @@
<file>themes/default/mIconGPU.svg</file>
<file>themes/default/mAddToProject.svg</file>
<file>themes/default/mDockify.svg</file>
<file>themes/default/mActionAdd3DMap.svg</file>
</qresource>
<qresource prefix="/images/tips">
<file alias="symbol_levels.png">qgis_tips/symbol_levels.png</file>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -54,6 +54,7 @@ SET(QGIS_3D_MOC_HDRS
qgs3dmapsettings.h
qgsabstract3dengine.h
qgscameracontroller.h
qgslayoutitem3dmap.h
qgsoffscreen3dengine.h
qgswindow3dengine.h

@@ -26,9 +26,11 @@
QgsLayoutItem3DMap::QgsLayoutItem3DMap( QgsLayout *layout )
: QgsLayoutItem( layout )
{

}

QgsLayoutItem3DMap::~QgsLayoutItem3DMap() = default;


QgsLayoutItem3DMap *QgsLayoutItem3DMap::create( QgsLayout *layout )
{
return new QgsLayoutItem3DMap( layout );
@@ -41,6 +43,9 @@ int QgsLayoutItem3DMap::type() const

void QgsLayoutItem3DMap::draw( QgsLayoutItemRenderContext &context )
{
if ( !mSettings )
return;

QgsOffscreen3DEngine engine;
QSizeF sizePixels = mLayout->renderContext().measurementConverter().convert( sizeWithUnits(), QgsUnitTypes::LayoutPixels ).toQSizeF();
engine.setSize( QSize( static_cast<int>( std::ceil( sizePixels.width() ) ),
@@ -34,6 +34,7 @@ class Qgs3DMapSettings;
*/
class _3D_EXPORT QgsLayoutItem3DMap : public QgsLayoutItem
{
Q_OBJECT

#ifdef SIP_RUN
SIP_CONVERT_TO_SUBCLASS_CODE
@@ -61,6 +62,8 @@ class _3D_EXPORT QgsLayoutItem3DMap : public QgsLayoutItem
*/
QgsLayoutItem3DMap( QgsLayout *layout SIP_TRANSFERTHIS );

~QgsLayoutItem3DMap();

/**
* Returns a new 3D map item for the specified \a layout.
*
@@ -446,6 +446,7 @@ IF (WITH_3D)
3d/qgspolygon3dsymbolwidget.cpp
3d/qgsphongmaterialwidget.cpp
3d/qgsvectorlayer3drendererwidget.cpp
layout/qgslayout3dmapwidget.cpp
)

SET (QGIS_APP_MOC_HDRS
@@ -459,6 +460,7 @@ IF (WITH_3D)
3d/qgspolygon3dsymbolwidget.h
3d/qgsphongmaterialwidget.h
3d/qgsvectorlayer3drendererwidget.h
layout/qgslayout3dmapwidget.h
)
ENDIF (WITH_3D)

@@ -0,0 +1,24 @@
/***************************************************************************
qgslayout3dmapwidget.cpp
--------------------------------------
Date : August 2018
Copyright : (C) 2018 by Martin Dobias
Email : wonder dot sk at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#include "qgslayout3dmapwidget.h"


QgsLayout3DMapWidget::QgsLayout3DMapWidget( QgsLayoutItem3DMap *map3D )
: QgsLayoutItemBaseWidget( nullptr, map3D )
, mMap3D( map3D )
{
setupUi( this );
}
@@ -0,0 +1,35 @@
/***************************************************************************
qgslayout3dmapwidget.h
--------------------------------------
Date : August 2018
Copyright : (C) 2018 by Martin Dobias
Email : wonder dot sk at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#ifndef QGSLAYOUT3DMAPWIDGET_H
#define QGSLAYOUT3DMAPWIDGET_H

#include "qgslayoutitemwidget.h"
#include "ui_qgslayout3dmapwidgetbase.h"
#include "qgslayoutitem3dmap.h"

class QgsLayoutItem3DMap;

class QgsLayout3DMapWidget : public QgsLayoutItemBaseWidget, private Ui::QgsLayout3DMapWidgetBase
{
Q_OBJECT
public:
explicit QgsLayout3DMapWidget( QgsLayoutItem3DMap *map3D );

private:
QPointer< QgsLayoutItem3DMap > mMap3D;
};

#endif // QGSLAYOUT3DMAPWIDGET_H
@@ -43,6 +43,10 @@
#include "qgisapp.h"
#include "qgsmapcanvas.h"

#ifdef HAVE_3D
#include "qgslayout3dmapwidget.h"
#endif

void QgsLayoutAppUtils::registerGuiForKnownItemTypes()
{
QgsLayoutItemGuiRegistry *registry = QgsGui::layoutItemGuiRegistry();
@@ -341,4 +345,15 @@ void QgsLayoutAppUtils::registerGuiForKnownItemTypes()
return f;
} );
registry->addLayoutItemGuiMetadata( attributeTableItemMetadata .release() );

// 3D map item
#ifdef HAVE_3D
std::unique_ptr< QgsLayoutItemGuiMetadata > map3dMetadata = qgis::make_unique< QgsLayoutItemGuiMetadata>(
QgsLayoutItemRegistry::Layout3DMap, QObject::tr( "3D Map" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAdd3DMap.svg" ) ),
[ = ]( QgsLayoutItem * item )->QgsLayoutItemBaseWidget *
{
return new QgsLayout3DMapWidget( qobject_cast< QgsLayoutItem3DMap * >( item ) );
}, createRubberBand );
registry->addLayoutItemGuiMetadata( map3dMetadata.release() );
#endif
}

0 comments on commit d4a3f68

Please sign in to comment.