forked from mbernasocchi/QGIS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'composer_blend' of https://github.com/nyalldawson/Quant…
- Loading branch information
Showing
10 changed files
with
251 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/*************************************************************************** | ||
qgscomposereffect.cpp | ||
------------------- | ||
begin : March 2013 | ||
copyright : (C) 2013 by Nyall Dawson | ||
email : [email protected] | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include <QPainter> | ||
|
||
#include "qgscomposereffect.h" | ||
|
||
QgsComposerEffect::QgsComposerEffect() | ||
: mCompositionMode( QPainter::CompositionMode_SourceOver ) | ||
{ | ||
} | ||
|
||
QgsComposerEffect::~QgsComposerEffect() | ||
{ | ||
} | ||
|
||
void QgsComposerEffect::draw( QPainter *painter ) | ||
{ | ||
QPoint offset; | ||
QPixmap pixmap; | ||
|
||
// Set desired composition mode then draw source | ||
painter->setCompositionMode( mCompositionMode ); | ||
|
||
if ( mCompositionMode == QPainter::CompositionMode_SourceOver ) | ||
{ | ||
// Normal (sourceover) blending, do faster drawSource operation | ||
drawSource( painter ); | ||
return; | ||
} | ||
|
||
// Otherwise, draw using pixmap so QPrinter output works as expected | ||
if ( sourceIsPixmap() ) | ||
{ | ||
// No point in drawing in device coordinates (pixmap will be scaled anyways). | ||
pixmap = sourcePixmap( Qt::LogicalCoordinates, &offset ); | ||
} | ||
else | ||
{ | ||
// Draw pixmap in device coordinates to avoid pixmap scaling; | ||
pixmap = sourcePixmap( Qt::DeviceCoordinates, &offset ); | ||
painter->setWorldTransform( QTransform() ); | ||
} | ||
|
||
painter->drawPixmap( offset, pixmap ); | ||
|
||
} | ||
|
||
void QgsComposerEffect::setCompositionMode( const QPainter::CompositionMode compositionMode ) | ||
{ | ||
mCompositionMode = compositionMode; | ||
|
||
// force redraw with new composition mode | ||
update(); | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/*************************************************************************** | ||
qgscomposereffect.h | ||
------------------- | ||
begin : March 2013 | ||
copyright : (C) 2013 by Nyall Dawson | ||
email : [email protected] | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#ifndef QGSCOMPOSEREFFECT_H | ||
#define QGSCOMPOSEREFFECT_H | ||
|
||
#include <QtGui> | ||
#include <QGraphicsEffect> | ||
|
||
class CORE_EXPORT QgsComposerEffect : public QGraphicsEffect | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
QgsComposerEffect(); | ||
~QgsComposerEffect(); | ||
|
||
void setCompositionMode( const QPainter::CompositionMode compositionMode ); | ||
|
||
protected: | ||
/** Called whenever source needs to be drawn */ | ||
virtual void draw( QPainter *painter ); | ||
|
||
private: | ||
|
||
QPainter::CompositionMode mCompositionMode; | ||
}; | ||
|
||
#endif // QGSCOMPOSEREFFECT_H | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.