krita

kis_selection.h

00001 /*
00002  *  Copyright (c) 2004 Boudewijn Rempt <boud@valdyas.org>
00003  *
00004  *  this program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the gnu general public license as published by
00006  *  the free software foundation; either version 2 of the license, or
00007  *  (at your option) any later version.
00008  *
00009  *  this program is distributed in the hope that it will be useful,
00010  *  but without any warranty; without even the implied warranty of
00011  *  merchantability or fitness for a particular purpose.  see the
00012  *  gnu general public license for more details.
00013  *
00014  *  you should have received a copy of the gnu general public license
00015  *  along with this program; if not, write to the free software
00016  *  foundation, inc., 675 mass ave, cambridge, ma 02139, usa.
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     // Returns selectedness, or 0 if invalid coordinates
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 
00082     // Tests if the the rect is totally outside the selection
00083     bool isTotallyUnselected(QRect r);
00084 
00089     QRect selectedRect();
00090 
00095     QRect selectedExactRect();
00096 
00097     void paintSelection(QImage img, Q_INT32 x, Q_INT32 y, Q_INT32 w, Q_INT32 h);
00098     void paintSelection(QImage img, const QRect& scaledImageRect, const QSize& scaledImageSize, const QSize& imageSize);
00099 
00100 private:
00101     void paintUniformSelectionRegion(QImage img, const QRect& imageRect, const QRegion& uniformRegion);
00102 
00103 private:
00104     KisPaintDeviceSP m_parentPaintDevice;
00105 };
00106 
00107 #endif // KIS_SELECTION_H_
KDE Home | KDE Accessibility Home | Description of Access Keys