Krita Source Code Documentation
Loading...
Searching...
No Matches
shearimage.cc
Go to the documentation of this file.
1/*
2 * shearimage.cc -- Part of Krita
3 *
4 * SPDX-FileCopyrightText: 2004 Michael Thaler <michael.thaler@physik.tu-muenchen.de>
5 *
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
8
9#include "shearimage.h"
10
11#include <klocalizedstring.h>
12#include <kpluginfactory.h>
13
14#include <kis_image.h>
15#include <KisViewManager.h>
16#include <kis_node_manager.h>
17#include <kis_image_manager.h>
18#include <kis_action.h>
19#include "kis_selection.h"
20
21#include "dlg_shearimage.h"
22
23K_PLUGIN_FACTORY_WITH_JSON(ShearImageFactory, "kritashearimage.json", registerPlugin<ShearImage>();)
24
25ShearImage::ShearImage(QObject *parent, const QVariantList &)
26 : KisActionPlugin(parent)
27{
28 KisAction *action = createAction("shearimage");
29 connect(action, SIGNAL(triggered()), this, SLOT(slotShearImage()));
30
31 action = createAction("shearlayer");
32 connect(action, SIGNAL(triggered()), this, SLOT(slotShearLayer()));
33
34 action = createAction("shearAllLayers");
35 connect(action, SIGNAL(triggered()), this, SLOT(slotShearAllLayers()));
36}
37
41
43{
44 KisImageWSP image = viewManager()->image();
45 if (!image) return;
46
47 if (!viewManager()->blockUntilOperationsFinished(image)) return;
48
49 DlgShearImage * dlgShearImage = new DlgShearImage(viewManager()->mainWindowAsQWidget(), "ShearImage");
50 Q_CHECK_PTR(dlgShearImage);
51
52 dlgShearImage->setCaption(i18n("Shear Image"));
53
54 if (dlgShearImage->exec() == QDialog::Accepted) {
55 qint32 angleX = dlgShearImage->angleX();
56 qint32 angleY = dlgShearImage->angleY();
57 viewManager()->imageManager()->shearCurrentImage(angleX, angleY);
58 }
59 delete dlgShearImage;
60}
61
67{
68 KisImageWSP image = viewManager()->image();
69 if (!image) return;
70
71 if (!viewManager()->blockUntilOperationsFinished(image)) return;
72
73 DlgShearImage * dlgShearImage = new DlgShearImage(viewManager()->mainWindowAsQWidget(), "ShearLayer");
74 Q_CHECK_PTR(dlgShearImage);
75
76 dlgShearImage->setCaption(i18np("Shear Layer", "Shear %1 Layers", nodes.size()));
77
78 if (dlgShearImage->exec() == QDialog::Accepted) {
79 qint32 angleX = dlgShearImage->angleX();
80 qint32 angleY = dlgShearImage->angleY();
81
82 image->shearNodes(nodes,
83 angleX, angleY,
84 viewManager()->selection());
85 }
86 delete dlgShearImage;
87}
88
90{
91 shearLayersImpl(viewManager()->nodeManager()->selectedNodes());
92}
93
95{
96 KisImageWSP image = viewManager()->image();
97 if (!image) return;
98
99 shearLayerImpl(image->root());
100}
101
102#include "shearimage.moc"
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
QPointer< KisViewManager > viewManager() const
void shearNodes(KisNodeList nodes, double angleX, double angleY, KisSelectionSP selection)
virtual void setCaption(const QString &caption)
Definition KoDialog.cpp:498
void shearLayerImpl(KisNodeSP rootNode)
Definition shearimage.cc:62
void shearLayersImpl(KisNodeList nodes)
Definition shearimage.cc:66
void slotShearAllLayers()
Definition shearimage.cc:94
ShearImage(QObject *parent, const QVariantList &)
Definition shearimage.cc:25
~ShearImage() override
Definition shearimage.cc:38
void slotShearLayer()
Definition shearimage.cc:89
void slotShearImage()
Definition shearimage.cc:42
K_PLUGIN_FACTORY_WITH_JSON(KritaASCCDLFactory, "kritaasccdl.json", registerPlugin< KritaASCCDL >();) KritaASCCDL