void QgsPointDisplacementRendererWidget::on_mRendererSettingsButton_clicked() { if ( !mRenderer ) return; QgsRendererAbstractMetadata* m = QgsRendererRegistry::instance()->rendererMetadata( mRenderer->embeddedRenderer()->type() ); if ( m ) { QgsRendererWidget* w = m->createRendererWidget( mLayer, mStyle, mRenderer->embeddedRenderer()->clone() ); w->setPanelTitle( tr( "Renderer settings" ) ); QgsSymbolWidgetContext context = mContext; QgsExpressionContextScope scope; scope.addVariable( QgsExpressionContextScope::StaticVariable( QgsExpressionContext::EXPR_CLUSTER_COLOR, "", true ) ); scope.addVariable( QgsExpressionContextScope::StaticVariable( QgsExpressionContext::EXPR_CLUSTER_SIZE, 0, true ) ); QList< QgsExpressionContextScope > scopes = context.additionalExpressionContextScopes(); scopes << scope; context.setAdditionalExpressionContextScopes( scopes ); w->setContext( context ); connect( w, SIGNAL( widgetChanged() ), this, SLOT( updateRendererFromWidget() ) ); openPanel( w ); } }
void QgsComposerPolygonWidget::on_mPolygonStyleButton_clicked() { if ( !mComposerPolygon ) { return; } // use the atlas coverage layer, if any QgsVectorLayer* coverageLayer = atlasCoverageLayer(); QScopedPointer<QgsFillSymbol> newSymbol; newSymbol.reset( mComposerPolygon->polygonStyleSymbol()->clone() ); QgsExpressionContext context = mComposerPolygon->createExpressionContext(); QgsSymbolSelectorDialog d( newSymbol.data(), QgsStyle::defaultStyle(), coverageLayer, this ); QgsSymbolWidgetContext symbolContext; symbolContext.setExpressionContext( &context ); d.setContext( symbolContext ); if ( d.exec() == QDialog::Accepted ) { mComposerPolygon->beginCommand( tr( "Polygon style changed" ) ); mComposerPolygon->setPolygonStyleSymbol( newSymbol.data() ); updatePolygonStyle(); mComposerPolygon->endCommand(); } }
void QgsDataDefinedSizeLegendWidget::changeSymbol() { std::unique_ptr<QgsMarkerSymbol> newSymbol( mSourceSymbol->clone() ); QgsSymbolWidgetContext context; if ( mMapCanvas ) context.setMapCanvas( mMapCanvas ); QgsExpressionContext ec; ec << QgsExpressionContextUtils::globalScope() << QgsExpressionContextUtils::projectScope( QgsProject::instance() ) << QgsExpressionContextUtils::atlasScope( nullptr ); if ( mMapCanvas ) ec << QgsExpressionContextUtils::mapSettingsScope( mMapCanvas->mapSettings() ); context.setExpressionContext( &ec ); QString crsAuthId = mMapCanvas ? mMapCanvas->mapSettings().destinationCrs().authid() : QString(); std::unique_ptr<QgsVectorLayer> layer( new QgsVectorLayer( "Point?crs=" + crsAuthId, "tmp", "memory" ) ); QgsSymbolSelectorDialog d( newSymbol.get(), QgsStyle::defaultStyle(), layer.get(), this ); d.setContext( context ); if ( d.exec() != QDialog::Accepted ) return; mSourceSymbol.reset( newSymbol.release() ); QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( mSourceSymbol.get(), btnChangeSymbol->iconSize() ); btnChangeSymbol->setIcon( icon ); emit widgetChanged(); }
void QgsComposerShapeWidget::on_mShapeStyleButton_clicked() { if ( !mComposerShape ) { return; } // use the atlas coverage layer, if any QgsVectorLayer* coverageLayer = atlasCoverageLayer(); QgsFillSymbol* newSymbol = mComposerShape->shapeStyleSymbol()->clone(); QgsExpressionContext context = mComposerShape->createExpressionContext(); QgsSymbolSelectorDialog d( newSymbol, QgsStyle::defaultStyle(), coverageLayer, this ); QgsSymbolWidgetContext symbolContext; symbolContext.setExpressionContext( &context ); d.setContext( symbolContext ); if ( d.exec() == QDialog::Accepted ) { mComposerShape->beginCommand( tr( "Shape style changed" ) ); mComposerShape->setShapeStyleSymbol( newSymbol ); updateShapeStyle(); mComposerShape->endCommand(); } delete newSymbol; }
void QgsPointClusterRendererWidget::setContext( const QgsSymbolWidgetContext &context ) { QgsRendererWidget::setContext( context ); if ( mDistanceUnitWidget ) mDistanceUnitWidget->setMapCanvas( context.mapCanvas() ); if ( mCenterSymbolToolButton ) { mCenterSymbolToolButton->setMapCanvas( context.mapCanvas() ); mCenterSymbolToolButton->setMessageBar( context.messageBar() ); } }
void QgsPointDisplacementRendererWidget::setContext( const QgsSymbolWidgetContext &context ) { QgsRendererWidget::setContext( context ); if ( mDistanceUnitWidget ) mDistanceUnitWidget->setMapCanvas( context.mapCanvas() ); if ( mMinLabelScaleWidget ) { mMinLabelScaleWidget->setMapCanvas( context.mapCanvas() ); mMinLabelScaleWidget->setShowCurrentScaleButton( true ); } if ( mCenterSymbolToolButton ) { mCenterSymbolToolButton->setMapCanvas( context.mapCanvas() ); } }
void QgsComposerArrowWidget::mLineStyleButton_clicked() { if ( !mArrow ) { return; } // use the atlas coverage layer, if any QgsVectorLayer *coverageLayer = atlasCoverageLayer(); QgsLineSymbol *newSymbol = mArrow->lineSymbol()->clone(); QgsExpressionContext context = mArrow->createExpressionContext(); QgsSymbolSelectorWidget *d = new QgsSymbolSelectorWidget( newSymbol, QgsStyle::defaultStyle(), coverageLayer, nullptr ); QgsSymbolWidgetContext symbolContext; symbolContext.setExpressionContext( &context ); d->setContext( symbolContext ); connect( d, &QgsPanelWidget::widgetChanged, this, &QgsComposerArrowWidget::updateLineStyleFromWidget ); connect( d, &QgsPanelWidget::panelAccepted, this, &QgsComposerArrowWidget::cleanUpLineStyleSelector ); openPanel( d ); mArrow->beginCommand( tr( "Arrow line style changed" ) ); }
void QgsComposerPolygonWidget::on_mPolygonStyleButton_clicked() { if ( !mComposerPolygon ) { return; } // use the atlas coverage layer, if any QgsVectorLayer* coverageLayer = atlasCoverageLayer(); QgsFillSymbol* newSymbol = mComposerPolygon->polygonStyleSymbol()->clone(); QgsExpressionContext context = mComposerPolygon->createExpressionContext(); QgsSymbolSelectorWidget* d = new QgsSymbolSelectorWidget( newSymbol, QgsStyle::defaultStyle(), coverageLayer, nullptr ); QgsSymbolWidgetContext symbolContext; symbolContext.setExpressionContext( &context ); d->setContext( symbolContext ); connect( d, SIGNAL( widgetChanged() ), this, SLOT( updateStyleFromWidget() ) ); connect( d, SIGNAL( panelAccepted( QgsPanelWidget* ) ), this, SLOT( cleanUpStyleSelector( QgsPanelWidget* ) ) ); openPanel( d ); mComposerPolygon->beginCommand( tr( "Polygon style changed" ) ); }
void QgsComposerMapGridWidget::on_mGridMarkerStyleButton_clicked() { if ( !mComposerMapGrid || !mComposerMap ) { return; } // use the atlas coverage layer, if any QgsVectorLayer* coverageLayer = atlasCoverageLayer(); QgsMarkerSymbol* newSymbol = static_cast<QgsMarkerSymbol*>( mComposerMapGrid->markerSymbol()->clone() ); QgsExpressionContext context = mComposerMap->createExpressionContext(); QgsSymbolSelectorWidget* d = new QgsSymbolSelectorWidget( newSymbol, QgsStyle::defaultStyle(), coverageLayer, nullptr ); QgsSymbolWidgetContext symbolContext; symbolContext.setExpressionContext( &context ); d->setContext( symbolContext ); connect( d, SIGNAL( widgetChanged() ), this, SLOT( updateGridMarkerStyleFromWidget() ) ); connect( d, SIGNAL( panelAccepted( QgsPanelWidget* ) ), this, SLOT( cleanUpGridMarkerStyleSelector( QgsPanelWidget* ) ) ); openPanel( d ); mComposerMap->beginCommand( tr( "Grid markers style changed" ) ); }
void QgsPointDisplacementRendererWidget::on_mCenterSymbolPushButton_clicked() { if ( !mRenderer || !mRenderer->centerSymbol() ) { return; } QgsMarkerSymbol* markerSymbol = mRenderer->centerSymbol()->clone(); QgsSymbolSelectorWidget* dlg = new QgsSymbolSelectorWidget( markerSymbol, QgsStyle::defaultStyle(), mLayer, this ); dlg->setPanelTitle( tr( "Center symbol" ) ); QgsSymbolWidgetContext context = mContext; QgsExpressionContextScope scope; scope.addVariable( QgsExpressionContextScope::StaticVariable( QgsExpressionContext::EXPR_CLUSTER_COLOR, "", true ) ); scope.addVariable( QgsExpressionContextScope::StaticVariable( QgsExpressionContext::EXPR_CLUSTER_SIZE, 0, true ) ); QList< QgsExpressionContextScope > scopes = context.additionalExpressionContextScopes(); scopes << scope; context.setAdditionalExpressionContextScopes( scopes ); dlg->setContext( context ); connect( dlg, SIGNAL( widgetChanged() ), this, SLOT( updateCenterSymbolFromWidget() ) ); connect( dlg, SIGNAL( panelAccepted( QgsPanelWidget* ) ), this, SLOT( cleanUpSymbolSelector( QgsPanelWidget* ) ) ); openPanel( dlg ); }
void QgsPointClusterRendererWidget::mRendererSettingsButton_clicked() { if ( !mRenderer ) return; QgsRendererAbstractMetadata *m = QgsApplication::rendererRegistry()->rendererMetadata( mRenderer->embeddedRenderer()->type() ); if ( m ) { QgsRendererWidget *w = m->createRendererWidget( mLayer, mStyle, mRenderer->embeddedRenderer()->clone() ); w->setPanelTitle( tr( "Renderer Settings" ) ); QgsExpressionContextScope scope; scope.addVariable( QgsExpressionContextScope::StaticVariable( QgsExpressionContext::EXPR_CLUSTER_COLOR, "", true ) ); scope.addVariable( QgsExpressionContextScope::StaticVariable( QgsExpressionContext::EXPR_CLUSTER_SIZE, 0, true ) ); QList< QgsExpressionContextScope > scopes = mContext.additionalExpressionContextScopes(); scopes << scope; QgsSymbolWidgetContext context = mContext; context.setAdditionalExpressionContextScopes( scopes ); w->setContext( context ); connect( w, &QgsPanelWidget::widgetChanged, this, &QgsPointClusterRendererWidget::updateRendererFromWidget ); w->setDockMode( this->dockMode() ); openPanel( w ); } }
void QgsPointDisplacementRendererWidget::setContext( const QgsSymbolWidgetContext& context ) { QgsRendererWidget::setContext( context ); if ( mDistanceUnitWidget ) mDistanceUnitWidget->setMapCanvas( context.mapCanvas() ); }
void QgsHeatmapRendererWidget::setContext( const QgsSymbolWidgetContext& context ) { QgsRendererWidget::setContext( context ); if ( context.mapCanvas() ) mRadiusUnitWidget->setMapCanvas( context.mapCanvas() ); }