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_progress_subject.h"
00032 #include "kis_filter_configuration.h"
00033 #include "kis_colorspace.h"
00034 #include "koffice_export.h"
00035 
00036 class KisColorSpace;
00037 class KisPreviewDialog;
00038 class KisProgressDisplayInterface;
00039 class KisFilterConfigWidget;
00040 class QWidget;
00041 
00045 class KRITACORE_EXPORT KisFilter : public KisProgressSubject, public KShared {
00046     Q_OBJECT
00047 public:
00048 
00052     KisFilter(const KisID& id, const QString & category, const QString & entry);
00053     virtual ~KisFilter() {}
00054 
00055 public:
00056 
00057     virtual void setProgressDisplay(KisProgressDisplayInterface * progressDisplay);
00058 
00059     virtual void process(KisPaintDeviceSP src, KisPaintDeviceSP dst, KisFilterConfiguration*, const QRect&) = 0;
00060 
00061 public:
00062     virtual KisFilterConfiguration * configuration(QWidget*);
00063     virtual KisFilterConfiguration * configuration();
00064             
00068     virtual bool supportsPainting() { return false; };
00069 
00071     virtual bool supportsPreview() { return false; };
00072 
00077     virtual std::list<KisFilterConfiguration*> listOfExamplesConfiguration(KisPaintDeviceSP )
00078     { std::list<KisFilterConfiguration*> list; list.insert(list.begin(), 0); return list; }
00079 
00084     virtual bool supportsIncrementalPainting() { return true; };
00085 
00091     virtual bool supportsThreading() { return true; };
00092 
00098     virtual int overlapMarginNeeded() { return 0; };
00099 
00106     virtual ColorSpaceIndependence colorSpaceIndependence() { return TO_RGBA8; };
00107     
00118     virtual bool workWith(KisColorSpace*) { return true; }
00119     
00120     virtual void enableProgress();
00121     virtual void disableProgress();
00122 
00123     bool autoUpdate();
00124 
00125     // Unique identification for this filter
00126     inline const KisID id() const { return m_id; };
00127     // Which submenu in the filters menu does filter want to go?
00128 
00129     inline QString menuCategory() const { return m_category; };
00130     // The i18n'ed string this filter wants to show itself in the menu
00131 
00132     inline QString menuEntry() const { return m_entry; };
00133 
00140     virtual KisFilterConfigWidget * createConfigurationWidget(QWidget * parent, KisPaintDeviceSP dev);
00141 
00142     virtual void cancel() { m_cancelRequested = true; }
00143 
00144     virtual void setAutoUpdate(bool set);
00145     bool progressEnabled() const { return m_progressEnabled; }
00146     inline bool cancelRequested() const { return m_progressEnabled && m_cancelRequested; }
00147 
00148 protected slots:
00149 
00150     // Convenience functions for progress display.
00151     void setProgressTotalSteps(Q_INT32 totalSteps);
00152     void setProgress(Q_INT32 progress);
00153     void incProgress();
00154     void setProgressStage(const QString& stage, Q_INT32 progress);
00155     void setProgressDone();
00156     inline Q_INT32 progress() { return m_progressSteps; }
00157 private:
00158     bool m_cancelRequested;
00159     bool m_progressEnabled;
00160     bool m_autoUpdate;
00161 
00162 protected:
00163     Q_INT32 m_progressTotalSteps;
00164     Q_INT32 m_lastProgressPerCent;
00165     Q_INT32 m_progressSteps;
00166 
00167     KisID m_id;
00168     KisProgressDisplayInterface * m_progressDisplay;
00169     QString m_category; // The category in the filter menu this filter fits
00170     QString m_entry; // the i18n'ed accelerated menu text
00171 
00172 };
00173 
00174 
00175 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys