Example #1
0
void QgsCompositionWidget::on_mPageStyleButton_clicked()
{
    if ( !mComposition )
    {
        return;
    }

    QgsVectorLayer* coverageLayer = 0;
    // use the atlas coverage layer, if any
    if ( mComposition->atlasComposition().enabled() )
    {
        coverageLayer = mComposition->atlasComposition().coverageLayer();
    }

    QgsFillSymbolV2* newSymbol = dynamic_cast<QgsFillSymbolV2*>( mComposition->pageStyleSymbol()->clone() );
    QgsSymbolV2SelectorDialog d( newSymbol, QgsStyleV2::defaultStyle(), coverageLayer );

    if ( d.exec() == QDialog::Accepted )
    {
        mComposition->setPageStyleSymbol( newSymbol );
        updatePageStyle();
    }
    else
    {
        delete newSymbol;
    }
}
Example #2
0
void QgsCompositionWidget::on_mPageStyleButton_clicked()
{
  if ( !mComposition )
  {
    return;
  }

  QgsSymbolV2SelectorDialog d( mComposition->pageStyleSymbol(), QgsStyleV2::defaultStyle(), 0 );

  if ( d.exec() == QDialog::Accepted )
  {
    updatePageStyle();
  }
}
Example #3
0
QgsCompositionWidget::QgsCompositionWidget( QWidget* parent, QgsComposition* c ): QWidget( parent ), mComposition( c )
{
    setupUi( this );
    blockSignals( true );
    createPaperEntries();

    //unit
    mPaperUnitsComboBox->addItem( tr( "mm" ) );
    mPaperUnitsComboBox->addItem( tr( "inch" ) );

    //orientation
    mPaperOrientationComboBox->insertItem( 0, tr( "Landscape" ) );
    mPaperOrientationComboBox->insertItem( 1, tr( "Portrait" ) );
    mPaperOrientationComboBox->setCurrentIndex( 0 );

    //read with/height from composition and find suitable entries to display
    displayCompositionWidthHeight();

    if ( mComposition )
    {
        mNumPagesSpinBox->setValue( mComposition->numPages() );

        updatePageStyle();

        //read printout resolution from composition
        mResolutionSpinBox->setValue( mComposition->printResolution() );

        //print as raster
        mPrintAsRasterCheckBox->setChecked( mComposition->printAsRaster() );

        // world file generation
        mGenerateWorldFileCheckBox->setChecked( mComposition->generateWorldFile() );

        // populate the map list
        mWorldFileMapComboBox->clear();
        QList<const QgsComposerMap*> availableMaps = mComposition->composerMapItems();
        QList<const QgsComposerMap*>::const_iterator mapItemIt = availableMaps.constBegin();
        for ( ; mapItemIt != availableMaps.constEnd(); ++mapItemIt )
        {
            mWorldFileMapComboBox->addItem( tr( "Map %1" ).arg(( *mapItemIt )->id() ), qVariantFromValue(( void* )*mapItemIt ) );
        }

        int idx = mWorldFileMapComboBox->findData( qVariantFromValue(( void* )mComposition->worldFileMap() ) );
        if ( idx != -1 )
        {
            mWorldFileMapComboBox->setCurrentIndex( idx );
        }

        // Connect to addition / removal of maps
        connect( mComposition, SIGNAL( composerMapAdded( QgsComposerMap* ) ), this, SLOT( onComposerMapAdded( QgsComposerMap* ) ) );
        connect( mComposition, SIGNAL( itemRemoved( QgsComposerItem* ) ), this, SLOT( onItemRemoved( QgsComposerItem* ) ) );

        mAlignmentToleranceSpinBox->setValue( mComposition->alignmentSnapTolerance() );

        //snap grid
        mGridResolutionSpinBox->setValue( mComposition->snapGridResolution() );
        mOffsetXSpinBox->setValue( mComposition->snapGridOffsetX() );
        mOffsetYSpinBox->setValue( mComposition->snapGridOffsetY() );

        mGridToleranceSpinBox->setValue( mComposition->snapGridTolerance() );
    }
    blockSignals( false );
}
Example #4
0
QgsCompositionWidget::QgsCompositionWidget( QWidget* parent, QgsComposition* c ): QWidget( parent ), mComposition( c )
{
  setupUi( this );
  blockSignals( true );
  createPaperEntries();

  //unit
  mPaperUnitsComboBox->addItem( tr( "mm" ) );
  mPaperUnitsComboBox->addItem( tr( "inch" ) );

  //orientation
  mPaperOrientationComboBox->insertItem( 0, tr( "Landscape" ) );
  mPaperOrientationComboBox->insertItem( 1, tr( "Portrait" ) );
  mPaperOrientationComboBox->setCurrentIndex( 0 );

  //read with/height from composition and find suitable entries to display
  displayCompositionWidthHeight();

  if ( mComposition )
  {
    mNumPagesSpinBox->setValue( mComposition->numPages() );
    connect( mComposition, SIGNAL( nPagesChanged() ), this, SLOT( setNumberPages() ) );

    updatePageStyle();

    //read printout resolution from composition
    mResolutionSpinBox->setValue( mComposition->printResolution() );

    //print as raster
    mPrintAsRasterCheckBox->setChecked( mComposition->printAsRaster() );

    // world file generation
    mGenerateWorldFileCheckBox->setChecked( mComposition->generateWorldFile() );

    // populate the map list
    mWorldFileMapComboBox->clear();
    QList<const QgsComposerMap*> availableMaps = mComposition->composerMapItems();
    QList<const QgsComposerMap*>::const_iterator mapItemIt = availableMaps.constBegin();
    for ( ; mapItemIt != availableMaps.constEnd(); ++mapItemIt )
    {
      mWorldFileMapComboBox->addItem( tr( "Map %1" ).arg(( *mapItemIt )->id() ), qVariantFromValue(( void* )*mapItemIt ) );
    }

    int idx = mWorldFileMapComboBox->findData( qVariantFromValue(( void* )mComposition->worldFileMap() ) );
    if ( idx != -1 )
    {
      mWorldFileMapComboBox->setCurrentIndex( idx );
    }

    // Connect to addition / removal of maps
    connect( mComposition, SIGNAL( composerMapAdded( QgsComposerMap* ) ), this, SLOT( onComposerMapAdded( QgsComposerMap* ) ) );
    connect( mComposition, SIGNAL( itemRemoved( QgsComposerItem* ) ), this, SLOT( onItemRemoved( QgsComposerItem* ) ) );

    mSnapToleranceSpinBox->setValue( mComposition->snapTolerance() );

    //snap grid
    mGridResolutionSpinBox->setValue( mComposition->snapGridResolution() );
    mOffsetXSpinBox->setValue( mComposition->snapGridOffsetX() );
    mOffsetYSpinBox->setValue( mComposition->snapGridOffsetY() );

    QgsAtlasComposition* atlas = &mComposition->atlasComposition();
    if ( atlas )
    {
      // repopulate data defined buttons if atlas layer changes
      connect( atlas, SIGNAL( coverageLayerChanged( QgsVectorLayer* ) ),
               this, SLOT( populateDataDefinedButtons() ) );
      connect( atlas, SIGNAL( toggled( bool ) ), this, SLOT( populateDataDefinedButtons() ) );
    }
  }

  connect( mPaperSizeDDBtn, SIGNAL( dataDefinedChanged( const QString& ) ), this, SLOT( updateDataDefinedProperty() ) );
  connect( mPaperSizeDDBtn, SIGNAL( dataDefinedActivated( bool ) ), this, SLOT( updateDataDefinedProperty() ) );
  connect( mPaperSizeDDBtn, SIGNAL( dataDefinedActivated( bool ) ), mPaperSizeComboBox, SLOT( setDisabled( bool ) ) );
  connect( mPaperWidthDDBtn, SIGNAL( dataDefinedChanged( const QString& ) ), this, SLOT( updateDataDefinedProperty() ) );
  connect( mPaperWidthDDBtn, SIGNAL( dataDefinedActivated( bool ) ), this, SLOT( updateDataDefinedProperty() ) );
  connect( mPaperWidthDDBtn, SIGNAL( dataDefinedActivated( bool ) ), mPaperWidthDoubleSpinBox, SLOT( setDisabled( bool ) ) );
  connect( mPaperHeightDDBtn, SIGNAL( dataDefinedChanged( const QString& ) ), this, SLOT( updateDataDefinedProperty() ) );
  connect( mPaperHeightDDBtn, SIGNAL( dataDefinedActivated( bool ) ), this, SLOT( updateDataDefinedProperty() ) );
  connect( mPaperHeightDDBtn, SIGNAL( dataDefinedActivated( bool ) ), mPaperHeightDoubleSpinBox, SLOT( setDisabled( bool ) ) );
  connect( mNumPagesDDBtn, SIGNAL( dataDefinedChanged( const QString& ) ), this, SLOT( updateDataDefinedProperty() ) );
  connect( mNumPagesDDBtn, SIGNAL( dataDefinedActivated( bool ) ), this, SLOT( updateDataDefinedProperty() ) );
  connect( mNumPagesDDBtn, SIGNAL( dataDefinedActivated( bool ) ), mNumPagesSpinBox, SLOT( setDisabled( bool ) ) );
  connect( mPaperOrientationDDBtn, SIGNAL( dataDefinedChanged( const QString& ) ), this, SLOT( updateDataDefinedProperty() ) );
  connect( mPaperOrientationDDBtn, SIGNAL( dataDefinedActivated( bool ) ), this, SLOT( updateDataDefinedProperty() ) );
  connect( mPaperOrientationDDBtn, SIGNAL( dataDefinedActivated( bool ) ), mPaperOrientationComboBox, SLOT( setDisabled( bool ) ) );

  //initialize data defined buttons
  populateDataDefinedButtons();

  blockSignals( false );
}