예제 #1
0
QgsAnnotationWidget::QgsAnnotationWidget( QgsAnnotationItem* item, QWidget * parent, Qt::WindowFlags f ): QWidget( parent, f ), mItem( item ), mMarkerSymbol( 0 )
{
  setupUi( this );

  if ( mItem )
  {
    blockAllSignals( true );

    if ( mItem->mapPositionFixed() )
    {
      mMapPositionFixedCheckBox->setCheckState( Qt::Checked );
    }
    else
    {
      mMapPositionFixedCheckBox->setCheckState( Qt::Unchecked );
    }
    mFrameWidthSpinBox->setValue( mItem->frameBorderWidth() );
    mFrameColorButton->setColor( mItem->frameColor() );

    const QgsMarkerSymbolV2* symbol = mItem->markerSymbol();
    if ( symbol )
    {
      mMarkerSymbol = dynamic_cast<QgsMarkerSymbolV2*>( symbol->clone() );
      updateCenterIcon();
    }

    blockAllSignals( false );
  }
}
예제 #2
0
void QgsPointDisplacementRendererWidget::updateCenterSymbolFromWidget()
{
  QgsSymbolSelectorWidget* dlg = qobject_cast<QgsSymbolSelectorWidget*>( sender() );
  QgsSymbol* symbol = dlg->symbol()->clone();
  mRenderer->setCenterSymbol( static_cast< QgsMarkerSymbol* >( symbol ) );
  updateCenterIcon();
  emit widgetChanged();
}
void QgsPointDisplacementRendererWidget::on_mCenterSymbolPushButton_clicked()
{
    if ( !mRenderer || !mRenderer->centerSymbol() )
    {
        return;
    }
    QgsMarkerSymbolV2* markerSymbol = dynamic_cast<QgsMarkerSymbolV2*>( mRenderer->centerSymbol()->clone() );
    QgsSymbolV2SelectorDialog dlg( markerSymbol, QgsStyleV2::defaultStyle(), mLayer, this );
    if ( dlg.exec() == QDialog::Rejected )
    {
        delete markerSymbol;
        return;
    }
    mRenderer->setCenterSymbol( markerSymbol );
    updateCenterIcon();
}
예제 #4
0
void QgsAnnotationWidget::on_mMapMarkerButton_clicked()
{
  if ( !mMarkerSymbol )
  {
    return;
  }
  QgsMarkerSymbol* markerSymbol = mMarkerSymbol->clone();
  QgsSymbolSelectorDialog dlg( markerSymbol, QgsStyle::defaultStyle(), nullptr, this );
  if ( dlg.exec() == QDialog::Rejected )
  {
    delete markerSymbol;
  }
  else
  {
    mMarkerSymbol.reset( markerSymbol );
    updateCenterIcon();
  }
}
예제 #5
0
void QgsAnnotationWidget::on_mMapMarkerButton_clicked()
{
  if ( !mMarkerSymbol )
  {
    return;
  }
  QgsMarkerSymbolV2* markerSymbol = dynamic_cast<QgsMarkerSymbolV2*>( mMarkerSymbol->clone() );
  QgsSymbolV2SelectorDialog dlg( markerSymbol, QgsStyleV2::defaultStyle(), 0, this );
  if ( dlg.exec() == QDialog::Rejected )
  {
    delete markerSymbol;
  }
  else
  {
    delete mMarkerSymbol;
    mMarkerSymbol = markerSymbol;
    updateCenterIcon();
  }
}
예제 #6
0
QgsAnnotationWidget::QgsAnnotationWidget( QgsAnnotationItem* item, QWidget * parent, Qt::WindowFlags f ): QWidget( parent, f ), mItem( item ), mMarkerSymbol( nullptr )
{
  setupUi( this );

  if ( mItem )
  {
    blockAllSignals( true );

    if ( mItem->hasFixedMapPosition() )
    {
      mMapPositionFixedCheckBox->setCheckState( Qt::Checked );
    }
    else
    {
      mMapPositionFixedCheckBox->setCheckState( Qt::Unchecked );
    }
    mFrameWidthSpinBox->setValue( mItem->frameBorderWidth() );
    mFrameColorButton->setColor( mItem->frameColor() );
    mFrameColorButton->setColorDialogTitle( tr( "Select frame color" ) );
    mFrameColorButton->setAllowAlpha( true );
    mFrameColorButton->setContext( QStringLiteral( "symbology" ) );
    mFrameColorButton->setNoColorString( tr( "Transparent frame" ) );
    mFrameColorButton->setShowNoColor( true );
    mBackgroundColorButton->setColor( mItem->frameBackgroundColor() );
    mBackgroundColorButton->setColorDialogTitle( tr( "Select background color" ) );
    mBackgroundColorButton->setAllowAlpha( true );
    mBackgroundColorButton->setContext( QStringLiteral( "symbology" ) );
    mBackgroundColorButton->setNoColorString( tr( "Transparent" ) );
    mBackgroundColorButton->setShowNoColor( true );

    connect( mBackgroundColorButton, SIGNAL( colorChanged( QColor ) ), this, SIGNAL( backgroundColorChanged( QColor ) ) );

    const QgsMarkerSymbol* symbol = mItem->markerSymbol();
    if ( symbol )
    {
      mMarkerSymbol.reset( symbol->clone() );
      updateCenterIcon();
    }

    blockAllSignals( false );
  }
}
예제 #7
0
QgsAnnotationWidget::QgsAnnotationWidget( QgsAnnotationItem* item, QWidget * parent, Qt::WindowFlags f ): QWidget( parent, f ), mItem( item ), mMarkerSymbol( 0 )
{
  setupUi( this );

  if ( mItem )
  {
    blockAllSignals( true );

    if ( mItem->mapPositionFixed() )
    {
      mMapPositionFixedCheckBox->setCheckState( Qt::Checked );
    }
    else
    {
      mMapPositionFixedCheckBox->setCheckState( Qt::Unchecked );
    }
    mFrameWidthSpinBox->setValue( mItem->frameBorderWidth() );
    mFrameColorButton->setColor( mItem->frameColor() );
    mFrameColorButton->setColorDialogTitle( tr( "Select frame color" ) );
    mFrameColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
    mFrameColorButton->setContext( "symbology" );
    mFrameColorButton->setNoColorString( tr( "Transparent frame" ) );
    mFrameColorButton->setShowNoColor( true );
    mBackgroundColorButton->setColor( mItem->frameBackgroundColor() );
    mBackgroundColorButton->setColorDialogTitle( tr( "Select background color" ) );
    mBackgroundColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
    mBackgroundColorButton->setContext( "symbology" );
    mBackgroundColorButton->setNoColorString( tr( "Transparent" ) );
    mBackgroundColorButton->setShowNoColor( true );

    const QgsMarkerSymbolV2* symbol = mItem->markerSymbol();
    if ( symbol )
    {
      mMarkerSymbol = dynamic_cast<QgsMarkerSymbolV2*>( symbol->clone() );
      updateCenterIcon();
    }

    blockAllSignals( false );
  }
}
QgsPointDisplacementRendererWidget::QgsPointDisplacementRendererWidget( QgsVectorLayer* layer, QgsStyleV2* style, QgsFeatureRendererV2* renderer )
    : QgsRendererV2Widget( layer, style )
    , mRenderer( NULL )
    , mEmbeddedRendererWidget( 0 )
{
  if ( !layer )
  {
    return;
  }

  //the renderer only applies to point vector layers
  if ( layer->wkbType() != QGis::WKBPoint && layer->wkbType()  != QGis::WKBPoint25D )
  {
    //setup blank dialog
    mRenderer = 0;
    setupBlankUi( layer->name() );
    return;
  }
  setupUi( this );
  mDistanceUnitWidget->setUnits( QgsSymbolV2::OutputUnitList() << QgsSymbolV2::MM << QgsSymbolV2::MapUnit << QgsSymbolV2::Pixel );

  if ( renderer )
  {
    mRenderer = QgsPointDisplacementRenderer::convertFromRenderer( renderer );
  }
  if ( !mRenderer )
  {
    mRenderer = new QgsPointDisplacementRenderer();
  }

  blockAllSignals( true );

  mPlacementComboBox->addItem( tr( "Ring" ), QgsPointDisplacementRenderer::Ring );
  mPlacementComboBox->addItem( tr( "Concentric rings" ), QgsPointDisplacementRenderer::ConcentricRings );

  //insert attributes into combo box
  if ( layer )
  {
    const QgsFields& layerAttributes = layer->fields();
    for ( int idx = 0; idx < layerAttributes.count(); ++idx )
    {
      mLabelFieldComboBox->addItem( layerAttributes[idx].name() );
    }
    mLabelFieldComboBox->addItem( tr( "None" ) );

    QString currentLabelAttribute = mRenderer->labelAttributeName();
    if ( !currentLabelAttribute.isEmpty() )
    {
      mLabelFieldComboBox->setCurrentIndex( mLabelFieldComboBox->findText( currentLabelAttribute ) );
    }
    else
    {
      mLabelFieldComboBox->setCurrentIndex( mLabelFieldComboBox->findText( tr( "None" ) ) );
    }
  }

  //insert possible renderer types
  QStringList rendererList = QgsRendererV2Registry::instance()->renderersList();
  QStringList::const_iterator it = rendererList.constBegin();
  for ( ; it != rendererList.constEnd(); ++it )
  {
    if ( *it != "pointDisplacement" )
    {
      QgsRendererV2AbstractMetadata* m = QgsRendererV2Registry::instance()->rendererMetadata( *it );
      mRendererComboBox->addItem( m->icon(), m->visibleName(), *it );
    }
  }

  mCircleColorButton->setColorDialogTitle( tr( "Select color" ) );
  mCircleColorButton->setContext( "symbology" );
  mCircleColorButton->setAllowAlpha( true );
  mCircleColorButton->setShowNoColor( true );
  mCircleColorButton->setNoColorString( tr( "No outline" ) );
  mLabelColorButton->setContext( "symbology" );
  mLabelColorButton->setColorDialogTitle( tr( "Select color" ) );
  mLabelColorButton->setAllowAlpha( true );

  mCircleWidthSpinBox->setValue( mRenderer->circleWidth() );
  mCircleColorButton->setColor( mRenderer->circleColor() );
  mLabelColorButton->setColor( mRenderer->labelColor() );
  mCircleModificationSpinBox->setClearValue( 0.0 );
  mCircleModificationSpinBox->setValue( mRenderer->circleRadiusAddition() );
  mDistanceSpinBox->setValue( mRenderer->tolerance() );
  mDistanceUnitWidget->setUnit( mRenderer->toleranceUnit() );
  mDistanceUnitWidget->setMapUnitScale( mRenderer->toleranceMapUnitScale() );

  mPlacementComboBox->setCurrentIndex( mPlacementComboBox->findData( mRenderer->placement() ) );

  //scale dependent labelling
  mMaxScaleDenominatorEdit->setText( QString::number( mRenderer->maxLabelScaleDenominator() ) );
  mMaxScaleDenominatorEdit->setValidator( new QDoubleValidator( mMaxScaleDenominatorEdit ) );
  if ( mRenderer->maxLabelScaleDenominator() > 0 )
  {
    mScaleDependentLabelsCheckBox->setCheckState( Qt::Checked );
  }
  else
  {
    mScaleDependentLabelsCheckBox->setCheckState( Qt::Unchecked );
    mMaxScaleDenominatorEdit->setEnabled( false );
  }


  blockAllSignals( false );

  //set the appropriate renderer dialog
  if ( mRenderer->embeddedRenderer() )
  {
    QString rendererName = mRenderer->embeddedRenderer()->type();
    int rendererIndex = mRendererComboBox->findData( rendererName );
    if ( rendererIndex != -1 )
    {
      mRendererComboBox->setCurrentIndex( rendererIndex );
      on_mRendererComboBox_currentIndexChanged( rendererIndex );
    }
  }

  updateCenterIcon();
}
QgsPointDisplacementRendererWidget::QgsPointDisplacementRendererWidget( QgsVectorLayer* layer, QgsStyleV2* style, QgsFeatureRendererV2* renderer )
    : QgsRendererV2Widget( layer, style ), mEmbeddedRendererWidget( 0 )
{
    if ( !layer )
    {
        return;
    }

    //the renderer only applies to point vector layers
    if ( layer->wkbType() != QGis::WKBPoint && layer->wkbType()  != QGis::WKBPoint25D )
    {
        //setup blank dialog
        mRenderer = 0;
        setupBlankUi( layer->name() );
        return;
    }
    setupUi( this );

    if ( renderer && renderer->type() == "pointDisplacement" )
    {
        mRenderer = dynamic_cast<QgsPointDisplacementRenderer*>( renderer->clone() );
    }
    else
    {
        mRenderer = new QgsPointDisplacementRenderer();
    }

    blockAllSignals( true );

    //insert attributes into combo box
    if ( layer )
    {
        const QgsFields& layerAttributes = layer->pendingFields();
        for ( int idx = 0; idx < layerAttributes.count(); ++idx )
        {
            mLabelFieldComboBox->addItem( layerAttributes[idx].name() );
        }
        mLabelFieldComboBox->addItem( tr( "None" ) );

        QString currentLabelAttribute = mRenderer->labelAttributeName();
        if ( !currentLabelAttribute.isEmpty() )
        {
            mLabelFieldComboBox->setCurrentIndex( mLabelFieldComboBox->findText( currentLabelAttribute ) );
        }
        else
        {
            mLabelFieldComboBox->setCurrentIndex( mLabelFieldComboBox->findText( tr( "None" ) ) );
        }
    }

    //insert possible renderer types
    QStringList rendererList = QgsRendererV2Registry::instance()->renderersList();
    QStringList::const_iterator it = rendererList.constBegin();
    for ( ; it != rendererList.constEnd(); ++it )
    {
        if ( *it != "pointDisplacement" )
        {
            QgsRendererV2AbstractMetadata* m = QgsRendererV2Registry::instance()->rendererMetadata( *it );
            mRendererComboBox->addItem( m->icon(), m->visibleName(), *it );
        }
    }

    mCircleWidthSpinBox->setValue( mRenderer->circleWidth() );
    mCircleColorButton->setColor( mRenderer->circleColor() );
    mLabelColorButton->setColor( mRenderer->labelColor() );
    mCircleModificationSpinBox->setValue( mRenderer->circleRadiusAddition() );
    mDistanceSpinBox->setValue( mRenderer->tolerance() );

    //scale dependent labelling
    mMaxScaleDenominatorEdit->setText( QString::number( mRenderer->maxLabelScaleDenominator() ) );
    mMaxScaleDenominatorEdit->setValidator( new QDoubleValidator( mMaxScaleDenominatorEdit ) );
    if ( mRenderer->maxLabelScaleDenominator() > 0 )
    {
        mScaleDependentLabelsCheckBox->setCheckState( Qt::Checked );
    }
    else
    {
        mScaleDependentLabelsCheckBox->setCheckState( Qt::Unchecked );
        mMaxScaleDenominatorEdit->setEnabled( false );
    }


    blockAllSignals( false );

    //set the appropriate renderer dialog
    if ( mRenderer && mRenderer->embeddedRenderer() )
    {
        QString rendererName = mRenderer->embeddedRenderer()->type();
        int rendererIndex = mRendererComboBox->findData( rendererName );
        if ( rendererIndex != -1 )
        {
            mRendererComboBox->setCurrentIndex( rendererIndex );
            on_mRendererComboBox_currentIndexChanged( rendererIndex );
        }
    }

    updateCenterIcon();
}