krita
kis_paint_layer.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef KIS_PAINT_LAYER_H_
00019 #define KIS_PAINT_LAYER_H_
00020
00021 #include "kis_types.h"
00022 #include "kis_layer.h"
00023 #include "kis_paint_device.h"
00024 #include "kis_colorspace.h"
00028 class KisPaintLayer : public KisLayer, public KisLayerSupportsIndirectPainting {
00029 typedef KisLayer super;
00030
00031 Q_OBJECT
00032
00033 public:
00034 KisPaintLayer(KisImage *img, const QString& name, Q_UINT8 opacity, KisPaintDeviceSP dev);
00035 KisPaintLayer(KisImage *img, const QString& name, Q_UINT8 opacity);
00036 KisPaintLayer(KisImage *img, const QString& name, Q_UINT8 opacity, KisColorSpace * colorSpace);
00037 KisPaintLayer(const KisPaintLayer& rhs);
00038 virtual ~KisPaintLayer();
00039
00040 virtual KisLayerSP clone() const;
00041 public:
00042
00043
00044 virtual void activate() {}
00045
00046
00047 virtual void deactivate() {}
00048
00049 virtual Q_INT32 x() const;
00050 virtual void setX(Q_INT32 x);
00051
00052 virtual Q_INT32 y() const;
00053 virtual void setY(Q_INT32 y);
00054
00055 virtual QRect extent() const;
00056 virtual QRect exactBounds() const;
00057
00058 virtual void paintSelection(QImage &img, Q_INT32 x, Q_INT32 y, Q_INT32 w, Q_INT32 h);
00059 virtual void paintSelection(QImage &img, const QRect& scaledImageRect, const QSize& scaledImageSize, const QSize& imageSize);
00060
00061 virtual void paintMaskInactiveLayers(QImage &img, Q_INT32 x, Q_INT32 y, Q_INT32 w, Q_INT32 h);
00062
00063 virtual QImage createThumbnail(Q_INT32 w, Q_INT32 h);
00064
00065 virtual bool accept(KisLayerVisitor &v)
00066 {
00067
00068
00069 return v.visit(this);
00070 }
00071
00072
00073 inline KisPaintDeviceSP paintDevice() const { return m_paintdev; }
00074
00076 inline KisPaintDeviceSP paintDeviceOrMask() const {
00077 if (hasMask() && editMask())
00078 return m_mask;
00079 return m_paintdev;
00080 }
00081
00082
00083
00085 bool hasMask() const { return m_mask != 0; }
00086
00088 KisPaintDeviceSP createMask();
00090 void createMaskFromPaintDevice(KisPaintDeviceSP from);
00095 void createMaskFromSelection(KisSelectionSP from);
00097 void removeMask();
00099 void applyMask();
00101 KisPaintDeviceSP getMask();
00103 KisSelectionSP getMaskAsSelection();
00104
00106 KNamedCommand* createMaskCommand();
00108 KNamedCommand* maskFromSelectionCommand();
00110 KNamedCommand* maskToSelectionCommand();
00112 KNamedCommand* removeMaskCommand();
00114 KNamedCommand* applyMaskCommand();
00115
00117 bool renderMask() const { return m_renderMask; }
00119 void setRenderMask(bool b);
00120
00126 bool editMask() const { return m_editMask; }
00128 void setEditMask(bool b);
00129
00131 virtual void setDirty(bool propagate = true);
00133 virtual void setDirty(const QRect & rect, bool propagate = true);
00134
00135
00136 virtual KisLayer* layer() { return this; }
00137 signals:
00139 void sigMaskInfoChanged();
00140
00141 private:
00142 void convertMaskToSelection(const QRect& r);
00143 void genericMaskCreationHelper();
00144 KisPaintDeviceSP m_paintdev;
00145
00146
00147 KisPaintDeviceSP m_mask;
00148 KisSelectionSP m_maskAsSelection;
00149 bool m_renderMask;
00150 bool m_editMask;
00151 };
00152
00153 typedef KSharedPtr<KisPaintLayer> KisPaintLayerSP;
00154
00155 #endif // KIS_PAINT_LAYER_H_
00156
|