krita

kis_iterators_pixel.h

00001 /* This file is part of the KDE project
00002  *  Copyright (c) 2004 Cyrille Berger <cberger@cberger.net>
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017 */
00018 
00019 #ifndef KIS_ITERATORS_PIXEL_H_
00020 #define KIS_ITERATORS_PIXEL_H_
00021 
00022 #include "kis_iterator.h"
00023 #include "kis_iteratorpixeltrait.h"
00024 
00032 class KisHLineIteratorPixel : public KisHLineIterator, public KisIteratorPixelTrait <KisHLineIterator>
00033 {
00034 
00035 public:
00036 
00037     KisHLineIteratorPixel( KisPaintDevice *ndevice, KisDataManager *dm, KisDataManager *sel_dm,
00038                            Q_INT32 x , Q_INT32 y , Q_INT32 w, Q_INT32 offsetx, Q_INT32 offsety,
00039                            bool writable);
00040     
00041     KisHLineIteratorPixel(const KisHLineIteratorPixel& rhs) : KisHLineIterator(rhs), KisIteratorPixelTrait<KisHLineIterator>(rhs)
00042         { m_offsetx = rhs.m_offsetx;  m_offsety = rhs.m_offsety; }
00043         
00044     KisHLineIteratorPixel& operator=(const KisHLineIteratorPixel& rhs)
00045         {
00046           KisHLineIterator::operator=(rhs);
00047           KisIteratorPixelTrait<KisHLineIterator>::operator=(rhs);
00048           m_offsetx = rhs.m_offsetx;  m_offsety = rhs.m_offsety;
00049           return *this;
00050         }
00051 
00052     inline KisHLineIteratorPixel & operator ++() { KisHLineIterator::operator++(); advance(1); return *this;}
00053     inline KisHLineIteratorPixel & operator --() { KisHLineIterator::operator--(); retreat(); return *this;}
00054 
00055     inline void nextRow() {
00056       KisHLineIterator::nextRow();
00057       if (m_selectionIterator) m_selectionIterator->nextRow();
00058     }
00059 
00061     KisHLineIteratorPixel & operator+=(int n) { KisHLineIterator::operator+=(n); advance(n); return *this; };
00062 
00063     Q_INT32 x() const { return KisHLineIterator::x() + m_offsetx; }
00064     
00065     Q_INT32 y() const { return KisHLineIterator::y() + m_offsety; }
00066     
00067     Q_INT32 nConseqHPixels() const {
00068         if (m_selectionIterator) {
00069             Q_INT32 parent = KisHLineIteratorPixel::nConseqHPixels();
00070             Q_INT32 selection = m_selectionIterator->nConseqHPixels();
00071             if (parent < selection)
00072                 return parent;
00073             return selection;
00074         }
00075         return KisHLineIteratorPixel::nConseqHPixels();
00076     }
00077 protected:
00078 
00079     Q_INT32 m_offsetx, m_offsety;
00080 };
00081 
00082 class KisVLineIteratorPixel : public KisVLineIterator, public KisIteratorPixelTrait <KisVLineIterator>
00083 {
00084 public:
00085     KisVLineIteratorPixel( KisPaintDevice *ndevice, KisDataManager *dm, KisDataManager *sel_dm,
00086                            Q_INT32 xpos , Q_INT32 ypos , Q_INT32 height, Q_INT32 offsetx, Q_INT32 offsety,
00087                            bool writable);
00088                            
00089     KisVLineIteratorPixel(const KisVLineIteratorPixel& rhs) : KisVLineIterator(rhs), KisIteratorPixelTrait<KisVLineIterator>(rhs)
00090         { m_offsetx = rhs.m_offsetx;  m_offsety = rhs.m_offsety; }
00091         
00092     KisVLineIteratorPixel& operator=(const KisVLineIteratorPixel& rhs)
00093         {
00094           KisVLineIterator::operator=(rhs);
00095           KisIteratorPixelTrait<KisVLineIterator>::operator=(rhs);
00096           m_offsetx = rhs.m_offsetx;  m_offsety = rhs.m_offsety;
00097           return *this; }
00098 
00099     inline KisVLineIteratorPixel & operator ++() { KisVLineIterator::operator++(); advance(1); return *this;}
00100 
00101     inline void nextRow() {
00102       KisVLineIterator::nextCol();
00103       if (m_selectionIterator) m_selectionIterator->nextCol();
00104     }
00105 
00106     Q_INT32 x() const { return KisVLineIterator::x() + m_offsetx; }
00107     
00108     Q_INT32 y() const { return KisVLineIterator::y() + m_offsety; }
00109 
00110 protected:
00111 
00112     Q_INT32 m_offsetx, m_offsety;
00113 };
00114 
00115 class KisRectIteratorPixel : public KisRectIterator, public KisIteratorPixelTrait <KisRectIterator>
00116 {
00117 public:
00118     KisRectIteratorPixel( KisPaintDevice *ndevice, KisDataManager *dm, KisDataManager *sel_dm,
00119                           Q_INT32 x, Q_INT32 y, Q_INT32 w, Q_INT32 h, Q_INT32 offsetx, Q_INT32 offsety,
00120                           bool writable);
00121     
00122     KisRectIteratorPixel(const KisRectIteratorPixel& rhs) : KisRectIterator(rhs), KisIteratorPixelTrait<KisRectIterator>(rhs)
00123         { m_offsetx = rhs.m_offsetx;  m_offsety = rhs.m_offsety; }
00124         
00125     KisRectIteratorPixel& operator=(const KisRectIteratorPixel& rhs)
00126         {
00127           KisRectIterator::operator=(rhs);
00128           KisIteratorPixelTrait<KisRectIterator>::operator=(rhs);
00129           m_offsetx = rhs.m_offsetx;  m_offsety = rhs.m_offsety;
00130           return *this; }
00131 
00132     inline KisRectIteratorPixel & operator ++() { KisRectIterator::operator++(); advance(1); return *this;}
00133 
00134     Q_INT32 x() const { return KisRectIterator::x() + m_offsetx; }
00135     
00136     Q_INT32 y() const { return KisRectIterator::y() + m_offsety; }
00137 
00138     Q_INT32 nConseqPixels() const {
00139         if (m_selectionIterator) {
00140             Q_INT32 parent = KisRectIterator::nConseqPixels();
00141             Q_INT32 selection = m_selectionIterator->nConseqPixels();
00142             if (parent < selection)
00143                 return parent;
00144             return selection;
00145         }
00146         return KisRectIterator::nConseqPixels();
00147     }
00148 
00149 protected:
00150 
00151     Q_INT32 m_offsetx, m_offsety;
00152 };
00153 
00154 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys