krita
kis_selection.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef KIS_SELECTION_H_
00019 #define KIS_SELECTION_H_
00020
00021 #include <qrect.h>
00022
00023 #include "kis_types.h"
00024 #include "kis_paint_device.h"
00025
00026 #include <koffice_export.h>
00027
00028
00029 enum enumSelectionMode {
00030 SELECTION_ADD,
00031 SELECTION_SUBTRACT
00032 };
00033
00043 class KRITACORE_EXPORT KisSelection : public KisPaintDevice {
00044
00045 typedef KisPaintDevice super;
00046
00047 public:
00053 KisSelection(KisPaintDeviceSP dev);
00054
00058 KisSelection();
00059
00063 KisSelection(const KisSelection& rhs);
00064
00065 virtual ~KisSelection();
00066
00067
00068 Q_UINT8 selected(Q_INT32 x, Q_INT32 y);
00069
00070 void setSelected(Q_INT32 x, Q_INT32 y, Q_UINT8 s);
00071
00072 QImage maskImage();
00073
00074 void select(QRect r);
00075
00076 void invert();
00077
00078 void clear(QRect r);
00079
00080 void clear();
00081
00083 bool isTotallyUnselected(QRect r);
00084
00091 bool isProbablyTotallyUnselected(QRect r);
00092
00097 QRect selectedRect() const;
00098
00103 QRect selectedExactRect() const;
00104
00105 void paintSelection(QImage img, Q_INT32 x, Q_INT32 y, Q_INT32 w, Q_INT32 h);
00106 void paintSelection(QImage img, const QRect& scaledImageRect, const QSize& scaledImageSize, const QSize& imageSize);
00107
00108 void startCachingExactRect();
00109 void stopCachingExactRect();
00110
00111
00112
00113 void setInterestedInDirtyness(bool b) { m_dirty = b; }
00114 bool interestedInDirtyness() const { return m_dirty; }
00115
00116 virtual void setDirty(const QRect & rc);
00117 virtual void setDirty();
00118 private:
00119 void paintUniformSelectionRegion(QImage img, const QRect& imageRect, const QRegion& uniformRegion);
00120
00121 private:
00122
00123
00124 void extent(Q_INT32 &x, Q_INT32 &y, Q_INT32 &w, Q_INT32 &h) const
00125 {
00126 KisPaintDevice::extent(x,y,w,h);
00127 }
00128
00129 QRect extent() const { return KisPaintDevice::extent(); }
00130
00131 void exactBounds(Q_INT32 &x, Q_INT32 &y, Q_INT32 &w, Q_INT32 &h) const
00132 {
00133 return KisPaintDevice::exactBounds(x,y,w,h);
00134 }
00135
00136 QRect exactBounds() const
00137 {
00138 return KisPaintDevice::extent();
00139 }
00140
00141 QRect exactBoundsOldMethod() const
00142 {
00143 return KisPaintDevice::exactBoundsOldMethod();
00144 }
00145
00146 QRect exactBoundsImprovedOldMethod() const
00147 {
00148 return KisPaintDevice::exactBoundsImprovedOldMethod();
00149 }
00150
00151
00152 private:
00153 KisPaintDeviceSP m_parentPaintDevice;
00154 bool m_doCacheExactRect;
00155 QRect m_cachedExactRect;
00156 bool m_dirty;
00157 };
00158
00159 #endif // KIS_SELECTION_H_
|