Skip to content
Permalink
Browse files

Merge pull request #590 from nyalldawson/advanced_composition

FFE? some blending fixes & composition feature requests
  • Loading branch information
NathanW2 committed May 14, 2013
2 parents 226c524 + 519fe2f commit db619edcb46b656c7d749dce3de046aba23a3eb0
@@ -208,6 +208,11 @@ class QgsComposerMap : QgsComposerItem
@note this function was added in version 1.4*/
void setGridAnnotationFont( const QFont& f );
QFont gridAnnotationFont() const;

/**Sets font color for grid annotations
@note this function was added in version 2.0*/
void setAnnotationFontColor( const QColor& c );
QColor annotationFontColor() const;

/**Sets coordinate precision for grid annotations
@note this function was added in version 1.4*/
@@ -242,6 +247,13 @@ class QgsComposerMap : QgsComposerItem
@note: this function was added in version 1.9*/
void setGridFrameWidth( double w );
double gridFrameWidth() const;

/** Returns the grid's blending mode
@note added in version 2.0*/
const QPainter::CompositionMode gridBlendMode() const;
/** Sets the grid's blending mode
@note added in version 2.0*/
void setGridBlendMode( const QPainter::CompositionMode blendMode );

/**In case of annotations, the bounding rectangle can be larger than the map item rectangle
@note this function was added in version 1.4*/
@@ -755,7 +755,25 @@ class QgsVectorLayer : QgsMapLayer
@note this method was added in version 1.1
*/
QgsVectorOverlay* findOverlayByType( const QString& typeName );


/* Set the blending mode used for rendering each feature
* @note added in 2.0
*/
void setFeatureBlendMode( const QPainter::CompositionMode blendMode );
/* Returns the current blending mode for features
* @note added in 2.0
*/
const QPainter::CompositionMode featureBlendMode() const;

/* Set the transparency for the vector layer
* @note added in 2.0
*/
void setLayerTransparency( const int layerTransparency );
/* Returns the current transparency for the vector layer
* @note added in 2.0
*/
const int layerTransparency() const;

//! Buffer with uncommitted editing operations. Only valid after editing has been turned on.
QgsVectorLayerEditBuffer* editBuffer();

@@ -632,9 +632,9 @@ void QgsComposer::on_mActionExportAsPDF_triggered()
showWMSPrintingWarning();
}

if ( containsBlendModes() )
if ( containsAdvancedEffects() )
{
showBlendModePrintingWarning();
showAdvancedEffectsWarning();
}

// If we are not printing as raster, temporarily disable advanced effects
@@ -828,9 +828,9 @@ void QgsComposer::on_mActionPrint_triggered()
showWMSPrintingWarning();
}

if ( containsBlendModes() )
if ( containsAdvancedEffects() )
{
showBlendModePrintingWarning();
showAdvancedEffectsWarning();
}

// If we are not printing as raster, temporarily disable advanced effects
@@ -2056,9 +2056,9 @@ bool QgsComposer::containsWMSLayer() const
return false;
}

bool QgsComposer::containsBlendModes() const
bool QgsComposer::containsAdvancedEffects() const
{
// Check if composer contains any blend modes
// Check if composer contains any blend modes or flattened layers for transparency
QMap<QgsComposerItem*, QWidget*>::const_iterator item_it = mItemWidgetMap.constBegin();
QgsComposerItem* currentItem = 0;
QgsComposerMap* currentMap = 0;
@@ -2071,11 +2071,11 @@ bool QgsComposer::containsBlendModes() const
{
return true;
}
// If item is a composer map, check if it contains any blended layers
// If item is a composer map, check if it contains any advanced effects
currentMap = dynamic_cast<QgsComposerMap *>( currentItem );
if ( currentMap )
{
if ( currentMap->containsBlendModes() )
if ( currentMap->containsAdvancedEffects() )
{
return true;
}
@@ -2087,6 +2087,14 @@ bool QgsComposer::containsBlendModes() const
return true;
}
}
if ( currentMap->gridEnabled() )
{
// map contains an grid, check its blend mode
if ( currentMap->gridBlendMode() != QPainter::CompositionMode_SourceOver )
{
return true;
}
}
}
}
return false;
@@ -2111,13 +2119,13 @@ void QgsComposer::showWMSPrintingWarning()
}
}

