Krita Source Code Documentation
Loading...
Searching...
No Matches
DlgClonesArray Class Reference

#include <dlg_clonesarray.h>

+ Inheritance diagram for DlgClonesArray:

Public Member Functions

 DlgClonesArray (KisViewManager *viewManager, QWidget *parent=0)
 
 ~DlgClonesArray () override
 
- Public Member Functions inherited from KoDialog
QPushButton * button (ButtonCode id) const
 
QIcon buttonIcon (ButtonCode id) const
 
QString buttonText (ButtonCode id) const
 
QString buttonToolTip (ButtonCode id) const
 
QString buttonWhatsThis (ButtonCode id) const
 
ButtonCode defaultButton () const
 
QString helpLinkText () const
 
void incrementInitialSize (const QSize &size)
 
bool isButtonEnabled (ButtonCode id) const
 
 KoDialog (QWidget *parent=0, Qt::WindowFlags f=Qt::WindowFlags())
 
QWidget * mainWidget ()
 
QSize minimumSizeHint () const override
 
void setButtonFocus (ButtonCode id)
 
void setButtonGuiItem (ButtonCode id, const KGuiItem &item)
 
void setButtonIcon (ButtonCode id, const QIcon &icon)
 
void setButtons (ButtonCodes buttonMask)
 
void setButtonsOrientation (Qt::Orientation orientation)
 
void setButtonText (ButtonCode id, const QString &text)
 
void setButtonToolTip (ButtonCode id, const QString &text)
 
void setButtonWhatsThis (ButtonCode id, const QString &text)
 
void setDefaultButton (ButtonCode id)
 
void setEscapeButton (ButtonCode id)
 
void setInitialSize (const QSize &size)
 
void setMainWidget (QWidget *widget)
 
void showButton (ButtonCode id, bool state)
 
void showButtonSeparator (bool state)
 
QSize sizeHint () const override
 
 ~KoDialog () override
 

Private Slots

void applyClicked ()
 
void cancelClicked ()
 
void okClicked ()
 
void setDirty ()
 
void syncAngularToOrthogonal ()
 
void syncOrthogonalToAngular ()
 
void updateCheckboxAvailability ()
 

Private Member Functions

void initializeValues ()
 
void reapplyClones ()
 
void setAngularSignalsEnabled (bool value)
 
void setClean ()
 
void setOrthogonalSignalsEnabled (bool value)
 

Private Attributes

KisProcessingApplicatorm_applicator
 
KisLayerSP m_baseLayer
 
bool m_isDirty {false}
 
WdgClonesArraym_page
 
QPointer< KisViewManagerm_viewManager
 

Additional Inherited Members

- Public Types inherited from KoDialog
enum  ButtonCode {
  None = 0x00000000 , Help = 0x00000001 , Default = 0x00000002 , Ok = 0x00000004 ,
  Apply = 0x00000008 , Try = 0x00000010 , Cancel = 0x00000020 , Close = 0x00000040 ,
  No = 0x00000080 , Yes = 0x00000100 , Reset = 0x00000200 , Details = 0x00000400 ,
  User1 = 0x00001000 , User2 = 0x00002000 , User3 = 0x00004000 , NoDefault = 0x00008000
}
 
enum  ButtonPopupMode { InstantPopup = 0 , DelayedPopup = 1 }
 
enum  CaptionFlag { NoCaptionFlags = 0 , AppNameCaption = 1 , ModifiedCaption = 2 , HIGCompliantCaption = AppNameCaption }
 
- Public Slots inherited from KoDialog
void delayedDestruct ()
 
void enableButton (ButtonCode id, bool state)
 
void enableButtonApply (bool state)
 
void enableButtonCancel (bool state)
 
void enableButtonOk (bool state)
 
void enableLinkedHelp (bool state)
 
bool isDetailsWidgetVisible () const
 
virtual void setCaption (const QString &caption)
 
virtual void setCaption (const QString &caption, bool modified)
 
void setDetailsWidget (QWidget *detailsWidget)
 
void setDetailsWidgetVisible (bool visible)
 
void setHelp (const QString &anchor, const QString &appname=QString())
 
void setHelpLinkText (const QString &text)
 
