21#include <QApplication>
26#include <klocalizedstring.h>
88 dynamic_cast<
KisCanvas2*>(canvas)->coordinatesConverter(),
89 dynamic_cast<
KisCanvas2*>(canvas)->snapGuide(),
90 m_currentArgs, m_transaction))
93 dynamic_cast<
KisCanvas2*>(canvas)->coordinatesConverter(),
94 dynamic_cast<
KisCanvas2*>(canvas)->snapGuide(),
95 m_currentArgs, m_transaction))
98 dynamic_cast<
KisCanvas2*>(canvas)->coordinatesConverter(),
99 m_currentArgs, m_transaction, canvas->resourceManager()))
102 dynamic_cast<
KisCanvas2*>(canvas)->coordinatesConverter(),
103 dynamic_cast<
KisCanvas2*>(canvas)->snapGuide(),
104 m_currentArgs, m_transaction))
107 dynamic_cast<
KisCanvas2*>(canvas)->coordinatesConverter(),
108 dynamic_cast<
KisCanvas2*>(canvas)->snapGuide(),
109 m_currentArgs, m_transaction))
110 , m_perspectiveStrategy(
112 dynamic_cast<
KisCanvas2*>(canvas)->coordinatesConverter(),
113 dynamic_cast<
KisCanvas2*>(canvas)->snapGuide(),
114 m_currentArgs, m_transaction))
119 setObjectName(
"tool_transform");
206 KConfigGroup group = KSharedConfig::openConfig()->group(
toolId());
248 QPolygonF hullF = hull;
260 warnTools <<
"WARNING: KisToolTransform: calculated convex hull's bounds "
261 "differ from the bounding rect of the source clip. It shouldn't "
299 QPainterPath mappedOutline =
324 QRect canvasUpdateRect;
327 canvasUpdateRect =
m_canvas->coordinatesConverter()->
332 getCursorOutline().translated(imagePos);
340 if (!canvasUpdateRect.isEmpty()) {
342 canvasUpdateRect =
kisGrowRect(canvasUpdateRect, 2);
343 m_canvas->updateCanvas(canvasUpdateRect);
359 if (usePrimaryAction) {
382 if (usePrimaryAction) {
403 if (usePrimaryAction) {
522 QPointF mousePos =
m_canvas->coordinatesConverter()->documentToImage(event->
point);
764 QTransform thumbToImageTransform;
766 const int maxSize = 2000;
770 srcRect.getRect(&x, &y, &w, &h);
773 if (w > maxSize || h > maxSize) {
774 qreal scale = qreal(maxSize) / (w > h ? w : h);
775 QTransform scaleTransform = QTransform::fromScale(scale, scale);
780 createThumbnail(thumbRect.width(),
785 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;
935 i18nc(
"floating message in transformation tool",
936 "Layer type cannot use the transform tool"),
942 i18nc(
"floating message in transformation tool",
943 "Layer type cannot use the transform tool. Use transform mask instead."),
955 return node->inherits(
"KisTransformMask") && node->
visible(
true);
958 if (impossibleMask) {
962 i18nc(
"floating message in transformation tool",
963 "Layer has children with transform masks. Please disable them before doing transformation."),
976 i18nc(
"floating message in transformation tool",
977 "Selections are not used when editing transform masks "),
992 connect(transformStrategy, SIGNAL(sigConvexHullCalculated(QPolygon,
void*)), SLOT(
slotConvexHullCalculated(QPolygon,
void*)));
993 strategy = transformStrategy;
1004 connect(transformStrategy, SIGNAL(sigConvexHullCalculated(QPolygon,
void*)), SLOT(
slotConvexHullCalculated(QPolygon,
void*)));
1005 strategy = transformStrategy;
1060 showFloatingMessage(
1061 i18nc(
"floating message in transformation tool",
1062 "Cannot transform empty layer "),
1086 showFloatingMessage(
1087 i18nc(
"floating message in transformation tool",
1088 "Invisible sublayers will also be transformed. Lock layers if you do not want them to be transformed "),
1099 showFloatingMessage(
1100 i18nc(
"floating message in transformation tool",
1101 "Cannot transform empty layer "),
1155 specialSpacer->setObjectName(
"SpecialSpacer");
1156 specialSpacer->setFixedSize(0, 0);
1234 if (needsPreviewRecalculation) {
1278 if (transformDiffers &&
1459 actions << actionRegistry->
makeQAction(
"movetool-move-up",
this);
1460 actions << actionRegistry->
makeQAction(
"movetool-move-down",
this);
1461 actions << actionRegistry->
makeQAction(
"movetool-move-left",
this);
1462 actions << actionRegistry->
makeQAction(
"movetool-move-right",
this);
1463 actions << actionRegistry->
makeQAction(
"movetool-move-up-more",
this);
1464 actions << actionRegistry->
makeQAction(
"movetool-move-down-more",
this);
1465 actions << actionRegistry->
makeQAction(
"movetool-move-left-more",
this);
1466 actions << actionRegistry->
makeQAction(
"movetool-move-right-more",
this);
1468 auto makeSubtoolAction = [&actionRegistry, &actions,
this](QString actionName,
const char *slot) {
1469 QAction *action = actionRegistry->
makeQAction(actionName,
this);
1470 action->setProperty(
"always_enabled",
true);
1471 connect(action, SIGNAL(triggered()), slot);
1489 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
QImage convertToQImage(const KoColorProfile *dstProfile, qint32 x, qint32 y, qint32 w, qint32 h, KoColorConversionTransformation::Intent renderingIntent=KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::ConversionFlags conversionFlags=KoColorConversionTransformation::internalConversionFlags()) 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