Commit 7a35b3b2 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Implement centralized painting of handles

Now every (vector) tool in Krita uses KisHandlePainterHelper to
paint the handles. The helper supports styling, that is you
can set any predefined object of type KisHandleStyle to get
needed effect.
parent 48536508
......@@ -33,6 +33,7 @@
#include "kis_int_parse_spin_box.h"
#include <KoColor.h>
#include "kis_canvas_resource_provider.h"
#include <KisHandlePainterHelper.h>
#include <klocalizedstring.h>
......@@ -62,52 +63,35 @@ void KoCreatePathTool::paint(QPainter &painter, const KoViewConverter &converter
paintPath(*(d->shape), painter, converter);
painter.restore();
painter.save();
painter.setTransform(d->shape->absoluteTransformation(&converter) * painter.transform());
KoShape::applyConversion(painter, converter);
KisHandlePainterHelper helper =
KoShape::createHandlePainterHelper(&painter, d->shape, converter, d->handleRadius);
QPen pen(QBrush(Qt::blue), 1);
pen.setCosmetic(true);
painter.setPen(pen);
painter.setBrush(Qt::white);
const bool firstPointActive = d->firstPoint == d->activePoint;
const bool firstPoint = (d->firstPoint == d->activePoint);
if (d->pointIsDragged || firstPoint) {
if (d->pointIsDragged || firstPointActive) {
const bool onlyPaintActivePoints = false;
KoPathPoint::PointTypes paintFlags = KoPathPoint::ControlPoint2;
if (d->activePoint->activeControlPoint1()) {
paintFlags |= KoPathPoint::ControlPoint1;
}
d->activePoint->paint(painter, d->handleRadius, paintFlags, onlyPaintActivePoints);
}
// check if we have to color the first point
if (d->mouseOverFirstPoint) {
painter.setBrush(Qt::red);
} else {
painter.setBrush(Qt::white);
helper.setHandleStyle(KisHandleStyle::highlightedPrimaryHandles());
d->activePoint->paint(helper, paintFlags, onlyPaintActivePoints);
}
d->firstPoint->paint(painter, d->handleRadius, KoPathPoint::Node);
painter.restore();
if (!firstPointActive) {
helper.setHandleStyle(d->mouseOverFirstPoint ?
KisHandleStyle::highlightedPrimaryHandles() :
KisHandleStyle::primarySelection());
d->firstPoint->paint(helper, KoPathPoint::Node);
}
}
if (d->hoveredPoint) {
painter.save();
painter.setTransform(d->hoveredPoint->parent()->absoluteTransformation(&converter), true);
KoShape::applyConversion(painter, converter);
QPen pen(QBrush(Qt::blue), 1);
pen.setCosmetic(true);
painter.setPen(pen);
painter.setBrush(Qt::white);
d->hoveredPoint->paint(painter, d->handleRadius, KoPathPoint::Node);
painter.restore();
KisHandlePainterHelper helper = KoShape::createHandlePainterHelper(&painter, d->hoveredPoint->parent(), converter, d->handleRadius);
helper.setHandleStyle(KisHandleStyle::highlightedPrimaryHandles());
d->hoveredPoint->paint(helper, KoPathPoint::Node);
}
painter.save();
......
......@@ -35,6 +35,7 @@
#include <KoPathPointMergeCommand.h>
#include <KoShapePaintingContext.h>
#include <widgets/KoStrokeConfigWidget.h>
#include <KisHandlePainterHelper.h>
#include <klocalizedstring.h>
......@@ -93,15 +94,11 @@ void KoPencilTool::paint(QPainter &painter, const KoViewConverter &converter)
}
if (m_hoveredPoint) {
painter.save();
painter.setTransform(m_hoveredPoint->parent()->absoluteTransformation(&converter), true);
KoShape::applyConversion(painter, converter);
painter.setPen(QPen(Qt::blue, 0)); //TODO make configurable
painter.setBrush(Qt::white); //TODO make configurable
m_hoveredPoint->paint(painter, handleRadius(), KoPathPoint::Node);
KisHandlePainterHelper helper =
KoShape::createHandlePainterHelper(&painter, m_hoveredPoint->parent(), converter, handleRadius());
painter.restore();
helper.setHandleStyle(KisHandleStyle::primarySelection());
m_hoveredPoint->paint(helper, KoPathPoint::Node);
}
}
......
......@@ -21,6 +21,8 @@
#include "KoParameterShape.h"
#include "KoParameterShape_p.h"
#include <KisHandlePainterHelper.h>
#include <QPainter>
#include <FlakeDebug.h>
......@@ -88,42 +90,20 @@ QPointF KoParameterShape::handlePosition(int handleId) const
return d->handles.value(handleId);
}
void KoParameterShape::paintHandles(QPainter & painter, const KoViewConverter & converter, int handleRadius)
void KoParameterShape::paintHandles(KisHandlePainterHelper &handlesHelper)
{
Q_D(KoParameterShape);
applyConversion(painter, converter);
QTransform worldMatrix = painter.worldTransform();
painter.setTransform(QTransform());
QTransform matrix;
matrix.rotate(45.0);
QPolygonF poly(d->handleRect(QPointF(0, 0), handleRadius));
poly = matrix.map(poly);
QList<QPointF>::const_iterator it(d->handles.constBegin());
for (; it != d->handles.constEnd(); ++it) {
QPointF moveVector = worldMatrix.map(*it);
poly.translate(moveVector.x(), moveVector.y());
painter.drawPolygon(poly);
poly.translate(-moveVector.x(), -moveVector.y());
handlesHelper.drawGradientHandle(*it);
}
}
void KoParameterShape::paintHandle(QPainter & painter, const KoViewConverter & converter, int handleId, int handleRadius)
void KoParameterShape::paintHandle(KisHandlePainterHelper &handlesHelper, int handleId)
{
Q_D(KoParameterShape);
applyConversion(painter, converter);
QTransform worldMatrix = painter.worldTransform();
painter.setTransform(QTransform());
QTransform matrix;
matrix.rotate(45.0);
QPolygonF poly(d->handleRect(QPointF(0, 0), handleRadius));
poly = matrix.map(poly);
poly.translate(worldMatrix.map(d->handles[handleId]));
painter.drawPolygon(poly);
handlesHelper.drawGradientHandle(d->handles[handleId]);
}
void KoParameterShape::setSize(const QSizeF &newSize)
......
......@@ -25,6 +25,7 @@
#include "kritaflake_export.h"
class KoParameterShapePrivate;
class KisHandlePainterHelper;
/**
* KoParameterShape is the base class for all parametric shapes
......@@ -83,7 +84,7 @@ public:
* @param converter the view converter for applying the actual zoom
* @param handleRadius the radius of the handles used for painting
*/
void paintHandles(QPainter &painter, const KoViewConverter &converter, int handleRadius);
void paintHandles(KisHandlePainterHelper &handlesHelper);
/**
* @brief Paint the given handles
......@@ -93,7 +94,7 @@ public:
* @param handleId of the handle which should be repainted
* @param handleRadius the radius of the handle used for painting
*/
void paintHandle(QPainter &painter, const KoViewConverter &converter, int handleId, int handleRadius);
void paintHandle(KisHandlePainterHelper &handlesHelper, int handleId);
/// reimplemented from KoShape
virtual void setSize(const QSizeF &size);
......
......@@ -25,6 +25,7 @@
#include <FlakeDebug.h>
#include <QPainter>
#include <QPointF>
#include <KisHandlePainterHelper.h>
#include <math.h>
......@@ -261,49 +262,40 @@ void KoPathPoint::map(const QTransform &matrix)
d->shape->notifyChanged();
}
void KoPathPoint::paint(QPainter &painter, int handleRadius, PointTypes types, bool active)
void KoPathPoint::paint(KisHandlePainterHelper &handlesHelper, PointTypes types, bool active)
{
QRectF handle(-handleRadius, -handleRadius, 2*handleRadius, 2*handleRadius);
bool drawControlPoint1 = types & ControlPoint1 && (!active || activeControlPoint1());
bool drawControlPoint2 = types & ControlPoint2 && (!active || activeControlPoint2());
// draw lines at the bottom
if (drawControlPoint2)
painter.drawLine(point(), controlPoint2());
if (drawControlPoint1)
painter.drawLine(point(), controlPoint1());
QTransform worldMatrix = painter.worldTransform();
if (drawControlPoint2) {
handlesHelper.drawConnectionLine(point(), controlPoint2());
}
painter.setWorldTransform(QTransform());
if (drawControlPoint1) {
handlesHelper.drawConnectionLine(point(), controlPoint1());
}
// the point is lowest
if (types & Node) {
if (properties() & IsSmooth)
painter.drawRect(handle.translated(worldMatrix.map(point())));
else if (properties() & IsSymmetric) {
QTransform matrix;
matrix.rotate(45.0);
QPolygonF poly(handle);
poly = matrix.map(poly);
poly.translate(worldMatrix.map(point()));
painter.drawPolygon(poly);
} else
painter.drawEllipse(handle.translated(worldMatrix.map(point())));
if (properties() & IsSmooth) {
handlesHelper.drawHandleRect(point());
} else if (properties() & IsSymmetric) {
handlesHelper.drawGradientHandle(point());
} else {
handlesHelper.drawHandleCircle(point());
}
}
// then comes control point 2
if (drawControlPoint2)
painter.drawEllipse(handle.translated(worldMatrix.map(controlPoint2())));
if (drawControlPoint2) {
handlesHelper.drawHandleCircle(controlPoint2());
}
// then comes control point 1
if (drawControlPoint1)
painter.drawEllipse(handle.translated(worldMatrix.map(controlPoint1())));
painter.setWorldTransform(worldMatrix);
if (drawControlPoint1) {
handlesHelper.drawHandleCircle(controlPoint1());
}
}
void KoPathPoint::setParent(KoPathShape* parent)
......
......@@ -31,6 +31,7 @@ class QPointF;
class QTransform;
class QRectF;
class QPainter;
class KisHandlePainterHelper;
/**
* @brief A KoPathPoint represents a point in a path.
......@@ -213,7 +214,7 @@ public:
* @param active If true only the given active points are painted
* If false all given points are used.
*/
void paint(QPainter &painter, int handleRadius, PointTypes types, bool active = true);
void paint(KisHandlePainterHelper &handlesHelper, PointTypes types, bool active = true);
/**
* @brief Sets the parent path shape.
......
......@@ -461,18 +461,16 @@ void KoPathShapePrivate::debugPath() const
}
#endif
void KoPathShape::paintPoints(QPainter &painter, const KoViewConverter &converter, int handleRadius)
void KoPathShape::paintPoints(KisHandlePainterHelper &handlesHelper)
{
Q_D(KoPathShape);
applyConversion(painter, converter);
KoSubpathList::const_iterator pathIt(d->subpaths.constBegin());
for (; pathIt != d->subpaths.constEnd(); ++pathIt) {
KoSubpath::const_iterator it((*pathIt)->constBegin());
for (; it != (*pathIt)->constEnd(); ++it)
(*it)->paint(painter, handleRadius, KoPathPoint::Node);
(*it)->paint(handlesHelper, KoPathPoint::Node);
}
}
......
......@@ -37,6 +37,7 @@ class KoPathSegment;
class KoPathPoint;
class KoPathShapePrivate;
class KoMarker;
class KisHandlePainterHelper;
typedef QPair<int, int> KoPathPointIndex;
......@@ -89,7 +90,7 @@ public:
/// reimplemented
virtual void paint(QPainter &painter, const KoViewConverter &converter, KoShapePaintingContext &paintContext);
virtual void paintPoints(QPainter &painter, const KoViewConverter &converter, int handleRadius);
virtual void paintPoints(KisHandlePainterHelper &handlesHelper);
/// reimplemented
QRectF outlineRect() const override;
......
......@@ -74,6 +74,7 @@
#include <limits>
#include "KoOdfGradientBackground.h"
#include <KisHandlePainterHelper.h>
// KoShapePrivate
......@@ -2171,6 +2172,17 @@ void KoShape::applyConversion(QPainter &painter, const KoViewConverter &converte
painter.scale(zoomX, zoomY);
}
KisHandlePainterHelper KoShape::createHandlePainterHelper(QPainter *painter, KoShape *shape, const KoViewConverter &converter, qreal handleRadius)
{
const QTransform originalPainterTransform = painter->transform();
painter->setTransform(shape->absoluteTransformation(&converter) * painter->transform());
KoShape::applyConversion(*painter, converter);
// move c-tor
return KisHandlePainterHelper(painter, originalPainterTransform, handleRadius);
}
QPointF KoShape::shapeToDocument(const QPointF &point) const
{
return absoluteTransformation(0).map(point);
......
......@@ -59,7 +59,7 @@ class KoShapeAnchor;
class KoBorder;
struct KoInsets;
class KoShapeBackground;
class KisHandlePainterHelper;
/**
......@@ -904,6 +904,13 @@ public:
*/
static void applyConversion(QPainter &painter, const KoViewConverter &converter);
/**
* A convenience method that creates a handles helper with applying transformations at
* the same time. Please note that you shouldn't save/restore additionally. All the work
* on restoring original painter's transformations is done by the helper.
*/
static KisHandlePainterHelper createHandlePainterHelper(QPainter *painter, KoShape *shape, const KoViewConverter &converter, qreal handleRadius = 0.0);
/**
* @brief Transforms point from shape coordinates to document coordinates
* @param point in shape coordinates
......
......@@ -50,6 +50,7 @@
#include "KoSnapGuide.h"
#include "KoShapeController.h"
#include "kis_action_registry.h"
#include <KisHandlePainterHelper.h>
#include <KoIcon.h>
......@@ -416,23 +417,18 @@ void KoPathTool::breakAtSegment()
void KoPathTool::paint(QPainter &painter, const KoViewConverter &converter)
{
Q_D(KoToolBase);
painter.setRenderHint(QPainter::Antialiasing, true);
// use different colors so that it is also visible on a background of the same color
painter.setBrush(Qt::white);
painter.setPen(Qt::blue);
Q_FOREACH (KoPathShape *shape, m_pointSelection.selectedShapes()) {
painter.save();
painter.setTransform(shape->absoluteTransformation(&converter) * painter.transform());
KisHandlePainterHelper helper =
KoShape::createHandlePainterHelper(&painter, shape, converter, m_handleRadius);
helper.setHandleStyle(KisHandleStyle::primarySelection());
KoParameterShape * parameterShape = dynamic_cast<KoParameterShape*>(shape);
if (parameterShape && parameterShape->isParametricShape()) {
parameterShape->paintHandles(painter, converter, m_handleRadius);
parameterShape->paintHandles(helper);
} else {
shape->paintPoints(painter, converter, m_handleRadius);
shape->paintPoints(helper);
}
painter.restore();
}
if (m_currentStrategy) {
......@@ -441,17 +437,11 @@ void KoPathTool::paint(QPainter &painter, const KoViewConverter &converter)
painter.restore();
}
painter.setBrush(Qt::green);
painter.setPen(Qt::blue);
m_pointSelection.paint(painter, converter);
painter.setBrush(Qt::red);
painter.setPen(Qt::blue);
m_pointSelection.paint(painter, converter, m_handleRadius);
if (m_activeHandle) {
if (m_activeHandle->check(m_pointSelection.selectedShapes())) {
m_activeHandle->paint(painter, converter);
m_activeHandle->paint(painter, converter, m_handleRadius);
} else {
delete m_activeHandle;
m_activeHandle = 0;
......
......@@ -36,6 +36,8 @@
#include "KoPointerEvent.h"
#include "KoShapeController.h"
#include <QPainter>
#include <KisHandlePainterHelper.h>
KoPathToolHandle::KoPathToolHandle(KoPathTool *tool)
: m_tool(tool)
......@@ -58,19 +60,18 @@ PointHandle::PointHandle(KoPathTool *tool, KoPathPoint *activePoint, KoPathPoint
{
}
void PointHandle::paint(QPainter &painter, const KoViewConverter &converter)
void PointHandle::paint(QPainter &painter, const KoViewConverter &converter, qreal handleRadius)
{
painter.save();
painter.setTransform(m_activePoint->parent()->absoluteTransformation(&converter) * painter.transform());
KoShape::applyConversion(painter, converter);
KoPathToolSelection * selection = dynamic_cast<KoPathToolSelection*>(m_tool->selection());
KoPathPoint::PointType type = KoPathPoint::Node;
if (selection && selection->contains(m_activePoint))
if (selection && selection->contains(m_activePoint)) {
type = KoPathPoint::All;
m_activePoint->paint(painter, handleRadius(), type);
painter.restore();
}
KisHandlePainterHelper helper = KoShape::createHandlePainterHelper(&painter, m_activePoint->parent(), converter, handleRadius);
helper.setHandleStyle(KisHandleStyle::highlightedPrimaryHandles());
m_activePoint->paint(helper, type);
}
void PointHandle::repaint() const
......@@ -159,13 +160,11 @@ ParameterHandle::ParameterHandle(KoPathTool *tool, KoParameterShape *parameterSh
{
}
void ParameterHandle::paint(QPainter &painter, const KoViewConverter &converter)
void ParameterHandle::paint(QPainter &painter, const KoViewConverter &converter, qreal handleRadius)
{
painter.save();
painter.setTransform(m_parameterShape->absoluteTransformation(&converter) * painter.transform());
m_parameterShape->paintHandle(painter, converter, m_handleId, handleRadius());
painter.restore();
KisHandlePainterHelper helper = KoShape::createHandlePainterHelper(&painter, m_parameterShape, converter, handleRadius);
helper.setHandleStyle(KisHandleStyle::highlightedPrimaryHandles());
m_parameterShape->paintHandle(helper, m_handleId);
}
void ParameterHandle::repaint() const
......
......@@ -35,13 +35,15 @@ class KoViewConverter;
class KoPointerEvent;
class QPainter;
class KoPathShape;
class KisHandlePainterHelper;
class KoPathToolHandle
{
public:
explicit KoPathToolHandle(KoPathTool *tool);
virtual ~KoPathToolHandle();
virtual void paint(QPainter &painter, const KoViewConverter &converter) = 0;
virtual void paint(QPainter &painter, const KoViewConverter &converter, qreal handleRadius) = 0;
virtual void repaint() const = 0;
virtual KoInteractionStrategy * handleMousePress(KoPointerEvent *event) = 0;
// test if handle is still valid
......@@ -56,7 +58,7 @@ class PointHandle : public KoPathToolHandle
{
public:
PointHandle(KoPathTool *tool, KoPathPoint *activePoint, KoPathPoint::PointType activePointType);
void paint(QPainter &painter, const KoViewConverter &converter);
void paint(QPainter &painter, const KoViewConverter &converter, qreal handleRadius);
void repaint() const;
KoInteractionStrategy *handleMousePress(KoPointerEvent *event);
virtual bool check(const QList<KoPathShape*> &selectedShapes);
......@@ -72,10 +74,10 @@ class ParameterHandle : public KoPathToolHandle
{
public:
ParameterHandle(KoPathTool *tool, KoParameterShape *parameterShape, int handleId);
void paint(QPainter &painter, const KoViewConverter &converter);
void paint(QPainter &painter, const KoViewConverter &converter, qreal handleRadius);
void repaint() const;
KoInteractionStrategy *handleMousePress(KoPointerEvent *event);
virtual bool check(const QList<KoPathShape*> &selectedShapes);
bool check(const QList<KoPathShape*> &selectedShapes);
protected:
KoParameterShape *m_parameterShape;
int m_handleId;
......
......@@ -30,6 +30,7 @@
#include <KoDocumentResourceManager.h>
#include <KoShapeController.h>
#include <QPainter>
#include <KisHandlePainterHelper.h>
KoPathToolSelection::KoPathToolSelection(KoPathTool * tool)
: m_tool(tool)
......@@ -40,21 +41,17 @@ KoPathToolSelection::~KoPathToolSelection()
{
}
void KoPathToolSelection::paint(QPainter &painter, const KoViewConverter &converter)
void KoPathToolSelection::paint(QPainter &painter, const KoViewConverter &converter, qreal handleRadius)
{
int handleRadius = m_tool->canvas()->shapeController()->resourceManager()->handleRadius();
PathShapePointMap::iterator it(m_shapePointMap.begin());
for (; it != m_shapePointMap.end(); ++it) {
painter.save();
painter.setTransform(it.key()->absoluteTransformation(&converter) * painter.transform());
KoShape::applyConversion(painter, converter);
KisHandlePainterHelper helper =
KoShape::createHandlePainterHelper(&painter, it.key(), converter, handleRadius);
helper.setHandleStyle(KisHandleStyle::selectedPrimaryHandles());
Q_FOREACH (KoPathPoint *p, it.value())
p->paint(painter, handleRadius, KoPathPoint::All);
painter.restore();
Q_FOREACH (KoPathPoint *p, it.value()) {
p->paint(helper, KoPathPoint::All);
}
}
}
......
......@@ -48,7 +48,7 @@ public:
~KoPathToolSelection();
/// @brief Draw the selected points
void paint(QPainter &painter, const KoViewConverter &converter);
void paint(QPainter &painter, const KoViewConverter &converter, qreal handleRadius);
/**
* @brief Add a point to the selection
......
......@@ -15,6 +15,7 @@ set(kritaglobal_LIB_SRCS
kis_dom_utils.cpp
kis_painting_tweaks.cpp
KisHandlePainterHelper.cpp
KisHandleStyle.cpp
kis_signal_compressor.cpp
kis_signal_compressor_with_param.cpp
kis_acyclic_signal_connector.cpp
......
......@@ -20,38 +20,111 @@
#include <QPainter>
#include "kis_algebra_2d.h"
#include "kis_painting_tweaks.h"
using KisPaintingTweaks::PenBrushSaver;
KisHandlePainterHelper::KisHandlePainterHelper(QPainter *_painter, qreal handleRadius)
: m_painter(_painter),
m_originalPainterTransform(m_painter->transform()),
m_painterTransform(m_painter->transform()),
m_handleRadius(handleRadius),
m_decomposedMatrix(m_painterTransform)
{
init();
}
KisHandlePainterHelper::KisHandlePainterHelper(QPainter *_painter, const QTransform &originalPainterTransform, qreal handleRadius)
: m_painter(_painter),
m_originalPainterTransform(originalPainterTransform),
m_painterTransform(m_painter->transform()),
m_handleRadius(handleRadius),
m_decomposedMatrix(m_painterTransform)
{
init();
}
KisHandlePainterHelper::KisHandlePainterHelper(KisHandlePainterHelper &&rhs)
: m_painter(rhs.m_painter),
m_originalPainterTransform(rhs.m_originalPainterTransform),
m_painterTransform(rhs.m_painterTransform),
m_handleRadius(rhs.m_handleRadius),
m_decomposedMatrix(rhs.m_decomposedMatrix),
m_handleTransform(rhs.m_handleTransform),
m_handlePolygon(rhs.m_handlePolygon),
m_handleStyle(rhs.m_handleStyle)
{
// disable the source helper
rhs.m_painter = 0;
}
void KisHandlePainterHelper::init()
{
m_handleStyle = KisHandleStyle::inheritStyle();
m_painter->setTransform(QTransform());
m_handleTransform = m_decomposedMatrix.shearTransform() * m_decomposedMatrix.rotateTransform();
if (handleRadius > 0.0) {
const QRectF handleRect(-handleRadius, -handleRadius, 2 * handleRadius, 2 * handleRadius);
if (m_handleRadius > 0.0) {
const QRectF handleRect(-m_handleRadius, -m_handleRadius, 2 * m_handleRadius, 2 * m_handleRadius);
m_handlePolygon = m_handleTransform.map(QPolygonF(handleRect));
}
}
KisHandlePainterHelper::~KisHandlePainterHelper() {
m_painter->setTransform(m_painterTransform);
if (m_painter) {
m_painter->setTransform(m_originalPainterTransform);
}
}
void KisHandlePainterHelper::setHandleStyle(const KisHandleStyle &style)
{
m_handleStyle = style;
}
void KisHandlePainterHelper::drawHandleRect(const QPointF &center, qreal radius) {
KIS_SAFE_ASSERT_RECOVER_RETURN(m_painter);
QRectF handleRect(-radius, -radius, 2 * radius, 2 * radius);
QPolygonF handlePolygon = m_handleTransform.map(QPolygonF(handleRect));
handlePolygon.translate(m_painterTransform.map(center));
m_painter->drawPolygon(handlePolygon);
Q_FOREACH (KisHandleStyle::IterationStyle it, m_handleStyle.handleIterations) {
PenBrushSaver saver(it.isValid ? m_painter : 0, it.stylePair, PenBrushSaver::allow_noop);
m_painter->drawPolygon(handlePolygon);
}
}
void KisHandlePainterHelper::drawHandleCircle(const QPointF &center, qreal radius) {
KIS_SAFE_ASSERT_RECOVER_RETURN(m_painter);
QRectF handleRect(-radius, -radius, 2 * radius, 2 * radius);
handleRect.translate(m_painterTransform.map(center));
Q_FOREACH (KisHandleStyle::IterationStyle it, m_handleStyle.handleIterations) {
PenBrushSaver saver(it.isValid ? m_painter : 0, it.stylePair, PenBrushSaver::allow_noop);
m_painter->drawEllipse(handleRect);
}
}
void KisHandlePainterHelper::drawHandleCircle(const QPointF &center)
{
drawHandleCircle(center, m_handleRadius);
}
void KisHandlePainterHelper::drawHandleRect(const QPointF &center) {
m_painter->drawPolygon(m_handlePolygon.translated(m_painterTransform.map(center)));
KIS_SAFE_ASSERT_RECOVER_RETURN(m_painter);
QPolygonF paintingPolygon = m_handlePolygon.translated(m_painterTransform.map(center));
Q_FOREACH (KisHandleStyle::IterationStyle it, m_handleStyle.handleIterations) {
PenBrushSaver saver(it.isValid ? m_painter : 0, it.stylePair, PenBrushSaver::allow_noop);
m_painter->drawPolygon(paintingPolygon);
}
}
void KisHandlePainterHelper::drawGradientHandle(const QPointF &center, qreal radius) {
KIS_SAFE_ASSERT_RECOVER_RETURN(m_painter);
QPolygonF handlePolygon;
handlePolygon << QPointF(-radius, 0);
......@@ -60,10 +133,21 @@ void KisHandlePainterHelper::drawGradientHandle(const QPointF &center, qreal rad
handlePolygon << QPointF(0, -radius);
handlePolygon = m_handleTransform.map(handlePolygon);
m_painter->drawPolygon(handlePolygon.translated(m_painterTransform.map(center)));
handlePolygon.translate(m_painterTransform.map(center));
Q_FOREACH (KisHandleStyle::IterationStyle it, m_handleStyle.handleIterations) {
PenBrushSaver saver(it.isValid ? m_painter : 0, it.stylePair, PenBrushSaver::allow_noop);
m_painter->drawPolygon(handlePolygon);
}
}
void KisHandlePainterHelper::drawGradientHandle(const QPointF &center)