krita

kis_imagepipe_brush.h

00001 /*
00002  *  Copyright (c) 2004 Boudewijn Rempt <boud@valdyas.org>
00003  *  Copyright (c) 2005 Bart Coppens <kde@bartcoppens.be>
00004  *
00005  *  This program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2 of the License, or
00008  *  (at your option) any later version.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018  */
00019 #ifndef KIS_IMAGEPIPE_BRUSH_
00020 #define KIS_IMAGEPIPE_BRUSH_
00021 
00022 #include <qptrlist.h>
00023 #include <qvaluelist.h>
00024 #include <qvaluevector.h>
00025 #include <qmap.h>
00026 #include <qstring.h>
00027 
00028 #include <kio/job.h>
00029 
00030 #include "kis_resource.h"
00031 #include "kis_brush.h"
00032 #include "kis_global.h"
00033 
00034 class QCString;
00035 class QImage;
00036 class QPoint;
00037 class QSize;
00038 
00057 class KisPipeBrushParasite {
00058 public:
00060     KisPipeBrushParasite() : ncells(0), dim(0), needsMovement(false) {
00061         for (int i = 0; i < MaxDim; i++) {
00062             rank[i] = index[i] = brushesCount[i] = 0;
00063             selection[i] = Constant;
00064         }
00065     }
00067     void setBrushesCount();
00069     KisPipeBrushParasite(const QString& source);
00073     bool saveToDevice(QIODevice* dev) const;
00074 
00076     enum SelectionMode {
00077         Constant, Incremental, Angular, Velocity, Random, Pressure, TiltX, TiltY
00078     };
00079     enum Placement { DefaultPlacement, ConstantPlacement, RandomPlacement };
00080     static int const MaxDim = 4;
00081     //Q_INT32 step;
00082     Q_INT32 ncells;
00083     Q_INT32 dim;
00084     // Apparantly only used for editing a pipe brush, which we won't at the moment
00085     // Q_INT32 cols, rows;
00086     // Q_INT32 cellwidth, cellheight;
00087     // Aparantly the gimp doesn't use this anymore? Anyway it is a bit weird to
00088     // paint at someplace else than where your cursor displays it will...
00089     //Placement placement;
00090     Q_INT32 rank[MaxDim];
00091     SelectionMode selection[MaxDim];
00093     Q_INT32 brushesCount[MaxDim];
00095     Q_INT32 index[MaxDim];
00097     bool needsMovement;
00098 };
00099 
00100 
00101 class KisImagePipeBrush : public KisBrush {
00102     typedef KisBrush super;
00103     Q_OBJECT
00104 
00105 public:
00106     KisImagePipeBrush(const QString& filename);
00111     KisImagePipeBrush(const QString& name, int w, int h,
00112                       QValueVector< QValueVector<KisPaintDevice*> > devices,
00113                       QValueVector<KisPipeBrushParasite::SelectionMode> modes);
00114     virtual ~KisImagePipeBrush();
00115 
00116     virtual bool load();
00117     virtual bool save();
00119     virtual bool saveToDevice(QIODevice* dev) const;
00120 
00124     virtual QImage img();
00125 
00129     virtual KisAlphaMaskSP mask(const KisPaintInformation& info,
00130                                 double subPixelX = 0, double subPixelY = 0) const;
00131     virtual KisPaintDeviceSP image(KisColorSpace * colorSpace, const KisPaintInformation& info,
00132                              double subPixelX = 0, double subPixelY = 0) const;
00133 
00134     virtual bool useColorAsMask() const;
00135     virtual void setUseColorAsMask(bool useColorAsMask);
00136     virtual bool hasColor() const;
00137 
00138     virtual enumBrushType brushType() const;
00139     
00140     virtual KisBoundary boundary();
00141     
00142     KisPipeBrushParasite const& parasite() const { return m_parasite; }
00143     
00144     virtual bool canPaintFor(const KisPaintInformation& info);
00145 
00146     virtual void makeMaskImage();
00147 
00148     virtual KisImagePipeBrush* clone() const;
00149 
00150 private:
00151     bool init();
00152     void setParasiteString(const QString& parasite);
00153     void selectNextBrush(const KisPaintInformation& info) const;
00154 
00155     QString m_name;
00156     QString m_parasiteString; // Contains instructions on how to use the brush
00157     mutable KisPipeBrushParasite m_parasite;
00158     Q_UINT32 m_numOfBrushes;
00159     mutable Q_UINT32 m_currentBrush;
00160 
00161     QByteArray m_data;
00162     mutable QPtrList<KisBrush> m_brushes;
00163 
00164     enumBrushType m_brushType;
00165     
00166 };
00167 
00168 #endif // KIS_IMAGEPIPE_BRUSH_
KDE Home | KDE Accessibility Home | Description of Access Keys