22#include <QPainterPath>
32 : coordinateSystem(StrokeWidth),
34 hasAutoOrientation(false),
35 explicitOrientation(0)
50 return name == other.name &&
51 coordinateSystem == other.coordinateSystem &&
52 referencePoint == other.referencePoint &&
53 referenceSize == other.referenceSize &&
54 hasAutoOrientation == other.hasAutoOrientation &&
55 explicitOrientation == other.explicitOrientation &&
56 compareShapesTo(other.shapes);
61 coordinateSystem(rhs.coordinateSystem),
62 referencePoint(rhs.referencePoint),
63 referenceSize(rhs.referenceSize),
64 hasAutoOrientation(rhs.hasAutoOrientation),
65 explicitOrientation(rhs.explicitOrientation)
67 Q_FOREACH (
KoShape *shape, rhs.shapes) {
84 if (shapes.size() != other.size())
return false;
86 for (
int i = 0; i < shapes.size(); i++) {
87 if (shapes[i]->outline() != other[i]->outline() ||
88 shapes[i]->absoluteTransformation() != other[i]->absoluteTransformation()) {
97 QTransform
markerTransform(qreal strokeWidth, qreal nodeAngle,
const QPointF &pos = QPointF()) {
98 const QTransform translate = QTransform::fromTranslate(-referencePoint.x(), -referencePoint.y());
100 QTransform t = translate;
102 if (coordinateSystem == StrokeWidth) {
103 t *= QTransform::fromScale(strokeWidth, strokeWidth);
106 const qreal angle = hasAutoOrientation ? nodeAngle : explicitOrientation;
109 r.rotateRadians(angle);
113 t *= QTransform::fromTranslate(pos.x(), pos.y());
142 return *
d == *other.
d;
147 d->coordinateSystem =
value;
152 return d->coordinateSystem;
159 if (
value ==
"userSpaceOnUse") {
176 d->referencePoint =
value;
181 return d->referencePoint;
186 d->referenceSize = size;
191 return d->referenceSize;
196 return d->hasAutoOrientation;
201 d->hasAutoOrientation =
value;
206 return d->explicitOrientation;
211 d->explicitOrientation =
value;
218 if (
d->shapePainter) {
219 d->shapePainter->setShapes(
shapes);
230 QTransform oldTransform = painter->transform();
232 if (!
d->shapePainter) {
234 d->shapePainter->setShapes(
d->shapes);
237 painter->setTransform(
d->markerTransform(strokeWidth, nodeAngle, pos),
true);
238 d->shapePainter->paint(*painter);
240 painter->setTransform(oldTransform);
260 const QTransform t =
d->markerTransform(strokeWidth, nodeAngle);
262 if (!t.isIdentity()) {
263 shapesBounds = t.mapRect(shapesBounds);
272 Q_FOREACH (
KoShape *shape,
d->shapes) {
276 const QTransform t =
d->markerTransform(strokeWidth, nodeAngle);
278 if (!t.isIdentity()) {
287 const QRectF outlineRect =
outline(pen.widthF(), 0).boundingRect();
293 marker = QPointF(-outlineRect.left() + previewRect.left(), previewRect.center().y());
295 end = QPointF(previewRect.right(), start.y());
297 start = QPointF(previewRect.left(), previewRect.center().y());
298 marker = QPointF(-outlineRect.center().x() + previewRect.center().x(), start.y());
299 end = QPointF(previewRect.right(), start.y());
301 start = QPointF(previewRect.left(), previewRect.center().y());
302 marker = QPointF(-outlineRect.right() + previewRect.right(), start.y());
307 painter->setPen(pen);
308 painter->setClipRect(previewRect);
310 painter->drawLine(start, end);
318 const QGradient *originalGradient = stroke->
lineBrush().gradient();
320 if (!originalGradient) {
322 Q_FOREACH(
KoShape *shape, linearizedShapes) {
325 qSharedPointerDynamicCast<KoShapeStroke>(shape->
stroke()) :
331 shapeStroke->setLineBrush(QBrush());
332 shapeStroke->setColor(stroke->
color());
347 const QTransform markerTransformInverted =
348 d->markerTransform(strokeWidth, nodeAngle, pos).inverted();
350 QTransform gradientToUser;
353 if (g->coordinateMode() == QGradient::ObjectBoundingMode) {
356 parentShape->
outline().boundingRect() :
364 g->setCoordinateMode(QGradient::LogicalMode);
368 Q_FOREACH(
KoShape *shape, linearizedShapes) {
374 qSharedPointerDynamicCast<KoShapeStroke>(shape->
stroke()) :
381 brush.setTransform(t);
382 shapeStroke->setLineBrush(brush);
383 shapeStroke->setColor(Qt::transparent);
float value(const T *src, size_t ch)
QSharedPointer< KoShapeStroke > KoShapeStrokeSP
A simple solid color shape background.
A gradient shape background.
bool compareShapesTo(const QList< KoShape * > other) const
Private(const Private &rhs)
void setCoordinateSystem(MarkerCoordinateSystem value)
static MarkerCoordinateSystem coordinateSystemFromString(const QString &value)
QRectF boundingRect(qreal strokeWidth, qreal nodeAngle) const
bool operator==(const KoMarker::Private &other) const
qreal explicitOrientation
void paintAtPosition(QPainter *painter, const QPointF &pos, qreal strokeWidth, qreal nodeAngle)
paintAtOrigin paints the marker at the position pos. Scales and rotates the marker if needed.
void setAutoOrientation(bool value)
MarkerCoordinateSystem coordinateSystem
void applyShapeStroke(const KoShape *shape, KoShapeStroke *stroke, const QPointF &pos, qreal strokeWidth, qreal nodeAngle)
static QString coordinateSystemToString(MarkerCoordinateSystem value)
void setReferenceSize(const QSizeF &size)
QTransform markerTransform(qreal strokeWidth, qreal nodeAngle, const QPointF &pos=QPointF())
void setShapes(const QList< KoShape * > &shapes)
void setReferencePoint(const QPointF &value)
QScopedPointer< KoShapePainter > shapePainter
void setExplicitOrientation(qreal value)
void drawPreview(QPainter *painter, const QRectF &previewRect, const QPen &pen, KoFlake::MarkerPosition position)
QList< KoShape * > shapes
QPainterPath outline(qreal strokeWidth, qreal nodeAngle) const
qreal maxInset(qreal strokeWidth) const
QBrush lineBrush() const
Returns the strokes brush.
virtual QPainterPath outline() const
virtual KoShapeStrokeModelSP stroke() const
virtual QRectF boundingRect() const
Get the bounding box of the shape.
virtual void setStroke(KoShapeStrokeModelSP stroke)
QTransform absoluteTransformation() const
virtual void setBackground(QSharedPointer< KoShapeBackground > background)
static QList< KoShape * > linearizeSubtree(const QList< KoShape * > &shapes)
virtual KoShape * cloneShape() const
creates a deep copy of the shape or shape's subtree
virtual QSharedPointer< KoShapeBackground > background() const
#define KIS_ASSERT_RECOVER_RETURN(cond)
QSharedPointer< T > toQShared(T *ptr)
Rect ensureRectNotSmaller(Rect rc, const decltype(Rect().size()) &size)
KRITAFLAKE_EXPORT QGradient * cloneGradient(const QGradient *gradient)
clones the given gradient