virtual void setPlainCaption (const QString &caption)
 
- Signals inherited from KoDialog
void aboutToShowDetails ()
 
void applyClicked ()
 
void buttonClicked (KoDialog::ButtonCode button)
 
void cancelClicked ()
 
void closeClicked ()
 
void defaultClicked ()
 
void finished ()
 
void helpClicked ()
 
void hidden ()
 
void layoutHintChanged ()
 
void noClicked ()
 
void okClicked ()
 
void resetClicked ()
 
void tryClicked ()
 
void user1Clicked ()
 
void user2Clicked ()
 
void user3Clicked ()
 
void yesClicked ()
 
- Static Public Member Functions inherited from KoDialog
static int groupSpacingHint ()
 
static QString makeStandardCaption (const QString &userCaption, QWidget *window=0, CaptionFlags flags=HIGCompliantCaption)
 
static int marginHint ()
 
static void resizeLayout (QLayout *lay, int margin, int spacing)
 
static void resizeLayout (QWidget *widget, int margin, int spacing)
 
static int spacingHint ()
 
- Protected Slots inherited from KoDialog
virtual void slotButtonClicked (int button)
 
- Protected Member Functions inherited from KoDialog
void closeEvent (QCloseEvent *e) override
 
void hideEvent (QHideEvent *) override
 
void keyPressEvent (QKeyEvent *) override
 
void showEvent (QShowEvent *e) override
 

Detailed Description

Definition at line 31 of file dlg_clonesarray.h.

Constructor & Destructor Documentation

◆ DlgClonesArray()

DlgClonesArray::DlgClonesArray ( KisViewManager * viewManager,
QWidget * parent = 0 )

Definition at line 23 of file dlg_clonesarray.cpp.

24 : KoDialog(parent)
25 , m_viewManager(viewManager)
26 , m_applicator(0)
27 , m_baseLayer(m_viewManager->activeLayer())
28{
29 Q_ASSERT(m_baseLayer);
30
31 setCaption(i18n("Create Clones Array"));
34 setObjectName("clones_array_dialog");
35
36 m_page = new WdgClonesArray(this);
37 Q_CHECK_PTR(m_page);
38 m_page->setObjectName("clones_array");
39
40 m_page->columnAngle->setRange(-360, 360);
41 m_page->columnAngle->setFlipOptionsMode(KisAngleSelector::FlipOptionsMode_NoFlipOptions);
42 m_page->rowAngle->setRange(-360, 360);
43 m_page->rowAngle->setFlipOptionsMode(KisAngleSelector::FlipOptionsMode_NoFlipOptions);
44
46 resize(m_page->sizeHint());
47
48 connect(this, SIGNAL(okClicked()), SLOT(okClicked()));
49 connect(this, SIGNAL(applyClicked()), SLOT(applyClicked()));
50 connect(this, SIGNAL(cancelClicked()), SLOT(cancelClicked()));
51
52 connect(m_page->columnXOffset, SIGNAL(valueChanged(int)), SLOT(syncOrthogonalToAngular()));
53 connect(m_page->columnYOffset, SIGNAL(valueChanged(int)), SLOT(syncOrthogonalToAngular()));
54 connect(m_page->rowXOffset, SIGNAL(valueChanged(int)), SLOT(syncOrthogonalToAngular()));
55 connect(m_page->rowYOffset, SIGNAL(valueChanged(int)), SLOT(syncOrthogonalToAngular()));
56
57 connect(m_page->columnDistance, SIGNAL(valueChanged(double)), SLOT(syncAngularToOrthogonal()));
58 connect(m_page->columnAngle, SIGNAL(angleChanged(qreal)), SLOT(syncAngularToOrthogonal()));
59 connect(m_page->rowDistance, SIGNAL(valueChanged(double)), SLOT(syncAngularToOrthogonal()));
60 connect(m_page->rowAngle, SIGNAL(angleChanged(qreal)), SLOT(syncAngularToOrthogonal()));
61
62 connect(m_page->numNegativeColumns, SIGNAL(valueChanged(int)), SLOT(setDirty()));
63 connect(m_page->numPositiveColumns, SIGNAL(valueChanged(int)), SLOT(setDirty()));
64 connect(m_page->numNegativeRows, SIGNAL(valueChanged(int)), SLOT(setDirty()));
65 connect(m_page->numPositiveRows, SIGNAL(valueChanged(int)), SLOT(setDirty()));
66
67 connect(m_page->numNegativeColumns, SIGNAL(valueChanged(int)), SLOT(updateCheckboxAvailability()));
68 connect(m_page->numPositiveColumns, SIGNAL(valueChanged(int)), SLOT(updateCheckboxAvailability()));
69 connect(m_page->numNegativeRows, SIGNAL(valueChanged(int)), SLOT(updateCheckboxAvailability()));
70 connect(m_page->numPositiveRows, SIGNAL(valueChanged(int)), SLOT(updateCheckboxAvailability()));
71
72 connect(m_page->columnPreference, SIGNAL(stateChanged(int)), SLOT(setDirty()));
73
76}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
void updateCheckboxAvailability()
KisProcessingApplicator * m_applicator
KisLayerSP m_baseLayer
WdgClonesArray * m_page
QPointer< KisViewManager > m_viewManager
@ FlipOptionsMode_NoFlipOptions
There is no flip options available.
void setMainWidget(QWidget *widget)
Definition KoDialog.cpp:354
virtual void setCaption(const QString &caption)
Definition KoDialog.cpp:498
void setButtons(ButtonCodes buttonMask)
Definition KoDialog.cpp:195
void setDefaultButton(ButtonCode id)
Definition KoDialog.cpp:302
@ Ok
Show Ok button. (this button accept()s the dialog; result set to QDialog::Accepted)
Definition KoDialog.h:127
@ Apply
Show Apply button.
Definition KoDialog.h:128
@ Cancel
Show Cancel-button. (this button reject()s the dialog; result set to QDialog::Rejected)
Definition KoDialog.h:130
KoDialog(QWidget *parent=0, Qt::WindowFlags f=Qt::WindowFlags())
Definition KoDialog.cpp:176

