Krita Source Code Documentation
Loading...
Searching...
No Matches
CutThroughShapeStrategy.cpp File Reference
#include "CutThroughShapeStrategy.h"
#include <QDebug>
#include <QPainter>
#include <kis_algebra_2d.h>
#include <KoToolBase.h>
#include <KoCanvasBase.h>
#include <KoViewConverter.h>
#include <KoSelection.h>
#include <kis_global.h>
#include "kis_debug.h"
#include <KoPathShape.h>
#include <krita_utils.h>
#include <kis_canvas2.h>
#include <QPainterPath>
#include <KoShapeController.h>
#include <kundo2command.h>
#include <KoKeepShapesSelectedCommand.h>
#include <QtMath>

Go to the source code of this file.

Functions

QPointF snapEndPoint (const QPointF &startPoint, const QPointF &mouseLocation, Qt::KeyboardModifiers modifiers)
 

Function Documentation

◆ snapEndPoint()

QPointF snapEndPoint ( const QPointF & startPoint,
const QPointF & mouseLocation,
Qt::KeyboardModifiers modifiers )

Definition at line 50 of file CutThroughShapeStrategy.cpp.

50 {
51
52 QPointF nicePoint = snapToClosestNiceAngle(mouseLocation, startPoint); // by default the function gives you 15 degrees increments
53
54 if (modifiers & Qt::KeyboardModifier::ShiftModifier) {
55 return nicePoint;
56 if (qAbs(mouseLocation.x() - startPoint.x()) >= qAbs(mouseLocation.y() - startPoint.y())) {
57 // do horizontal line
58 return QPointF(mouseLocation.x(), startPoint.y());
59 } else {
60 return QPointF(startPoint.x(), mouseLocation.y());
61 }
62 }
63 QLineF line = QLineF(startPoint, mouseLocation);
64 qreal angle = line.angleTo(QLineF(startPoint, nicePoint));
65 qreal eps = kisDegreesToRadians(2.0f);
66 if (angle < eps) {
67 return nicePoint;
68 }
69 return mouseLocation;
70}
const qreal eps
PointType snapToClosestNiceAngle(PointType point, PointType startPoint, qreal angle=(2 *M_PI)/24)
Definition kis_global.h:209
T kisDegreesToRadians(T degrees)
Definition kis_global.h:176

References eps, kisDegreesToRadians(), and snapToClosestNiceAngle().