chalk

kis_image.h
1/*
2 * Copyright (c) 2002 Patrick Julien <freak@codepimps.org>
3 * 2006 Boudewijn Rempt <boud@valdyas.org>
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_IMAGE_H_
20#define KIS_IMAGE_H_
21
22#include <tqobject.h>
23#include <tqstring.h>
24#include <tqvaluevector.h>
25#include <tqmutex.h>
26
27#include <config.h>
28
29#include <ksharedptr.h>
30#include <kurl.h>
31
32#include "KoUnit.h"
33
34#include "kis_composite_op.h"
35#include "kis_global.h"
36#include "kis_types.h"
37#include "kis_annotation.h"
38#include "kis_paint_device.h"
39
40#include <koffice_export.h>
41
42
43class DCOPObject;
44class KCommand;
45
46class KoCommandHistory;
47
48class KisColorSpace;
49class KisNameServer;
50class KisUndoAdapter;
51class KisPainter;
52class KCommand;
53class KisColor;
54class KisFilterStrategy;
55class KisImageIface;
56class KisProfile;
57class KisProgressDisplayInterface;
58class KisPaintLayer;
59class KisPerspectiveGrid;
60
61class KRITACORE_EXPORT KisImage : public TQObject, public TDEShared {
62 TQ_OBJECT
63
64
65public:
66 KisImage(KisUndoAdapter * adapter, TQ_INT32 width, TQ_INT32 height, KisColorSpace * colorSpace, const TQString& name);
67 KisImage(const KisImage& rhs);
68 virtual ~KisImage();
69 virtual DCOPObject *dcopObject();
70
71public:
72 typedef enum enumPaintFlags {
73 PAINT_IMAGE_ONLY = 0,
74 PAINT_BACKGROUND = 1,
75 PAINT_SELECTION = 2,
76 PAINT_MASKINACTIVELAYERS = 4,
77 PAINT_EMBEDDED_RECT = 8 // If the current layer is an embedded part draw a rect around it
78 } PaintFlags;
79
82 virtual void renderToPainter(TQ_INT32 x1,
83 TQ_INT32 y1,
84 TQ_INT32 x2,
85 TQ_INT32 y2,
86 TQPainter &painter,
87 KisProfile *profile,
88 PaintFlags paintFlags,
89 float exposure = 0.0f);
94 virtual TQImage convertToTQImage(TQ_INT32 x1,
95 TQ_INT32 y1,
96 TQ_INT32 x2,
97 TQ_INT32 y2,
98 KisProfile * profile,
99 float exposure = 0.0f);
100
101 virtual TQImage convertToTQImage(const TQRect& r, const TQSize& fullImageSize, KisProfile *profile, PaintFlags paintFlags, float exposure = 0.0f);
102
103 KisBackgroundSP background() const;
104 KisSubstrateSP substrate() const;
105
106
107public:
108
113 void lock();
114
120 void unlock();
121
125 bool locked() const;
126
127 KisColor backgroundColor() const;
128 void setBackgroundColor(const KisColor & color);
129
130 TQString name() const;
131 void setName(const TQString& name);
132
133 TQString description() const;
134 void setDescription(const TQString& description);
135
136 TQString nextLayerName() const;
137 void rollBackLayerName();
138
139 KisPerspectiveGrid* perspectiveGrid();
140 void createPerspectiveGrid(TQPoint topLeft, TQPoint topRight, TQPoint bottomRight, TQPoint bottomLeft);
151 void resize(TQ_INT32 w, TQ_INT32 h, TQ_INT32 x = 0, TQ_INT32 y = 0, bool cropLayers = false);
152
160 void resize(const TQRect& rc, bool cropLayers = false);
161
162 void scale(double sx, double sy, KisProgressDisplayInterface *m_progress, KisFilterStrategy *filterStrategy);
163 void rotate(double radians, KisProgressDisplayInterface *m_progress);
164 void shear(double angleX, double angleY, KisProgressDisplayInterface *m_progress);
165
169 void convertTo(KisColorSpace * dstColorSpace, TQ_INT32 renderingIntent = INTENT_PERCEPTUAL);
170
171 // Get the profile associated with this image
172 KisProfile * getProfile() const;
173
182
183 void setProfile(const KisProfile * profile);
184
189 void setUndoAdapter(KisUndoAdapter * undoAdapter);
190
195 KisUndoAdapter *undoAdapter() const;
196
200 bool undo() const;
205 void setModified();
206
207 KisColorSpace * colorSpace() const;
208
209 // Resolution of the image == XXX: per inch?
210 double xRes();
211 double yRes();
212 void setResolution(double xres, double yres);
213
214 TQ_INT32 width() const;
215 TQ_INT32 height() const;
216
217 bool empty() const;
218
223 KisPaintDeviceSP mergedImage();
224
225 /*
226 * Returns the colour of the merged image at pixel (x, y).
227 */
228 KisColor mergedPixel(TQ_INT32 x, TQ_INT32 y);
229
231 KisLayerSP newLayer(const TQString& name, TQ_UINT8 opacity,
232 const KisCompositeOp& compositeOp = KisCompositeOp(), KisColorSpace * colorstrategy = 0);
233
235 KisPaintDeviceSP activeDevice();
236
237 void setLayerProperties(KisLayerSP layer, TQ_UINT8 opacity, const KisCompositeOp& compositeOp, const TQString& name);
238
239 KisGroupLayerSP rootLayer() const;
240 KisLayerSP activeLayer() const;
241
244 KisPaintDeviceSP projection();
245
246 KisLayerSP activate(KisLayerSP layer);
247 KisLayerSP findLayer(const TQString& name) const;
248 KisLayerSP findLayer(int id) const;
249
251 bool moveLayer(KisLayerSP layer, KisGroupLayerSP parent, KisLayerSP aboveThis);
252
259 bool addLayer(KisLayerSP layer, KisGroupLayerSP parent);
260
275 bool addLayer(KisLayerSP layer, KisGroupLayerSP parent, KisLayerSP aboveThis);
276
278 bool removeLayer(KisLayerSP layer);
279
281 bool raiseLayer(KisLayerSP layer);
282
284 bool lowerLayer(KisLayerSP layer);
285
287 bool toTop(KisLayerSP layer);
288
290 bool toBottom(KisLayerSP layer);
291
292 TQ_INT32 nlayers() const;
293 TQ_INT32 nHiddenLayers() const;
294
295 KCommand *raiseLayerCommand(KisLayerSP layer);
296 KCommand *lowerLayerCommand(KisLayerSP layer);
297 KCommand *topLayerCommand(KisLayerSP layer);
298 KCommand *bottomLayerCommand(KisLayerSP layer);
299
304 void flatten();
305
310 void mergeLayer(KisLayerSP l);
311
312 TQRect bounds() const;
313
315 void notifyLayersChanged();
316
317 void notifyPropertyChanged(KisLayerSP layer);
318
319 void notifyImageLoaded();
320
321 void notifyLayerUpdated(KisLayerSP layer, TQRect rc);
322
323 void setColorSpace(KisColorSpace * colorSpace);
324 void setRootLayer(KisGroupLayerSP rootLayer);
325
326 //KisGuideMgr *guides() const;
327
333 void addAnnotation(KisAnnotationSP annotation);
334
336 KisAnnotationSP annotation(TQString type);
337
339 void removeAnnotation(TQString type);
340
344 vKisAnnotationSP_it beginAnnotations();
345
347 vKisAnnotationSP_it endAnnotations();
348
349signals:
350
351 void sigActiveSelectionChanged(KisImageSP image);
352 void sigSelectionChanged(KisImageSP image);
353 void sigSelectionChanged(KisImageSP image, const TQRect& rect);
354
356 void sigLayerActivated(KisLayerSP layer);
357
359 void sigLayerAdded(KisLayerSP layer);
360
368 void sigLayerRemoved(KisLayerSP layer, KisGroupLayerSP wasParent, KisLayerSP wasAboveThis);
369
375 void sigLayerMoved(KisLayerSP layer, KisGroupLayerSP previousParent, KisLayerSP wasAboveThis);
376
378 void sigLayerPropertiesChanged(KisLayerSP layer);
379
384 void sigLayersChanged(KisGroupLayerSP rootLayer);
385
392 void sigImageUpdated(TQRect rc);
393
400 void sigLayerUpdated(KisLayerSP layer, TQRect rc);
401
405 void sigImageModified();
406
407 void sigSizeChanged(TQ_INT32 w, TQ_INT32 h);
408 void sigProfileChanged(KisProfile * profile);
409 void sigColorSpaceChanged(KisColorSpace* cs);
410
411
413 void sigMaskInfoChanged();
414public slots:
415 void slotSelectionChanged();
416 void slotSelectionChanged(const TQRect& r);
417
418
419private:
420 KisImage& operator=(const KisImage& rhs);
421 void init(KisUndoAdapter * adapter, TQ_INT32 width, TQ_INT32 height, KisColorSpace * colorSpace, const TQString& name);
422 void emitSizeChanged();
423
424private:
425
426 KURL m_uri;
427 TQString m_name;
428 TQString m_description;
429
430 TQ_INT32 m_width;
431 TQ_INT32 m_height;
432
433 double m_xres;
434 double m_yres;
435
436 KoUnit::Unit m_unit;
437
438 KisColorSpace * m_colorSpace;
439
440 bool m_dirty;
441 TQRect m_dirtyRect;
442
443 KisBackgroundSP m_bkg;
444
445 KisGroupLayerSP m_rootLayer; // The layers are contained in here
446 KisLayerSP m_activeLayer;
447
448 KisNameServer *m_nserver;
449 KisUndoAdapter *m_adapter;
450 //KisGuideMgr m_guides;
451
452 DCOPObject *m_dcop;
453
454 vKisAnnotationSP m_annotations;
455
456 class KisImagePrivate;
457 KisImagePrivate * m_private;
458
459};
460
461#endif // KIS_IMAGE_H_
A colorspace is the definition of a certain color model in Chalk.
A KisColor describes a color in a certain colorspace.
Definition kis_color.h:33
This layer is of a type that can be painted on.
KisPainter contains the graphics primitives necessary to draw on a KisPaintDevice.
Definition kis_painter.h:56