1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
/*
* Copyright (c) 2002 Patrick Julien <[email protected]>
* Copyright (c) 2004 Boudewijn Rempt <[email protected]>
* Copyright (c) 2004 Clarence Dang <[email protected]>
* Copyright (c) 2004 Adrian Page <[email protected]>
* Copyright (c) 2004 Cyrille Berger <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef KIS_PAINTOP_H_
#define KIS_PAINTOP_H_
#include <tqstring.h>
#include <ksharedptr.h>
#include <tdelocale.h>
#include "kis_global.h"
#include "kis_types.h"
#include "kis_id.h"
#include "kis_vec.h"
#include "kis_colorspace.h"
#include <koffice_export.h>
class KisPoint;
class KisAlphaMask;
class KisPainter;
class KisColorSpace;
class KisInputDevice;
class TQWidget;
/**
* This class keeps information that can be used in the painting process, for example by
* brushes.
**/
class KRITACORE_EXPORT KisPaintInformation {
public:
KisPaintInformation(double pressure = PRESSURE_DEFAULT,
double xTilt = 0.0, double yTilt = 0.0,
KisVector2D movement = KisVector2D())
: pressure(pressure), xTilt(xTilt), yTilt(yTilt), movement(movement) {}
double pressure;
double xTilt;
double yTilt;
KisVector2D movement;
};
class KRITACORE_EXPORT KisPaintOp : public TDEShared
{
public:
KisPaintOp(KisPainter * painter);
virtual ~KisPaintOp();
virtual void paintAt(const KisPoint &pos, const KisPaintInformation& info) = 0;
void setSource(KisPaintDeviceSP p);
/**
* Whether this paintop wants to deposit paint even when not moving, i.e. the
* tool needs to activate its timer.
*/
virtual bool incremental() { return false; }
protected:
virtual KisPaintDeviceSP computeDab(KisAlphaMaskSP mask);
virtual KisPaintDeviceSP computeDab(KisAlphaMaskSP mask, KisColorSpace *cs);
/**
* Split the coordinate into whole + fraction, where fraction is always >= 0.
*/
virtual void splitCoordinate(double coordinate, TQ_INT32 *whole, double *fraction);
KisPainter * m_painter;
KisPaintDeviceSP m_source; // use this layer as source layer for the operation
private:
KisPaintDeviceSP m_dab;
};
class KisPaintOpSettings {
public:
KisPaintOpSettings(TQWidget *parent) { Q_UNUSED(parent); }
virtual ~KisPaintOpSettings() {}
virtual TQWidget *widget() const { return 0; }
};
/**
* The paintop factory is responsible for creating paintops of the specified class.
* If there is an optionWidget, the derived paintop itself must support settings,
* and it's up to the factory to do that.
*/
class KisPaintOpFactory : public TDEShared
{
public:
KisPaintOpFactory() {}
virtual ~KisPaintOpFactory() {}
virtual KisPaintOp * createOp(const KisPaintOpSettings *settings, KisPainter * painter) = 0;
virtual KisID id() { return KisID("abstractpaintop", i18n("Abstract PaintOp")); }
/**
* The filename of the pixmap we can use to represent this paintop in the ui.
*/
virtual TQString pixmap() { return ""; }
/**
* Whether this paintop is internal to a certain tool or can be used
* in various tools. If false, it won't show up in the toolchest.
* The KisColorSpace argument can be used when certain paintops only support a specific cs
*/
virtual bool userVisible(KisColorSpace * cs = 0) { return cs->id() != KisID("WET", ""); }
/**
* Create and return an (abstracted) widget with options for this paintop when used with the
* specified input device. Return 0 if there are no settings available for the given
* device.
*/
virtual KisPaintOpSettings* settings(TQWidget* parent, const KisInputDevice& inputDevice);
};
#endif // KIS_PAINTOP_H_
|