Commit ea51095a authored by Kuntal  Majumder's avatar Kuntal Majumder 😟 Committed by Dmitry Kazakov

Added a QSpinBox to adjust granularity while doing transforms

Summary:
The patch adds a QSpinBox to the transform tool options to adjust the granularity while doing transforms.

This patch fixes real transformation granularity only, preview
granularity will be solved in the following patches.

CCBUG:344210

Reviewers: #krita, rempt, dkazakov
Reviewed By: #krita, dkazakov
Subscribers: #krita
Tags: #krita

Differential Revision: https://phabricator.kde.org/D17660
parent b56a0362
......@@ -53,6 +53,7 @@ KisToolTransformConfigWidget::KisToolTransformConfigWidget(TransformTransactionP
chkWorkRecursively->setChecked(workRecursively);
connect(chkWorkRecursively, SIGNAL(toggled(bool)), this, SIGNAL(sigRestartTransform()));
connect(changeGranularity,SIGNAL(valueChanged(int)),this,SLOT(slotGranularityChanged(int)));
// Init Filter combo
cmbFilter->setIDList(KisFilterStrategyRegistry::instance()->listKeys());
......@@ -1295,3 +1296,11 @@ void KisToolTransformConfigWidget::slotEditCagePoints(bool value)
config->setEditingTransformPoints(value);
notifyConfigChanged();
}
void KisToolTransformConfigWidget::slotGranularityChanged(int value)
{
if (m_uiSlotsBlocked) return;
ToolTransformArgs *config = m_transaction->currentConfig();
config->setPixelPrecision(value);
notifyConfigChanged();
}
......@@ -112,6 +112,8 @@ public Q_SLOTS:
void notifyEditingFinished();
void slotGranularityChanged(int value);
private:
// rad being in |R, the returned value is in [0; 360]
double radianToDegree(double rad);
......
......@@ -265,7 +265,7 @@ void KisTransformUtils::transformDevice(const ToolTransformArgs &config,
KisCageTransformWorker worker(device,
config.origPoints(),
updater,
8);
config.pixelPrecision());
worker.prepareTransform();
worker.setTransformedCage(config.transfPoints());
......@@ -327,7 +327,7 @@ QRect KisTransformUtils::needRect(const ToolTransformArgs &config,
KisCageTransformWorker worker(0,
config.origPoints(),
0,
8);
config.pixelPrecision());
worker.setTransformedCage(config.transfPoints());
result = worker.approxNeedRect(rc, srcBounds);
} else if (config.mode() == ToolTransformArgs::LIQUIFY) {
......@@ -359,7 +359,7 @@ QRect KisTransformUtils::changeRect(const ToolTransformArgs &config,
KisCageTransformWorker worker(0,
config.origPoints(),
0,
8);
config.pixelPrecision());
worker.setTransformedCage(config.transfPoints());
result = worker.approxChangeRect(rc);
......
......@@ -246,6 +246,7 @@ ToolTransformArgs::ToolTransformArgs(TransformMode mode,
, m_shearX(shearX)
, m_shearY(shearY)
, m_liquifyProperties(new KisLiquifyProperties())
, m_pixelPrecision(8)
{
setFilterId(filterId);
}
......
......@@ -92,6 +92,14 @@ public:
m_mode = mode;
}
inline int pixelPrecision() const {
return m_pixelPrecision;
}
inline void setPixelPrecision(int precision) {
m_pixelPrecision = precision;
}
//warp-related
inline int numPoints() const {
KIS_ASSERT_RECOVER_NOOP(m_origPoints.size() == m_transfPoints.size());
......@@ -330,6 +338,7 @@ private:
* operations should revert to it.
*/
QScopedPointer<ToolTransformArgs> m_continuedTransformation;
int m_pixelPrecision;
};
#endif // TOOL_TRANSFORM_ARGS_H_
......@@ -38,21 +38,6 @@
<enum>Qt::LeftToRight</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="bottomMargin">
......@@ -250,7 +235,7 @@
<enum>QFrame::Raised</enum>
</property>
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="freeTransformWidget">
<layout class="QVBoxLayout" name="verticalLayout">
......@@ -1434,7 +1419,7 @@
</size>
</property>
<property name="text">
<string>&amp;Flexibility:</string>
<string>Fle&amp;xibility:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
......@@ -1516,7 +1501,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Subd&amp;ivide</string>
<string>Subdi&amp;vide</string>
</property>
<property name="checked">
<bool>true</bool>
......@@ -1642,6 +1627,12 @@
</layout>
</widget>
<widget class="QWidget" name="cageTransformPage">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QLabel" name="cageTransformDirections">
......@@ -1669,7 +1660,7 @@
<bool>true</bool>
</property>
<property name="text">
<string>De&amp;form Layer</string>
<string>Defor&amp;m Layer</string>
</property>
<attribute name="buttonGroup">
<string notr="true">cageTransformButtonGroup</string>
......@@ -1677,7 +1668,58 @@
</widget>
</item>
<item>
<spacer name="verticalSpacer_4">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Adjust Granularity</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="changeGranularity">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Set Granularity</string>
</property>
<property name="inputMethodHints">
<set>Qt::ImhNone</set>
</property>
<property name="maximum">
<number>20</number>
</property>
<property name="value">
<number>8</number>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
......@@ -2200,8 +2242,8 @@
<resources/>
<connections/>
<buttongroups>
<buttongroup name="freeTransformRadioGroup"/>
<buttongroup name="cageTransformButtonGroup"/>
<buttongroup name="freeTransformRadioGroup"/>
<buttongroup name="buttonGroup"/>
</buttongroups>
</ui>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment