File indexing completed on 2025-01-26 04:11:33
0001 /* 0002 * SPDX-FileCopyrightText: 2010 Lukáš Tvrdý <lukast.dev@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef KIS_SKETCH_PAINTOP_H_ 0008 #define KIS_SKETCH_PAINTOP_H_ 0009 0010 #include <brushengine/kis_paintop.h> 0011 #include <kis_types.h> 0012 0013 #include "KisSketchStandardOptions.h" 0014 #include "KisSketchOpOptionData.h" 0015 #include "kis_sketch_paintop_settings.h" 0016 0017 #include "kis_painter.h" 0018 #include <kis_brush_option.h> 0019 #include <KisStandardOptions.h> 0020 #include "KisRotationOption.h" 0021 #include "KisOpacityOption.h" 0022 #include "KisAirbrushOptionData.h" 0023 0024 class KisDabCache; 0025 0026 0027 class KisSketchPaintOp : public KisPaintOp 0028 { 0029 0030 public: 0031 0032 KisSketchPaintOp(const KisPaintOpSettingsSP settings, KisPainter *painter, KisNodeSP node, KisImageSP image); 0033 ~KisSketchPaintOp() override; 0034 0035 void paintLine(const KisPaintInformation &pi1, const KisPaintInformation &pi2, KisDistanceInformation *currentDistance) override; 0036 0037 static QList<KoResourceLoadResult> prepareLinkedResources(const KisPaintOpSettingsSP settings, KisResourcesInterfaceSP resourcesInterface); 0038 0039 protected: 0040 KisSpacingInformation paintAt(const KisPaintInformation& info) override; 0041 0042 KisSpacingInformation updateSpacingImpl(const KisPaintInformation &info) const override; 0043 0044 KisTimingInformation updateTimingImpl(const KisPaintInformation &info) const override; 0045 0046 private: 0047 // pixel buffer 0048 KisPaintDeviceSP m_dab; 0049 0050 // mask detection area 0051 KisFixedPaintDeviceSP m_maskDab; 0052 QRectF m_brushBoundingBox; 0053 QPointF m_hotSpot; 0054 0055 // simple mode 0056 qreal m_radius {1.0}; 0057 0058 KisOpacityOption m_opacityOption; 0059 KisSizeOption m_sizeOption; 0060 KisRotationOption m_rotationOption; 0061 KisRateOption m_rateOption; 0062 KisDensityOption m_densityOption; 0063 KisLineWidthOption m_lineWidthOption; 0064 KisOffsetScaleOption m_offsetScaleOption; 0065 KisAirbrushOptionData m_airbrushOption; 0066 0067 KisBrushOptionProperties m_brushOption; 0068 KisSketchOpOptionData m_sketchProperties; 0069 0070 QVector<QPointF> m_points; 0071 int m_count {0}; 0072 KisPainter * m_painter {nullptr}; 0073 KisBrushSP m_brush; 0074 KisDabCache *m_dabCache {nullptr}; 0075 0076 private: 0077 void drawConnection(const QPointF &start, const QPointF &end, double lineWidth); 0078 void updateBrushMask(const KisPaintInformation& info, qreal scale, qreal rotation); 0079 void doPaintLine(const KisPaintInformation &pi1, const KisPaintInformation &pi2); 0080 }; 0081 0082 #endif // KIS_SKETCH_PAINTOP_H_