File indexing completed on 2025-01-26 04:11:18

0001 /*
0002  *  SPDX-FileCopyrightText: 2002 Patrick Julien <freak@codepimps.org>
0003  *  SPDX-FileCopyrightText: 2004-2008 Boudewijn Rempt <boud@valdyas.org>
0004  *  SPDX-FileCopyrightText: 2004 Clarence Dang <dang@kde.org>
0005  *  SPDX-FileCopyrightText: 2004 Adrian Page <adrian@pagenet.plus.com>
0006  *  SPDX-FileCopyrightText: 2004 Cyrille Berger <cberger@cberger.net>
0007  *
0008  *  SPDX-License-Identifier: GPL-2.0-or-later
0009  */
0010 
0011 #ifndef KIS_DUPLICATEOP_SETTINGS_H_
0012 #define KIS_DUPLICATEOP_SETTINGS_H_
0013 
0014 #include <kis_brush_based_paintop_settings.h>
0015 #include <kis_types.h>
0016 #include <QPointF>
0017 
0018 class QDomElement;
0019 class KisDuplicateOpSettings : public KisBrushBasedPaintOpSettings
0020 {
0021 
0022 public:
0023     using KisPaintOpSettings::fromXML;
0024     using KisPaintOpSettings::toXML;
0025 
0026     KisDuplicateOpSettings(KisResourcesInterfaceSP resourcesInterface);
0027     ~KisDuplicateOpSettings() override;
0028     bool paintIncremental() override;
0029     QString indirectPaintingCompositeOp() const override;
0030 
0031     QPointF offset() const;
0032     QPointF position() const;
0033     /**
0034      * This function is called by a tool when the mouse is pressed.
0035      * Returns false if picking new origin is in action,
0036      * and returns true otherwise (i.e. if brush is starting a new stroke).
0037      * See kis_tool_freehand:trySampleByPaintOp()
0038      */
0039     bool mousePressEvent(const KisPaintInformation& pos, Qt::KeyboardModifiers modifiers, KisNodeWSP currentNode) override;
0040     /**
0041      * This function is called by a tool when the mouse is released.
0042      * If the tool is supposed to ignore the event, the paint op should return true
0043      * and if the tool is supposed to use the event, return false.
0044      */
0045     bool mouseReleaseEvent() override;
0046     void activate() override;
0047 
0048     void fromXML(const QDomElement& elt) override;
0049     void toXML(QDomDocument& doc, QDomElement& rootElt) const override;
0050 
0051     KisPaintOpSettingsSP clone() const override;
0052     using KisBrushBasedPaintOpSettings::brushOutline;
0053     KisOptimizedBrushOutline brushOutline(const KisPaintInformation &info, const OutlineMode &mode, qreal alignForZoom) override;
0054 
0055     KisNodeWSP sourceNode() const;
0056 
0057     QList<KisUniformPaintOpPropertySP> uniformProperties(KisPaintOpSettingsSP settings, QPointer<KisPaintOpPresetUpdateProxy> updateProxy) override;
0058 
0059 public:
0060 
0061     Q_DISABLE_COPY(KisDuplicateOpSettings)
0062 
0063     QPointF m_offset;
0064     bool m_isOffsetNotUptodate; // true between the act of setting a new origin and the first stroke
0065     bool m_duringPaintingStroke; // true if the stroke is begin painted now, false otherwise
0066     QPointF m_position; // Give the position of the last alt-click
0067     KisNodeWSP m_sourceNode; // Give the node of the source point (origin)
0068     QList<KisUniformPaintOpPropertyWSP> m_uniformProperties;
0069 };
0070 
0071 typedef KisSharedPtr<KisDuplicateOpSettings> KisDuplicateOpSettingsSP;
0072 
0073 
0074 #endif // KIS_DUPLICATEOP_SETTINGS_H_