Krita Source Code Documentation
Loading...
Searching...
No Matches
KoPathControlPointMoveStrategy.cpp
Go to the documentation of this file.
1/* This file is part of the KDE project
2 * SPDX-FileCopyrightText: 2006 Jan Hambrecht <jaham@gmx.net>
3 * SPDX-FileCopyrightText: 2006, 2007 Thorsten Zachmann <zachmann@kde.org>
4 *
5 * SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7
9#include "KoCanvasBase.h"
10#include "KoSnapGuide.h"
11
12#include "KoPathTool.h"
14#include "kis_command_utils.h"
15
18 , m_lastPosition(pos)
19 , m_move(0, 0)
20 , m_tool(tool)
21 , m_pointData(pointData)
22 , m_pointType(type)
23{
25}
26
30
31void KoPathControlPointMoveStrategy::handleMouseMove(const QPointF &mouseLocation, Qt::KeyboardModifiers modifiers)
32{
33 QPointF docPoint = m_tool->canvas()->snapGuide()->snap(mouseLocation, modifiers);
34 QPointF localPos = m_path->documentToShape(docPoint);
35 QPointF move = localPos - m_path->documentToShape(m_lastPosition);
36 // as the last position can change when the top left is changed we have
37 // to save it in document pos and not in shape pos
38 m_lastPosition = docPoint;
39
40 m_move += move;
41
45}
46
47void KoPathControlPointMoveStrategy::finishInteraction(Qt::KeyboardModifiers modifiers)
48{
49 Q_UNUSED(modifiers);
50}
51
KoSnapGuide * snapGuide
The undo / redo command for path point moving.
KoPathControlPointMoveStrategy(KoPathTool *tool, const KoPathPointData &point, KoPathPoint::PointType type, const QPointF &pos)
void finishInteraction(Qt::KeyboardModifiers modifiers) override
void handleMouseMove(const QPointF &mouseLocation, Qt::KeyboardModifiers modifiers) override
QScopedPointer< KUndo2Command > m_intermediateCommand
QPointF m_lastPosition
the last mouse position
QPointF m_move
the accumulated point move amount
Describe a KoPathPoint by a KoPathShape and its indices.
KoPathShape * pathShape
path shape the path point belongs too
PointType
the type for identifying part of a KoPathPoint
Definition KoPathPoint.h:47
QPointF documentToShape(const QPointF &point) const
Transforms point from document coordinates to shape coordinates.
Definition KoShape.cpp:1211
QPointF snap(const QPointF &mousePosition, Qt::KeyboardModifiers modifiers)
snaps the mouse position, returns if mouse was snapped
KoCanvasBase * canvas() const
Returns the canvas the tool is working on.
void redoAndMergeIntoAccumulatingCommand(KUndo2Command *cmd, QScopedPointer< KUndo2Command > &accumulatingCommand)