void QgsGraduatedSymbolRendererV2Widget::on_methodComboBox_currentIndexChanged( int idx )
{
  mMethodStackedWidget->setCurrentIndex( idx );
  if ( idx == 0 )
  {
    mRenderer->setGraduatedMethod( QgsGraduatedSymbolRendererV2::GraduatedColor );
    QgsVectorColorRampV2* ramp = cboGraduatedColorRamp->currentColorRamp();

    if ( !ramp )
    {
      if ( cboGraduatedColorRamp->count() == 0 )
        QMessageBox::critical( this, tr( "Error" ), tr( "There are no available color ramps. You can add them in Style Manager." ) );
      else
        QMessageBox::critical( this, tr( "Error" ), tr( "The selected color ramp is not available." ) );
      return;
    }
    mRenderer->setSourceColorRamp( ramp );
    reapplyColorRamp();
  }
  else
  {
    mRenderer->setGraduatedMethod( QgsGraduatedSymbolRendererV2::GraduatedSize );
    reapplySizes();
  }
}
Exemplo n.º 2
0
void QgsGraduatedSymbolRendererWidget::on_methodComboBox_currentIndexChanged( int idx )
{
  toggleMethodWidgets( idx );
  if ( idx == 0 )
  {
    mRenderer->setGraduatedMethod( QgsGraduatedSymbolRenderer::GraduatedColor );
    QgsColorRamp* ramp = btnColorRamp->colorRamp();

    if ( !ramp )
    {
      QMessageBox::critical( this, tr( "Error" ), tr( "No color ramp defined." ) );
      return;
    }
    mRenderer->setSourceColorRamp( ramp );
    reapplyColorRamp();
  }
  else
  {
    lblColorRamp->setVisible( false );
    btnColorRamp->setVisible( false );
    lblSize->setVisible( true );
    minSizeSpinBox->setVisible( true );
    lblSize->setVisible( true );
    maxSizeSpinBox->setVisible( true );
    mSizeUnitWidget->setVisible( true );

    mRenderer->setGraduatedMethod( QgsGraduatedSymbolRenderer::GraduatedSize );
    reapplySizes();
  }
}