Skip to content
Permalink
Browse files

Move connect from construction for maptoomeasureline and add it as vi…

…rtual method. Fix #35078
  • Loading branch information
ismailsunni committed Mar 15, 2020
1 parent 6211fe2 commit 66069a89613d33f26d46d6cd7b465b17a8b0f33e
@@ -128,7 +128,7 @@ Qgs3DMapCanvasDockWidget::Qgs3DMapCanvasDockWidget( QWidget *parent )

mMapToolIdentify = new Qgs3DMapToolIdentify( mCanvas );

// mMapToolMeasureLine = new Qgs3DMapToolMeasureLine( mCanvas );
mMapToolMeasureLine = new Qgs3DMapToolMeasureLine( mCanvas );

mLabelPendingJobs = new QLabel( this );
mProgressPendingJobs = new QProgressBar( this );
@@ -225,6 +225,7 @@ void Qgs3DMapCanvasDockWidget::setMapSettings( Qgs3DMapSettings *map )

// Update the connection after the map is updated
mMapToolIdentify->updateSignalSlots();
mMapToolMeasureLine->updateSignalSlots();

mAnimationWidget->setCameraController( mCanvas->scene()->cameraController() );
mAnimationWidget->setMap( map );
@@ -51,6 +51,11 @@ QCursor Qgs3DMapTool::cursor() const
return Qt::CrossCursor;
}

void Qgs3DMapTool::updateSignalSlots()
{

}

Qgs3DMapCanvas *Qgs3DMapTool::canvas()
{
return mCanvas;
@@ -44,6 +44,9 @@ class Qgs3DMapTool : public QObject
//! Mouse cursor to be used when the tool is active
virtual QCursor cursor() const;

//! Update the connection to the map canvas's property (scene, map setting)
virtual void updateSignalSlots();

/**
* Whether the default mouse controls to zoom/pan/rotate camera can stay enabled
* while the tool is active. This may be useful for some basic tools using just
@@ -45,13 +45,11 @@ class Qgs3DMapToolIdentify : public Qgs3DMapTool

QCursor cursor() const override;

void updateSignalSlots();

public slots:
void onTerrainEntityChanged();
void updateSignalSlots() override;

private slots:
void onTerrainPicked( Qt3DRender::QPickEvent *event );
void onTerrainEntityChanged();

private:
std::unique_ptr<Qgs3DMapToolIdentifyPickHandler> mPickHandler;
@@ -50,16 +50,13 @@ void Qgs3DMapToolMeasureLinePickHandler::handlePickOnVectorLayer( QgsVectorLayer
Qgs3DMapToolMeasureLine::Qgs3DMapToolMeasureLine( Qgs3DMapCanvas *canvas )
: Qgs3DMapTool( canvas )
{
connect( mCanvas->scene(), &Qgs3DMapScene::terrainEntityChanged, this, &Qgs3DMapToolMeasureLine::onTerrainEntityChanged );
mPickHandler.reset( new Qgs3DMapToolMeasureLinePickHandler( this ) );

// Dialog
mDialog = new Qgs3DMeasureDialog( this );
mDialog->setWindowFlags( mDialog->windowFlags() | Qt::Tool );
mDialog->restorePosition();

// Update scale if the terrain vertical scale changed
connect( mCanvas->map(), &Qgs3DMapSettings::terrainVerticalScaleChanged, this, &Qgs3DMapToolMeasureLine::updateMeasurementLayer );
}

Qgs3DMapToolMeasureLine::~Qgs3DMapToolMeasureLine() = default;
@@ -124,6 +121,15 @@ QCursor Qgs3DMapToolMeasureLine::cursor() const
return Qt::CrossCursor;
}

void Qgs3DMapToolMeasureLine::updateSignalSlots()
{
connect( mCanvas->scene(), &Qgs3DMapScene::terrainEntityChanged, this, &Qgs3DMapToolMeasureLine::onTerrainEntityChanged );

// Update scale if the terrain vertical scale changed
connect( mCanvas->map(), &Qgs3DMapSettings::terrainVerticalScaleChanged, this, &Qgs3DMapToolMeasureLine::updateMeasurementLayer );

}

void Qgs3DMapToolMeasureLine::onTerrainPicked( Qt3DRender::QPickEvent *event )
{
handleClick( event, event->worldIntersection() );
@@ -67,6 +67,8 @@ class Qgs3DMapToolMeasureLine : public Qgs3DMapTool

QCursor cursor() const override;

void updateSignalSlots() override;

private slots:
void onTerrainPicked( Qt3DRender::QPickEvent *event );
void onTerrainEntityChanged();

0 comments on commit 66069a8

Please sign in to comment.
You can’t perform that action at this time.