Skip to content

Commit db619ed

Browse files
committed
Merge pull request #590 from nyalldawson/advanced_composition
FFE? some blending fixes & composition feature requests
2 parents 226c524 + 519fe2f commit db619ed

21 files changed

+490
-59
lines changed

python/core/composer/qgscomposermap.sip

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,11 @@ class QgsComposerMap : QgsComposerItem
208208
@note this function was added in version 1.4*/
209209
void setGridAnnotationFont( const QFont& f );
210210
QFont gridAnnotationFont() const;
211+
212+
/**Sets font color for grid annotations
213+
@note this function was added in version 2.0*/
214+
void setAnnotationFontColor( const QColor& c );
215+
QColor annotationFontColor() const;
211216

212217
/**Sets coordinate precision for grid annotations
213218
@note this function was added in version 1.4*/
@@ -242,6 +247,13 @@ class QgsComposerMap : QgsComposerItem
242247
@note: this function was added in version 1.9*/
243248
void setGridFrameWidth( double w );
244249
double gridFrameWidth() const;
250+
251+
/** Returns the grid's blending mode
252+
@note added in version 2.0*/
253+
const QPainter::CompositionMode gridBlendMode() const;
254+
/** Sets the grid's blending mode
255+
@note added in version 2.0*/
256+
void setGridBlendMode( const QPainter::CompositionMode blendMode );
245257

246258
/**In case of annotations, the bounding rectangle can be larger than the map item rectangle
247259
@note this function was added in version 1.4*/

python/core/qgsvectorlayer.sip

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,25 @@ class QgsVectorLayer : QgsMapLayer
755755
@note this method was added in version 1.1
756756
*/
757757
QgsVectorOverlay* findOverlayByType( const QString& typeName );
758-
758+
759+
/* Set the blending mode used for rendering each feature
760+
* @note added in 2.0
761+
*/
762+
void setFeatureBlendMode( const QPainter::CompositionMode blendMode );
763+
/* Returns the current blending mode for features
764+
* @note added in 2.0
765+
*/
766+
const QPainter::CompositionMode featureBlendMode() const;
767+
768+
/* Set the transparency for the vector layer
769+
* @note added in 2.0
770+
*/
771+
void setLayerTransparency( const int layerTransparency );
772+
/* Returns the current transparency for the vector layer
773+
* @note added in 2.0
774+
*/
775+
const int layerTransparency() const;
776+
759777
//! Buffer with uncommitted editing operations. Only valid after editing has been turned on.
760778
QgsVectorLayerEditBuffer* editBuffer();
761779

src/app/composer/qgscomposer.cpp

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -632,9 +632,9 @@ void QgsComposer::on_mActionExportAsPDF_triggered()
632632
showWMSPrintingWarning();
633633
}
634634

635-
if ( containsBlendModes() )
635+
if ( containsAdvancedEffects() )
636636
{
637-
showBlendModePrintingWarning();
637+
showAdvancedEffectsWarning();
638638
}
639639

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

831-
if ( containsBlendModes() )
831+
if ( containsAdvancedEffects() )
832832
{
833-
showBlendModePrintingWarning();
833+
showAdvancedEffectsWarning();
834834
}
835835

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

2059-
bool QgsComposer::containsBlendModes() const
2059+
bool QgsComposer::containsAdvancedEffects() const
20602060
{
2061-
// Check if composer contains any blend modes
2061+
// Check if composer contains any blend modes or flattened layers for transparency
20622062
QMap<QgsComposerItem*, QWidget*>::const_iterator item_it = mItemWidgetMap.constBegin();
20632063
QgsComposerItem* currentItem = 0;
20642064
QgsComposerMap* currentMap = 0;
@@ -2071,11 +2071,11 @@ bool QgsComposer::containsBlendModes() const
20712071
{
20722072
return true;
20732073
}
2074-
// If item is a composer map, check if it contains any blended layers
2074+
// If item is a composer map, check if it contains any advanced effects
20752075
currentMap = dynamic_cast<QgsComposerMap *>( currentItem );
20762076
if ( currentMap )
20772077
{
2078-
if ( currentMap->containsBlendModes() )
2078+
if ( currentMap->containsAdvancedEffects() )
20792079
{
20802080
return true;
20812081
}
@@ -2087,6 +2087,14 @@ bool QgsComposer::containsBlendModes() const
20872087
return true;
20882088
}
20892089
}
2090+
if ( currentMap->gridEnabled() )
2091+
{
2092+
// map contains an grid, check its blend mode
2093+
if ( currentMap->gridBlendMode() != QPainter::CompositionMode_SourceOver )
2094+
{
2095+
return true;
2096+
}
2097+
}
20902098
}
20912099
}
20922100
return false;
@@ -2111,13 +2119,13 @@ void QgsComposer::showWMSPrintingWarning()
21112119
}
21122120
}
21132121