References KoDialog::Apply, applyClicked(), KoDialog::Cancel, cancelClicked(), connect(), KisAngleSelector::FlipOptionsMode_NoFlipOptions, initializeValues(), m_baseLayer, m_page, KoDialog::Ok, okClicked(), KoDialog::setButtons(), KoDialog::setCaption(), KoDialog::setDefaultButton(), setDirty(), KoDialog::setMainWidget(), syncAngularToOrthogonal(), syncOrthogonalToAngular(), and updateCheckboxAvailability().

◆ ~DlgClonesArray()

DlgClonesArray::~DlgClonesArray ( )
override

Definition at line 78 of file dlg_clonesarray.cpp.

79{
80 delete m_page;
81}

References m_page.

Member Function Documentation

◆ applyClicked

void DlgClonesArray::applyClicked ( )
privateslot

Definition at line 180 of file dlg_clonesarray.cpp.

181{
183}

References reapplyClones().

◆ cancelClicked

void DlgClonesArray::cancelClicked ( )
privateslot

Definition at line 185 of file dlg_clonesarray.cpp.

186{
187 if (m_applicator) {
189 delete m_applicator;
190 m_applicator = 0;
191 }
192}

References KisProcessingApplicator::cancel(), and m_applicator.

◆ initializeValues()

void DlgClonesArray::initializeValues ( )
private

Definition at line 83 of file dlg_clonesarray.cpp.

84{
87 m_page->columnXOffset->setValue(bounds.width());
88 m_page->rowYOffset->setValue(bounds.height());
89 }
90}
QRect exactBounds() const
#define bounds(x, a, b)
KisPaintDeviceSP original() const override=0

References bounds, KisPaintDevice::exactBounds(), m_baseLayer, m_page, and KisLayer::original().

◆ okClicked

void DlgClonesArray::okClicked ( )
privateslot

Definition at line 167 of file dlg_clonesarray.cpp.

168{
169 if (!m_applicator || m_isDirty) {
171 }
172
173 Q_ASSERT(m_applicator);
174
175 m_applicator->end();
176 delete m_applicator;
177 m_applicator = 0;
178}

References KisProcessingApplicator::end(), m_applicator, m_isDirty, and reapplyClones().

◆ reapplyClones()

