Commit 6ed320c4 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Remove the link to KisNode in KisPaintOpSettings

The settings object is purely XML data so we shouldn't store a shared
pointer there. It causes really subtle bugs related to the lifetime of
the node in question.

Now the node is passed to the PaontOp directly via constructor. And the
options widget gets it directly from KisPaintOpBox.

BUG:341847
parent b5254779
...@@ -79,8 +79,7 @@ void KisLowMemoryBenchmark::benchmarkWideArea(const QString presetFileName, ...@@ -79,8 +79,7 @@ void KisLowMemoryBenchmark::benchmarkWideArea(const QString presetFileName,
KisPainter *painter = new KisPainter(layer->paintDevice()); KisPainter *painter = new KisPainter(layer->paintDevice());
painter->setPaintColor(KoColor(Qt::black, colorSpace)); painter->setPaintColor(KoColor(Qt::black, colorSpace));
painter->setPaintOpPreset(preset, image); painter->setPaintOpPreset(preset, layer, image);
preset->settings()->setNode(layer);
/** /**
* A simple adapter that will store all the transactions for us * A simple adapter that will store all the transactions for us
......
...@@ -363,8 +363,7 @@ inline void KisStrokeBenchmark::benchmarkLine(QString presetFileName) ...@@ -363,8 +363,7 @@ inline void KisStrokeBenchmark::benchmarkLine(QString presetFileName)
{ {
KisPaintOpPresetSP preset = new KisPaintOpPreset(m_dataPath + presetFileName); KisPaintOpPresetSP preset = new KisPaintOpPreset(m_dataPath + presetFileName);
preset->load(); preset->load();
preset->settings()->setNode(m_layer); m_painter->setPaintOpPreset(preset, m_layer, m_image);
m_painter->setPaintOpPreset(preset, m_image);
QPointF startPoint(0.10 * TEST_IMAGE_WIDTH, 0.5 * TEST_IMAGE_HEIGHT); QPointF startPoint(0.10 * TEST_IMAGE_WIDTH, 0.5 * TEST_IMAGE_HEIGHT);
QPointF endPoint(0.90 * TEST_IMAGE_WIDTH, 0.5 * TEST_IMAGE_HEIGHT); QPointF endPoint(0.90 * TEST_IMAGE_WIDTH, 0.5 * TEST_IMAGE_HEIGHT);
...@@ -393,9 +392,7 @@ void KisStrokeBenchmark::benchmarkCircle(QString presetFileName) ...@@ -393,9 +392,7 @@ void KisStrokeBenchmark::benchmarkCircle(QString presetFileName)
return; return;
} }
m_painter->setPaintOpPreset(preset, m_layer, m_image);
preset->settings()->setNode(m_layer);
m_painter->setPaintOpPreset(preset, m_image);
QBENCHMARK{ QBENCHMARK{
...@@ -449,8 +446,7 @@ void KisStrokeBenchmark::benchmarkRandomLines(QString presetFileName) ...@@ -449,8 +446,7 @@ void KisStrokeBenchmark::benchmarkRandomLines(QString presetFileName)
qDebug() << "preset : " << presetFileName; qDebug() << "preset : " << presetFileName;
} }
preset->settings()->setNode(m_layer); m_painter->setPaintOpPreset(preset, m_layer, m_image);
m_painter->setPaintOpPreset(preset, m_image);
QBENCHMARK{ QBENCHMARK{
KisDistanceInformation currentDistance; KisDistanceInformation currentDistance;
...@@ -477,8 +473,7 @@ void KisStrokeBenchmark::benchmarkStroke(QString presetFileName) ...@@ -477,8 +473,7 @@ void KisStrokeBenchmark::benchmarkStroke(QString presetFileName)
qDebug() << "preset : " << presetFileName; qDebug() << "preset : " << presetFileName;
} }
preset->settings()->setNode(m_layer); m_painter->setPaintOpPreset(preset, m_layer, m_image);
m_painter->setPaintOpPreset(preset, m_image);
QBENCHMARK{ QBENCHMARK{
KisDistanceInformation currentDistance; KisDistanceInformation currentDistance;
......
...@@ -67,7 +67,7 @@ public: ...@@ -67,7 +67,7 @@ public:
* @param settings the settings associated with the input device * @param settings the settings associated with the input device
* @param painter the painter used to draw * @param painter the painter used to draw
*/ */
virtual KisPaintOp * createOp(const KisPaintOpSettingsSP settings, KisPainter * painter, KisImageWSP image) = 0; virtual KisPaintOp * createOp(const KisPaintOpSettingsSP settings, KisPainter * painter, KisNodeSP node, KisImageSP image) = 0;
virtual QString id() const = 0; virtual QString id() const = 0;
virtual QString name() const = 0; virtual QString name() const = 0;
virtual QString category() const = 0; virtual QString category() const = 0;
......
...@@ -83,7 +83,7 @@ void KisPaintOpRegistry::preinitializePaintOpIfNeeded(const KisPaintOpPresetSP p ...@@ -83,7 +83,7 @@ void KisPaintOpRegistry::preinitializePaintOpIfNeeded(const KisPaintOpPresetSP p
} }
#endif /* HAVE_THREADED_TEXT_RENDERING_WORKAROUND */ #endif /* HAVE_THREADED_TEXT_RENDERING_WORKAROUND */
KisPaintOp * KisPaintOpRegistry::paintOp(const QString & id, const KisPaintOpSettingsSP settings, KisPainter * painter, KisImageWSP image) const KisPaintOp * KisPaintOpRegistry::paintOp(const QString & id, const KisPaintOpSettingsSP settings, KisPainter * painter, KisNodeSP node, KisImageSP image) const
{ {
if (painter == 0) { if (painter == 0) {
warnKrita << " KisPaintOpRegistry::paintOp painter is null"; warnKrita << " KisPaintOpRegistry::paintOp painter is null";
...@@ -94,7 +94,7 @@ KisPaintOp * KisPaintOpRegistry::paintOp(const QString & id, const KisPaintOpSet ...@@ -94,7 +94,7 @@ KisPaintOp * KisPaintOpRegistry::paintOp(const QString & id, const KisPaintOpSet
KisPaintOpFactory* f = value(id); KisPaintOpFactory* f = value(id);
if (f) { if (f) {
KisPaintOp * op = f->createOp(settings, painter, image); KisPaintOp * op = f->createOp(settings, painter, node, image);
if (op) { if (op) {
return op; return op;
} }
...@@ -103,14 +103,14 @@ KisPaintOp * KisPaintOpRegistry::paintOp(const QString & id, const KisPaintOpSet ...@@ -103,14 +103,14 @@ KisPaintOp * KisPaintOpRegistry::paintOp(const QString & id, const KisPaintOpSet
return 0; return 0;
} }
KisPaintOp * KisPaintOpRegistry::paintOp(const KisPaintOpPresetSP preset, KisPainter * painter, KisImageWSP image) const KisPaintOp * KisPaintOpRegistry::paintOp(const KisPaintOpPresetSP preset, KisPainter * painter, KisNodeSP node, KisImageSP image) const
{ {
Q_ASSERT(preset); Q_ASSERT(preset);
Q_ASSERT(painter); Q_ASSERT(painter);
if (!preset) return 0; if (!preset) return 0;
return paintOp(preset->paintOp().id(), preset->settings(), painter, image); return paintOp(preset->paintOp().id(), preset->settings(), painter, node, image);
} }
KisPaintOpSettingsSP KisPaintOpRegistry::settings(const KoID& id) const KisPaintOpSettingsSP KisPaintOpRegistry::settings(const KoID& id) const
......
...@@ -58,7 +58,7 @@ public: ...@@ -58,7 +58,7 @@ public:
* Create and return a paintop based on the given preset. A preset defines * Create and return a paintop based on the given preset. A preset defines
* a paintop, a settings object and possible a brush tip. * a paintop, a settings object and possible a brush tip.
*/ */
KisPaintOp* paintOp(const KisPaintOpPresetSP preset, KisPainter * painter, KisImageWSP image) const; KisPaintOp* paintOp(const KisPaintOpPresetSP preset, KisPainter * painter, KisNodeSP node, KisImageSP image) const;
/** /**
* Create and return an (abstracted) configuration widget * Create and return an (abstracted) configuration widget
...@@ -99,7 +99,7 @@ private: ...@@ -99,7 +99,7 @@ private:
/** /**
* Return a newly created paintop. You are responsible for deleting * Return a newly created paintop. You are responsible for deleting
*/ */
KisPaintOp * paintOp(const QString& id, const KisPaintOpSettingsSP settings, KisPainter * painter, KisImageWSP image = 0) const; KisPaintOp * paintOp(const QString& id, const KisPaintOpSettingsSP settings, KisPainter * painter, KisNodeSP node, KisImageSP image) const;
}; };
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include <KoCompositeOpRegistry.h> #include <KoCompositeOpRegistry.h>
#include <KoViewConverter.h> #include <KoViewConverter.h>
#include "kis_node.h"
#include "kis_paint_layer.h" #include "kis_paint_layer.h"
#include "kis_image.h" #include "kis_image.h"
#include "kis_painter.h" #include "kis_painter.h"
...@@ -43,7 +42,6 @@ ...@@ -43,7 +42,6 @@
struct KisPaintOpSettings::Private { struct KisPaintOpSettings::Private {
Private() : disableDirtyNotifications(false) {} Private() : disableDirtyNotifications(false) {}
KisNodeWSP node;
QPointer<KisPaintOpSettingsWidget> settingsWidget; QPointer<KisPaintOpSettingsWidget> settingsWidget;
QString modelName; QString modelName;
KisPaintOpPresetWSP preset; KisPaintOpPresetWSP preset;
...@@ -147,16 +145,6 @@ void KisPaintOpSettings::activate() ...@@ -147,16 +145,6 @@ void KisPaintOpSettings::activate()
{ {
} }
void KisPaintOpSettings::setNode(KisNodeSP node)
{
d->node = node;
}
KisNodeSP KisPaintOpSettings::node() const
{
return d->node;
}
void KisPaintOpSettings::changePaintOpSize(qreal x, qreal y) void KisPaintOpSettings::changePaintOpSize(qreal x, qreal y)
{ {
if (!d->settingsWidget.isNull()) { if (!d->settingsWidget.isNull()) {
......
...@@ -82,12 +82,6 @@ public: ...@@ -82,12 +82,6 @@ public:
*/ */
virtual KisPaintOpSettingsSP clone() const; virtual KisPaintOpSettingsSP clone() const;
/**
* Override this function if your paintop is interested in which
* node is currently active.
*/
virtual void setNode(KisNodeSP node);
/** /**
* @return the node the paintop is working on. * @return the node the paintop is working on.
*/ */
......
...@@ -50,6 +50,10 @@ public: ...@@ -50,6 +50,10 @@ public:
m_image = image; m_image = image;
} }
virtual void setNode(KisNodeWSP node) {
m_node = node;
}
/** /**
* @see KisPaintOpSettings::changePaintOpSize(qreal x, qreal y) * @see KisPaintOpSettings::changePaintOpSize(qreal x, qreal y)
*/ */
...@@ -83,6 +87,7 @@ public: ...@@ -83,6 +87,7 @@ public:
protected: protected:
KisImageWSP m_image; KisImageWSP m_image;
KisNodeWSP m_node;
}; };
#endif #endif
...@@ -2450,10 +2450,10 @@ const KoAbstractGradient* KisPainter::gradient() const ...@@ -2450,10 +2450,10 @@ const KoAbstractGradient* KisPainter::gradient() const
return d->gradient; return d->gradient;
} }
void KisPainter::setPaintOpPreset(KisPaintOpPresetSP preset, KisImageWSP image) void KisPainter::setPaintOpPreset(KisPaintOpPresetSP preset, KisNodeSP node, KisImageSP image)
{ {
d->paintOpPreset = preset; d->paintOpPreset = preset;
KisPaintOp *paintop = KisPaintOpRegistry::instance()->paintOp(preset, this, image); KisPaintOp *paintop = KisPaintOpRegistry::instance()->paintOp(preset, this, node, image);
Q_ASSERT(paintop); Q_ASSERT(paintop);
if (paintop) { if (paintop) {
delete d->paintOp; delete d->paintOp;
......
...@@ -582,7 +582,7 @@ public: ...@@ -582,7 +582,7 @@ public:
* Some paintops really want to know about the image they work * Some paintops really want to know about the image they work
* for, e.g. the clone paintop. * for, e.g. the clone paintop.
*/ */
void setPaintOpPreset(KisPaintOpPresetSP preset, KisImageWSP image); void setPaintOpPreset(KisPaintOpPresetSP preset, KisNodeSP node, KisImageSP image);
/// Return the paintop preset /// Return the paintop preset
KisPaintOpPresetSP preset() const; KisPaintOpPresetSP preset() const;
......
...@@ -287,10 +287,8 @@ void KisRecordedPaintAction::play(KisNodeSP node, const KisPlayInfo& info, KoUpd ...@@ -287,10 +287,8 @@ void KisRecordedPaintAction::play(KisNodeSP node, const KisPlayInfo& info, KoUpd
painter->setPaintColor(d->foregroundColor); painter->setPaintColor(d->foregroundColor);
painter->setBackgroundColor(d->backgroundColor); painter->setBackgroundColor(d->backgroundColor);
if (d->paintOpPreset) if (d->paintOpPreset) {
{ painter->setPaintOpPreset(d->paintOpPreset, node, info.image());
d->paintOpPreset->settings()->setNode(node);
painter->setPaintOpPreset(d->paintOpPreset, info.image());
} }
painter->setStrokeStyle(d->strokeStyle); painter->setStrokeStyle(d->strokeStyle);
...@@ -320,9 +318,6 @@ void KisRecordedPaintAction::play(KisNodeSP node, const KisPlayInfo& info, KoUpd ...@@ -320,9 +318,6 @@ void KisRecordedPaintAction::play(KisNodeSP node, const KisPlayInfo& info, KoUpd
} }
delete painter; delete painter;
if (d->paintOpPreset)
d->paintOpPreset->settings()->setNode(0);
transaction.commit(info.undoAdapter()); transaction.commit(info.undoAdapter());
} }
......
...@@ -37,10 +37,11 @@ ...@@ -37,10 +37,11 @@
#include <kis_pressure_opacity_option.h> #include <kis_pressure_opacity_option.h>
KisChalkPaintOp::KisChalkPaintOp(const KisChalkPaintOpSettings *settings, KisPainter * painter, KisImageWSP image) KisChalkPaintOp::KisChalkPaintOp(const KisChalkPaintOpSettings *settings, KisPainter * painter, KisNodeSP node, KisImageSP image)
: KisPaintOp(painter) : KisPaintOp(painter)
{ {
Q_UNUSED(image); Q_UNUSED(image);
Q_UNUSED(node);
m_opacityOption.readOptionSetting(settings); m_opacityOption.readOptionSetting(settings);
m_opacityOption.resetAllSensors(); m_opacityOption.resetAllSensors();
......
...@@ -33,7 +33,7 @@ class KisChalkPaintOp : public KisPaintOp ...@@ -33,7 +33,7 @@ class KisChalkPaintOp : public KisPaintOp
public: public:
KisChalkPaintOp(const KisChalkPaintOpSettings *settings, KisPainter * painter, KisImageWSP image); KisChalkPaintOp(const KisChalkPaintOpSettings *settings, KisPainter * painter, KisNodeSP node, KisImageSP image);
virtual ~KisChalkPaintOp(); virtual ~KisChalkPaintOp();
KisSpacingInformation paintAt(const KisPaintInformation& info); KisSpacingInformation paintAt(const KisPaintInformation& info);
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#include <kis_fixed_paint_device.h> #include <kis_fixed_paint_device.h>
KisColorSmudgeOp::KisColorSmudgeOp(const KisBrushBasedPaintOpSettings* settings, KisPainter* painter, KisImageWSP image): KisColorSmudgeOp::KisColorSmudgeOp(const KisBrushBasedPaintOpSettings* settings, KisPainter* painter, KisNodeSP node, KisImageSP image):
KisBrushBasedPaintOp(settings, painter), KisBrushBasedPaintOp(settings, painter),
m_firstRun(true), m_image(image), m_firstRun(true), m_image(image),
m_tempDev(painter->device()->createCompositionSourceDevice()), m_tempDev(painter->device()->createCompositionSourceDevice()),
...@@ -48,6 +48,8 @@ KisColorSmudgeOp::KisColorSmudgeOp(const KisBrushBasedPaintOpSettings* settings, ...@@ -48,6 +48,8 @@ KisColorSmudgeOp::KisColorSmudgeOp(const KisBrushBasedPaintOpSettings* settings,
m_colorRateOption("ColorRate"), m_colorRateOption("ColorRate"),
m_smudgeRadiusOption("SmudgeRadius") m_smudgeRadiusOption("SmudgeRadius")
{ {
Q_UNUSED(node);
Q_ASSERT(settings); Q_ASSERT(settings);
Q_ASSERT(painter); Q_ASSERT(painter);
......
...@@ -43,7 +43,7 @@ class KisPainter; ...@@ -43,7 +43,7 @@ class KisPainter;
class KisColorSmudgeOp: public KisBrushBasedPaintOp class KisColorSmudgeOp: public KisBrushBasedPaintOp
{ {
public: public:
KisColorSmudgeOp(const KisBrushBasedPaintOpSettings* settings, KisPainter* painter, KisImageWSP image); KisColorSmudgeOp(const KisBrushBasedPaintOpSettings* settings, KisPainter* painter, KisNodeSP node, KisImageSP image);
virtual ~KisColorSmudgeOp(); virtual ~KisColorSmudgeOp();
KisSpacingInformation paintAt(const KisPaintInformation& info); KisSpacingInformation paintAt(const KisPaintInformation& info);
......
...@@ -29,11 +29,12 @@ ...@@ -29,11 +29,12 @@
#include "kis_painter.h" #include "kis_painter.h"
#include "kis_types.h" #include "kis_types.h"
KisCurvePaintOp::KisCurvePaintOp(const KisCurvePaintOpSettings *settings, KisPainter * painter, KisImageWSP image) KisCurvePaintOp::KisCurvePaintOp(const KisCurvePaintOpSettings *settings, KisPainter * painter, KisNodeSP node, KisImageSP image)
: KisPaintOp(painter), m_painter(0) : KisPaintOp(painter), m_painter(0)
{ {
Q_ASSERT(settings); Q_ASSERT(settings);
Q_UNUSED(image); Q_UNUSED(image);
Q_UNUSED(node);
m_curveProperties.readOptionSetting(settings); m_curveProperties.readOptionSetting(settings);
m_opacityOption.readOptionSetting(settings); m_opacityOption.readOptionSetting(settings);
......
...@@ -34,7 +34,7 @@ class KisCurvePaintOp : public KisPaintOp ...@@ -34,7 +34,7 @@ class KisCurvePaintOp : public KisPaintOp
{ {
public: public:
KisCurvePaintOp(const KisCurvePaintOpSettings *settings, KisPainter * painter, KisImageWSP image); KisCurvePaintOp(const KisCurvePaintOpSettings *settings, KisPainter * painter, KisNodeSP node, KisImageSP image);
virtual ~KisCurvePaintOp(); virtual ~KisCurvePaintOp();
KisSpacingInformation paintAt(const KisPaintInformation& info); KisSpacingInformation paintAt(const KisPaintInformation& info);
......
...@@ -11,7 +11,6 @@ set(kritadefaultpaintops_PART_SRCS ...@@ -11,7 +11,6 @@ set(kritadefaultpaintops_PART_SRCS
brush/kis_brushop.cpp brush/kis_brushop.cpp
brush/kis_brushop_settings_widget.cpp brush/kis_brushop_settings_widget.cpp
duplicate/kis_duplicateop.cpp duplicate/kis_duplicateop.cpp
duplicate/kis_duplicateop_factory.cpp
duplicate/kis_duplicateop_settings.cpp duplicate/kis_duplicateop_settings.cpp
duplicate/kis_duplicateop_settings_widget.cpp duplicate/kis_duplicateop_settings_widget.cpp
duplicate/kis_duplicateop_option.cpp duplicate/kis_duplicateop_option.cpp
......
...@@ -41,8 +41,8 @@ ...@@ -41,8 +41,8 @@
#include <kis_pressure_sharpness_option.h> #include <kis_pressure_sharpness_option.h>
#include <kis_fixed_paint_device.h> #include <kis_fixed_paint_device.h>
KisBrushOp::KisBrushOp(const KisBrushBasedPaintOpSettings *settings, KisPainter *painter, KisImageWSP image) KisBrushOp::KisBrushOp(const KisBrushBasedPaintOpSettings *settings, KisPainter *painter, KisNodeSP node, KisImageSP image)
: KisBrushBasedPaintOp(settings, painter), m_opacityOption(settings->node()), m_hsvTransformation(0) : KisBrushBasedPaintOp(settings, painter), m_opacityOption(node), m_hsvTransformation(0)
{ {
Q_UNUSED(image); Q_UNUSED(image);
Q_ASSERT(settings); Q_ASSERT(settings);
......
...@@ -51,7 +51,7 @@ class KisBrushOp : public KisBrushBasedPaintOp ...@@ -51,7 +51,7 @@ class KisBrushOp : public KisBrushBasedPaintOp
public: public:
KisBrushOp(const KisBrushBasedPaintOpSettings *settings, KisPainter * painter, KisImageWSP image); KisBrushOp(const KisBrushBasedPaintOpSettings *settings, KisPainter * painter, KisNodeSP node, KisImageSP image);
~KisBrushOp(); ~KisBrushOp();
KisSpacingInformation paintAt(const KisPaintInformation& info); KisSpacingInformation paintAt(const KisPaintInformation& info);
......
...@@ -29,7 +29,8 @@ ...@@ -29,7 +29,8 @@
#include "kis_simple_paintop_factory.h" #include "kis_simple_paintop_factory.h"
#include "kis_brushop.h" #include "kis_brushop.h"
#include "kis_brushop_settings_widget.h" #include "kis_brushop_settings_widget.h"
#include "kis_duplicateop_factory.h" #include "kis_duplicateop.h"
#include "kis_duplicateop_settings.h"
#include "kis_global.h" #include "kis_global.h"
#include "kis_paintop_registry.h" #include "kis_paintop_registry.h"
#include "kis_brush_based_paintop_settings.h" #include "kis_brush_based_paintop_settings.h"
...@@ -44,7 +45,7 @@ DefaultPaintOpsPlugin::DefaultPaintOpsPlugin(QObject *parent, const QVariantList ...@@ -44,7 +45,7 @@ DefaultPaintOpsPlugin::DefaultPaintOpsPlugin(QObject *parent, const QVariantList
{ {
KisPaintOpRegistry *r = KisPaintOpRegistry::instance(); KisPaintOpRegistry *r = KisPaintOpRegistry::instance();
r->add(new KisSimplePaintOpFactory<KisBrushOp, KisBrushBasedPaintOpSettings, KisBrushOpSettingsWidget>("paintbrush", i18n("Pixel"), KisPaintOpFactory::categoryStable(), "krita-paintbrush.png", QString(), QStringList(), 1)); r->add(new KisSimplePaintOpFactory<KisBrushOp, KisBrushBasedPaintOpSettings, KisBrushOpSettingsWidget>("paintbrush", i18n("Pixel"), KisPaintOpFactory::categoryStable(), "krita-paintbrush.png", QString(), QStringList(), 1));
r->add(new KisDuplicateOpFactory); r->add(new KisSimplePaintOpFactory<KisDuplicateOp, KisDuplicateOpSettings, KisDuplicateOpSettingsWidget>("duplicate", i18nc("clone paintbrush (previously \"Duplicate\")", "Clone"), KisPaintOpFactory::categoryStable(), "krita-duplicate.png", QString(), QStringList(COMPOSITE_COPY), 15));
QStringList whiteList; QStringList whiteList;
whiteList << COMPOSITE_COPY; whiteList << COMPOSITE_COPY;
KisBrushServer::instance(); KisBrushServer::instance();
......
...@@ -66,9 +66,10 @@ ...@@ -66,9 +66,10 @@
#include "kis_duplicateop_settings_widget.h" #include "kis_duplicateop_settings_widget.h"
#include "kis_duplicateop_option.h" #include "kis_duplicateop_option.h"
KisDuplicateOp::KisDuplicateOp(KisImageWSP image, const KisDuplicateOpSettings *settings, KisPainter *painter) KisDuplicateOp::KisDuplicateOp(const KisDuplicateOpSettings *settings, KisPainter *painter, KisNodeSP node, KisImageSP image)
: KisBrushBasedPaintOp(settings, painter) : KisBrushBasedPaintOp(settings, painter)
, m_image(image) , m_image(image)
, m_node(node)
, m_settings(settings) , m_settings(settings)
{ {
Q_ASSERT(settings); Q_ASSERT(settings);
...@@ -88,7 +89,6 @@ KisDuplicateOp::~KisDuplicateOp() ...@@ -88,7 +89,6 @@ KisDuplicateOp::~KisDuplicateOp()
#define CLAMP(x,l,u) ((x)<(l)?(l):((x)>(u)?(u):(x))) #define CLAMP(x,l,u) ((x)<(l)?(l):((x)>(u)?(u):(x)))
KisSpacingInformation KisDuplicateOp::paintAt(const KisPaintInformation& info) KisSpacingInformation KisDuplicateOp::paintAt(const KisPaintInformation& info)
{ {
if (!painter()->device()) return 1.0; if (!painter()->device()) return 1.0;
...@@ -111,7 +111,7 @@ KisSpacingInformation KisDuplicateOp::paintAt(const KisPaintInformation& info) ...@@ -111,7 +111,7 @@ KisSpacingInformation KisDuplicateOp::paintAt(const KisPaintInformation& info)
realSourceDevice = m_image->projection(); realSourceDevice = m_image->projection();
} }
else { else {
realSourceDevice = m_settings->node()->projection(); realSourceDevice = m_node->projection();
} }
qreal scale = m_sizeOption.apply(info); qreal scale = m_sizeOption.apply(info);
......
...@@ -45,7 +45,7 @@ class KisDuplicateOp : public KisBrushBasedPaintOp ...@@ -45,7 +45,7 @@ class KisDuplicateOp : public KisBrushBasedPaintOp
public: public:
KisDuplicateOp(KisImageWSP image, const KisDuplicateOpSettings *m_settings, KisPainter * painter); KisDuplicateOp(const KisDuplicateOpSettings *m_settings, KisPainter * painter, KisNodeSP node, KisImageSP image);
~KisDuplicateOp(); ~KisDuplicateOp();
KisSpacingInformation paintAt(const KisPaintInformation& info); KisSpacingInformation paintAt(const KisPaintInformation& info);
...@@ -56,7 +56,9 @@ private: ...@@ -56,7 +56,9 @@ private:
private: private:
KisImageWSP m_image; KisImageSP m_image;
KisNodeSP m_node;
const KisDuplicateOpSettings * m_settings; const KisDuplicateOpSettings * m_settings;
KisPaintDeviceSP m_srcdev; KisPaintDeviceSP m_srcdev;
KisPaintDeviceSP m_target; KisPaintDeviceSP m_target;
......
/*
* Copyright (c) 2002 Patrick Julien <freak@codepimps.org>
* Copyright (c) 2004-2008 Boudewijn Rempt <boud@valdyas.org>
* Copyright (c) 2004 Clarence Dang <dang@kde.org>
* Copyright (c) 2004 Adrian Page <adrian@pagenet.plus.com>
* Copyright (c) 2004 Cyrille Berger <cberger@cberger.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "kis_duplicateop_factory.h"
#include <KoInputDevice.h>
#include <KoCompositeOpRegistry.h>
#include <kis_painter.h>
#include <kis_paintop_settings.h>
#include <kis_image.h>
#include "kis_duplicateop_settings_widget.h"
#include "kis_duplicateop_settings.h"
#include "kis_duplicateop.h"
KisDuplicateOpFactory::KisDuplicateOpFactory()
: KisPaintOpFactory(QStringList(COMPOSITE_COPY))
{
setPriority(15);
}
KisDuplicateOpFactory::~KisDuplicateOpFactory()
{
}
KisPaintOp * KisDuplicateOpFactory::createOp(const KisPaintOpSettingsSP settings,
KisPainter * painter,
KisImageWSP image)
{
const KisDuplicateOpSettings *duplicateopSettings = dynamic_cast<const KisDuplicateOpSettings *>(settings.data());
Q_ASSERT(settings != 0 && duplicateopSettings != 0);
KisPaintOp * op = new KisDuplicateOp(image, duplicateopSettings, painter);
Q_CHECK_PTR(op);
return op;
}
KisPaintOpSettingsSP KisDuplicateOpFactory::settings()
{
return new KisDuplicateOpSettings();
}
KisPaintOpSettingsWidget* KisDuplicateOpFactory::createSettingsWidget(QWidget* parent)
{
return new KisDuplicateOpSettingsWidget(parent);
}
/*
* Copyright (c) 2002 Patrick Julien <freak@codepimps.org>
* Copyright (c) 2004-2008 Boudewijn Rempt <boud@valdyas.org>
* Copyright (c) 2004 Clarence Dang <dang@kde.org>
* Copyright (c) 2004 Adrian Page <adrian@pagenet.plus.com>
* Copyright (c) 2004 Cyrille Berger <cberger@cberger.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of