File indexing completed on 2024-12-22 04:12:58
0001 /* 0002 * SPDX-FileCopyrightText: 2011 Dmitry Kazakov <dimula73@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef __KIS_RESOURCES_SNAPSHOT_H 0008 #define __KIS_RESOURCES_SNAPSHOT_H 0009 0010 #include "kis_shared.h" 0011 #include "kis_shared_ptr.h" 0012 #include "kis_types.h" 0013 #include "kritaui_export.h" 0014 #include "kis_painter.h" 0015 #include "kis_default_bounds.h" 0016 0017 class KoCanvasResourceProvider; 0018 class KoCompositeOp; 0019 class KisPainter; 0020 class KisPostExecutionUndoAdapter; 0021 class KoPattern; 0022 class KisInterstrokeDataFactory; 0023 0024 /** 0025 * @brief The KisResourcesSnapshot class takes a snapshot of the various resources 0026 * like colors and settings used at the begin of a stroke so subsequent 0027 * changes don't impact the running stroke. The main reason for the snapshot is that the 0028 * user can *change* the options while the stroke is being executed in the background. 0029 */ 0030 class KRITAUI_EXPORT KisResourcesSnapshot : public KisShared 0031 { 0032 public: 0033 KisResourcesSnapshot(KisImageSP image, KisNodeSP currentNode, KoCanvasResourceProvider *resourceManager, KisDefaultBoundsBaseSP bounds = 0, KisNodeList selectedNodes = KisNodeList(), KisPaintOpPresetSP presetOverride = 0); 0034 KisResourcesSnapshot(KisImageSP image, KisNodeSP currentNode, KisDefaultBoundsBaseSP bounds = 0); 0035 ~KisResourcesSnapshot(); 0036 0037 void setupPainter(KisPainter *painter); 0038 void setupMaskingBrushPainter(KisPainter *painter); 0039 0040 KisPostExecutionUndoAdapter* postExecutionUndoAdapter() const; 0041 void setCurrentNode(KisNodeSP node); 0042 void setStrokeStyle(KisPainter::StrokeStyle strokeStyle); 0043 void setFillStyle(KisPainter::FillStyle fillStyle); 0044 void setFillTransform(QTransform transform); 0045 0046 KisNodeList selectedNodes() const; 0047 KisNodeSP currentNode() const; 0048 KisImageSP image() const; 0049 bool needsIndirectPainting() const; 0050 QString indirectPaintingCompositeOp() const; 0051 0052 bool needsMaskingBrushRendering() const; 0053 0054 /** 0055 * \return currently active selection. Note that it will return 0056 * null if current node *is* the current selection. This 0057 * is done to avoid recursive selection application when 0058 * painting on selection masks. 0059 */ 0060 KisSelectionSP activeSelection() const; 0061 0062 bool needsAirbrushing() const; 0063 qreal airbrushingInterval() const; 0064 0065 bool needsSpacingUpdates() const; 0066 0067 void setOpacity(qreal opacity); 0068 quint8 opacity() const; 0069 QString compositeOpId() const; 0070 0071 KoPatternSP currentPattern() const; 0072 KoColor currentFgColor() const; 0073 KoColor currentBgColor() const; 0074 KisPaintOpPresetSP currentPaintOpPreset() const; 0075 KoAbstractGradientSP currentGradient() const; 0076 KisFilterConfigurationSP currentGenerator() const; 0077 0078 QTransform fillTransform() const; 0079 0080 /// @return the channel lock flags of the current node with the global override applied 0081 QBitArray channelLockFlags() const; 0082 0083 qreal effectiveZoom() const; 0084 bool presetAllowsLod() const; 0085 bool presetNeedsAsynchronousUpdates() const; 0086 0087 void setFGColorOverride(const KoColor &color); 0088 void setBGColorOverride(const KoColor &color); 0089 void setSelectionOverride(KisSelectionSP selection); 0090 void setBrush(const KisPaintOpPresetSP &brush); 0091 0092 private: 0093 struct Private; 0094 Private * const m_d; 0095 }; 0096 0097 typedef KisSharedPtr<KisResourcesSnapshot> KisResourcesSnapshotSP; 0098 0099 0100 #endif /* __KIS_RESOURCES_SNAPSHOT_H */