Commit 1bf722ae authored by Boudewijn Rempt's avatar Boudewijn Rempt

* Add a profile visitor for changing profiles without converting to another colorspace

* Add lots of debug for Adrian
* Block signals of KisImage on loading/importing; unblock when setting the image to a view
* Some layout "fixes" (I'm not completely satisfied yet)

svn path=/trunk/koffice/; revision=510442
parent 5964f58d
......@@ -88,6 +88,6 @@ Spaces
Slots and signals
Prefix slots with slot and signals with sig: slotSelectionUpdated, sigSelectionUpdated.
Prefix slots with slot and signals with sig: slotUpdateSelection, sigSelectionUpdated.
Boudewijn Rempt
\ No newline at end of file
......@@ -32,7 +32,7 @@ public:
KisGrayColorSpace(KisColorSpaceFactoryRegistry * parent, KisProfile *p);
virtual ~KisGrayColorSpace();
virtual bool willDegrade(ColorSpaceIndependence independence)
virtual bool willDegrade(ColorSpaceIndependence /*independence*/)
{
return false;
};
......
......@@ -82,7 +82,7 @@ void KisRgbF32ColorSpace::getPixel(const Q_UINT8 *src, float *red, float *green,
*alpha = srcPixel -> alpha;
}
void KisRgbF32ColorSpace::fromQColor(const QColor& c, Q_UINT8 *dstU8, KisProfile * profile)
void KisRgbF32ColorSpace::fromQColor(const QColor& c, Q_UINT8 *dstU8, KisProfile * /*profile*/)
{
Pixel *dst = reinterpret_cast<Pixel *>(dstU8);
......@@ -91,7 +91,7 @@ void KisRgbF32ColorSpace::fromQColor(const QColor& c, Q_UINT8 *dstU8, KisProfile
dst -> blue = UINT8_TO_FLOAT(c.blue());
}
void KisRgbF32ColorSpace::fromQColor(const QColor& c, Q_UINT8 opacity, Q_UINT8 *dstU8, KisProfile * profile)
void KisRgbF32ColorSpace::fromQColor(const QColor& c, Q_UINT8 opacity, Q_UINT8 *dstU8, KisProfile * /*profile*/)
{
Pixel *dst = reinterpret_cast<Pixel *>(dstU8);
......@@ -101,14 +101,14 @@ void KisRgbF32ColorSpace::fromQColor(const QColor& c, Q_UINT8 opacity, Q_UINT8 *
dst -> alpha = UINT8_TO_FLOAT(opacity);
}
void KisRgbF32ColorSpace::toQColor(const Q_UINT8 *srcU8, QColor *c, KisProfile * profile)
void KisRgbF32ColorSpace::toQColor(const Q_UINT8 *srcU8, QColor *c, KisProfile * /*profile*/)
{
const Pixel *src = reinterpret_cast<const Pixel *>(srcU8);
c -> setRgb(FLOAT_TO_UINT8(src -> red), FLOAT_TO_UINT8(src -> green), FLOAT_TO_UINT8(src -> blue));
}
void KisRgbF32ColorSpace::toQColor(const Q_UINT8 *srcU8, QColor *c, Q_UINT8 *opacity, KisProfile * profile)
void KisRgbF32ColorSpace::toQColor(const Q_UINT8 *srcU8, QColor *c, Q_UINT8 *opacity, KisProfile * /*profile*/)
{
const Pixel *src = reinterpret_cast<const Pixel *>(srcU8);
......
......@@ -28,7 +28,8 @@ libkritaimage_la_SOURCES = kis_adjustment_layer.cc kis_alpha_mask.cc \
noinst_HEADERS = kis_rotate_visitor.h kis_scale_visitor.h \
kis_selected_transaction.h kis_strategy_move.h kis_transform_worker.h kis_datamanager.h \
kis_filter_strategy.h kis_iteratorpixeltrait.h kis_merge_visitor.h kis_thread.h kis_thread_pool.h
kis_filter_strategy.h kis_iteratorpixeltrait.h kis_merge_visitor.h kis_thread.h kis_thread_pool.h \
kis_change_profile_visitor.h
include_HEADERS = \
kis_adjustment_layer.h \
......
/*
* Copyright (c) 2006 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_CHANGE_PROFILE_VISITOR_H_
#define KIS_CHANGE_PROFILE_VISITOR_H_
#include "kis_global.h"
#include "kis_types.h"
#include "kis_layer_visitor.h"
#include "kis_paint_layer.h"
#include "kis_paint_device.h"
#include "kis_adjustment_layer.h"
#include "kis_group_layer.h"
/**
* The Change Profile visitor walks over all layers and if the current
* layer has the specified colorspace AND the specified old profile, sets
* the colorspace to the same colorspace with the NEW profile, without doing
* conversions. This is essential if you have loaded an image that didn't
* have an embedded profile to which you want to attach the right profile.
*/
class KisChangeProfileVisitor :public KisLayerVisitor {
public:
KisChangeProfileVisitor(KisColorSpace *oldColorSpace, KisColorSpace *dstColorSpace);
virtual ~KisChangeProfileVisitor();
public:
virtual bool visit(KisPaintLayer *layer);
virtual bool visit(KisGroupLayer *layer);
virtual bool visit(KisPartLayer *layer);
virtual bool visit(KisAdjustmentLayer* layer);
private:
KisColorSpace *m_oldColorSpace;
KisColorSpace *m_dstColorSpace;
};
KisChangeProfileVisitor::KisChangeProfileVisitor(KisColorSpace * oldColorSpace,
KisColorSpace *dstColorSpace) :
KisLayerVisitor(),
m_oldColorSpace(oldColorSpace),
m_dstColorSpace(dstColorSpace)
{
}
KisChangeProfileVisitor::~KisChangeProfileVisitor()
{
}
bool KisChangeProfileVisitor::visit(KisGroupLayer * layer)
{
// Clear the projection, we will have to re-render everything.
layer->resetProjection();
KisLayerSP child = layer->firstChild();
while (child) {
child->accept(*this);
child = child->nextSibling();
}
layer->setDirty(true);
return true;
}
bool KisChangeProfileVisitor::visit(KisPaintLayer *layer)
{
if (!layer) return false;
if (!layer->paintDevice()) return false;
if (!layer->paintDevice()->colorSpace()) return false;
KisColorSpace * cs = layer->paintDevice()->colorSpace();
if (cs == m_oldColorSpace) {
layer->paintDevice()->setProfile(m_dstColorSpace->getProfile());
layer->setDirty(true);
}
return true;
}
bool KisChangeProfileVisitor::visit(KisPartLayer *)
{
return true;
}
bool KisChangeProfileVisitor::visit(KisAdjustmentLayer * layer)
{
layer->resetCache();
layer->setDirty(true);
return true;
}
#endif // KIS_CHANGE_PROFILE_VISITOR_H_
......@@ -62,6 +62,7 @@
#include "kis_filter_strategy.h"
#include "kis_profile.h"
#include "kis_paint_layer.h"
#include "kis_change_profile_visitor.h"
class KisImage::KisImagePrivate {
public:
......@@ -817,10 +818,18 @@ KisProfile * KisImage::getProfile() const
void KisImage::setProfile(const KisProfile * profile)
{
KisColorSpace * dstSpace = KisMetaRegistry::instance()->csRegistry()->getColorSpace( colorSpace()->id(), profile);
//convertTo( dstSpace ); // XXX: We shouldn't convert here -- if you want to convert, use the conversion function.
setColorSpace(dstSpace);
emit(sigProfileChanged(const_cast<KisProfile *>(profile)));
if (profile == 0) return;
KisColorSpace * dstCs= KisMetaRegistry::instance()->csRegistry()->getColorSpace( colorSpace()->id(),
profile);
if (dstCs) {
KisColorSpace * oldCs = colorSpace();
setColorSpace(dstCs);
emit(sigProfileChanged(const_cast<KisProfile *>(profile)));
KisChangeProfileVisitor visitor(oldCs, dstCs);
m_rootLayer->accept(visitor);
}
}
double KisImage::xRes()
......@@ -1158,7 +1167,7 @@ void KisImage::renderToPainter(Q_INT32 x1,
float exposure)
{
kdDebug() << "Render to painter " << x1 << ", " << y1 << " : " << x2 << ", " << y2 << endl;
Q_INT32 w = x2 - x1 + 1;
Q_INT32 h = y2 - y1 + 1;
......@@ -1255,8 +1264,9 @@ KisColor KisImage::mergedPixel(Q_INT32 x, Q_INT32 y)
void KisImage::updateProjection(const QRect& rc)
{
QRect rect = rc & QRect(0, 0, width(), height());
kdDebug() << "updating projection : " << rc.x() << ", " rc.y() << ", " << rc.width() << ", " << rc.height() << endl;
KisMergeVisitor visitor(this, m_rootLayer->projection(), rc);
m_rootLayer -> accept(visitor);
......
......@@ -143,7 +143,15 @@ public:
// Get the profile associated with this image
KisProfile * getProfile() const;
// Set the profile associated with this image
/**
* Set the profile of the image to the new profile and do the same for
* all layers that have the same colorspace and profile as the image.
* It doesn't do any pixel conversion.
*
* This is essential if you have loaded an image that didn't
* have an embedded profile to which you want to attach the right profile.
*/
void setProfile(const KisProfile * profile);
/**
......
......@@ -211,7 +211,7 @@ KisPaintDevice::KisPaintDevice(KisColorSpace * colorSpace, const char * name) :
{
//kdDebug() << "creating paint device " << name << endl;
if (name == 0) {
kdDebug() << "device without a name " << kdBacktrace() << "\n";
//kdDebug() << "device without a name " << kdBacktrace() << "\n";
}
if (colorSpace == 0) {
kdDebug(41001) << "Cannot create paint device without colorstrategy!\n";
......@@ -250,7 +250,7 @@ KisPaintDevice::KisPaintDevice(KisLayer *parent, KisColorSpace * colorSpace, con
Q_ASSERT( colorSpace );
//kdDebug() << "creating paint device " << name << endl;
if (name == 0) {
kdDebug() << "device without a name " << kdBacktrace() << "\n";
//kdDebug() << "device without a name " << kdBacktrace() << "\n";
}
m_dcop = 0;
......@@ -624,6 +624,18 @@ void KisPaintDevice::convertTo(KisColorSpace * dstColorSpace, Q_INT32 renderingI
}
}
void KisPaintDevice::setProfile(KisProfile * profile)
{
if (profile == 0) return;
KisColorSpace * dstSpace =
KisMetaRegistry::instance()->csRegistry()->getColorSpace( colorSpace()->id(),
profile);
if (dstSpace)
m_colorSpace = dstSpace;
}
void KisPaintDevice::setData(KisDataManagerSP data, KisColorSpace * colorSpace)
{
m_datamanager = data;
......
......@@ -227,6 +227,12 @@ public:
*/
virtual void convertTo(KisColorSpace * dstColorSpace, Q_INT32 renderingIntent = INTENT_PERCEPTUAL);
/**
* Changes the profile of the colorspace of this paint device to the given
* profile. If the given profile is 0, nothing happens.
*/
virtual void setProfile(KisProfile * profile);
/**
* Fill this paint device with the data from img; starting at (offsetX, offsetY)
* @param srcProfileName name of the RGB profile to interpret the img as. "" is interpreted as sRGB
......
......@@ -62,6 +62,10 @@ public:
virtual ~KisAbstractColorSpace();
virtual bool operator==(const KisAbstractColorSpace& rhs) {
return (m_id == rhs.m_id && m_profile == rhs.m_profile);
}
//================== Information about this color strategy ========================//
......
......@@ -56,6 +56,11 @@ public:
virtual DCOPObject * dcopObject();
virtual bool operator==(const KisColorSpace& rhs) {
return id().id() == rhs.id().id();
}
public:
//========== Channels =====================================================//
......
......@@ -98,7 +98,7 @@ void KritaFiltersGallery::showFiltersGalleryDialog()
KisPaintDeviceSP dev = img->activeDevice();
if (!dev) return;
QRect r1 = dev -> extent();
QRect r1 = dev -> exactBounds();
QRect r2 = img -> bounds();
QRect rect = r1.intersect(r2);
......
......@@ -123,7 +123,7 @@ void KisDlgFiltersGallery::refreshPreview( )
KisTransaction cmd("Temporary transaction", layer.data());
KisFilterConfiguration* config = m_currentFilter->configuration(m_currentConfigWidget);
QRect rect = layer -> extent();
QRect rect = layer -> exactBounds();
m_currentFilter->process(layer.data(), layer.data(), config, rect);
m_widget->previewWidget->slotUpdate();
cmd.unexecute();
......
......@@ -241,12 +241,36 @@ void KisChannelSeparator::separate(KisProgressDisplayInterface * progress, enumS
image->addLayer( dynamic_cast<KisLayer*>(l.data()), image -> rootLayer(), 0);
}
else {
/*
QStringList listMimeFilter = KoFilterManager::mimeFilter("application/x-krita", KoFilterManager::Export);
QString mimelist = listMimeFilter.join(" ");
// To images
// create a document
// create an image
// add layer to image
// show document in new view
KFileDialog fd (QString::null, mimelist, this, "Export Layer", true);
fd.setCaption(i18n("Export Layer"));
fd.setMimeFilter(listMimeFilter);
fd.setOperationMode(KFileDialog::Saving);
if (!fd.exec()) return;
KURL url = fd.selectedURL();
QString mimefilter = fd.currentMimeFilter();
if (url.isEmpty())
return;
QRect r = l -> exactBounds();
KisDoc d;
d.prepareForImport();
KisImageSP dst = new KisImage(d.undoAdapter(), r.width(), r.height(), img->colorSpace(), l->name());
d.setCurrentImage( dst );
dst->addLayer(l->clone(), dst->rootLayer(), 0);
d.setOutputMimeType(mimefilter.latin1());
d.exp0rt(url);
*/
}
}
image->notify();
......@@ -261,4 +285,7 @@ void KisChannelSeparator::separate(KisProgressDisplayInterface * progress, enumS
}
#include "kis_channel_separator.moc"
......@@ -59,6 +59,7 @@ public:
public: // Implement KisProgressSubject
virtual void cancel() { m_cancelRequested = true; }
private:
KisView * m_view;
bool m_cancelRequested;
......
......@@ -30,9 +30,11 @@ R * Fix drying the wet colorspace
Core
? * When painting with the qpainter, if the zoom factor is < 1, we should first
A * When painting with the qpainter, if the zoom factor is < 1, we should first
scale down, then colorcorrect, then add the masks, then paint. This would
solve the slow loading for big images problem.
A * When painting with qpainter, simply resizing the window seems to result in a complete
repaint. This happens every time a docked docker changes width, for instance.
R * rendering with complex groupings gives very wrong results
P * Fix part layers (nearly done)
R * disable everything necessary when the current layer is wet.
......
......@@ -200,7 +200,7 @@ KisBirdEyeBox::KisBirdEyeBox(KisView * view, QWidget* parent, const char* name)
m_exposureDoubleWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
hl->addWidget(m_exposureDoubleWidget);
//l->addItem(new QSpacerItem(0, 1, QSizePolicy::Minimum, QSizePolicy::Expanding));
l->addItem(new QSpacerItem(0, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding));
m_exposureDoubleWidget -> setPrecision(1);
m_exposureDoubleWidget -> setValue(0);
......
......@@ -161,11 +161,10 @@ KisDoc::KisDoc(QWidget *parentWidget, const char *widgetName, QObject *parent, c
KisDoc::~KisDoc()
{
// XXX: Now gives a crash, see CRASHES file.
delete m_cmdHistory;
delete m_dcop;
delete m_nserver;
m_undoListeners.setAutoDelete(false);
delete m_dcop;
}
QCString KisDoc::mimeType() const
......@@ -445,6 +444,7 @@ KisImageSP KisDoc::loadImage(const QDomElement& element)
}
img = new KisImage(this, width, height, cs, name);
img->blockSignals(true); // Don't send out signals while we're building the image
Q_CHECK_PTR(img);
connect( img, SIGNAL( sigImageModified() ), this, SLOT( slotImageUpdated() ));
img -> setDescription(description);
......@@ -452,8 +452,6 @@ KisImageSP KisDoc::loadImage(const QDomElement& element)
loadLayers(element, img, img -> rootLayer().data());
} else {
// TODO Try to import it
}
img -> notifyImageLoaded();
......@@ -1139,6 +1137,7 @@ KisImageSP KisDoc::currentImage()
void KisDoc::setCurrentImage(KisImageSP image)
{
kdDebug() << "setCurrentImage " << image->name() << "\n";
m_currentImage = image;
setUndo(true);
image->notifyImageLoaded();
......
......@@ -75,8 +75,8 @@ void KisIntSpinbox::init(int val)
l->insertStretch(0, 1);
d->m_numinput = new QLineEdit(this, "KisIntSpinbox::QLineEdit");
d->m_numinput->setInputMask("000%");
d->m_numinput->setMaximumWidth(d->m_numinput->fontMetrics().width("100%"));
d->m_numinput->setMinimumWidth(d->m_numinput->fontMetrics().width("100%"));
//d->m_numinput->setMaximumWidth(d->m_numinput->fontMetrics().width("100%"));
//d->m_numinput->setMinimumWidth(d->m_numinput->fontMetrics().width("100%"));
d->m_numinput->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
l->addWidget( d->m_numinput );
......
......@@ -20,6 +20,7 @@
#include <qtooltip.h>
#include <qtoolbutton.h>
#include <qcursor.h>
#include <qeventloop.h>
#include <kdebug.h>
#include <kapplication.h>
......@@ -167,9 +168,11 @@ void KisLabelProgress::update(int percent)
m_bar -> setValue(percent);
KApplication *app = KApplication::kApplication();
Q_ASSERT(app);
app -> processEvents();
// The following is safer, but makes cancel impossible:
//QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput |
// QEventLoop::ExcludeSocketNotifiers);
}
void KisLabelProgress::updateStage(const QString&, int percent)
......
......@@ -187,7 +187,7 @@ void KisToolManager::setCurrentTool(KisTool *tool)
tool->createOptionWidget(0);
}
QWidget * w = tool->optionWidget();
w->setMinimumWidth(200); // XXX Hack! This has been measured to be the widest tool docker :-( BSAR
m_paletteManager->addWidget(w, krita::TOOL_OPTION_WIDGET, krita::CONTROL_PALETTE );
m_inputDeviceToolMap[m_controller->currentInputDevice()] = tool;
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment