mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-15 00:02:52 -04:00
Make function more readable
This commit is contained in:
parent
c79168a6bc
commit
9492c69d9f
@ -33,47 +33,7 @@ void QgsAppCanvasFiltering::setupElevationControllerAction( QAction *action, Qgs
|
|||||||
{
|
{
|
||||||
if ( checked )
|
if ( checked )
|
||||||
{
|
{
|
||||||
QgsElevationControllerWidget *controller = new QgsElevationControllerWidget();
|
createElevationController( action, canvas );
|
||||||
connect( controller, &QgsElevationControllerWidget::rangeChanged, canvas, &QgsMapCanvas::setZRange );
|
|
||||||
|
|
||||||
QAction *setProjectLimitsAction = new QAction( tr( "Set Elevation Range…" ), controller );
|
|
||||||
controller->menu()->addAction( setProjectLimitsAction );
|
|
||||||
connect( setProjectLimitsAction, &QAction::triggered, QgisApp::instance(), []
|
|
||||||
{
|
|
||||||
QgisApp::instance()->showProjectProperties( tr( "Elevation" ) );
|
|
||||||
} );
|
|
||||||
QAction *disableAction = new QAction( tr( "Disable Elevation Filter" ), controller );
|
|
||||||
controller->menu()->addAction( disableAction );
|
|
||||||
connect( disableAction, &QAction::triggered, action, [action]
|
|
||||||
{
|
|
||||||
action->setChecked( false );
|
|
||||||
} );
|
|
||||||
|
|
||||||
canvas->addOverlayWidget( controller, Qt::Edge::LeftEdge );
|
|
||||||
mCanvasElevationControllerMap.insert( canvas, controller );
|
|
||||||
connect( canvas, &QObject::destroyed, this, [canvas, this]
|
|
||||||
{
|
|
||||||
mCanvasElevationControllerMap.remove( canvas );
|
|
||||||
} );
|
|
||||||
connect( controller, &QObject::destroyed, this, [canvas, this]
|
|
||||||
{
|
|
||||||
mCanvasElevationControllerMap.remove( canvas );
|
|
||||||
} );
|
|
||||||
|
|
||||||
if ( canvas == QgisApp::instance()->mapCanvas() )
|
|
||||||
{
|
|
||||||
// for main canvas, attach settings to project settings
|
|
||||||
controller->setFixedRangeSize( QgsProject::instance()->elevationProperties()->elevationFilterRangeSize() );
|
|
||||||
connect( controller, &QgsElevationControllerWidget::fixedRangeSizeChanged, this, []( double size )
|
|
||||||
{
|
|
||||||
QgsProject::instance()->elevationProperties()->setElevationFilterRangeSize( size );
|
|
||||||
} );
|
|
||||||
controller->setInverted( QgsProject::instance()->elevationProperties()->invertElevationFilter() );
|
|
||||||
connect( controller, &QgsElevationControllerWidget::invertedChanged, this, []( bool inverted )
|
|
||||||
{
|
|
||||||
QgsProject::instance()->elevationProperties()->setInvertElevationFilter( inverted );
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -85,3 +45,48 @@ void QgsAppCanvasFiltering::setupElevationControllerAction( QAction *action, Qgs
|
|||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QgsAppCanvasFiltering::createElevationController( QAction *senderAction, QgsMapCanvas *canvas )
|
||||||
|
{
|
||||||
|
QgsElevationControllerWidget *controller = new QgsElevationControllerWidget();
|
||||||
|
connect( controller, &QgsElevationControllerWidget::rangeChanged, canvas, &QgsMapCanvas::setZRange );
|
||||||
|
|
||||||
|
QAction *setProjectLimitsAction = new QAction( tr( "Set Elevation Range…" ), controller );
|
||||||
|
controller->menu()->addAction( setProjectLimitsAction );
|
||||||
|
connect( setProjectLimitsAction, &QAction::triggered, QgisApp::instance(), []
|
||||||
|
{
|
||||||
|
QgisApp::instance()->showProjectProperties( tr( "Elevation" ) );
|
||||||
|
} );
|
||||||
|
QAction *disableAction = new QAction( tr( "Disable Elevation Filter" ), controller );
|
||||||
|
controller->menu()->addAction( disableAction );
|
||||||
|
connect( disableAction, &QAction::triggered, senderAction, [senderAction]
|
||||||
|
{
|
||||||
|
senderAction->setChecked( false );
|
||||||
|
} );
|
||||||
|
|
||||||
|
canvas->addOverlayWidget( controller, Qt::Edge::LeftEdge );
|
||||||
|
mCanvasElevationControllerMap.insert( canvas, controller );
|
||||||
|
connect( canvas, &QObject::destroyed, this, [canvas, this]
|
||||||
|
{
|
||||||
|
mCanvasElevationControllerMap.remove( canvas );
|
||||||
|
} );
|
||||||
|
connect( controller, &QObject::destroyed, this, [canvas, this]
|
||||||
|
{
|
||||||
|
mCanvasElevationControllerMap.remove( canvas );
|
||||||
|
} );
|
||||||
|
|
||||||
|
if ( canvas == QgisApp::instance()->mapCanvas() )
|
||||||
|
{
|
||||||
|
// for main canvas, attach settings to project settings
|
||||||
|
controller->setFixedRangeSize( QgsProject::instance()->elevationProperties()->elevationFilterRangeSize() );
|
||||||
|
connect( controller, &QgsElevationControllerWidget::fixedRangeSizeChanged, this, []( double size )
|
||||||
|
{
|
||||||
|
QgsProject::instance()->elevationProperties()->setElevationFilterRangeSize( size );
|
||||||
|
} );
|
||||||
|
controller->setInverted( QgsProject::instance()->elevationProperties()->invertElevationFilter() );
|
||||||
|
connect( controller, &QgsElevationControllerWidget::invertedChanged, this, []( bool inverted )
|
||||||
|
{
|
||||||
|
QgsProject::instance()->elevationProperties()->setInvertElevationFilter( inverted );
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -36,6 +36,8 @@ class QgsAppCanvasFiltering : public QObject
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
void createElevationController( QAction *senderAction, QgsMapCanvas *canvas );
|
||||||
|
|
||||||
QHash< QgsMapCanvas *, QgsElevationControllerWidget * > mCanvasElevationControllerMap;
|
QHash< QgsMapCanvas *, QgsElevationControllerWidget * > mCanvasElevationControllerMap;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user