void DlgClonesArray::reapplyClones ( )
private

Definition at line 194 of file dlg_clonesarray.cpp.

195{
197
198 KisImageSP image = m_viewManager->image();
199
200 if (!m_viewManager->blockUntilOperationsFinished(image)) return;
201
203 new KisProcessingApplicator(image, 0,
206
207 int columnXOffset = m_page->columnXOffset->value();
208 int columnYOffset = m_page->columnYOffset->value();
209 int rowXOffset = m_page->rowXOffset->value();
210 int rowYOffset = m_page->rowYOffset->value();
211 bool rowPreference = !m_page->columnPreference->isChecked();
212
213 int startColumn = -m_page->numNegativeColumns->value();
214 int startRow = -m_page->numNegativeRows->value();
215
216 int endColumn = m_page->numPositiveColumns->value() - 1;
217 int endRow = m_page->numPositiveRows->value() - 1;
218
219 QString positiveGroupName = i18n("+ Array of %1", m_baseLayer->name());
220 KisGroupLayerSP positiveGroupLayer = new KisGroupLayer(image, positiveGroupName, OPACITY_OPAQUE_U8);
222
223 KisGroupLayerSP negativeGroupLayer;
224
225 if (startRow < 0 || startColumn < 0) {
226 QString negativeGroupName = i18n("- Array of %1", m_baseLayer->name());
227 negativeGroupLayer = new KisGroupLayer(image, negativeGroupName, OPACITY_OPAQUE_U8);
229 }
230
231 for (int row = endRow; row >= startRow; row--) {
232 for (int col = endColumn; col >= startColumn; col--) {
233 if (!col && !row) continue;
234
235 bool choosePositiveGroup = rowPreference ? row > 0 || (row == 0 && col > 0) : col > 0 || (col == 0 && row > 0);
236 KisNodeSP parent = choosePositiveGroup ? positiveGroupLayer : negativeGroupLayer;
237
238
239 QString cloneName = i18n("Clone %1, %2", col, row);
240 KisCloneLayerSP clone = new KisCloneLayer(m_baseLayer, image, cloneName, OPACITY_OPAQUE_U8);
241 clone->setX(-row * rowXOffset + col * columnXOffset);
242 clone->setY(-row * rowYOffset + col * columnYOffset);
243
245 }
246 }
247
248 setClean();
249}
QVector< KisImageSignalType > KisImageSignalVector
const quint8 OPACITY_OPAQUE_U8
The command for adding a layer.
void applyCommand(KUndo2Command *command, KisStrokeJobData::Sequentiality sequentiality=KisStrokeJobData::SEQUENTIAL, KisStrokeJobData::Exclusivity exclusivity=KisStrokeJobData::NORMAL)
ChildIterator< value_type, is_const > parent(const ChildIterator< value_type, is_const > &it)
Definition KisForest.h:327
QString name() const
KisNodeSP prevSibling() const
Definition kis_node.cpp:402
KisNodeWSP parent
Definition kis_node.cpp:86

References KisProcessingApplicator::applyCommand(), cancelClicked(), KisStrokeJobData::EXCLUSIVE, m_applicator, m_baseLayer, m_page, m_viewManager, KisBaseNode::name(), KisProcessingApplicator::NONE, OPACITY_OPAQUE_U8, KisNode::parent, KisNode::prevSibling(), KisStrokeJobData::SEQUENTIAL, and setClean().

◆ setAngularSignalsEnabled()

void DlgClonesArray::setAngularSignalsEnabled ( bool value)
private

Definition at line 159 of file dlg_clonesarray.cpp.

160{
161 m_page->columnDistance->blockSignals(!value);
162 m_page->columnAngle->blockSignals(!value);
163 m_page->rowDistance->blockSignals(!value);
164 m_page->rowAngle->blockSignals(!value);
165}
float value(const T *src, size_t ch)

References m_page, and value().

◆ setClean()

void DlgClonesArray::setClean ( )
private

Definition at line 98 of file dlg_clonesarray.cpp.

99{
100 m_isDirty = false;
102}
void enableButtonApply(bool state)
Definition KoDialog.cpp:620

References KoDialog::enableButtonApply(), and m_isDirty.

◆ setDirty

void DlgClonesArray::setDirty ( )
privateslot

Definition at line 92 of file dlg_clonesarray.cpp.

93{
94 m_isDirty = true;
96}

References KoDialog::enableButtonApply(), and m_isDirty.

◆ setOrthogonalSignalsEnabled()

void DlgClonesArray::setOrthogonalSignalsEnabled ( bool value)
private

Definition at line 151 of file dlg_clonesarray.cpp.

152{
153 m_page->columnXOffset->blockSignals(!value);
154 m_page->columnYOffset->blockSignals(!value);
155 m_page->rowXOffset->blockSignals(!value);
156 m_page->rowYOffset->blockSignals(!value);
157}

References m_page, and value().

◆ syncAngularToOrthogonal

void DlgClonesArray::syncAngularToOrthogonal ( )
privateslot

Definition at line 131 of file dlg_clonesarray.cpp.

132{
134
135 qreal a, d;
136
137 d = m_page->columnDistance->value();
138 a = kisDegreesToRadians(m_page->columnAngle->angle());
139 m_page->columnXOffset->setValue(qRound(d * cos(a)));
140 m_page->columnYOffset->setValue(qRound(d * sin(a)));
141
142 d = m_page->rowDistance->value();
143 a = kisDegreesToRadians(m_page->rowAngle->angle());
144 m_page->rowXOffset->setValue(qRound(d * cos(a)));
145 m_page->rowYOffset->setValue(qRound(d * sin(a)));
146
148 setDirty();
149}
void setOrthogonalSignalsEnabled(bool value)
T kisDegreesToRadians(T degrees)
Definition kis_global.h:176

References kisDegreesToRadians(), m_page, setDirty(), and setOrthogonalSignalsEnabled().

◆ syncOrthogonalToAngular

void DlgClonesArray::syncOrthogonalToAngular ( )
privateslot

Definition at line 111 of file dlg_clonesarray.cpp.

112{
114
115 int x, y;
116
117 x = m_page->columnXOffset->value();
118 y = m_page->columnYOffset->value();
119 m_page->columnDistance->setValue((float)sqrt(pow2(x) + pow2(y)));
120 m_page->columnAngle->setAngle(kisRadiansToDegrees(atan2((double) y, (double) x)));
121
122 x = m_page->rowXOffset->value();
123 y = m_page->rowYOffset->value();
124 m_page->rowDistance->setValue((float)sqrt(pow2(x) + pow2(y)));
125 m_page->rowAngle->setAngle(kisRadiansToDegrees(atan2((double) y, (double) x)));
126
128 setDirty();
129}
void setAngularSignalsEnabled(bool value)
T kisRadiansToDegrees(T radians)
Definition kis_global.h:181
T pow2(const T &x)
Definition kis_global.h:166
KRITAIMAGE_EXPORT qreal atan2(qreal y, qreal x)
atan2 replacement

References kisRadiansToDegrees(), m_page, pow2(), setAngularSignalsEnabled(), and setDirty().

◆ updateCheckboxAvailability

void DlgClonesArray::updateCheckboxAvailability ( )
privateslot

Definition at line 104 of file dlg_clonesarray.cpp.

105{
106 m_page->columnPreference->setEnabled(
107 m_page->numNegativeColumns->value() > 0 ||
108 m_page->numNegativeRows->value() > 0);
109}

References m_page.

Member Data Documentation

◆ m_applicator

KisProcessingApplicator* DlgClonesArray::m_applicator
private

Definition at line 63 of file dlg_clonesarray.h.

◆ m_baseLayer

KisLayerSP DlgClonesArray::m_baseLayer
private

Definition at line 64 of file dlg_clonesarray.h.

◆ m_isDirty

bool DlgClonesArray::m_isDirty {false}
private

Definition at line 65 of file dlg_clonesarray.h.

65{false};

◆ m_page

WdgClonesArray* DlgClonesArray::m_page
private

Definition at line 61 of file dlg_clonesarray.h.

◆ m_viewManager

QPointer<KisViewManager> DlgClonesArray::m_viewManager
private

Definition at line 62 of file dlg_clonesarray.h.


The documentation for this class was generated from the following files: