Make QPen default to 1-width non-cosmetic.
Use the Qt4CompatiblePainting render hint when painting with QPainter to treat default constructed QPens as cosmetic still. The NonCosmeticDefaultPen render hint gets documented as obsolete, since it was in any case not respected by the raster nor OpenGL paint engine. Change-Id: I04d910e9700baf7f13a8aac07a3633014bb9283e Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
This commit is contained in:
parent
11566de014
commit
b213d5bfa3
5
dist/changes-5.0.0
vendored
5
dist/changes-5.0.0
vendored
@ -519,6 +519,11 @@ QtGui
|
|||||||
rectangle filling. It's possible to still get the old behavior by setting the
|
rectangle filling. It's possible to still get the old behavior by setting the
|
||||||
QPainter::Qt4CompatiblePainting render hint.
|
QPainter::Qt4CompatiblePainting render hint.
|
||||||
|
|
||||||
|
* Behavioral change regarding QPen: The default QPen constructors now create a
|
||||||
|
1-width non-cosmetic pen as opposed to a 0-width cosmetic pen. The old
|
||||||
|
behavior can be emulated by setting the QPainter::Qt4CompatiblePainting
|
||||||
|
render hint when painting.
|
||||||
|
|
||||||
QtWidgets
|
QtWidgets
|
||||||
---------
|
---------
|
||||||
* QInputContext removed as well as related getters and setters on QWidget and QApplication.
|
* QInputContext removed as well as related getters and setters on QWidget and QApplication.
|
||||||
|
@ -1194,7 +1194,7 @@ void QOpenGL2PaintEngineEx::stroke(const QVectorPath &path, const QPen &pen)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
QOpenGL2PaintEngineState *s = state();
|
QOpenGL2PaintEngineState *s = state();
|
||||||
if (pen.isCosmetic() && !qt_scaleForTransform(s->transform(), 0)) {
|
if (qt_pen_is_cosmetic(pen, state()->renderHints) && !qt_scaleForTransform(s->transform(), 0)) {
|
||||||
// QTriangulatingStroker class is not meant to support cosmetically sheared strokes.
|
// QTriangulatingStroker class is not meant to support cosmetically sheared strokes.
|
||||||
QPaintEngineEx::stroke(path, pen);
|
QPaintEngineEx::stroke(path, pen);
|
||||||
return;
|
return;
|
||||||
@ -1229,15 +1229,16 @@ void QOpenGL2PaintEngineExPrivate::stroke(const QVectorPath &path, const QPen &p
|
|||||||
: QRectF(0, 0, width, height));
|
: QRectF(0, 0, width, height));
|
||||||
|
|
||||||
if (penStyle == Qt::SolidLine) {
|
if (penStyle == Qt::SolidLine) {
|
||||||
stroker.process(path, pen, clip);
|
stroker.process(path, pen, clip, s->renderHints);
|
||||||
|
|
||||||
} else { // Some sort of dash
|
} else { // Some sort of dash
|
||||||
dasher.process(path, pen, clip);
|
dasher.process(path, pen, clip, s->renderHints);
|
||||||
|
|
||||||
QVectorPath dashStroke(dasher.points(),
|
QVectorPath dashStroke(dasher.points(),
|
||||||
dasher.elementCount(),
|
dasher.elementCount(),
|
||||||
dasher.elementTypes());
|
dasher.elementTypes(),
|
||||||
stroker.process(dashStroke, pen, clip);
|
s->renderHints);
|
||||||
|
stroker.process(dashStroke, pen, clip, s->renderHints);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!stroker.vertexCount())
|
if (!stroker.vertexCount())
|
||||||
@ -1261,7 +1262,7 @@ void QOpenGL2PaintEngineExPrivate::stroke(const QVectorPath &path, const QPen &p
|
|||||||
? qMax(pen.miterLimit() * width, width)
|
? qMax(pen.miterLimit() * width, width)
|
||||||
: width;
|
: width;
|
||||||
|
|
||||||
if (pen.isCosmetic())
|
if (qt_pen_is_cosmetic(pen, q->state()->renderHints))
|
||||||
extra = extra * inverseScale;
|
extra = extra * inverseScale;
|
||||||
|
|
||||||
QRectF bounds = path.controlPointRect().adjusted(-extra, -extra, extra, extra);
|
QRectF bounds = path.controlPointRect().adjusted(-extra, -extra, extra, extra);
|
||||||
|
@ -81,7 +81,7 @@ static inline void skipDuplicatePoints(const qreal **pts, const qreal *endPts)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QTriangulatingStroker::process(const QVectorPath &path, const QPen &pen, const QRectF &)
|
void QTriangulatingStroker::process(const QVectorPath &path, const QPen &pen, const QRectF &, QPainter::RenderHints hints)
|
||||||
{
|
{
|
||||||
const qreal *pts = path.points();
|
const qreal *pts = path.points();
|
||||||
const QPainterPath::ElementType *types = path.elements();
|
const QPainterPath::ElementType *types = path.elements();
|
||||||
@ -95,7 +95,7 @@ void QTriangulatingStroker::process(const QVectorPath &path, const QPen &pen, co
|
|||||||
|
|
||||||
m_width = realWidth / 2;
|
m_width = realWidth / 2;
|
||||||
|
|
||||||
bool cosmetic = pen.isCosmetic();
|
bool cosmetic = qt_pen_is_cosmetic(pen, hints);
|
||||||
if (cosmetic) {
|
if (cosmetic) {
|
||||||
m_width = m_width * m_inv_scale;
|
m_width = m_width * m_inv_scale;
|
||||||
}
|
}
|
||||||
@ -519,14 +519,14 @@ QDashedStrokeProcessor::QDashedStrokeProcessor()
|
|||||||
m_dash_stroker.setCubicToHook(qdashprocessor_cubicTo);
|
m_dash_stroker.setCubicToHook(qdashprocessor_cubicTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QDashedStrokeProcessor::process(const QVectorPath &path, const QPen &pen, const QRectF &clip)
|
void QDashedStrokeProcessor::process(const QVectorPath &path, const QPen &pen, const QRectF &clip, QPainter::RenderHints hints)
|
||||||
{
|
{
|
||||||
|
|
||||||
const qreal *pts = path.points();
|
const qreal *pts = path.points();
|
||||||
const QPainterPath::ElementType *types = path.elements();
|
const QPainterPath::ElementType *types = path.elements();
|
||||||
int count = path.elementCount();
|
int count = path.elementCount();
|
||||||
|
|
||||||
bool cosmetic = pen.isCosmetic();
|
bool cosmetic = qt_pen_is_cosmetic(pen, hints);
|
||||||
|
|
||||||
m_points.reset();
|
m_points.reset();
|
||||||
m_types.reset();
|
m_types.reset();
|
||||||
|
@ -55,7 +55,7 @@ class Q_GUI_EXPORT QTriangulatingStroker
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QTriangulatingStroker() : m_vertices(0) {}
|
QTriangulatingStroker() : m_vertices(0) {}
|
||||||
void process(const QVectorPath &path, const QPen &pen, const QRectF &clip);
|
void process(const QVectorPath &path, const QPen &pen, const QRectF &clip, QPainter::RenderHints hints);
|
||||||
|
|
||||||
inline int vertexCount() const { return m_vertices.size(); }
|
inline int vertexCount() const { return m_vertices.size(); }
|
||||||
inline const float *vertices() const { return m_vertices.data(); }
|
inline const float *vertices() const { return m_vertices.data(); }
|
||||||
@ -97,7 +97,7 @@ class Q_GUI_EXPORT QDashedStrokeProcessor
|
|||||||
public:
|
public:
|
||||||
QDashedStrokeProcessor();
|
QDashedStrokeProcessor();
|
||||||
|
|
||||||
void process(const QVectorPath &path, const QPen &pen, const QRectF &clip);
|
void process(const QVectorPath &path, const QPen &pen, const QRectF &clip, QPainter::RenderHints hints);
|
||||||
|
|
||||||
inline void addElement(QPainterPath::ElementType type, qreal x, qreal y) {
|
inline void addElement(QPainterPath::ElementType type, qreal x, qreal y) {
|
||||||
m_points.add(x);
|
m_points.add(x);
|
||||||
|
@ -275,7 +275,7 @@ void QCosmeticStroker::setup()
|
|||||||
qreal width = state->lastPen.widthF();
|
qreal width = state->lastPen.widthF();
|
||||||
if (width == 0)
|
if (width == 0)
|
||||||
opacity = 256;
|
opacity = 256;
|
||||||
else if (state->lastPen.isCosmetic())
|
else if (qt_pen_is_cosmetic(state->lastPen, state->renderHints))
|
||||||
opacity = (int) 256*width;
|
opacity = (int) 256*width;
|
||||||
else
|
else
|
||||||
opacity = (int) 256*width*state->txscale;
|
opacity = (int) 256*width*state->txscale;
|
||||||
|
@ -680,7 +680,7 @@ void QPaintBufferEngine::penChanged()
|
|||||||
} else {
|
} else {
|
||||||
qreal penWidth = (pen.widthF() == 0) ? 1 : pen.widthF();
|
qreal penWidth = (pen.widthF() == 0) ? 1 : pen.widthF();
|
||||||
QPointF transformedWidth(penWidth, penWidth);
|
QPointF transformedWidth(penWidth, penWidth);
|
||||||
if (!pen.isCosmetic())
|
if (!qt_pen_is_cosmetic(pen, state()->renderHints))
|
||||||
transformedWidth = painter()->transform().map(transformedWidth);
|
transformedWidth = painter()->transform().map(transformedWidth);
|
||||||
buffer->penWidthAdjustment = transformedWidth.x() / 2.0;
|
buffer->penWidthAdjustment = transformedWidth.x() / 2.0;
|
||||||
}
|
}
|
||||||
|
@ -445,7 +445,7 @@ void QPaintEngine::drawPoints(const QPointF *points, int pointCount)
|
|||||||
p->save();
|
p->save();
|
||||||
|
|
||||||
QTransform transform;
|
QTransform transform;
|
||||||
if (p->pen().isCosmetic()) {
|
if (qt_pen_is_cosmetic(p->pen(), p->renderHints())) {
|
||||||
transform = p->transform();
|
transform = p->transform();
|
||||||
p->setTransform(QTransform());
|
p->setTransform(QTransform());
|
||||||
}
|
}
|
||||||
|
@ -771,7 +771,7 @@ void QRasterPaintEngine::updatePen(const QPen &pen)
|
|||||||
} else if (pen_style != Qt::NoPen) {
|
} else if (pen_style != Qt::NoPen) {
|
||||||
if (!d->dashStroker)
|
if (!d->dashStroker)
|
||||||
d->dashStroker.reset(new QDashStroker(&d->basicStroker));
|
d->dashStroker.reset(new QDashStroker(&d->basicStroker));
|
||||||
if (pen.isCosmetic()) {
|
if (qt_pen_is_cosmetic(pen, s->renderHints)) {
|
||||||
d->dashStroker->setClipRect(d->deviceRect);
|
d->dashStroker->setClipRect(d->deviceRect);
|
||||||
} else {
|
} else {
|
||||||
// ### I've seen this inverted devrect multiple places now...
|
// ### I've seen this inverted devrect multiple places now...
|
||||||
@ -786,10 +786,11 @@ void QRasterPaintEngine::updatePen(const QPen &pen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ensureRasterState(); // needed because of tx_noshear...
|
ensureRasterState(); // needed because of tx_noshear...
|
||||||
|
bool cosmetic = qt_pen_is_cosmetic(pen, s->renderHints);
|
||||||
s->flags.fast_pen = pen_style > Qt::NoPen
|
s->flags.fast_pen = pen_style > Qt::NoPen
|
||||||
&& s->penData.blend
|
&& s->penData.blend
|
||||||
&& ((pen.isCosmetic() && penWidth <= 1)
|
&& ((cosmetic && penWidth <= 1)
|
||||||
|| (!pen.isCosmetic() && s->flags.tx_noshear && penWidth * s->txscale <= 1));
|
|| (!cosmetic && s->flags.tx_noshear && penWidth * s->txscale <= 1));
|
||||||
|
|
||||||
s->flags.non_complex_pen = qpen_capStyle(s->lastPen) <= Qt::SquareCap && s->flags.tx_noshear;
|
s->flags.non_complex_pen = qpen_capStyle(s->lastPen) <= Qt::SquareCap && s->flags.tx_noshear;
|
||||||
|
|
||||||
@ -1610,7 +1611,7 @@ void QRasterPaintEngine::stroke(const QVectorPath &path, const QPen &pen)
|
|||||||
stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding);
|
stroker.setLegacyRoundingEnabled(s->flags.legacy_rounding);
|
||||||
stroker.drawPath(path);
|
stroker.drawPath(path);
|
||||||
} else if (s->flags.non_complex_pen && path.shape() == QVectorPath::LinesHint) {
|
} else if (s->flags.non_complex_pen && path.shape() == QVectorPath::LinesHint) {
|
||||||
qreal width = s->lastPen.isCosmetic()
|
qreal width = qt_pen_is_cosmetic(s->lastPen, s->renderHints)
|
||||||
? (qpen_widthf(s->lastPen) == 0 ? 1 : qpen_widthf(s->lastPen))
|
? (qpen_widthf(s->lastPen) == 0 ? 1 : qpen_widthf(s->lastPen))
|
||||||
: qpen_widthf(s->lastPen) * s->txscale;
|
: qpen_widthf(s->lastPen) * s->txscale;
|
||||||
int dashIndex = 0;
|
int dashIndex = 0;
|
||||||
|
@ -435,7 +435,7 @@ void QPaintEngineEx::stroke(const QVectorPath &path, const QPen &pen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pen.style() > Qt::SolidLine) {
|
if (pen.style() > Qt::SolidLine) {
|
||||||
if (pen.isCosmetic()) {
|
if (qt_pen_is_cosmetic(pen, state()->renderHints)){
|
||||||
d->activeStroker->setClipRect(d->exDeviceRect);
|
d->activeStroker->setClipRect(d->exDeviceRect);
|
||||||
} else {
|
} else {
|
||||||
QRectF clipRect = state()->matrix.inverted().mapRect(QRectF(d->exDeviceRect));
|
QRectF clipRect = state()->matrix.inverted().mapRect(QRectF(d->exDeviceRect));
|
||||||
@ -462,7 +462,7 @@ void QPaintEngineEx::stroke(const QVectorPath &path, const QPen &pen)
|
|||||||
flags |= QVectorPath::CurvedShapeMask;
|
flags |= QVectorPath::CurvedShapeMask;
|
||||||
|
|
||||||
// ### Perspective Xforms are currently not supported...
|
// ### Perspective Xforms are currently not supported...
|
||||||
if (!pen.isCosmetic()) {
|
if (!qt_pen_is_cosmetic(pen, state()->renderHints)) {
|
||||||
// We include cosmetic pens in this case to avoid having to
|
// We include cosmetic pens in this case to avoid having to
|
||||||
// change the current transform. Normal transformed,
|
// change the current transform. Normal transformed,
|
||||||
// non-cosmetic pens will be transformed as part of fill
|
// non-cosmetic pens will be transformed as part of fill
|
||||||
|
@ -897,26 +897,8 @@ void QPainterPrivate::updateState(QPainterState *newState)
|
|||||||
|
|
||||||
if (!newState) {
|
if (!newState) {
|
||||||
engine->state = newState;
|
engine->state = newState;
|
||||||
|
|
||||||
} else if (newState->state() || engine->state!=newState) {
|
} else if (newState->state() || engine->state!=newState) {
|
||||||
bool setNonCosmeticPen = (newState->renderHints & QPainter::NonCosmeticDefaultPen)
|
updateStateImpl(newState);
|
||||||
&& newState->pen.widthF() == 0;
|
|
||||||
if (setNonCosmeticPen) {
|
|
||||||
// Override the default pen's cosmetic state if the
|
|
||||||
// NonCosmeticDefaultPen render hint is used.
|
|
||||||
QPen oldPen = newState->pen;
|
|
||||||
newState->pen.setWidth(1);
|
|
||||||
newState->pen.setCosmetic(false);
|
|
||||||
newState->dirtyFlags |= QPaintEngine::DirtyPen;
|
|
||||||
|
|
||||||
updateStateImpl(newState);
|
|
||||||
|
|
||||||
// Restore the state pen back to its default to preserve visible
|
|
||||||
// state.
|
|
||||||
newState->pen = oldPen;
|
|
||||||
} else {
|
|
||||||
updateStateImpl(newState);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1417,14 +1399,13 @@ void QPainterPrivate::updateState(QPainterState *newState)
|
|||||||
indicating that the engine should use fragment programs and offscreen
|
indicating that the engine should use fragment programs and offscreen
|
||||||
rendering for antialiasing.
|
rendering for antialiasing.
|
||||||
|
|
||||||
\value NonCosmeticDefaultPen The engine should interpret pens with a width
|
\value NonCosmeticDefaultPen This value is obsolete, the default for QPen
|
||||||
of 0 (which otherwise enables QPen::isCosmetic()) as being a non-cosmetic
|
is now non-cosmetic.
|
||||||
pen with a width of 1.
|
|
||||||
|
|
||||||
\value Qt4CompatiblePainting Compatibility hint telling the engine to use the
|
\value Qt4CompatiblePainting Compatibility hint telling the engine to use the
|
||||||
same X11 based fill rules as in Qt 4, where aliased rendering is offset
|
same X11 based fill rules as in Qt 4, where aliased rendering is offset
|
||||||
by slightly less than half a pixel. Potentially useful when porting a
|
by slightly less than half a pixel. Also will treat default constructed pens
|
||||||
Qt 4 application to Qt 5.
|
as cosmetic. Potentially useful when porting a Qt 4 application to Qt 5.
|
||||||
|
|
||||||
\sa renderHints(), setRenderHint(), {QPainter#Rendering
|
\sa renderHints(), setRenderHint(), {QPainter#Rendering
|
||||||
Quality}{Rendering Quality}, {Concentric Circles Example}
|
Quality}{Rendering Quality}, {Concentric Circles Example}
|
||||||
@ -3849,13 +3830,10 @@ void QPainter::setPen(const QColor &color)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d->state->pen.style() == Qt::SolidLine
|
QPen pen(color.isValid() ? color : QColor(Qt::black));
|
||||||
&& d->state->pen.widthF() == 0
|
|
||||||
&& d->state->pen.isSolid()
|
|
||||||
&& d->state->pen.color() == color)
|
|
||||||
return;
|
|
||||||
|
|
||||||
QPen pen(color.isValid() ? color : QColor(Qt::black), 0, Qt::SolidLine);
|
if (d->state->pen == pen)
|
||||||
|
return;
|
||||||
|
|
||||||
d->state->pen = pen;
|
d->state->pen = pen;
|
||||||
if (d->extended)
|
if (d->extended)
|
||||||
@ -3904,7 +3882,7 @@ void QPainter::setPen(const QPen &pen)
|
|||||||
/*!
|
/*!
|
||||||
\overload
|
\overload
|
||||||
|
|
||||||
Sets the painter's pen to have the given \a style, width 0 and
|
Sets the painter's pen to have the given \a style, width 1 and
|
||||||
black color.
|
black color.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -3916,15 +3894,12 @@ void QPainter::setPen(Qt::PenStyle style)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d->state->pen.style() == style
|
QPen pen = QPen(style);
|
||||||
&& (style == Qt::NoPen || (d->state->pen.widthF() == 0
|
|
||||||
&& d->state->pen.isSolid()
|
if (d->state->pen == pen)
|
||||||
&& d->state->pen.color() == QColor(Qt::black))))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// QPen(Qt::NoPen) is to avoid creating QPenData, including its brush (from the color)
|
d->state->pen = pen;
|
||||||
// Note that this works well as long as QPen(Qt::NoPen) returns a black, zero-width pen
|
|
||||||
d->state->pen = (style == Qt::NoPen) ? QPen(Qt::NoPen) : QPen(Qt::black, 0, style);
|
|
||||||
|
|
||||||
if (d->extended)
|
if (d->extended)
|
||||||
d->extended->penChanged();
|
d->extended->penChanged();
|
||||||
|
@ -241,10 +241,6 @@ public:
|
|||||||
void updateMatrix();
|
void updateMatrix();
|
||||||
void updateInvMatrix();
|
void updateInvMatrix();
|
||||||
|
|
||||||
int rectSubtraction() const {
|
|
||||||
return state->pen.style() != Qt::NoPen && state->pen.width() == 0 ? 1 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void checkEmulation();
|
void checkEmulation();
|
||||||
|
|
||||||
static QPainterPrivate *get(QPainter *painter)
|
static QPainterPrivate *get(QPainter *painter)
|
||||||
@ -269,6 +265,11 @@ Q_GUI_EXPORT void qt_draw_helper(QPainterPrivate *p, const QPainterPath &path, Q
|
|||||||
|
|
||||||
QString qt_generate_brush_key(const QBrush &brush);
|
QString qt_generate_brush_key(const QBrush &brush);
|
||||||
|
|
||||||
|
inline bool qt_pen_is_cosmetic(const QPen &pen, QPainter::RenderHints hints)
|
||||||
|
{
|
||||||
|
return pen.isCosmetic() || (const_cast<QPen &>(pen).data_ptr()->defaultWidth && (hints & QPainter::Qt4CompatiblePainting));
|
||||||
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
#endif // QPAINTER_P_H
|
#endif // QPAINTER_P_H
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
#include <qfile.h>
|
#include <qfile.h>
|
||||||
#include <qtemporaryfile.h>
|
#include <qtemporaryfile.h>
|
||||||
#include <private/qmath_p.h>
|
#include <private/qmath_p.h>
|
||||||
|
#include <private/qpainter_p.h>
|
||||||
#include <qnumeric.h>
|
#include <qnumeric.h>
|
||||||
#include "private/qfont_p.h"
|
#include "private/qfont_p.h"
|
||||||
#include <qimagewriter.h>
|
#include <qimagewriter.h>
|
||||||
@ -784,7 +785,7 @@ QPdf::Stroker::Stroker()
|
|||||||
basicStroker.setStrokeWidth(.1);
|
basicStroker.setStrokeWidth(.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QPdf::Stroker::setPen(const QPen &pen)
|
void QPdf::Stroker::setPen(const QPen &pen, QPainter::RenderHints hints)
|
||||||
{
|
{
|
||||||
if (pen.style() == Qt::NoPen) {
|
if (pen.style() == Qt::NoPen) {
|
||||||
stroker = 0;
|
stroker = 0;
|
||||||
@ -792,7 +793,7 @@ void QPdf::Stroker::setPen(const QPen &pen)
|
|||||||
}
|
}
|
||||||
qreal w = pen.widthF();
|
qreal w = pen.widthF();
|
||||||
bool zeroWidth = w < 0.0001;
|
bool zeroWidth = w < 0.0001;
|
||||||
cosmeticPen = pen.isCosmetic();
|
cosmeticPen = qt_pen_is_cosmetic(pen, hints);
|
||||||
if (zeroWidth)
|
if (zeroWidth)
|
||||||
w = .1;
|
w = .1;
|
||||||
|
|
||||||
@ -1198,12 +1199,14 @@ void QPdfEngine::updateState(const QPaintEngineState &state)
|
|||||||
if (flags & DirtyPen) {
|
if (flags & DirtyPen) {
|
||||||
d->pen = state.pen();
|
d->pen = state.pen();
|
||||||
d->hasPen = d->pen.style() != Qt::NoPen;
|
d->hasPen = d->pen.style() != Qt::NoPen;
|
||||||
d->stroker.setPen(d->pen);
|
d->stroker.setPen(d->pen, state.renderHints());
|
||||||
QBrush penBrush = d->pen.brush();
|
QBrush penBrush = d->pen.brush();
|
||||||
bool oldSimple = d->simplePen;
|
bool oldSimple = d->simplePen;
|
||||||
d->simplePen = (d->hasPen && (penBrush.style() == Qt::SolidPattern) && penBrush.isOpaque());
|
d->simplePen = (d->hasPen && (penBrush.style() == Qt::SolidPattern) && penBrush.isOpaque());
|
||||||
if (oldSimple != d->simplePen)
|
if (oldSimple != d->simplePen)
|
||||||
flags |= DirtyTransform;
|
flags |= DirtyTransform;
|
||||||
|
} else if (flags & DirtyHints) {
|
||||||
|
d->stroker.setPen(d->pen, state.renderHints());
|
||||||
}
|
}
|
||||||
if (flags & DirtyBrush) {
|
if (flags & DirtyBrush) {
|
||||||
d->brush = state.brush();
|
d->brush = state.brush();
|
||||||
|
@ -124,7 +124,7 @@ namespace QPdf {
|
|||||||
|
|
||||||
struct Stroker {
|
struct Stroker {
|
||||||
Stroker();
|
Stroker();
|
||||||
void setPen(const QPen &pen);
|
void setPen(const QPen &pen, QPainter::RenderHints hints);
|
||||||
void strokePath(const QPainterPath &path);
|
void strokePath(const QPainterPath &path);
|
||||||
ByteStream *stream;
|
ByteStream *stream;
|
||||||
bool first;
|
bool first;
|
||||||
|
@ -86,7 +86,7 @@ typedef QPenPrivate QPenData;
|
|||||||
|
|
||||||
\snippet code/src_gui_painting_qpen.cpp 1
|
\snippet code/src_gui_painting_qpen.cpp 1
|
||||||
|
|
||||||
The default pen is a solid black brush with 0 width, square
|
The default pen is a solid black brush with 1 width, square
|
||||||
cap style (Qt::SquareCap), and bevel join style (Qt::BevelJoin).
|
cap style (Qt::SquareCap), and bevel join style (Qt::BevelJoin).
|
||||||
|
|
||||||
In addition QPen provides the color() and setColor()
|
In addition QPen provides the color() and setColor()
|
||||||
@ -230,9 +230,9 @@ typedef QPenPrivate QPenData;
|
|||||||
\internal
|
\internal
|
||||||
*/
|
*/
|
||||||
inline QPenPrivate::QPenPrivate(const QBrush &_brush, qreal _width, Qt::PenStyle penStyle,
|
inline QPenPrivate::QPenPrivate(const QBrush &_brush, qreal _width, Qt::PenStyle penStyle,
|
||||||
Qt::PenCapStyle _capStyle, Qt::PenJoinStyle _joinStyle)
|
Qt::PenCapStyle _capStyle, Qt::PenJoinStyle _joinStyle, bool _defaultWidth)
|
||||||
: ref(1), dashOffset(0), miterLimit(2),
|
: ref(1), dashOffset(0), miterLimit(2),
|
||||||
cosmetic(false)
|
cosmetic(false), defaultWidth(_defaultWidth)
|
||||||
{
|
{
|
||||||
width = _width;
|
width = _width;
|
||||||
brush = _brush;
|
brush = _brush;
|
||||||
@ -261,12 +261,12 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
Q_GLOBAL_STATIC_WITH_ARGS(QPenDataHolder, defaultPenInstance,
|
Q_GLOBAL_STATIC_WITH_ARGS(QPenDataHolder, defaultPenInstance,
|
||||||
(Qt::black, 0, Qt::SolidLine, qpen_default_cap, qpen_default_join))
|
(Qt::black, 1, Qt::SolidLine, qpen_default_cap, qpen_default_join))
|
||||||
Q_GLOBAL_STATIC_WITH_ARGS(QPenDataHolder, nullPenInstance,
|
Q_GLOBAL_STATIC_WITH_ARGS(QPenDataHolder, nullPenInstance,
|
||||||
(Qt::black, 0, Qt::NoPen, qpen_default_cap, qpen_default_join))
|
(Qt::black, 1, Qt::NoPen, qpen_default_cap, qpen_default_join))
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Constructs a default black solid line pen with 0 width.
|
Constructs a default black solid line pen with 1 width.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
QPen::QPen()
|
QPen::QPen()
|
||||||
@ -276,7 +276,7 @@ QPen::QPen()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Constructs a black pen with 0 width and the given \a style.
|
Constructs a black pen with 1 width and the given \a style.
|
||||||
|
|
||||||
\sa setStyle()
|
\sa setStyle()
|
||||||
*/
|
*/
|
||||||
@ -287,20 +287,20 @@ QPen::QPen(Qt::PenStyle style)
|
|||||||
d = nullPenInstance()->pen;
|
d = nullPenInstance()->pen;
|
||||||
d->ref.ref();
|
d->ref.ref();
|
||||||
} else {
|
} else {
|
||||||
d = new QPenData(Qt::black, 0, style, qpen_default_cap, qpen_default_join);
|
d = new QPenData(Qt::black, 1, style, qpen_default_cap, qpen_default_join);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Constructs a solid line pen with 0 width and the given \a color.
|
Constructs a solid line pen with 1 width and the given \a color.
|
||||||
|
|
||||||
\sa setBrush(), setColor()
|
\sa setBrush(), setColor()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
QPen::QPen(const QColor &color)
|
QPen::QPen(const QColor &color)
|
||||||
{
|
{
|
||||||
d = new QPenData(color, 0, Qt::SolidLine, qpen_default_cap, qpen_default_join);
|
d = new QPenData(color, 1, Qt::SolidLine, qpen_default_cap, qpen_default_join);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -315,7 +315,7 @@ QPen::QPen(const QColor &color)
|
|||||||
|
|
||||||
QPen::QPen(const QBrush &brush, qreal width, Qt::PenStyle s, Qt::PenCapStyle c, Qt::PenJoinStyle j)
|
QPen::QPen(const QBrush &brush, qreal width, Qt::PenStyle s, Qt::PenCapStyle c, Qt::PenJoinStyle j)
|
||||||
{
|
{
|
||||||
d = new QPenData(brush, width, s, c, j);
|
d = new QPenData(brush, width, s, c, j, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -655,12 +655,15 @@ void QPen::setWidth(int width)
|
|||||||
|
|
||||||
void QPen::setWidthF(qreal width)
|
void QPen::setWidthF(qreal width)
|
||||||
{
|
{
|
||||||
if (width < 0.f)
|
if (width < 0.f) {
|
||||||
qWarning("QPen::setWidthF: Setting a pen width with a negative value is not defined");
|
qWarning("QPen::setWidthF: Setting a pen width with a negative value is not defined");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (qAbs(d->width - width) < 0.00000001f)
|
if (qAbs(d->width - width) < 0.00000001f)
|
||||||
return;
|
return;
|
||||||
detach();
|
detach();
|
||||||
d->width = width;
|
d->width = width;
|
||||||
|
d->defaultWidth = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -785,8 +788,7 @@ bool QPen::isSolid() const
|
|||||||
used with. Drawing a shape with a cosmetic pen ensures that its
|
used with. Drawing a shape with a cosmetic pen ensures that its
|
||||||
outline will have the same thickness at different scale factors.
|
outline will have the same thickness at different scale factors.
|
||||||
|
|
||||||
A zero width pen is cosmetic by default; pens with a non-zero width
|
A zero width pen is cosmetic by default.
|
||||||
are non-cosmetic.
|
|
||||||
|
|
||||||
\sa setCosmetic(), widthF()
|
\sa setCosmetic(), widthF()
|
||||||
*/
|
*/
|
||||||
@ -848,7 +850,8 @@ bool QPen::operator==(const QPen &p) const
|
|||||||
|| (qFuzzyCompare(pdd->dashOffset, dd->dashOffset) &&
|
|| (qFuzzyCompare(pdd->dashOffset, dd->dashOffset) &&
|
||||||
pdd->dashPattern == dd->dashPattern))
|
pdd->dashPattern == dd->dashPattern))
|
||||||
&& p.d->brush == d->brush
|
&& p.d->brush == d->brush
|
||||||
&& pdd->cosmetic == dd->cosmetic);
|
&& pdd->cosmetic == dd->cosmetic
|
||||||
|
&& pdd->defaultWidth == dd->defaultWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -910,6 +913,8 @@ QDataStream &operator<<(QDataStream &s, const QPen &p)
|
|||||||
}
|
}
|
||||||
if (s.version() >= 9)
|
if (s.version() >= 9)
|
||||||
s << double(p.dashOffset());
|
s << double(p.dashOffset());
|
||||||
|
if (s.version() >= QDataStream::Qt_5_0)
|
||||||
|
s << bool(dd->defaultWidth);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@ -935,6 +940,7 @@ QDataStream &operator>>(QDataStream &s, QPen &p)
|
|||||||
QVector<qreal> dashPattern;
|
QVector<qreal> dashPattern;
|
||||||
double dashOffset = 0;
|
double dashOffset = 0;
|
||||||
bool cosmetic = false;
|
bool cosmetic = false;
|
||||||
|
bool defaultWidth = false;
|
||||||
if (s.version() < QDataStream::Qt_4_3) {
|
if (s.version() < QDataStream::Qt_4_3) {
|
||||||
quint8 style8;
|
quint8 style8;
|
||||||
s >> style8;
|
s >> style8;
|
||||||
@ -967,6 +973,13 @@ QDataStream &operator>>(QDataStream &s, QPen &p)
|
|||||||
s >> dashOffset;
|
s >> dashOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (s.version() >= QDataStream::Qt_5_0) {
|
||||||
|
s >> defaultWidth;
|
||||||
|
} else {
|
||||||
|
// best we can do for legacy pens
|
||||||
|
defaultWidth = qFuzzyIsNull(width);
|
||||||
|
}
|
||||||
|
|
||||||
p.detach();
|
p.detach();
|
||||||
QPenData *dd = static_cast<QPenData *>(p.d);
|
QPenData *dd = static_cast<QPenData *>(p.d);
|
||||||
dd->width = width;
|
dd->width = width;
|
||||||
@ -978,6 +991,7 @@ QDataStream &operator>>(QDataStream &s, QPen &p)
|
|||||||
dd->miterLimit = miterLimit;
|
dd->miterLimit = miterLimit;
|
||||||
dd->dashOffset = dashOffset;
|
dd->dashOffset = dashOffset;
|
||||||
dd->cosmetic = cosmetic;
|
dd->cosmetic = cosmetic;
|
||||||
|
dd->defaultWidth = defaultWidth;
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE
|
|||||||
class QPenPrivate {
|
class QPenPrivate {
|
||||||
public:
|
public:
|
||||||
QPenPrivate(const QBrush &brush, qreal width, Qt::PenStyle, Qt::PenCapStyle,
|
QPenPrivate(const QBrush &brush, qreal width, Qt::PenStyle, Qt::PenCapStyle,
|
||||||
Qt::PenJoinStyle _joinStyle);
|
Qt::PenJoinStyle _joinStyle, bool defaultWidth = true);
|
||||||
QAtomicInt ref;
|
QAtomicInt ref;
|
||||||
qreal width;
|
qreal width;
|
||||||
QBrush brush;
|
QBrush brush;
|
||||||
@ -71,6 +71,7 @@ public:
|
|||||||
qreal dashOffset;
|
qreal dashOffset;
|
||||||
qreal miterLimit;
|
qreal miterLimit;
|
||||||
uint cosmetic : 1;
|
uint cosmetic : 1;
|
||||||
|
uint defaultWidth : 1; // default-constructed width? used for cosmetic pen compatibility
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
@ -1201,7 +1201,7 @@ void QGL2PaintEngineEx::stroke(const QVectorPath &path, const QPen &pen)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
QOpenGL2PaintEngineState *s = state();
|
QOpenGL2PaintEngineState *s = state();
|
||||||
if (pen.isCosmetic() && !qt_scaleForTransform(s->transform(), 0)) {
|
if (qt_pen_is_cosmetic(pen, s->renderHints) && !qt_scaleForTransform(s->transform(), 0)) {
|
||||||
// QTriangulatingStroker class is not meant to support cosmetically sheared strokes.
|
// QTriangulatingStroker class is not meant to support cosmetically sheared strokes.
|
||||||
QPaintEngineEx::stroke(path, pen);
|
QPaintEngineEx::stroke(path, pen);
|
||||||
return;
|
return;
|
||||||
@ -1236,15 +1236,15 @@ void QGL2PaintEngineExPrivate::stroke(const QVectorPath &path, const QPen &pen)
|
|||||||
: QRectF(0, 0, width, height));
|
: QRectF(0, 0, width, height));
|
||||||
|
|
||||||
if (penStyle == Qt::SolidLine) {
|
if (penStyle == Qt::SolidLine) {
|
||||||
stroker.process(path, pen, clip);
|
stroker.process(path, pen, clip, s->renderHints);
|
||||||
|
|
||||||
} else { // Some sort of dash
|
} else { // Some sort of dash
|
||||||
dasher.process(path, pen, clip);
|
dasher.process(path, pen, clip, s->renderHints);
|
||||||
|
|
||||||
QVectorPath dashStroke(dasher.points(),
|
QVectorPath dashStroke(dasher.points(),
|
||||||
dasher.elementCount(),
|
dasher.elementCount(),
|
||||||
dasher.elementTypes());
|
dasher.elementTypes());
|
||||||
stroker.process(dashStroke, pen, clip);
|
stroker.process(dashStroke, pen, clip, s->renderHints);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!stroker.vertexCount())
|
if (!stroker.vertexCount())
|
||||||
@ -1268,7 +1268,7 @@ void QGL2PaintEngineExPrivate::stroke(const QVectorPath &path, const QPen &pen)
|
|||||||
? qMax(pen.miterLimit() * width, width)
|
? qMax(pen.miterLimit() * width, width)
|
||||||
: width;
|
: width;
|
||||||
|
|
||||||
if (pen.isCosmetic())
|
if (qt_pen_is_cosmetic(pen, s->renderHints))
|
||||||
extra = extra * inverseScale;
|
extra = extra * inverseScale;
|
||||||
|
|
||||||
QRectF bounds = path.controlPointRect().adjusted(-extra, -extra, extra, extra);
|
QRectF bounds = path.controlPointRect().adjusted(-extra, -extra, extra, extra);
|
||||||
|
@ -717,8 +717,8 @@ QCoreGraphicsPaintEngine::updateState(const QPaintEngineState &state)
|
|||||||
if (flags & DirtyCompositionMode)
|
if (flags & DirtyCompositionMode)
|
||||||
updateCompositionMode(state.compositionMode());
|
updateCompositionMode(state.compositionMode());
|
||||||
|
|
||||||
if (flags & (DirtyPen | DirtyTransform)) {
|
if (flags & (DirtyPen | DirtyTransform | DirtyHints)) {
|
||||||
if (!d->current.pen.isCosmetic()) {
|
if (!qt_pen_is_cosmetic(d->current.pen, state.renderHints())) {
|
||||||
d->cosmeticPen = QCoreGraphicsPaintEnginePrivate::CosmeticNone;
|
d->cosmeticPen = QCoreGraphicsPaintEnginePrivate::CosmeticNone;
|
||||||
} else if (d->current.transform.m11() < d->current.transform.m22()-1.0 ||
|
} else if (d->current.transform.m11() < d->current.transform.m22()-1.0 ||
|
||||||
d->current.transform.m11() > d->current.transform.m22()+1.0) {
|
d->current.transform.m11() > d->current.transform.m22()+1.0) {
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
#include <qdebug.h>
|
#include <qdebug.h>
|
||||||
#include "private/qpaintengine_alpha_p.h"
|
#include "private/qpaintengine_alpha_p.h"
|
||||||
|
|
||||||
|
#include "private/qpainter_p.h"
|
||||||
#include "private/qpicture_p.h"
|
#include "private/qpicture_p.h"
|
||||||
#include "private/qfont_p.h"
|
#include "private/qfont_p.h"
|
||||||
#include "QtGui/qpicture.h"
|
#include "QtGui/qpicture.h"
|
||||||
@ -384,11 +385,14 @@ QAlphaPaintEnginePrivate::~QAlphaPaintEnginePrivate()
|
|||||||
|
|
||||||
QRectF QAlphaPaintEnginePrivate::addPenWidth(const QPainterPath &path)
|
QRectF QAlphaPaintEnginePrivate::addPenWidth(const QPainterPath &path)
|
||||||
{
|
{
|
||||||
|
Q_Q(QAlphaPaintEngine);
|
||||||
|
|
||||||
QPainterPath tmp = path;
|
QPainterPath tmp = path;
|
||||||
|
|
||||||
if (m_pen.style() == Qt::NoPen)
|
if (m_pen.style() == Qt::NoPen)
|
||||||
return (path.controlPointRect() * m_transform).boundingRect();
|
return (path.controlPointRect() * m_transform).boundingRect();
|
||||||
if (m_pen.isCosmetic())
|
bool cosmetic = qt_pen_is_cosmetic(m_pen, q->state->renderHints());
|
||||||
|
if (cosmetic)
|
||||||
tmp = path * m_transform;
|
tmp = path * m_transform;
|
||||||
|
|
||||||
QPainterPathStroker stroker;
|
QPainterPathStroker stroker;
|
||||||
@ -399,7 +403,7 @@ QRectF QAlphaPaintEnginePrivate::addPenWidth(const QPainterPath &path)
|
|||||||
stroker.setJoinStyle(m_pen.joinStyle());
|
stroker.setJoinStyle(m_pen.joinStyle());
|
||||||
stroker.setCapStyle(m_pen.capStyle());
|
stroker.setCapStyle(m_pen.capStyle());
|
||||||
tmp = stroker.createStroke(tmp);
|
tmp = stroker.createStroke(tmp);
|
||||||
if (m_pen.isCosmetic())
|
if (cosmetic)
|
||||||
return tmp.controlPointRect();
|
return tmp.controlPointRect();
|
||||||
|
|
||||||
return (tmp.controlPointRect() * m_transform).boundingRect();
|
return (tmp.controlPointRect() * m_transform).boundingRect();
|
||||||
|
@ -852,6 +852,8 @@ void QWin32PrintEnginePrivate::fillPath_dev(const QPainterPath &path, const QCol
|
|||||||
|
|
||||||
void QWin32PrintEnginePrivate::strokePath_dev(const QPainterPath &path, const QColor &color, qreal penWidth)
|
void QWin32PrintEnginePrivate::strokePath_dev(const QPainterPath &path, const QColor &color, qreal penWidth)
|
||||||
{
|
{
|
||||||
|
Q_Q(QWin32PrintEngine);
|
||||||
|
|
||||||
composeGdiPath(path);
|
composeGdiPath(path);
|
||||||
LOGBRUSH brush;
|
LOGBRUSH brush;
|
||||||
brush.lbStyle = BS_SOLID;
|
brush.lbStyle = BS_SOLID;
|
||||||
@ -868,7 +870,9 @@ void QWin32PrintEnginePrivate::strokePath_dev(const QPainterPath &path, const QC
|
|||||||
else if (pen.joinStyle() == Qt::RoundJoin)
|
else if (pen.joinStyle() == Qt::RoundJoin)
|
||||||
joinStyle = PS_JOIN_ROUND;
|
joinStyle = PS_JOIN_ROUND;
|
||||||
|
|
||||||
HPEN pen = ExtCreatePen(((penWidth == 0) ? PS_COSMETIC : PS_GEOMETRIC)
|
bool cosmetic = qt_pen_is_cosmetic(pen, q->state->renderHints());
|
||||||
|
|
||||||
|
HPEN pen = ExtCreatePen((cosmetic ? PS_COSMETIC : PS_GEOMETRIC)
|
||||||
| PS_SOLID | capStyle | joinStyle,
|
| PS_SOLID | capStyle | joinStyle,
|
||||||
(penWidth == 0) ? 1 : penWidth, &brush, 0, 0);
|
(penWidth == 0) ? 1 : penWidth, &brush, 0, 0);
|
||||||
|
|
||||||
@ -885,6 +889,8 @@ void QWin32PrintEnginePrivate::fillPath(const QPainterPath &path, const QColor &
|
|||||||
|
|
||||||
void QWin32PrintEnginePrivate::strokePath(const QPainterPath &path, const QColor &color)
|
void QWin32PrintEnginePrivate::strokePath(const QPainterPath &path, const QColor &color)
|
||||||
{
|
{
|
||||||
|
Q_Q(QWin32PrintEngine);
|
||||||
|
|
||||||
QPainterPathStroker stroker;
|
QPainterPathStroker stroker;
|
||||||
if (pen.style() == Qt::CustomDashLine) {
|
if (pen.style() == Qt::CustomDashLine) {
|
||||||
stroker.setDashPattern(pen.dashPattern());
|
stroker.setDashPattern(pen.dashPattern());
|
||||||
@ -898,11 +904,12 @@ void QWin32PrintEnginePrivate::strokePath(const QPainterPath &path, const QColor
|
|||||||
|
|
||||||
QPainterPath stroke;
|
QPainterPath stroke;
|
||||||
qreal width = pen.widthF();
|
qreal width = pen.widthF();
|
||||||
if (pen.style() == Qt::SolidLine && (pen.isCosmetic() || matrix.type() < QTransform::TxScale)) {
|
bool cosmetic = qt_pen_is_cosmetic(pen, q->state->renderHints());
|
||||||
|
if (pen.style() == Qt::SolidLine && (cosmetic || matrix.type() < QTransform::TxScale)) {
|
||||||
strokePath_dev(path * matrix, color, width);
|
strokePath_dev(path * matrix, color, width);
|
||||||
} else {
|
} else {
|
||||||
stroker.setWidth(width);
|
stroker.setWidth(width);
|
||||||
if (pen.isCosmetic()) {
|
if (cosmetic) {
|
||||||
stroke = stroker.createStroke(path * matrix);
|
stroke = stroker.createStroke(path * matrix);
|
||||||
} else {
|
} else {
|
||||||
stroke = stroker.createStroke(path) * painterMatrix;
|
stroke = stroker.createStroke(path) * painterMatrix;
|
||||||
|
@ -8030,7 +8030,7 @@ QAbstractGraphicsShapeItem::~QAbstractGraphicsShapeItem()
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
Returns the item's pen. If no pen has been set, this function returns
|
Returns the item's pen. If no pen has been set, this function returns
|
||||||
QPen(), a default black solid line pen with 0 width.
|
QPen(), a default black solid line pen with 1 width.
|
||||||
*/
|
*/
|
||||||
QPen QAbstractGraphicsShapeItem::pen() const
|
QPen QAbstractGraphicsShapeItem::pen() const
|
||||||
{
|
{
|
||||||
@ -8204,7 +8204,7 @@ QRectF QGraphicsPathItem::boundingRect() const
|
|||||||
{
|
{
|
||||||
Q_D(const QGraphicsPathItem);
|
Q_D(const QGraphicsPathItem);
|
||||||
if (d->boundingRect.isNull()) {
|
if (d->boundingRect.isNull()) {
|
||||||
qreal pw = pen().widthF();
|
qreal pw = pen().style() == Qt::NoPen ? qreal(0) : pen().widthF();
|
||||||
if (pw == 0.0)
|
if (pw == 0.0)
|
||||||
d->boundingRect = d->path.controlPointRect();
|
d->boundingRect = d->path.controlPointRect();
|
||||||
else {
|
else {
|
||||||
@ -8434,7 +8434,7 @@ QRectF QGraphicsRectItem::boundingRect() const
|
|||||||
{
|
{
|
||||||
Q_D(const QGraphicsRectItem);
|
Q_D(const QGraphicsRectItem);
|
||||||
if (d->boundingRect.isNull()) {
|
if (d->boundingRect.isNull()) {
|
||||||
qreal halfpw = pen().widthF() / 2;
|
qreal halfpw = pen().style() == Qt::NoPen ? qreal(0) : pen().widthF() / 2;
|
||||||
d->boundingRect = d->rect;
|
d->boundingRect = d->rect;
|
||||||
if (halfpw > 0.0)
|
if (halfpw > 0.0)
|
||||||
d->boundingRect.adjust(-halfpw, -halfpw, halfpw, halfpw);
|
d->boundingRect.adjust(-halfpw, -halfpw, halfpw, halfpw);
|
||||||
@ -8723,7 +8723,7 @@ QRectF QGraphicsEllipseItem::boundingRect() const
|
|||||||
{
|
{
|
||||||
Q_D(const QGraphicsEllipseItem);
|
Q_D(const QGraphicsEllipseItem);
|
||||||
if (d->boundingRect.isNull()) {
|
if (d->boundingRect.isNull()) {
|
||||||
qreal pw = pen().widthF();
|
qreal pw = pen().style() == Qt::NoPen ? qreal(0) : pen().widthF();
|
||||||
if (pw == 0.0 && d->spanAngle == 360 * 16)
|
if (pw == 0.0 && d->spanAngle == 360 * 16)
|
||||||
d->boundingRect = d->rect;
|
d->boundingRect = d->rect;
|
||||||
else
|
else
|
||||||
@ -8959,7 +8959,7 @@ QRectF QGraphicsPolygonItem::boundingRect() const
|
|||||||
{
|
{
|
||||||
Q_D(const QGraphicsPolygonItem);
|
Q_D(const QGraphicsPolygonItem);
|
||||||
if (d->boundingRect.isNull()) {
|
if (d->boundingRect.isNull()) {
|
||||||
qreal pw = pen().widthF();
|
qreal pw = pen().style() == Qt::NoPen ? qreal(0) : pen().widthF();
|
||||||
if (pw == 0.0)
|
if (pw == 0.0)
|
||||||
d->boundingRect = d->polygon.boundingRect();
|
d->boundingRect = d->polygon.boundingRect();
|
||||||
else
|
else
|
||||||
|
@ -1485,17 +1485,7 @@ void QGraphicsProxyWidget::paint(QPainter *painter, const QStyleOptionGraphicsIt
|
|||||||
if (exposedWidgetRect.isEmpty())
|
if (exposedWidgetRect.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Disable QPainter's default pen being cosmetic. This allows widgets and
|
|
||||||
// styles to follow Qt's existing defaults without getting ugly cosmetic
|
|
||||||
// lines when scaled.
|
|
||||||
bool restore = !(painter->renderHints() & QPainter::NonCosmeticDefaultPen);
|
|
||||||
painter->setRenderHints(QPainter::NonCosmeticDefaultPen, true);
|
|
||||||
|
|
||||||
d->widget->render(painter, exposedWidgetRect.topLeft(), exposedWidgetRect);
|
d->widget->render(painter, exposedWidgetRect.topLeft(), exposedWidgetRect);
|
||||||
|
|
||||||
// Restore the render hints if necessary.
|
|
||||||
if (restore)
|
|
||||||
painter->setRenderHints(QPainter::NonCosmeticDefaultPen, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -2299,7 +2299,6 @@ void QGraphicsWidget::paintWindowFrame(QPainter *painter, const QStyleOptionGrap
|
|||||||
painter->fillRect(windowFrameRect, palette().window());
|
painter->fillRect(windowFrameRect, palette().window());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
painter->setRenderHint(QPainter::NonCosmeticDefaultPen);
|
|
||||||
|
|
||||||
// Draw title
|
// Draw title
|
||||||
int height = (int)d->titleBarHeight(bar);
|
int height = (int)d->titleBarHeight(bar);
|
||||||
|
@ -1490,6 +1490,7 @@ void tst_QPainter::setWindow()
|
|||||||
pixmap.fill(QColor(Qt::white));
|
pixmap.fill(QColor(Qt::white));
|
||||||
|
|
||||||
QPainter painter(&pixmap);
|
QPainter painter(&pixmap);
|
||||||
|
painter.setRenderHint(QPainter::Qt4CompatiblePainting);
|
||||||
painter.setWindow(0, 0, 3, 3);
|
painter.setWindow(0, 0, 3, 3);
|
||||||
painter.drawLine(1, 1, 2, 2);
|
painter.drawLine(1, 1, 2, 2);
|
||||||
|
|
||||||
|
@ -470,9 +470,9 @@ void tst_QPathClipper::clipTest(int subjectIndex, int clipIndex, QPathClipper::O
|
|||||||
p.setRenderHint(QPainter::Antialiasing);
|
p.setRenderHint(QPainter::Antialiasing);
|
||||||
p.scale(scale, scale);
|
p.scale(scale, scale);
|
||||||
p.translate(-bounds.topLeft());
|
p.translate(-bounds.topLeft());
|
||||||
p.setPen(Qt::black);
|
p.setPen(QPen(Qt::black, 0));
|
||||||
p.drawPath(subject);
|
p.drawPath(subject);
|
||||||
p.setPen(Qt::red);
|
p.setPen(QPen(Qt::red, 0));
|
||||||
p.drawPath(clip);
|
p.drawPath(clip);
|
||||||
p.end();
|
p.end();
|
||||||
|
|
||||||
|
@ -154,9 +154,9 @@ void tst_QPen::constructor_data()
|
|||||||
QTest::addColumn<int>("capStyle");
|
QTest::addColumn<int>("capStyle");
|
||||||
QTest::addColumn<int>("joinStyle");
|
QTest::addColumn<int>("joinStyle");
|
||||||
|
|
||||||
QTest::newRow("solid_black") << QPen() << QBrush(Qt::black) << 0. << (int)Qt::SolidLine
|
QTest::newRow("solid_black") << QPen() << QBrush(Qt::black) << 1. << (int)Qt::SolidLine
|
||||||
<< (int) Qt::SquareCap << (int)Qt::BevelJoin;
|
<< (int) Qt::SquareCap << (int)Qt::BevelJoin;
|
||||||
QTest::newRow("solid_red") << QPen(Qt::red) << QBrush(Qt::red) << 0. << (int)Qt::SolidLine
|
QTest::newRow("solid_red") << QPen(Qt::red) << QBrush(Qt::red) << 1. << (int)Qt::SolidLine
|
||||||
<< (int)Qt::SquareCap << (int)Qt::BevelJoin;
|
<< (int)Qt::SquareCap << (int)Qt::BevelJoin;
|
||||||
QTest::newRow("full") << QPen(QBrush(QLinearGradient(0, 0, 100, 100)), 10,
|
QTest::newRow("full") << QPen(QBrush(QLinearGradient(0, 0, 100, 100)), 10,
|
||||||
Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin)
|
Qt::SolidLine, Qt::RoundCap, Qt::MiterJoin)
|
||||||
|
@ -234,6 +234,7 @@ void tst_QGraphicsEffect::boundingRect()
|
|||||||
// Install effect on QGraphicsItem.
|
// Install effect on QGraphicsItem.
|
||||||
QRectF itemRect(0, 0, 100, 100);
|
QRectF itemRect(0, 0, 100, 100);
|
||||||
QGraphicsRectItem *item = new QGraphicsRectItem;
|
QGraphicsRectItem *item = new QGraphicsRectItem;
|
||||||
|
item->setPen(QPen(Qt::black, 0));
|
||||||
item->setRect(itemRect);
|
item->setRect(itemRect);
|
||||||
item->setGraphicsEffect(effect);
|
item->setGraphicsEffect(effect);
|
||||||
int margin = effect->margin();
|
int margin = effect->margin();
|
||||||
@ -265,16 +266,19 @@ void tst_QGraphicsEffect::boundingRect2()
|
|||||||
{
|
{
|
||||||
CustomEffect *effect = new CustomEffect;
|
CustomEffect *effect = new CustomEffect;
|
||||||
QGraphicsRectItem *root = new QGraphicsRectItem;
|
QGraphicsRectItem *root = new QGraphicsRectItem;
|
||||||
|
root->setPen(QPen(Qt::black, 0));
|
||||||
root->setGraphicsEffect(effect);
|
root->setGraphicsEffect(effect);
|
||||||
|
|
||||||
QGraphicsRectItem *child = new QGraphicsRectItem;
|
QGraphicsRectItem *child = new QGraphicsRectItem;
|
||||||
QRectF childRect(0, 0, 100, 100);
|
QRectF childRect(0, 0, 100, 100);
|
||||||
|
child->setPen(QPen(Qt::black, 0));
|
||||||
child->setFlag(QGraphicsItem::ItemClipsChildrenToShape);
|
child->setFlag(QGraphicsItem::ItemClipsChildrenToShape);
|
||||||
child->setRect(childRect);
|
child->setRect(childRect);
|
||||||
child->setParentItem(root);
|
child->setParentItem(root);
|
||||||
|
|
||||||
QGraphicsRectItem *grandChild = new QGraphicsRectItem;
|
QGraphicsRectItem *grandChild = new QGraphicsRectItem;
|
||||||
QRectF grandChildRect(0, 0, 200, 200);
|
QRectF grandChildRect(0, 0, 200, 200);
|
||||||
|
grandChild->setPen(QPen(Qt::black, 0));
|
||||||
grandChild->setRect(grandChildRect);
|
grandChild->setRect(grandChildRect);
|
||||||
grandChild->setParentItem(child);
|
grandChild->setParentItem(child);
|
||||||
|
|
||||||
|
@ -491,6 +491,7 @@ void tst_QGraphicsItem::construction()
|
|||||||
switch (i) {
|
switch (i) {
|
||||||
case 0:
|
case 0:
|
||||||
item = new QGraphicsEllipseItem;
|
item = new QGraphicsEllipseItem;
|
||||||
|
((QGraphicsEllipseItem *)item)->setPen(QPen(Qt::black, 0));
|
||||||
QCOMPARE(int(item->type()), int(QGraphicsEllipseItem::Type));
|
QCOMPARE(int(item->type()), int(QGraphicsEllipseItem::Type));
|
||||||
QCOMPARE(qgraphicsitem_cast<QGraphicsEllipseItem *>(item), (QGraphicsEllipseItem *)item);
|
QCOMPARE(qgraphicsitem_cast<QGraphicsEllipseItem *>(item), (QGraphicsEllipseItem *)item);
|
||||||
QCOMPARE(qgraphicsitem_cast<QGraphicsRectItem *>(item), (QGraphicsRectItem *)0);
|
QCOMPARE(qgraphicsitem_cast<QGraphicsRectItem *>(item), (QGraphicsRectItem *)0);
|
||||||
@ -498,6 +499,7 @@ void tst_QGraphicsItem::construction()
|
|||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
item = new QGraphicsLineItem;
|
item = new QGraphicsLineItem;
|
||||||
|
((QGraphicsLineItem *)item)->setPen(QPen(Qt::black, 0));
|
||||||
QCOMPARE(int(item->type()), int(QGraphicsLineItem::Type));
|
QCOMPARE(int(item->type()), int(QGraphicsLineItem::Type));
|
||||||
QCOMPARE(qgraphicsitem_cast<QGraphicsLineItem *>(item), (QGraphicsLineItem *)item);
|
QCOMPARE(qgraphicsitem_cast<QGraphicsLineItem *>(item), (QGraphicsLineItem *)item);
|
||||||
QCOMPARE(qgraphicsitem_cast<QGraphicsRectItem *>(item), (QGraphicsRectItem *)0);
|
QCOMPARE(qgraphicsitem_cast<QGraphicsRectItem *>(item), (QGraphicsRectItem *)0);
|
||||||
@ -505,6 +507,7 @@ void tst_QGraphicsItem::construction()
|
|||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
item = new QGraphicsPathItem;
|
item = new QGraphicsPathItem;
|
||||||
|
((QGraphicsPathItem *)item)->setPen(QPen(Qt::black, 0));
|
||||||
QCOMPARE(int(item->type()), int(QGraphicsPathItem::Type));
|
QCOMPARE(int(item->type()), int(QGraphicsPathItem::Type));
|
||||||
QCOMPARE(qgraphicsitem_cast<QGraphicsPathItem *>(item), (QGraphicsPathItem *)item);
|
QCOMPARE(qgraphicsitem_cast<QGraphicsPathItem *>(item), (QGraphicsPathItem *)item);
|
||||||
QCOMPARE(qgraphicsitem_cast<QGraphicsRectItem *>(item), (QGraphicsRectItem *)0);
|
QCOMPARE(qgraphicsitem_cast<QGraphicsRectItem *>(item), (QGraphicsRectItem *)0);
|
||||||
@ -519,6 +522,7 @@ void tst_QGraphicsItem::construction()
|
|||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
item = new QGraphicsPolygonItem;
|
item = new QGraphicsPolygonItem;
|
||||||
|
((QGraphicsPolygonItem *)item)->setPen(QPen(Qt::black, 0));
|
||||||
QCOMPARE(int(item->type()), int(QGraphicsPolygonItem::Type));
|
QCOMPARE(int(item->type()), int(QGraphicsPolygonItem::Type));
|
||||||
QCOMPARE(qgraphicsitem_cast<QGraphicsPolygonItem *>(item), (QGraphicsPolygonItem *)item);
|
QCOMPARE(qgraphicsitem_cast<QGraphicsPolygonItem *>(item), (QGraphicsPolygonItem *)item);
|
||||||
QCOMPARE(qgraphicsitem_cast<QGraphicsRectItem *>(item), (QGraphicsRectItem *)0);
|
QCOMPARE(qgraphicsitem_cast<QGraphicsRectItem *>(item), (QGraphicsRectItem *)0);
|
||||||
@ -526,6 +530,7 @@ void tst_QGraphicsItem::construction()
|
|||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
item = new QGraphicsRectItem;
|
item = new QGraphicsRectItem;
|
||||||
|
((QGraphicsRectItem *)item)->setPen(QPen(Qt::black, 0));
|
||||||
QCOMPARE(int(item->type()), int(QGraphicsRectItem::Type));
|
QCOMPARE(int(item->type()), int(QGraphicsRectItem::Type));
|
||||||
QCOMPARE(qgraphicsitem_cast<QGraphicsRectItem *>(item), (QGraphicsRectItem *)item);
|
QCOMPARE(qgraphicsitem_cast<QGraphicsRectItem *>(item), (QGraphicsRectItem *)item);
|
||||||
QCOMPARE(qgraphicsitem_cast<QGraphicsLineItem *>(item), (QGraphicsLineItem *)0);
|
QCOMPARE(qgraphicsitem_cast<QGraphicsLineItem *>(item), (QGraphicsLineItem *)0);
|
||||||
@ -579,7 +584,9 @@ public:
|
|||||||
BoundingRectItem(QGraphicsItem *parent = 0)
|
BoundingRectItem(QGraphicsItem *parent = 0)
|
||||||
: QGraphicsRectItem(0, 0, parent ? 200 : 100, parent ? 200 : 100,
|
: QGraphicsRectItem(0, 0, parent ? 200 : 100, parent ? 200 : 100,
|
||||||
parent)
|
parent)
|
||||||
{}
|
{
|
||||||
|
setPen(QPen(Qt::black, 0));
|
||||||
|
}
|
||||||
|
|
||||||
QRectF boundingRect() const
|
QRectF boundingRect() const
|
||||||
{
|
{
|
||||||
@ -2204,6 +2211,7 @@ void tst_QGraphicsItem::setMatrix()
|
|||||||
QSignalSpy spy(&scene, SIGNAL(changed(QList<QRectF>)));
|
QSignalSpy spy(&scene, SIGNAL(changed(QList<QRectF>)));
|
||||||
QRectF unrotatedRect(-12, -34, 56, 78);
|
QRectF unrotatedRect(-12, -34, 56, 78);
|
||||||
QGraphicsRectItem item(unrotatedRect, 0);
|
QGraphicsRectItem item(unrotatedRect, 0);
|
||||||
|
item.setPen(QPen(Qt::black, 0));
|
||||||
scene.addItem(&item);
|
scene.addItem(&item);
|
||||||
scene.update(scene.sceneRect());
|
scene.update(scene.sceneRect());
|
||||||
QApplication::instance()->processEvents();
|
QApplication::instance()->processEvents();
|
||||||
@ -2277,6 +2285,7 @@ void tst_QGraphicsItem::zValue()
|
|||||||
void tst_QGraphicsItem::shape()
|
void tst_QGraphicsItem::shape()
|
||||||
{
|
{
|
||||||
QGraphicsLineItem line(QLineF(-10, -10, 20, 20));
|
QGraphicsLineItem line(QLineF(-10, -10, 20, 20));
|
||||||
|
line.setPen(QPen(Qt::black, 0));
|
||||||
|
|
||||||
// We unfortunately need this hack as QPainterPathStroker will set a width of 1.0
|
// We unfortunately need this hack as QPainterPathStroker will set a width of 1.0
|
||||||
// if we pass a value of 0.0 to QPainterPathStroker::setWidth()
|
// if we pass a value of 0.0 to QPainterPathStroker::setWidth()
|
||||||
@ -2317,6 +2326,7 @@ void tst_QGraphicsItem::shape()
|
|||||||
QCOMPARE(line.shape(), p);
|
QCOMPARE(line.shape(), p);
|
||||||
|
|
||||||
QGraphicsRectItem rect(QRectF(-10, -10, 20, 20));
|
QGraphicsRectItem rect(QRectF(-10, -10, 20, 20));
|
||||||
|
rect.setPen(QPen(Qt::black, 0));
|
||||||
QPainterPathStroker ps1;
|
QPainterPathStroker ps1;
|
||||||
ps1.setWidth(penWidthZero);
|
ps1.setWidth(penWidthZero);
|
||||||
path = QPainterPath();
|
path = QPainterPath();
|
||||||
@ -2326,6 +2336,7 @@ void tst_QGraphicsItem::shape()
|
|||||||
QCOMPARE(rect.shape(), p);
|
QCOMPARE(rect.shape(), p);
|
||||||
|
|
||||||
QGraphicsEllipseItem ellipse(QRectF(-10, -10, 20, 20));
|
QGraphicsEllipseItem ellipse(QRectF(-10, -10, 20, 20));
|
||||||
|
ellipse.setPen(QPen(Qt::black, 0));
|
||||||
QPainterPathStroker ps2;
|
QPainterPathStroker ps2;
|
||||||
ps2.setWidth(ellipse.pen().widthF() <= 0.0 ? penWidthZero : ellipse.pen().widthF());
|
ps2.setWidth(ellipse.pen().widthF() <= 0.0 ? penWidthZero : ellipse.pen().widthF());
|
||||||
path = QPainterPath();
|
path = QPainterPath();
|
||||||
@ -2339,6 +2350,7 @@ void tst_QGraphicsItem::shape()
|
|||||||
p = ps3.createStroke(path);
|
p = ps3.createStroke(path);
|
||||||
p.addPath(path);
|
p.addPath(path);
|
||||||
QGraphicsPathItem pathItem(path);
|
QGraphicsPathItem pathItem(path);
|
||||||
|
pathItem.setPen(QPen(Qt::black, 0));
|
||||||
QCOMPARE(pathItem.shape(), p);
|
QCOMPARE(pathItem.shape(), p);
|
||||||
|
|
||||||
QRegion region(QRect(0, 0, 300, 200));
|
QRegion region(QRect(0, 0, 300, 200));
|
||||||
@ -2377,6 +2389,7 @@ void tst_QGraphicsItem::shape()
|
|||||||
QPolygonF poly;
|
QPolygonF poly;
|
||||||
poly << QPointF(0, 0) << QPointF(10, 0) << QPointF(0, 10);
|
poly << QPointF(0, 0) << QPointF(10, 0) << QPointF(0, 10);
|
||||||
QGraphicsPolygonItem polygon(poly);
|
QGraphicsPolygonItem polygon(poly);
|
||||||
|
polygon.setPen(QPen(Qt::black, 0));
|
||||||
path = QPainterPath();
|
path = QPainterPath();
|
||||||
path.addPolygon(poly);
|
path.addPolygon(poly);
|
||||||
|
|
||||||
@ -3393,6 +3406,12 @@ void tst_QGraphicsItem::childrenBoundingRectTransformed()
|
|||||||
rect4->setParentItem(rect3);
|
rect4->setParentItem(rect3);
|
||||||
rect5->setParentItem(rect4);
|
rect5->setParentItem(rect4);
|
||||||
|
|
||||||
|
rect->setPen(QPen(Qt::black, 0));
|
||||||
|
rect2->setPen(QPen(Qt::black, 0));
|
||||||
|
rect3->setPen(QPen(Qt::black, 0));
|
||||||
|
rect4->setPen(QPen(Qt::black, 0));
|
||||||
|
rect5->setPen(QPen(Qt::black, 0));
|
||||||
|
|
||||||
rect2->setTransform(QTransform().translate(50, 50).rotate(45));
|
rect2->setTransform(QTransform().translate(50, 50).rotate(45));
|
||||||
rect2->setPos(25, 25);
|
rect2->setPos(25, 25);
|
||||||
rect3->setTransform(QTransform().translate(50, 50).rotate(45));
|
rect3->setTransform(QTransform().translate(50, 50).rotate(45));
|
||||||
@ -3425,6 +3444,9 @@ void tst_QGraphicsItem::childrenBoundingRect2()
|
|||||||
QGraphicsLineItem l2(100, 0, 100, 100, &box);
|
QGraphicsLineItem l2(100, 0, 100, 100, &box);
|
||||||
QGraphicsLineItem l3(0, 0, 0, 100, &box);
|
QGraphicsLineItem l3(0, 0, 0, 100, &box);
|
||||||
// Make sure lines (zero with/height) are included in the childrenBoundingRect.
|
// Make sure lines (zero with/height) are included in the childrenBoundingRect.
|
||||||
|
l1.setPen(QPen(Qt::black, 0));
|
||||||
|
l2.setPen(QPen(Qt::black, 0));
|
||||||
|
l3.setPen(QPen(Qt::black, 0));
|
||||||
QCOMPARE(box.childrenBoundingRect(), QRectF(0, 0, 100, 100));
|
QCOMPARE(box.childrenBoundingRect(), QRectF(0, 0, 100, 100));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3442,6 +3464,12 @@ void tst_QGraphicsItem::childrenBoundingRect3()
|
|||||||
rect4->setParentItem(rect3);
|
rect4->setParentItem(rect3);
|
||||||
rect5->setParentItem(rect4);
|
rect5->setParentItem(rect4);
|
||||||
|
|
||||||
|
rect->setPen(QPen(Qt::black, 0));
|
||||||
|
rect2->setPen(QPen(Qt::black, 0));
|
||||||
|
rect3->setPen(QPen(Qt::black, 0));
|
||||||
|
rect4->setPen(QPen(Qt::black, 0));
|
||||||
|
rect5->setPen(QPen(Qt::black, 0));
|
||||||
|
|
||||||
rect2->setTransform(QTransform().translate(50, 50).rotate(45));
|
rect2->setTransform(QTransform().translate(50, 50).rotate(45));
|
||||||
rect2->setPos(25, 25);
|
rect2->setPos(25, 25);
|
||||||
rect3->setTransform(QTransform().translate(50, 50).rotate(45));
|
rect3->setTransform(QTransform().translate(50, 50).rotate(45));
|
||||||
@ -3495,6 +3523,9 @@ void tst_QGraphicsItem::childrenBoundingRect5()
|
|||||||
QGraphicsRectItem *child = scene.addRect(QRectF(0, 0, 100, 100));
|
QGraphicsRectItem *child = scene.addRect(QRectF(0, 0, 100, 100));
|
||||||
child->setParentItem(parent);
|
child->setParentItem(parent);
|
||||||
|
|
||||||
|
parent->setPen(QPen(Qt::black, 0));
|
||||||
|
child->setPen(QPen(Qt::black, 0));
|
||||||
|
|
||||||
QGraphicsView view(&scene);
|
QGraphicsView view(&scene);
|
||||||
view.show();
|
view.show();
|
||||||
|
|
||||||
@ -4382,6 +4413,7 @@ void tst_QGraphicsItem::defaultItemTest_QGraphicsTextItem()
|
|||||||
void tst_QGraphicsItem::defaultItemTest_QGraphicsEllipseItem()
|
void tst_QGraphicsItem::defaultItemTest_QGraphicsEllipseItem()
|
||||||
{
|
{
|
||||||
QGraphicsEllipseItem item;
|
QGraphicsEllipseItem item;
|
||||||
|
item.setPen(QPen(Qt::black, 0));
|
||||||
QVERIFY(item.rect().isNull());
|
QVERIFY(item.rect().isNull());
|
||||||
QVERIFY(item.boundingRect().isNull());
|
QVERIFY(item.boundingRect().isNull());
|
||||||
QVERIFY(item.shape().isEmpty());
|
QVERIFY(item.shape().isEmpty());
|
||||||
@ -6517,6 +6549,7 @@ void tst_QGraphicsItem::boundingRegion()
|
|||||||
QFETCH(QRegion, expectedRegion);
|
QFETCH(QRegion, expectedRegion);
|
||||||
|
|
||||||
QGraphicsLineItem item(line);
|
QGraphicsLineItem item(line);
|
||||||
|
item.setPen(QPen(Qt::black, 0));
|
||||||
QCOMPARE(item.boundingRegionGranularity(), qreal(0.0));
|
QCOMPARE(item.boundingRegionGranularity(), qreal(0.0));
|
||||||
item.setBoundingRegionGranularity(granularity);
|
item.setBoundingRegionGranularity(granularity);
|
||||||
QCOMPARE(item.boundingRegionGranularity(), granularity);
|
QCOMPARE(item.boundingRegionGranularity(), granularity);
|
||||||
@ -6980,6 +7013,7 @@ public:
|
|||||||
TransformDebugItem()
|
TransformDebugItem()
|
||||||
: QGraphicsRectItem(QRectF(-10, -10, 20, 20))
|
: QGraphicsRectItem(QRectF(-10, -10, 20, 20))
|
||||||
{
|
{
|
||||||
|
setPen(QPen(Qt::black, 0));
|
||||||
setBrush(QColor(qrand() % 256, qrand() % 256, qrand() % 256));
|
setBrush(QColor(qrand() % 256, qrand() % 256, qrand() % 256));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7047,7 +7081,9 @@ void tst_QGraphicsItem::sceneTransformCache()
|
|||||||
// parent is transformed.
|
// parent is transformed.
|
||||||
QGraphicsScene scene;
|
QGraphicsScene scene;
|
||||||
QGraphicsRectItem *rect = scene.addRect(0, 0, 100, 100);
|
QGraphicsRectItem *rect = scene.addRect(0, 0, 100, 100);
|
||||||
|
rect->setPen(QPen(Qt::black, 0));
|
||||||
QGraphicsRectItem *rect2 = scene.addRect(0, 0, 100, 100);
|
QGraphicsRectItem *rect2 = scene.addRect(0, 0, 100, 100);
|
||||||
|
rect2->setPen(QPen(Qt::black, 0));
|
||||||
rect2->setParentItem(rect);
|
rect2->setParentItem(rect);
|
||||||
rect2->rotate(90);
|
rect2->rotate(90);
|
||||||
rect->translate(0, 50);
|
rect->translate(0, 50);
|
||||||
@ -7071,9 +7107,11 @@ void tst_QGraphicsItem::sceneTransformCache()
|
|||||||
QGraphicsRectItem *rect3 = scene.addRect(0, 0, 100, 100);
|
QGraphicsRectItem *rect3 = scene.addRect(0, 0, 100, 100);
|
||||||
QGraphicsRectItem *rect4 = scene.addRect(0, 0, 100, 100);
|
QGraphicsRectItem *rect4 = scene.addRect(0, 0, 100, 100);
|
||||||
rect3->setPos(QPointF(10,10));
|
rect3->setPos(QPointF(10,10));
|
||||||
|
rect3->setPen(QPen(Qt::black, 0));
|
||||||
|
|
||||||
rect4->setParentItem(rect3);
|
rect4->setParentItem(rect3);
|
||||||
rect4->setPos(QPointF(10,10));
|
rect4->setPos(QPointF(10,10));
|
||||||
|
rect4->setPen(QPen(Qt::black, 0));
|
||||||
|
|
||||||
QCOMPARE(rect4->mapToScene(rect4->boundingRect().topLeft()), QPointF(20,20));
|
QCOMPARE(rect4->mapToScene(rect4->boundingRect().topLeft()), QPointF(20,20));
|
||||||
|
|
||||||
@ -7084,9 +7122,11 @@ void tst_QGraphicsItem::sceneTransformCache()
|
|||||||
QGraphicsRectItem *rect5 = scene.addRect(0, 0, 100, 100);
|
QGraphicsRectItem *rect5 = scene.addRect(0, 0, 100, 100);
|
||||||
QGraphicsRectItem *rect6 = scene.addRect(0, 0, 100, 100);
|
QGraphicsRectItem *rect6 = scene.addRect(0, 0, 100, 100);
|
||||||
rect5->setPos(QPointF(20,20));
|
rect5->setPos(QPointF(20,20));
|
||||||
|
rect5->setPen(QPen(Qt::black, 0));
|
||||||
|
|
||||||
rect6->setParentItem(rect5);
|
rect6->setParentItem(rect5);
|
||||||
rect6->setPos(QPointF(10,10));
|
rect6->setPos(QPointF(10,10));
|
||||||
|
rect6->setPen(QPen(Qt::black, 0));
|
||||||
//test if rect6 transform is ok
|
//test if rect6 transform is ok
|
||||||
QCOMPARE(rect6->mapToScene(rect6->boundingRect().topLeft()), QPointF(30,30));
|
QCOMPARE(rect6->mapToScene(rect6->boundingRect().topLeft()), QPointF(30,30));
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
|
|
||||||
#include <QtTest/QtTest>
|
#include <QtTest/QtTest>
|
||||||
#include <qgraphicsitem.h>
|
#include <qgraphicsitem.h>
|
||||||
|
#include <qpen.h>
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(QPolygonF)
|
Q_DECLARE_METATYPE(QPolygonF)
|
||||||
|
|
||||||
@ -170,6 +171,7 @@ void tst_QGraphicsPolygonItem::boundingRect()
|
|||||||
QFETCH(QRectF, boundingRect);
|
QFETCH(QRectF, boundingRect);
|
||||||
|
|
||||||
SubQGraphicsPolygonItem item(polygon);
|
SubQGraphicsPolygonItem item(polygon);
|
||||||
|
item.setPen(QPen(Qt::black, 0));
|
||||||
QCOMPARE(item.boundingRect(), boundingRect);
|
QCOMPARE(item.boundingRect(), boundingRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,7 +322,8 @@ void tst_QGraphicsScene::sceneRect()
|
|||||||
QCOMPARE(scene.sceneRect(), QRectF());
|
QCOMPARE(scene.sceneRect(), QRectF());
|
||||||
QCOMPARE(sceneRectChanged.count(), 0);
|
QCOMPARE(sceneRectChanged.count(), 0);
|
||||||
|
|
||||||
QGraphicsItem *item = scene.addRect(QRectF(0, 0, 10, 10));
|
QGraphicsRectItem *item = scene.addRect(QRectF(0, 0, 10, 10));
|
||||||
|
item->setPen(QPen(Qt::black, 0));
|
||||||
item->setPos(-5, -5);
|
item->setPos(-5, -5);
|
||||||
QCOMPARE(sceneRectChanged.count(), 0);
|
QCOMPARE(sceneRectChanged.count(), 0);
|
||||||
|
|
||||||
@ -458,7 +459,9 @@ void tst_QGraphicsScene::items()
|
|||||||
{
|
{
|
||||||
QGraphicsScene scene;
|
QGraphicsScene scene;
|
||||||
QGraphicsLineItem *l1 = scene.addLine(-5, 0, 5, 0);
|
QGraphicsLineItem *l1 = scene.addLine(-5, 0, 5, 0);
|
||||||
|
l1->setPen(QPen(Qt::black, 0));
|
||||||
QGraphicsLineItem *l2 = scene.addLine(0, -5, 0, 5);
|
QGraphicsLineItem *l2 = scene.addLine(0, -5, 0, 5);
|
||||||
|
l2->setPen(QPen(Qt::black, 0));
|
||||||
QVERIFY(!l1->sceneBoundingRect().intersects(l2->sceneBoundingRect()));
|
QVERIFY(!l1->sceneBoundingRect().intersects(l2->sceneBoundingRect()));
|
||||||
QVERIFY(!l2->sceneBoundingRect().intersects(l1->sceneBoundingRect()));
|
QVERIFY(!l2->sceneBoundingRect().intersects(l1->sceneBoundingRect()));
|
||||||
QList<QGraphicsItem *> items;
|
QList<QGraphicsItem *> items;
|
||||||
@ -533,7 +536,9 @@ void tst_QGraphicsScene::itemsBoundingRect()
|
|||||||
foreach (QRectF rect, rects) {
|
foreach (QRectF rect, rects) {
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
path.addRect(rect);
|
path.addRect(rect);
|
||||||
scene.addPath(path)->setMatrix(matrix);
|
QGraphicsPathItem *item = scene.addPath(path);
|
||||||
|
item->setPen(QPen(Qt::black, 0));
|
||||||
|
item->setMatrix(matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
QCOMPARE(scene.itemsBoundingRect(), boundingRect);
|
QCOMPARE(scene.itemsBoundingRect(), boundingRect);
|
||||||
@ -597,7 +602,8 @@ void tst_QGraphicsScene::items_QPointF()
|
|||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
path.addRect(0, 0, rect.width(), rect.height());
|
path.addRect(0, 0, rect.width(), rect.height());
|
||||||
|
|
||||||
QGraphicsItem *item = scene.addPath(path);
|
QGraphicsPathItem *item = scene.addPath(path);
|
||||||
|
item->setPen(QPen(Qt::black, 0));
|
||||||
item->setZValue(n++);
|
item->setZValue(n++);
|
||||||
item->setPos(rect.topLeft());
|
item->setPos(rect.topLeft());
|
||||||
addedItems << item;
|
addedItems << item;
|
||||||
@ -1170,6 +1176,9 @@ void tst_QGraphicsScene::addPath()
|
|||||||
QCOMPARE(path->pen(), QPen(Qt::red));
|
QCOMPARE(path->pen(), QPen(Qt::red));
|
||||||
QCOMPARE(path->path(), p);
|
QCOMPARE(path->path(), p);
|
||||||
QCOMPARE(path->brush(), QBrush(Qt::blue));
|
QCOMPARE(path->brush(), QBrush(Qt::blue));
|
||||||
|
|
||||||
|
path->setPen(QPen(Qt::red, 0));
|
||||||
|
|
||||||
QCOMPARE(scene.itemAt(0, 0), (QGraphicsItem *)path);
|
QCOMPARE(scene.itemAt(0, 0), (QGraphicsItem *)path);
|
||||||
QCOMPARE(scene.itemAt(-9.9, 0), (QGraphicsItem *)path);
|
QCOMPARE(scene.itemAt(-9.9, 0), (QGraphicsItem *)path);
|
||||||
QCOMPARE(scene.itemAt(9.9, 0), (QGraphicsItem *)path);
|
QCOMPARE(scene.itemAt(9.9, 0), (QGraphicsItem *)path);
|
||||||
@ -1222,6 +1231,9 @@ void tst_QGraphicsScene::addRect()
|
|||||||
QCOMPARE(rect->pen(), QPen(Qt::red));
|
QCOMPARE(rect->pen(), QPen(Qt::red));
|
||||||
QCOMPARE(rect->brush(), QBrush(Qt::blue));
|
QCOMPARE(rect->brush(), QBrush(Qt::blue));
|
||||||
QCOMPARE(rect->rect(), QRectF(-10, -10, 20, 20));
|
QCOMPARE(rect->rect(), QRectF(-10, -10, 20, 20));
|
||||||
|
|
||||||
|
rect->setPen(QPen(Qt::red, 0));
|
||||||
|
|
||||||
QCOMPARE(scene.itemAt(0, 0), (QGraphicsItem *)rect);
|
QCOMPARE(scene.itemAt(0, 0), (QGraphicsItem *)rect);
|
||||||
QCOMPARE(scene.itemAt(-10, -10), (QGraphicsItem *)rect);
|
QCOMPARE(scene.itemAt(-10, -10), (QGraphicsItem *)rect);
|
||||||
QCOMPARE(scene.itemAt(-9.9, 0), (QGraphicsItem *)rect);
|
QCOMPARE(scene.itemAt(-9.9, 0), (QGraphicsItem *)rect);
|
||||||
@ -1397,7 +1409,7 @@ void tst_QGraphicsScene::clear()
|
|||||||
QGraphicsScene scene;
|
QGraphicsScene scene;
|
||||||
scene.clear();
|
scene.clear();
|
||||||
QVERIFY(scene.items().isEmpty());
|
QVERIFY(scene.items().isEmpty());
|
||||||
scene.addRect(0, 0, 100, 100);
|
scene.addRect(0, 0, 100, 100)->setPen(QPen(Qt::black, 0));
|
||||||
QCOMPARE(scene.sceneRect(), QRectF(0, 0, 100, 100));
|
QCOMPARE(scene.sceneRect(), QRectF(0, 0, 100, 100));
|
||||||
scene.clear();
|
scene.clear();
|
||||||
QVERIFY(scene.items().isEmpty());
|
QVERIFY(scene.items().isEmpty());
|
||||||
@ -2610,8 +2622,8 @@ void tst_QGraphicsScene::render()
|
|||||||
|
|
||||||
QGraphicsView view;
|
QGraphicsView view;
|
||||||
QGraphicsScene scene(&view);
|
QGraphicsScene scene(&view);
|
||||||
scene.addEllipse(QRectF(-10, -10, 20, 20), QPen(Qt::black), QBrush(Qt::white));
|
scene.addEllipse(QRectF(-10, -10, 20, 20), QPen(Qt::black, 0), QBrush(Qt::white));
|
||||||
scene.addEllipse(QRectF(-2, -7, 4, 4), QPen(Qt::black), QBrush(Qt::yellow))->setZValue(1);
|
scene.addEllipse(QRectF(-2, -7, 4, 4), QPen(Qt::black, 0), QBrush(Qt::yellow))->setZValue(1);
|
||||||
QGraphicsPixmapItem *item = scene.addPixmap(pix);
|
QGraphicsPixmapItem *item = scene.addPixmap(pix);
|
||||||
item->setZValue(2);
|
item->setZValue(2);
|
||||||
item->setOffset(QPointF(3, 3));
|
item->setOffset(QPointF(3, 3));
|
||||||
@ -2808,6 +2820,7 @@ void tst_QGraphicsScene::update()
|
|||||||
QGraphicsScene scene;
|
QGraphicsScene scene;
|
||||||
|
|
||||||
QGraphicsRectItem *rect = new QGraphicsRectItem(0, 0, 100, 100);
|
QGraphicsRectItem *rect = new QGraphicsRectItem(0, 0, 100, 100);
|
||||||
|
rect->setPen(QPen(Qt::black, 0));
|
||||||
scene.addItem(rect);
|
scene.addItem(rect);
|
||||||
qApp->processEvents();
|
qApp->processEvents();
|
||||||
rect->setPos(-100, -100);
|
rect->setPos(-100, -100);
|
||||||
@ -3484,6 +3497,7 @@ void tst_QGraphicsScene::task176178_itemIndexMethodBreaksSceneRect()
|
|||||||
QGraphicsScene scene;
|
QGraphicsScene scene;
|
||||||
scene.setItemIndexMethod(QGraphicsScene::NoIndex);
|
scene.setItemIndexMethod(QGraphicsScene::NoIndex);
|
||||||
QGraphicsRectItem *rect = new QGraphicsRectItem;
|
QGraphicsRectItem *rect = new QGraphicsRectItem;
|
||||||
|
rect->setPen(QPen(Qt::black, 0));
|
||||||
rect->setRect(0,0,100,100);
|
rect->setRect(0,0,100,100);
|
||||||
scene.addItem(rect);
|
scene.addItem(rect);
|
||||||
QCOMPARE(scene.sceneRect(), rect->rect());
|
QCOMPARE(scene.sceneRect(), rect->rect());
|
||||||
@ -3513,11 +3527,11 @@ void tst_QGraphicsScene::task250680_childClip()
|
|||||||
{
|
{
|
||||||
QGraphicsRectItem *clipper = new QGraphicsRectItem;
|
QGraphicsRectItem *clipper = new QGraphicsRectItem;
|
||||||
clipper->setFlag(QGraphicsItem::ItemClipsChildrenToShape);
|
clipper->setFlag(QGraphicsItem::ItemClipsChildrenToShape);
|
||||||
clipper->setPen(QPen(Qt::green));
|
clipper->setPen(QPen(Qt::green, 0));
|
||||||
clipper->setRect(200, 200, 640, 480);
|
clipper->setRect(200, 200, 640, 480);
|
||||||
|
|
||||||
QGraphicsRectItem *rect = new QGraphicsRectItem(clipper);
|
QGraphicsRectItem *rect = new QGraphicsRectItem(clipper);
|
||||||
rect->setPen(QPen(Qt::red));
|
rect->setPen(QPen(Qt::red, 0));
|
||||||
rect->setBrush(QBrush(QColor(255, 0, 0, 75)));
|
rect->setBrush(QBrush(QColor(255, 0, 0, 75)));
|
||||||
rect->setPos(320, 240);
|
rect->setPos(320, 240);
|
||||||
rect->setRect(-25, -25, 50, 50);
|
rect->setRect(-25, -25, 50, 50);
|
||||||
@ -3662,6 +3676,7 @@ void tst_QGraphicsScene::changedSignal()
|
|||||||
view = new QGraphicsView(&scene);
|
view = new QGraphicsView(&scene);
|
||||||
|
|
||||||
QGraphicsRectItem *rect = new QGraphicsRectItem(0, 0, 10, 10);
|
QGraphicsRectItem *rect = new QGraphicsRectItem(0, 0, 10, 10);
|
||||||
|
rect->setPen(QPen(Qt::black, 0));
|
||||||
scene.addItem(rect);
|
scene.addItem(rect);
|
||||||
|
|
||||||
QCOMPARE(cl.changes.size(), 0);
|
QCOMPARE(cl.changes.size(), 0);
|
||||||
@ -4246,13 +4261,13 @@ void tst_QGraphicsScene::siblingIndexAlwaysValid()
|
|||||||
|
|
||||||
// first add the blue rect
|
// first add the blue rect
|
||||||
QGraphicsRectItem* const item1 = new QGraphicsRectItem(QRect( 10, 10, 10, 10 ));
|
QGraphicsRectItem* const item1 = new QGraphicsRectItem(QRect( 10, 10, 10, 10 ));
|
||||||
item1->setPen(QColor(Qt::blue));
|
item1->setPen(QPen(Qt::blue, 0));
|
||||||
item1->setBrush(Qt::blue);
|
item1->setBrush(Qt::blue);
|
||||||
scene2.addItem(item1);
|
scene2.addItem(item1);
|
||||||
|
|
||||||
// then add the red rect
|
// then add the red rect
|
||||||
QGraphicsRectItem* const item2 = new QGraphicsRectItem(5, 5, 10, 10);
|
QGraphicsRectItem* const item2 = new QGraphicsRectItem(5, 5, 10, 10);
|
||||||
item2->setPen(QColor(Qt::red));
|
item2->setPen(QPen(Qt::red, 0));
|
||||||
item2->setBrush(Qt::red);
|
item2->setBrush(Qt::red);
|
||||||
scene2.addItem(item2);
|
scene2.addItem(item2);
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ void tst_QGraphicsSceneIndex::overlappedItems()
|
|||||||
|
|
||||||
for (int i = 0; i < 10; ++i)
|
for (int i = 0; i < 10; ++i)
|
||||||
for (int j = 0; j < 10; ++j)
|
for (int j = 0; j < 10; ++j)
|
||||||
scene.addRect(i*50, j*50, 200, 200);
|
scene.addRect(i*50, j*50, 200, 200)->setPen(QPen(Qt::black, 0));
|
||||||
|
|
||||||
QCOMPARE(scene.items(QPointF(5, 5)).count(), 1);
|
QCOMPARE(scene.items(QPointF(5, 5)).count(), 1);
|
||||||
QCOMPARE(scene.items(QPointF(55, 55)).count(), 4);
|
QCOMPARE(scene.items(QPointF(55, 55)).count(), 4);
|
||||||
|
@ -542,6 +542,7 @@ void tst_QGraphicsView::sceneRect()
|
|||||||
QCOMPARE(view.sceneRect(), QRectF());
|
QCOMPARE(view.sceneRect(), QRectF());
|
||||||
QGraphicsScene scene;
|
QGraphicsScene scene;
|
||||||
QGraphicsRectItem *item = scene.addRect(QRectF(-100, -100, 100, 100));
|
QGraphicsRectItem *item = scene.addRect(QRectF(-100, -100, 100, 100));
|
||||||
|
item->setPen(QPen(Qt::black, 0));
|
||||||
|
|
||||||
view.setScene(&scene);
|
view.setScene(&scene);
|
||||||
|
|
||||||
@ -1510,6 +1511,7 @@ void tst_QGraphicsView::itemsInRect_cosmeticAdjust()
|
|||||||
|
|
||||||
QGraphicsScene scene(-100, -100, 200, 200);
|
QGraphicsScene scene(-100, -100, 200, 200);
|
||||||
CountPaintItem *rect = new CountPaintItem(QRectF(-50, -50, 100, 100));
|
CountPaintItem *rect = new CountPaintItem(QRectF(-50, -50, 100, 100));
|
||||||
|
rect->setPen(QPen(Qt::black, 0));
|
||||||
scene.addItem(rect);
|
scene.addItem(rect);
|
||||||
|
|
||||||
QGraphicsView view(&scene);
|
QGraphicsView view(&scene);
|
||||||
@ -2603,8 +2605,13 @@ void tst_QGraphicsView::optimizationFlags_dontSavePainterState2()
|
|||||||
|
|
||||||
MyScene scene;
|
MyScene scene;
|
||||||
// Add transformed dummy items to make sure the painter's worldTransform() is changed in drawItems.
|
// Add transformed dummy items to make sure the painter's worldTransform() is changed in drawItems.
|
||||||
scene.addRect(0, 0, 20, 20)->setTransform(QTransform::fromScale(2, 2));
|
QGraphicsRectItem *rectA = scene.addRect(0, 0, 20, 20);
|
||||||
scene.addRect(50, 50, 20, 20)->setTransform(QTransform::fromTranslate(200, 200));
|
QGraphicsRectItem *rectB = scene.addRect(50, 50, 20, 20);
|
||||||
|
|
||||||
|
rectA->setTransform(QTransform::fromScale(2, 2));
|
||||||
|
rectA->setPen(QPen(Qt::black, 0));
|
||||||
|
rectB->setTransform(QTransform::fromTranslate(200, 200));
|
||||||
|
rectB->setPen(QPen(Qt::black, 0));
|
||||||
|
|
||||||
foreach (QGraphicsItem *item, scene.items())
|
foreach (QGraphicsItem *item, scene.items())
|
||||||
item->setOpacity(0.6);
|
item->setOpacity(0.6);
|
||||||
@ -3367,10 +3374,11 @@ void tst_QGraphicsView::moveItemWhileScrolling()
|
|||||||
setScene(new QGraphicsScene(0, 0, 1000, 1000));
|
setScene(new QGraphicsScene(0, 0, 1000, 1000));
|
||||||
rect = scene()->addRect(0, 0, 10, 10);
|
rect = scene()->addRect(0, 0, 10, 10);
|
||||||
rect->setPos(50, 50);
|
rect->setPos(50, 50);
|
||||||
|
rect->setPen(QPen(Qt::black, 0));
|
||||||
painted = false;
|
painted = false;
|
||||||
}
|
}
|
||||||
QRegion lastPaintedRegion;
|
QRegion lastPaintedRegion;
|
||||||
QGraphicsItem *rect;
|
QGraphicsRectItem *rect;
|
||||||
bool painted;
|
bool painted;
|
||||||
void waitForPaintEvent()
|
void waitForPaintEvent()
|
||||||
{
|
{
|
||||||
@ -4331,25 +4339,31 @@ void tst_QGraphicsView::task255529_transformationAnchorMouseAndViewportMargins()
|
|||||||
view.show();
|
view.show();
|
||||||
qApp->setActiveWindow(&view);
|
qApp->setActiveWindow(&view);
|
||||||
QVERIFY(QTest::qWaitForWindowActive(&view));
|
QVERIFY(QTest::qWaitForWindowActive(&view));
|
||||||
QPoint mouseViewPos(20, 20);
|
|
||||||
sendMouseMove(view.viewport(), mouseViewPos);
|
|
||||||
|
|
||||||
QPointF mouseScenePos = view.mapToScene(mouseViewPos);
|
|
||||||
view.setTransform(QTransform().scale(5, 5).rotate(5, Qt::ZAxis), true);
|
|
||||||
|
|
||||||
QPointF newMouseScenePos = view.mapToScene(mouseViewPos);
|
|
||||||
|
|
||||||
qreal slack = 1;
|
|
||||||
|
|
||||||
const qreal dx = qAbs(newMouseScenePos.x() - mouseScenePos.x());
|
|
||||||
const qreal dy = qAbs(newMouseScenePos.y() - mouseScenePos.y());
|
|
||||||
const QByteArray message = QString::fromLatin1("QTBUG-22455, distance: dx=%1, dy=%2 slack=%3 (%4).").
|
|
||||||
arg(dx).arg(dy).arg(slack).arg(qApp->style()->metaObject()->className()).toLocal8Bit();
|
|
||||||
// This is highly unstable (observed to pass on Windows and some Linux configurations).
|
// This is highly unstable (observed to pass on Windows and some Linux configurations).
|
||||||
#ifdef Q_OS_MAC
|
#ifndef Q_OS_MAC
|
||||||
QEXPECT_FAIL("", message.constData(), Abort);
|
for (int i = 0; i < 4; ++i) {
|
||||||
|
QPoint mouseViewPos(20, 20);
|
||||||
|
sendMouseMove(view.viewport(), mouseViewPos);
|
||||||
|
|
||||||
|
QPointF mouseScenePos = view.mapToScene(mouseViewPos);
|
||||||
|
view.setTransform(QTransform().scale(5, 5).rotate(5, Qt::ZAxis), true);
|
||||||
|
|
||||||
|
qreal slack = 1;
|
||||||
|
|
||||||
|
QPointF newMouseScenePos = view.mapToScene(mouseViewPos);
|
||||||
|
|
||||||
|
const qreal dx = qAbs(newMouseScenePos.x() - mouseScenePos.x());
|
||||||
|
const qreal dy = qAbs(newMouseScenePos.y() - mouseScenePos.y());
|
||||||
|
const QByteArray message = QString::fromLatin1("QTBUG-22455, distance: dx=%1, dy=%2 slack=%3 (%4).").
|
||||||
|
arg(dx).arg(dy).arg(slack).arg(qApp->style()->metaObject()->className()).toLocal8Bit();
|
||||||
|
if (i == 9 || (dx < slack && dy < slack)) {
|
||||||
|
QVERIFY2(dx < slack && dy < slack, message.constData());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTest::qWait(100);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
QVERIFY2(dx < slack && dy < slack, message.constData());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QGraphicsView::task259503_scrollingArtifacts()
|
void tst_QGraphicsView::task259503_scrollingArtifacts()
|
||||||
|
Loading…
Reference in New Issue
Block a user