2114-
void QgsComposer::showBlendModePrintingWarning()
2122+
void QgsComposer::showAdvancedEffectsWarning()
21152123
{
21162124
if ( ! mComposition->printAsRaster() )
21172125
{
21182126
QgsMessageViewer* m = new QgsMessageViewer( this, QgisGui::ModalDialogFlags, false );
2119-
m->setWindowTitle( tr( "Project contains blend modes" ) );
2120-
m->setMessage( tr( "Blend modes are enabled in this project, which cannot be printed as vectors. Printing as a raster is recommended." ), QgsMessageOutput::MessageText );
2127+
m->setWindowTitle( tr( "Project contains composition effects" ) );
2128+
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 );
21212129
m->setCheckBoxText( tr( "Print as raster" ) );
21222130
m->setCheckBoxState( Qt::Checked );
21232131
m->setCheckBoxVisible( true );

src/app/composer/qgscomposer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,14 +309,14 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase
309309
//! True if a composer map contains a WMS layer
310310
bool containsWMSLayer() const;
311311

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

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

318318
//! Displays a warning because of incompatibility between blend modes and QPrinter
319-
void showBlendModePrintingWarning();
319+
void showAdvancedEffectsWarning();
320320

321321
//! Changes elements that are not suitable for this project
322322
void cleanupAfterTemplateRead();

src/app/composer/qgscomposermapwidget.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,9 @@ void QgsComposerMapWidget::updateGuiElements()
343343
mFrameStyleComboBox->setCurrentIndex( mFrameStyleComboBox->findText( tr( "No frame" ) ) );
344344
}
345345

346+
//grid blend mode
347+
mGridBlendComboBox->setBlendMode( mComposerMap->gridBlendMode() );
348+
346349
//grid annotation format
347350
QgsComposerMap::GridAnnotationFormat gf = mComposerMap->gridAnnotationFormat();
348351
mAnnotationFormatComboBox->setCurrentIndex(( int )gf );
@@ -359,6 +362,10 @@ void QgsComposerMapWidget::updateGuiElements()
359362
initAnnotationDirectionBox( mAnnotationDirectionComboBoxTop, mComposerMap->gridAnnotationDirection( QgsComposerMap::Top ) );
360363
initAnnotationDirectionBox( mAnnotationDirectionComboBoxBottom, mComposerMap->gridAnnotationDirection( QgsComposerMap::Bottom ) );
361364

365+
mAnnotationFontColorButton->setColor( mComposerMap->annotationFontColor() );
366+
mAnnotationFontColorButton->setColorDialogTitle( tr( "Select font color" ) );
367+
mAnnotationFontColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
368+
362369
mDistanceToMapFrameSpinBox->setValue( mComposerMap->annotationFrameDistance() );
363370

364371
if ( mComposerMap->showGridAnnotation() )
@@ -423,6 +430,7 @@ void QgsComposerMapWidget::blockAllSignals( bool b )
423430
mSetToMapCanvasExtentButton->blockSignals( b );
424431
mUpdatePreviewButton->blockSignals( b );
425432
mGridLineStyleButton->blockSignals( b );
433+
mGridBlendComboBox->blockSignals( b );
426434
mDrawAnnotationCheckableGroupBox->blockSignals( b );
427435
mAnnotationFontButton->blockSignals( b );
428436
mAnnotationFormatComboBox->blockSignals( b );
@@ -436,6 +444,7 @@ void QgsComposerMapWidget::blockAllSignals( bool b )
436444
mAnnotationDirectionComboBoxTop->blockSignals( b );
437445
mAnnotationDirectionComboBoxBottom->blockSignals( b );
438446
mCoordinatePrecisionSpinBox->blockSignals( b );
447+
mAnnotationFontColorButton->blockSignals( b );
439448
mDrawCanvasItemsCheckBox->blockSignals( b );
440449
mFrameStyleComboBox->blockSignals( b );
441450
mFrameWidthSpinBox->blockSignals( b );
@@ -705,6 +714,16 @@ void QgsComposerMapWidget::on_mCrossWidthSpinBox_valueChanged( double d )
705714
mComposerMap->endCommand();
706715
}
707716

717+
void QgsComposerMapWidget::on_mGridBlendComboBox_currentIndexChanged( int index )
718+
{
719+
Q_UNUSED( index );
720+
if ( mComposerMap )
721+
{
722+
mComposerMap->setGridBlendMode( mGridBlendComboBox->blendMode() );
723+
}
724+
725+
}
726+
708727
void QgsComposerMapWidget::on_mAnnotationFontButton_clicked()
709728
{
710729
if ( !mComposerMap )
@@ -729,6 +748,18 @@ void QgsComposerMapWidget::on_mAnnotationFontButton_clicked()
729748
}
730749
}
731750

751+
void QgsComposerMapWidget::on_mAnnotationFontColorButton_colorChanged( const QColor& newFontColor )
752+
{
753+
if ( !mComposerMap )
754+
{
755+
return;
756+
}
757+
mComposerMap->beginCommand( tr( "Label font changed" ) );
758+
mComposerMap->setAnnotationFontColor( newFontColor );
759+
mComposerMap->update();
760+
mComposerMap->endCommand();
761+
}
762+
732763
void QgsComposerMapWidget::on_mDistanceToMapFrameSpinBox_valueChanged( double d )
733764
{
734765
if ( !mComposerMap )

src/app/composer/qgscomposermapwidget.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ class QgsComposerMapWidget: public QWidget, private Ui::QgsComposerMapWidgetBase
6060
void on_mGridLineStyleButton_clicked();
6161
void on_mGridTypeComboBox_currentIndexChanged( const QString& text );
6262
void on_mCrossWidthSpinBox_valueChanged( double d );
63+
void on_mGridBlendComboBox_currentIndexChanged( int index );
6364
void on_mAnnotationFontButton_clicked();
65+
void on_mAnnotationFontColorButton_colorChanged( const QColor& newFontColor );
6466
void on_mDistanceToMapFrameSpinBox_valueChanged( double d );
6567

6668
void on_mAnnotationFormatComboBox_currentIndexChanged( int index );

0 commit comments

Comments
 (0)