110 #include "private/qgraphicsitem_p.h" 112 #include <QtGui/qgraphicsitem.h> 114 #include <QtGui/qimage.h> 115 #include <QtGui/qpainter.h> 116 #include <QtGui/qpaintengine.h> 117 #include <QtCore/qrect.h> 118 #include <QtCore/qdebug.h> 119 #include <private/qdrawhelper_p.h> 121 #ifndef QT_NO_GRAPHICSEFFECT 163 return d_func()->boundingRect(system);
179 return d->source->boundingRect(system);
191 return d_func()->graphicsItem();
202 return d_func()->widget();
213 return d_func()->styleOption();
240 d_func()->draw(painter);
259 d->source->draw(painter);
284 return d_func()->isPixmap();
297 return source() ? source()->isPixmap() :
false;
325 return pixmapItem->
pixmap();
329 && !static_cast<const QGraphicsItemEffectSourcePrivate *>(d_func())->
info) {
330 qWarning(
"QGraphicsEffectSource::pixmap: Not yet implemented, lacking device context");
335 if (item &&
d->m_cachedSystem == system &&
d->m_cachedMode == mode)
339 pm =
d->pixmap(system, &
d->m_cachedOffset, mode);
340 d->m_cachedSystem = system;
341 d->m_cachedMode = mode;
343 d->invalidateCache();
348 *offset =
d->m_cachedOffset;
374 return d->source->pixmap(system, offset, mode);
385 m_cachedOffset = offset;
391 && (reason == EffectRectChanged
422 d->setGraphicsEffectSource(0);
479 if (
d->isEnabled == enable)
482 d->isEnabled = enable;
484 d->source->d_func()->effectBoundingRectChanged();
485 d->source->d_func()->invalidateCache();
546 d->source->d_func()->effectBoundingRectChanged();
658 return d->filter->color();
664 if (
d->filter->color() ==
color)
667 d->filter->setColor(color);
685 return d->filter->strength();
694 d->filter->setStrength(strength);
736 d->filter->draw(painter, offset, pixmap);
748 d->filter->draw(painter, offset, pixmap);
834 return d->filter->radius();
843 d->filter->setRadius(radius);
874 return d->filter->blurHints();
880 if (
d->filter->blurHints() == hints)
883 d->filter->setBlurHints(hints);
903 return d->filter->boundingRectFor(rect);
912 if (
d->filter->radius() < 1) {
926 d->filter->draw(painter, offset, pixmap);
986 return d->filter->offset();
992 if (
d->filter->offset() ==
offset)
995 d->filter->setOffset(offset);
1053 return d->filter->blurRadius();
1062 d->filter->setBlurRadius(blurRadius);
1092 return d->filter->color();
1098 if (
d->filter->color() ==
color)
1101 d->filter->setColor(color);
1122 return d->filter->boundingRectFor(rect);
1131 if (
d->filter->blurRadius() <= 0 &&
d->filter->offset().isNull()) {
1148 d->filter->draw(painter, offset, pixmap);
1217 d->isFullyOpaque = 0;
1254 return d->opacityMask;
1260 if (
d->opacityMask == mask)
1263 d->opacityMask = mask;
1288 if (
d->isFullyTransparent)
1292 if (
d->isFullyOpaque && !
d->hasOpacityMask) {
1306 if (
d->hasOpacityMask) {
1331 #endif //QT_NO_GRAPHICSEFFECT QPixmap pixmap(Qt::CoordinateSystem system=Qt::LogicalCoordinates, QPoint *offset=0, QGraphicsEffect::PixmapPadMode mode=QGraphicsEffect::PadToEffectiveBoundingRect) const
Returns a pixmap with the source painted into it.
void draw(QPainter *painter)
Reimplemented Function
void offsetChanged(const QPointF &offset)
This signal is emitted whenever the effect's shadow offset changes.
The QPainter class performs low-level painting on widgets and other paint devices.
The QColor class provides colors based on RGB, HSV or CMYK values.
void colorChanged(const QColor &color)
This signal is emitted whenever the effect's color changes.
bool sourceIsPixmap() const
Returns true if the source effectively is a pixmap, e.g., a QGraphicsPixmapItem.
QGraphicsEffectSource(QGraphicsEffectSourcePrivate &dd, QObject *parent=0)
void setBlurHints(BlurHints hints)
QPixmap sourcePixmap(Qt::CoordinateSystem system=Qt::LogicalCoordinates, QPoint *offset=0, PixmapPadMode mode=PadToEffectiveBoundingRect) const
Returns a pixmap with the source painted into it.
QRectF boundingRectFor(const QRectF &rect) const
Reimplemented Function
void enabledChanged(bool enabled)
This signal is emitted whenever the effect is enabled or disabled.
QGraphicsColorizeEffect(QObject *parent=0)
Constructs a new QGraphicsColorizeEffect instance.
static mach_timebase_info_data_t info
#define QT_END_NAMESPACE
This macro expands to.
~QGraphicsDropShadowEffect()
Destroys the effect.
virtual void sourceChanged(ChangeFlags flags)
This virtual function is called by QGraphicsEffect to notify the effect that the source has changed...
virtual ~QGraphicsEffect()
Removes the effect from the source, and destroys the graphics effect.
QGraphicsDropShadowEffect(QObject *parent=0)
Constructs a new QGraphicsDropShadowEffect instance.
void opacityMaskChanged(const QBrush &mask)
This signal is emitted whenever the effect's opacity mask changes.
The QPointF class defines a point in the plane using floating point precision.
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
void restore()
Restores the current painter state (pops a saved state off the stack).
QRectF sourceBoundingRect(Qt::CoordinateSystem system=Qt::LogicalCoordinates) const
Returns the bounding rectangle of the source mapped to the given system.
void setBlurRadius(qreal blurRadius)
void drawSource(QPainter *painter)
Draws the source directly using the given painter.
The QGraphicsEffectSource class represents the source on which a QGraphicsEffect is installed on...
~QGraphicsColorizeEffect()
Destroys the effect.
void draw(QPainter *painter)
Reimplemented Function
static Q_DECL_CONSTEXPR bool qFuzzyCompare(double p1, double p2)
const QGraphicsItem * graphicsItem() const
Returns a pointer to the item if this source is a QGraphicsItem; otherwise returns 0...
The QGraphicsDropShadowEffect class provides a drop shadow effect.
QRectF boundingRect() const
Returns the effective bounding rectangle for this effect, i.e., the bounding rectangle of the source ...
void draw(QPainter *painter)
Draws the source using the given painter.
~QGraphicsOpacityEffect()
Destroys the effect.
The QObject class is the base class of all Qt objects.
~QGraphicsBlurEffect()
Destroys the effect.
The QGraphicsBlurEffect class provides a blur effect.
void draw(QPainter *painter)
Reimplemented Function
void updateBoundingRect()
This function notifies the effect framework when the effect's bounding rectangle has changed...
void draw(QPainter *painter)
Reimplemented Function
void save()
Saves the current painter state (pushes the state onto a stack).
static QPixmap * find(const QString &key)
bool isPixmap() const
Returns true if the source effectively is a pixmap, e.g., a QGraphicsPixmapItem.
void setOffset(const QPointF &ofs)
void colorChanged(const QColor &color)
This signal is emitted whenever the effect's color changes.
void invalidateCache(InvalidateReason reason=SourceChanged) const
QRectF boundingRect(Qt::CoordinateSystem coordinateSystem=Qt::LogicalCoordinates) const
Returns the bounding rectangle of the source mapped to the given system.
#define QT_BEGIN_NAMESPACE
This macro expands to.
The QRectF class defines a rectangle in the plane using floating point precision. ...
The QGraphicsColorizeEffect class provides a colorize effect.
QRectF boundingRectFor(const QRectF &rect) const
Reimplemented Function
The QStyleOption class stores the parameters used by QStyle functions.
void blurRadiusChanged(qreal blurRadius)
This signal is emitted whenever the effect's blur radius changes.
virtual Type type() const =0
Reimplement this function to return the paint engine Type.
void setBlurRadius(qreal blurRadius)
BlurHints blurHints() const
Q_CORE_EXPORT void qWarning(const char *,...)
void blurRadiusChanged(qreal blurRadius)
This signal is emitted whenever the effect's blur radius changes.
QPaintEngine * paintEngine() const
Returns the paint engine that the painter is currently operating on if the painter is active; otherwi...
Qt::BrushStyle style() const
Returns the brush style.
PixmapPadMode
This enum describes how the pixmap returned from sourcePixmap should be padded.
QGraphicsOpacityEffect(QObject *parent=0)
Constructs a new QGraphicsOpacityEffect instance.
void setColor(const QColor &c)
QPixmap pixmap() const
Returns the item's pixmap, or an invalid QPixmap if no pixmap has been set.
void setOpacityMask(const QBrush &mask)
~QGraphicsEffectSource()
Destroys the effect source.
void blurHintsChanged(BlurHints hints)
This signal is emitted whenever the effect's blur hints changes.
void opacityChanged(qreal opacity)
This signal is emitted whenever the effect's opacity changes.
void setRenderHints(RenderHints hints, bool on=true)
Sets the given render hints on the painter if on is true; otherwise clears the render hints...
The QBrush class defines the fill pattern of shapes drawn by QPainter.
The QGraphicsOpacityEffect class provides an opacity effect.
void setCachedOffset(const QPoint &offset)
void setEnabled(bool enable)
void setOpacity(qreal opacity)
void setColor(const QColor &color)
const QTransform & worldTransform() const
Returns the world transformation matrix.
void setCompositionMode(CompositionMode mode)
Sets the composition mode to the given mode.
QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
QObject * parent() const
Returns a pointer to the parent object.
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
The QPoint class defines a point in the plane using integer precision.
Q_DECL_CONSTEXPR const T & qBound(const T &min, const T &val, const T &max)
void update()
Schedules a redraw of the effect.
virtual QRectF boundingRectFor(const QRectF &sourceRect) const
Returns the effective bounding rectangle for this effect, given the provided rect in the device coord...
void setWorldTransform(const QTransform &matrix, bool combine=false)
Sets the world transformation matrix.
QRect rect() const
Returns the pixmap's enclosing rectangle.
int y() const
Returns the y coordinate of this point.
QGraphicsEffect(QObject *parent=0)
Constructs a new QGraphicsEffect instance having the specified parent.
The QPixmap class is an off-screen image representation that can be used as a paint device...
void strengthChanged(qreal strength)
This signal is emitted whenever setStrength() changes the colorize strength property.
virtual ~QGraphicsEffectSourcePrivate()
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device...
static Q_DECL_CONSTEXPR bool qFuzzyIsNull(double d)
static void remove(const QString &key)
Removes the pixmap associated with key from the cache.
RenderHints renderHints() const
Returns a flag that specifies the rendering hints that are set for this painter.
int x() const
Returns the x coordinate of this point.
void setOpacity(qreal opacity)
Sets the opacity of the painter to opacity.
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
void setStrength(qreal strength)
QPointF offset() const
Returns the pixmap item's offset, which defines the point of the top-left corner of the pixmap...
const QStyleOption * styleOption() const
Returns a pointer to the style options (used when drawing the source) if available; otherwise returns...
QGraphicsEffectSource * source() const
Returns a pointer to the source, which provides extra context information that can be useful for the ...
The QGraphicsPixmapItem class provides a pixmap item that you can add to a QGraphicsScene.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
QBrush opacityMask() const
QGraphicsBlurEffect(QObject *parent=0)
Constructs a new QGraphicsBlurEffect instance.
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
The QGraphicsEffect class is the base class for all graphics effects.
const QWidget * widget() const
Returns a pointer to the widget if this source is a QWidget; otherwise returns 0. ...
void update()
Schedules a redraw of the source.
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.