krita

kis_filter.h

00001 /*
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 #ifndef _KIS_FILTER_H_
00019 #define _KIS_FILTER_H_
00020 
00021 #include <list>
00022 
00023 #include <qstring.h>
00024 
00025 #include <ksharedptr.h>
00026 #include <klocale.h>
00027 
00028 #include "kis_types.h"
00029 #include "kis_filter_registry.h"
00030 #include "kis_id.h"
00031 #include "kis_paint_device.h"
00032 #include "kis_progress_subject.h"
00033 #include "kis_filter_configuration.h"
00034 #include "kis_colorspace.h"
00035 #include "koffice_export.h"
00036 
00037 class KisColorSpace;
00038 class KisPreviewDialog;
00039 class KisProgressDisplayInterface;
00040 class KisFilterConfigWidget;
00041 class QWidget;
00042 
00046 class KRITACORE_EXPORT KisFilter : public KisProgressSubject, public KShared {
00047     Q_OBJECT
00048 public:
00049 
00053     KisFilter(const KisID& id, const QString & category, const QString & entry);
00054     virtual ~KisFilter() {}
00055 
00056 public:
00057 
00058     virtual void setProgressDisplay(KisProgressDisplayInterface * progressDisplay);
00059 
00060     virtual void process(KisPaintDeviceSP src, KisPaintDeviceSP dst, KisFilterConfiguration*, const QRect&) = 0;
00061 
00062 public:
00067      virtual KisFilterConfiguration * configuration(QWidget*);
00068 
00073     virtual KisFilterConfiguration * configuration();
00074 
00078     virtual bool supportsPainting() { return false; };
00079 
00081     virtual bool supportsPreview() { return false; };
00082 
00084     // XXX: This uses supportsPreview() for backwards compatibility
00085     virtual bool supportsAdjustmentLayers() { return supportsPreview(); };
00086 
00091     virtual std::list<KisFilterConfiguration*> listOfExamplesConfiguration(KisPaintDeviceSP )
00092     { std::list<KisFilterConfiguration*> list; list.insert(list.begin(), 0); return list; }
00093 
00098     virtual bool supportsIncrementalPainting() { return true; };
00099 
00105     virtual bool supportsThreading() { return true; };
00106 
00112     virtual int overlapMarginNeeded(KisFilterConfiguration* = 0) const { return 0; };
00113 
00121     virtual QRect enlargeRect(QRect rect, KisFilterConfiguration* = 0) const;
00122 
00129     virtual ColorSpaceIndependence colorSpaceIndependence() { return TO_RGBA8; };
00130 
00141     virtual bool workWith(KisColorSpace*) { return true; }
00142 
00143     virtual void enableProgress();
00144     virtual void disableProgress();
00145 
00146     bool autoUpdate();
00147 
00148     // Unique identification for this filter
00149     inline const KisID id() const { return m_id; };
00150     // Which submenu in the filters menu does filter want to go?
00151 
00152     inline QString menuCategory() const { return m_category; };
00153     // The i18n'ed string this filter wants to show itself in the menu
00154 
00155     inline QString menuEntry() const { return m_entry; };
00156 
00165     virtual KisFilterConfigWidget * createConfigurationWidget(QWidget * parent, KisPaintDeviceSP dev);
00166 
00167     virtual void cancel() { m_cancelRequested = true; }
00168 
00169     virtual void setAutoUpdate(bool set);
00170     bool progressEnabled() const { return m_progressEnabled; }
00171     inline bool cancelRequested() const { return m_progressEnabled && m_cancelRequested; }
00172 
00173 protected slots:
00174 
00175     // Convenience functions for progress display.
00176     void setProgressTotalSteps(Q_INT32 totalSteps);
00177     void setProgress(Q_INT32 progress);
00178     void incProgress();
00179     void setProgressStage(const QString& stage, Q_INT32 progress);
00180     void setProgressDone();
00181     inline Q_INT32 progress() { return m_progressSteps; }
00182 private:
00183     bool m_cancelRequested;
00184     bool m_progressEnabled;
00185     bool m_autoUpdate;
00186 
00187 protected:
00188     Q_INT32 m_progressTotalSteps;
00189     Q_INT32 m_lastProgressPerCent;
00190     Q_INT32 m_progressSteps;
00191 
00192     KisID m_id;
00193     KisProgressDisplayInterface * m_progressDisplay;
00194     QString m_category; // The category in the filter menu this filter fits
00195     QString m_entry; // the i18n'ed accelerated menu text
00196 
00197 };
00198 
00199 
00200 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys