Verified Commit cf276a70 authored by Kuntal  Majumder's avatar Kuntal Majumder 😟

tool/transform : Can manipulate granularity during cage transform

Summary:
The patch adds a QComboBox to the transform tool options to adjust the
granularity preview while doing cage transforms, it also changes the
QSpinBox to change the real granularity to a QComboBox.

CCBUG:344210

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

Differential Revision: https://phabricator.kde.org/D17807
parent 494f604d
......@@ -164,7 +164,6 @@ void KisCageTransformWorker::prepareTransform()
// no need to process empty devices
if (srcBounds.isEmpty()) return;
m_d->gridSize =
GridIterationTools::calcGridSize(srcBounds, m_d->pixelPrecision);
......@@ -172,7 +171,6 @@ void KisCageTransformWorker::prepareTransform()
GridIterationTools::processGrid(pointsOp, srcBounds, m_d->pixelPrecision);
const int numPoints = pointsOp.m_points.size();
KIS_ASSERT_RECOVER_RETURN(numPoints == m_d->gridSize.width() * m_d->gridSize.height());
m_d->allSrcPoints = pointsOp.m_points;
......
......@@ -88,13 +88,11 @@ QImage KisCageTransformStrategy::calculateTransformedImage(ToolTransformArgs &cu
const QPointF &srcOffset,
QPointF *dstOffset)
{
Q_UNUSED(currentArgs);
KisCageTransformWorker worker(srcImage,
srcOffset,
origPoints,
0,
16);
currentArgs.previewPixelPrecision());
worker.prepareTransform();
worker.setTransformedCage(transfPoints);
return worker.runOnQImage(dstOffset);
......
......@@ -53,7 +53,18 @@ KisToolTransformConfigWidget::KisToolTransformConfigWidget(TransformTransactionP
chkWorkRecursively->setChecked(workRecursively);
connect(chkWorkRecursively, SIGNAL(toggled(bool)), this, SIGNAL(sigRestartTransform()));
connect(changeGranularity,SIGNAL(valueChanged(int)),this,SLOT(slotGranularityChanged(int)));
// Granularity can only be specified in the power of 2's
QStringList granularityValues{"4","8","16","32"};
changeGranularity->addItems(granularityValues);
changeGranularity->setCurrentIndex(1);
granularityPreview->addItems(granularityValues);
granularityPreview->setCurrentIndex(2);
connect(changeGranularity,SIGNAL(currentIndexChanged(QString)),
this,SLOT(slotGranularityChanged(QString)));
connect(granularityPreview, SIGNAL(currentIndexChanged(QString)),
this,SLOT(slotPreviewGranularityChanged(QString)));
// Init Filter combo
cmbFilter->setIDList(KisFilterStrategyRegistry::instance()->listKeys());
......@@ -1297,10 +1308,20 @@ void KisToolTransformConfigWidget::slotEditCagePoints(bool value)
notifyConfigChanged();
}
void KisToolTransformConfigWidget::slotGranularityChanged(int value)
void KisToolTransformConfigWidget::slotGranularityChanged(QString value)
{
if (m_uiSlotsBlocked) return;
KIS_SAFE_ASSERT_RECOVER_RETURN(value.toInt() > 1);
ToolTransformArgs *config = m_transaction->currentConfig();
config->setPixelPrecision(value.toInt());
notifyConfigChanged();
}
void KisToolTransformConfigWidget::slotPreviewGranularityChanged(QString value)
{
if (m_uiSlotsBlocked) return;
KIS_SAFE_ASSERT_RECOVER_RETURN(value.toInt() > 1);
ToolTransformArgs *config = m_transaction->currentConfig();
config->setPixelPrecision(value);
config->setPreviewPixelPrecision(value.toInt());
notifyConfigChanged();
}
......@@ -112,7 +112,8 @@ public Q_SLOTS:
void notifyEditingFinished();
void slotGranularityChanged(int value);
void slotGranularityChanged(QString value);
void slotPreviewGranularityChanged(QString value);
private:
// rad being in |R, the returned value is in [0; 360]
......
......@@ -48,6 +48,8 @@ ToolTransformArgs::ToolTransformArgs()
, m_shearX(0.0)
, m_shearY(0.0)
, m_liquifyProperties(new KisLiquifyProperties())
, m_pixelPrecision(8)
, m_previewPixelPrecision(16)
{
KConfigGroup configGroup = KSharedConfig::openConfig()->group("KisToolTransform");
QString savedFilterId = configGroup.readEntry("filterId", "Bicubic");
......@@ -96,6 +98,8 @@ void ToolTransformArgs::init(const ToolTransformArgs& args)
m_filter = args.m_filter;
m_flattenedPerspectiveTransform = args.m_flattenedPerspectiveTransform;
m_editTransformPoints = args.m_editTransformPoints;
m_pixelPrecision = 8;
m_previewPixelPrecision = 16;
if (args.m_liquifyWorker) {
m_liquifyWorker.reset(new KisLiquifyTransformWorker(*args.m_liquifyWorker.data()));
......@@ -166,7 +170,9 @@ bool ToolTransformArgs::operator==(const ToolTransformArgs& other) const
((m_liquifyWorker && other.m_liquifyWorker &&
*m_liquifyWorker == *other.m_liquifyWorker)
|| m_liquifyWorker == other.m_liquifyWorker);
|| m_liquifyWorker == other.m_liquifyWorker) &&
m_pixelPrecision == other.m_pixelPrecision &&
m_previewPixelPrecision == other.m_previewPixelPrecision;
}
bool ToolTransformArgs::isSameMode(const ToolTransformArgs& other) const
......@@ -247,6 +253,7 @@ ToolTransformArgs::ToolTransformArgs(TransformMode mode,
, m_shearY(shearY)
, m_liquifyProperties(new KisLiquifyProperties())
, m_pixelPrecision(8)
, m_previewPixelPrecision(16)
{
setFilterId(filterId);
}
......
......@@ -100,6 +100,14 @@ public:
m_pixelPrecision = precision;
}
inline int previewPixelPrecision() const {
return m_previewPixelPrecision;
}
inline void setPreviewPixelPrecision(int precision) {
m_previewPixelPrecision = precision;
}
//warp-related
inline int numPoints() const {
KIS_ASSERT_RECOVER_NOOP(m_origPoints.size() == m_transfPoints.size());
......@@ -338,7 +346,10 @@ private:
* operations should revert to it.
*/
QScopedPointer<ToolTransformArgs> m_continuedTransformation;
//PixelPrecision should always be in powers of 2
int m_pixelPrecision;
int m_previewPixelPrecision;
};
#endif // TOOL_TRANSFORM_ARGS_H_
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>489</width>
<height>674</height>
<width>499</width>
<height>709</height>
</rect>
</property>
<property name="sizePolicy">
......@@ -1677,46 +1677,62 @@
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
<width>17</width>
<height>17</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_3">
<widget class="QLabel" name="adjustGranularity">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Adjust Granularity</string>
<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>
<layout class="QVBoxLayout" name="verticalLayout_13">
<item>
<widget class="QLabel" name="previewGranularity">
<property name="text">
<string>Preview</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="granularityPreview">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="realGranularity">
<property name="text">
<string>Real</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="changeGranularity">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
......@@ -1725,8 +1741,8 @@
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
<width>17</width>
<height>411</height>
</size>
</property>
</spacer>
......@@ -2243,7 +2259,7 @@
<connections/>
<buttongroups>
<buttongroup name="cageTransformButtonGroup"/>
<buttongroup name="freeTransformRadioGroup"/>
<buttongroup name="buttonGroup"/>
<buttongroup name="freeTransformRadioGroup"/>
</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