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

#include <dlg_grow_selection.h>

+ Inheritance diagram for WdgGrowSelection:

Public Member Functions

void getConfiguration (KisOperationConfigurationSP config) override
 
 WdgGrowSelection (QWidget *parent, KisViewManager *view, KisOperationConfigurationSP config)
 
- Public Member Functions inherited from KisOperationUIWidget
QString caption () const
 
 KisOperationUIWidget (const QString &caption, QWidget *parent=0)
 
 Private ()
 
 ~KisOperationUIWidget () override
 

Private Slots

void slotGrowValueChanged (double value)
 
void slotGrowValueChanged (int value)
 
void slotUnitChanged (int index)
 

Private Member Functions

void updateGrowUIValue (double value)
 

Private Attributes

int m_growValue
 
double m_resolution
 

Additional Inherited Members

- Public Attributes inherited from KisOperationUIWidget
QString caption
 

Detailed Description

Definition at line 16 of file dlg_grow_selection.h.

Constructor & Destructor Documentation

◆ WdgGrowSelection()

WdgGrowSelection::WdgGrowSelection ( QWidget * parent,
KisViewManager * view,
KisOperationConfigurationSP config )

Definition at line 19 of file dlg_grow_selection.cc.

20 : KisOperationUIWidget(i18n("Grow Selection"), parent)
21 , m_growValue(config->getInt("x-radius", 1))
22{
23 Q_ASSERT(view);
24 KisImageWSP image = view->image();
25 Q_ASSERT(image);
26 m_resolution = image->yRes();
27
28 setupUi(this);
29
30 spbGrowValue->setValue(m_growValue);
31 spbGrowValue->setFocus();
32 spbGrowValue->setVisible(true);
33 spbGrowValueDouble->setVisible(false);
34
35 cmbUnit->addItems(KoUnit::listOfUnitNameForUi());
36 cmbUnit->setCurrentIndex(KoUnit(KoUnit::Pixel).indexInListForUi());
37
38 // ensure that both spinboxes request the same horizontal size
39 KisSizeGroup *spbGroup = new KisSizeGroup(this);
40 spbGroup->addWidget(spbGrowValue);
41 spbGroup->addWidget(spbGrowValueDouble);
42
43 connect(spbGrowValue, SIGNAL(valueChanged(int)), this, SLOT(slotGrowValueChanged(int)));
44 connect(spbGrowValueDouble, SIGNAL(valueChanged(double)), this, SLOT(slotGrowValueChanged(double)));
45 connect(cmbUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUnitChanged(int)));
46}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
double yRes() const
KisOperationUIWidget(const QString &caption, QWidget *parent=0)
void addWidget(QWidget *widget)
KisImageWSP image() const
Return the image this view is displaying.
@ Pixel
Definition KoUnit.h:82
static QStringList listOfUnitNameForUi(ListOptions listOptions=ListAll)
Returns the list of unit types for the UI, controlled with the given listOptions.
Definition KoUnit.cpp:69
void slotGrowValueChanged(int value)
void slotUnitChanged(int index)

References KisSizeGroup::addWidget(), connect(), KisViewManager::image(), KoUnit::listOfUnitNameForUi(), m_growValue, m_resolution, KoUnit::Pixel, slotGrowValueChanged(), slotUnitChanged(), and KisImage::yRes().

Member Function Documentation

◆ getConfiguration()

void WdgGrowSelection::getConfiguration ( KisOperationConfigurationSP config)
overridevirtual

Fetch the setting from the config widget

Parameters
configconfiguration to which the setting will be written

Implements KisOperationUIWidget.

Definition at line 89 of file dlg_grow_selection.cc.

90{
91 config->setProperty("x-radius", m_growValue);
92 config->setProperty("y-radius", m_growValue);
93}

References m_growValue.

◆ slotGrowValueChanged [1/2]

void WdgGrowSelection::slotGrowValueChanged ( double value)
privateslot

Definition at line 53 of file dlg_grow_selection.cc.

54{
55 const KoUnit selectedUnit = KoUnit::fromListForUi(cmbUnit->currentIndex());
56 const double resValue = (selectedUnit == KoUnit(KoUnit::Pixel)) ? value : (value * m_resolution);
57 m_growValue = qRound(selectedUnit.fromUserValue(resValue));
58}
float value(const T *src, size_t ch)
qreal fromUserValue(qreal value) const
Definition KoUnit.cpp:201
static KoUnit fromListForUi(int index, ListOptions listOptions=ListAll, qreal factor=1.0)
Definition KoUnit.cpp:80

References KoUnit::fromListForUi(), KoUnit::fromUserValue(), m_growValue, m_resolution, KoUnit::Pixel, and value().

◆ slotGrowValueChanged [2/2]

void WdgGrowSelection::slotGrowValueChanged ( int value)
privateslot

Definition at line 48 of file dlg_grow_selection.cc.

49{
51}

References slotGrowValueChanged(), and value().

◆ slotUnitChanged

void WdgGrowSelection::slotUnitChanged ( int index)
privateslot

Definition at line 60 of file dlg_grow_selection.cc.

61{
63
64 const KoUnit selectedUnit = KoUnit::fromListForUi(index);
65 if (selectedUnit != KoUnit(KoUnit::Pixel)) {
66 spbGrowValue->setVisible(false);
67 spbGrowValueDouble->setVisible(true);
68 } else {
69 spbGrowValue->setVisible(true);
70 spbGrowValueDouble->setVisible(false);
71 }
72}
void updateGrowUIValue(double value)

References KoUnit::fromListForUi(), m_growValue, KoUnit::Pixel, and updateGrowUIValue().

◆ updateGrowUIValue()

void WdgGrowSelection::updateGrowUIValue ( double value)
private

Definition at line 74 of file dlg_grow_selection.cc.

75{
76 const KoUnit selectedUnit = KoUnit::fromListForUi(cmbUnit->currentIndex());
77 if (selectedUnit != KoUnit(KoUnit::Pixel)) {
78 spbGrowValueDouble->blockSignals(true);
79 spbGrowValueDouble->setValue(selectedUnit.toUserValue(value / m_resolution));
80 spbGrowValueDouble->blockSignals(false);
81 } else {
82 const int finalValue = (selectedUnit == KoUnit(KoUnit::Point)) ? qRound(value / m_resolution) : value;
83 spbGrowValue->blockSignals(true);
84 spbGrowValue->setValue(selectedUnit.toUserValue(finalValue));
85 spbGrowValue->blockSignals(false);
86 }
87}
@ Point
Postscript point, 1/72th of an Inco.
Definition KoUnit.h:76
qreal toUserValue(qreal ptValue, bool rounding=true) const
Definition KoUnit.cpp:186

References KoUnit::fromListForUi(), m_resolution, KoUnit::Pixel, KoUnit::Point, KoUnit::toUserValue(), and value().

Member Data Documentation

◆ m_growValue

int WdgGrowSelection::m_growValue
private

Definition at line 34 of file dlg_grow_selection.h.

◆ m_resolution

double WdgGrowSelection::m_resolution
private

Definition at line 33 of file dlg_grow_selection.h.


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