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) {
404 if (usePrimaryAction) {
523 QPointF mousePos =
m_canvas->coordinatesConverter()->documentToImage(event->
point);
765 QTransform thumbToImageTransform;
767 const int maxSize = 2000;
771 srcRect.getRect(&x, &y, &w, &h);
774 if (w > maxSize || h > maxSize) {
775 qreal scale = qreal(maxSize) / (w > h ? w : h);
776 QTransform scaleTransform = QTransform::fromScale(scale, scale);
780 QSize size = thumbRect.size();
781 if (size.width() < 1) size.setWidth(1);
782 if (size.height() < 1) size.setHeight(1);
784 origImg =
m_canvas->displayColorConverter()->convertImageToDisplayColorSpace(dev, QRect(QPoint(0, 0), size),
true);
786 thumbToImageTransform = scaleTransform.inverted();
790 thumbToImageTransform = QTransform();
796 m_freeStrategy->setThumbnailImage(origImg, thumbToImageTransform);
798 m_warpStrategy->setThumbnailImage(origImg, thumbToImageTransform);
799 m_cageStrategy->setThumbnailImage(origImg, thumbToImageTransform);
801 m_meshStrategy->setThumbnailImage(origImg, thumbToImageTransform);
808 QSet<KoShape*> dummy;
936 i18nc(
"floating message in transformation tool",
937 "Cannot transform locked layers"),
942 i18nc(
"floating message in transformation tool",
943 "Cannot transform hidden layers"),
948 i18nc(
"floating message in transformation tool",
949 "Cannot use transform tool on this set of layers"),
964 i18nc(
"floating message in transformation tool",
965 "Layer type cannot use the transform tool"),
971 i18nc(
"floating message in transformation tool",
972 "Layer type cannot use the transform tool. Use transform mask instead."),
984 return node->inherits(
"KisTransformMask") && node->
visible(
true);
987 if (impossibleMask) {
990 i18nc(
"floating message in transformation tool",
991 "Layer has children with transform masks. Please disable them before doing transformation."),
1002 showFloatingMessage(
1003 i18nc(
"floating message in transformation tool",
1004 "Selections are not used when editing transform masks "),
1019 connect(transformStrategy, SIGNAL(sigConvexHullCalculated(QPolygon,
void*)), SLOT(
slotConvexHullCalculated(QPolygon,
void*)));
1020 strategy = transformStrategy;
1031 connect(transformStrategy, SIGNAL(sigConvexHullCalculated(QPolygon,
void*)), SLOT(
slotConvexHullCalculated(QPolygon,
void*)));
1032 strategy = transformStrategy;
1087 showFloatingMessage(
1088 i18nc(
"floating message in transformation tool",
1089 "Cannot transform empty layer "),
1113 showFloatingMessage(
1114 i18nc(
"floating message in transformation tool",
1115 "Invisible sublayers will also be transformed. Lock layers if you do not want them to be transformed "),
1126 showFloatingMessage(
1127 i18nc(
"floating message in transformation tool",
1128 "Cannot transform empty layer "),
1182 specialSpacer->setObjectName(
"SpecialSpacer");
1183 specialSpacer->setFixedSize(0, 0);
1261 if (needsPreviewRecalculation) {
1305 if (transformDiffers &&
1496 actions << actionRegistry->
makeQAction(
"movetool-move-up",
this);
1497 actions << actionRegistry->
makeQAction(
"movetool-move-down",
this);
1498 actions << actionRegistry->
makeQAction(
"movetool-move-left",
this);
1499 actions << actionRegistry->
makeQAction(
"movetool-move-right",
this);
1500 actions << actionRegistry->
makeQAction(
"movetool-move-up-more",
this);
1501 actions << actionRegistry->
makeQAction(
"movetool-move-down-more",
this);
1502 actions << actionRegistry->
makeQAction(
"movetool-move-left-more",
this);
1503 actions << actionRegistry->
makeQAction(
"movetool-move-right-more",
this);
1505 auto makeSubtoolAction = [&actionRegistry, &actions,
this](QString actionName,
const char *slot) {
1506 QAction *action = actionRegistry->
makeQAction(actionName,
this);
1507 action->setProperty(
"always_enabled",
true);
1508 connect(action, SIGNAL(triggered()), slot);
1526 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