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:
00063     virtual KisFilterConfiguration * configuration(QWidget*);
00064     virtual KisFilterConfiguration * configuration();
00065             
00069     virtual bool supportsPainting() { return false; };
00070 
00072     virtual bool supportsPreview() { return false; };
00073 
00075     // XXX: This uses supportsPreview() for backwards compatibility
00076     virtual bool supportsAdjustmentLayers() { return supportsPreview(); };
00077 
00082     virtual std::list<KisFilterConfiguration*> listOfExamplesConfiguration(KisPaintDeviceSP )
00083     { std::list<KisFilterConfiguration*> list; list.insert(list.begin(), 0); return list; }
00084 
00089     virtual bool supportsIncrementalPainting() { return true; };
00090 
00096     virtual bool supportsThreading() { return true; };
00097 
00103     virtual int overlapMarginNeeded(KisFilterConfiguration* = 0) const { return 0; };
00104 
00112     virtual QRect enlargeRect(QRect rect, KisFilterConfiguration* = 0) const;
00113 
00120     virtual ColorSpaceIndependence colorSpaceIndependence() { return TO_RGBA8; };
00121     
00132     virtual bool workWith(KisColorSpace*) { return true; }
00133     
00134     virtual void enableProgress();
00135     virtual void disableProgress();
00136 
00137     bool autoUpdate();
00138 
00139     // Unique identification for this filter
00140     inline const KisID id() const { return m_id; };
00141     // Which submenu in the filters menu does filter want to go?
00142 
00143     inline QString menuCategory() const { return m_category; };
00144     // The i18n'ed string this filter wants to show itself in the menu
00145 
00146     inline QString menuEntry() const { return m_entry; };
00147 
00154     virtual KisFilterConfigWidget * createConfigurationWidget(QWidget * parent, KisPaintDeviceSP dev);
00155 
00156     virtual void cancel() { m_cancelRequested = true; }
00157 
00158     virtual void setAutoUpdate(bool set);
00159     bool progressEnabled() const { return m_progressEnabled; }
00160     inline bool cancelRequested() const { return m_progressEnabled && m_cancelRequested; }
00161 
00162 protected slots:
00163 
00164     // Convenience functions for progress display.
00165     void setProgressTotalSteps(Q_INT32 totalSteps);
00166     void setProgress(Q_INT32 progress);
00167     void incProgress();
00168     void setProgressStage(const QString& stage, Q_INT32 progress);
00169     void setProgressDone();
00170     inline Q_INT32 progress() { return m_progressSteps; }
00171 private:
00172     bool m_cancelRequested;
00173     bool m_progressEnabled;
00174     bool m_autoUpdate;
00175 
00176 protected:
00177     Q_INT32 m_progressTotalSteps;
00178     Q_INT32 m_lastProgressPerCent;
00179     Q_INT32 m_progressSteps;
00180 
00181     KisID m_id;
00182     KisProgressDisplayInterface * m_progressDisplay;
00183     QString m_category; // The category in the filter menu this filter fits
00184     QString m_entry; // the i18n'ed accelerated menu text
00185 
00186 };
00187 
00188 
00189 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys