00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef KIS_PAINT_DEVICE_IMPL_H_
00019 #define KIS_PAINT_DEVICE_IMPL_H_
00020
00021 #include <qcolor.h>
00022 #include <qobject.h>
00023 #include <qpixmap.h>
00024 #include <qptrlist.h>
00025 #include <qrect.h>
00026 #include <qvaluelist.h>
00027 #include <qstring.h>
00028
00029 #include "kis_types.h"
00030 #include "kdebug.h"
00031 #include "kis_global.h"
00032 #include "kis_image.h"
00033 #include "kis_colorspace.h"
00034 #include "kis_canvas_controller.h"
00035 #include "kis_color.h"
00036 #include <koffice_export.h>
00037
00038 class DCOPObject;
00039
00040 class QImage;
00041 class QSize;
00042 class QPoint;
00043 class QWMatrix;
00044 class QTimer;
00045
00046 class KNamedCommand;
00047
00048 class KoStore;
00049
00050 class KisExifInfo;
00051 class KisHLineIteratorPixel;
00052 class KisImage;
00053 class KisRectIteratorPixel;
00054 class KisVLineIteratorPixel;
00055 class KisRandomAccessorPixel;
00056 class KisRandomSubAccessorPixel;
00057 class KisUndoAdapter;
00058 class KisFilter;
00059 class KisDataManager;
00060 typedef KSharedPtr<KisDataManager> KisDataManagerSP;
00061
00062 class KisMemento;
00063 typedef KSharedPtr<KisMemento> KisMementoSP;
00064
00065
00073 class KRITACORE_EXPORT KisPaintDevice
00074 : public QObject
00075 , public KShared
00076 {
00077
00078 Q_OBJECT
00079
00080 public:
00081
00088 KisPaintDevice(KisColorSpace * colorSpace, const char * name = 0);
00089
00098 KisPaintDevice(KisLayer *parentLayer, KisColorSpace * colorSpace, const char * name = 0);
00099
00100 KisPaintDevice(const KisPaintDevice& rhs);
00101 virtual ~KisPaintDevice();
00102 virtual DCOPObject *dcopObject();
00103
00104
00105 public:
00106
00110 virtual bool write(KoStore *store);
00111
00115 virtual bool read(KoStore *store);
00116
00117 public:
00118
00122 virtual void move(Q_INT32 x, Q_INT32 y);
00123
00127 virtual void move(const QPoint& pt);
00128
00133 virtual KNamedCommand * moveCommand(Q_INT32 x, Q_INT32 y);
00134
00138 bool contains(Q_INT32 x, Q_INT32 y) const;
00139
00143 bool contains(const QPoint& pt) const;
00144
00151 virtual void extent(Q_INT32 &x, Q_INT32 &y, Q_INT32 &w, Q_INT32 &h) const;
00152 virtual QRect extent() const;
00153
00161 bool extentIsValid() const;
00162
00164 void setExtentIsValid(bool isValid);
00165
00170 virtual void exactBounds(Q_INT32 &x, Q_INT32 &y, Q_INT32 &w, Q_INT32 &h) const;
00171 virtual QRect exactBounds() const;
00172 virtual QRect exactBoundsOldMethod() const;
00173 virtual QRect exactBoundsImprovedOldMethod() const;
00174
00178 void crop(Q_INT32 x, Q_INT32 y, Q_INT32 w, Q_INT32 h);
00179
00181 void crop(QRect r);
00182
00186 virtual void clear();
00187
00191 void fill(Q_INT32 x, Q_INT32 y, Q_INT32 w, Q_INT32 h, const Q_UINT8 *fillPixel);
00192
00203 virtual void readBytes(Q_UINT8 * data, Q_INT32 x, Q_INT32 y, Q_INT32 w, Q_INT32 h);
00204
00213 virtual void writeBytes(const Q_UINT8 * data, Q_INT32 x, Q_INT32 y, Q_INT32 w, Q_INT32 h);
00214
00219 Q_INT32 numContiguousColumns(Q_INT32 x, Q_INT32 minY, Q_INT32 maxY);
00220
00225 Q_INT32 numContiguousRows(Q_INT32 y, Q_INT32 minX, Q_INT32 maxX);
00226
00231 Q_INT32 rowStride(Q_INT32 x, Q_INT32 y);
00232
00236 KDE_DEPRECATED const Q_UINT8* pixel(Q_INT32 x, Q_INT32 y);
00237
00241 KDE_DEPRECATED Q_UINT8* writablePixel(Q_INT32 x, Q_INT32 y);
00242
00246 virtual void convertTo(KisColorSpace * dstColorSpace, Q_INT32 renderingIntent = INTENT_PERCEPTUAL);
00247
00252 virtual void setProfile(KisProfile * profile);
00253
00258 virtual void convertFromQImage(const QImage& img, const QString &srcProfileName, Q_INT32 offsetX = 0, Q_INT32 offsetY = 0);
00259
00272 virtual QImage convertToQImage(KisProfile * dstProfile, Q_INT32 x, Q_INT32 y, Q_INT32 w, Q_INT32 h, float exposure = 0.0f);
00273
00282 virtual QImage convertToQImage(KisProfile * dstProfile, float exposure = 0.0f);
00283
00289 KisPaintDeviceSP createThumbnailDevice(Q_INT32 w, Q_INT32 h);
00290
00296 virtual QImage createThumbnail(Q_INT32 maxw, Q_INT32 maxh);
00297
00298
00307 bool pixel(Q_INT32 x, Q_INT32 y, QColor *c, Q_UINT8 *opacity);
00308
00309
00319 bool pixel(Q_INT32 x, Q_INT32 y, KisColor * kc);
00320
00324 KisColor colorAt(Q_INT32 x, Q_INT32 y);
00325
00341 bool setPixel(Q_INT32 x, Q_INT32 y, const QColor& c, Q_UINT8 opacity);
00342
00343 bool setPixel(Q_INT32 x, Q_INT32 y, const KisColor& kc);
00344
00345 KisColorSpace * colorSpace() const;
00346
00347 KisDataManagerSP dataManager() const;
00348
00352 void setData(KisDataManagerSP data, KisColorSpace * colorSpace);
00353
00357 Q_INT32 getX() const;
00358
00362 Q_INT32 getY() const;
00363
00367 void setX(Q_INT32 x);
00368
00372 void setY(Q_INT32 y);
00373
00374
00378 virtual Q_INT32 pixelSize() const;
00379
00383 virtual Q_INT32 nChannels() const;
00384
00389 KisImage *image() const;
00390
00395 KisLayer *parentLayer() const;
00396
00401 void setParentLayer(KisLayer *parentLayer);
00402
00406 virtual void setDirty(const QRect & rc);
00407
00411 virtual void setDirty();
00412
00413
00417 void mirrorX();
00421 void mirrorY();
00422
00423 KisMementoSP getMemento();
00424 void rollback(KisMementoSP memento);
00425 void rollforward(KisMementoSP memento);
00426
00430 KisRectIteratorPixel createRectIterator(Q_INT32 left, Q_INT32 top, Q_INT32 w, Q_INT32 h, bool writable);
00431
00435 KisHLineIteratorPixel createHLineIterator(Q_INT32 x, Q_INT32 y, Q_INT32 w, bool writable);
00436
00440 KisVLineIteratorPixel createVLineIterator(Q_INT32 x, Q_INT32 y, Q_INT32 h, bool writable);
00441
00448 KisRandomAccessorPixel createRandomAccessor(Q_INT32 x, Q_INT32 y, bool writable);
00449
00453 KisRandomSubAccessorPixel createRandomSubAccessor();
00454
00456 KisSelectionSP selection();
00457
00459 void addSelection(KisSelectionSP selection);
00460
00462 void subtractSelection(KisSelectionSP selection);
00463
00465 bool hasSelection();
00466
00468 bool selectionDeselected();
00469
00471 void deselect();
00472
00474 void reselect();
00475
00477 void clearSelection();
00478
00483 void applySelectionMask(KisSelectionSP mask);
00484
00490 KisSelectionSP setSelection(KisSelectionSP selection);
00491
00495 void emitSelectionChanged();
00496
00502 void emitSelectionChanged(const QRect& r);
00503
00504
00505 KisUndoAdapter *undoAdapter() const;
00506
00511 KisExifInfo* exifInfo();
00515 bool hasExifInfo() { return m_exifInfo != 0; }
00516 signals:
00517 void positionChanged(KisPaintDeviceSP device);
00518 void ioProgress(Q_INT8 percentage);
00519 void profileChanged(KisProfile * profile);
00520
00521 private slots:
00522
00523 void runBackgroundFilters();
00524
00525 private:
00526 KisPaintDevice& operator=(const KisPaintDevice&);
00527
00528 protected:
00529 KisDataManagerSP m_datamanager;
00530
00531 private:
00532
00533
00534
00535 KisLayer *m_parentLayer;
00536
00537 bool m_extentIsValid;
00538
00539 Q_INT32 m_x;
00540 Q_INT32 m_y;
00541 KisColorSpace * m_colorSpace;
00542
00543 Q_INT32 m_pixelSize;
00544 Q_INT32 m_nChannels;
00545
00546
00547 bool m_hasSelection;
00548 bool m_selectionDeselected;
00549
00550
00551
00552 KisSelectionSP m_selection;
00553
00554 DCOPObject * m_dcop;
00555
00556 KisExifInfo* m_exifInfo;
00557
00558 QValueList<KisFilter*> m_longRunningFilters;
00559 QTimer * m_longRunningFilterTimer;
00560 };
00561
00562 inline Q_INT32 KisPaintDevice::pixelSize() const
00563 {
00564 Q_ASSERT(m_pixelSize > 0);
00565 return m_pixelSize;
00566 }
00567
00568 inline Q_INT32 KisPaintDevice::nChannels() const
00569 {
00570 Q_ASSERT(m_nChannels > 0);
00571 return m_nChannels;
00572 ;
00573 }
00574
00575 inline KisColorSpace * KisPaintDevice::colorSpace() const
00576 {
00577 Q_ASSERT(m_colorSpace != 0);
00578 return m_colorSpace;
00579 }
00580
00581
00582 inline Q_INT32 KisPaintDevice::getX() const
00583 {
00584 return m_x;
00585 }
00586
00587 inline Q_INT32 KisPaintDevice::getY() const
00588 {
00589 return m_y;
00590 }
00591
00592 #endif // KIS_PAINT_DEVICE_IMPL_H_
00593