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 
00078     virtual std::list<KisFilterConfiguration*> listOfExamplesConfiguration(KisPaintDeviceSP )
00079     { std::list<KisFilterConfiguration*> list; list.insert(list.begin(), 0); return list; }
00080 
00085     virtual bool supportsIncrementalPainting() { return true; };
00086 
00092     virtual bool supportsThreading() { return true; };
00093 
00099     virtual int overlapMarginNeeded() { return 0; };
00100 
00107     virtual ColorSpaceIndependence colorSpaceIndependence() { return TO_RGBA8; };
00108     
00119     virtual bool workWith(KisColorSpace*) { return true; }
00120     
00121     virtual void enableProgress();
00122     virtual void disableProgress();
00123 
00124     bool autoUpdate();
00125 
00126     // Unique identification for this filter
00127     inline const KisID id() const { return m_id; };
00128     // Which submenu in the filters menu does filter want to go?
00129 
00130     inline QString menuCategory() const { return m_category; };
00131     // The i18n'ed string this filter wants to show itself in the menu
00132 
00133     inline QString menuEntry() const { return m_entry; };
00134 
00141     virtual KisFilterConfigWidget * createConfigurationWidget(QWidget * parent, KisPaintDeviceSP dev);
00142 
00143     virtual void cancel() { m_cancelRequested = true; }
00144 
00145     virtual void setAutoUpdate(bool set);
00146     bool progressEnabled() const { return m_progressEnabled; }
00147     inline bool cancelRequested() const { return m_progressEnabled && m_cancelRequested; }
00148 
00149 protected slots:
00150 
00151     // Convenience functions for progress display.
00152     void setProgressTotalSteps(Q_INT32 totalSteps);
00153     void setProgress(Q_INT32 progress);
00154     void incProgress();
00155     void setProgressStage(const QString& stage, Q_INT32 progress);
00156     void setProgressDone();
00157     inline Q_INT32 progress() { return m_progressSteps; }
00158 private:
00159     bool m_cancelRequested;
00160     bool m_progressEnabled;
00161     bool m_autoUpdate;
00162 
00163 protected:
00164     Q_INT32 m_progressTotalSteps;
00165     Q_INT32 m_lastProgressPerCent;
00166     Q_INT32 m_progressSteps;
00167 
00168     KisID m_id;
00169     KisProgressDisplayInterface * m_progressDisplay;
00170     QString m_category; // The category in the filter menu this filter fits
00171     QString m_entry; // the i18n'ed accelerated menu text
00172 
00173 };
00174 
00175 
00176 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys