chalk

kis_imagepipe_brush.h
1/*
2 * Copyright (c) 2004 Boudewijn Rempt <boud@valdyas.org>
3 * Copyright (c) 2005 Bart Coppens <kde@bartcoppens.be>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19#ifndef KIS_IMAGEPIPE_BRUSH_
20#define KIS_IMAGEPIPE_BRUSH_
21
22#include <tqptrlist.h>
23#include <tqvaluelist.h>
24#include <tqvaluevector.h>
25#include <tqmap.h>
26#include <tqstring.h>
27
28#include <tdeio/job.h>
29
30#include "kis_resource.h"
31#include "kis_brush.h"
32#include "kis_global.h"
33
34class TQCString;
35class TQImage;
36class TQPoint;
37class TQSize;
38
58public:
60 KisPipeBrushParasite() : ncells(0), dim(0), needsMovement(false) {
61 for (int i = 0; i < MaxDim; i++) {
62 rank[i] = index[i] = brushesCount[i] = 0;
63 selection[i] = Constant;
64 }
65 }
66
67 void setBrushesCount();
69 KisPipeBrushParasite(const TQString& source);
73 bool saveToDevice(TQIODevice* dev) const;
74
77 Constant, Incremental, Angular, Velocity, Random, Pressure, TiltX, TiltY
78 };
79 enum Placement { DefaultPlacement, ConstantPlacement, RandomPlacement };
80 static int const MaxDim = 4;
81 //TQ_INT32 step;
82 TQ_INT32 ncells;
83 TQ_INT32 dim;
84 // Apparantly only used for editing a pipe brush, which we won't at the moment
85 // TQ_INT32 cols, rows;
86 // TQ_INT32 cellwidth, cellheight;
87 // Aparantly the gimp doesn't use this anymore? Anyway it is a bit weird to
88 // paint at someplace else than where your cursor displays it will...
89 //Placement placement;
90 TQ_INT32 rank[MaxDim];
91 SelectionMode selection[MaxDim];
93 TQ_INT32 brushesCount[MaxDim];
95 TQ_INT32 index[MaxDim];
98};
99
100
101class KisImagePipeBrush : public KisBrush {
102 typedef KisBrush super;
103 TQ_OBJECT
104
105
106public:
107 KisImagePipeBrush(const TQString& filename);
112 KisImagePipeBrush(const TQString& name, int w, int h,
113 TQValueVector< TQValueVector<KisPaintDevice*> > devices,
114 TQValueVector<KisPipeBrushParasite::SelectionMode> modes);
115 virtual ~KisImagePipeBrush();
116
117 virtual bool load();
118 virtual bool save();
120 virtual bool saveToDevice(TQIODevice* dev) const;
121
125 virtual TQImage img();
126
130 virtual KisAlphaMaskSP mask(const KisPaintInformation& info,
131 double subPixelX = 0, double subPixelY = 0) const;
132 virtual KisPaintDeviceSP image(KisColorSpace * colorSpace, const KisPaintInformation& info,
133 double subPixelX = 0, double subPixelY = 0) const;
134
135 virtual bool useColorAsMask() const;
136 virtual void setUseColorAsMask(bool useColorAsMask);
137 virtual bool hasColor() const;
138
139 virtual enumBrushType brushType() const;
140
141 virtual KisBoundary boundary();
142
143 KisPipeBrushParasite const& parasite() const { return m_parasite; }
144
145 virtual bool canPaintFor(const KisPaintInformation& info);
146
147 virtual void makeMaskImage();
148
149 virtual KisImagePipeBrush* clone() const;
150
151private:
152 bool init();
153 void setParasiteString(const TQString& parasite);
154 void selectNextBrush(const KisPaintInformation& info) const;
155
156 TQString m_name;
157 TQString m_parasiteString; // Contains instructions on how to use the brush
158 mutable KisPipeBrushParasite m_parasite;
159 TQ_UINT32 m_numOfBrushes;
160 mutable TQ_UINT32 m_currentBrush;
161
162 TQByteArray m_data;
163 mutable TQPtrList<KisBrush> m_brushes;
164
165 enumBrushType m_brushType;
166
167};
168
169#endif // KIS_IMAGEPIPE_BRUSH_
Generates an 'outline' for a paint device.
A colorspace is the definition of a certain color model in Chalk.
This class keeps information that can be used in the painting process, for example by brushes.
Definition kis_paintop.h:50
The parasite info that gets loaded from the terribly documented gimp pipe brush parasite.
KisPipeBrushParasite()
Set some default values.
TQ_INT32 brushesCount[MaxDim]
The total count of brushes in each dimension (helper).
void setBrushesCount()
Initializes the brushesCount helper.
bool saveToDevice(TQIODevice *dev) const
Saves a GIMP-compatible representation of this parasite to the device.
SelectionMode
Velocity won't be supported, atm Angular and Tilt aren't either, but have chances of implementation.
bool needsMovement
If true, the brush won't be painted when there is no motion.
TQ_INT32 index[MaxDim]
The current index in each dimension, so that the selection modes know where to start.
virtual TQImage img()=0
Returns a TQImage representing this resource.
virtual bool save()=0
Save this resource asynchronously.
virtual bool load()=0
Load this resource.