21#include <QApplication>
26#include <klocalizedstring.h>
89 dynamic_cast<
KisCanvas2*>(canvas)->coordinatesConverter(),
90 dynamic_cast<
KisCanvas2*>(canvas)->snapGuide(),
91 m_currentArgs, m_transaction))
94 dynamic_cast<
KisCanvas2*>(canvas)->coordinatesConverter(),
95 dynamic_cast<
KisCanvas2*>(canvas)->snapGuide(),
96 m_currentArgs, m_transaction))
99 dynamic_cast<
KisCanvas2*>(canvas)->coordinatesConverter(),
100 m_currentArgs, m_transaction, canvas->resourceManager()))
103 dynamic_cast<
KisCanvas2*>(canvas)->coordinatesConverter(),
104 dynamic_cast<
KisCanvas2*>(canvas)->snapGuide(),
105 m_currentArgs, m_transaction))
108 dynamic_cast<
KisCanvas2*>(canvas)->coordinatesConverter(),
109 dynamic_cast<
KisCanvas2*>(canvas)->snapGuide(),
110 m_currentArgs, m_transaction))
111 , m_perspectiveStrategy(
113 dynamic_cast<
KisCanvas2*>(canvas)->coordinatesConverter(),
114 dynamic_cast<
KisCanvas2*>(canvas)->snapGuide(),
115 m_currentArgs, m_transaction))
120 setObjectName(
"tool_transform");
207 KConfigGroup group = KSharedConfig::openConfig()->group(
toolId());
249 QPolygonF hullF = hull;
261 warnTools <<
"WARNING: KisToolTransform: calculated convex hull's bounds "
262 "differ from the bounding rect of the source clip. It shouldn't "
300 QPainterPath mappedOutline =
325 QRect canvasUpdateRect;
328 canvasUpdateRect =
m_canvas->coordinatesConverter()->
333 getCursorOutline().translated(imagePos);
341 if (!canvasUpdateRect.isEmpty()) {
343 canvasUpdateRect =
kisGrowRect(canvasUpdateRect, 2);
344 m_canvas->updateCanvas(canvasUpdateRect);
360 if (usePrimaryAction) {
383 if (usePrimaryAction) {
405 if (usePrimaryAction) {
524 QPointF mousePos =
m_canvas->coordinatesConverter()->documentToImage(event->
point);
766 QTransform thumbToImageTransform;
768 const int maxSize = 2000;
772 srcRect.getRect(&x, &y, &w, &h);
775 if (w > maxSize || h > maxSize) {
776 qreal scale = qreal(maxSize) / (w > h ? w : h);
777 QTransform scaleTransform = QTransform::fromScale(scale, scale);
781 QSize size = thumbRect.size();
782 if (size.width() < 1) size.setWidth(1);
783 if (size.height() < 1) size.setHeight(1);
785 origImg =
m_canvas->displayColorConverter()->convertImageToDisplayColorSpace(dev, QRect(QPoint(0, 0), size),
true);
787 thumbToImageTransform = scaleTransform.inverted();
791 thumbToImageTransform = QTransform();
797 m_freeStrategy->setThumbnailImage(origImg, thumbToImageTransform);
799 m_warpStrategy->setThumbnailImage(origImg, thumbToImageTransform);
800 m_cageStrategy->setThumbnailImage(origImg, thumbToImageTransform);
802 m_meshStrategy->setThumbnailImage(origImg, thumbToImageTransform);
809 QSet<KoShape*> dummy;
937 i18nc(
"floating message in transformation tool",
938 "Cannot transform locked layers"),
943 i18nc(
"floating message in transformation tool",
944 "Cannot transform hidden layers"),
949 i18nc(
"floating message in transformation tool",
950 "Cannot use transform tool on this set of layers"),
965 i18nc(
"floating message in transformation tool",
966 "Layer type cannot use the transform tool"),
972 i18nc(
"floating message in transformation tool",
973 "Layer type cannot use the transform tool. Use transform mask instead."),
985 return node->inherits(
"KisTransformMask") && node->
visible(
true);
988 if (impossibleMask) {
991 i18nc(
"floating message in transformation tool",
992 "Layer has children with transform masks. Please disable them before doing transformation."),
1003 showFloatingMessage(
1004 i18nc(
"floating message in transformation tool",
1005 "Selections are not used when editing transform masks "),
1020 connect(transformStrategy, SIGNAL(sigConvexHullCalculated(QPolygon,
void*)), SLOT(
slotConvexHullCalculated(QPolygon,
void*)));
1021 strategy = transformStrategy;
1032 connect(transformStrategy, SIGNAL(sigConvexHullCalculated(QPolygon,
void*)), SLOT(
slotConvexHullCalculated(QPolygon,
void*)));
1033 strategy = transformStrategy;
1088 showFloatingMessage(
1089 i18nc(
"floating message in transformation tool",
1090 "Cannot transform empty layer "),
1114 showFloatingMessage(
1115 i18nc(
"floating message in transformation tool",
1116 "Invisible sublayers will also be transformed. Lock layers if you do not want them to be transformed "),
1127 showFloatingMessage(
1128 i18nc(
"floating message in transformation tool",
1129 "Cannot transform empty layer "),
1183 specialSpacer->setObjectName(
"SpecialSpacer");
1184 specialSpacer->setFixedSize(0, 0);
1262 if (needsPreviewRecalculation) {
1306 if (transformDiffers &&
1497 actions << actionRegistry->
makeQAction(
"movetool-move-up",
this);
1498 actions << actionRegistry->
makeQAction(
"movetool-move-down",
this);
1499 actions << actionRegistry->
makeQAction(
"movetool-move-left",
this);
1500 actions << actionRegistry->
makeQAction(
"movetool-move-right",
this);
1501 actions << actionRegistry->
makeQAction(
"movetool-move-up-more",
this);
1502 actions << actionRegistry->
makeQAction(
"movetool-move-down-more",
this);
1503 actions << actionRegistry->
makeQAction(
"movetool-move-left-more",
this);
1504 actions << actionRegistry->
makeQAction(
"movetool-move-right-more",
this);
1506 auto makeSubtoolAction = [&actionRegistry, &actions,
this](QString actionName,
const char *slot) {
1507 QAction *action = actionRegistry->
makeQAction(actionName,
this);
1508 action->setProperty(
"always_enabled",
true);
1509 connect(action, SIGNAL(triggered()), slot);
1527 if (!canvasController)
return;
float value(const T *src, size_t ch)
QAction * makeQAction(const QString &name, QObject *parent=0)
static KisActionRegistry * instance()
void startUpdateStreamLowLevel()
void initUpdateStreamLowLevel(KisStrokesFacade *strokesFacade, KisStrokeId strokeId)
void cancelUpdateStream()
KisViewManager * viewManager() const
static KisConfigNotifier * instance()
static QCursor waitCursor()
static QCursor pointingHandCursor()
bool cancelStroke(KisStrokeId id) override
void addJob(KisStrokeId id, KisStrokeJobData *data) override
KisStrokeId startStroke(KisStrokeStrategy *strokeStrategy) override
void endStroke(KisStrokeId id) override
QRect exactBounds() const
KisPaintDeviceSP createThumbnailDeviceOversampled(qint32 w, qint32 h, qreal oversample, QRect rect=QRect(), QRect outputRect=QRect()) const
The KisResourcesSnapshot class takes a snapshot of the various resources like colors and settings use...
KisNodeList selectedNodes() const
KisSelectionSP activeSelection() const
void addConnection(Sender sender, Signal signal, Receiver receiver, Method method, Qt::ConnectionType type=Qt::AutoConnection)
virtual KoCanvasBase * canvas() const
bool isTouchEvent() const
QPointF point
The point in document coordinates.
#define KIS_SAFE_ASSERT_RECOVER(cond)
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
#define KIS_ASSERT_RECOVER_RETURN(cond)
#define KIS_ASSERT_RECOVER_NOOP(cond)
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
T kisGrowRect(const T &rect, U offset)
#define koIcon(name)
Use these macros for icons without any issues.
QSharedPointer< T > toQShared(T *ptr)
QList< KisNodeSP > KisNodeList
KisNodeSP recursiveFindNode(KisNodeSP node, std::function< bool(KisNodeSP)> func)
void filterMergeableNodes(KisNodeList &nodes, bool allowMasks)
bool isEditable(bool checkVisibility=true) const
virtual bool visible(bool recursive=false) const