krita

kis_paintop.h

00001 /*
00002  *  Copyright (c) 2002 Patrick Julien <freak@codepimps.org>
00003  *  Copyright (c) 2004 Boudewijn Rempt <boud@valdyas.org>
00004  *  Copyright (c) 2004 Clarence Dang <dang@kde.org>
00005  *  Copyright (c) 2004 Adrian Page <adrian@pagenet.plus.com>
00006  *  Copyright (c) 2004 Cyrille Berger <cberger@cberger.net>
00007  *
00008  *  This program is free software; you can redistribute it and/or modify
00009  *  it under the terms of the GNU General Public License as published by
00010  *  the Free Software Foundation; either version 2 of the License, or
00011  *  (at your option) any later version.
00012  *
00013  *  This program is distributed in the hope that it will be useful,
00014  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  *  GNU General Public License for more details.
00017  *
00018  *  You should have received a copy of the GNU General Public License
00019  *  along with this program; if not, write to the Free Software
00020  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00021  */
00022 
00023 #ifndef KIS_PAINTOP_H_
00024 #define KIS_PAINTOP_H_
00025 
00026 #include <qstring.h>
00027 
00028 #include <ksharedptr.h>
00029 #include <klocale.h>
00030 
00031 #include "kis_global.h"
00032 #include "kis_types.h"
00033 #include "kis_id.h"
00034 #include "kis_vec.h"
00035 #include "kis_colorspace.h"
00036 
00037 #include <koffice_export.h>
00038 
00039 class KisPoint;
00040 class KisAlphaMask;
00041 class KisPainter;
00042 class KisColorSpace;
00043 class KisInputDevice;
00044 class QWidget;
00045 
00050 class KRITACORE_EXPORT KisPaintInformation {
00051 public:
00052     KisPaintInformation(double pressure = PRESSURE_DEFAULT,
00053                         double xTilt = 0.0, double yTilt = 0.0,
00054                         KisVector2D movement = KisVector2D())
00055         : pressure(pressure), xTilt(xTilt), yTilt(yTilt), movement(movement) {}
00056     double pressure;
00057     double xTilt;
00058     double yTilt;
00059     KisVector2D movement;
00060 };
00061 
00062 class KRITACORE_EXPORT KisPaintOp : public KShared
00063 {
00064 
00065 public:
00066 
00067     KisPaintOp(KisPainter * painter);
00068     virtual ~KisPaintOp();
00069 
00070     virtual void paintAt(const KisPoint &pos, const KisPaintInformation& info) = 0;
00071     void setSource(KisPaintDeviceSP p);
00072 
00077     virtual bool incremental() { return false; }
00078 
00079 
00080 protected:
00081 
00082     virtual KisPaintDeviceSP computeDab(KisAlphaMaskSP mask);
00083     virtual KisPaintDeviceSP computeDab(KisAlphaMaskSP mask, KisColorSpace *cs);
00084 
00085 
00089     virtual void splitCoordinate(double coordinate, Q_INT32 *whole, double *fraction);
00090 
00091     KisPainter * m_painter;
00092     KisPaintDeviceSP m_source; // use this layer as source layer for the operation
00093 private:
00094     KisPaintDeviceSP m_dab;
00095 };
00096 
00097 class KisPaintOpSettings {
00098 
00099 public:
00100     KisPaintOpSettings(QWidget *parent) { Q_UNUSED(parent); }
00101     virtual ~KisPaintOpSettings() {}
00102 
00103     virtual QWidget *widget() const { return 0; }
00104 };
00105 
00111 class KisPaintOpFactory  : public KShared
00112 {
00113 
00114 public:
00115     KisPaintOpFactory() {}
00116     virtual ~KisPaintOpFactory() {}
00117 
00118     virtual KisPaintOp * createOp(const KisPaintOpSettings *settings, KisPainter * painter) = 0;
00119     virtual KisID id() { return KisID("abstractpaintop", i18n("Abstract PaintOp")); }
00120 
00124     virtual QString pixmap() { return ""; }
00125 
00131     virtual bool userVisible(KisColorSpace * cs = 0) { return cs->id() != KisID("WET", ""); }
00132 
00138     virtual KisPaintOpSettings* settings(QWidget* parent, const KisInputDevice& inputDevice);
00139 
00140 };
00141 #endif // KIS_PAINTOP_H_
KDE Home | KDE Accessibility Home | Description of Access Keys