コード例 #1
0
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();
  }
}
コード例 #2
0
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();
}
コード例 #3
0
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;
}
コード例 #4
0
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" ) );
}
コード例 #5
0
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" ) );
}
コード例 #6
0
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" ) );
}