void QgsComposer::showBlendModePrintingWarning()
void QgsComposer::showAdvancedEffectsWarning()
{
if ( ! mComposition->printAsRaster() )
{
QgsMessageViewer* m = new QgsMessageViewer( this, QgisGui::ModalDialogFlags, false );
m->setWindowTitle( tr( "Project contains blend modes" ) );
m->setMessage( tr( "Blend modes are enabled in this project, which cannot be printed as vectors. Printing as a raster is recommended." ), QgsMessageOutput::MessageText );
m->setWindowTitle( tr( "Project contains composition effects" ) );
m->setMessage( tr( "Advanced composition effects such as blend modes or vector layer transparency are enabled in this project, which cannot be printed as vectors. Printing as a raster is recommended." ), QgsMessageOutput::MessageText );
m->setCheckBoxText( tr( "Print as raster" ) );
m->setCheckBoxState( Qt::Checked );
m->setCheckBoxVisible( true );
@@ -309,14 +309,14 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase
//! True if a composer map contains a WMS layer
bool containsWMSLayer() const;

//! True if a composer contains blend modes
bool containsBlendModes() const;
//! True if a composer contains advanced effects, such as blend modes
bool containsAdvancedEffects() const;

//! Displays a warning because of possible min/max size in WMS
void showWMSPrintingWarning();

//! Displays a warning because of incompatibility between blend modes and QPrinter
void showBlendModePrintingWarning();
void showAdvancedEffectsWarning();

//! Changes elements that are not suitable for this project
void cleanupAfterTemplateRead();
@@ -343,6 +343,9 @@ void QgsComposerMapWidget::updateGuiElements()
mFrameStyleComboBox->setCurrentIndex( mFrameStyleComboBox->findText( tr( "No frame" ) ) );
}

//grid blend mode
mGridBlendComboBox->setBlendMode( mComposerMap->gridBlendMode() );

//grid annotation format
QgsComposerMap::GridAnnotationFormat gf = mComposerMap->gridAnnotationFormat();
mAnnotationFormatComboBox->setCurrentIndex(( int )gf );
@@ -359,6 +362,10 @@ void QgsComposerMapWidget::updateGuiElements()
initAnnotationDirectionBox( mAnnotationDirectionComboBoxTop, mComposerMap->gridAnnotationDirection( QgsComposerMap::Top ) );
initAnnotationDirectionBox( mAnnotationDirectionComboBoxBottom, mComposerMap->gridAnnotationDirection( QgsComposerMap::Bottom ) );

mAnnotationFontColorButton->setColor( mComposerMap->annotationFontColor() );
mAnnotationFontColorButton->setColorDialogTitle( tr( "Select font color" ) );
mAnnotationFontColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );

mDistanceToMapFrameSpinBox->setValue( mComposerMap->annotationFrameDistance() );

if ( mComposerMap->showGridAnnotation() )
@@ -423,6 +430,7 @@ void QgsComposerMapWidget::blockAllSignals( bool b )
mSetToMapCanvasExtentButton->blockSignals( b );
mUpdatePreviewButton->blockSignals( b );
mGridLineStyleButton->blockSignals( b );
mGridBlendComboBox->blockSignals( b );
mDrawAnnotationCheckableGroupBox->blockSignals( b );
mAnnotationFontButton->blockSignals( b );
mAnnotationFormatComboBox->blockSignals( b );
@@ -436,6 +444,7 @@ void QgsComposerMapWidget::blockAllSignals( bool b )
mAnnotationDirectionComboBoxTop->blockSignals( b );
mAnnotationDirectionComboBoxBottom->blockSignals( b );
mCoordinatePrecisionSpinBox->blockSignals( b );
mAnnotationFontColorButton->blockSignals( b );
mDrawCanvasItemsCheckBox->blockSignals( b );
mFrameStyleComboBox->blockSignals( b );
mFrameWidthSpinBox->blockSignals( b );
@@ -705,6 +714,16 @@ void QgsComposerMapWidget::on_mCrossWidthSpinBox_valueChanged( double d )
mComposerMap->endCommand();
}

void QgsComposerMapWidget::on_mGridBlendComboBox_currentIndexChanged( int index )
{
Q_UNUSED( index );
if ( mComposerMap )
{
mComposerMap->setGridBlendMode( mGridBlendComboBox->blendMode() );
}

}

void QgsComposerMapWidget::on_mAnnotationFontButton_clicked()
{
if ( !mComposerMap )
@@ -729,6 +748,18 @@ void QgsComposerMapWidget::on_mAnnotationFontButton_clicked()
}
}

void QgsComposerMapWidget::on_mAnnotationFontColorButton_colorChanged( const QColor& newFontColor )
{
if ( !mComposerMap )
{
return;
}
mComposerMap->beginCommand( tr( "Label font changed" ) );
mComposerMap->setAnnotationFontColor( newFontColor );
mComposerMap->update();
mComposerMap->endCommand();
}

void QgsComposerMapWidget::on_mDistanceToMapFrameSpinBox_valueChanged( double d )
{
if ( !mComposerMap )
@@ -60,7 +60,9 @@ class QgsComposerMapWidget: public QWidget, private Ui::QgsComposerMapWidgetBase
void on_mGridLineStyleButton_clicked();
void on_mGridTypeComboBox_currentIndexChanged( const QString& text );
void on_mCrossWidthSpinBox_valueChanged( double d );
void on_mGridBlendComboBox_currentIndexChanged( int index );
void on_mAnnotationFontButton_clicked();
void on_mAnnotationFontColorButton_colorChanged( const QColor& newFontColor );
void on_mDistanceToMapFrameSpinBox_valueChanged( double d );

void on_mAnnotationFormatComboBox_currentIndexChanged( int index );

0 comments on commit db619ed

Please sign in to comment.
You can’t perform that action at this time.