Commit 1432f48b authored by Cyrille Berger's avatar Cyrille Berger

* add a dialog for selecting and configuring operators

* add the ashikhmin02 operator and its configuration widget

svn path=/trunk/koffice/; revision=714086
parent 6e7b088e
......@@ -2,19 +2,22 @@ include_directories(lib/ libpfs/)
set(kritatonemapping_PART_SRCS
tonemapping.cc
kis_tonemapping_dialog.cc
# Krita Tone Mapping Library
lib/kis_tone_mapping_operator.cc
lib/kis_tone_mapping_operators_registry.cc
lib/kis_tone_mapping_operator_configuration_widget.cc
# PFS Library (only needed for most operators)
libpfs/kis_array2d.cc
# ashikhmin 02 operator
operators/ashikhmin02/tmo_ashikhmin02.cpp
operators/ashikhmin02/kis_ashikhmin02_operator.cc
)
# kde4_add_ui_files(kritatonemapping_PART_SRCS myuifile.ui )
kde4_add_ui_files(kritatonemapping_PART_SRCS operators/ashikhmin02/ashikhmin02_configuration_widget.ui wdgtonemappingdialog.ui)
kde4_add_plugin(kritatonemapping ${kritatonemapping_PART_SRCS})
......
/*
* Copyright (c) 2007 Cyrille Berger (cberger@cberger.net)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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_tonemapping_dialog.h"
#include <KoGenericRegistryModel.h>
#include <kis_layer.h>
#include "kis_tone_mapping_operator.h"
#include "kis_tone_mapping_operator_configuration_widget.h"
#include "kis_tone_mapping_operators_registry.h"
#include "ui_wdgtonemappingdialog.h"
struct KisToneMappingOperatorConfigurationWidget;
struct KisToneMappingDialog::Private {
KisLayerSP layer;
Ui_WdgToneMappingDialog uiToneMappingDialog;
KoGenericRegistryModel<KisToneMappingOperator*>* operatorsModel;
KisToneMappingOperatorConfigurationWidget* currentConfigurationWidget;
QWidget* currentCentralWidget;
QGridLayout *widgetLayout;
};
KisToneMappingDialog::KisToneMappingDialog(QWidget* parent, KisLayerSP _layer) : QDialog(parent), d(new Private)
{
d->layer = _layer;
d->currentConfigurationWidget = 0;
d->currentCentralWidget = 0;
d->uiToneMappingDialog.setupUi(this);
d->widgetLayout = new QGridLayout( d->uiToneMappingDialog.centralWidgetHolder );
connect(d->uiToneMappingDialog.comboBoxOperators, SIGNAL(activated ( int )), SLOT(slotOperatorSelected(int )) );
connect(d->uiToneMappingDialog.pushButtonOk, SIGNAL(pressed()), SLOT(accept()));
connect(d->uiToneMappingDialog.pushButtonOk, SIGNAL(pressed()), SLOT(apply()));
connect(d->uiToneMappingDialog.pushButtonCancel, SIGNAL(pressed()), SLOT(reject()));
d->operatorsModel = new KoGenericRegistryModel<KisToneMappingOperator*>(KisToneMappingOperatorsRegistry::instance());
d->uiToneMappingDialog.comboBoxOperators->setModel(d->operatorsModel);
slotOperatorSelected(0);
}
void KisToneMappingDialog::apply()
{
}
void KisToneMappingDialog::slotOperatorSelected(int index)
{
kDebug() << "slotOperatorSelected(" << index << ")";
QModelIndex modelIndex = d->operatorsModel->index(index,0);
KisToneMappingOperator* tmop = d->operatorsModel->get( modelIndex );
if( tmop)
{
delete d->currentCentralWidget;
KisToneMappingOperatorConfigurationWidget* widget = tmop->createConfigurationWidget( d->uiToneMappingDialog.centralWidgetHolder );
if(widget)
{
d->currentConfigurationWidget = widget;
d->currentCentralWidget = widget;
} else {
d->currentConfigurationWidget = 0;
d->currentCentralWidget = new QLabel( i18n("No configuration option."), d->uiToneMappingDialog.centralWidgetHolder );
}
d->widgetLayout->addWidget( d->currentCentralWidget, 0 , 0);
}
}
#include "kis_tonemapping_dialog.moc"
/*
* Copyright (c) 2007 Cyrille Berger (cberger@cberger.net)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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_TONEMAPPING_DIALOG_H_
#define _KIS_TONEMAPPING_DIALOG_H_
#include <QDialog>
#include <kis_types.h>
class Ui_WdgToneMappingDialog;
class KisToneMappingDialog : public QDialog {
Q_OBJECT
public:
KisToneMappingDialog(QWidget* parent, KisLayerSP layer);
protected slots:
void slotOperatorSelected(int );
void apply();
private:
struct Private;
Private* const d;
};
#endif
/*
* Copyright (c) 2007 Cyrille Berger (cberger@cberger.net)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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_tone_mapping_operator_configuration_widget.h"
KisToneMappingOperatorConfigurationWidget::KisToneMappingOperatorConfigurationWidget(QWidget * parent, Qt::WFlags f ) : QWidget(parent, f)
{
}
KisToneMappingOperatorConfigurationWidget::~KisToneMappingOperatorConfigurationWidget()
{
}
#include "kis_tone_mapping_operator_configuration_widget.moc"
......@@ -20,8 +20,37 @@
#include <QWidget>
class KisPropertiesConfiguration;
/**
* Base class of configuration widget of tonemapping operators.
*/
class KisToneMappingOperatorConfigurationWidget : public QWidget {
Q_OBJECT
protected:
KisToneMappingOperatorConfigurationWidget(QWidget * parent, Qt::WFlags f = 0 );
public:
virtual ~KisToneMappingOperatorConfigurationWidget();
/**
* @param config the configuration widget for this tonemapping operator.
*/
virtual void setConfiguration(KisPropertiesConfiguration* config) = 0;
/**
* @return the tonemapping operator configuration
*/
virtual KisPropertiesConfiguration* configuration() const = 0;
signals:
/**
* Subclasses should emit this signal whenever the preview should be
* be recalculated.
*/
void sigPleaseUpdatePreview();
};
......
......@@ -15,7 +15,7 @@
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
*/
#ifndef _KIS_ARRAY_2D_H_
#define _KIS_ARRAY_2D_H_
......
<ui version="4.0" >
<class>Ashikhmin02OperatorConfigurationWidget</class>
<widget class="QWidget" name="Ashikhmin02OperatorConfigurationWidget" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>295</width>
<height>132</height>
</rect>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>
<layout class="QGridLayout" >
<item row="0" column="0" colspan="2" >
<widget class="QCheckBox" name="simple" >
<property name="text" >
<string>simple</string>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>Local contrast threshold:</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QDoubleSpinBox" name="localContrast" >
<property name="maximum" >
<double>10.000000000000000</double>
</property>
<property name="singleStep" >
<double>0.100000000000000</double>
</property>
<property name="value" >
<double>0.500000000000000</double>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>Equation:</string>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QComboBox" name="equation" >
<item>
<property name="text" >
<string>2</string>
</property>
</item>
<item>
<property name="text" >
<string>4</string>
</property>
</item>
</widget>
</item>
<item row="3" column="1" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
/*
* Copyright (c) 2007 Cyrille Berger <cberger@cberger.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2 of the License.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "kis_ashikhmin02_operator.h"
#include <kis_properties_configuration.h>
#include <kis_tone_mapping_operator_configuration_widget.h>
#include "ui_ashikhmin02_configuration_widget.h"
class KisAshikhmin02OperatorConfigurationWidget : public KisToneMappingOperatorConfigurationWidget{
public:
KisAshikhmin02OperatorConfigurationWidget(QWidget* wdg) : KisToneMappingOperatorConfigurationWidget(wdg)
{
widget.setupUi(this);
}
virtual void setConfiguration(KisPropertiesConfiguration* config)
{
}
virtual KisPropertiesConfiguration* configuration() const
{
KisPropertiesConfiguration* config = new KisPropertiesConfiguration();
return config;
}
private:
Ui_Ashikhmin02OperatorConfigurationWidget widget;
};
KisAshikhmin02Operator::KisAshikhmin02Operator() : KisToneMappingOperator("ashikhminO2", i18n("Ashikhmin 02"))
{
}
KisToneMappingOperatorConfigurationWidget* KisAshikhmin02Operator::createConfigurationWidget(QWidget* wdg) const
{
return new KisAshikhmin02OperatorConfigurationWidget(wdg);
}
void KisAshikhmin02Operator::toneMap(KisPaintDeviceSP, KisPropertiesConfiguration* config) const
{
}
/*
* Copyright (c) 2007 Cyrille Berger <cberger@cberger.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2 of the License.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef _KIS_ASHIKHMIN02_OPERATOR_H_
#define _KIS_ASHIKHMIN02_OPERATOR_H_
#include "kis_tone_mapping_operator.h"
class KisAshikhmin02Operator : public KisToneMappingOperator {
public:
KisAshikhmin02Operator();
virtual KisToneMappingOperatorConfigurationWidget* createConfigurationWidget(QWidget*) const;
virtual void toneMap(KisPaintDeviceSP, KisPropertiesConfiguration* config) const;
};
#endif
......@@ -26,11 +26,17 @@
#include <klocale.h>
#include <kstandarddirs.h>
#include "kis_config.h"
#include "kis_cursor.h"
#include "kis_global.h"
#include "kis_types.h"
#include "kis_view2.h"
#include <kis_config.h>
#include <kis_cursor.h>
#include <kis_global.h>
#include <kis_layer.h>
#include <kis_types.h>
#include <kis_view2.h>
#include "kis_tone_mapping_operators_registry.h"
#include "kis_tonemapping_dialog.h"
#include "operators/ashikhmin02/kis_ashikhmin02_operator.h"
typedef KGenericFactory<tonemappingPlugin> tonemappingPluginFactory;
K_EXPORT_COMPONENT_FACTORY( kritatonemapping, tonemappingPluginFactory( "krita" ) )
......@@ -50,6 +56,8 @@ tonemappingPlugin::tonemappingPlugin(QObject *parent, const QStringList &)
m_toneMappingAction = new KAction(i18n("Tonemapping"), this);
actionCollection()->addAction("tonemapping", m_toneMappingAction );
connect(m_toneMappingAction, SIGNAL(triggered()), this, SLOT(slotToneMapping()));
KisToneMappingOperatorsRegistry::instance()->add(new KisAshikhmin02Operator);
}
}
......@@ -60,6 +68,10 @@ tonemappingPlugin::~tonemappingPlugin()
void tonemappingPlugin::slotToneMapping()
{
KisToneMappingDialog* dialog = new KisToneMappingDialog(m_view, m_view->activeLayer());
dialog->setVisible(true);
dialog->setAttribute(Qt::WA_DeleteOnClose);
}
#include "tonemapping.moc"
<ui version="4.0" >
<class>WdgToneMappingDialog</class>
<widget class="QWidget" name="WdgToneMappingDialog" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>
<layout class="QGridLayout" >
<item row="0" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>Operator:</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2" >
<widget class="QComboBox" name="comboBoxOperators" />
</item>
<item row="1" column="0" >
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>Preset:</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2" >
<widget class="QComboBox" name="comboBoxPresets" />
</item>
<item row="2" column="0" colspan="4" >
<widget class="QWidget" native="1" name="centralWidgetHolder" />
</item>
<item row="3" column="2" >
<widget class="QPushButton" name="pushButtonOk" >
<property name="text" >
<string>Ok</string>
</property>
</widget>
</item>
<item row="3" column="3" >
<widget class="QPushButton" name="pushButtonCancel" >
<property name="text" >
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
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