Commit 7829c8f8 authored by Boudewijn Rempt's avatar Boudewijn Rempt

* Fix after-deselect-selection-reappears-if-select-tool-is-used again bug

* Fix apidox errors & add some more documentation (at least, _I_ don't
  get any errors anymore)
* Update the TODO (it's smaller now!)
* Tools now have an empty widget if they don't have a widget -- still need
  to fix the captioning for non-paint tools.
* Add a primitive dcop interface to KisColorSpace. It should now be possible
  to write a dcop client that inverts a paint device but I don't know how to
  do that.

svn path=/trunk/koffice/; revision=476894
parent 6fa259bc
......@@ -45,7 +45,7 @@ messages: rc.cpp
$(XGETTEXT) i18ndata rc.cpp `find . -name \*.cc -o -name \*.h` ui/kis_aboutdata.h -o $(podir)/krita.pot
rm -f i18ndata
DOXYGEN_EXCLUDE = CImg.h
DOXYGEN_EXCLUDE = CImg.h colorspaces plugins kritacolor/colorspaces core/tiles
include $(top_srcdir)/admin/Doxyfile.am
kde_services_DATA = kritapart.desktop
......
......@@ -3,7 +3,6 @@ Code organization
* Separate all interfaces from the implementations and place them in krita/sdk. Use these interfaces for DCOP.
Problem: what to do when it is useful for plugins to derive from a base class with some default functionality. Composition
with delegation here? Go through patterns book.
* Separate the core Krita image library from the part; place the former in krita/libkrita and the latter in krita/kritapart
Bugs
* On opening a second image after loading first image but not changing it,
......@@ -30,7 +29,6 @@ Transform tool (CBR)
Integration
(BSAR, akademy)
* A krita document embedded in KWord has the wrong scaling and transparency
* A krita document embedded in another document prints at the wrong place
* Embedded KOffice objects don't paint themselves correctly
......@@ -143,15 +141,6 @@ User Interface
* Add history docker
* Convert the layer & channel box to a qlistbox; enable the channel box.
* Use OpenGL if available to composite checkerboard with image so
while scrolling the checks can stay in place, and the partially
transparent image move. This maybe needs Qt 4. OpenGL can also be
used to bumpmap images on a height-field canvas.
we now have a checkered background layer that we composite everything
on, but in future we should composite the image first, and then render
it onto a background image -- or not, if another KOffice app wants it
rendered with transparency. But that'd probably better wait until Qt 4,
where it would be a hardware accelerated snip.
* Doing a copy of a selection, but having the wrong layer selected gives
me an empty selection (all transparent). Pressing paste should say so
(popup) instead of creating a new useless layer.
......
......@@ -113,7 +113,6 @@ public:
private:
void visit(KisPainter& gc, KisPaintDeviceImplSP dev, Q_INT32 opacity)
{
// kdDebug() << "\tpainting device " << dev->name() << ", " << dev->colorSpace()->id().name() << "\n";
Q_INT32 w = m_rc.width();
Q_INT32 h = m_rc.height();
Q_INT32 dx = m_rc.x();
......
......@@ -487,7 +487,7 @@ KisImage::KisImage(const KisImage& rhs) : QObject(), KShared(rhs)
KisImageIface *KisImage::dcopObject()
DCOPObject * KisImage::dcopObject()
{
if (!m_dcop) {
m_dcop = new KisImageIface(this);
......
......@@ -43,7 +43,6 @@ class KisColorSpace;
class KisNameServer;
class KisUndoAdapter;
class KisPainter;
class DCOPObject;
class KCommand;
class KisCompositeOp;
class KisColor;
......@@ -60,7 +59,7 @@ public:
KisImage(KisUndoAdapter * adapter, Q_INT32 width, Q_INT32 height, KisColorSpace * colorSpace, const QString& name);
KisImage(const KisImage& rhs);
virtual ~KisImage();
virtual KisImageIface *dcopObject();
virtual DCOPObject *dcopObject();
public:
typedef enum enumPaintFlags {
......@@ -313,7 +312,7 @@ private:
KisUndoAdapter *m_adapter;
//KisGuideMgr m_guides;
KisImageIface *m_dcop;
DCOPObject *m_dcop;
vKisAnnotationSP m_annotations;
......
......@@ -88,3 +88,20 @@ DCOPRef KisImageIface::activeDevice()
"KisPaintDeviceImplIface");
}
DCOPRef KisImageIface::colorSpace() const
{
KisColorSpace * cs = m_img->colorSpace();
if ( !cs )
return DCOPRef();
else
return DCOPRef( kapp->dcopClient()->appId(),
cs->dcopObject()->objId(),
"KisColorSpaceIface" );
}
void KisImageIface::setColorSpace(DCOPRef colorSpace)
{
// XXX: Figure out how to get the correct object from
// the dcopref
}
......@@ -46,11 +46,22 @@ k_dcop:
void rotateCW();
void rotate180();
void rotate(double angle);
/**
* Get the active painting device.
*/
DCOPRef activeDevice();
/**
* Get the colorspace of this image
*/
DCOPRef colorSpace() const;
/**
* Set the colorspace of this image
*/
void setColorSpace(DCOPRef colorSpace);
private:
......
......@@ -19,12 +19,14 @@
*/
#include <kapplication.h>
#include <dcopclient.h>
#include "kis_paint_device_iface.h"
#include "kis_colorspace_iface.h"
#include "kis_colorspace.h"
#include "kis_paint_device_impl.h"
#include <dcopclient.h>
KisPaintDeviceImplIface::KisPaintDeviceImplIface( KisPaintDeviceImpl * parent )
: DCOPObject(parent->name().utf8())
{
......@@ -65,3 +67,20 @@ void KisPaintDeviceImplIface::writeBytes(QByteArray bytes, Q_INT32 x, Q_INT32 y,
{
m_parent->writeBytes((Q_UINT8*)bytes.data(), x, y, w, h);
}
DCOPRef KisPaintDeviceImplIface::colorSpace() const
{
KisColorSpace * cs = m_parent->colorSpace();
if ( !cs )
return DCOPRef();
else
return DCOPRef( kapp->dcopClient()->appId(),
cs->dcopObject()->objId(),
"KisColorSpaceIface" );
}
void KisPaintDeviceImplIface::setColorSpace(DCOPRef)
{
// XXX: Figure out how to get the correct object from
// the dcopref
}
/* This file is part of the KDE project
/*
* This file is part of the KDE project
*
* Copyright (C) 2005 Boudewijn Rempt <boud@valdyas.org>
*
* This program is free software; you can redistribute it and/or modify
......@@ -15,7 +17,6 @@
* 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_PAINT_DEVICE_IFACE_H
#define _KIS_PAINT_DEVICE_IFACE_H
......@@ -68,6 +69,16 @@ k_dcop:
*/
void writeBytes(QByteArray bytes, Q_INT32 x, Q_INT32 y, Q_INT32 w, Q_INT32 h);
/**
* Get the colorspace of this image
*/
DCOPRef colorSpace() const;
/**
* Set the colorspace of this image
*/
void setColorSpace(DCOPRef colorSpace);
private:
......
......@@ -819,8 +819,13 @@ void KisPaintDeviceImpl::emitSelectionChanged(const QRect& r) {
}
KisSelectionSP KisPaintDeviceImpl::selection(){
if (!m_selection) {
KisSelectionSP KisPaintDeviceImpl::selection()
{
// If there either is no selection yet,
// or there is a selection but it has been deselected
// create a new selection
// otherwise, make do with the current selection
if (!m_selection || (m_selection && m_selectionDeselected)) {
m_selection = new KisSelection(this, "layer selection for: " + name());
Q_CHECK_PTR(m_selection);
m_selection -> setVisible(true);
......@@ -829,6 +834,7 @@ KisSelectionSP KisPaintDeviceImpl::selection(){
}
m_hasSelection = true;
m_selectionDeselected = false;
return m_selection;
}
......@@ -842,7 +848,16 @@ bool KisPaintDeviceImpl::hasSelection()
void KisPaintDeviceImpl::deselect()
{
if (m_selection && m_hasSelection) {
m_hasSelection = false;
m_selectionDeselected = true;
}
}
void KisPaintDeviceImpl::reselect()
{
m_hasSelection = true;
m_selectionDeselected = false;
}
void KisPaintDeviceImpl::addSelection(KisSelectionSP selection) {
......
......@@ -364,6 +364,9 @@ public:
/** Deselect the selection for this paintdevice. */
void deselect();
/** Reinstates the old selection */
void reselect();
/** Clear the selected pixels from the paint device */
void clearSelection();
......@@ -412,6 +415,8 @@ private:
// Whether the selection is active
bool m_hasSelection;
bool m_selectionDeselected;
// Contains the actual selection. For now, there can be only
// one selection per layer. XXX: is this a limitation?
KisSelectionSP m_selection;
......
......@@ -42,7 +42,7 @@ class KisPaintBox;
/**
* This class keeps information that can be used in the painting process, for example by
* bruses.
* brushes.
**/
class KRITACORE_EXPORT KisPaintInformation {
public:
......
/**
@mainpage Krita Image manipulation and paint application
Krita is an advanced and modular paint and image manipulation
application.
Krita is built around two core libraries: kritacolor and kritaimage.
The kritacolor library abstracts colorspaces and color
transformations. Colorspaces provide functions to manipulate pixels. The
kritcolor library loads colorspace plugins to extend the range of
available colorspaces.
The kritaimage library abstracts the storage, creation, inspection
and manipulation of pixels stored in a rectangular area. It provides
layers, filters, iterators and painters. Filters and paint operations
are provided as service plugins loaded through the appropriate trader
queries.
Both libraries are used by the user interface, which is a KOffice
part. the user interface loads tools and other plugins.
*/
......@@ -14,6 +14,8 @@ endif
libkritacolor_la_SOURCES = \
kis_color.cc \
kis_colorspace.cc \
kis_colorspace_iface.cc \
kis_colorspace_iface.skel \
kis_composite_op.cc \
kis_profile.cc \
kis_histogram_producer.cc \
......
......@@ -62,11 +62,18 @@ class KisAbstractColorSpace : public KisColorSpace {
public:
/**
* @param id The unique human and machine readable identifiation of this colorspace
* @param cmType the lcms type indentification for this colorspace, may be 0
* @param colorSpaceSignature the icc identification for this colorspace, may be 0
* @param parent the registry that owns this instance
* @param profile the profile this colorspace uses for transforms
*/
KisAbstractColorSpace(const KisID & id,
DWORD cmType,
icColorSpaceSignature colorSpaceSignature,
KisColorSpaceFactoryRegistry * parent,
KisProfile *p);
KisProfile *profile);
void init();
......
......@@ -30,7 +30,7 @@
class KisBasicHistogramProducer : public KisHistogramProducer {
public:
KisBasicHistogramProducer(const KisID& id, int channels, int nrOfBins, KisColorSpace *cs);
KisBasicHistogramProducer(const KisID& id, int channels, int nrOfBins, KisColorSpace *colorSpace);
virtual ~KisBasicHistogramProducer() {}
virtual void clear();
......@@ -82,24 +82,24 @@ protected:
class KisBasicU8HistogramProducer : public KisBasicHistogramProducer {
public:
KisBasicU8HistogramProducer(const KisID& id, KisColorSpace *cs);
virtual void addRegionToBin(Q_UINT8 * pixels, Q_UINT8 * selectionMask, Q_UINT32 nPixels, KisColorSpace *cs);
KisBasicU8HistogramProducer(const KisID& id, KisColorSpace *colorSpace);
virtual void addRegionToBin(Q_UINT8 * pixels, Q_UINT8 * selectionMask, Q_UINT32 nPixels, KisColorSpace *colorSpace);
virtual QString positionToString(double pos) const;
virtual double maximalZoom() const { return 1.0; }
};
class KisBasicU16HistogramProducer : public KisBasicHistogramProducer {
public:
KisBasicU16HistogramProducer(const KisID& id, KisColorSpace *cs);
virtual void addRegionToBin(Q_UINT8 * pixels, Q_UINT8 * selectionMask, Q_UINT32 nPixels, KisColorSpace *cs);
KisBasicU16HistogramProducer(const KisID& id, KisColorSpace *colorSpace);
virtual void addRegionToBin(Q_UINT8 * pixels, Q_UINT8 * selectionMask, Q_UINT32 nPixels, KisColorSpace *colorSpace);
virtual QString positionToString(double pos) const;
virtual double maximalZoom() const;
};
class KisBasicF32HistogramProducer : public KisBasicHistogramProducer {
public:
KisBasicF32HistogramProducer(const KisID& id, KisColorSpace *cs);
virtual void addRegionToBin(Q_UINT8 * pixels, Q_UINT8 * selectionMask, Q_UINT32 nPixels, KisColorSpace *cs);
KisBasicF32HistogramProducer(const KisID& id, KisColorSpace *colorSpace);
virtual void addRegionToBin(Q_UINT8 * pixels, Q_UINT8 * selectionMask, Q_UINT32 nPixels, KisColorSpace *colorSpace);
virtual QString positionToString(double pos) const;
virtual double maximalZoom() const;
};
......@@ -107,8 +107,8 @@ public:
#if HAVE_OPENEXR
class KisBasicF16HalfHistogramProducer : public KisBasicHistogramProducer {
public:
KisBasicF16HalfHistogramProducer(const KisID& id, KisColorSpace *cs);
virtual void addRegionToBin(Q_UINT8 * pixels, Q_UINT8 * selectionMask, Q_UINT32 nPixels, KisColorSpace *cs);
KisBasicF16HalfHistogramProducer(const KisID& id, KisColorSpace *colorSpace);
virtual void addRegionToBin(Q_UINT8 * pixels, Q_UINT8 * selectionMask, Q_UINT32 nPixels, KisColorSpace *colorSpace);
virtual QString positionToString(double pos) const;
virtual double maximalZoom() const;
};
......@@ -122,11 +122,11 @@ public:
*/
template<class T> class KisBasicHistogramProducerFactory : public KisHistogramProducerFactory {
public:
KisBasicHistogramProducerFactory(const KisID& id, KisColorSpace *cs)
: KisHistogramProducerFactory(id), m_cs(cs) {}
KisBasicHistogramProducerFactory(const KisID& id, KisColorSpace *colorSpace)
: KisHistogramProducerFactory(id), m_cs(colorSpace) {}
virtual ~KisBasicHistogramProducerFactory() {}
virtual KisHistogramProducerSP generate() { return new T(id(), m_cs); }
virtual bool isCompatibleWith(KisColorSpace* cs) const { return cs -> id() == m_cs -> id(); }
virtual bool isCompatibleWith(KisColorSpace* colorSpace) const { return colorSpace -> id() == m_cs -> id(); }
protected:
KisColorSpace *m_cs;
};
......
......@@ -33,46 +33,46 @@
class KisColor {
public:
// Create an empty KisColor. It will be valid, but also black and transparent
/// Create an empty KisColor. It will be valid, but also black and transparent
KisColor();
virtual ~KisColor();
// Create a KisColor from a QColor. The QColor is immediately converted to native. The QColor
// is assumed to have the current monitor profile.
/// Create a KisColor from a QColor. The QColor is immediately converted to native. The QColor
/// is assumed to have the current monitor profile.
KisColor(const QColor & color, KisColorSpace * colorSpace);
// Create a KisColor from a QColor. The QColor is immediately converted to native. The QColor
// is assumed to have the current monitor profile.
/// Create a KisColor from a QColor. The QColor is immediately converted to native. The QColor
/// is assumed to have the current monitor profile.
KisColor(const QColor & color, Q_UINT8 alpha, KisColorSpace * colorSpace);
// Create a KisColor using a native color strategy. The data is copied.
/// Create a KisColor using a native color strategy. The data is copied.
KisColor(const Q_UINT8 * data, KisColorSpace * colorSpace);
// Create a KisColor by converting src into another colorspace
/// Create a KisColor by converting src into another colorspace
KisColor(const KisColor &src, KisColorSpace * colorSpace);
// Copy constructor -- deep copies the colors.
/// Copy constructor -- deep copies the colors.
KisColor(const KisColor & rhs);
// Effective C++, item 11
/// Effective C++, item 11
KisColor &operator=(const KisColor &);
// For easy memcpy'ing etc.
/// For easy memcpy'ing etc.
Q_UINT8 * data() const { return m_data; }
KisColorSpace * colorSpace() const { return m_colorSpace; }
KisProfile * profile() const { return m_colorSpace -> getProfile(); }
// Convert this KisColor to the specified colorspace. If the specified colorspace is the
// same as the original colorspace, do nothing. Returns the converted KisColor.
/// Convert this KisColor to the specified colorspace. If the specified colorspace is the
/// same as the original colorspace, do nothing. Returns the converted KisColor.
void convertTo(KisColorSpace * cs);
// Replace the existing color data, and colorspace with the specified data.
/// Replace the existing color data, and colorspace with the specified data.
void setColor(Q_UINT8 * data, KisColorSpace * colorSpace = 0);
// To save the user the trouble of doing color->colorSpace()->toQColor(color->data(), &c, &a
/// To save the user the trouble of doing color->colorSpace()->toQColor(color->data(), &c, &a
void toQColor(QColor *c) const;
void toQColor(QColor *c, Q_UINT8 *opacity) const;
......
/*
* Copyright (c) 2005 Boudewijn Rempt <boud@valdyas.org>
*
* 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.
*/
#include "kis_colorspace.h"
#include "kis_colorspace_iface.h"
KisColorSpace::KisColorSpace()
{
m_dcop = 0;
}
KisColorSpace::~KisColorSpace()
{
delete m_dcop;
}
DCOPObject * KisColorSpace::dcopObject()
{
if (!m_dcop) {
m_dcop = new KisColorSpaceIface(this);
Q_CHECK_PTR(m_dcop);
}
return m_dcop;
}
......@@ -26,6 +26,8 @@
#include "kis_composite_op.h"
#include "kis_channelinfo.h"
class DCOPObject;
class KisPixel;
class KisPixelRO;
class KisProfile;
......@@ -47,6 +49,8 @@ public:
KisColorSpace();
virtual ~KisColorSpace();
virtual DCOPObject * dcopObject();
public:
//========== Channels =====================================================//
......@@ -342,6 +346,11 @@ public:
Q_INT32 rows,
Q_INT32 cols,
const KisCompositeOp& op) = 0;
private:
DCOPObject * m_dcop;
};
class KisColorSpaceFactory {
......
/*
* This file is part of the KDE project
*
* Copyright (C) 2005 Boudewijn Rempt <boud@valdyas.org>
*
* 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.
*/
#include <kapplication.h>
#include "kis_colorspace_iface.h"
#include "kis_colorspace.h"
#include <dcopclient.h>
KisColorSpaceIface::KisColorSpaceIface( KisColorSpace * parent )
: DCOPObject(parent->id().id().latin1())
{
m_parent = parent;
}
QByteArray KisColorSpaceIface::invertColor(QByteArray src, Q_INT32 nPixels)
{
m_parent->invertColor((Q_UINT8*)src.data(), nPixels);
return src;
}
/* This file is part of the KDE project
* Copyright (C) 2005 Boudewijn Rempt <boud@valdyas.org>
*
* 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_COLORSPACE_IFACE_H
#define _KIS_COLORSPACE_IFACE_H
#include <dcopref.h>
#include <dcopobject.h>
#include <qstring.h>
class KisColorSpace;
class KisColorSpaceIface : public DCOPObject
{
K_DCOP
public:
KisColorSpaceIface( KisColorSpace * parent );
k_dcop:
QByteArray invertColor(QByteArray src, Q_INT32 nPixels);
private:
KisColorSpace *m_parent;
};
#endif
......@@ -114,11 +114,9 @@ void KisSimpleNoiseReducer::process(KisPaintDeviceImplSP src, KisPaintDeviceImpl
means[i] /= pixelsnb;
if( 100*ABS(means[i] - srcIt.oldRawData()[i]) > threshold * means[i] )
{
// kdDebug() << ABS(means[i] - srcIt.oldRawData()[i]) << " " << ( 0.1 * means[i] ) << " " << means[i] << " " << (int)srcIt.oldRawData()[i] << endl;
++depthbad;
}
}
// kdDebug() << depthbad << " " << (depth / 2) << endl;
// Change the value of the pixel, if the pixel is too much different
if(depthbad > depth / 2)
{
......
......@@ -181,7 +181,6 @@ void waveuntrans(Wavelet* wav, Wavelet* buff, uint halfsize, KisColorSpace* cs)
memcpy(wav->coeffs + p, buff->coeffs + p, l);
}
kdDebug() << halfsize << " " << wav->size << endl;
if(halfsize != wav->size/2)
{
waveuntrans(wav, buff, halfsize*2, cs);
......
The smeary brush mixes the colors on the canvas with the paint color and deposits
the mixture onto the canvas in the next brush stroke. This should be extended with
the concept of wetness to make sure paint dries and doesn't smear.
......@@ -34,19 +34,43 @@
* An annotation can be of something like a QByteArray or a QString op a more specific
* datatype that can be attached to an image (or maybe later, if needed, to a layer)
* and contains data that must be associated with an image for purposes of import/export.
*
* Annotations will be saved to krita images and may be exported in filetypes that support
* them.