00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef KIS_IMAGE_H_
00019 #define KIS_IMAGE_H_
00020
00021 #include <qobject.h>
00022 #include <qstring.h>
00023 #include <qvaluevector.h>
00024 #include <qmutex.h>
00025
00026 #include <config.h>
00027
00028 #include <ksharedptr.h>
00029 #include <kurl.h>
00030
00031 #include "KoUnit.h"
00032
00033 #include "kis_composite_op.h"
00034 #include "kis_global.h"
00035 #include "kis_types.h"
00036 #include "kis_annotation.h"
00037 #include "kis_paint_device.h"
00038
00039 #include <koffice_export.h>
00040
00041
00042 class DCOPObject;
00043 class KCommand;
00044
00045 class KoCommandHistory;
00046
00047 class KisColorSpace;
00048 class KisNameServer;
00049 class KisUndoAdapter;
00050 class KisPainter;
00051 class KCommand;
00052 class KisColor;
00053 class KisFilterStrategy;
00054 class KisImageIface;
00055 class KisProfile;
00056 class KisProgressDisplayInterface;
00057 class KisPaintLayer;
00058
00059
00060 class KRITACORE_EXPORT KisImage : public QObject, public KShared {
00061 Q_OBJECT
00062
00063 public:
00064 KisImage(KisUndoAdapter * adapter, Q_INT32 width, Q_INT32 height, KisColorSpace * colorSpace, const QString& name);
00065 KisImage(const KisImage& rhs);
00066 virtual ~KisImage();
00067 virtual DCOPObject *dcopObject();
00068
00069 public:
00070 typedef enum enumPaintFlags {
00071 PAINT_IMAGE_ONLY = 0,
00072 PAINT_BACKGROUND = 1,
00073 PAINT_SELECTION = 2,
00074 PAINT_MASKINACTIVELAYERS = 4,
00075 PAINT_EMBEDDED_RECT = 8
00076 } PaintFlags;
00077
00080 virtual void renderToPainter(Q_INT32 x1,
00081 Q_INT32 y1,
00082 Q_INT32 x2,
00083 Q_INT32 y2,
00084 QPainter &painter,
00085 KisProfile *profile,
00086 PaintFlags paintFlags,
00087 float exposure = 0.0f);
00092 virtual QImage convertToQImage(Q_INT32 x1,
00093 Q_INT32 y1,
00094 Q_INT32 x2,
00095 Q_INT32 y2,
00096 KisProfile * profile,
00097 float exposure = 0.0f);
00098
00099 virtual QImage convertToQImage(const QRect& r, const QSize& fullImageSize, KisProfile *profile, PaintFlags paintFlags, float exposure = 0.0f);
00100
00101 KisBackgroundSP background() const;
00102
00103 public:
00104
00109 void lock();
00110
00116 void unlock();
00117
00121 bool locked() const;
00122
00123 KisColor backgroundColor() const;
00124 void setBackgroundColor(const KisColor & color);
00125
00126 QString name() const;
00127 void setName(const QString& name);
00128
00129 QString description() const;
00130 void setDescription(const QString& description);
00131
00132 QString nextLayerName() const;
00133 void rollBackLayerName();
00144 void resize(Q_INT32 w, Q_INT32 h, Q_INT32 x = 0, Q_INT32 y = 0, bool cropLayers = false);
00145
00153 void resize(const QRect& rc, bool cropLayers = false);
00154
00155 void scale(double sx, double sy, KisProgressDisplayInterface *m_progress, KisFilterStrategy *filterStrategy);
00156 void rotate(double angle, KisProgressDisplayInterface *m_progress);
00157 void shear(double angleX, double angleY, KisProgressDisplayInterface *m_progress);
00158
00162 void convertTo(KisColorSpace * dstColorSpace, Q_INT32 renderingIntent = INTENT_PERCEPTUAL);
00163
00164
00165 KisProfile * getProfile() const;
00166
00176 void setProfile(const KisProfile * profile);
00177
00182 void setUndoAdapter(KisUndoAdapter * undoAdapter);
00183
00188 KisUndoAdapter *undoAdapter() const;
00189
00193 bool undo() const;
00198 void setModified();
00199
00200 KisColorSpace * colorSpace() const;
00201
00202
00203 double xRes();
00204 double yRes();
00205 void setResolution(double xres, double yres);
00206
00207 Q_INT32 width() const;
00208 Q_INT32 height() const;
00209
00210 bool empty() const;
00211
00216 KisPaintDeviceSP mergedImage();
00217
00218
00219
00220
00221 KisColor mergedPixel(Q_INT32 x, Q_INT32 y);
00222
00224 KisLayerSP newLayer(const QString& name, Q_UINT8 opacity,
00225 const KisCompositeOp& compositeOp = KisCompositeOp(), KisColorSpace * colorstrategy = 0);
00226
00228 KisPaintDeviceSP activeDevice();
00229
00230 void setLayerProperties(KisLayerSP layer, Q_UINT8 opacity, const KisCompositeOp& compositeOp, const QString& name);
00231
00232 KisGroupLayerSP rootLayer() const;
00233 KisLayerSP activeLayer() const;
00234
00237 KisPaintDeviceSP projection();
00238
00239 KisLayerSP activate(KisLayerSP layer);
00240 KisLayerSP findLayer(const QString& name) const;
00241 KisLayerSP findLayer(int id) const;
00242
00244 bool moveLayer(KisLayerSP layer, KisGroupLayerSP parent, KisLayerSP aboveThis);
00245
00252 bool addLayer(KisLayerSP layer, KisGroupLayerSP parent);
00253
00268 bool addLayer(KisLayerSP layer, KisGroupLayerSP parent, KisLayerSP aboveThis);
00269
00271 bool removeLayer(KisLayerSP layer);
00272
00274 bool raiseLayer(KisLayerSP layer);
00275
00277 bool lowerLayer(KisLayerSP layer);
00278
00280 bool toTop(KisLayerSP layer);
00281
00283 bool toBottom(KisLayerSP layer);
00284
00285 Q_INT32 nlayers() const;
00286 Q_INT32 nHiddenLayers() const;
00287
00288 KCommand *raiseLayerCommand(KisLayerSP layer);
00289 KCommand *lowerLayerCommand(KisLayerSP layer);
00290 KCommand *topLayerCommand(KisLayerSP layer);
00291 KCommand *bottomLayerCommand(KisLayerSP layer);
00292
00297 void flatten();
00298
00303 void mergeLayer(KisLayerSP l);
00304
00305 QRect bounds() const;
00306
00308 void notifyLayersChanged();
00309
00310 void notifyPropertyChanged(KisLayerSP layer);
00311
00312 void notifyImageLoaded();
00313
00314 void notifyLayerUpdated(KisLayerSP layer, QRect rc);
00315
00316 void setColorSpace(KisColorSpace * colorSpace);
00317 void setRootLayer(KisGroupLayerSP rootLayer);
00318
00319
00320
00326 void addAnnotation(KisAnnotationSP annotation);
00327
00329 KisAnnotationSP annotation(QString type);
00330
00332 void removeAnnotation(QString type);
00333
00337 vKisAnnotationSP_it beginAnnotations();
00338
00340 vKisAnnotationSP_it endAnnotations();
00341
00342 signals:
00343
00344 void sigActiveSelectionChanged(KisImageSP image);
00345 void sigSelectionChanged(KisImageSP image);
00346
00348 void sigLayerActivated(KisLayerSP layer);
00349
00351 void sigLayerAdded(KisLayerSP layer);
00352
00360 void sigLayerRemoved(KisLayerSP layer, KisGroupLayerSP wasParent, KisLayerSP wasAboveThis);
00361
00367 void sigLayerMoved(KisLayerSP layer, KisGroupLayerSP previousParent, KisLayerSP wasAboveThis);
00368
00370 void sigLayerPropertiesChanged(KisLayerSP layer);
00371
00376 void sigLayersChanged(KisGroupLayerSP rootLayer);
00377
00384 void sigImageUpdated(QRect rc);
00385
00392 void sigLayerUpdated(KisLayerSP layer, QRect rc);
00393
00397 void sigImageModified();
00398
00399 void sigSizeChanged(Q_INT32 w, Q_INT32 h);
00400 void sigProfileChanged(KisProfile * profile);
00401 void sigColorSpaceChanged(KisColorSpace* cs);
00402
00403
00404 public slots:
00405 void slotSelectionChanged();
00406 void slotSelectionChanged(const QRect& r);
00407
00408
00409 private:
00410 KisImage& operator=(const KisImage& rhs);
00411 void init(KisUndoAdapter * adapter, Q_INT32 width, Q_INT32 height, KisColorSpace * colorSpace, const QString& name);
00412 void emitSizeChanged();
00413
00414 private:
00415
00416 KURL m_uri;
00417 QString m_name;
00418 QString m_description;
00419
00420 Q_INT32 m_width;
00421 Q_INT32 m_height;
00422
00423 double m_xres;
00424 double m_yres;
00425
00426 KoUnit::Unit m_unit;
00427
00428 KisColorSpace * m_colorSpace;
00429
00430 bool m_dirty;
00431 QRect m_dirtyRect;
00432
00433 KisBackgroundSP m_bkg;
00434
00435 KisGroupLayerSP m_rootLayer;
00436 KisLayerSP m_activeLayer;
00437
00438 KisNameServer *m_nserver;
00439 KisUndoAdapter *m_adapter;
00440
00441
00442 DCOPObject *m_dcop;
00443
00444 vKisAnnotationSP m_annotations;
00445
00446 class KisImagePrivate;
00447 KisImagePrivate * m_private;
00448 };
00449
00450 #endif // KIS_IMAGE_H_