Skip to content
Permalink
Browse files
Update rubber band's line material based on viewport size
  • Loading branch information
wonder-sk authored and nyalldawson committed Jun 18, 2021
1 parent de79264 commit b304e229f87974bf50801c82bdb3ca7d5ae3abdc
Showing with 11 additions and 4 deletions.
  1. +8 −2 src/3d/qgsrubberband3d.cpp
  2. +2 −1 src/3d/qgsrubberband3d.h
  3. +1 −1 src/app/3d/qgs3dmaptoolmeasureline.cpp
@@ -15,6 +15,7 @@

#include "qgsrubberband3d.h"

#include "qgscameracontroller.h"
#include "qgslinevertexdata_p.h"
#include "qgsabstractmaterialsettings.h"
#include "qgslinematerial_p.h"
@@ -33,7 +34,7 @@
/// @cond PRIVATE


QgsRubberBand3D::QgsRubberBand3D( Qgs3DMapSettings &map, Qt3DCore::QEntity *parentEntity )
QgsRubberBand3D::QgsRubberBand3D( Qgs3DMapSettings &map, QgsCameraController *cameraController, Qt3DCore::QEntity *parentEntity )
{
mMapSettings = ↦

@@ -57,7 +58,12 @@ QgsRubberBand3D::QgsRubberBand3D( Qgs3DMapSettings &map, Qt3DCore::QEntity *pare
mLineMaterial = new QgsLineMaterial;
mLineMaterial->setLineWidth( 3 );
mLineMaterial->setLineColor( Qt::red );
mLineMaterial->setViewportSize( QSize( 200, 200 ) ); // TODO: based on viewport size!

QObject::connect( cameraController, &QgsCameraController::viewportChanged, mLineMaterial, [this, cameraController]
{
mLineMaterial->setViewportSize( cameraController->viewport().size() );
} );
mLineMaterial->setViewportSize( cameraController->viewport().size() );

mEntity->addComponent( mLineMaterial );
}
@@ -33,6 +33,7 @@

#include "qgslinestring.h"

class QgsCameraController;
class QgsLineMaterial;
class Qgs3DMapSettings;

@@ -63,7 +64,7 @@ namespace Qt3DRender
class _3D_EXPORT QgsRubberBand3D
{
public:
QgsRubberBand3D( Qgs3DMapSettings &map, Qt3DCore::QEntity *parentEntity );
QgsRubberBand3D( Qgs3DMapSettings &map, QgsCameraController *cameraController, Qt3DCore::QEntity *parentEntity );
~QgsRubberBand3D();

float width() const;
@@ -74,7 +74,7 @@ void Qgs3DMapToolMeasureLine::activate()

mCanvas->scene()->registerPickHandler( mPickHandler.get() );

mRubberBand.reset( new QgsRubberBand3D( *mCanvas->map(), mCanvas->scene() ) );
mRubberBand.reset( new QgsRubberBand3D( *mCanvas->map(), mCanvas->cameraController(), mCanvas->scene() ) );

if ( mIsAlreadyActivated )
{

0 comments on commit b304e22

Please sign in to comment.