chalk

kis_filter.h
1/*
2 * Copyright (c) 2004 Cyrille Berger <cberger@cberger.net>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18#ifndef _KIS_FILTER_H_
19#define _KIS_FILTER_H_
20
21#include <list>
22
23#include <tqstring.h>
24
25#include <ksharedptr.h>
26#include <tdelocale.h>
27
28#include "kis_types.h"
29#include "kis_filter_registry.h"
30#include "kis_id.h"
31#include "kis_paint_device.h"
32#include "kis_progress_subject.h"
33#include "kis_filter_configuration.h"
34#include "kis_colorspace.h"
35#include "koffice_export.h"
36
37class KisColorSpace;
38class KisPreviewDialog;
39class KisProgressDisplayInterface;
41class TQWidget;
42
46class KRITACORE_EXPORT KisFilter : public KisProgressSubject, public TDEShared {
47 TQ_OBJECT
48
49public:
50
54 KisFilter(const KisID& id, const TQString & category, const TQString & entry);
55 virtual ~KisFilter() {}
56
57public:
58
59 virtual void setProgressDisplay(KisProgressDisplayInterface * progressDisplay);
60
61 virtual void process(KisPaintDeviceSP src, KisPaintDeviceSP dst, KisFilterConfiguration*, const TQRect&) = 0;
62
63public:
68 virtual KisFilterConfiguration * configuration(TQWidget*);
69
75
79 virtual bool supportsPainting() { return false; };
80
82 virtual bool supportsPreview() { return false; };
83
85 // XXX: This uses supportsPreview() for backwards compatibility
86 virtual bool supportsAdjustmentLayers() { return supportsPreview(); };
87
92 virtual std::list<KisFilterConfiguration*> listOfExamplesConfiguration(KisPaintDeviceSP )
93 { std::list<KisFilterConfiguration*> list; list.insert(list.begin(), 0); return list; }
94
99 virtual bool supportsIncrementalPainting() { return true; };
100
106 virtual bool supportsThreading() { return true; };
107
113 virtual int overlapMarginNeeded(KisFilterConfiguration* = 0) const { return 0; };
114
122 virtual TQRect enlargeRect(TQRect rect, KisFilterConfiguration* = 0) const;
123
130 virtual ColorSpaceIndependence colorSpaceIndependence() { return TO_RGBA8; };
131
142 virtual bool workWith(KisColorSpace*) { return true; }
143
144 virtual void enableProgress();
145 virtual void disableProgress();
146
147 bool autoUpdate();
148
149 // Unique identification for this filter
150 inline const KisID id() const { return m_id; };
151 // Which submenu in the filters menu does filter want to go?
152
153 inline TQString menuCategory() const { return m_category; };
154 // The i18n'ed string this filter wants to show itself in the menu
155
156 inline TQString menuEntry() const { return m_entry; };
157
166 virtual KisFilterConfigWidget * createConfigurationWidget(TQWidget * parent, KisPaintDeviceSP dev);
167
168 virtual void cancel() { m_cancelRequested = true; }
169
170 virtual void setAutoUpdate(bool set);
171 bool progressEnabled() const { return m_progressEnabled; }
172 inline bool cancelRequested() const { return m_progressEnabled && m_cancelRequested; }
173
174protected slots:
175
176 // Convenience functions for progress display.
177 void setProgressTotalSteps(TQ_INT32 totalSteps);
178 void setProgress(TQ_INT32 progress);
179 void incProgress();
180 void setProgressStage(const TQString& stage, TQ_INT32 progress);
181 void setProgressDone();
182 inline TQ_INT32 progress() { return m_progressSteps; }
183private:
184 bool m_cancelRequested;
185 bool m_progressEnabled;
186 bool m_autoUpdate;
187
188protected:
189 TQ_INT32 m_progressTotalSteps;
190 TQ_INT32 m_lastProgressPerCent;
191 TQ_INT32 m_progressSteps;
192
193 KisID m_id;
194 KisProgressDisplayInterface * m_progressDisplay;
195 TQString m_category; // The category in the filter menu this filter fits
196 TQString m_entry; // the i18n'ed accelerated menu text
197
198};
199
200
201#endif
A colorspace is the definition of a certain color model in Chalk.
A KisFilterConfiguration is the serializable representation of the filter parameters.
virtual int overlapMarginNeeded(KisFilterConfiguration *=0) const
Used when threading is used – the overlap margin is passed to the filter to use to compute pixels,...
Definition kis_filter.h:113
virtual bool supportsPreview()
This filter can be displayed in a preview dialog.
Definition kis_filter.h:82
virtual bool workWith(KisColorSpace *)
Determine if this filter can work with this colorSpace.
Definition kis_filter.h:142
virtual bool supportsIncrementalPainting()
Can this filter work incrementally when painting, or do we need to work on the state as it was before...
Definition kis_filter.h:99
virtual KisFilterConfiguration * configuration(TQWidget *)
KisFilter(const KisID &id, const TQString &category, const TQString &entry)
Construct a Chalk filter.
virtual ColorSpaceIndependence colorSpaceIndependence()
Determine the colorspace independence of this filter.
Definition kis_filter.h:130
virtual std::list< KisFilterConfiguration * > listOfExamplesConfiguration(KisPaintDeviceSP)
Return a list of default configuration to demonstrates the use of the filter.
Definition kis_filter.h:92
virtual bool supportsPainting()
If true, this filter can be used in painting tools as a paint operation.
Definition kis_filter.h:79
virtual bool supportsAdjustmentLayers()
This filter can be used in adjustment layers.
Definition kis_filter.h:86
virtual bool supportsThreading()
This filter supports cutting up the work area and filtering each chunk in a separate thread.
Definition kis_filter.h:106
Chalk has a large number of extensible resources.
Definition kis_id.h:57