From d63c9d696eb6e2539528b99afc21f4086c9defe3 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Sun, 23 May 2021 20:48:35 +0900 Subject: Renaming of files in preparation for code style tools. Signed-off-by: Michele Calgaro (cherry picked from commit 8b78a8791bc539bcffe7159f9d9714d577cb3d7d) --- chalk/plugins/viewplugins/colorrange/Makefile.am | 2 +- chalk/plugins/viewplugins/colorrange/colorrange.cc | 82 -- .../plugins/viewplugins/colorrange/colorrange.cpp | 82 ++ .../viewplugins/colorrange/dlg_colorrange.cc | 351 ------ .../viewplugins/colorrange/dlg_colorrange.cpp | 351 ++++++ .../viewplugins/colorspaceconversion/Makefile.am | 2 +- .../colorspaceconversion/colorspaceconversion.cc | 155 --- .../colorspaceconversion/colorspaceconversion.cpp | 155 +++ .../dlg_colorspaceconversion.cc | 91 -- .../dlg_colorspaceconversion.cpp | 91 ++ chalk/plugins/viewplugins/dropshadow/Makefile.am | 4 +- .../viewplugins/dropshadow/dlg_dropshadow.cc | 117 -- .../viewplugins/dropshadow/dlg_dropshadow.cpp | 117 ++ .../viewplugins/dropshadow/kis_dropshadow.cc | 758 ------------- .../viewplugins/dropshadow/kis_dropshadow.cpp | 758 +++++++++++++ .../dropshadow/kis_dropshadow_plugin.cc | 91 -- .../dropshadow/kis_dropshadow_plugin.cpp | 91 ++ .../plugins/viewplugins/filtersgallery/Makefile.am | 4 +- .../viewplugins/filtersgallery/filters_gallery.cc | 138 --- .../viewplugins/filtersgallery/filters_gallery.cpp | 138 +++ .../filtersgallery/kis_dlg_filtersgallery.cc | 133 --- .../filtersgallery/kis_dlg_filtersgallery.cpp | 133 +++ chalk/plugins/viewplugins/histogram/Makefile.am | 2 +- .../plugins/viewplugins/histogram/dlg_histogram.cc | 68 -- .../viewplugins/histogram/dlg_histogram.cpp | 68 ++ chalk/plugins/viewplugins/histogram/histogram.cc | 105 -- chalk/plugins/viewplugins/histogram/histogram.cpp | 105 ++ .../viewplugins/histogram/kis_histogram_widget.cc | 147 --- .../viewplugins/histogram/kis_histogram_widget.cpp | 147 +++ .../viewplugins/histogram_docker/Makefile.am | 2 +- .../histogram_docker/histogramdocker.cc | 192 ---- .../histogram_docker/histogramdocker.cpp | 192 ++++ .../histogram_docker/kis_accumulating_producer.cc | 102 -- .../histogram_docker/kis_accumulating_producer.cpp | 102 ++ .../histogram_docker/kis_cachedhistogram.cc | 37 - .../histogram_docker/kis_cachedhistogram.cpp | 37 + .../histogram_docker/kis_imagerasteredcache.cc | 162 --- .../histogram_docker/kis_imagerasteredcache.cpp | 162 +++ .../plugins/viewplugins/history_docker/Makefile.am | 2 +- .../viewplugins/history_docker/historydocker.cc | 58 - .../viewplugins/history_docker/historydocker.cpp | 58 + chalk/plugins/viewplugins/imagesize/Makefile.am | 2 +- .../plugins/viewplugins/imagesize/dlg_imagesize.cc | 277 ----- .../viewplugins/imagesize/dlg_imagesize.cpp | 277 +++++ .../plugins/viewplugins/imagesize/dlg_layersize.cc | 261 ----- .../viewplugins/imagesize/dlg_layersize.cpp | 261 +++++ chalk/plugins/viewplugins/imagesize/imagesize.cc | 190 ---- chalk/plugins/viewplugins/imagesize/imagesize.cpp | 190 ++++ .../viewplugins/modify_selection/Makefile.am | 2 +- .../modify_selection/dlg_border_selection.cc | 76 -- .../modify_selection/dlg_border_selection.cpp | 76 ++ .../modify_selection/dlg_grow_selection.cc | 76 -- .../modify_selection/dlg_grow_selection.cpp | 76 ++ .../modify_selection/dlg_shrink_selection.cc | 81 -- .../modify_selection/dlg_shrink_selection.cpp | 81 ++ .../modify_selection/modify_selection.cc | 158 --- .../modify_selection/modify_selection.cpp | 158 +++ .../viewplugins/performancetest/Makefile.am | 2 +- .../viewplugins/performancetest/dlg_perftest.cc | 110 -- .../viewplugins/performancetest/dlg_perftest.cpp | 110 ++ .../viewplugins/performancetest/perftest.cc | 1198 -------------------- .../viewplugins/performancetest/perftest.cpp | 1198 ++++++++++++++++++++ chalk/plugins/viewplugins/rotateimage/Makefile.am | 2 +- .../viewplugins/rotateimage/dlg_rotateimage.cc | 147 --- .../viewplugins/rotateimage/dlg_rotateimage.cpp | 147 +++ .../plugins/viewplugins/rotateimage/rotateimage.cc | 134 --- .../viewplugins/rotateimage/rotateimage.cpp | 134 +++ chalk/plugins/viewplugins/scripting/Makefile.am | 2 +- chalk/plugins/viewplugins/scripting/scripting.cc | 111 -- chalk/plugins/viewplugins/scripting/scripting.cpp | 111 ++ chalk/plugins/viewplugins/selectopaque/Makefile.am | 2 +- .../viewplugins/selectopaque/selectopaque.cc | 116 -- .../viewplugins/selectopaque/selectopaque.cpp | 116 ++ .../viewplugins/separate_channels/Makefile.am | 4 +- .../viewplugins/separate_channels/dlg_separate.cc | 110 -- .../viewplugins/separate_channels/dlg_separate.cpp | 110 ++ .../separate_channels/kis_channel_separator.cc | 301 ----- .../separate_channels/kis_channel_separator.cpp | 301 +++++ .../kis_separate_channels_plugin.cc | 96 -- .../kis_separate_channels_plugin.cpp | 96 ++ chalk/plugins/viewplugins/shearimage/Makefile.am | 2 +- .../viewplugins/shearimage/dlg_shearimage.cc | 96 -- .../viewplugins/shearimage/dlg_shearimage.cpp | 96 ++ chalk/plugins/viewplugins/shearimage/shearimage.cc | 113 -- .../plugins/viewplugins/shearimage/shearimage.cpp | 113 ++ chalk/plugins/viewplugins/substrate/Makefile.am | 2 +- .../plugins/viewplugins/substrate/dlg_substrate.cc | 59 - .../viewplugins/substrate/dlg_substrate.cpp | 59 + .../substrate/kis_repeating_substrate.cc | 0 .../substrate/kis_repeating_substrate.cpp | 0 chalk/plugins/viewplugins/substrate/substrate.cc | 78 -- chalk/plugins/viewplugins/substrate/substrate.cpp | 78 ++ chalk/plugins/viewplugins/variations/Makefile.am | 2 +- .../viewplugins/variations/dlg_variations.cc | 58 - .../viewplugins/variations/dlg_variations.cpp | 58 + chalk/plugins/viewplugins/variations/variations.cc | 88 -- .../plugins/viewplugins/variations/variations.cpp | 88 ++ 97 files changed, 6741 insertions(+), 6741 deletions(-) delete mode 100644 chalk/plugins/viewplugins/colorrange/colorrange.cc create mode 100644 chalk/plugins/viewplugins/colorrange/colorrange.cpp delete mode 100644 chalk/plugins/viewplugins/colorrange/dlg_colorrange.cc create mode 100644 chalk/plugins/viewplugins/colorrange/dlg_colorrange.cpp delete mode 100644 chalk/plugins/viewplugins/colorspaceconversion/colorspaceconversion.cc create mode 100644 chalk/plugins/viewplugins/colorspaceconversion/colorspaceconversion.cpp delete mode 100644 chalk/plugins/viewplugins/colorspaceconversion/dlg_colorspaceconversion.cc create mode 100644 chalk/plugins/viewplugins/colorspaceconversion/dlg_colorspaceconversion.cpp delete mode 100644 chalk/plugins/viewplugins/dropshadow/dlg_dropshadow.cc create mode 100644 chalk/plugins/viewplugins/dropshadow/dlg_dropshadow.cpp delete mode 100644 chalk/plugins/viewplugins/dropshadow/kis_dropshadow.cc create mode 100644 chalk/plugins/viewplugins/dropshadow/kis_dropshadow.cpp delete mode 100644 chalk/plugins/viewplugins/dropshadow/kis_dropshadow_plugin.cc create mode 100644 chalk/plugins/viewplugins/dropshadow/kis_dropshadow_plugin.cpp delete mode 100644 chalk/plugins/viewplugins/filtersgallery/filters_gallery.cc create mode 100644 chalk/plugins/viewplugins/filtersgallery/filters_gallery.cpp delete mode 100644 chalk/plugins/viewplugins/filtersgallery/kis_dlg_filtersgallery.cc create mode 100644 chalk/plugins/viewplugins/filtersgallery/kis_dlg_filtersgallery.cpp delete mode 100644 chalk/plugins/viewplugins/histogram/dlg_histogram.cc create mode 100644 chalk/plugins/viewplugins/histogram/dlg_histogram.cpp delete mode 100644 chalk/plugins/viewplugins/histogram/histogram.cc create mode 100644 chalk/plugins/viewplugins/histogram/histogram.cpp delete mode 100644 chalk/plugins/viewplugins/histogram/kis_histogram_widget.cc create mode 100644 chalk/plugins/viewplugins/histogram/kis_histogram_widget.cpp delete mode 100644 chalk/plugins/viewplugins/histogram_docker/histogramdocker.cc create mode 100644 chalk/plugins/viewplugins/histogram_docker/histogramdocker.cpp delete mode 100644 chalk/plugins/viewplugins/histogram_docker/kis_accumulating_producer.cc create mode 100644 chalk/plugins/viewplugins/histogram_docker/kis_accumulating_producer.cpp delete mode 100644 chalk/plugins/viewplugins/histogram_docker/kis_cachedhistogram.cc create mode 100644 chalk/plugins/viewplugins/histogram_docker/kis_cachedhistogram.cpp delete mode 100644 chalk/plugins/viewplugins/histogram_docker/kis_imagerasteredcache.cc create mode 100644 chalk/plugins/viewplugins/histogram_docker/kis_imagerasteredcache.cpp delete mode 100644 chalk/plugins/viewplugins/history_docker/historydocker.cc create mode 100644 chalk/plugins/viewplugins/history_docker/historydocker.cpp delete mode 100644 chalk/plugins/viewplugins/imagesize/dlg_imagesize.cc create mode 100644 chalk/plugins/viewplugins/imagesize/dlg_imagesize.cpp delete mode 100644 chalk/plugins/viewplugins/imagesize/dlg_layersize.cc create mode 100644 chalk/plugins/viewplugins/imagesize/dlg_layersize.cpp delete mode 100644 chalk/plugins/viewplugins/imagesize/imagesize.cc create mode 100644 chalk/plugins/viewplugins/imagesize/imagesize.cpp delete mode 100644 chalk/plugins/viewplugins/modify_selection/dlg_border_selection.cc create mode 100644 chalk/plugins/viewplugins/modify_selection/dlg_border_selection.cpp delete mode 100644 chalk/plugins/viewplugins/modify_selection/dlg_grow_selection.cc create mode 100644 chalk/plugins/viewplugins/modify_selection/dlg_grow_selection.cpp delete mode 100644 chalk/plugins/viewplugins/modify_selection/dlg_shrink_selection.cc create mode 100644 chalk/plugins/viewplugins/modify_selection/dlg_shrink_selection.cpp delete mode 100644 chalk/plugins/viewplugins/modify_selection/modify_selection.cc create mode 100644 chalk/plugins/viewplugins/modify_selection/modify_selection.cpp delete mode 100644 chalk/plugins/viewplugins/performancetest/dlg_perftest.cc create mode 100644 chalk/plugins/viewplugins/performancetest/dlg_perftest.cpp delete mode 100644 chalk/plugins/viewplugins/performancetest/perftest.cc create mode 100644 chalk/plugins/viewplugins/performancetest/perftest.cpp delete mode 100644 chalk/plugins/viewplugins/rotateimage/dlg_rotateimage.cc create mode 100644 chalk/plugins/viewplugins/rotateimage/dlg_rotateimage.cpp delete mode 100644 chalk/plugins/viewplugins/rotateimage/rotateimage.cc create mode 100644 chalk/plugins/viewplugins/rotateimage/rotateimage.cpp delete mode 100644 chalk/plugins/viewplugins/scripting/scripting.cc create mode 100644 chalk/plugins/viewplugins/scripting/scripting.cpp delete mode 100644 chalk/plugins/viewplugins/selectopaque/selectopaque.cc create mode 100644 chalk/plugins/viewplugins/selectopaque/selectopaque.cpp delete mode 100644 chalk/plugins/viewplugins/separate_channels/dlg_separate.cc create mode 100644 chalk/plugins/viewplugins/separate_channels/dlg_separate.cpp delete mode 100644 chalk/plugins/viewplugins/separate_channels/kis_channel_separator.cc create mode 100644 chalk/plugins/viewplugins/separate_channels/kis_channel_separator.cpp delete mode 100644 chalk/plugins/viewplugins/separate_channels/kis_separate_channels_plugin.cc create mode 100644 chalk/plugins/viewplugins/separate_channels/kis_separate_channels_plugin.cpp delete mode 100644 chalk/plugins/viewplugins/shearimage/dlg_shearimage.cc create mode 100644 chalk/plugins/viewplugins/shearimage/dlg_shearimage.cpp delete mode 100644 chalk/plugins/viewplugins/shearimage/shearimage.cc create mode 100644 chalk/plugins/viewplugins/shearimage/shearimage.cpp delete mode 100644 chalk/plugins/viewplugins/substrate/dlg_substrate.cc create mode 100644 chalk/plugins/viewplugins/substrate/dlg_substrate.cpp delete mode 100644 chalk/plugins/viewplugins/substrate/kis_repeating_substrate.cc create mode 100644 chalk/plugins/viewplugins/substrate/kis_repeating_substrate.cpp delete mode 100644 chalk/plugins/viewplugins/substrate/substrate.cc create mode 100644 chalk/plugins/viewplugins/substrate/substrate.cpp delete mode 100644 chalk/plugins/viewplugins/variations/dlg_variations.cc create mode 100644 chalk/plugins/viewplugins/variations/dlg_variations.cpp delete mode 100644 chalk/plugins/viewplugins/variations/variations.cc create mode 100644 chalk/plugins/viewplugins/variations/variations.cpp (limited to 'chalk/plugins/viewplugins') diff --git a/chalk/plugins/viewplugins/colorrange/Makefile.am b/chalk/plugins/viewplugins/colorrange/Makefile.am index c8752391..e2ab687d 100644 --- a/chalk/plugins/viewplugins/colorrange/Makefile.am +++ b/chalk/plugins/viewplugins/colorrange/Makefile.am @@ -7,7 +7,7 @@ INCLUDES = -I$(srcdir)/../../../sdk \ kde_module_LTLIBRARIES = chalkcolorrange.la -chalkcolorrange_la_SOURCES = colorrange.cc dlg_colorrange.cc wdg_colorrange.ui +chalkcolorrange_la_SOURCES = colorrange.cpp dlg_colorrange.cpp wdg_colorrange.ui noinst_HEADERS = wdg_colorrange.h dlg_colorrange.h colorrange.h chalkcolorrange_la_LIBADD = $(LIB_KOFFICEUI) ../../../libchalkcommon.la \ diff --git a/chalk/plugins/viewplugins/colorrange/colorrange.cc b/chalk/plugins/viewplugins/colorrange/colorrange.cc deleted file mode 100644 index be0648ba..00000000 --- a/chalk/plugins/viewplugins/colorrange/colorrange.cc +++ /dev/null @@ -1,82 +0,0 @@ -/* - * colorrange.h -- Part of Chalk - * - * Copyright (c) 2004 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 - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "colorrange.h" -#include "dlg_colorrange.h" - -typedef KGenericFactory ColorRangeFactory; -K_EXPORT_COMPONENT_FACTORY( chalkcolorrange, ColorRangeFactory( "chalk" ) ) - -ColorRange::ColorRange(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - - if (parent->inherits("KisView")) { - setInstance(ColorRangeFactory::instance()); - setXMLFile(locate("data","chalkplugins/colorrange.rc"), true); - m_view = dynamic_cast(parent); - m_view->canvasSubject()->selectionManager()->addSelectionAction( new TDEAction(i18n("&Color Range..."), 0, 0, this, TQT_SLOT(slotActivated()), actionCollection(), "colorrange") ); - - } -} - -ColorRange::~ColorRange() -{ -} - -void ColorRange::slotActivated() -{ - KisPaintDeviceSP layer = m_view->canvasSubject()->currentImg()->activeDevice(); - if (!layer) return; - - DlgColorRange * dlgColorRange = new DlgColorRange(m_view, layer, m_view, "ColorRange"); - TQ_CHECK_PTR(dlgColorRange); - - dlgColorRange->exec(); -} - -#include "colorrange.moc" - diff --git a/chalk/plugins/viewplugins/colorrange/colorrange.cpp b/chalk/plugins/viewplugins/colorrange/colorrange.cpp new file mode 100644 index 00000000..be0648ba --- /dev/null +++ b/chalk/plugins/viewplugins/colorrange/colorrange.cpp @@ -0,0 +1,82 @@ +/* + * colorrange.h -- Part of Chalk + * + * Copyright (c) 2004 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 + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "colorrange.h" +#include "dlg_colorrange.h" + +typedef KGenericFactory ColorRangeFactory; +K_EXPORT_COMPONENT_FACTORY( chalkcolorrange, ColorRangeFactory( "chalk" ) ) + +ColorRange::ColorRange(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + + if (parent->inherits("KisView")) { + setInstance(ColorRangeFactory::instance()); + setXMLFile(locate("data","chalkplugins/colorrange.rc"), true); + m_view = dynamic_cast(parent); + m_view->canvasSubject()->selectionManager()->addSelectionAction( new TDEAction(i18n("&Color Range..."), 0, 0, this, TQT_SLOT(slotActivated()), actionCollection(), "colorrange") ); + + } +} + +ColorRange::~ColorRange() +{ +} + +void ColorRange::slotActivated() +{ + KisPaintDeviceSP layer = m_view->canvasSubject()->currentImg()->activeDevice(); + if (!layer) return; + + DlgColorRange * dlgColorRange = new DlgColorRange(m_view, layer, m_view, "ColorRange"); + TQ_CHECK_PTR(dlgColorRange); + + dlgColorRange->exec(); +} + +#include "colorrange.moc" + diff --git a/chalk/plugins/viewplugins/colorrange/dlg_colorrange.cc b/chalk/plugins/viewplugins/colorrange/dlg_colorrange.cc deleted file mode 100644 index 453bbec2..00000000 --- a/chalk/plugins/viewplugins/colorrange/dlg_colorrange.cc +++ /dev/null @@ -1,351 +0,0 @@ -/* - * dlg_colorrange.cc - part of KimageShop^WKrayon^WChalk - * - * Copyright (c) 2004 Boudewijn Rempt - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "dlg_colorrange.h" -#include "wdg_colorrange.h" - -namespace { - -// XXX: Poynton says: hsv/hls is not what one ought to use for colour calculations. -// Unfortunately, I don't know enough to be able to use anything else. - - bool isReddish(int h) - { - return ((h > 330 && h < 360) || ( h > 0 && h < 40)); - } - - bool isYellowish(int h) - { - return (h> 40 && h < 65); - } - - bool isGreenish(int h) - { - return (h > 70 && h < 155); - } - - bool isCyanish(int h) - { - return (h > 150 && h < 190); - } - - bool isBlueish(int h) - { - return (h > 185 && h < 270); - } - - bool isMagentaish(int h) - { - return (h > 265 && h < 330); - } - - bool isHighlight(int v) - { - return (v > 200); - } - - bool isMidTone(int v) - { - return (v > 100 && v < 200); - } - - bool isShadow(int v) - { - return (v < 100); - } - -} - -TQ_UINT32 matchColors(const TQColor & c, enumAction action) -{ - int r = c.red(); - int g = c.green(); - int b = c.blue(); - - int h, s, v; - rgb_to_hsv(r, g, b, &h, &s, &v); - - - - // XXX: Map the degree in which the colors conform to the requirement - // to a range of selectedness between 0 and 255 - - // XXX: Implement out-of-gamut using lcms - - switch(action) { - - case REDS: - if (isReddish(h)) - return MAX_SELECTED; - else - return MIN_SELECTED; - case YELLOWS: - if (isYellowish(h)) { - return MAX_SELECTED; - } - else - return MIN_SELECTED; - case GREENS: - if (isGreenish(h)) - return MAX_SELECTED; - else - return MIN_SELECTED; - case CYANS: - if (isCyanish(h)) - return MAX_SELECTED; - else - return MIN_SELECTED; - case BLUES: - if (isBlueish(h)) - return MAX_SELECTED; - else - return MIN_SELECTED; - case MAGENTAS: - if (isMagentaish(h)) - return MAX_SELECTED; - else - return MIN_SELECTED; - case HIGHLIGHTS: - if (isHighlight(v)) - return MAX_SELECTED; - else - return MIN_SELECTED; - case MIDTONES: - if (isMidTone(v)) - return MAX_SELECTED; - else - return MIN_SELECTED; - case SHADOWS: - if (isShadow(v)) - return MAX_SELECTED; - else - return MIN_SELECTED; - }; - - return MIN_SELECTED; -} - - - -DlgColorRange::DlgColorRange( KisView * view, KisPaintDeviceSP dev, TQWidget * parent, const char * name) - : super (parent, name, true, i18n("Color Range"), Ok | Cancel, Ok) -{ - m_dev = dev; - m_view = view; - - m_subject = view->canvasSubject(); - - m_page = new WdgColorRange(this, "color_range"); - TQ_CHECK_PTR(m_page); - - setCaption(i18n("Color Range")); - setMainWidget(m_page); - resize(m_page->sizeHint()); - - if (m_dev->image()->undo()) m_transaction = new KisSelectedTransaction(i18n("Select by Color Range"), m_dev); - - if(! m_dev->hasSelection()) - m_dev->selection()->clear(); - m_selection = m_dev->selection(); - - updatePreview(); - - m_invert = false; - m_mode = SELECTION_ADD; - m_currentAction = REDS; - - connect(this, TQT_SIGNAL(okClicked()), - this, TQT_SLOT(okClicked())); - - connect(this, TQT_SIGNAL(cancelClicked()), - this, TQT_SLOT(cancelClicked())); - - connect(m_page->chkInvert, TQT_SIGNAL(clicked()), - this, TQT_SLOT(slotInvertClicked())); - - connect(m_page->cmbSelect, TQT_SIGNAL(activated(int)), - this, TQT_SLOT(slotSelectionTypeChanged(int))); - - connect (m_page->radioAdd, TQT_SIGNAL(toggled(bool)), - this, TQT_SLOT(slotAdd(bool))); - - connect (m_page->radioSubtract, TQT_SIGNAL(toggled(bool)), - this, TQT_SLOT(slotSubtract(bool))); - - connect (m_page->bnSelect, TQT_SIGNAL(clicked()), - this, TQT_SLOT(slotSelectClicked())); - - connect (m_page->bnDeselect, TQT_SIGNAL(clicked()), - this, TQT_SLOT(slotDeselectClicked())); - -} - -DlgColorRange::~DlgColorRange() -{ - delete m_page; -} - - -void DlgColorRange::updatePreview() -{ - if (!m_selection) return; - - TQ_INT32 x, y, w, h; - m_dev->exactBounds(x, y, w, h); - TQPixmap pix = TQPixmap(m_selection->maskImage().smoothScale(350, 350, TQ_ScaleMin)); - m_subject->canvasController()->updateCanvas(); - m_page->pixSelection->setPixmap(pix); -} - -void DlgColorRange::okClicked() -{ - m_dev->setDirty(); - m_dev->emitSelectionChanged(); - - if (m_dev->image()->undo()) m_subject->undoAdapter()->addCommand(m_transaction); - accept(); -} - -void DlgColorRange::cancelClicked() -{ - if (m_dev->image()->undo()) m_transaction->unexecute(); - - m_subject->canvasController()->updateCanvas(); - reject(); -} - -void DlgColorRange::slotInvertClicked() -{ - m_invert = m_page->chkInvert->isChecked(); -} - -void DlgColorRange::slotSelectionTypeChanged(int index) -{ - m_currentAction = (enumAction)index; -} - -void DlgColorRange::slotSubtract(bool on) -{ - if (on) - m_mode = SELECTION_SUBTRACT; -} -void DlgColorRange::slotAdd(bool on) -{ - if (on) - m_mode = SELECTION_ADD; -} - -void DlgColorRange::slotSelectClicked() -{ - TQApplication::setOverrideCursor(KisCursor::waitCursor()); - // XXX: Multithread this! - TQ_INT32 x, y, w, h; - m_dev->exactBounds(x, y, w, h); - KisColorSpace * cs = m_dev->colorSpace(); - TQ_UINT8 opacity; - for (int y2 = y; y2 < h - y; ++y2) { - KisHLineIterator hiter = m_dev->createHLineIterator(x, y2, w, false); - KisHLineIterator selIter = m_selection ->createHLineIterator(x, y2, w, true); - while (!hiter.isDone()) { - TQColor c; - - cs->toTQColor(hiter.rawData(), &c, &opacity); - // Don't try to select transparent pixels. - if (opacity > OPACITY_TRANSPARENT) { - TQ_UINT8 match = matchColors(c, m_currentAction); - - if (match) { - // Personally, I think the invert option a bit silly. But it's possible I don't quite understand it. BSAR. - if (!m_invert) { - if (m_mode == SELECTION_ADD) { - *(selIter.rawData()) = match; - } - else if (m_mode == SELECTION_SUBTRACT) { - TQ_UINT8 selectedness = *(selIter.rawData()); - if (match < selectedness) { - *(selIter.rawData()) = selectedness - match; - } - else { - *(selIter.rawData()) = 0; - } - } - } - else { - if (m_mode == SELECTION_ADD) { - TQ_UINT8 selectedness = *(selIter.rawData()); - if (match < selectedness) { - *(selIter.rawData()) = selectedness - match; - } - else { - *(selIter.rawData()) = 0; - } - } - else if (m_mode == SELECTION_SUBTRACT) { - *(selIter.rawData()) = match; - } - } - } - } - ++hiter; - ++selIter; - } - } - updatePreview(); - TQApplication::restoreOverrideCursor(); -} - -void DlgColorRange::slotDeselectClicked() -{ - m_dev->selection()->clear(); - updatePreview(); -} - - -#include "dlg_colorrange.moc" diff --git a/chalk/plugins/viewplugins/colorrange/dlg_colorrange.cpp b/chalk/plugins/viewplugins/colorrange/dlg_colorrange.cpp new file mode 100644 index 00000000..82748f4c --- /dev/null +++ b/chalk/plugins/viewplugins/colorrange/dlg_colorrange.cpp @@ -0,0 +1,351 @@ +/* + * dlg_colorrange.cpp - part of KimageShop^WKrayon^WChalk + * + * Copyright (c) 2004 Boudewijn Rempt + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "dlg_colorrange.h" +#include "wdg_colorrange.h" + +namespace { + +// XXX: Poynton says: hsv/hls is not what one ought to use for colour calculations. +// Unfortunately, I don't know enough to be able to use anything else. + + bool isReddish(int h) + { + return ((h > 330 && h < 360) || ( h > 0 && h < 40)); + } + + bool isYellowish(int h) + { + return (h> 40 && h < 65); + } + + bool isGreenish(int h) + { + return (h > 70 && h < 155); + } + + bool isCyanish(int h) + { + return (h > 150 && h < 190); + } + + bool isBlueish(int h) + { + return (h > 185 && h < 270); + } + + bool isMagentaish(int h) + { + return (h > 265 && h < 330); + } + + bool isHighlight(int v) + { + return (v > 200); + } + + bool isMidTone(int v) + { + return (v > 100 && v < 200); + } + + bool isShadow(int v) + { + return (v < 100); + } + +} + +TQ_UINT32 matchColors(const TQColor & c, enumAction action) +{ + int r = c.red(); + int g = c.green(); + int b = c.blue(); + + int h, s, v; + rgb_to_hsv(r, g, b, &h, &s, &v); + + + + // XXX: Map the degree in which the colors conform to the requirement + // to a range of selectedness between 0 and 255 + + // XXX: Implement out-of-gamut using lcms + + switch(action) { + + case REDS: + if (isReddish(h)) + return MAX_SELECTED; + else + return MIN_SELECTED; + case YELLOWS: + if (isYellowish(h)) { + return MAX_SELECTED; + } + else + return MIN_SELECTED; + case GREENS: + if (isGreenish(h)) + return MAX_SELECTED; + else + return MIN_SELECTED; + case CYANS: + if (isCyanish(h)) + return MAX_SELECTED; + else + return MIN_SELECTED; + case BLUES: + if (isBlueish(h)) + return MAX_SELECTED; + else + return MIN_SELECTED; + case MAGENTAS: + if (isMagentaish(h)) + return MAX_SELECTED; + else + return MIN_SELECTED; + case HIGHLIGHTS: + if (isHighlight(v)) + return MAX_SELECTED; + else + return MIN_SELECTED; + case MIDTONES: + if (isMidTone(v)) + return MAX_SELECTED; + else + return MIN_SELECTED; + case SHADOWS: + if (isShadow(v)) + return MAX_SELECTED; + else + return MIN_SELECTED; + }; + + return MIN_SELECTED; +} + + + +DlgColorRange::DlgColorRange( KisView * view, KisPaintDeviceSP dev, TQWidget * parent, const char * name) + : super (parent, name, true, i18n("Color Range"), Ok | Cancel, Ok) +{ + m_dev = dev; + m_view = view; + + m_subject = view->canvasSubject(); + + m_page = new WdgColorRange(this, "color_range"); + TQ_CHECK_PTR(m_page); + + setCaption(i18n("Color Range")); + setMainWidget(m_page); + resize(m_page->sizeHint()); + + if (m_dev->image()->undo()) m_transaction = new KisSelectedTransaction(i18n("Select by Color Range"), m_dev); + + if(! m_dev->hasSelection()) + m_dev->selection()->clear(); + m_selection = m_dev->selection(); + + updatePreview(); + + m_invert = false; + m_mode = SELECTION_ADD; + m_currentAction = REDS; + + connect(this, TQT_SIGNAL(okClicked()), + this, TQT_SLOT(okClicked())); + + connect(this, TQT_SIGNAL(cancelClicked()), + this, TQT_SLOT(cancelClicked())); + + connect(m_page->chkInvert, TQT_SIGNAL(clicked()), + this, TQT_SLOT(slotInvertClicked())); + + connect(m_page->cmbSelect, TQT_SIGNAL(activated(int)), + this, TQT_SLOT(slotSelectionTypeChanged(int))); + + connect (m_page->radioAdd, TQT_SIGNAL(toggled(bool)), + this, TQT_SLOT(slotAdd(bool))); + + connect (m_page->radioSubtract, TQT_SIGNAL(toggled(bool)), + this, TQT_SLOT(slotSubtract(bool))); + + connect (m_page->bnSelect, TQT_SIGNAL(clicked()), + this, TQT_SLOT(slotSelectClicked())); + + connect (m_page->bnDeselect, TQT_SIGNAL(clicked()), + this, TQT_SLOT(slotDeselectClicked())); + +} + +DlgColorRange::~DlgColorRange() +{ + delete m_page; +} + + +void DlgColorRange::updatePreview() +{ + if (!m_selection) return; + + TQ_INT32 x, y, w, h; + m_dev->exactBounds(x, y, w, h); + TQPixmap pix = TQPixmap(m_selection->maskImage().smoothScale(350, 350, TQ_ScaleMin)); + m_subject->canvasController()->updateCanvas(); + m_page->pixSelection->setPixmap(pix); +} + +void DlgColorRange::okClicked() +{ + m_dev->setDirty(); + m_dev->emitSelectionChanged(); + + if (m_dev->image()->undo()) m_subject->undoAdapter()->addCommand(m_transaction); + accept(); +} + +void DlgColorRange::cancelClicked() +{ + if (m_dev->image()->undo()) m_transaction->unexecute(); + + m_subject->canvasController()->updateCanvas(); + reject(); +} + +void DlgColorRange::slotInvertClicked() +{ + m_invert = m_page->chkInvert->isChecked(); +} + +void DlgColorRange::slotSelectionTypeChanged(int index) +{ + m_currentAction = (enumAction)index; +} + +void DlgColorRange::slotSubtract(bool on) +{ + if (on) + m_mode = SELECTION_SUBTRACT; +} +void DlgColorRange::slotAdd(bool on) +{ + if (on) + m_mode = SELECTION_ADD; +} + +void DlgColorRange::slotSelectClicked() +{ + TQApplication::setOverrideCursor(KisCursor::waitCursor()); + // XXX: Multithread this! + TQ_INT32 x, y, w, h; + m_dev->exactBounds(x, y, w, h); + KisColorSpace * cs = m_dev->colorSpace(); + TQ_UINT8 opacity; + for (int y2 = y; y2 < h - y; ++y2) { + KisHLineIterator hiter = m_dev->createHLineIterator(x, y2, w, false); + KisHLineIterator selIter = m_selection ->createHLineIterator(x, y2, w, true); + while (!hiter.isDone()) { + TQColor c; + + cs->toTQColor(hiter.rawData(), &c, &opacity); + // Don't try to select transparent pixels. + if (opacity > OPACITY_TRANSPARENT) { + TQ_UINT8 match = matchColors(c, m_currentAction); + + if (match) { + // Personally, I think the invert option a bit silly. But it's possible I don't quite understand it. BSAR. + if (!m_invert) { + if (m_mode == SELECTION_ADD) { + *(selIter.rawData()) = match; + } + else if (m_mode == SELECTION_SUBTRACT) { + TQ_UINT8 selectedness = *(selIter.rawData()); + if (match < selectedness) { + *(selIter.rawData()) = selectedness - match; + } + else { + *(selIter.rawData()) = 0; + } + } + } + else { + if (m_mode == SELECTION_ADD) { + TQ_UINT8 selectedness = *(selIter.rawData()); + if (match < selectedness) { + *(selIter.rawData()) = selectedness - match; + } + else { + *(selIter.rawData()) = 0; + } + } + else if (m_mode == SELECTION_SUBTRACT) { + *(selIter.rawData()) = match; + } + } + } + } + ++hiter; + ++selIter; + } + } + updatePreview(); + TQApplication::restoreOverrideCursor(); +} + +void DlgColorRange::slotDeselectClicked() +{ + m_dev->selection()->clear(); + updatePreview(); +} + + +#include "dlg_colorrange.moc" diff --git a/chalk/plugins/viewplugins/colorspaceconversion/Makefile.am b/chalk/plugins/viewplugins/colorspaceconversion/Makefile.am index 00f93d3c..23780106 100644 --- a/chalk/plugins/viewplugins/colorspaceconversion/Makefile.am +++ b/chalk/plugins/viewplugins/colorspaceconversion/Makefile.am @@ -14,7 +14,7 @@ INCLUDES = -I$(srcdir)/../../../sdk \ kde_module_LTLIBRARIES = chalkcolorspaceconversion.la -chalkcolorspaceconversion_la_SOURCES = wdgconvertcolorspace.ui colorspaceconversion.cc dlg_colorspaceconversion.cc +chalkcolorspaceconversion_la_SOURCES = wdgconvertcolorspace.ui colorspaceconversion.cpp dlg_colorspaceconversion.cpp noinst_HEADERS = wdgconvertcolorspace.h dlg_colorspaceconversion.h colorspaceconversion.h chalkcolorspaceconversion_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) $(LIB_QT) -ltdecore -ltdeui -lkjs -ltdefx -ltdeio -ltdeparts diff --git a/chalk/plugins/viewplugins/colorspaceconversion/colorspaceconversion.cc b/chalk/plugins/viewplugins/colorspaceconversion/colorspaceconversion.cc deleted file mode 100644 index d956ee46..00000000 --- a/chalk/plugins/viewplugins/colorspaceconversion/colorspaceconversion.cc +++ /dev/null @@ -1,155 +0,0 @@ -/* - * colorspaceconversion.cc -- Part of Chalk - * - * Copyright (c) 2004 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 - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include "kis_meta_registry.h" -#include -#include -#include -#include -#include - -#include "colorspaceconversion.h" -#include "dlg_colorspaceconversion.h" -#include "wdgconvertcolorspace.h" - -typedef KGenericFactory ColorSpaceConversionFactory; -K_EXPORT_COMPONENT_FACTORY( chalkcolorspaceconversion, ColorSpaceConversionFactory( "chalk" ) ) - - -ColorSpaceConversion::ColorSpaceConversion(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - - if ( parent->inherits("KisView") ) - { - m_view = (KisView*) parent; - - setInstance(ColorSpaceConversionFactory::instance()); - setXMLFile(locate("data","chalkplugins/colorspaceconversion.rc"), true); - - (void) new TDEAction(i18n("&Convert Image Type..."), 0, 0, this, TQT_SLOT(slotImgColorSpaceConversion()), actionCollection(), "imgcolorspaceconversion"); - (void) new TDEAction(i18n("&Convert Layer Type..."), 0, 0, this, TQT_SLOT(slotLayerColorSpaceConversion()), actionCollection(), "layercolorspaceconversion"); - - } -} - -ColorSpaceConversion::~ColorSpaceConversion() -{ - m_view = 0; -} - -void ColorSpaceConversion::slotImgColorSpaceConversion() -{ - KisImageSP image = m_view->canvasSubject()->currentImg(); - - if (!image) return; - - - if (image->colorSpace()->willDegrade(TO_LAB16)) { - if (KMessageBox::warningContinueCancel(m_view, - i18n("This conversion will convert your %1 image through 16-bit L*a*b* and back.\n" - "Watercolor and openEXR colorspaces will even be converted through 8-bit RGB.\n") - .arg(image->colorSpace()->id().name()), - i18n("Colorspace Conversion"), - KGuiItem(i18n("Continue")), - "lab16degradation") != KMessageBox::Continue) return; - - } - - DlgColorSpaceConversion * dlgColorSpaceConversion = new DlgColorSpaceConversion(m_view, "ColorSpaceConversion"); - TQ_CHECK_PTR(dlgColorSpaceConversion); - - dlgColorSpaceConversion->setCaption(i18n("Convert All Layers From ") + image->colorSpace()->id().name()); - - if (dlgColorSpaceConversion->exec() == TQDialog::Accepted) { - // XXX: Do the rest of the stuff - KisID cspace = dlgColorSpaceConversion->m_page->cmbColorSpaces->currentItem(); - KisColorSpace * cs = KisMetaRegistry::instance()->csRegistry()->getColorSpace(cspace, dlgColorSpaceConversion->m_page->cmbDestProfile->currentText()); - - TQApplication::setOverrideCursor(KisCursor::waitCursor()); - image->convertTo(cs, dlgColorSpaceConversion->m_page->grpIntent->selectedId()); - TQApplication::restoreOverrideCursor(); - } - delete dlgColorSpaceConversion; -} - -void ColorSpaceConversion::slotLayerColorSpaceConversion() -{ - - KisImageSP image = m_view->canvasSubject()->currentImg(); - if (!image) return; - - KisPaintDeviceSP dev = image->activeDevice(); - if (!dev) return; - - if (dev->colorSpace()->willDegrade(TO_LAB16)) { - if (KMessageBox::warningContinueCancel(m_view, - i18n("This conversion will convert your %1 layer through 16-bit L*a*b* and back.\n" - "Watercolor and openEXR colorspaces will even be converted through 8-bit RGB.\n") - .arg(dev->colorSpace()->id().name()), - i18n("Colorspace Conversion"), - KGuiItem(i18n("Continue")), - "lab16degradation") != KMessageBox::Continue) return; - - } - - DlgColorSpaceConversion * dlgColorSpaceConversion = new DlgColorSpaceConversion(m_view, "ColorSpaceConversion"); - TQ_CHECK_PTR(dlgColorSpaceConversion); - - dlgColorSpaceConversion->setCaption(i18n("Convert Current Layer From") + dev->colorSpace()->id().name()); - - if (dlgColorSpaceConversion->exec() == TQDialog::Accepted) { - KisID cspace = dlgColorSpaceConversion->m_page->cmbColorSpaces->currentItem(); - KisColorSpace * cs = KisMetaRegistry::instance()->csRegistry() -> - getColorSpace(cspace, dlgColorSpaceConversion->m_page->cmbDestProfile->currentText()); - - TQApplication::setOverrideCursor(KisCursor::waitCursor()); - dev->convertTo(cs, dlgColorSpaceConversion->m_page->grpIntent->selectedId()); - TQApplication::restoreOverrideCursor(); - } - delete dlgColorSpaceConversion; -} - -#include "colorspaceconversion.moc" diff --git a/chalk/plugins/viewplugins/colorspaceconversion/colorspaceconversion.cpp b/chalk/plugins/viewplugins/colorspaceconversion/colorspaceconversion.cpp new file mode 100644 index 00000000..377f0569 --- /dev/null +++ b/chalk/plugins/viewplugins/colorspaceconversion/colorspaceconversion.cpp @@ -0,0 +1,155 @@ +/* + * colorspaceconversion.cpp -- Part of Chalk + * + * Copyright (c) 2004 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 + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include "kis_meta_registry.h" +#include +#include +#include +#include +#include + +#include "colorspaceconversion.h" +#include "dlg_colorspaceconversion.h" +#include "wdgconvertcolorspace.h" + +typedef KGenericFactory ColorSpaceConversionFactory; +K_EXPORT_COMPONENT_FACTORY( chalkcolorspaceconversion, ColorSpaceConversionFactory( "chalk" ) ) + + +ColorSpaceConversion::ColorSpaceConversion(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + + if ( parent->inherits("KisView") ) + { + m_view = (KisView*) parent; + + setInstance(ColorSpaceConversionFactory::instance()); + setXMLFile(locate("data","chalkplugins/colorspaceconversion.rc"), true); + + (void) new TDEAction(i18n("&Convert Image Type..."), 0, 0, this, TQT_SLOT(slotImgColorSpaceConversion()), actionCollection(), "imgcolorspaceconversion"); + (void) new TDEAction(i18n("&Convert Layer Type..."), 0, 0, this, TQT_SLOT(slotLayerColorSpaceConversion()), actionCollection(), "layercolorspaceconversion"); + + } +} + +ColorSpaceConversion::~ColorSpaceConversion() +{ + m_view = 0; +} + +void ColorSpaceConversion::slotImgColorSpaceConversion() +{ + KisImageSP image = m_view->canvasSubject()->currentImg(); + + if (!image) return; + + + if (image->colorSpace()->willDegrade(TO_LAB16)) { + if (KMessageBox::warningContinueCancel(m_view, + i18n("This conversion will convert your %1 image through 16-bit L*a*b* and back.\n" + "Watercolor and openEXR colorspaces will even be converted through 8-bit RGB.\n") + .arg(image->colorSpace()->id().name()), + i18n("Colorspace Conversion"), + KGuiItem(i18n("Continue")), + "lab16degradation") != KMessageBox::Continue) return; + + } + + DlgColorSpaceConversion * dlgColorSpaceConversion = new DlgColorSpaceConversion(m_view, "ColorSpaceConversion"); + TQ_CHECK_PTR(dlgColorSpaceConversion); + + dlgColorSpaceConversion->setCaption(i18n("Convert All Layers From ") + image->colorSpace()->id().name()); + + if (dlgColorSpaceConversion->exec() == TQDialog::Accepted) { + // XXX: Do the rest of the stuff + KisID cspace = dlgColorSpaceConversion->m_page->cmbColorSpaces->currentItem(); + KisColorSpace * cs = KisMetaRegistry::instance()->csRegistry()->getColorSpace(cspace, dlgColorSpaceConversion->m_page->cmbDestProfile->currentText()); + + TQApplication::setOverrideCursor(KisCursor::waitCursor()); + image->convertTo(cs, dlgColorSpaceConversion->m_page->grpIntent->selectedId()); + TQApplication::restoreOverrideCursor(); + } + delete dlgColorSpaceConversion; +} + +void ColorSpaceConversion::slotLayerColorSpaceConversion() +{ + + KisImageSP image = m_view->canvasSubject()->currentImg(); + if (!image) return; + + KisPaintDeviceSP dev = image->activeDevice(); + if (!dev) return; + + if (dev->colorSpace()->willDegrade(TO_LAB16)) { + if (KMessageBox::warningContinueCancel(m_view, + i18n("This conversion will convert your %1 layer through 16-bit L*a*b* and back.\n" + "Watercolor and openEXR colorspaces will even be converted through 8-bit RGB.\n") + .arg(dev->colorSpace()->id().name()), + i18n("Colorspace Conversion"), + KGuiItem(i18n("Continue")), + "lab16degradation") != KMessageBox::Continue) return; + + } + + DlgColorSpaceConversion * dlgColorSpaceConversion = new DlgColorSpaceConversion(m_view, "ColorSpaceConversion"); + TQ_CHECK_PTR(dlgColorSpaceConversion); + + dlgColorSpaceConversion->setCaption(i18n("Convert Current Layer From") + dev->colorSpace()->id().name()); + + if (dlgColorSpaceConversion->exec() == TQDialog::Accepted) { + KisID cspace = dlgColorSpaceConversion->m_page->cmbColorSpaces->currentItem(); + KisColorSpace * cs = KisMetaRegistry::instance()->csRegistry() -> + getColorSpace(cspace, dlgColorSpaceConversion->m_page->cmbDestProfile->currentText()); + + TQApplication::setOverrideCursor(KisCursor::waitCursor()); + dev->convertTo(cs, dlgColorSpaceConversion->m_page->grpIntent->selectedId()); + TQApplication::restoreOverrideCursor(); + } + delete dlgColorSpaceConversion; +} + +#include "colorspaceconversion.moc" diff --git a/chalk/plugins/viewplugins/colorspaceconversion/dlg_colorspaceconversion.cc b/chalk/plugins/viewplugins/colorspaceconversion/dlg_colorspaceconversion.cc deleted file mode 100644 index 8159ad73..00000000 --- a/chalk/plugins/viewplugins/colorspaceconversion/dlg_colorspaceconversion.cc +++ /dev/null @@ -1,91 +0,0 @@ -/* - * dlg_colorspaceconversion.cc - part of KimageShop^WKrayon^WChalk - * - * Copyright (c) 2004 Boudewijn Rempt - * - * 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 -#include -#include -#include -#include - -#include -#include -#include - -#include "kis_meta_registry.h" -#include -#include "kis_profile.h" -#include "kis_colorspace.h" -#include -#include -#include - -#include "wdgconvertcolorspace.h" -#include "dlg_colorspaceconversion.h" - -DlgColorSpaceConversion::DlgColorSpaceConversion( TQWidget * parent, - const char * name) - : super (parent, name, true, i18n("Image Size"), Ok | Cancel, Ok) -{ - m_page = new WdgConvertColorSpace(this, "colorspace_conversion"); - TQ_CHECK_PTR(m_page); - - setMainWidget(m_page); - resize(m_page->sizeHint()); - - m_page->cmbColorSpaces->setIDList(KisMetaRegistry::instance()->csRegistry()->listKeys()); - - fillCmbDestProfile(m_page->cmbColorSpaces->currentItem()); - - connect(m_page->cmbColorSpaces, TQT_SIGNAL(activated(const KisID &)), - this, TQT_SLOT(fillCmbDestProfile(const KisID &))); - - - connect(this, TQT_SIGNAL(okClicked()), - this, TQT_SLOT(okClicked())); - -} - -DlgColorSpaceConversion::~DlgColorSpaceConversion() -{ - delete m_page; -} - -// SLOTS - -void DlgColorSpaceConversion::okClicked() -{ - accept(); -} - - -void DlgColorSpaceConversion::fillCmbDestProfile(const KisID & s) -{ - m_page->cmbDestProfile->clear(); - - TQValueVector profileList = KisMetaRegistry::instance()->csRegistry()->profilesFor(s); - TQValueVector ::iterator it; - for ( it = profileList.begin(); it != profileList.end(); ++it ) { - m_page->cmbDestProfile->insertItem((*it)->productName()); - - } -} - - -#include "dlg_colorspaceconversion.moc" diff --git a/chalk/plugins/viewplugins/colorspaceconversion/dlg_colorspaceconversion.cpp b/chalk/plugins/viewplugins/colorspaceconversion/dlg_colorspaceconversion.cpp new file mode 100644 index 00000000..259c6f47 --- /dev/null +++ b/chalk/plugins/viewplugins/colorspaceconversion/dlg_colorspaceconversion.cpp @@ -0,0 +1,91 @@ +/* + * dlg_colorspaceconversion.cpp - part of KimageShop^WKrayon^WChalk + * + * Copyright (c) 2004 Boudewijn Rempt + * + * 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 +#include +#include +#include +#include + +#include +#include +#include + +#include "kis_meta_registry.h" +#include +#include "kis_profile.h" +#include "kis_colorspace.h" +#include +#include +#include + +#include "wdgconvertcolorspace.h" +#include "dlg_colorspaceconversion.h" + +DlgColorSpaceConversion::DlgColorSpaceConversion( TQWidget * parent, + const char * name) + : super (parent, name, true, i18n("Image Size"), Ok | Cancel, Ok) +{ + m_page = new WdgConvertColorSpace(this, "colorspace_conversion"); + TQ_CHECK_PTR(m_page); + + setMainWidget(m_page); + resize(m_page->sizeHint()); + + m_page->cmbColorSpaces->setIDList(KisMetaRegistry::instance()->csRegistry()->listKeys()); + + fillCmbDestProfile(m_page->cmbColorSpaces->currentItem()); + + connect(m_page->cmbColorSpaces, TQT_SIGNAL(activated(const KisID &)), + this, TQT_SLOT(fillCmbDestProfile(const KisID &))); + + + connect(this, TQT_SIGNAL(okClicked()), + this, TQT_SLOT(okClicked())); + +} + +DlgColorSpaceConversion::~DlgColorSpaceConversion() +{ + delete m_page; +} + +// SLOTS + +void DlgColorSpaceConversion::okClicked() +{ + accept(); +} + + +void DlgColorSpaceConversion::fillCmbDestProfile(const KisID & s) +{ + m_page->cmbDestProfile->clear(); + + TQValueVector profileList = KisMetaRegistry::instance()->csRegistry()->profilesFor(s); + TQValueVector ::iterator it; + for ( it = profileList.begin(); it != profileList.end(); ++it ) { + m_page->cmbDestProfile->insertItem((*it)->productName()); + + } +} + + +#include "dlg_colorspaceconversion.moc" diff --git a/chalk/plugins/viewplugins/dropshadow/Makefile.am b/chalk/plugins/viewplugins/dropshadow/Makefile.am index d65b4b0e..3b9a8620 100644 --- a/chalk/plugins/viewplugins/dropshadow/Makefile.am +++ b/chalk/plugins/viewplugins/dropshadow/Makefile.am @@ -14,8 +14,8 @@ INCLUDES = -I$(srcdir)/../../../sdk \ kde_module_LTLIBRARIES = chalkdropshadow.la chalkdropshadow_la_SOURCES = wdg_dropshadow.ui \ - kis_dropshadow.cc dlg_dropshadow.cc \ - kis_dropshadow_plugin.cc + kis_dropshadow.cpp dlg_dropshadow.cpp \ + kis_dropshadow_plugin.cpp noinst_HEADERS = wdg_dropshadow.h kis_dropshadow_plugin.h \ kis_dropshadow.h dlg_dropshadow.h diff --git a/chalk/plugins/viewplugins/dropshadow/dlg_dropshadow.cc b/chalk/plugins/viewplugins/dropshadow/dlg_dropshadow.cc deleted file mode 100644 index 59019489..00000000 --- a/chalk/plugins/viewplugins/dropshadow/dlg_dropshadow.cc +++ /dev/null @@ -1,117 +0,0 @@ -/* - * dlg_dropshadow.cc - part of KimageShop^WKrayon^WChalk - * - * Copyright (c) 2005 Michael Thaler - * Copyright (c) 2006 Cyrille Berger - * - * 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 -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "dlg_dropshadow.h" -#include "wdg_dropshadow.h" - -DlgDropshadow::DlgDropshadow( const TQString & /*imageCS*/, - const TQString & /*layerCS*/, - TQWidget * parent, - const char * name) - : super (parent, name, true, i18n("Drop Shadow"), Ok | Cancel, Ok) -{ - m_page = new WdgDropshadow(this, "dropshadow"); - TQ_CHECK_PTR(m_page); - setMainWidget(m_page); - resize(m_page->sizeHint()); - - TDEConfig * cfg = TDEGlobal::config(); - m_page->xOffsetSpinBox->setValue( cfg->readNumEntry("dropshadow_x", 8) ); - m_page->yOffsetSpinBox->setValue( cfg->readNumEntry("dropshadow_y", 8) ); - m_page->blurRadiusSpinBox->setValue( cfg->readNumEntry("dropshadow_blurRadius", 5) ); - TQColor black(0,0,0); - m_page->shadowColorButton->setColor( cfg->readColorEntry("dropshadow_color", &black) ); - m_page->opacitySlider->setValue( cfg->readNumEntry("dropshadow_opacity", 80 ) ); - m_page->opacitySpinBox->setValue( cfg->readNumEntry("dropshadow_opacity", 80 ) ); - m_page->allowResizingCheckBox->setChecked( cfg->readBoolEntry("dropshadow_resizing", true ) ); - - connect(this, TQT_SIGNAL(okClicked()), - this, TQT_SLOT(okClicked())); -} - -DlgDropshadow::~DlgDropshadow() -{ - delete m_page; -} - -TQ_INT32 DlgDropshadow::getXOffset() -{ - return m_page->xOffsetSpinBox->value(); -} - -TQ_INT32 DlgDropshadow::getYOffset() -{ - return m_page->yOffsetSpinBox->value(); -} - -TQ_INT32 DlgDropshadow::getBlurRadius() -{ - return m_page->blurRadiusSpinBox->value(); -} - -TQ_UINT8 DlgDropshadow::getShadowOpacity() -{ - double opacity = (double)m_page->opacitySpinBox->value(); - //convert percent to a 8 bit opacity value - return (TQ_UINT8)(opacity / 100 * 255); -} - -TQColor DlgDropshadow::getShadowColor() -{ - return m_page->shadowColorButton->color(); -} - -bool DlgDropshadow::allowResizingChecked() -{ - return m_page->allowResizingCheckBox->isChecked(); -} - -// SLOTS - -void DlgDropshadow::okClicked() -{ - TDEConfig * cfg = TDEGlobal::config(); - cfg->writeEntry("dropshadow_x", m_page->xOffsetSpinBox->value()); - cfg->writeEntry("dropshadow_y", m_page->yOffsetSpinBox->value()); - cfg->writeEntry("dropshadow_blurRadius", m_page->blurRadiusSpinBox->value()); - cfg->writeEntry("dropshadow_color", m_page->shadowColorButton->color()); - cfg->writeEntry("dropshadow_opacity", m_page->opacitySpinBox->value()); - cfg->writeEntry("dropshadow_resizing", m_page->allowResizingCheckBox->isChecked()); - - accept(); -} - -#include "dlg_dropshadow.moc" diff --git a/chalk/plugins/viewplugins/dropshadow/dlg_dropshadow.cpp b/chalk/plugins/viewplugins/dropshadow/dlg_dropshadow.cpp new file mode 100644 index 00000000..c82bbbad --- /dev/null +++ b/chalk/plugins/viewplugins/dropshadow/dlg_dropshadow.cpp @@ -0,0 +1,117 @@ +/* + * dlg_dropshadow.cpp - part of KimageShop^WKrayon^WChalk + * + * Copyright (c) 2005 Michael Thaler + * Copyright (c) 2006 Cyrille Berger + * + * 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 +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "dlg_dropshadow.h" +#include "wdg_dropshadow.h" + +DlgDropshadow::DlgDropshadow( const TQString & /*imageCS*/, + const TQString & /*layerCS*/, + TQWidget * parent, + const char * name) + : super (parent, name, true, i18n("Drop Shadow"), Ok | Cancel, Ok) +{ + m_page = new WdgDropshadow(this, "dropshadow"); + TQ_CHECK_PTR(m_page); + setMainWidget(m_page); + resize(m_page->sizeHint()); + + TDEConfig * cfg = TDEGlobal::config(); + m_page->xOffsetSpinBox->setValue( cfg->readNumEntry("dropshadow_x", 8) ); + m_page->yOffsetSpinBox->setValue( cfg->readNumEntry("dropshadow_y", 8) ); + m_page->blurRadiusSpinBox->setValue( cfg->readNumEntry("dropshadow_blurRadius", 5) ); + TQColor black(0,0,0); + m_page->shadowColorButton->setColor( cfg->readColorEntry("dropshadow_color", &black) ); + m_page->opacitySlider->setValue( cfg->readNumEntry("dropshadow_opacity", 80 ) ); + m_page->opacitySpinBox->setValue( cfg->readNumEntry("dropshadow_opacity", 80 ) ); + m_page->allowResizingCheckBox->setChecked( cfg->readBoolEntry("dropshadow_resizing", true ) ); + + connect(this, TQT_SIGNAL(okClicked()), + this, TQT_SLOT(okClicked())); +} + +DlgDropshadow::~DlgDropshadow() +{ + delete m_page; +} + +TQ_INT32 DlgDropshadow::getXOffset() +{ + return m_page->xOffsetSpinBox->value(); +} + +TQ_INT32 DlgDropshadow::getYOffset() +{ + return m_page->yOffsetSpinBox->value(); +} + +TQ_INT32 DlgDropshadow::getBlurRadius() +{ + return m_page->blurRadiusSpinBox->value(); +} + +TQ_UINT8 DlgDropshadow::getShadowOpacity() +{ + double opacity = (double)m_page->opacitySpinBox->value(); + //convert percent to a 8 bit opacity value + return (TQ_UINT8)(opacity / 100 * 255); +} + +TQColor DlgDropshadow::getShadowColor() +{ + return m_page->shadowColorButton->color(); +} + +bool DlgDropshadow::allowResizingChecked() +{ + return m_page->allowResizingCheckBox->isChecked(); +} + +// SLOTS + +void DlgDropshadow::okClicked() +{ + TDEConfig * cfg = TDEGlobal::config(); + cfg->writeEntry("dropshadow_x", m_page->xOffsetSpinBox->value()); + cfg->writeEntry("dropshadow_y", m_page->yOffsetSpinBox->value()); + cfg->writeEntry("dropshadow_blurRadius", m_page->blurRadiusSpinBox->value()); + cfg->writeEntry("dropshadow_color", m_page->shadowColorButton->color()); + cfg->writeEntry("dropshadow_opacity", m_page->opacitySpinBox->value()); + cfg->writeEntry("dropshadow_resizing", m_page->allowResizingCheckBox->isChecked()); + + accept(); +} + +#include "dlg_dropshadow.moc" diff --git a/chalk/plugins/viewplugins/dropshadow/kis_dropshadow.cc b/chalk/plugins/viewplugins/dropshadow/kis_dropshadow.cc deleted file mode 100644 index 97c2c17e..00000000 --- a/chalk/plugins/viewplugins/dropshadow/kis_dropshadow.cc +++ /dev/null @@ -1,758 +0,0 @@ -/* - * This file is part of Chalk - * - * Copyright (c) 2005 Michael Thaler - * - * The gaussian blur algoithm is ported from gimo - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * 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 - -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include "kis_meta_registry.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "kis_rgb_colorspace.h" - -#include "kis_dropshadow.h" - -#define MIN(a, b) (((a) < (b)) ? (a) : (b)) -#define MAX(a, b) (((a) > (b)) ? (a) : (b)) - -KisDropshadow::KisDropshadow(KisView * view) - : m_view(view) -{ -} - -void KisDropshadow::dropshadow(KisProgressDisplayInterface * progress, TQ_INT32 xoffset, TQ_INT32 yoffset, TQ_INT32 blurradius, TQColor color, TQ_UINT8 opacity, bool allowResize) -{ - KisImageSP image = m_view->canvasSubject()->currentImg(); - if (!image) return; - - KisLayerSP src = image->activeLayer(); - if (!src) return; - - KisPaintDeviceSP dev = image->activeDevice(); - if (!dev) return; - - m_cancelRequested = false; - if ( progress ) - progress->setSubject(this, true, true); - emit notifyProgressStage(i18n("Add drop shadow..."), 0); - - if (image->undo()) { - image->undoAdapter()->beginMacro(i18n("Add Drop Shadow")); - } - - KisPaintDeviceSP shadowDev = new KisPaintDevice( KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA",""),"" ), "Shadow"); - KisPaintDeviceSP bShadowDev; - KisRgbColorSpace *rgb8cs = static_cast(shadowDev->colorSpace()); - - TQRect rect = dev->exactBounds(); - - for (TQ_INT32 row = 0; row < rect.height(); ++row) - { - KisHLineIteratorPixel srcIt = dev->createHLineIterator(rect.x(), rect.y() + row, rect.width(), false); - KisHLineIteratorPixel dstIt = shadowDev->createHLineIterator(rect.x(), rect.y() + row, rect.width(), true); - while( ! srcIt.isDone() ) - { - if (srcIt.isSelected()) - { - //set the shadow color - TQ_UINT8 alpha = dev->colorSpace()->getAlpha(srcIt.rawData()); - rgb8cs->setPixel(dstIt.rawData(), color.red(), color.green(), color.blue(), alpha); - } - ++srcIt; - ++dstIt; - } - emit notifyProgress((row * 100) / rect.height() ); - } - - if( blurradius > 0 ) - { - bShadowDev = new KisPaintDevice( KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA",""),"" ), "bShadow"); - gaussianblur(shadowDev, bShadowDev, rect, blurradius, blurradius, BLUR_RLE, progress); - shadowDev = bShadowDev; - } - - if (!m_cancelRequested) { - shadowDev->move (xoffset,yoffset); - - KisGroupLayerSP parent = image->rootLayer(); - if (image->activeLayer()) - parent = image->activeLayer()->parent().data(); - - KisPaintLayerSP l = new KisPaintLayer(image, i18n("Drop Shadow"), opacity, shadowDev); - image->addLayer( l.data(), parent, src->siblingBelow() ); - - if (allowResize) - { - TQRect shadowBounds = shadowDev->exactBounds(); - - if (!image->bounds().contains(shadowBounds)) { - - TQRect newImageSize = image->bounds() | shadowBounds; - image->resize(newImageSize.width(), newImageSize.height()); - - if (shadowBounds.left() < 0 || shadowBounds.top() < 0) { - - TQ_INT32 newRootX = image->rootLayer()->x(); - TQ_INT32 newRootY = image->rootLayer()->y(); - - if (shadowBounds.left() < 0) { - newRootX += -shadowBounds.left(); - } - if (shadowBounds.top() < 0) { - newRootY += -shadowBounds.top(); - } - - KCommand *moveCommand = image->rootLayer()->moveCommand(TQPoint(image->rootLayer()->x(), image->rootLayer()->y()), - TQPoint(newRootX, newRootY)); - Q_ASSERT(moveCommand != 0); - - if (moveCommand) { - moveCommand->execute(); - if (image->undo()) { - image->undoAdapter()->addCommand(moveCommand); - } else { - delete moveCommand; - } - } - } - } - } - m_view->canvasSubject()->document()->setModified(true); - } - - if (image->undo()) { - image->undoAdapter()->endMacro(); - } - - emit notifyProgressDone(); -} - -void KisDropshadow::gaussianblur (KisPaintDeviceSP srcDev, KisPaintDeviceSP dstDev, TQRect& rect, double horz, double vert, BlurMethod method, KisProgressDisplayInterface *) -{ - TQ_INT32 width, height; - TQ_INT32 bytes; - TQ_UINT8 *dest, *dp; - TQ_UINT8 *src, *sp, *sp_p, *sp_m; - TQ_INT32 *buf = NULL; - TQ_INT32 *bb; - double n_p[5], n_m[5]; - double d_p[5], d_m[5]; - double bd_p[5], bd_m[5]; - double *val_p = NULL; - double *val_m = NULL; - double *vp, *vm; - TQ_INT32 x1, y1, x2, y2; - TQ_INT32 i, j; - TQ_INT32 row, col, b; - TQ_INT32 terms; - double progress, max_progress; - TQ_INT32 initial_p[4]; - TQ_INT32 initial_m[4]; - double std_dev; - TQ_INT32 pixels; - TQ_INT32 total = 1; - TQ_INT32 start, end; - TQ_INT32 *curve; - TQ_INT32 *sum = NULL; - TQ_INT32 val; - TQ_INT32 length; - TQ_INT32 initial_pp, initial_mm; - - x1 = (TQ_INT32)(rect.x() - horz); - y1 = (TQ_INT32)(rect.y() - vert); - width = (TQ_INT32)(rect.width() + 2 * horz); - height = (TQ_INT32)(rect.height() + 2 * vert); - x2 = x1 + width; - y2 = y1 + height; - - if (width < 1 || height < 1) return; - - emit notifyProgressStage(i18n("Blur..."), 0); - - bytes = srcDev->pixelSize(); - - switch (method) - { - case BLUR_IIR: - val_p = new double[MAX (width, height) * bytes]; - val_m = new double[MAX (width, height) * bytes]; - break; - - case BLUR_RLE: - buf = new TQ_INT32[MAX (width, height) * 2]; - break; - } - - src = new TQ_UINT8[MAX (width, height) * bytes]; - dest = new TQ_UINT8[MAX (width, height) * bytes]; - - progress = 0.0; - max_progress = (horz <= 0.0 ) ? 0 : width * height * horz; - max_progress += (vert <= 0.0 ) ? 0 : width * height * vert; - - - /* First the vertical pass */ - if (vert > 0.0) - { - vert = fabs (vert) + 1.0; - std_dev = sqrt (-(vert * vert) / (2 * log (1.0 / 255.0))); - - switch (method) - { - case BLUR_IIR: - /* derive the constants for calculating the gaussian - * from the std dev - */ - find_constants (n_p, n_m, d_p, d_m, bd_p, bd_m, std_dev); - break; - - case BLUR_RLE: - curve = make_curve (std_dev, &length); - sum = new TQ_INT32[2 * length + 1]; - - sum[0] = 0; - - for (i = 1; i <= length*2; i++) - sum[i] = curve[i-length-1] + sum[i-1]; - sum += length; - - total = sum[length] - sum[-length]; - break; - } - - for (col = 0; col < width; col++) - { - switch (method) - { - case BLUR_IIR: - memset (val_p, 0, height * bytes * sizeof (double)); - memset (val_m, 0, height * bytes * sizeof (double)); - break; - - case BLUR_RLE: - break; - } - - //gimp_pixel_rgn_get_col (&src_rgn, src, col + x1, y1, height); - srcDev->readBytes(src, col+x1, y1, 1, height); - - multiply_alpha (src, height, bytes); - - switch (method) - { - case BLUR_IIR: - sp_p = src; - sp_m = src + (height - 1) * bytes; - vp = val_p; - vm = val_m + (height - 1) * bytes; - - /* Set up the first vals */ - for (i = 0; i < bytes; i++) - { - initial_p[i] = sp_p[i]; - initial_m[i] = sp_m[i]; - } - - for (row = 0; row < height; row++) - { - double *vpptr, *vmptr; - terms = (row < 4) ? row : 4; - - for (b = 0; b < bytes; b++) - { - vpptr = vp + b; vmptr = vm + b; - for (i = 0; i <= terms; i++) - { - *vpptr += n_p[i] * sp_p[(-i * bytes) + b] - - d_p[i] * vp[(-i * bytes) + b]; - *vmptr += n_m[i] * sp_m[(i * bytes) + b] - - d_m[i] * vm[(i * bytes) + b]; - } - for (j = i; j <= 4; j++) - { - *vpptr += (n_p[j] - bd_p[j]) * initial_p[b]; - *vmptr += (n_m[j] - bd_m[j]) * initial_m[b]; - } - } - - sp_p += bytes; - sp_m -= bytes; - vp += bytes; - vm -= bytes; - } - - transfer_pixels (val_p, val_m, dest, bytes, height); - break; - - case BLUR_RLE: - sp = src; - dp = dest; - - for (b = 0; b < bytes; b++) - { - initial_pp = sp[b]; - initial_mm = sp[(height-1) * bytes + b]; - - /* Determine a run-length encoded version of the row */ - run_length_encode (sp + b, buf, bytes, height); - - for (row = 0; row < height; row++) - { - start = (row < length) ? -row : -length; - end = (height <= (row + length) ? - (height - row - 1) : length); - - val = 0; - i = start; - bb = buf + (row + i) * 2; - - if (start != -length) - val += initial_pp * (sum[start] - sum[-length]); - - while (i < end) - { - pixels = bb[0]; - i += pixels; - if (i > end) - i = end; - val += bb[1] * (sum[i] - sum[start]); - bb += (pixels * 2); - start = i; - } - - if (end != length) - val += initial_mm * (sum[length] - sum[end]); - - dp[row * bytes + b] = val / total; - } - } - break; - } - - separate_alpha (src, height, bytes); - - dstDev->writeBytes(dest, col + x1, y1, 1, height); - - progress += height * vert; - if ((col % 5) == 0) emit notifyProgress( (TQ_UINT32)((progress * 100) / max_progress)); - } - } - - /* Now the horizontal pass */ - if (horz > 0.0) - { - horz = fabs (horz) + 1.0; - - if (horz != vert) - { - std_dev = sqrt (-(horz * horz) / (2 * log (1.0 / 255.0))); - - switch (method) - { - case BLUR_IIR: - /* derive the constants for calculating the gaussian - * from the std dev - */ - find_constants (n_p, n_m, d_p, d_m, bd_p, bd_m, std_dev); - break; - - case BLUR_RLE: - curve = make_curve (std_dev, &length); - sum = new TQ_INT32[2 * length + 1]; - - sum[0] = 0; - - for (i = 1; i <= length*2; i++) - sum[i] = curve[i-length-1] + sum[i-1]; - sum += length; - - total = sum[length] - sum[-length]; - break; - } - } - - for (row = 0; row < height; row++) - { - switch (method) - { - case BLUR_IIR: - memset (val_p, 0, width * bytes * sizeof (double)); - memset (val_m, 0, width * bytes * sizeof (double)); - break; - - case BLUR_RLE: - break; - } - - - //gimp_pixel_rgn_get_row (&src_rgn, src, x1, row + y1, width); - dstDev->readBytes(src, x1, row + y1, width, 1); - - multiply_alpha (dest, width, bytes); - - switch (method) - { - case BLUR_IIR: - sp_p = src; - sp_m = src + (width - 1) * bytes; - vp = val_p; - vm = val_m + (width - 1) * bytes; - - /* Set up the first vals */ - for (i = 0; i < bytes; i++) - { - initial_p[i] = sp_p[i]; - initial_m[i] = sp_m[i]; - } - - for (col = 0; col < width; col++) - { - double *vpptr, *vmptr; - terms = (col < 4) ? col : 4; - - for (b = 0; b < bytes; b++) - { - vpptr = vp + b; vmptr = vm + b; - for (i = 0; i <= terms; i++) - { - *vpptr += n_p[i] * sp_p[(-i * bytes) + b] - - d_p[i] * vp[(-i * bytes) + b]; - *vmptr += n_m[i] * sp_m[(i * bytes) + b] - - d_m[i] * vm[(i * bytes) + b]; - } - for (j = i; j <= 4; j++) - { - *vpptr += (n_p[j] - bd_p[j]) * initial_p[b]; - *vmptr += (n_m[j] - bd_m[j]) * initial_m[b]; - } - } - - sp_p += bytes; - sp_m -= bytes; - vp += bytes; - vm -= bytes; - } - - transfer_pixels (val_p, val_m, dest, bytes, width); - break; - - case BLUR_RLE: - sp = src; - dp = dest; - - for (b = 0; b < bytes; b++) - { - initial_pp = sp[b]; - initial_mm = sp[(width-1) * bytes + b]; - - /* Determine a run-length encoded version of the row */ - run_length_encode (sp + b, buf, bytes, width); - - for (col = 0; col < width; col++) - { - start = (col < length) ? -col : -length; - end = (width <= (col + length)) ? (width - col - 1) : length; - - val = 0; - i = start; - bb = buf + (col + i) * 2; - - if (start != -length) - val += initial_pp * (sum[start] - sum[-length]); - - while (i < end) - { - pixels = bb[0]; - i += pixels; - if (i > end) - i = end; - val += bb[1] * (sum[i] - sum[start]); - bb += (pixels * 2); - start = i; - } - - if (end != length) - val += initial_mm * (sum[length] - sum[end]); - - dp[col * bytes + b] = val / total; - } - } - break; - } - - separate_alpha (dest, width, bytes); - - //gimp_pixel_rgn_set_row (&dest_rgn, dest, x1, row + y1, width); - dstDev->writeBytes(dest, x1, row + y1, width, 1); - - progress += width * horz; - //if ((row % 5) == 0) gimp_progress_update (progress / max_progress); - if ((row % 5) == 0) emit notifyProgress( (TQ_UINT32)((progress * 100) / max_progress )); - } - } - - /* free up buffers */ - switch (method) - { - case BLUR_IIR: - delete[] val_p; - delete[] val_m; - break; - - case BLUR_RLE: - delete[] buf; - break; - } - - delete[] src; - delete[] dest; -} - -void KisDropshadow::find_constants (double n_p[], double n_m[], double d_p[], double d_m[], double bd_p[], double bd_m[], double std_dev) -{ - TQ_INT32 i; - double constants [8]; - double div; - - /* The constants used in the implemenation of a casual sequence - * using a 4th order approximation of the gaussian operator - */ - - div = sqrt(2 * M_PI) * std_dev; - constants [0] = -1.783 / std_dev; - constants [1] = -1.723 / std_dev; - constants [2] = 0.6318 / std_dev; - constants [3] = 1.997 / std_dev; - constants [4] = 1.6803 / div; - constants [5] = 3.735 / div; - constants [6] = -0.6803 / div; - constants [7] = -0.2598 / div; - - n_p [0] = constants[4] + constants[6]; - n_p [1] = exp (constants[1]) * - (constants[7] * sin (constants[3]) - - (constants[6] + 2 * constants[4]) * cos (constants[3])) + - exp (constants[0]) * - (constants[5] * sin (constants[2]) - - (2 * constants[6] + constants[4]) * cos (constants[2])); - n_p [2] = 2 * exp (constants[0] + constants[1]) * - ((constants[4] + constants[6]) * cos (constants[3]) * cos (constants[2]) - - constants[5] * cos (constants[3]) * sin (constants[2]) - - constants[7] * cos (constants[2]) * sin (constants[3])) + - constants[6] * exp (2 * constants[0]) + - constants[4] * exp (2 * constants[1]); - n_p [3] = exp (constants[1] + 2 * constants[0]) * - (constants[7] * sin (constants[3]) - constants[6] * cos (constants[3])) + - exp (constants[0] + 2 * constants[1]) * - (constants[5] * sin (constants[2]) - constants[4] * cos (constants[2])); - n_p [4] = 0.0; - - d_p [0] = 0.0; - d_p [1] = -2 * exp (constants[1]) * cos (constants[3]) - - 2 * exp (constants[0]) * cos (constants[2]); - d_p [2] = 4 * cos (constants[3]) * cos (constants[2]) * exp (constants[0] + constants[1]) + - exp (2 * constants[1]) + exp (2 * constants[0]); - d_p [3] = -2 * cos (constants[2]) * exp (constants[0] + 2 * constants[1]) - - 2 * cos (constants[3]) * exp (constants[1] + 2 * constants[0]); - d_p [4] = exp (2 * constants[0] + 2 * constants[1]); - - for (i = 0; i <= 4; i++) - d_m [i] = d_p [i]; - - n_m[0] = 0.0; - for (i = 1; i <= 4; i++) - n_m [i] = n_p[i] - d_p[i] * n_p[0]; - - { - double sum_n_p, sum_n_m, sum_d; - double a, b; - - sum_n_p = 0.0; - sum_n_m = 0.0; - sum_d = 0.0; - for (i = 0; i <= 4; i++) - { - sum_n_p += n_p[i]; - sum_n_m += n_m[i]; - sum_d += d_p[i]; - } - - a = sum_n_p / (1.0 + sum_d); - b = sum_n_m / (1.0 + sum_d); - - for (i = 0; i <= 4; i++) - { - bd_p[i] = d_p[i] * a; - bd_m[i] = d_m[i] * b; - } - } -} - - -void KisDropshadow::transfer_pixels (double *src1, double *src2, TQ_UINT8 *dest, TQ_INT32 bytes, TQ_INT32 width) -{ - TQ_INT32 b; - TQ_INT32 bend = bytes * width; - double sum; - - for(b = 0; b < bend; b++) - { - sum = *src1++ + *src2++; - if (sum > 255) sum = 255; - else if(sum < 0) sum = 0; - - *dest++ = (TQ_UINT8) sum; - } -} - -//The equations: g(r) = exp (- r^2 / (2 * sigma^2)), r = sqrt (x^2 + y ^2) -TQ_INT32 * KisDropshadow::make_curve(double sigma, TQ_INT32 *length) -{ - int *curve; - double sigma2; - double l; - int temp; - int i, n; - - sigma2 = 2 * sigma * sigma; - l = sqrt (-sigma2 * log (1.0 / 255.0)); - - n = (int)(ceil (l) * 2); - if ((n % 2) == 0) - n += 1; - - curve = new TQ_INT32[n]; - - *length = n / 2; - curve += *length; - curve[0] = 255; - - for (i = 1; i <= *length; i++) - { - temp = (TQ_INT32) (exp (- (i * i) / sigma2) * 255); - curve[-i] = temp; - curve[i] = temp; - } - - return curve; -} - -void KisDropshadow::run_length_encode (TQ_UINT8 *src, TQ_INT32 *dest, TQ_INT32 bytes, TQ_INT32 width) -{ - TQ_INT32 start; - TQ_INT32 i; - TQ_INT32 j; - TQ_UINT8 last; - - last = *src; - src += bytes; - start = 0; - - for (i = 1; i < width; i++) - { - if (*src != last) - { - for (j = start; j < i; j++) - { - *dest++ = (i - j); - *dest++ = last; - } - start = i; - last = *src; - } - src += bytes; - } - - for (j = start; j < i; j++) - { - *dest++ = (i - j); - *dest++ = last; - } -} - -void KisDropshadow::multiply_alpha (TQ_UINT8 *buf, TQ_INT32 width, TQ_INT32 bytes) -{ - TQ_INT32 i, j; - double alpha; - - for (i = 0; i < width * bytes; i += bytes) - { - alpha = buf[i + bytes - 1] * (1.0 / 255.0); - for (j = 0; j < bytes - 1; j++) { - double a = (double)(buf[i + j]) * alpha; - buf[i + j] = (TQ_UINT8)a; - } - } -} - -void KisDropshadow::separate_alpha (TQ_UINT8 *buf, TQ_INT32 width, TQ_INT32 bytes) -{ - TQ_INT32 i, j; - TQ_UINT8 alpha; - double recip_alpha; - TQ_UINT32 new_val; - - for (i = 0; i < width * bytes; i += bytes) - { - alpha = buf[i + bytes - 1]; - if (alpha != 0 && alpha != 255) - { - recip_alpha = 255.0 / alpha; - for (j = 0; j < bytes - 1; j++) - { - new_val = (TQ_UINT32)(buf[i + j] * recip_alpha); - buf[i + j] = MIN (255, new_val); - } - } - } -} - -#include "kis_dropshadow.moc" diff --git a/chalk/plugins/viewplugins/dropshadow/kis_dropshadow.cpp b/chalk/plugins/viewplugins/dropshadow/kis_dropshadow.cpp new file mode 100644 index 00000000..97c2c17e --- /dev/null +++ b/chalk/plugins/viewplugins/dropshadow/kis_dropshadow.cpp @@ -0,0 +1,758 @@ +/* + * This file is part of Chalk + * + * Copyright (c) 2005 Michael Thaler + * + * The gaussian blur algoithm is ported from gimo + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * 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 + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include "kis_meta_registry.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "kis_rgb_colorspace.h" + +#include "kis_dropshadow.h" + +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) + +KisDropshadow::KisDropshadow(KisView * view) + : m_view(view) +{ +} + +void KisDropshadow::dropshadow(KisProgressDisplayInterface * progress, TQ_INT32 xoffset, TQ_INT32 yoffset, TQ_INT32 blurradius, TQColor color, TQ_UINT8 opacity, bool allowResize) +{ + KisImageSP image = m_view->canvasSubject()->currentImg(); + if (!image) return; + + KisLayerSP src = image->activeLayer(); + if (!src) return; + + KisPaintDeviceSP dev = image->activeDevice(); + if (!dev) return; + + m_cancelRequested = false; + if ( progress ) + progress->setSubject(this, true, true); + emit notifyProgressStage(i18n("Add drop shadow..."), 0); + + if (image->undo()) { + image->undoAdapter()->beginMacro(i18n("Add Drop Shadow")); + } + + KisPaintDeviceSP shadowDev = new KisPaintDevice( KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA",""),"" ), "Shadow"); + KisPaintDeviceSP bShadowDev; + KisRgbColorSpace *rgb8cs = static_cast(shadowDev->colorSpace()); + + TQRect rect = dev->exactBounds(); + + for (TQ_INT32 row = 0; row < rect.height(); ++row) + { + KisHLineIteratorPixel srcIt = dev->createHLineIterator(rect.x(), rect.y() + row, rect.width(), false); + KisHLineIteratorPixel dstIt = shadowDev->createHLineIterator(rect.x(), rect.y() + row, rect.width(), true); + while( ! srcIt.isDone() ) + { + if (srcIt.isSelected()) + { + //set the shadow color + TQ_UINT8 alpha = dev->colorSpace()->getAlpha(srcIt.rawData()); + rgb8cs->setPixel(dstIt.rawData(), color.red(), color.green(), color.blue(), alpha); + } + ++srcIt; + ++dstIt; + } + emit notifyProgress((row * 100) / rect.height() ); + } + + if( blurradius > 0 ) + { + bShadowDev = new KisPaintDevice( KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA",""),"" ), "bShadow"); + gaussianblur(shadowDev, bShadowDev, rect, blurradius, blurradius, BLUR_RLE, progress); + shadowDev = bShadowDev; + } + + if (!m_cancelRequested) { + shadowDev->move (xoffset,yoffset); + + KisGroupLayerSP parent = image->rootLayer(); + if (image->activeLayer()) + parent = image->activeLayer()->parent().data(); + + KisPaintLayerSP l = new KisPaintLayer(image, i18n("Drop Shadow"), opacity, shadowDev); + image->addLayer( l.data(), parent, src->siblingBelow() ); + + if (allowResize) + { + TQRect shadowBounds = shadowDev->exactBounds(); + + if (!image->bounds().contains(shadowBounds)) { + + TQRect newImageSize = image->bounds() | shadowBounds; + image->resize(newImageSize.width(), newImageSize.height()); + + if (shadowBounds.left() < 0 || shadowBounds.top() < 0) { + + TQ_INT32 newRootX = image->rootLayer()->x(); + TQ_INT32 newRootY = image->rootLayer()->y(); + + if (shadowBounds.left() < 0) { + newRootX += -shadowBounds.left(); + } + if (shadowBounds.top() < 0) { + newRootY += -shadowBounds.top(); + } + + KCommand *moveCommand = image->rootLayer()->moveCommand(TQPoint(image->rootLayer()->x(), image->rootLayer()->y()), + TQPoint(newRootX, newRootY)); + Q_ASSERT(moveCommand != 0); + + if (moveCommand) { + moveCommand->execute(); + if (image->undo()) { + image->undoAdapter()->addCommand(moveCommand); + } else { + delete moveCommand; + } + } + } + } + } + m_view->canvasSubject()->document()->setModified(true); + } + + if (image->undo()) { + image->undoAdapter()->endMacro(); + } + + emit notifyProgressDone(); +} + +void KisDropshadow::gaussianblur (KisPaintDeviceSP srcDev, KisPaintDeviceSP dstDev, TQRect& rect, double horz, double vert, BlurMethod method, KisProgressDisplayInterface *) +{ + TQ_INT32 width, height; + TQ_INT32 bytes; + TQ_UINT8 *dest, *dp; + TQ_UINT8 *src, *sp, *sp_p, *sp_m; + TQ_INT32 *buf = NULL; + TQ_INT32 *bb; + double n_p[5], n_m[5]; + double d_p[5], d_m[5]; + double bd_p[5], bd_m[5]; + double *val_p = NULL; + double *val_m = NULL; + double *vp, *vm; + TQ_INT32 x1, y1, x2, y2; + TQ_INT32 i, j; + TQ_INT32 row, col, b; + TQ_INT32 terms; + double progress, max_progress; + TQ_INT32 initial_p[4]; + TQ_INT32 initial_m[4]; + double std_dev; + TQ_INT32 pixels; + TQ_INT32 total = 1; + TQ_INT32 start, end; + TQ_INT32 *curve; + TQ_INT32 *sum = NULL; + TQ_INT32 val; + TQ_INT32 length; + TQ_INT32 initial_pp, initial_mm; + + x1 = (TQ_INT32)(rect.x() - horz); + y1 = (TQ_INT32)(rect.y() - vert); + width = (TQ_INT32)(rect.width() + 2 * horz); + height = (TQ_INT32)(rect.height() + 2 * vert); + x2 = x1 + width; + y2 = y1 + height; + + if (width < 1 || height < 1) return; + + emit notifyProgressStage(i18n("Blur..."), 0); + + bytes = srcDev->pixelSize(); + + switch (method) + { + case BLUR_IIR: + val_p = new double[MAX (width, height) * bytes]; + val_m = new double[MAX (width, height) * bytes]; + break; + + case BLUR_RLE: + buf = new TQ_INT32[MAX (width, height) * 2]; + break; + } + + src = new TQ_UINT8[MAX (width, height) * bytes]; + dest = new TQ_UINT8[MAX (width, height) * bytes]; + + progress = 0.0; + max_progress = (horz <= 0.0 ) ? 0 : width * height * horz; + max_progress += (vert <= 0.0 ) ? 0 : width * height * vert; + + + /* First the vertical pass */ + if (vert > 0.0) + { + vert = fabs (vert) + 1.0; + std_dev = sqrt (-(vert * vert) / (2 * log (1.0 / 255.0))); + + switch (method) + { + case BLUR_IIR: + /* derive the constants for calculating the gaussian + * from the std dev + */ + find_constants (n_p, n_m, d_p, d_m, bd_p, bd_m, std_dev); + break; + + case BLUR_RLE: + curve = make_curve (std_dev, &length); + sum = new TQ_INT32[2 * length + 1]; + + sum[0] = 0; + + for (i = 1; i <= length*2; i++) + sum[i] = curve[i-length-1] + sum[i-1]; + sum += length; + + total = sum[length] - sum[-length]; + break; + } + + for (col = 0; col < width; col++) + { + switch (method) + { + case BLUR_IIR: + memset (val_p, 0, height * bytes * sizeof (double)); + memset (val_m, 0, height * bytes * sizeof (double)); + break; + + case BLUR_RLE: + break; + } + + //gimp_pixel_rgn_get_col (&src_rgn, src, col + x1, y1, height); + srcDev->readBytes(src, col+x1, y1, 1, height); + + multiply_alpha (src, height, bytes); + + switch (method) + { + case BLUR_IIR: + sp_p = src; + sp_m = src + (height - 1) * bytes; + vp = val_p; + vm = val_m + (height - 1) * bytes; + + /* Set up the first vals */ + for (i = 0; i < bytes; i++) + { + initial_p[i] = sp_p[i]; + initial_m[i] = sp_m[i]; + } + + for (row = 0; row < height; row++) + { + double *vpptr, *vmptr; + terms = (row < 4) ? row : 4; + + for (b = 0; b < bytes; b++) + { + vpptr = vp + b; vmptr = vm + b; + for (i = 0; i <= terms; i++) + { + *vpptr += n_p[i] * sp_p[(-i * bytes) + b] - + d_p[i] * vp[(-i * bytes) + b]; + *vmptr += n_m[i] * sp_m[(i * bytes) + b] - + d_m[i] * vm[(i * bytes) + b]; + } + for (j = i; j <= 4; j++) + { + *vpptr += (n_p[j] - bd_p[j]) * initial_p[b]; + *vmptr += (n_m[j] - bd_m[j]) * initial_m[b]; + } + } + + sp_p += bytes; + sp_m -= bytes; + vp += bytes; + vm -= bytes; + } + + transfer_pixels (val_p, val_m, dest, bytes, height); + break; + + case BLUR_RLE: + sp = src; + dp = dest; + + for (b = 0; b < bytes; b++) + { + initial_pp = sp[b]; + initial_mm = sp[(height-1) * bytes + b]; + + /* Determine a run-length encoded version of the row */ + run_length_encode (sp + b, buf, bytes, height); + + for (row = 0; row < height; row++) + { + start = (row < length) ? -row : -length; + end = (height <= (row + length) ? + (height - row - 1) : length); + + val = 0; + i = start; + bb = buf + (row + i) * 2; + + if (start != -length) + val += initial_pp * (sum[start] - sum[-length]); + + while (i < end) + { + pixels = bb[0]; + i += pixels; + if (i > end) + i = end; + val += bb[1] * (sum[i] - sum[start]); + bb += (pixels * 2); + start = i; + } + + if (end != length) + val += initial_mm * (sum[length] - sum[end]); + + dp[row * bytes + b] = val / total; + } + } + break; + } + + separate_alpha (src, height, bytes); + + dstDev->writeBytes(dest, col + x1, y1, 1, height); + + progress += height * vert; + if ((col % 5) == 0) emit notifyProgress( (TQ_UINT32)((progress * 100) / max_progress)); + } + } + + /* Now the horizontal pass */ + if (horz > 0.0) + { + horz = fabs (horz) + 1.0; + + if (horz != vert) + { + std_dev = sqrt (-(horz * horz) / (2 * log (1.0 / 255.0))); + + switch (method) + { + case BLUR_IIR: + /* derive the constants for calculating the gaussian + * from the std dev + */ + find_constants (n_p, n_m, d_p, d_m, bd_p, bd_m, std_dev); + break; + + case BLUR_RLE: + curve = make_curve (std_dev, &length); + sum = new TQ_INT32[2 * length + 1]; + + sum[0] = 0; + + for (i = 1; i <= length*2; i++) + sum[i] = curve[i-length-1] + sum[i-1]; + sum += length; + + total = sum[length] - sum[-length]; + break; + } + } + + for (row = 0; row < height; row++) + { + switch (method) + { + case BLUR_IIR: + memset (val_p, 0, width * bytes * sizeof (double)); + memset (val_m, 0, width * bytes * sizeof (double)); + break; + + case BLUR_RLE: + break; + } + + + //gimp_pixel_rgn_get_row (&src_rgn, src, x1, row + y1, width); + dstDev->readBytes(src, x1, row + y1, width, 1); + + multiply_alpha (dest, width, bytes); + + switch (method) + { + case BLUR_IIR: + sp_p = src; + sp_m = src + (width - 1) * bytes; + vp = val_p; + vm = val_m + (width - 1) * bytes; + + /* Set up the first vals */ + for (i = 0; i < bytes; i++) + { + initial_p[i] = sp_p[i]; + initial_m[i] = sp_m[i]; + } + + for (col = 0; col < width; col++) + { + double *vpptr, *vmptr; + terms = (col < 4) ? col : 4; + + for (b = 0; b < bytes; b++) + { + vpptr = vp + b; vmptr = vm + b; + for (i = 0; i <= terms; i++) + { + *vpptr += n_p[i] * sp_p[(-i * bytes) + b] - + d_p[i] * vp[(-i * bytes) + b]; + *vmptr += n_m[i] * sp_m[(i * bytes) + b] - + d_m[i] * vm[(i * bytes) + b]; + } + for (j = i; j <= 4; j++) + { + *vpptr += (n_p[j] - bd_p[j]) * initial_p[b]; + *vmptr += (n_m[j] - bd_m[j]) * initial_m[b]; + } + } + + sp_p += bytes; + sp_m -= bytes; + vp += bytes; + vm -= bytes; + } + + transfer_pixels (val_p, val_m, dest, bytes, width); + break; + + case BLUR_RLE: + sp = src; + dp = dest; + + for (b = 0; b < bytes; b++) + { + initial_pp = sp[b]; + initial_mm = sp[(width-1) * bytes + b]; + + /* Determine a run-length encoded version of the row */ + run_length_encode (sp + b, buf, bytes, width); + + for (col = 0; col < width; col++) + { + start = (col < length) ? -col : -length; + end = (width <= (col + length)) ? (width - col - 1) : length; + + val = 0; + i = start; + bb = buf + (col + i) * 2; + + if (start != -length) + val += initial_pp * (sum[start] - sum[-length]); + + while (i < end) + { + pixels = bb[0]; + i += pixels; + if (i > end) + i = end; + val += bb[1] * (sum[i] - sum[start]); + bb += (pixels * 2); + start = i; + } + + if (end != length) + val += initial_mm * (sum[length] - sum[end]); + + dp[col * bytes + b] = val / total; + } + } + break; + } + + separate_alpha (dest, width, bytes); + + //gimp_pixel_rgn_set_row (&dest_rgn, dest, x1, row + y1, width); + dstDev->writeBytes(dest, x1, row + y1, width, 1); + + progress += width * horz; + //if ((row % 5) == 0) gimp_progress_update (progress / max_progress); + if ((row % 5) == 0) emit notifyProgress( (TQ_UINT32)((progress * 100) / max_progress )); + } + } + + /* free up buffers */ + switch (method) + { + case BLUR_IIR: + delete[] val_p; + delete[] val_m; + break; + + case BLUR_RLE: + delete[] buf; + break; + } + + delete[] src; + delete[] dest; +} + +void KisDropshadow::find_constants (double n_p[], double n_m[], double d_p[], double d_m[], double bd_p[], double bd_m[], double std_dev) +{ + TQ_INT32 i; + double constants [8]; + double div; + + /* The constants used in the implemenation of a casual sequence + * using a 4th order approximation of the gaussian operator + */ + + div = sqrt(2 * M_PI) * std_dev; + constants [0] = -1.783 / std_dev; + constants [1] = -1.723 / std_dev; + constants [2] = 0.6318 / std_dev; + constants [3] = 1.997 / std_dev; + constants [4] = 1.6803 / div; + constants [5] = 3.735 / div; + constants [6] = -0.6803 / div; + constants [7] = -0.2598 / div; + + n_p [0] = constants[4] + constants[6]; + n_p [1] = exp (constants[1]) * + (constants[7] * sin (constants[3]) - + (constants[6] + 2 * constants[4]) * cos (constants[3])) + + exp (constants[0]) * + (constants[5] * sin (constants[2]) - + (2 * constants[6] + constants[4]) * cos (constants[2])); + n_p [2] = 2 * exp (constants[0] + constants[1]) * + ((constants[4] + constants[6]) * cos (constants[3]) * cos (constants[2]) - + constants[5] * cos (constants[3]) * sin (constants[2]) - + constants[7] * cos (constants[2]) * sin (constants[3])) + + constants[6] * exp (2 * constants[0]) + + constants[4] * exp (2 * constants[1]); + n_p [3] = exp (constants[1] + 2 * constants[0]) * + (constants[7] * sin (constants[3]) - constants[6] * cos (constants[3])) + + exp (constants[0] + 2 * constants[1]) * + (constants[5] * sin (constants[2]) - constants[4] * cos (constants[2])); + n_p [4] = 0.0; + + d_p [0] = 0.0; + d_p [1] = -2 * exp (constants[1]) * cos (constants[3]) - + 2 * exp (constants[0]) * cos (constants[2]); + d_p [2] = 4 * cos (constants[3]) * cos (constants[2]) * exp (constants[0] + constants[1]) + + exp (2 * constants[1]) + exp (2 * constants[0]); + d_p [3] = -2 * cos (constants[2]) * exp (constants[0] + 2 * constants[1]) - + 2 * cos (constants[3]) * exp (constants[1] + 2 * constants[0]); + d_p [4] = exp (2 * constants[0] + 2 * constants[1]); + + for (i = 0; i <= 4; i++) + d_m [i] = d_p [i]; + + n_m[0] = 0.0; + for (i = 1; i <= 4; i++) + n_m [i] = n_p[i] - d_p[i] * n_p[0]; + + { + double sum_n_p, sum_n_m, sum_d; + double a, b; + + sum_n_p = 0.0; + sum_n_m = 0.0; + sum_d = 0.0; + for (i = 0; i <= 4; i++) + { + sum_n_p += n_p[i]; + sum_n_m += n_m[i]; + sum_d += d_p[i]; + } + + a = sum_n_p / (1.0 + sum_d); + b = sum_n_m / (1.0 + sum_d); + + for (i = 0; i <= 4; i++) + { + bd_p[i] = d_p[i] * a; + bd_m[i] = d_m[i] * b; + } + } +} + + +void KisDropshadow::transfer_pixels (double *src1, double *src2, TQ_UINT8 *dest, TQ_INT32 bytes, TQ_INT32 width) +{ + TQ_INT32 b; + TQ_INT32 bend = bytes * width; + double sum; + + for(b = 0; b < bend; b++) + { + sum = *src1++ + *src2++; + if (sum > 255) sum = 255; + else if(sum < 0) sum = 0; + + *dest++ = (TQ_UINT8) sum; + } +} + +//The equations: g(r) = exp (- r^2 / (2 * sigma^2)), r = sqrt (x^2 + y ^2) +TQ_INT32 * KisDropshadow::make_curve(double sigma, TQ_INT32 *length) +{ + int *curve; + double sigma2; + double l; + int temp; + int i, n; + + sigma2 = 2 * sigma * sigma; + l = sqrt (-sigma2 * log (1.0 / 255.0)); + + n = (int)(ceil (l) * 2); + if ((n % 2) == 0) + n += 1; + + curve = new TQ_INT32[n]; + + *length = n / 2; + curve += *length; + curve[0] = 255; + + for (i = 1; i <= *length; i++) + { + temp = (TQ_INT32) (exp (- (i * i) / sigma2) * 255); + curve[-i] = temp; + curve[i] = temp; + } + + return curve; +} + +void KisDropshadow::run_length_encode (TQ_UINT8 *src, TQ_INT32 *dest, TQ_INT32 bytes, TQ_INT32 width) +{ + TQ_INT32 start; + TQ_INT32 i; + TQ_INT32 j; + TQ_UINT8 last; + + last = *src; + src += bytes; + start = 0; + + for (i = 1; i < width; i++) + { + if (*src != last) + { + for (j = start; j < i; j++) + { + *dest++ = (i - j); + *dest++ = last; + } + start = i; + last = *src; + } + src += bytes; + } + + for (j = start; j < i; j++) + { + *dest++ = (i - j); + *dest++ = last; + } +} + +void KisDropshadow::multiply_alpha (TQ_UINT8 *buf, TQ_INT32 width, TQ_INT32 bytes) +{ + TQ_INT32 i, j; + double alpha; + + for (i = 0; i < width * bytes; i += bytes) + { + alpha = buf[i + bytes - 1] * (1.0 / 255.0); + for (j = 0; j < bytes - 1; j++) { + double a = (double)(buf[i + j]) * alpha; + buf[i + j] = (TQ_UINT8)a; + } + } +} + +void KisDropshadow::separate_alpha (TQ_UINT8 *buf, TQ_INT32 width, TQ_INT32 bytes) +{ + TQ_INT32 i, j; + TQ_UINT8 alpha; + double recip_alpha; + TQ_UINT32 new_val; + + for (i = 0; i < width * bytes; i += bytes) + { + alpha = buf[i + bytes - 1]; + if (alpha != 0 && alpha != 255) + { + recip_alpha = 255.0 / alpha; + for (j = 0; j < bytes - 1; j++) + { + new_val = (TQ_UINT32)(buf[i + j] * recip_alpha); + buf[i + j] = MIN (255, new_val); + } + } + } +} + +#include "kis_dropshadow.moc" diff --git a/chalk/plugins/viewplugins/dropshadow/kis_dropshadow_plugin.cc b/chalk/plugins/viewplugins/dropshadow/kis_dropshadow_plugin.cc deleted file mode 100644 index 97a0b8a7..00000000 --- a/chalk/plugins/viewplugins/dropshadow/kis_dropshadow_plugin.cc +++ /dev/null @@ -1,91 +0,0 @@ -/* - * This file is part of the KDE project - * - * Copyright (c) 2005 Michael Thaler - * - * 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 -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "kis_dropshadow_plugin.h" -#include "kis_dropshadow.h" -#include "dlg_dropshadow.h" - -K_EXPORT_COMPONENT_FACTORY( chalkdropshadow, KGenericFactory( "chalk" ) ) - -KisDropshadowPlugin::KisDropshadowPlugin(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - if ( parent->inherits("KisView") ) { - - setInstance(KGenericFactory::instance()); - setXMLFile(locate("data","chalkplugins/dropshadow.rc"), true); - - m_view = (KisView*) parent; - (void) new TDEAction(i18n("Add Drop Shadow..."), 0, 0, this, TQT_SLOT(slotDropshadow()), actionCollection(), "dropshadow"); - } -} - -KisDropshadowPlugin::~KisDropshadowPlugin() -{ -} - -void KisDropshadowPlugin::slotDropshadow() -{ - KisImageSP image = m_view->canvasSubject()->currentImg(); - if (!image) return; - - KisPaintDeviceSP dev = image->activeDevice(); - if (!dev) return; - - DlgDropshadow * dlgDropshadow = new DlgDropshadow(dev->colorSpace()->id().name(), - image->colorSpace()->id().name(), - m_view, "Dropshadow"); - TQ_CHECK_PTR(dlgDropshadow); - - dlgDropshadow->setCaption(i18n("Drop Shadow")); - - if (dlgDropshadow->exec() == TQDialog::Accepted) { - - KisDropshadow dropshadow(m_view); - dropshadow.dropshadow(m_view->canvasSubject()->progressDisplay(), - dlgDropshadow->getXOffset(), - dlgDropshadow->getYOffset(), - dlgDropshadow->getBlurRadius(), - dlgDropshadow->getShadowColor(), - dlgDropshadow->getShadowOpacity(), - dlgDropshadow->allowResizingChecked()); - - } - - delete dlgDropshadow; - -} - -#include "kis_dropshadow_plugin.moc" diff --git a/chalk/plugins/viewplugins/dropshadow/kis_dropshadow_plugin.cpp b/chalk/plugins/viewplugins/dropshadow/kis_dropshadow_plugin.cpp new file mode 100644 index 00000000..97a0b8a7 --- /dev/null +++ b/chalk/plugins/viewplugins/dropshadow/kis_dropshadow_plugin.cpp @@ -0,0 +1,91 @@ +/* + * This file is part of the KDE project + * + * Copyright (c) 2005 Michael Thaler + * + * 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 +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "kis_dropshadow_plugin.h" +#include "kis_dropshadow.h" +#include "dlg_dropshadow.h" + +K_EXPORT_COMPONENT_FACTORY( chalkdropshadow, KGenericFactory( "chalk" ) ) + +KisDropshadowPlugin::KisDropshadowPlugin(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + if ( parent->inherits("KisView") ) { + + setInstance(KGenericFactory::instance()); + setXMLFile(locate("data","chalkplugins/dropshadow.rc"), true); + + m_view = (KisView*) parent; + (void) new TDEAction(i18n("Add Drop Shadow..."), 0, 0, this, TQT_SLOT(slotDropshadow()), actionCollection(), "dropshadow"); + } +} + +KisDropshadowPlugin::~KisDropshadowPlugin() +{ +} + +void KisDropshadowPlugin::slotDropshadow() +{ + KisImageSP image = m_view->canvasSubject()->currentImg(); + if (!image) return; + + KisPaintDeviceSP dev = image->activeDevice(); + if (!dev) return; + + DlgDropshadow * dlgDropshadow = new DlgDropshadow(dev->colorSpace()->id().name(), + image->colorSpace()->id().name(), + m_view, "Dropshadow"); + TQ_CHECK_PTR(dlgDropshadow); + + dlgDropshadow->setCaption(i18n("Drop Shadow")); + + if (dlgDropshadow->exec() == TQDialog::Accepted) { + + KisDropshadow dropshadow(m_view); + dropshadow.dropshadow(m_view->canvasSubject()->progressDisplay(), + dlgDropshadow->getXOffset(), + dlgDropshadow->getYOffset(), + dlgDropshadow->getBlurRadius(), + dlgDropshadow->getShadowColor(), + dlgDropshadow->getShadowOpacity(), + dlgDropshadow->allowResizingChecked()); + + } + + delete dlgDropshadow; + +} + +#include "kis_dropshadow_plugin.moc" diff --git a/chalk/plugins/viewplugins/filtersgallery/Makefile.am b/chalk/plugins/viewplugins/filtersgallery/Makefile.am index 306076b6..7a67d360 100644 --- a/chalk/plugins/viewplugins/filtersgallery/Makefile.am +++ b/chalk/plugins/viewplugins/filtersgallery/Makefile.am @@ -11,8 +11,8 @@ INCLUDES = -I$(srcdir)/../../../sdk \ $(KOFFICE_INCLUDES) \ $(all_includes) -chalkfiltersgallery_la_SOURCES = filters_gallery.cc \ - kis_dlg_filtersgallery.cc kis_wdg_filtersgallery.ui +chalkfiltersgallery_la_SOURCES = filters_gallery.cpp \ + kis_dlg_filtersgallery.cpp kis_wdg_filtersgallery.ui kde_module_LTLIBRARIES = chalkfiltersgallery.la noinst_HEADERS = filters_gallery.h kis_dlg_filtersgallery.h diff --git a/chalk/plugins/viewplugins/filtersgallery/filters_gallery.cc b/chalk/plugins/viewplugins/filtersgallery/filters_gallery.cc deleted file mode 100644 index 337b55c0..00000000 --- a/chalk/plugins/viewplugins/filtersgallery/filters_gallery.cc +++ /dev/null @@ -1,138 +0,0 @@ -/* - * This file is part of Chalk - * - * Copyright (c) 2005 Cyrille Berger - * - * 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 "filters_gallery.h" - -#include - -#include -#include -#include - -#include - -#include -#include "kis_progress_display_interface.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Chalk { -namespace Plugins { -namespace FiltersGallery { - -typedef KGenericFactory ChalkFiltersGalleryFactory; -K_EXPORT_COMPONENT_FACTORY( chalkfiltersgallery, ChalkFiltersGalleryFactory( "chalk" ) ) - -ChalkFiltersGallery::ChalkFiltersGallery(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - - if ( parent->inherits("KisView") ) - { - setInstance(ChalkFiltersGallery::instance()); - setXMLFile(locate("data","chalkplugins/chalkfiltersgallery.rc"), true); - - m_view = (KisView*) parent; - - (void) new TDEAction(i18n("&Filters Gallery"), 0, 0, this, TQT_SLOT(showFiltersGalleryDialog()), actionCollection(), "chalk_filters_gallery"); - - // Add a docker with the list of filters -// TQImage img; -// if(img.load(locate("data","chalk/images/previewfilter.png"))) -// { -// KisPaintDeviceSP preview = new KisPaintDevice(KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA",""),"")); -// preview->convertFromTQImage(img,""); -// m_view->canvasSubject()->paletteManager()->addWidget(new KisFiltersListView(preview,m_view),"filterslist",chalk::EFFECTSBOX, 0); -// } - - } - - -} - -ChalkFiltersGallery::~ChalkFiltersGallery() -{ -} - -void ChalkFiltersGallery::showFiltersGalleryDialog() -{ - KisDlgFiltersGallery dlg(m_view, m_view); - if (dlg.exec()) - { - TQApplication::setOverrideCursor( TQt::waitCursor ); - - KisFilter* filter = dlg.currentFilter(); - if(filter ) - { - KisImageSP img = m_view->canvasSubject()->currentImg(); - if (!img) return; - - KisPaintDeviceSP dev = img->activeDevice(); - if (!dev) return; - TQRect r1 = dev->exactBounds(); - TQRect r2 = img->bounds(); - - TQRect rect = r1.intersect(r2); - - if (dev->hasSelection()) { - TQRect r3 = dev->selection()->selectedExactRect(); - rect = rect.intersect(r3); - } - KisFilterConfiguration* config = filter->configuration( dlg.currentConfigWidget()); - - filter->enableProgress(); - m_view->canvasSubject()->progressDisplay()->setSubject(filter, true, true); - filter->setProgressDisplay(m_view->canvasSubject()->progressDisplay()); - - KisTransaction * cmd = new KisTransaction(filter->id().name(), dev); - - filter->process(dev,dev, config, rect); - - delete config; - if (filter->cancelRequested()) { - cmd->unexecute(); - delete cmd; - } else { - dev->setDirty(rect); - if (img->undo()) - img->undoAdapter()->addCommand(cmd); - else - delete cmd; - } - filter->disableProgress(); - TQApplication::restoreOverrideCursor(); - - } - } -} - -} -} -} - -#include "filters_gallery.moc" diff --git a/chalk/plugins/viewplugins/filtersgallery/filters_gallery.cpp b/chalk/plugins/viewplugins/filtersgallery/filters_gallery.cpp new file mode 100644 index 00000000..337b55c0 --- /dev/null +++ b/chalk/plugins/viewplugins/filtersgallery/filters_gallery.cpp @@ -0,0 +1,138 @@ +/* + * This file is part of Chalk + * + * Copyright (c) 2005 Cyrille Berger + * + * 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 "filters_gallery.h" + +#include + +#include +#include +#include + +#include + +#include +#include "kis_progress_display_interface.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Chalk { +namespace Plugins { +namespace FiltersGallery { + +typedef KGenericFactory ChalkFiltersGalleryFactory; +K_EXPORT_COMPONENT_FACTORY( chalkfiltersgallery, ChalkFiltersGalleryFactory( "chalk" ) ) + +ChalkFiltersGallery::ChalkFiltersGallery(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + + if ( parent->inherits("KisView") ) + { + setInstance(ChalkFiltersGallery::instance()); + setXMLFile(locate("data","chalkplugins/chalkfiltersgallery.rc"), true); + + m_view = (KisView*) parent; + + (void) new TDEAction(i18n("&Filters Gallery"), 0, 0, this, TQT_SLOT(showFiltersGalleryDialog()), actionCollection(), "chalk_filters_gallery"); + + // Add a docker with the list of filters +// TQImage img; +// if(img.load(locate("data","chalk/images/previewfilter.png"))) +// { +// KisPaintDeviceSP preview = new KisPaintDevice(KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA",""),"")); +// preview->convertFromTQImage(img,""); +// m_view->canvasSubject()->paletteManager()->addWidget(new KisFiltersListView(preview,m_view),"filterslist",chalk::EFFECTSBOX, 0); +// } + + } + + +} + +ChalkFiltersGallery::~ChalkFiltersGallery() +{ +} + +void ChalkFiltersGallery::showFiltersGalleryDialog() +{ + KisDlgFiltersGallery dlg(m_view, m_view); + if (dlg.exec()) + { + TQApplication::setOverrideCursor( TQt::waitCursor ); + + KisFilter* filter = dlg.currentFilter(); + if(filter ) + { + KisImageSP img = m_view->canvasSubject()->currentImg(); + if (!img) return; + + KisPaintDeviceSP dev = img->activeDevice(); + if (!dev) return; + TQRect r1 = dev->exactBounds(); + TQRect r2 = img->bounds(); + + TQRect rect = r1.intersect(r2); + + if (dev->hasSelection()) { + TQRect r3 = dev->selection()->selectedExactRect(); + rect = rect.intersect(r3); + } + KisFilterConfiguration* config = filter->configuration( dlg.currentConfigWidget()); + + filter->enableProgress(); + m_view->canvasSubject()->progressDisplay()->setSubject(filter, true, true); + filter->setProgressDisplay(m_view->canvasSubject()->progressDisplay()); + + KisTransaction * cmd = new KisTransaction(filter->id().name(), dev); + + filter->process(dev,dev, config, rect); + + delete config; + if (filter->cancelRequested()) { + cmd->unexecute(); + delete cmd; + } else { + dev->setDirty(rect); + if (img->undo()) + img->undoAdapter()->addCommand(cmd); + else + delete cmd; + } + filter->disableProgress(); + TQApplication::restoreOverrideCursor(); + + } + } +} + +} +} +} + +#include "filters_gallery.moc" diff --git a/chalk/plugins/viewplugins/filtersgallery/kis_dlg_filtersgallery.cc b/chalk/plugins/viewplugins/filtersgallery/kis_dlg_filtersgallery.cc deleted file mode 100644 index e0bec7ec..00000000 --- a/chalk/plugins/viewplugins/filtersgallery/kis_dlg_filtersgallery.cc +++ /dev/null @@ -1,133 +0,0 @@ -/* - * This file is part of Chalk - * - * Copyright (c) 2005-2006 Cyrille Berger - * Copyright (c) 2007 Benjamin Schleimer - * - * 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_dlg_filtersgallery.h" - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "kis_wdg_filtersgallery.h" - -namespace Chalk { -namespace Plugins { -namespace FiltersGallery { - - -KisDlgFiltersGallery::KisDlgFiltersGallery(KisView* view, TQWidget* parent,const char *name) - : KDialogBase(parent,name, true,i18n("Filters Gallery"), Ok | Cancel), m_view(view),m_currentConfigWidget(0), m_currentFilter(0) -{ - // Initialize main widget - m_widget = new KisWdgFiltersGallery(this); - m_widget->filtersList->setLayer(view->canvasSubject()->currentImg()->activeLayer()); - m_widget->filtersList->setProfile(view->canvasSubject()->monitorProfile()); - - setMainWidget(m_widget); - // Initialize filters list - connect(m_widget->filtersList , TQT_SIGNAL(selectionChanged(TQIconViewItem*)), this, TQT_SLOT(selectionHasChanged(TQIconViewItem* ))); - // Initialize configWidgetHolder - m_widget->configWidgetHolder->setColumnLayout ( 0, Qt::Horizontal ); - //m_widget->configWidgetHolder->setSizePolicy(TQSizePolicy::Expanding, TQSizePolicy::Minimum); - // Initialize preview widget - - if (m_view->canvasSubject()->currentImg() && m_view->canvasSubject()->currentImg()->activeDevice()) - { - m_widget->previewWidget->slotSetDevice( m_view->canvasSubject()->currentImg()->activeDevice().data() ); - } - connect( m_widget->previewWidget, TQT_SIGNAL(updated()), this, TQT_SLOT(refreshPreview())); - resize( minimumSizeHint()); - m_widget->previewWidget->setSizePolicy(TQSizePolicy::Expanding, TQSizePolicy::MinimumExpanding); - m_labelNoCW = new TQLabel(i18n("No configuration options are available for this filter."), m_widget->configWidgetHolder); - m_widget->configWidgetHolder->layout()->add(m_labelNoCW); - m_labelNoCW->hide(); -} - -KisDlgFiltersGallery::~KisDlgFiltersGallery() -{ -} - -void KisDlgFiltersGallery::selectionHasChanged ( TQIconViewItem * item ) -{ - KisFiltersIconViewItem* kisitem = (KisFiltersIconViewItem*) item; - m_currentFilter = kisitem->filter(); - if(m_currentConfigWidget != 0) - { - m_widget->configWidgetHolder->layout()->remove(m_currentConfigWidget); - delete m_currentConfigWidget; - m_currentConfigWidget = 0; - } else { - m_labelNoCW->hide(); - } - KisImageSP img = m_view->canvasSubject()->currentImg(); - KisPaintLayerSP activeLayer = dynamic_cast(img->activeLayer().data()); - - if (activeLayer) - m_currentConfigWidget = m_currentFilter->createConfigurationWidget(m_widget->configWidgetHolder, activeLayer->paintDevice()); - - if(m_currentConfigWidget != 0) { - //m_currentConfigWidget->setSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Fixed); - m_widget->configWidgetHolder->layout()->add(m_currentConfigWidget); - m_currentConfigWidget->show(); - connect(m_currentConfigWidget, TQT_SIGNAL(sigPleaseUpdatePreview()), this, TQT_SLOT(slotConfigChanged())); - } - else { - m_labelNoCW->show(); - } - - refreshPreview(); -} - -void KisDlgFiltersGallery::slotConfigChanged() -{ - if(m_widget->previewWidget->getAutoUpdate()) - { - refreshPreview(); - } else { - m_widget->previewWidget->needUpdate(); - } -} - - -void KisDlgFiltersGallery::refreshPreview( ) -{ - if(!m_currentFilter) return; - - KisFilterConfiguration* config = m_currentFilter->configuration(m_currentConfigWidget); - - m_widget->previewWidget->runFilter(m_currentFilter, config); -} - -} -} -} - -#include "kis_dlg_filtersgallery.moc" diff --git a/chalk/plugins/viewplugins/filtersgallery/kis_dlg_filtersgallery.cpp b/chalk/plugins/viewplugins/filtersgallery/kis_dlg_filtersgallery.cpp new file mode 100644 index 00000000..e0bec7ec --- /dev/null +++ b/chalk/plugins/viewplugins/filtersgallery/kis_dlg_filtersgallery.cpp @@ -0,0 +1,133 @@ +/* + * This file is part of Chalk + * + * Copyright (c) 2005-2006 Cyrille Berger + * Copyright (c) 2007 Benjamin Schleimer + * + * 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_dlg_filtersgallery.h" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "kis_wdg_filtersgallery.h" + +namespace Chalk { +namespace Plugins { +namespace FiltersGallery { + + +KisDlgFiltersGallery::KisDlgFiltersGallery(KisView* view, TQWidget* parent,const char *name) + : KDialogBase(parent,name, true,i18n("Filters Gallery"), Ok | Cancel), m_view(view),m_currentConfigWidget(0), m_currentFilter(0) +{ + // Initialize main widget + m_widget = new KisWdgFiltersGallery(this); + m_widget->filtersList->setLayer(view->canvasSubject()->currentImg()->activeLayer()); + m_widget->filtersList->setProfile(view->canvasSubject()->monitorProfile()); + + setMainWidget(m_widget); + // Initialize filters list + connect(m_widget->filtersList , TQT_SIGNAL(selectionChanged(TQIconViewItem*)), this, TQT_SLOT(selectionHasChanged(TQIconViewItem* ))); + // Initialize configWidgetHolder + m_widget->configWidgetHolder->setColumnLayout ( 0, Qt::Horizontal ); + //m_widget->configWidgetHolder->setSizePolicy(TQSizePolicy::Expanding, TQSizePolicy::Minimum); + // Initialize preview widget + + if (m_view->canvasSubject()->currentImg() && m_view->canvasSubject()->currentImg()->activeDevice()) + { + m_widget->previewWidget->slotSetDevice( m_view->canvasSubject()->currentImg()->activeDevice().data() ); + } + connect( m_widget->previewWidget, TQT_SIGNAL(updated()), this, TQT_SLOT(refreshPreview())); + resize( minimumSizeHint()); + m_widget->previewWidget->setSizePolicy(TQSizePolicy::Expanding, TQSizePolicy::MinimumExpanding); + m_labelNoCW = new TQLabel(i18n("No configuration options are available for this filter."), m_widget->configWidgetHolder); + m_widget->configWidgetHolder->layout()->add(m_labelNoCW); + m_labelNoCW->hide(); +} + +KisDlgFiltersGallery::~KisDlgFiltersGallery() +{ +} + +void KisDlgFiltersGallery::selectionHasChanged ( TQIconViewItem * item ) +{ + KisFiltersIconViewItem* kisitem = (KisFiltersIconViewItem*) item; + m_currentFilter = kisitem->filter(); + if(m_currentConfigWidget != 0) + { + m_widget->configWidgetHolder->layout()->remove(m_currentConfigWidget); + delete m_currentConfigWidget; + m_currentConfigWidget = 0; + } else { + m_labelNoCW->hide(); + } + KisImageSP img = m_view->canvasSubject()->currentImg(); + KisPaintLayerSP activeLayer = dynamic_cast(img->activeLayer().data()); + + if (activeLayer) + m_currentConfigWidget = m_currentFilter->createConfigurationWidget(m_widget->configWidgetHolder, activeLayer->paintDevice()); + + if(m_currentConfigWidget != 0) { + //m_currentConfigWidget->setSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Fixed); + m_widget->configWidgetHolder->layout()->add(m_currentConfigWidget); + m_currentConfigWidget->show(); + connect(m_currentConfigWidget, TQT_SIGNAL(sigPleaseUpdatePreview()), this, TQT_SLOT(slotConfigChanged())); + } + else { + m_labelNoCW->show(); + } + + refreshPreview(); +} + +void KisDlgFiltersGallery::slotConfigChanged() +{ + if(m_widget->previewWidget->getAutoUpdate()) + { + refreshPreview(); + } else { + m_widget->previewWidget->needUpdate(); + } +} + + +void KisDlgFiltersGallery::refreshPreview( ) +{ + if(!m_currentFilter) return; + + KisFilterConfiguration* config = m_currentFilter->configuration(m_currentConfigWidget); + + m_widget->previewWidget->runFilter(m_currentFilter, config); +} + +} +} +} + +#include "kis_dlg_filtersgallery.moc" diff --git a/chalk/plugins/viewplugins/histogram/Makefile.am b/chalk/plugins/viewplugins/histogram/Makefile.am index 31a044eb..b2ec010d 100644 --- a/chalk/plugins/viewplugins/histogram/Makefile.am +++ b/chalk/plugins/viewplugins/histogram/Makefile.am @@ -13,7 +13,7 @@ INCLUDES = -I$(srcdir)/../../../sdk \ kde_module_LTLIBRARIES = chalkhistogram.la -chalkhistogram_la_SOURCES = histogram.cc dlg_histogram.cc wdghistogram.ui kis_histogram_widget.cc +chalkhistogram_la_SOURCES = histogram.cpp dlg_histogram.cpp wdghistogram.ui kis_histogram_widget.cpp noinst_HEADERS = dlg_histogram.h histogram.h wdghistogram.h kis_histogram_widget.h kde_services_DATA = chalkhistogram.desktop diff --git a/chalk/plugins/viewplugins/histogram/dlg_histogram.cc b/chalk/plugins/viewplugins/histogram/dlg_histogram.cc deleted file mode 100644 index 448a58cf..00000000 --- a/chalk/plugins/viewplugins/histogram/dlg_histogram.cc +++ /dev/null @@ -1,68 +0,0 @@ -/* - * dlg_histogram.cc - part of KimageShop^WKrayon^WChalk - * - * Copyright (c) 2004 Boudewijn Rempt - * - * 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 -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "kis_types.h" -#include "kis_histogram.h" -#include "kis_layer.h" -#include "kis_paint_device.h" - -#include "dlg_histogram.h" -#include "kis_histogram_widget.h" - - -DlgHistogram::DlgHistogram( TQWidget * parent, const char * name) - : super (parent, name, true, i18n("Histogram"), Ok | Cancel, Ok) -{ - m_page = new KisHistogramWidget(this, "histogram"); - TQ_CHECK_PTR(m_page); - - setCaption(i18n("Histogram")); - setMainWidget(m_page); - resize(m_page->sizeHint()); -} - -DlgHistogram::~DlgHistogram() -{ - delete m_page; -} - -void DlgHistogram::setPaintDevice(KisPaintDeviceSP dev) -{ - m_page->setPaintDevice(dev); -} - -void DlgHistogram::okClicked() -{ - accept(); -} - -#include "dlg_histogram.moc" diff --git a/chalk/plugins/viewplugins/histogram/dlg_histogram.cpp b/chalk/plugins/viewplugins/histogram/dlg_histogram.cpp new file mode 100644 index 00000000..77ad0668 --- /dev/null +++ b/chalk/plugins/viewplugins/histogram/dlg_histogram.cpp @@ -0,0 +1,68 @@ +/* + * dlg_histogram.cpp - part of KimageShop^WKrayon^WChalk + * + * Copyright (c) 2004 Boudewijn Rempt + * + * 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 +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "kis_types.h" +#include "kis_histogram.h" +#include "kis_layer.h" +#include "kis_paint_device.h" + +#include "dlg_histogram.h" +#include "kis_histogram_widget.h" + + +DlgHistogram::DlgHistogram( TQWidget * parent, const char * name) + : super (parent, name, true, i18n("Histogram"), Ok | Cancel, Ok) +{ + m_page = new KisHistogramWidget(this, "histogram"); + TQ_CHECK_PTR(m_page); + + setCaption(i18n("Histogram")); + setMainWidget(m_page); + resize(m_page->sizeHint()); +} + +DlgHistogram::~DlgHistogram() +{ + delete m_page; +} + +void DlgHistogram::setPaintDevice(KisPaintDeviceSP dev) +{ + m_page->setPaintDevice(dev); +} + +void DlgHistogram::okClicked() +{ + accept(); +} + +#include "dlg_histogram.moc" diff --git a/chalk/plugins/viewplugins/histogram/histogram.cc b/chalk/plugins/viewplugins/histogram/histogram.cc deleted file mode 100644 index 8252a98d..00000000 --- a/chalk/plugins/viewplugins/histogram/histogram.cc +++ /dev/null @@ -1,105 +0,0 @@ -/* - * histogram.h -- Part of Chalk - * - * Copyright (c) 2004 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 - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "histogram.h" -#include "dlg_histogram.h" -#include "kis_colorspace.h" -#include "kis_histogram.h" - -typedef KGenericFactory HistogramFactory; -K_EXPORT_COMPONENT_FACTORY( chalkhistogram, HistogramFactory( "chalk" ) ) - -Histogram::Histogram(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - - if ( parent->inherits("KisView") ) { - - setInstance(HistogramFactory::instance()); - setXMLFile(locate("data","chalkplugins/histogram.rc"), true); - - m_action = new TDEAction(i18n("&Histogram"), 0, 0, this, TQT_SLOT(slotActivated()), actionCollection(), "histogram"); - - m_view = (KisView*) parent; - if (KisImageSP img = m_view->canvasSubject()->currentImg()) { - connect(img, TQT_SIGNAL(sigLayersChanged(KisGroupLayerSP)), this, TQT_SLOT(slotLayersChanged())); - connect(img, TQT_SIGNAL(sigLayerAdded(KisLayerSP)), this, TQT_SLOT(slotLayersChanged())); - connect(img, TQT_SIGNAL(sigLayerActivated(KisLayerSP)), this, TQT_SLOT(slotLayersChanged())); - connect(img, TQT_SIGNAL(sigLayerPropertiesChanged(KisLayerSP)), this, TQT_SLOT(slotLayersChanged())); - connect(img, TQT_SIGNAL(sigLayerRemoved(KisLayerSP, KisGroupLayerSP, KisLayerSP)), - this, TQT_SLOT(slotLayersChanged())); - connect(img, TQT_SIGNAL(sigLayerMoved(KisLayerSP, KisGroupLayerSP, KisLayerSP)), - this, TQT_SLOT(slotLayersChanged())); - m_img = img; - } - } -} - -Histogram::~Histogram() -{ -} - -void Histogram::slotLayersChanged() { - m_action->setEnabled(m_img && m_img->activeLayer() && m_img->activeLayer()->visible()); -} - -void Histogram::slotActivated() -{ - DlgHistogram * dlgHistogram = new DlgHistogram(m_view, "Histogram"); - TQ_CHECK_PTR(dlgHistogram); - - KisPaintDeviceSP dev = m_view->canvasSubject()->currentImg()->activeDevice(); - if (dev) - dlgHistogram->setPaintDevice(dev); - - if (dlgHistogram->exec() == TQDialog::Accepted) { - // Do nothing; this is an informational dialog - } - delete dlgHistogram; -} - -#include "histogram.moc" - diff --git a/chalk/plugins/viewplugins/histogram/histogram.cpp b/chalk/plugins/viewplugins/histogram/histogram.cpp new file mode 100644 index 00000000..8252a98d --- /dev/null +++ b/chalk/plugins/viewplugins/histogram/histogram.cpp @@ -0,0 +1,105 @@ +/* + * histogram.h -- Part of Chalk + * + * Copyright (c) 2004 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 + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "histogram.h" +#include "dlg_histogram.h" +#include "kis_colorspace.h" +#include "kis_histogram.h" + +typedef KGenericFactory HistogramFactory; +K_EXPORT_COMPONENT_FACTORY( chalkhistogram, HistogramFactory( "chalk" ) ) + +Histogram::Histogram(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + + if ( parent->inherits("KisView") ) { + + setInstance(HistogramFactory::instance()); + setXMLFile(locate("data","chalkplugins/histogram.rc"), true); + + m_action = new TDEAction(i18n("&Histogram"), 0, 0, this, TQT_SLOT(slotActivated()), actionCollection(), "histogram"); + + m_view = (KisView*) parent; + if (KisImageSP img = m_view->canvasSubject()->currentImg()) { + connect(img, TQT_SIGNAL(sigLayersChanged(KisGroupLayerSP)), this, TQT_SLOT(slotLayersChanged())); + connect(img, TQT_SIGNAL(sigLayerAdded(KisLayerSP)), this, TQT_SLOT(slotLayersChanged())); + connect(img, TQT_SIGNAL(sigLayerActivated(KisLayerSP)), this, TQT_SLOT(slotLayersChanged())); + connect(img, TQT_SIGNAL(sigLayerPropertiesChanged(KisLayerSP)), this, TQT_SLOT(slotLayersChanged())); + connect(img, TQT_SIGNAL(sigLayerRemoved(KisLayerSP, KisGroupLayerSP, KisLayerSP)), + this, TQT_SLOT(slotLayersChanged())); + connect(img, TQT_SIGNAL(sigLayerMoved(KisLayerSP, KisGroupLayerSP, KisLayerSP)), + this, TQT_SLOT(slotLayersChanged())); + m_img = img; + } + } +} + +Histogram::~Histogram() +{ +} + +void Histogram::slotLayersChanged() { + m_action->setEnabled(m_img && m_img->activeLayer() && m_img->activeLayer()->visible()); +} + +void Histogram::slotActivated() +{ + DlgHistogram * dlgHistogram = new DlgHistogram(m_view, "Histogram"); + TQ_CHECK_PTR(dlgHistogram); + + KisPaintDeviceSP dev = m_view->canvasSubject()->currentImg()->activeDevice(); + if (dev) + dlgHistogram->setPaintDevice(dev); + + if (dlgHistogram->exec() == TQDialog::Accepted) { + // Do nothing; this is an informational dialog + } + delete dlgHistogram; +} + +#include "histogram.moc" + diff --git a/chalk/plugins/viewplugins/histogram/kis_histogram_widget.cc b/chalk/plugins/viewplugins/histogram/kis_histogram_widget.cc deleted file mode 100644 index c4983870..00000000 --- a/chalk/plugins/viewplugins/histogram/kis_histogram_widget.cc +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (c) 2004 Boudewijn Rempt - * (c) 2005 Bart Coppens - * - * 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 -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "kis_channelinfo.h" -#include "kis_histogram_view.h" -#include "kis_histogram_widget.h" -#include "kis_histogram.h" -#include "kis_global.h" -#include "kis_types.h" -#include "kis_layer.h" -#include "kis_paint_device.h" -#include "kis_colorspace.h" - - -KisHistogramWidget::KisHistogramWidget(TQWidget *parent, const char *name) - : super(parent, name) -{ - m_from = 0.0; - m_width = 0.0; -} - -KisHistogramWidget::~KisHistogramWidget() -{ -} - -void KisHistogramWidget::setPaintDevice(KisPaintDeviceSP dev) -{ - grpType->disconnect(this); - cmbChannel->disconnect(this); - - m_histogramView->setPaintDevice(dev); - setActiveChannel(0); // So we have the colored one if there are colors - - // The channels - cmbChannel->clear(); - cmbChannel->insertStringList(m_histogramView->channelStrings()); - cmbChannel->setCurrentItem(0); - - // View display - currentView->setMinValue(0); - currentView->setMaxValue(100); - - updateEnabled(); - - m_from = m_histogramView->currentProducer()->viewFrom(); - m_width = m_histogramView->currentProducer()->viewWidth(); - - connect(grpType, TQT_SIGNAL(clicked(int)), this, TQT_SLOT(slotTypeSwitched(int))); - connect(cmbChannel, TQT_SIGNAL(activated(int)), this, TQT_SLOT(setActiveChannel(int))); - connect(zoomIn, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotZoomIn())); - connect(zoomOut, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotZoomOut())); - connect(currentView, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(slide(int))); -} - -void KisHistogramWidget::setActiveChannel(int channel) -{ - m_histogramView->setActiveChannel(channel); - updateEnabled(); -} - -void KisHistogramWidget::slotTypeSwitched(int id) -{ - if (id == LINEAR) - m_histogramView->setHistogramType(LINEAR); - else if (id == LOGARITHMIC) - m_histogramView->setHistogramType(LOGARITHMIC); -} - -void KisHistogramWidget::setView(double from, double size) -{ - m_from = from; - m_width = size; - if (m_from + m_width > 1.0) - m_from = 1.0 - m_width; - m_histogramView->setView(m_from, m_width); - updateEnabled(); -} - -void KisHistogramWidget::slotZoomIn() { - if ((m_width / 2) >= m_histogramView->currentProducer()->maximalZoom()) { - setView(m_from, m_width / 2); - } -} - -void KisHistogramWidget::slotZoomOut() { - if (m_width * 2 <= 1.0) { - setView(m_from, m_width * 2); - } -} - -void KisHistogramWidget::slide(int val) { - // Beware: at the END (e.g. 100), we want to still view m_width: - setView((static_cast(val) / 100.0) * (1.0 - m_width), m_width); -} - -void KisHistogramWidget::updateEnabled() { - if (m_histogramView->currentProducer()->maximalZoom() < 1.0) { - if ((m_width / 2) >= m_histogramView->currentProducer()->maximalZoom()) { - zoomIn->setEnabled(true); - } else { - zoomIn->setEnabled(false); - } - if (m_width * 2 <= 1.0) { - zoomOut->setEnabled(true); - } else { - zoomOut->setEnabled(false); - } - if (m_width < 1.0) - currentView->setEnabled(true); - else - currentView->setEnabled(false); - } else { - zoomIn->setEnabled(false); - zoomOut->setEnabled(false); - currentView->setEnabled(false); - } -} - -#include "kis_histogram_widget.moc" - diff --git a/chalk/plugins/viewplugins/histogram/kis_histogram_widget.cpp b/chalk/plugins/viewplugins/histogram/kis_histogram_widget.cpp new file mode 100644 index 00000000..c4983870 --- /dev/null +++ b/chalk/plugins/viewplugins/histogram/kis_histogram_widget.cpp @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2004 Boudewijn Rempt + * (c) 2005 Bart Coppens + * + * 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 +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "kis_channelinfo.h" +#include "kis_histogram_view.h" +#include "kis_histogram_widget.h" +#include "kis_histogram.h" +#include "kis_global.h" +#include "kis_types.h" +#include "kis_layer.h" +#include "kis_paint_device.h" +#include "kis_colorspace.h" + + +KisHistogramWidget::KisHistogramWidget(TQWidget *parent, const char *name) + : super(parent, name) +{ + m_from = 0.0; + m_width = 0.0; +} + +KisHistogramWidget::~KisHistogramWidget() +{ +} + +void KisHistogramWidget::setPaintDevice(KisPaintDeviceSP dev) +{ + grpType->disconnect(this); + cmbChannel->disconnect(this); + + m_histogramView->setPaintDevice(dev); + setActiveChannel(0); // So we have the colored one if there are colors + + // The channels + cmbChannel->clear(); + cmbChannel->insertStringList(m_histogramView->channelStrings()); + cmbChannel->setCurrentItem(0); + + // View display + currentView->setMinValue(0); + currentView->setMaxValue(100); + + updateEnabled(); + + m_from = m_histogramView->currentProducer()->viewFrom(); + m_width = m_histogramView->currentProducer()->viewWidth(); + + connect(grpType, TQT_SIGNAL(clicked(int)), this, TQT_SLOT(slotTypeSwitched(int))); + connect(cmbChannel, TQT_SIGNAL(activated(int)), this, TQT_SLOT(setActiveChannel(int))); + connect(zoomIn, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotZoomIn())); + connect(zoomOut, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotZoomOut())); + connect(currentView, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(slide(int))); +} + +void KisHistogramWidget::setActiveChannel(int channel) +{ + m_histogramView->setActiveChannel(channel); + updateEnabled(); +} + +void KisHistogramWidget::slotTypeSwitched(int id) +{ + if (id == LINEAR) + m_histogramView->setHistogramType(LINEAR); + else if (id == LOGARITHMIC) + m_histogramView->setHistogramType(LOGARITHMIC); +} + +void KisHistogramWidget::setView(double from, double size) +{ + m_from = from; + m_width = size; + if (m_from + m_width > 1.0) + m_from = 1.0 - m_width; + m_histogramView->setView(m_from, m_width); + updateEnabled(); +} + +void KisHistogramWidget::slotZoomIn() { + if ((m_width / 2) >= m_histogramView->currentProducer()->maximalZoom()) { + setView(m_from, m_width / 2); + } +} + +void KisHistogramWidget::slotZoomOut() { + if (m_width * 2 <= 1.0) { + setView(m_from, m_width * 2); + } +} + +void KisHistogramWidget::slide(int val) { + // Beware: at the END (e.g. 100), we want to still view m_width: + setView((static_cast(val) / 100.0) * (1.0 - m_width), m_width); +} + +void KisHistogramWidget::updateEnabled() { + if (m_histogramView->currentProducer()->maximalZoom() < 1.0) { + if ((m_width / 2) >= m_histogramView->currentProducer()->maximalZoom()) { + zoomIn->setEnabled(true); + } else { + zoomIn->setEnabled(false); + } + if (m_width * 2 <= 1.0) { + zoomOut->setEnabled(true); + } else { + zoomOut->setEnabled(false); + } + if (m_width < 1.0) + currentView->setEnabled(true); + else + currentView->setEnabled(false); + } else { + zoomIn->setEnabled(false); + zoomOut->setEnabled(false); + currentView->setEnabled(false); + } +} + +#include "kis_histogram_widget.moc" + diff --git a/chalk/plugins/viewplugins/histogram_docker/Makefile.am b/chalk/plugins/viewplugins/histogram_docker/Makefile.am index 0dcb9914..bdedf5dd 100644 --- a/chalk/plugins/viewplugins/histogram_docker/Makefile.am +++ b/chalk/plugins/viewplugins/histogram_docker/Makefile.am @@ -10,7 +10,7 @@ INCLUDES = -I$(srcdir)/../../../sdk \ $(KOFFICE_INCLUDES) \ $(all_includes) -chalkhistogramdocker_la_SOURCES = histogramdocker.cc kis_imagerasteredcache.cc kis_cachedhistogram.cc kis_accumulating_producer.cc +chalkhistogramdocker_la_SOURCES = histogramdocker.cpp kis_imagerasteredcache.cpp kis_cachedhistogram.cpp kis_accumulating_producer.cpp kde_module_LTLIBRARIES = chalkhistogramdocker.la noinst_HEADERS = histogramdocker.h kis_imagerasteredcache.h kis_cachedhistogram.h kis_accumulating_producer.h diff --git a/chalk/plugins/viewplugins/histogram_docker/histogramdocker.cc b/chalk/plugins/viewplugins/histogram_docker/histogramdocker.cc deleted file mode 100644 index 25a7b9cf..00000000 --- a/chalk/plugins/viewplugins/histogram_docker/histogramdocker.cc +++ /dev/null @@ -1,192 +0,0 @@ -/* - * This file is part of the KDE project - * - * Copyright (c) 2005 Bart Coppens - * - * 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 - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "kis_meta_registry.h" -#include -#include -#include -#include - -#include -#include - -#include "histogramdocker.h" -#include "kis_imagerasteredcache.h" -#include "kis_accumulating_producer.h" - -typedef KGenericFactory ChalkHistogramDockerFactory; -K_EXPORT_COMPONENT_FACTORY( chalkhistogramdocker, ChalkHistogramDockerFactory( "chalk" ) ) - -ChalkHistogramDocker::ChalkHistogramDocker(TQObject *parent, const char *name, const TQStringList&) - : KParts::Plugin(parent, name) -{ - - if ( parent->inherits("KisView") ) { - m_view = dynamic_cast(parent); - - setInstance(ChalkHistogramDockerFactory::instance()); - setXMLFile(locate("data","chalkplugins/chalkhistogramdocker.rc"), true); - - KisImageSP img = m_view->canvasSubject()->currentImg(); - if (!img) { - m_cache = 0; - return; - } - - m_hview = 0; // producerChanged wants to setCurrentChannels, prevent that here - m_cache = 0; // we try to delete it in producerChanged - colorSpaceChanged(img->colorSpace()); // calls producerChanged(0) - - - m_hview = new KisHistogramView(m_view); - TQToolTip::add(m_hview, i18n("Right-click to select histogram type")); - m_hview->setHistogram(m_histogram); - m_hview->setColor(true); - m_hview->setCurrentChannels(m_producer, m_producer->channels()); - m_hview->setFixedSize(256, 100); // XXX if not it keeps expanding - m_hview->setCaption(i18n("Histogram")); - - - connect(m_hview, TQT_SIGNAL(rightClicked(const TQPoint&)), - this, TQT_SLOT(popupMenu(const TQPoint&))); - connect(m_cache, TQT_SIGNAL(cacheUpdated()), - new HistogramDockerUpdater(this, m_histogram, m_hview, m_producer), TQT_SLOT(updated())); - connect(&m_popup, TQT_SIGNAL(activated(int)), - this, TQT_SLOT(producerChanged(int))); - connect(img, TQT_SIGNAL(sigColorSpaceChanged(KisColorSpace*)), - this, TQT_SLOT(colorSpaceChanged(KisColorSpace*))); // No need to force updates here - - // Add it to the control palette - m_view->canvasSubject()->paletteManager()->addWidget( - m_hview, "histodocker", chalk::CONTROL_PALETTE); - } else { - m_cache = 0; - } -} - -ChalkHistogramDocker::~ChalkHistogramDocker() -{ - uint count = m_producers . count(); - for (uint i = 0; i < count; i++) { - delete m_producers . at(i); - } - - if (m_cache) - m_cache->deleteLater(); -} - -void ChalkHistogramDocker::producerChanged(int pos) -{ - if (m_cache) - m_cache->deleteLater(); - m_cache = 0; - - if (m_currentProducerPos < m_popup.count()) - m_popup.setItemChecked(m_currentProducerPos, false); - m_currentProducerPos = pos; - m_popup.setItemChecked(m_currentProducerPos, true); - - uint count = m_producers . count(); - for (uint i = 0; i < count; i++) { - delete m_producers . at(i); - } - m_producers.clear(); - - KisIDList keys = KisHistogramProducerFactoryRegistry::instance() -> - listKeysCompatibleWith(m_cs); - - m_factory = KisHistogramProducerFactoryRegistry::instance()->get(*(keys.at(pos))); - - KisCachedHistogramObserver observer(&m_producers, m_factory, 0, 0, 0, 0, false); - - // We can reference observer because it will be only used as a factory to create new - // instances - m_cache = new KisImageRasteredCache(m_view, &observer); - - m_producer = new KisAccumulatingHistogramProducer(&m_producers); - - // use dummy layer as a source; we are not going to actually use or need it - // All of these are SP, no need to delete them afterwards - m_histogram = new KisHistogram( new KisPaintDevice(KisMetaRegistry::instance()->csRegistry()->getAlpha8(), "dummy histogram"), m_producer, LOGARITHMIC); - - if (m_hview) { - m_hview->setHistogram(m_histogram); - m_hview->setColor(true); - m_hview->setCurrentChannels(m_producer, m_producer->channels()); - - connect(m_cache, TQT_SIGNAL(cacheUpdated()), - new HistogramDockerUpdater(this, m_histogram, m_hview, m_producer), TQT_SLOT(updated())); - } -} - -void ChalkHistogramDocker::popupMenu(const TQPoint& pos) -{ - m_popup.popup(pos, m_currentProducerPos); -} - -void ChalkHistogramDocker::colorSpaceChanged(KisColorSpace* cs) -{ - m_cs = cs; - - KisIDList keys = KisHistogramProducerFactoryRegistry::instance() -> - listKeysCompatibleWith(m_cs); - - m_popup.clear(); - m_currentProducerPos = 0; - - for (uint i = 0; i < keys.count(); i++) { - KisID id(*(keys.at(i))); - m_popup . insertItem(id.name(), static_cast(i)); - } - - producerChanged(0); -} - -HistogramDockerUpdater::HistogramDockerUpdater(TQObject* /*parent*/, KisHistogramSP h, KisHistogramView* v, - KisAccumulatingHistogramProducer* p) - : m_histogram(h), m_view(v), m_producer(p) -{ - connect(p, TQT_SIGNAL(completed()), this, TQT_SLOT(completed())); -} - -void HistogramDockerUpdater::updated() { - // We don't [!] do m_histogram->updateHistogram();, because that will try to compute - // the histogram synchronously, while we want it asynchronously. - m_producer->addRegionsToBinAsync(); -} - -void HistogramDockerUpdater::completed() { - m_histogram->computeHistogram(); - m_view->updateHistogram(); -} - -#include "histogramdocker.moc" diff --git a/chalk/plugins/viewplugins/histogram_docker/histogramdocker.cpp b/chalk/plugins/viewplugins/histogram_docker/histogramdocker.cpp new file mode 100644 index 00000000..25a7b9cf --- /dev/null +++ b/chalk/plugins/viewplugins/histogram_docker/histogramdocker.cpp @@ -0,0 +1,192 @@ +/* + * This file is part of the KDE project + * + * Copyright (c) 2005 Bart Coppens + * + * 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 + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "kis_meta_registry.h" +#include +#include +#include +#include + +#include +#include + +#include "histogramdocker.h" +#include "kis_imagerasteredcache.h" +#include "kis_accumulating_producer.h" + +typedef KGenericFactory ChalkHistogramDockerFactory; +K_EXPORT_COMPONENT_FACTORY( chalkhistogramdocker, ChalkHistogramDockerFactory( "chalk" ) ) + +ChalkHistogramDocker::ChalkHistogramDocker(TQObject *parent, const char *name, const TQStringList&) + : KParts::Plugin(parent, name) +{ + + if ( parent->inherits("KisView") ) { + m_view = dynamic_cast(parent); + + setInstance(ChalkHistogramDockerFactory::instance()); + setXMLFile(locate("data","chalkplugins/chalkhistogramdocker.rc"), true); + + KisImageSP img = m_view->canvasSubject()->currentImg(); + if (!img) { + m_cache = 0; + return; + } + + m_hview = 0; // producerChanged wants to setCurrentChannels, prevent that here + m_cache = 0; // we try to delete it in producerChanged + colorSpaceChanged(img->colorSpace()); // calls producerChanged(0) + + + m_hview = new KisHistogramView(m_view); + TQToolTip::add(m_hview, i18n("Right-click to select histogram type")); + m_hview->setHistogram(m_histogram); + m_hview->setColor(true); + m_hview->setCurrentChannels(m_producer, m_producer->channels()); + m_hview->setFixedSize(256, 100); // XXX if not it keeps expanding + m_hview->setCaption(i18n("Histogram")); + + + connect(m_hview, TQT_SIGNAL(rightClicked(const TQPoint&)), + this, TQT_SLOT(popupMenu(const TQPoint&))); + connect(m_cache, TQT_SIGNAL(cacheUpdated()), + new HistogramDockerUpdater(this, m_histogram, m_hview, m_producer), TQT_SLOT(updated())); + connect(&m_popup, TQT_SIGNAL(activated(int)), + this, TQT_SLOT(producerChanged(int))); + connect(img, TQT_SIGNAL(sigColorSpaceChanged(KisColorSpace*)), + this, TQT_SLOT(colorSpaceChanged(KisColorSpace*))); // No need to force updates here + + // Add it to the control palette + m_view->canvasSubject()->paletteManager()->addWidget( + m_hview, "histodocker", chalk::CONTROL_PALETTE); + } else { + m_cache = 0; + } +} + +ChalkHistogramDocker::~ChalkHistogramDocker() +{ + uint count = m_producers . count(); + for (uint i = 0; i < count; i++) { + delete m_producers . at(i); + } + + if (m_cache) + m_cache->deleteLater(); +} + +void ChalkHistogramDocker::producerChanged(int pos) +{ + if (m_cache) + m_cache->deleteLater(); + m_cache = 0; + + if (m_currentProducerPos < m_popup.count()) + m_popup.setItemChecked(m_currentProducerPos, false); + m_currentProducerPos = pos; + m_popup.setItemChecked(m_currentProducerPos, true); + + uint count = m_producers . count(); + for (uint i = 0; i < count; i++) { + delete m_producers . at(i); + } + m_producers.clear(); + + KisIDList keys = KisHistogramProducerFactoryRegistry::instance() -> + listKeysCompatibleWith(m_cs); + + m_factory = KisHistogramProducerFactoryRegistry::instance()->get(*(keys.at(pos))); + + KisCachedHistogramObserver observer(&m_producers, m_factory, 0, 0, 0, 0, false); + + // We can reference observer because it will be only used as a factory to create new + // instances + m_cache = new KisImageRasteredCache(m_view, &observer); + + m_producer = new KisAccumulatingHistogramProducer(&m_producers); + + // use dummy layer as a source; we are not going to actually use or need it + // All of these are SP, no need to delete them afterwards + m_histogram = new KisHistogram( new KisPaintDevice(KisMetaRegistry::instance()->csRegistry()->getAlpha8(), "dummy histogram"), m_producer, LOGARITHMIC); + + if (m_hview) { + m_hview->setHistogram(m_histogram); + m_hview->setColor(true); + m_hview->setCurrentChannels(m_producer, m_producer->channels()); + + connect(m_cache, TQT_SIGNAL(cacheUpdated()), + new HistogramDockerUpdater(this, m_histogram, m_hview, m_producer), TQT_SLOT(updated())); + } +} + +void ChalkHistogramDocker::popupMenu(const TQPoint& pos) +{ + m_popup.popup(pos, m_currentProducerPos); +} + +void ChalkHistogramDocker::colorSpaceChanged(KisColorSpace* cs) +{ + m_cs = cs; + + KisIDList keys = KisHistogramProducerFactoryRegistry::instance() -> + listKeysCompatibleWith(m_cs); + + m_popup.clear(); + m_currentProducerPos = 0; + + for (uint i = 0; i < keys.count(); i++) { + KisID id(*(keys.at(i))); + m_popup . insertItem(id.name(), static_cast(i)); + } + + producerChanged(0); +} + +HistogramDockerUpdater::HistogramDockerUpdater(TQObject* /*parent*/, KisHistogramSP h, KisHistogramView* v, + KisAccumulatingHistogramProducer* p) + : m_histogram(h), m_view(v), m_producer(p) +{ + connect(p, TQT_SIGNAL(completed()), this, TQT_SLOT(completed())); +} + +void HistogramDockerUpdater::updated() { + // We don't [!] do m_histogram->updateHistogram();, because that will try to compute + // the histogram synchronously, while we want it asynchronously. + m_producer->addRegionsToBinAsync(); +} + +void HistogramDockerUpdater::completed() { + m_histogram->computeHistogram(); + m_view->updateHistogram(); +} + +#include "histogramdocker.moc" diff --git a/chalk/plugins/viewplugins/histogram_docker/kis_accumulating_producer.cc b/chalk/plugins/viewplugins/histogram_docker/kis_accumulating_producer.cc deleted file mode 100644 index 217a36d9..00000000 --- a/chalk/plugins/viewplugins/histogram_docker/kis_accumulating_producer.cc +++ /dev/null @@ -1,102 +0,0 @@ -/* - * This file is part of Chalk - * - * Copyright (c) 2005 Bart Coppens - * - * 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 -#include -#include - -#include "kis_accumulating_producer.h" - -static const int EmitCompletedType = TQEvent::User + 1; - -/** - * The threaded producer definition in c++ file because this is really an internal affair. - * Note that since we _know_ that we'll only have a single instance of it running, at most, - * we don't care too much about locking and synchronization - **/ -class KisAccumulatingHistogramProducer::ThreadedProducer : public TQThread { - KisAccumulatingHistogramProducer* m_source; - bool m_stop; -protected: - virtual void run(); -public: - ThreadedProducer(KisAccumulatingHistogramProducer* source) - : m_source(source), m_stop(false) {} - void cancel() { m_stop = true; } -}; - -KisAccumulatingHistogramProducer::KisAccumulatingHistogramProducer(KisCachedHistogramObserver::Producers* source) - : KisBasicHistogramProducer( - KisID("ACCHISTO", ""), - source->at(0)->channels().count(), - source->at(0)->numberOfBins(), - 0), - m_source(source) -{ - m_thread = new ThreadedProducer(this); -} - -KisAccumulatingHistogramProducer::~KisAccumulatingHistogramProducer() { - m_thread->cancel(); - m_thread->wait(); - delete m_thread; -} - -void KisAccumulatingHistogramProducer::addRegionsToBinAsync() { - m_thread->cancel(); - m_thread->wait(); - clear(); - m_thread->start(); -} - -void KisAccumulatingHistogramProducer::ThreadedProducer::run() { - m_stop = false; - - uint count = m_source->m_source->count(); // Talk about bad naming schemes... - KisCachedHistogramObserver::Producers* source = m_source->m_source; - TQValueVector& bins = m_source->m_bins; - int channels = m_source->m_channels; - int nrOfBins = m_source->m_nrOfBins; - - for (uint i = 0; i < count && !m_stop; i++) { - KisHistogramProducer* p = source->at(i); - m_source->m_count += p->count(); - - for (int j = 0; j < channels && !m_stop; j++) { - for (int k = 0; k < nrOfBins; k++) { - bins.at(j).at(k) += p->getBinAt(j, k); - } - } - } - - if (!m_stop) { - // This function is thread-safe; and it takes ownership of the event - TQApplication::postEvent(m_source, new TQCustomEvent(EmitCompletedType)); - } -} - -void KisAccumulatingHistogramProducer::customEvent(TQCustomEvent* e) { - if (e->type() == EmitCompletedType) { - emit completed(); - } -} - -#include "kis_accumulating_producer.moc" - diff --git a/chalk/plugins/viewplugins/histogram_docker/kis_accumulating_producer.cpp b/chalk/plugins/viewplugins/histogram_docker/kis_accumulating_producer.cpp new file mode 100644 index 00000000..217a36d9 --- /dev/null +++ b/chalk/plugins/viewplugins/histogram_docker/kis_accumulating_producer.cpp @@ -0,0 +1,102 @@ +/* + * This file is part of Chalk + * + * Copyright (c) 2005 Bart Coppens + * + * 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 +#include +#include + +#include "kis_accumulating_producer.h" + +static const int EmitCompletedType = TQEvent::User + 1; + +/** + * The threaded producer definition in c++ file because this is really an internal affair. + * Note that since we _know_ that we'll only have a single instance of it running, at most, + * we don't care too much about locking and synchronization + **/ +class KisAccumulatingHistogramProducer::ThreadedProducer : public TQThread { + KisAccumulatingHistogramProducer* m_source; + bool m_stop; +protected: + virtual void run(); +public: + ThreadedProducer(KisAccumulatingHistogramProducer* source) + : m_source(source), m_stop(false) {} + void cancel() { m_stop = true; } +}; + +KisAccumulatingHistogramProducer::KisAccumulatingHistogramProducer(KisCachedHistogramObserver::Producers* source) + : KisBasicHistogramProducer( + KisID("ACCHISTO", ""), + source->at(0)->channels().count(), + source->at(0)->numberOfBins(), + 0), + m_source(source) +{ + m_thread = new ThreadedProducer(this); +} + +KisAccumulatingHistogramProducer::~KisAccumulatingHistogramProducer() { + m_thread->cancel(); + m_thread->wait(); + delete m_thread; +} + +void KisAccumulatingHistogramProducer::addRegionsToBinAsync() { + m_thread->cancel(); + m_thread->wait(); + clear(); + m_thread->start(); +} + +void KisAccumulatingHistogramProducer::ThreadedProducer::run() { + m_stop = false; + + uint count = m_source->m_source->count(); // Talk about bad naming schemes... + KisCachedHistogramObserver::Producers* source = m_source->m_source; + TQValueVector& bins = m_source->m_bins; + int channels = m_source->m_channels; + int nrOfBins = m_source->m_nrOfBins; + + for (uint i = 0; i < count && !m_stop; i++) { + KisHistogramProducer* p = source->at(i); + m_source->m_count += p->count(); + + for (int j = 0; j < channels && !m_stop; j++) { + for (int k = 0; k < nrOfBins; k++) { + bins.at(j).at(k) += p->getBinAt(j, k); + } + } + } + + if (!m_stop) { + // This function is thread-safe; and it takes ownership of the event + TQApplication::postEvent(m_source, new TQCustomEvent(EmitCompletedType)); + } +} + +void KisAccumulatingHistogramProducer::customEvent(TQCustomEvent* e) { + if (e->type() == EmitCompletedType) { + emit completed(); + } +} + +#include "kis_accumulating_producer.moc" + diff --git a/chalk/plugins/viewplugins/histogram_docker/kis_cachedhistogram.cc b/chalk/plugins/viewplugins/histogram_docker/kis_cachedhistogram.cc deleted file mode 100644 index 1ad197f9..00000000 --- a/chalk/plugins/viewplugins/histogram_docker/kis_cachedhistogram.cc +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This file is part of Chalk - * - * Copyright (c) 2005 Bart Coppens - * - * 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 -#include - -#include "kis_cachedhistogram.h" - -void KisCachedHistogramObserver::regionUpdated(KisPaintDeviceSP dev) { - m_producer->clear(); - KisRectIteratorPixel srcIt = dev->createRectIterator(m_x, m_y, m_w, m_h, false); - int i; - while ( !srcIt.isDone() ) { - i = srcIt.nConseqPixels(); - m_producer->addRegionToBin(srcIt.rawData(), srcIt.selectionMask(), i, dev->colorSpace()); - srcIt += i; - if (i == 0) - ++srcIt; - } -} diff --git a/chalk/plugins/viewplugins/histogram_docker/kis_cachedhistogram.cpp b/chalk/plugins/viewplugins/histogram_docker/kis_cachedhistogram.cpp new file mode 100644 index 00000000..1ad197f9 --- /dev/null +++ b/chalk/plugins/viewplugins/histogram_docker/kis_cachedhistogram.cpp @@ -0,0 +1,37 @@ +/* + * This file is part of Chalk + * + * Copyright (c) 2005 Bart Coppens + * + * 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 +#include + +#include "kis_cachedhistogram.h" + +void KisCachedHistogramObserver::regionUpdated(KisPaintDeviceSP dev) { + m_producer->clear(); + KisRectIteratorPixel srcIt = dev->createRectIterator(m_x, m_y, m_w, m_h, false); + int i; + while ( !srcIt.isDone() ) { + i = srcIt.nConseqPixels(); + m_producer->addRegionToBin(srcIt.rawData(), srcIt.selectionMask(), i, dev->colorSpace()); + srcIt += i; + if (i == 0) + ++srcIt; + } +} diff --git a/chalk/plugins/viewplugins/histogram_docker/kis_imagerasteredcache.cc b/chalk/plugins/viewplugins/histogram_docker/kis_imagerasteredcache.cc deleted file mode 100644 index 19599cd9..00000000 --- a/chalk/plugins/viewplugins/histogram_docker/kis_imagerasteredcache.cc +++ /dev/null @@ -1,162 +0,0 @@ -/* - * This file is part of the KDE project - * - * Copyright (c) 2005 Bart Coppens - * - * 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 - -#include - -#include - -#include -#include -#include -#include - -#include "kis_imagerasteredcache.h" - -KisImageRasteredCache::KisImageRasteredCache(KisView* view, Observer* o) - : m_observer(o->createNew(0, 0, 0, 0)), m_view(view) -{ - m_busy = false; - m_imageProjection = 0; - m_rasterSize = 64*4; - m_timeOutMSec = 1000; - - KisImageSP img = view->canvasSubject()->currentImg(); - - if (!img) { - return; - } - - imageSizeChanged(img->width(), img->height()); - - connect(img, TQT_SIGNAL(sigImageUpdated(TQRect)), - this, TQT_SLOT(imageUpdated(TQRect))); - connect(img, TQT_SIGNAL(sigSizeChanged(TQ_INT32, TQ_INT32)), - this, TQT_SLOT(imageSizeChanged(TQ_INT32, TQ_INT32))); - connect(&m_timer, TQT_SIGNAL(timeout()), this, TQT_SLOT(timeOut())); -} - -KisImageRasteredCache::~KisImageRasteredCache() { - cleanUpElements(); -} - -void KisImageRasteredCache::imageUpdated(TQRect rc) { - - if (rc.isValid()) { - TQRect r(0, 0, m_width * m_rasterSize, m_height * m_rasterSize); - r &= rc; - - uint x = static_cast(r.x() / m_rasterSize); - uint y = static_cast(r.y() / m_rasterSize); - uint x2 = static_cast(ceil(float(r.x() + r.width()) / float(m_rasterSize))); - uint y2 = static_cast(ceil(float(r.y() + r.height()) / float(m_rasterSize))); - - if (!m_raster.empty()) { - for ( ; x < x2; x++) { - for (uint i = y; i < y2; i++) { - if (x < m_raster.size()) { - if (i < m_raster.at(x).size()) { - Element* e = m_raster.at(x).at(i); - if (e && e->valid) { - e->valid = false; - m_queue.push_back(e); - } - } - } - } - } - } - } - - if (!m_busy) { - // If the timer is already started, this resets it. That way, we update always - // m_timeOutMSec milliseconds after the lastly monitored activity - m_timer.start(m_timeOutMSec, true); // true->singleshot - } -} - -void KisImageRasteredCache::imageSizeChanged(TQ_INT32 w, TQ_INT32 h) { - - KisImageSP image = m_view->canvasSubject()->currentImg(); - - cleanUpElements(); - m_busy = false; - - m_width = static_cast(ceil(float(w) / float(m_rasterSize))); - m_height = static_cast(ceil(float(h) / float(m_rasterSize))); - - m_raster.resize(m_width); - - int rasterX = 0; - - for (int i = 0; i < m_width * m_rasterSize; i += m_rasterSize) { - int rasterY = 0; - - m_raster.at(rasterX).resize(m_height + 1); - - for (int j = 0; j < m_height * m_rasterSize; j += m_rasterSize) { - Element* e = new Element(m_observer->createNew(i, j, m_rasterSize, m_rasterSize)); - m_raster.at(rasterX).at(rasterY) = e; - rasterY++; - } - rasterX++; - } - - imageUpdated(TQRect(0,0, image->width(), image->height())); -} - -void KisImageRasteredCache::timeOut() { - m_busy = true; - KisImageSP img = m_view->canvasSubject()->currentImg(); - - // Temporary cache: while we are busy, we won't get the mergeImage time and again. - if (!m_imageProjection) - m_imageProjection = img->mergedImage(); - - // Pick one element of the cache, and update it - if (!m_queue.isEmpty()) { - m_queue.front()->observer->regionUpdated(m_imageProjection); - m_queue.front()->valid = true; - m_queue.pop_front(); - } - - // If there are still elements, we need to be called again (this emulates processEvents) - if (!m_queue.isEmpty()) { - TQTimer::singleShot(0, this, TQT_SLOT(timeOut())); - } else { - emit cacheUpdated(); - m_imageProjection = 0; - m_busy = false; - } -} - -void KisImageRasteredCache::cleanUpElements() { - for (uint i = 0; i < m_raster.count(); i++) { - for (uint j = 0; j < m_raster.at(i).count(); j++) { - delete m_raster.at(i).at(j); - } - m_raster.at(i).clear(); - } - m_raster.clear(); - m_queue.clear(); -} - -#include "kis_imagerasteredcache.moc" diff --git a/chalk/plugins/viewplugins/histogram_docker/kis_imagerasteredcache.cpp b/chalk/plugins/viewplugins/histogram_docker/kis_imagerasteredcache.cpp new file mode 100644 index 00000000..19599cd9 --- /dev/null +++ b/chalk/plugins/viewplugins/histogram_docker/kis_imagerasteredcache.cpp @@ -0,0 +1,162 @@ +/* + * This file is part of the KDE project + * + * Copyright (c) 2005 Bart Coppens + * + * 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 + +#include + +#include + +#include +#include +#include +#include + +#include "kis_imagerasteredcache.h" + +KisImageRasteredCache::KisImageRasteredCache(KisView* view, Observer* o) + : m_observer(o->createNew(0, 0, 0, 0)), m_view(view) +{ + m_busy = false; + m_imageProjection = 0; + m_rasterSize = 64*4; + m_timeOutMSec = 1000; + + KisImageSP img = view->canvasSubject()->currentImg(); + + if (!img) { + return; + } + + imageSizeChanged(img->width(), img->height()); + + connect(img, TQT_SIGNAL(sigImageUpdated(TQRect)), + this, TQT_SLOT(imageUpdated(TQRect))); + connect(img, TQT_SIGNAL(sigSizeChanged(TQ_INT32, TQ_INT32)), + this, TQT_SLOT(imageSizeChanged(TQ_INT32, TQ_INT32))); + connect(&m_timer, TQT_SIGNAL(timeout()), this, TQT_SLOT(timeOut())); +} + +KisImageRasteredCache::~KisImageRasteredCache() { + cleanUpElements(); +} + +void KisImageRasteredCache::imageUpdated(TQRect rc) { + + if (rc.isValid()) { + TQRect r(0, 0, m_width * m_rasterSize, m_height * m_rasterSize); + r &= rc; + + uint x = static_cast(r.x() / m_rasterSize); + uint y = static_cast(r.y() / m_rasterSize); + uint x2 = static_cast(ceil(float(r.x() + r.width()) / float(m_rasterSize))); + uint y2 = static_cast(ceil(float(r.y() + r.height()) / float(m_rasterSize))); + + if (!m_raster.empty()) { + for ( ; x < x2; x++) { + for (uint i = y; i < y2; i++) { + if (x < m_raster.size()) { + if (i < m_raster.at(x).size()) { + Element* e = m_raster.at(x).at(i); + if (e && e->valid) { + e->valid = false; + m_queue.push_back(e); + } + } + } + } + } + } + } + + if (!m_busy) { + // If the timer is already started, this resets it. That way, we update always + // m_timeOutMSec milliseconds after the lastly monitored activity + m_timer.start(m_timeOutMSec, true); // true->singleshot + } +} + +void KisImageRasteredCache::imageSizeChanged(TQ_INT32 w, TQ_INT32 h) { + + KisImageSP image = m_view->canvasSubject()->currentImg(); + + cleanUpElements(); + m_busy = false; + + m_width = static_cast(ceil(float(w) / float(m_rasterSize))); + m_height = static_cast(ceil(float(h) / float(m_rasterSize))); + + m_raster.resize(m_width); + + int rasterX = 0; + + for (int i = 0; i < m_width * m_rasterSize; i += m_rasterSize) { + int rasterY = 0; + + m_raster.at(rasterX).resize(m_height + 1); + + for (int j = 0; j < m_height * m_rasterSize; j += m_rasterSize) { + Element* e = new Element(m_observer->createNew(i, j, m_rasterSize, m_rasterSize)); + m_raster.at(rasterX).at(rasterY) = e; + rasterY++; + } + rasterX++; + } + + imageUpdated(TQRect(0,0, image->width(), image->height())); +} + +void KisImageRasteredCache::timeOut() { + m_busy = true; + KisImageSP img = m_view->canvasSubject()->currentImg(); + + // Temporary cache: while we are busy, we won't get the mergeImage time and again. + if (!m_imageProjection) + m_imageProjection = img->mergedImage(); + + // Pick one element of the cache, and update it + if (!m_queue.isEmpty()) { + m_queue.front()->observer->regionUpdated(m_imageProjection); + m_queue.front()->valid = true; + m_queue.pop_front(); + } + + // If there are still elements, we need to be called again (this emulates processEvents) + if (!m_queue.isEmpty()) { + TQTimer::singleShot(0, this, TQT_SLOT(timeOut())); + } else { + emit cacheUpdated(); + m_imageProjection = 0; + m_busy = false; + } +} + +void KisImageRasteredCache::cleanUpElements() { + for (uint i = 0; i < m_raster.count(); i++) { + for (uint j = 0; j < m_raster.at(i).count(); j++) { + delete m_raster.at(i).at(j); + } + m_raster.at(i).clear(); + } + m_raster.clear(); + m_queue.clear(); +} + +#include "kis_imagerasteredcache.moc" diff --git a/chalk/plugins/viewplugins/history_docker/Makefile.am b/chalk/plugins/viewplugins/history_docker/Makefile.am index 53511b3d..c77357f2 100644 --- a/chalk/plugins/viewplugins/history_docker/Makefile.am +++ b/chalk/plugins/viewplugins/history_docker/Makefile.am @@ -7,7 +7,7 @@ INCLUDES = -I$(srcdir)/../../../sdk \ $(KOFFICE_INCLUDES) \ $(all_includes) -chalkhistorydocker_la_SOURCES = historydocker.cc +chalkhistorydocker_la_SOURCES = historydocker.cpp kde_module_LTLIBRARIES = chalkhistorydocker.la noinst_HEADERS = historydocker.h diff --git a/chalk/plugins/viewplugins/history_docker/historydocker.cc b/chalk/plugins/viewplugins/history_docker/historydocker.cc deleted file mode 100644 index 85e4df40..00000000 --- a/chalk/plugins/viewplugins/history_docker/historydocker.cc +++ /dev/null @@ -1,58 +0,0 @@ -/* - * This file is part of the KDE project - * - * Copyright (c) 2005 Boudewijn Rempt - * - * 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 -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "historydocker.h" - -typedef KGenericFactory ChalkHistoryDockerFactory; -K_EXPORT_COMPONENT_FACTORY( chalkhistorydocker, ChalkHistoryDockerFactory( "chalk" ) ) - -ChalkHistoryDocker::ChalkHistoryDocker(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - - - - if ( parent->inherits("KisView") ) - { - setInstance(ChalkHistoryDockerFactory::instance()); - // Create history docker - // Add the docker to the docker manager - // Connect the undo system to the docker - } - -} - -ChalkHistoryDocker::~ChalkHistoryDocker() -{ -} diff --git a/chalk/plugins/viewplugins/history_docker/historydocker.cpp b/chalk/plugins/viewplugins/history_docker/historydocker.cpp new file mode 100644 index 00000000..85e4df40 --- /dev/null +++ b/chalk/plugins/viewplugins/history_docker/historydocker.cpp @@ -0,0 +1,58 @@ +/* + * This file is part of the KDE project + * + * Copyright (c) 2005 Boudewijn Rempt + * + * 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 +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "historydocker.h" + +typedef KGenericFactory ChalkHistoryDockerFactory; +K_EXPORT_COMPONENT_FACTORY( chalkhistorydocker, ChalkHistoryDockerFactory( "chalk" ) ) + +ChalkHistoryDocker::ChalkHistoryDocker(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + + + + if ( parent->inherits("KisView") ) + { + setInstance(ChalkHistoryDockerFactory::instance()); + // Create history docker + // Add the docker to the docker manager + // Connect the undo system to the docker + } + +} + +ChalkHistoryDocker::~ChalkHistoryDocker() +{ +} diff --git a/chalk/plugins/viewplugins/imagesize/Makefile.am b/chalk/plugins/viewplugins/imagesize/Makefile.am index cea7a0e1..29ec8d09 100644 --- a/chalk/plugins/viewplugins/imagesize/Makefile.am +++ b/chalk/plugins/viewplugins/imagesize/Makefile.am @@ -12,7 +12,7 @@ INCLUDES = -I$(srcdir)/../../../sdk \ $(KOFFICE_INCLUDES) \ $(all_includes) -chalkimagesize_la_SOURCES = wdg_imagesize.ui wdg_layersize.ui imagesize.cc dlg_imagesize.cc dlg_layersize.cc wdg_resolution.ui +chalkimagesize_la_SOURCES = wdg_imagesize.ui wdg_layersize.ui imagesize.cpp dlg_imagesize.cpp dlg_layersize.cpp wdg_resolution.ui noinst_HEADERS = wdg_imagesize.h dlg_imagesize.h imagesize.h dlg_layersize.h diff --git a/chalk/plugins/viewplugins/imagesize/dlg_imagesize.cc b/chalk/plugins/viewplugins/imagesize/dlg_imagesize.cc deleted file mode 100644 index 8a9a8c09..00000000 --- a/chalk/plugins/viewplugins/imagesize/dlg_imagesize.cc +++ /dev/null @@ -1,277 +0,0 @@ -/* - * dlg_imagesize.cc - part of KimageShop^WKrayon^WChalk - * - * Copyright (c) 2004 Boudewijn Rempt - * - * 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 - -#include - -#include - -using namespace std; - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include "dlg_imagesize.h" -#include "wdg_imagesize.h" - - -// XXX: I'm really real bad at arithmetic, let alone math. Here -// be rounding errors. (Boudewijn) -DlgImageSize::DlgImageSize( TQWidget * parent, - const char * name) - : super (parent, name, true, i18n("Image Size"), Ok | Cancel, Ok) -{ - m_lock = false; - - m_page = new WdgImageSize(this, "image_size"); - TQ_CHECK_PTR(m_page); - - m_page->cmbFilterType->setIDList(KisFilterStrategyRegistry::instance()->listKeys()); - m_page->cmbFilterType->setCurrentText("Mitchell"); - - setMainWidget(m_page); - resize(m_page->sizeHint()); - - unblockAll(); - - - connect(this, TQT_SIGNAL(okClicked()), - this, TQT_SLOT(okClicked())); - -} - -DlgImageSize::~DlgImageSize() -{ - delete m_page; -} - -void DlgImageSize::hideScaleBox() -{ - m_page->grpResizeScale->hide(); -} - -void DlgImageSize::setWidth(TQ_UINT32 w) -{ - blockAll(); - - m_page->lblWidthOriginal->setNum((int)w); - m_page->intWidth->setValue(w); - m_oldW = w; - m_origW = w; - - unblockAll(); -} - -void DlgImageSize::setWidthPercent(TQ_UINT32 w) -{ - blockAll(); - - m_page->intWidthPercent->setValue(w); - m_oldWPercent = w; - - unblockAll(); -} - - -void DlgImageSize::setMaximumWidth(TQ_UINT32 w) -{ - m_page->intWidth->setMaxValue(w); - m_maxW = w; -} - -TQ_INT32 DlgImageSize::width() -{ - //return (TQ_INT32)tqRound(m_oldW); - return (TQ_INT32)tqRound(m_page->intWidth->value()); -} - -void DlgImageSize::setHeight(TQ_UINT32 h) -{ - blockAll(); - - m_page->lblHeightOriginal->setNum((int)h); - m_page->intHeight->setValue(h); - m_oldH = h; - m_origH = h; - - unblockAll(); -} - - -void DlgImageSize::setHeightPercent(TQ_UINT32 h) -{ - blockAll(); - - m_page->intHeightPercent->setValue(h); - m_oldHPercent = h; - - unblockAll(); -} - - - -void DlgImageSize::setMaximumHeight(TQ_UINT32 h) -{ - m_page->intHeight->setMaxValue(h); - m_maxH = h; -} - - -TQ_INT32 DlgImageSize::height() -{ - //return (TQ_INT32)tqRound(m_oldH); - return (TQ_INT32)tqRound(m_page->intHeight->value()); -} - -bool DlgImageSize::scale() -{ - return m_page->radioScale->isChecked(); -} - -bool DlgImageSize::cropLayers() -{ - return m_page->chkCrop->isChecked(); -} - -KisFilterStrategy *DlgImageSize::filterType() -{ - KisID filterID = m_page->cmbFilterType->currentItem(); - KisFilterStrategy *filter = KisFilterStrategyRegistry::instance()->get(filterID); - return filter; -} - -// SLOTS - -void DlgImageSize::okClicked() -{ - accept(); -} - -void DlgImageSize::slotWidthPixelsChanged(int w) -{ - blockAll(); - - double wPercent = double(w) * 100 / double(m_origW); - - m_page->intWidthPercent->setValue(tqRound(wPercent)); - - // Set height in pixels and percent of necessary - if (m_page->chkConstrain->isChecked()) { - m_page->intHeightPercent->setValue(tqRound(wPercent)); - - m_oldH = tqRound(m_origH * wPercent / 100); - m_page->intHeight->setValue(tqRound(m_oldH)); - - } - m_oldW = w; - - unblockAll(); -} - -void DlgImageSize::slotHeightPixelsChanged(int h) -{ - blockAll(); - - double hPercent = double(h) * 100 / double(m_origH); - - m_page->intHeightPercent->setValue(tqRound(hPercent)); - - // Set width in pixels and percent of necessary - if (m_page->chkConstrain->isChecked()) { - m_page->intWidthPercent->setValue(tqRound(hPercent)); - - m_oldW = tqRound(m_origW * hPercent / 100); - m_page->intWidth->setValue(tqRound(m_oldW)); - - } - m_oldH = h; - - unblockAll(); -} - -void DlgImageSize::slotWidthPercentChanged(int w) -{ - blockAll(); - - m_page->intWidth->setValue(tqRound(w * m_origW / 100)); - - if (m_page->chkConstrain->isChecked()) { - m_page->intHeightPercent->setValue(w); - m_page->intHeight->setValue(tqRound( w * m_origH / 100)); - } - - unblockAll(); -} - -void DlgImageSize::slotHeightPercentChanged(int h) -{ - blockAll(); - - m_page->intHeight->setValue(tqRound(h * m_origH / 100)); - if (m_page->chkConstrain->isChecked()) { - m_page->intWidthPercent->setValue(h); - m_page->intWidth->setValue(tqRound( h * m_origW / 100)); - } - - unblockAll(); - -} - - -void DlgImageSize::blockAll() -{ - // XXX: more efficient to use blockSignals? - m_page->intWidth->disconnect(); - m_page->intHeight->disconnect(); - m_page->intWidthPercent->disconnect(); - m_page->intHeightPercent->disconnect(); - -} - -void DlgImageSize::unblockAll() -{ - // XXX: more efficient to use blockSignals? - connect (m_page->intWidth, TQT_SIGNAL(valueChanged(int)), - this, TQT_SLOT(slotWidthPixelsChanged(int))); - - connect (m_page->intHeight, TQT_SIGNAL(valueChanged(int)), - this, TQT_SLOT(slotHeightPixelsChanged(int))); - - connect (m_page->intWidthPercent, TQT_SIGNAL(valueChanged(int)), - this, TQT_SLOT(slotWidthPercentChanged(int))); - - connect (m_page->intHeightPercent, TQT_SIGNAL(valueChanged(int)), - this, TQT_SLOT(slotHeightPercentChanged(int))); - - -} - -#include "dlg_imagesize.moc" diff --git a/chalk/plugins/viewplugins/imagesize/dlg_imagesize.cpp b/chalk/plugins/viewplugins/imagesize/dlg_imagesize.cpp new file mode 100644 index 00000000..c455af8c --- /dev/null +++ b/chalk/plugins/viewplugins/imagesize/dlg_imagesize.cpp @@ -0,0 +1,277 @@ +/* + * dlg_imagesize.cpp - part of KimageShop^WKrayon^WChalk + * + * Copyright (c) 2004 Boudewijn Rempt + * + * 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 + +#include + +#include + +using namespace std; + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include "dlg_imagesize.h" +#include "wdg_imagesize.h" + + +// XXX: I'm really real bad at arithmetic, let alone math. Here +// be rounding errors. (Boudewijn) +DlgImageSize::DlgImageSize( TQWidget * parent, + const char * name) + : super (parent, name, true, i18n("Image Size"), Ok | Cancel, Ok) +{ + m_lock = false; + + m_page = new WdgImageSize(this, "image_size"); + TQ_CHECK_PTR(m_page); + + m_page->cmbFilterType->setIDList(KisFilterStrategyRegistry::instance()->listKeys()); + m_page->cmbFilterType->setCurrentText("Mitchell"); + + setMainWidget(m_page); + resize(m_page->sizeHint()); + + unblockAll(); + + + connect(this, TQT_SIGNAL(okClicked()), + this, TQT_SLOT(okClicked())); + +} + +DlgImageSize::~DlgImageSize() +{ + delete m_page; +} + +void DlgImageSize::hideScaleBox() +{ + m_page->grpResizeScale->hide(); +} + +void DlgImageSize::setWidth(TQ_UINT32 w) +{ + blockAll(); + + m_page->lblWidthOriginal->setNum((int)w); + m_page->intWidth->setValue(w); + m_oldW = w; + m_origW = w; + + unblockAll(); +} + +void DlgImageSize::setWidthPercent(TQ_UINT32 w) +{ + blockAll(); + + m_page->intWidthPercent->setValue(w); + m_oldWPercent = w; + + unblockAll(); +} + + +void DlgImageSize::setMaximumWidth(TQ_UINT32 w) +{ + m_page->intWidth->setMaxValue(w); + m_maxW = w; +} + +TQ_INT32 DlgImageSize::width() +{ + //return (TQ_INT32)tqRound(m_oldW); + return (TQ_INT32)tqRound(m_page->intWidth->value()); +} + +void DlgImageSize::setHeight(TQ_UINT32 h) +{ + blockAll(); + + m_page->lblHeightOriginal->setNum((int)h); + m_page->intHeight->setValue(h); + m_oldH = h; + m_origH = h; + + unblockAll(); +} + + +void DlgImageSize::setHeightPercent(TQ_UINT32 h) +{ + blockAll(); + + m_page->intHeightPercent->setValue(h); + m_oldHPercent = h; + + unblockAll(); +} + + + +void DlgImageSize::setMaximumHeight(TQ_UINT32 h) +{ + m_page->intHeight->setMaxValue(h); + m_maxH = h; +} + + +TQ_INT32 DlgImageSize::height() +{ + //return (TQ_INT32)tqRound(m_oldH); + return (TQ_INT32)tqRound(m_page->intHeight->value()); +} + +bool DlgImageSize::scale() +{ + return m_page->radioScale->isChecked(); +} + +bool DlgImageSize::cropLayers() +{ + return m_page->chkCrop->isChecked(); +} + +KisFilterStrategy *DlgImageSize::filterType() +{ + KisID filterID = m_page->cmbFilterType->currentItem(); + KisFilterStrategy *filter = KisFilterStrategyRegistry::instance()->get(filterID); + return filter; +} + +// SLOTS + +void DlgImageSize::okClicked() +{ + accept(); +} + +void DlgImageSize::slotWidthPixelsChanged(int w) +{ + blockAll(); + + double wPercent = double(w) * 100 / double(m_origW); + + m_page->intWidthPercent->setValue(tqRound(wPercent)); + + // Set height in pixels and percent of necessary + if (m_page->chkConstrain->isChecked()) { + m_page->intHeightPercent->setValue(tqRound(wPercent)); + + m_oldH = tqRound(m_origH * wPercent / 100); + m_page->intHeight->setValue(tqRound(m_oldH)); + + } + m_oldW = w; + + unblockAll(); +} + +void DlgImageSize::slotHeightPixelsChanged(int h) +{ + blockAll(); + + double hPercent = double(h) * 100 / double(m_origH); + + m_page->intHeightPercent->setValue(tqRound(hPercent)); + + // Set width in pixels and percent of necessary + if (m_page->chkConstrain->isChecked()) { + m_page->intWidthPercent->setValue(tqRound(hPercent)); + + m_oldW = tqRound(m_origW * hPercent / 100); + m_page->intWidth->setValue(tqRound(m_oldW)); + + } + m_oldH = h; + + unblockAll(); +} + +void DlgImageSize::slotWidthPercentChanged(int w) +{ + blockAll(); + + m_page->intWidth->setValue(tqRound(w * m_origW / 100)); + + if (m_page->chkConstrain->isChecked()) { + m_page->intHeightPercent->setValue(w); + m_page->intHeight->setValue(tqRound( w * m_origH / 100)); + } + + unblockAll(); +} + +void DlgImageSize::slotHeightPercentChanged(int h) +{ + blockAll(); + + m_page->intHeight->setValue(tqRound(h * m_origH / 100)); + if (m_page->chkConstrain->isChecked()) { + m_page->intWidthPercent->setValue(h); + m_page->intWidth->setValue(tqRound( h * m_origW / 100)); + } + + unblockAll(); + +} + + +void DlgImageSize::blockAll() +{ + // XXX: more efficient to use blockSignals? + m_page->intWidth->disconnect(); + m_page->intHeight->disconnect(); + m_page->intWidthPercent->disconnect(); + m_page->intHeightPercent->disconnect(); + +} + +void DlgImageSize::unblockAll() +{ + // XXX: more efficient to use blockSignals? + connect (m_page->intWidth, TQT_SIGNAL(valueChanged(int)), + this, TQT_SLOT(slotWidthPixelsChanged(int))); + + connect (m_page->intHeight, TQT_SIGNAL(valueChanged(int)), + this, TQT_SLOT(slotHeightPixelsChanged(int))); + + connect (m_page->intWidthPercent, TQT_SIGNAL(valueChanged(int)), + this, TQT_SLOT(slotWidthPercentChanged(int))); + + connect (m_page->intHeightPercent, TQT_SIGNAL(valueChanged(int)), + this, TQT_SLOT(slotHeightPercentChanged(int))); + + +} + +#include "dlg_imagesize.moc" diff --git a/chalk/plugins/viewplugins/imagesize/dlg_layersize.cc b/chalk/plugins/viewplugins/imagesize/dlg_layersize.cc deleted file mode 100644 index 1d30db6a..00000000 --- a/chalk/plugins/viewplugins/imagesize/dlg_layersize.cc +++ /dev/null @@ -1,261 +0,0 @@ -/* - * dlg_layersize.cc - part of Chalk - * - * Copyright (c) 2004 Boudewijn Rempt - * Copyright (c) 2005 Sven Langkamp - * - * 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 - -#include - -#include - -using namespace std; - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include "dlg_layersize.h" -#include "wdg_layersize.h" - - -// XXX: I'm really real bad at arithmetic, let alone math. Here -// be rounding errors. (Boudewijn) -DlgLayerSize::DlgLayerSize( TQWidget * parent, - const char * name) - : super (parent, name, true, i18n("Scale Layer"), Ok | Cancel, Ok) -{ - m_lock = false; - - m_page = new WdgLayerSize(this, "layer_size"); - TQ_CHECK_PTR(m_page); - - m_page->cmbFilterType->setIDList(KisFilterStrategyRegistry::instance()->listKeys()); - m_page->cmbFilterType->setCurrentText("Mitchell"); - - setMainWidget(m_page); - resize(m_page->sizeHint()); - - unblockAll(); - - - connect(this, TQT_SIGNAL(okClicked()), - this, TQT_SLOT(okClicked())); - -} - -DlgLayerSize::~DlgLayerSize() -{ - delete m_page; -} - -void DlgLayerSize::setWidth(TQ_UINT32 w) -{ - blockAll(); - - m_page->lblWidthOriginal->setNum((int)w); - m_page->intWidth->setValue(w); - m_oldW = w; - m_origW = w; - - unblockAll(); -} - -void DlgLayerSize::setWidthPercent(TQ_UINT32 w) -{ - blockAll(); - - m_page->intWidthPercent->setValue(w); - m_oldWPercent = w; - - unblockAll(); -} - - -void DlgLayerSize::setMaximumWidth(TQ_UINT32 w) -{ - m_page->intWidth->setMaxValue(w); - m_maxW = w; -} - -TQ_INT32 DlgLayerSize::width() -{ - //return (TQ_INT32)tqRound(m_oldW); - return (TQ_INT32)tqRound(m_page->intWidth->value()); -} - -void DlgLayerSize::setHeight(TQ_UINT32 h) -{ - blockAll(); - - m_page->lblHeightOriginal->setNum((int)h); - m_page->intHeight->setValue(h); - m_oldH = h; - m_origH = h; - - unblockAll(); -} - - -void DlgLayerSize::setHeightPercent(TQ_UINT32 h) -{ - blockAll(); - - m_page->intHeightPercent->setValue(h); - m_oldHPercent = h; - - unblockAll(); -} - -void DlgLayerSize::setMaximumHeight(TQ_UINT32 h) -{ - m_page->intHeight->setMaxValue(h); - m_maxH = h; -} - -TQ_INT32 DlgLayerSize::height() -{ - //return (TQ_INT32)tqRound(m_oldH); - return (TQ_INT32)tqRound(m_page->intHeight->value()); -} - -KisFilterStrategy *DlgLayerSize::filterType() -{ - KisID filterID = m_page->cmbFilterType->currentItem(); - KisFilterStrategy *filter = KisFilterStrategyRegistry::instance()->get(filterID); - return filter; -} - - -// SLOTS - -void DlgLayerSize::okClicked() -{ - accept(); -} - -void DlgLayerSize::slotWidthPixelsChanged(int w) -{ - blockAll(); - - double wPercent = double(w) * 100 / double(m_origW); - - m_page->intWidthPercent->setValue(tqRound(wPercent)); - - // Set height in pixels and percent of necessary - if (m_page->chkConstrain->isChecked()) { - m_page->intHeightPercent->setValue(tqRound(wPercent)); - - m_oldH = tqRound(m_origH * wPercent / 100); - m_page->intHeight->setValue(tqRound(m_oldH)); - - } - m_oldW = w; - - unblockAll(); -} - -void DlgLayerSize::slotHeightPixelsChanged(int h) -{ - blockAll(); - - double hPercent = double(h) * 100 / double(m_origH); - - m_page->intHeightPercent->setValue(tqRound(hPercent)); - - // Set width in pixels and percent of necessary - if (m_page->chkConstrain->isChecked()) { - m_page->intWidthPercent->setValue(tqRound(hPercent)); - - m_oldW = tqRound(m_origW * hPercent / 100); - m_page->intWidth->setValue(tqRound(m_oldW)); - - } - m_oldH = h; - - unblockAll(); -} - -void DlgLayerSize::slotWidthPercentChanged(int w) -{ - blockAll(); - - m_page->intWidth->setValue(tqRound(w * m_origW / 100)); - - if (m_page->chkConstrain->isChecked()) { - m_page->intHeightPercent->setValue(w); - m_page->intHeight->setValue(tqRound( w * m_origH / 100)); - } - - unblockAll(); -} - -void DlgLayerSize::slotHeightPercentChanged(int h) -{ - blockAll(); - - m_page->intHeight->setValue(tqRound(h * m_origH / 100)); - if (m_page->chkConstrain->isChecked()) { - m_page->intWidthPercent->setValue(h); - m_page->intWidth->setValue(tqRound( h * m_origW / 100)); - } - - unblockAll(); - -} - - -void DlgLayerSize::blockAll() -{ - // XXX: more efficient to use blockSignals? - m_page->intWidth->disconnect(); - m_page->intHeight->disconnect(); - m_page->intWidthPercent->disconnect(); - m_page->intHeightPercent->disconnect(); - -} - -void DlgLayerSize::unblockAll() -{ - // XXX: more efficient to use blockSignals? - connect (m_page->intWidth, TQT_SIGNAL(valueChanged(int)), - this, TQT_SLOT(slotWidthPixelsChanged(int))); - - connect (m_page->intHeight, TQT_SIGNAL(valueChanged(int)), - this, TQT_SLOT(slotHeightPixelsChanged(int))); - - connect (m_page->intWidthPercent, TQT_SIGNAL(valueChanged(int)), - this, TQT_SLOT(slotWidthPercentChanged(int))); - - connect (m_page->intHeightPercent, TQT_SIGNAL(valueChanged(int)), - this, TQT_SLOT(slotHeightPercentChanged(int))); - - -} - -#include "dlg_layersize.moc" diff --git a/chalk/plugins/viewplugins/imagesize/dlg_layersize.cpp b/chalk/plugins/viewplugins/imagesize/dlg_layersize.cpp new file mode 100644 index 00000000..77979805 --- /dev/null +++ b/chalk/plugins/viewplugins/imagesize/dlg_layersize.cpp @@ -0,0 +1,261 @@ +/* + * dlg_layersize.cpp - part of Chalk + * + * Copyright (c) 2004 Boudewijn Rempt + * Copyright (c) 2005 Sven Langkamp + * + * 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 + +#include + +#include + +using namespace std; + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include "dlg_layersize.h" +#include "wdg_layersize.h" + + +// XXX: I'm really real bad at arithmetic, let alone math. Here +// be rounding errors. (Boudewijn) +DlgLayerSize::DlgLayerSize( TQWidget * parent, + const char * name) + : super (parent, name, true, i18n("Scale Layer"), Ok | Cancel, Ok) +{ + m_lock = false; + + m_page = new WdgLayerSize(this, "layer_size"); + TQ_CHECK_PTR(m_page); + + m_page->cmbFilterType->setIDList(KisFilterStrategyRegistry::instance()->listKeys()); + m_page->cmbFilterType->setCurrentText("Mitchell"); + + setMainWidget(m_page); + resize(m_page->sizeHint()); + + unblockAll(); + + + connect(this, TQT_SIGNAL(okClicked()), + this, TQT_SLOT(okClicked())); + +} + +DlgLayerSize::~DlgLayerSize() +{ + delete m_page; +} + +void DlgLayerSize::setWidth(TQ_UINT32 w) +{ + blockAll(); + + m_page->lblWidthOriginal->setNum((int)w); + m_page->intWidth->setValue(w); + m_oldW = w; + m_origW = w; + + unblockAll(); +} + +void DlgLayerSize::setWidthPercent(TQ_UINT32 w) +{ + blockAll(); + + m_page->intWidthPercent->setValue(w); + m_oldWPercent = w; + + unblockAll(); +} + + +void DlgLayerSize::setMaximumWidth(TQ_UINT32 w) +{ + m_page->intWidth->setMaxValue(w); + m_maxW = w; +} + +TQ_INT32 DlgLayerSize::width() +{ + //return (TQ_INT32)tqRound(m_oldW); + return (TQ_INT32)tqRound(m_page->intWidth->value()); +} + +void DlgLayerSize::setHeight(TQ_UINT32 h) +{ + blockAll(); + + m_page->lblHeightOriginal->setNum((int)h); + m_page->intHeight->setValue(h); + m_oldH = h; + m_origH = h; + + unblockAll(); +} + + +void DlgLayerSize::setHeightPercent(TQ_UINT32 h) +{ + blockAll(); + + m_page->intHeightPercent->setValue(h); + m_oldHPercent = h; + + unblockAll(); +} + +void DlgLayerSize::setMaximumHeight(TQ_UINT32 h) +{ + m_page->intHeight->setMaxValue(h); + m_maxH = h; +} + +TQ_INT32 DlgLayerSize::height() +{ + //return (TQ_INT32)tqRound(m_oldH); + return (TQ_INT32)tqRound(m_page->intHeight->value()); +} + +KisFilterStrategy *DlgLayerSize::filterType() +{ + KisID filterID = m_page->cmbFilterType->currentItem(); + KisFilterStrategy *filter = KisFilterStrategyRegistry::instance()->get(filterID); + return filter; +} + + +// SLOTS + +void DlgLayerSize::okClicked() +{ + accept(); +} + +void DlgLayerSize::slotWidthPixelsChanged(int w) +{ + blockAll(); + + double wPercent = double(w) * 100 / double(m_origW); + + m_page->intWidthPercent->setValue(tqRound(wPercent)); + + // Set height in pixels and percent of necessary + if (m_page->chkConstrain->isChecked()) { + m_page->intHeightPercent->setValue(tqRound(wPercent)); + + m_oldH = tqRound(m_origH * wPercent / 100); + m_page->intHeight->setValue(tqRound(m_oldH)); + + } + m_oldW = w; + + unblockAll(); +} + +void DlgLayerSize::slotHeightPixelsChanged(int h) +{ + blockAll(); + + double hPercent = double(h) * 100 / double(m_origH); + + m_page->intHeightPercent->setValue(tqRound(hPercent)); + + // Set width in pixels and percent of necessary + if (m_page->chkConstrain->isChecked()) { + m_page->intWidthPercent->setValue(tqRound(hPercent)); + + m_oldW = tqRound(m_origW * hPercent / 100); + m_page->intWidth->setValue(tqRound(m_oldW)); + + } + m_oldH = h; + + unblockAll(); +} + +void DlgLayerSize::slotWidthPercentChanged(int w) +{ + blockAll(); + + m_page->intWidth->setValue(tqRound(w * m_origW / 100)); + + if (m_page->chkConstrain->isChecked()) { + m_page->intHeightPercent->setValue(w); + m_page->intHeight->setValue(tqRound( w * m_origH / 100)); + } + + unblockAll(); +} + +void DlgLayerSize::slotHeightPercentChanged(int h) +{ + blockAll(); + + m_page->intHeight->setValue(tqRound(h * m_origH / 100)); + if (m_page->chkConstrain->isChecked()) { + m_page->intWidthPercent->setValue(h); + m_page->intWidth->setValue(tqRound( h * m_origW / 100)); + } + + unblockAll(); + +} + + +void DlgLayerSize::blockAll() +{ + // XXX: more efficient to use blockSignals? + m_page->intWidth->disconnect(); + m_page->intHeight->disconnect(); + m_page->intWidthPercent->disconnect(); + m_page->intHeightPercent->disconnect(); + +} + +void DlgLayerSize::unblockAll() +{ + // XXX: more efficient to use blockSignals? + connect (m_page->intWidth, TQT_SIGNAL(valueChanged(int)), + this, TQT_SLOT(slotWidthPixelsChanged(int))); + + connect (m_page->intHeight, TQT_SIGNAL(valueChanged(int)), + this, TQT_SLOT(slotHeightPixelsChanged(int))); + + connect (m_page->intWidthPercent, TQT_SIGNAL(valueChanged(int)), + this, TQT_SLOT(slotWidthPercentChanged(int))); + + connect (m_page->intHeightPercent, TQT_SIGNAL(valueChanged(int)), + this, TQT_SLOT(slotHeightPercentChanged(int))); + + +} + +#include "dlg_layersize.moc" diff --git a/chalk/plugins/viewplugins/imagesize/imagesize.cc b/chalk/plugins/viewplugins/imagesize/imagesize.cc deleted file mode 100644 index c795924e..00000000 --- a/chalk/plugins/viewplugins/imagesize/imagesize.cc +++ /dev/null @@ -1,190 +0,0 @@ -/* - * imagesize.cc -- Part of Chalk - * - * Copyright (c) 2004 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 - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "imagesize.h" -#include "dlg_imagesize.h" -#include "dlg_layersize.h" -#include "kis_filter_strategy.h" - -typedef KGenericFactory ImageSizeFactory; -K_EXPORT_COMPONENT_FACTORY( chalkimagesize, ImageSizeFactory( "chalk" ) ) - -ImageSize::ImageSize(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - if ( parent->inherits("KisView") ) - { - setInstance(ImageSizeFactory::instance()); - setXMLFile(locate("data","chalkplugins/imagesize.rc"), true); - - (void) new TDEAction(i18n("Change &Image Size..."), 0, "Shift-s", this, TQT_SLOT(slotImageSize()), actionCollection(), "imagesize"); - (void) new TDEAction(i18n("&Scale Layer..."), 0, 0, this, TQT_SLOT(slotLayerSize()), actionCollection(), "layerscale"); - - - m_view = (KisView*) parent; - // Selection manager takes ownership? - TDEAction * a = new TDEAction(i18n("&Scale Selection..."), 0, 0, this, TQT_SLOT(slotSelectionScale()), actionCollection(), "selectionscale"); - TQ_CHECK_PTR(a); - m_view ->canvasSubject()-> selectionManager()->addSelectionAction(a); - } -} - -ImageSize::~ImageSize() -{ - m_view = 0; -} - -void ImageSize::slotImageSize() -{ - KisImageSP image = m_view->canvasSubject()->currentImg(); - - if (!image) return; - - DlgImageSize * dlgImageSize = new DlgImageSize(m_view, "ImageSize"); - TQ_CHECK_PTR(dlgImageSize); - - dlgImageSize->setCaption(i18n("Image Size")); - - KisConfig cfg; - - dlgImageSize->setWidth(image->width()); - dlgImageSize->setHeight(image->height()); - - if (dlgImageSize->exec() == TQDialog::Accepted) { - TQ_INT32 w = dlgImageSize->width(); - TQ_INT32 h = dlgImageSize->height(); - - if (dlgImageSize->scale()) { - m_view->scaleCurrentImage((double)w / ((double)(image->width())), - (double)h / ((double)(image->height())), - dlgImageSize->filterType()); - } - else { - m_view->resizeCurrentImage(w, h, dlgImageSize->cropLayers()); - } - } - - delete dlgImageSize; -} - -void ImageSize::slotLayerSize() -{ - KisImageSP image = m_view->canvasSubject()->currentImg(); - - if (!image) return; - - DlgLayerSize * dlgLayerSize = new DlgLayerSize(m_view, "LayerSize"); - TQ_CHECK_PTR(dlgLayerSize); - - dlgLayerSize->setCaption(i18n("Layer Size")); - - KisConfig cfg; - KisPaintDeviceSP dev = image->activeDevice(); - - TQRect rc = dev->exactBounds(); - - dlgLayerSize->setWidth(rc.width()); - dlgLayerSize->setHeight(rc.height()); - - if (dlgLayerSize->exec() == TQDialog::Accepted) { - TQ_INT32 w = dlgLayerSize->width(); - TQ_INT32 h = dlgLayerSize->height(); - - m_view->scaleLayer((double)w / ((double)(rc.width())), - (double)h / ((double)(rc.height())), - dlgLayerSize->filterType()); - } - delete dlgLayerSize; -} - -void ImageSize::slotSelectionScale() -{ - KisImageSP image = m_view->canvasSubject()->currentImg(); - - if (!image) return; - - KisPaintDeviceSP layer = image->activeDevice(); - - if (!layer) return; - - if (!layer->hasSelection()) return; - - - DlgLayerSize * dlgLayerSize = new DlgLayerSize(m_view, "SelectionScale"); - TQ_CHECK_PTR(dlgLayerSize); - - dlgLayerSize->setCaption(i18n("Scale Selection")); - - KisConfig cfg; - TQRect rc = layer->selection()->selectedRect(); - - dlgLayerSize->setWidth(rc.width()); - dlgLayerSize->setHeight(rc.height()); - - if (dlgLayerSize->exec() == TQDialog::Accepted) { - TQ_INT32 w = dlgLayerSize->width(); - TQ_INT32 h = dlgLayerSize->height(); - - KisScaleWorker worker (layer->selection().data(), - (double)w / ((double)(rc.width())), - (double)h / ((double)(rc.height())), - dlgLayerSize->filterType()); - worker.run(); - - m_view->getCanvasController()->updateCanvas(); - - } - delete dlgLayerSize; -} - - -#include "imagesize.moc" diff --git a/chalk/plugins/viewplugins/imagesize/imagesize.cpp b/chalk/plugins/viewplugins/imagesize/imagesize.cpp new file mode 100644 index 00000000..af9c2570 --- /dev/null +++ b/chalk/plugins/viewplugins/imagesize/imagesize.cpp @@ -0,0 +1,190 @@ +/* + * imagesize.cpp -- Part of Chalk + * + * Copyright (c) 2004 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 + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "imagesize.h" +#include "dlg_imagesize.h" +#include "dlg_layersize.h" +#include "kis_filter_strategy.h" + +typedef KGenericFactory ImageSizeFactory; +K_EXPORT_COMPONENT_FACTORY( chalkimagesize, ImageSizeFactory( "chalk" ) ) + +ImageSize::ImageSize(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + if ( parent->inherits("KisView") ) + { + setInstance(ImageSizeFactory::instance()); + setXMLFile(locate("data","chalkplugins/imagesize.rc"), true); + + (void) new TDEAction(i18n("Change &Image Size..."), 0, "Shift-s", this, TQT_SLOT(slotImageSize()), actionCollection(), "imagesize"); + (void) new TDEAction(i18n("&Scale Layer..."), 0, 0, this, TQT_SLOT(slotLayerSize()), actionCollection(), "layerscale"); + + + m_view = (KisView*) parent; + // Selection manager takes ownership? + TDEAction * a = new TDEAction(i18n("&Scale Selection..."), 0, 0, this, TQT_SLOT(slotSelectionScale()), actionCollection(), "selectionscale"); + TQ_CHECK_PTR(a); + m_view ->canvasSubject()-> selectionManager()->addSelectionAction(a); + } +} + +ImageSize::~ImageSize() +{ + m_view = 0; +} + +void ImageSize::slotImageSize() +{ + KisImageSP image = m_view->canvasSubject()->currentImg(); + + if (!image) return; + + DlgImageSize * dlgImageSize = new DlgImageSize(m_view, "ImageSize"); + TQ_CHECK_PTR(dlgImageSize); + + dlgImageSize->setCaption(i18n("Image Size")); + + KisConfig cfg; + + dlgImageSize->setWidth(image->width()); + dlgImageSize->setHeight(image->height()); + + if (dlgImageSize->exec() == TQDialog::Accepted) { + TQ_INT32 w = dlgImageSize->width(); + TQ_INT32 h = dlgImageSize->height(); + + if (dlgImageSize->scale()) { + m_view->scaleCurrentImage((double)w / ((double)(image->width())), + (double)h / ((double)(image->height())), + dlgImageSize->filterType()); + } + else { + m_view->resizeCurrentImage(w, h, dlgImageSize->cropLayers()); + } + } + + delete dlgImageSize; +} + +void ImageSize::slotLayerSize() +{ + KisImageSP image = m_view->canvasSubject()->currentImg(); + + if (!image) return; + + DlgLayerSize * dlgLayerSize = new DlgLayerSize(m_view, "LayerSize"); + TQ_CHECK_PTR(dlgLayerSize); + + dlgLayerSize->setCaption(i18n("Layer Size")); + + KisConfig cfg; + KisPaintDeviceSP dev = image->activeDevice(); + + TQRect rc = dev->exactBounds(); + + dlgLayerSize->setWidth(rc.width()); + dlgLayerSize->setHeight(rc.height()); + + if (dlgLayerSize->exec() == TQDialog::Accepted) { + TQ_INT32 w = dlgLayerSize->width(); + TQ_INT32 h = dlgLayerSize->height(); + + m_view->scaleLayer((double)w / ((double)(rc.width())), + (double)h / ((double)(rc.height())), + dlgLayerSize->filterType()); + } + delete dlgLayerSize; +} + +void ImageSize::slotSelectionScale() +{ + KisImageSP image = m_view->canvasSubject()->currentImg(); + + if (!image) return; + + KisPaintDeviceSP layer = image->activeDevice(); + + if (!layer) return; + + if (!layer->hasSelection()) return; + + + DlgLayerSize * dlgLayerSize = new DlgLayerSize(m_view, "SelectionScale"); + TQ_CHECK_PTR(dlgLayerSize); + + dlgLayerSize->setCaption(i18n("Scale Selection")); + + KisConfig cfg; + TQRect rc = layer->selection()->selectedRect(); + + dlgLayerSize->setWidth(rc.width()); + dlgLayerSize->setHeight(rc.height()); + + if (dlgLayerSize->exec() == TQDialog::Accepted) { + TQ_INT32 w = dlgLayerSize->width(); + TQ_INT32 h = dlgLayerSize->height(); + + KisScaleWorker worker (layer->selection().data(), + (double)w / ((double)(rc.width())), + (double)h / ((double)(rc.height())), + dlgLayerSize->filterType()); + worker.run(); + + m_view->getCanvasController()->updateCanvas(); + + } + delete dlgLayerSize; +} + + +#include "imagesize.moc" diff --git a/chalk/plugins/viewplugins/modify_selection/Makefile.am b/chalk/plugins/viewplugins/modify_selection/Makefile.am index 5b374888..89f6e633 100644 --- a/chalk/plugins/viewplugins/modify_selection/Makefile.am +++ b/chalk/plugins/viewplugins/modify_selection/Makefile.am @@ -13,7 +13,7 @@ INCLUDES = -I$(srcdir)/../../../sdk \ $(all_includes) chalkmodifyselection_la_SOURCES = wdg_grow_selection.ui wdg_shrink_selection.ui wdg_border_selection.ui \ -dlg_grow_selection.cc dlg_shrink_selection.cc dlg_border_selection.cc modify_selection.cc +dlg_grow_selection.cpp dlg_shrink_selection.cpp dlg_border_selection.cpp modify_selection.cpp noinst_HEADERS = wdg_grow_selection.h wdg_shrink_selection.h wdg_border_selection.h dlg_grow_selection.h \ dlg_shrink_selection.h dlg_border_selection.h modify_selection.h diff --git a/chalk/plugins/viewplugins/modify_selection/dlg_border_selection.cc b/chalk/plugins/viewplugins/modify_selection/dlg_border_selection.cc deleted file mode 100644 index 7cd1c335..00000000 --- a/chalk/plugins/viewplugins/modify_selection/dlg_border_selection.cc +++ /dev/null @@ -1,76 +0,0 @@ -/* - * dlg_border_selection.cc - part of Chalk - * - * Copyright (c) 2006 Michael Thaler - * - * 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 - -#include - -#include - -using namespace std; - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "dlg_border_selection.h" -#include "wdg_border_selection.h" - -DlgBorderSelection::DlgBorderSelection( TQWidget * parent, const char * name) : super (parent, name, true, i18n("Border Selection"), Ok | Cancel, Ok) -{ - m_page = new WdgBorderSelection(this, "border_selection"); - TQ_CHECK_PTR(m_page); - - setMainWidget(m_page); - resize(m_page->sizeHint()); - - connect(this, TQT_SIGNAL(okClicked()), this, TQT_SLOT(okClicked())); -} - -DlgBorderSelection::~DlgBorderSelection() -{ - delete m_page; -} - -TQ_INT32 DlgBorderSelection::xradius() -{ - return m_page->radiusSpinBox->value(); -} - -TQ_INT32 DlgBorderSelection::yradius() -{ - return m_page->radiusSpinBox->value(); -} - - -// SLOTS - -void DlgBorderSelection::okClicked() -{ - accept(); -} - -#include "dlg_border_selection.moc" diff --git a/chalk/plugins/viewplugins/modify_selection/dlg_border_selection.cpp b/chalk/plugins/viewplugins/modify_selection/dlg_border_selection.cpp new file mode 100644 index 00000000..8e2bc4de --- /dev/null +++ b/chalk/plugins/viewplugins/modify_selection/dlg_border_selection.cpp @@ -0,0 +1,76 @@ +/* + * dlg_border_selection.cpp - part of Chalk + * + * Copyright (c) 2006 Michael Thaler + * + * 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 + +#include + +#include + +using namespace std; + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "dlg_border_selection.h" +#include "wdg_border_selection.h" + +DlgBorderSelection::DlgBorderSelection( TQWidget * parent, const char * name) : super (parent, name, true, i18n("Border Selection"), Ok | Cancel, Ok) +{ + m_page = new WdgBorderSelection(this, "border_selection"); + TQ_CHECK_PTR(m_page); + + setMainWidget(m_page); + resize(m_page->sizeHint()); + + connect(this, TQT_SIGNAL(okClicked()), this, TQT_SLOT(okClicked())); +} + +DlgBorderSelection::~DlgBorderSelection() +{ + delete m_page; +} + +TQ_INT32 DlgBorderSelection::xradius() +{ + return m_page->radiusSpinBox->value(); +} + +TQ_INT32 DlgBorderSelection::yradius() +{ + return m_page->radiusSpinBox->value(); +} + + +// SLOTS + +void DlgBorderSelection::okClicked() +{ + accept(); +} + +#include "dlg_border_selection.moc" diff --git a/chalk/plugins/viewplugins/modify_selection/dlg_grow_selection.cc b/chalk/plugins/viewplugins/modify_selection/dlg_grow_selection.cc deleted file mode 100644 index 38c445b0..00000000 --- a/chalk/plugins/viewplugins/modify_selection/dlg_grow_selection.cc +++ /dev/null @@ -1,76 +0,0 @@ -/* - * dlg_grow_selection.cc - part of Chalk - * - * Copyright (c) 2006 Michael Thaler - * - * 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 - -#include - -#include - -using namespace std; - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "dlg_grow_selection.h" -#include "wdg_grow_selection.h" - -DlgGrowSelection::DlgGrowSelection( TQWidget * parent, const char * name) : super (parent, name, true, i18n("Grow Selection"), Ok | Cancel, Ok) -{ - m_page = new WdgGrowSelection(this, "grow_selection"); - TQ_CHECK_PTR(m_page); - - setMainWidget(m_page); - resize(m_page->sizeHint()); - - connect(this, TQT_SIGNAL(okClicked()), this, TQT_SLOT(okClicked())); -} - -DlgGrowSelection::~DlgGrowSelection() -{ - delete m_page; -} - -TQ_INT32 DlgGrowSelection::xradius() -{ - return m_page->radiusSpinBox->value(); -} - -TQ_INT32 DlgGrowSelection::yradius() -{ - return m_page->radiusSpinBox->value(); -} - - -// SLOTS - -void DlgGrowSelection::okClicked() -{ - accept(); -} - -#include "dlg_grow_selection.moc" diff --git a/chalk/plugins/viewplugins/modify_selection/dlg_grow_selection.cpp b/chalk/plugins/viewplugins/modify_selection/dlg_grow_selection.cpp new file mode 100644 index 00000000..ae590eba --- /dev/null +++ b/chalk/plugins/viewplugins/modify_selection/dlg_grow_selection.cpp @@ -0,0 +1,76 @@ +/* + * dlg_grow_selection.cpp - part of Chalk + * + * Copyright (c) 2006 Michael Thaler + * + * 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 + +#include + +#include + +using namespace std; + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "dlg_grow_selection.h" +#include "wdg_grow_selection.h" + +DlgGrowSelection::DlgGrowSelection( TQWidget * parent, const char * name) : super (parent, name, true, i18n("Grow Selection"), Ok | Cancel, Ok) +{ + m_page = new WdgGrowSelection(this, "grow_selection"); + TQ_CHECK_PTR(m_page); + + setMainWidget(m_page); + resize(m_page->sizeHint()); + + connect(this, TQT_SIGNAL(okClicked()), this, TQT_SLOT(okClicked())); +} + +DlgGrowSelection::~DlgGrowSelection() +{ + delete m_page; +} + +TQ_INT32 DlgGrowSelection::xradius() +{ + return m_page->radiusSpinBox->value(); +} + +TQ_INT32 DlgGrowSelection::yradius() +{ + return m_page->radiusSpinBox->value(); +} + + +// SLOTS + +void DlgGrowSelection::okClicked() +{ + accept(); +} + +#include "dlg_grow_selection.moc" diff --git a/chalk/plugins/viewplugins/modify_selection/dlg_shrink_selection.cc b/chalk/plugins/viewplugins/modify_selection/dlg_shrink_selection.cc deleted file mode 100644 index f0129e74..00000000 --- a/chalk/plugins/viewplugins/modify_selection/dlg_shrink_selection.cc +++ /dev/null @@ -1,81 +0,0 @@ -/* - * dlg_shrink_selection.cc - part of Chalk - * - * Copyright (c) 2006 Michael Thaler - * - * 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 - -#include - -#include - -using namespace std; - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "dlg_shrink_selection.h" -#include "wdg_shrink_selection.h" - -DlgShrinkSelection::DlgShrinkSelection( TQWidget * parent, const char * name) : super (parent, name, true, i18n("Shrink Selection"), Ok | Cancel, Ok) -{ - m_page = new WdgShrinkSelection(this, "shrink_selection"); - TQ_CHECK_PTR(m_page); - - setMainWidget(m_page); - resize(m_page->sizeHint()); - - connect(this, TQT_SIGNAL(okClicked()), this, TQT_SLOT(okClicked())); -} - -DlgShrinkSelection::~DlgShrinkSelection() -{ - delete m_page; -} - -TQ_INT32 DlgShrinkSelection::xradius() -{ - return m_page->radiusSpinBox->value(); -} - -TQ_INT32 DlgShrinkSelection::yradius() -{ - return m_page->radiusSpinBox->value(); -} - -bool DlgShrinkSelection::shrinkFromImageBorder() -{ - return m_page->shrinkFromImageBorderCheckBox->isChecked(); -} - - -// SLOTS - -void DlgShrinkSelection::okClicked() -{ - accept(); -} - -#include "dlg_shrink_selection.moc" diff --git a/chalk/plugins/viewplugins/modify_selection/dlg_shrink_selection.cpp b/chalk/plugins/viewplugins/modify_selection/dlg_shrink_selection.cpp new file mode 100644 index 00000000..ce4ce9d3 --- /dev/null +++ b/chalk/plugins/viewplugins/modify_selection/dlg_shrink_selection.cpp @@ -0,0 +1,81 @@ +/* + * dlg_shrink_selection.cpp - part of Chalk + * + * Copyright (c) 2006 Michael Thaler + * + * 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 + +#include + +#include + +using namespace std; + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "dlg_shrink_selection.h" +#include "wdg_shrink_selection.h" + +DlgShrinkSelection::DlgShrinkSelection( TQWidget * parent, const char * name) : super (parent, name, true, i18n("Shrink Selection"), Ok | Cancel, Ok) +{ + m_page = new WdgShrinkSelection(this, "shrink_selection"); + TQ_CHECK_PTR(m_page); + + setMainWidget(m_page); + resize(m_page->sizeHint()); + + connect(this, TQT_SIGNAL(okClicked()), this, TQT_SLOT(okClicked())); +} + +DlgShrinkSelection::~DlgShrinkSelection() +{ + delete m_page; +} + +TQ_INT32 DlgShrinkSelection::xradius() +{ + return m_page->radiusSpinBox->value(); +} + +TQ_INT32 DlgShrinkSelection::yradius() +{ + return m_page->radiusSpinBox->value(); +} + +bool DlgShrinkSelection::shrinkFromImageBorder() +{ + return m_page->shrinkFromImageBorderCheckBox->isChecked(); +} + + +// SLOTS + +void DlgShrinkSelection::okClicked() +{ + accept(); +} + +#include "dlg_shrink_selection.moc" diff --git a/chalk/plugins/viewplugins/modify_selection/modify_selection.cc b/chalk/plugins/viewplugins/modify_selection/modify_selection.cc deleted file mode 100644 index 92d50ef7..00000000 --- a/chalk/plugins/viewplugins/modify_selection/modify_selection.cc +++ /dev/null @@ -1,158 +0,0 @@ -/* - * modify_selection.cc -- Part of Chalk - * - * Copyright (c) 2006 Michael Thaler (michael.thaler@physik.tu-muenchen.de) - * - * 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 - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "modify_selection.h" -#include "dlg_grow_selection.h" -#include "dlg_shrink_selection.h" -#include "dlg_border_selection.h" - -typedef KGenericFactory ModifySelectionFactory; -K_EXPORT_COMPONENT_FACTORY( chalkmodifyselection, ModifySelectionFactory( "chalk" ) ) - -ModifySelection::ModifySelection(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - if ( parent->inherits("KisView") ) - { - setInstance(ModifySelectionFactory::instance()); - setXMLFile(locate("data","chalkplugins/modify_selection.rc"), true); - - m_view = (KisView*) parent; - - // Selection manager takes ownership? - TDEAction* a = new TDEAction(i18n("Grow Selection..."), 0, 0, this, TQT_SLOT(slotGrowSelection()), actionCollection(), "growselection"); - TDEAction* b = new TDEAction(i18n("Shrink Selection..."), 0, 0, this, TQT_SLOT(slotShrinkSelection()), actionCollection(), "shrinkselection"); - TDEAction* c = new TDEAction(i18n("Border Selection..."), 0, 0, this, TQT_SLOT(slotBorderSelection()), actionCollection(), "borderselection"); - - TQ_CHECK_PTR(a); - TQ_CHECK_PTR(b); - TQ_CHECK_PTR(c); - - m_view ->canvasSubject()-> selectionManager()->addSelectionAction(a); - m_view ->canvasSubject()-> selectionManager()->addSelectionAction(b); - m_view ->canvasSubject()-> selectionManager()->addSelectionAction(c); - } -} - -ModifySelection::~ModifySelection() -{ - m_view = 0; -} - -void ModifySelection::slotGrowSelection() -{ - KisImageSP image = m_view->canvasSubject()->currentImg(); - - if (!image) return; - - DlgGrowSelection * dlgGrowSelection = new DlgGrowSelection(m_view, "GrowSelection"); - TQ_CHECK_PTR(dlgGrowSelection); - - dlgGrowSelection->setCaption(i18n("Grow Selection")); - - KisConfig cfg; - - if (dlgGrowSelection->exec() == TQDialog::Accepted) { - TQ_INT32 xradius = dlgGrowSelection->xradius(); - TQ_INT32 yradius = dlgGrowSelection->yradius(); - - m_view ->canvasSubject()-> selectionManager()->grow(xradius, yradius); - } - - delete dlgGrowSelection; -} - -void ModifySelection::slotShrinkSelection() -{ - KisImageSP image = m_view->canvasSubject()->currentImg(); - - if (!image) return; - - DlgShrinkSelection * dlgShrinkSelection = new DlgShrinkSelection(m_view, "ShrinkSelection"); - TQ_CHECK_PTR(dlgShrinkSelection); - - dlgShrinkSelection->setCaption(i18n("Shrink Selection")); - - KisConfig cfg; - - if (dlgShrinkSelection->exec() == TQDialog::Accepted) { - TQ_INT32 xradius = dlgShrinkSelection->xradius(); - TQ_INT32 yradius = dlgShrinkSelection->yradius(); - bool shrinkFromImageBorder = dlgShrinkSelection->shrinkFromImageBorder(); - - m_view ->canvasSubject()-> selectionManager()->shrink(xradius, yradius, shrinkFromImageBorder); - } - - delete dlgShrinkSelection; -} - -void ModifySelection::slotBorderSelection() -{ - KisImageSP image = m_view->canvasSubject()->currentImg(); - - if (!image) return; - - DlgBorderSelection * dlgBorderSelection = new DlgBorderSelection(m_view, "BorderSelection"); - TQ_CHECK_PTR(dlgBorderSelection); - - dlgBorderSelection->setCaption(i18n("Border Selection")); - - KisConfig cfg; - - if (dlgBorderSelection->exec() == TQDialog::Accepted) { - TQ_INT32 xradius = dlgBorderSelection->xradius(); - TQ_INT32 yradius = dlgBorderSelection->yradius(); - - m_view ->canvasSubject()-> selectionManager()->border(xradius, yradius); - } - - delete dlgBorderSelection; -} - -#include "modify_selection.moc" diff --git a/chalk/plugins/viewplugins/modify_selection/modify_selection.cpp b/chalk/plugins/viewplugins/modify_selection/modify_selection.cpp new file mode 100644 index 00000000..82389995 --- /dev/null +++ b/chalk/plugins/viewplugins/modify_selection/modify_selection.cpp @@ -0,0 +1,158 @@ +/* + * modify_selection.cpp -- Part of Chalk + * + * Copyright (c) 2006 Michael Thaler (michael.thaler@physik.tu-muenchen.de) + * + * 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 + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "modify_selection.h" +#include "dlg_grow_selection.h" +#include "dlg_shrink_selection.h" +#include "dlg_border_selection.h" + +typedef KGenericFactory ModifySelectionFactory; +K_EXPORT_COMPONENT_FACTORY( chalkmodifyselection, ModifySelectionFactory( "chalk" ) ) + +ModifySelection::ModifySelection(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + if ( parent->inherits("KisView") ) + { + setInstance(ModifySelectionFactory::instance()); + setXMLFile(locate("data","chalkplugins/modify_selection.rc"), true); + + m_view = (KisView*) parent; + + // Selection manager takes ownership? + TDEAction* a = new TDEAction(i18n("Grow Selection..."), 0, 0, this, TQT_SLOT(slotGrowSelection()), actionCollection(), "growselection"); + TDEAction* b = new TDEAction(i18n("Shrink Selection..."), 0, 0, this, TQT_SLOT(slotShrinkSelection()), actionCollection(), "shrinkselection"); + TDEAction* c = new TDEAction(i18n("Border Selection..."), 0, 0, this, TQT_SLOT(slotBorderSelection()), actionCollection(), "borderselection"); + + TQ_CHECK_PTR(a); + TQ_CHECK_PTR(b); + TQ_CHECK_PTR(c); + + m_view ->canvasSubject()-> selectionManager()->addSelectionAction(a); + m_view ->canvasSubject()-> selectionManager()->addSelectionAction(b); + m_view ->canvasSubject()-> selectionManager()->addSelectionAction(c); + } +} + +ModifySelection::~ModifySelection() +{ + m_view = 0; +} + +void ModifySelection::slotGrowSelection() +{ + KisImageSP image = m_view->canvasSubject()->currentImg(); + + if (!image) return; + + DlgGrowSelection * dlgGrowSelection = new DlgGrowSelection(m_view, "GrowSelection"); + TQ_CHECK_PTR(dlgGrowSelection); + + dlgGrowSelection->setCaption(i18n("Grow Selection")); + + KisConfig cfg; + + if (dlgGrowSelection->exec() == TQDialog::Accepted) { + TQ_INT32 xradius = dlgGrowSelection->xradius(); + TQ_INT32 yradius = dlgGrowSelection->yradius(); + + m_view ->canvasSubject()-> selectionManager()->grow(xradius, yradius); + } + + delete dlgGrowSelection; +} + +void ModifySelection::slotShrinkSelection() +{ + KisImageSP image = m_view->canvasSubject()->currentImg(); + + if (!image) return; + + DlgShrinkSelection * dlgShrinkSelection = new DlgShrinkSelection(m_view, "ShrinkSelection"); + TQ_CHECK_PTR(dlgShrinkSelection); + + dlgShrinkSelection->setCaption(i18n("Shrink Selection")); + + KisConfig cfg; + + if (dlgShrinkSelection->exec() == TQDialog::Accepted) { + TQ_INT32 xradius = dlgShrinkSelection->xradius(); + TQ_INT32 yradius = dlgShrinkSelection->yradius(); + bool shrinkFromImageBorder = dlgShrinkSelection->shrinkFromImageBorder(); + + m_view ->canvasSubject()-> selectionManager()->shrink(xradius, yradius, shrinkFromImageBorder); + } + + delete dlgShrinkSelection; +} + +void ModifySelection::slotBorderSelection() +{ + KisImageSP image = m_view->canvasSubject()->currentImg(); + + if (!image) return; + + DlgBorderSelection * dlgBorderSelection = new DlgBorderSelection(m_view, "BorderSelection"); + TQ_CHECK_PTR(dlgBorderSelection); + + dlgBorderSelection->setCaption(i18n("Border Selection")); + + KisConfig cfg; + + if (dlgBorderSelection->exec() == TQDialog::Accepted) { + TQ_INT32 xradius = dlgBorderSelection->xradius(); + TQ_INT32 yradius = dlgBorderSelection->yradius(); + + m_view ->canvasSubject()-> selectionManager()->border(xradius, yradius); + } + + delete dlgBorderSelection; +} + +#include "modify_selection.moc" diff --git a/chalk/plugins/viewplugins/performancetest/Makefile.am b/chalk/plugins/viewplugins/performancetest/Makefile.am index dc26593e..d68e6179 100644 --- a/chalk/plugins/viewplugins/performancetest/Makefile.am +++ b/chalk/plugins/viewplugins/performancetest/Makefile.am @@ -13,7 +13,7 @@ INCLUDES = -I$(srcdir)/../../../sdk \ kde_module_LTLIBRARIES = chalkperftest.la -chalkperftest_la_SOURCES = wdg_perftest.ui perftest.cc dlg_perftest.cc +chalkperftest_la_SOURCES = wdg_perftest.ui perftest.cpp dlg_perftest.cpp noinst_HEADERS = wdg_perftest.h dlg_perftest.h perftest.h chalkperftest_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) $(LIB_QT) -ltdecore -ltdeui -lkjs -ltdefx -ltdeio -ltdeparts diff --git a/chalk/plugins/viewplugins/performancetest/dlg_perftest.cc b/chalk/plugins/viewplugins/performancetest/dlg_perftest.cc deleted file mode 100644 index b2a72306..00000000 --- a/chalk/plugins/viewplugins/performancetest/dlg_perftest.cc +++ /dev/null @@ -1,110 +0,0 @@ -/* - * dlg_perftest.cc - part of KimageShop^WKrayon^WChalk - * - * Copyright (c) 2004 Michael Thaler - * - * 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 - -#include - -#include - -using namespace std; - -#include -#include -#include -#include - -#include -#include -#include - -#include "dlg_perftest.h" -#include "wdg_perftest.h" - - -DlgPerfTest::DlgPerfTest( TQWidget * parent, - const char * name) - : super (parent, name, true, i18n("Performance Test"), Ok | Cancel, Ok) -{ - m_lock = false; - - m_page = new WdgPerfTest(this, "perf_test"); - TQ_CHECK_PTR(m_page); - - setMainWidget(m_page); - resize(m_page->sizeHint()); - - connect(this, TQT_SIGNAL(okClicked()), - this, TQT_SLOT(okClicked())); - - connect(m_page->btnSelectAll, TQT_SIGNAL(clicked()), this, TQT_SLOT(selectAllClicked())); - connect(m_page->btnDeselectAll, TQT_SIGNAL(clicked()), this, TQT_SLOT(deselectAllClicked())); -} - -DlgPerfTest::~DlgPerfTest() -{ - delete m_page; -} - -WdgPerfTest * DlgPerfTest::page() -{ - return m_page; -} - -// SLOTS - -void DlgPerfTest::okClicked() -{ - accept(); -} - -void DlgPerfTest::setAllTestCheckBoxes(bool checked) -{ - m_page->chkBitBlt->setChecked(checked); - m_page->chkFill->setChecked(checked); - m_page->chkGradient->setChecked(checked); - m_page->chkPixel->setChecked(checked); - m_page->chkShape->setChecked(checked); - m_page->chkLayer->setChecked(checked); - m_page->chkScale->setChecked(checked); - m_page->chkRotate->setChecked(checked); - m_page->chkRender->setChecked(checked); - m_page->chkSelection->setChecked(checked); - m_page->chkColorConversion->setChecked(checked); - m_page->chkFilter->setChecked(checked); - m_page->chkReadBytes->setChecked(checked); - m_page->chkWriteBytes->setChecked(checked); - m_page->chkIterators->setChecked(checked); - m_page->chkPaintView->setChecked(checked); - m_page->chkPaintViewFPS->setChecked(checked); -} - -void DlgPerfTest::selectAllClicked() -{ - setAllTestCheckBoxes(true); -} - -void DlgPerfTest::deselectAllClicked() -{ - setAllTestCheckBoxes(false); -} - - -#include "dlg_perftest.moc" diff --git a/chalk/plugins/viewplugins/performancetest/dlg_perftest.cpp b/chalk/plugins/viewplugins/performancetest/dlg_perftest.cpp new file mode 100644 index 00000000..326d9727 --- /dev/null +++ b/chalk/plugins/viewplugins/performancetest/dlg_perftest.cpp @@ -0,0 +1,110 @@ +/* + * dlg_perftest.cpp - part of KimageShop^WKrayon^WChalk + * + * Copyright (c) 2004 Michael Thaler + * + * 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 + +#include + +#include + +using namespace std; + +#include +#include +#include +#include + +#include +#include +#include + +#include "dlg_perftest.h" +#include "wdg_perftest.h" + + +DlgPerfTest::DlgPerfTest( TQWidget * parent, + const char * name) + : super (parent, name, true, i18n("Performance Test"), Ok | Cancel, Ok) +{ + m_lock = false; + + m_page = new WdgPerfTest(this, "perf_test"); + TQ_CHECK_PTR(m_page); + + setMainWidget(m_page); + resize(m_page->sizeHint()); + + connect(this, TQT_SIGNAL(okClicked()), + this, TQT_SLOT(okClicked())); + + connect(m_page->btnSelectAll, TQT_SIGNAL(clicked()), this, TQT_SLOT(selectAllClicked())); + connect(m_page->btnDeselectAll, TQT_SIGNAL(clicked()), this, TQT_SLOT(deselectAllClicked())); +} + +DlgPerfTest::~DlgPerfTest() +{ + delete m_page; +} + +WdgPerfTest * DlgPerfTest::page() +{ + return m_page; +} + +// SLOTS + +void DlgPerfTest::okClicked() +{ + accept(); +} + +void DlgPerfTest::setAllTestCheckBoxes(bool checked) +{ + m_page->chkBitBlt->setChecked(checked); + m_page->chkFill->setChecked(checked); + m_page->chkGradient->setChecked(checked); + m_page->chkPixel->setChecked(checked); + m_page->chkShape->setChecked(checked); + m_page->chkLayer->setChecked(checked); + m_page->chkScale->setChecked(checked); + m_page->chkRotate->setChecked(checked); + m_page->chkRender->setChecked(checked); + m_page->chkSelection->setChecked(checked); + m_page->chkColorConversion->setChecked(checked); + m_page->chkFilter->setChecked(checked); + m_page->chkReadBytes->setChecked(checked); + m_page->chkWriteBytes->setChecked(checked); + m_page->chkIterators->setChecked(checked); + m_page->chkPaintView->setChecked(checked); + m_page->chkPaintViewFPS->setChecked(checked); +} + +void DlgPerfTest::selectAllClicked() +{ + setAllTestCheckBoxes(true); +} + +void DlgPerfTest::deselectAllClicked() +{ + setAllTestCheckBoxes(false); +} + + +#include "dlg_perftest.moc" diff --git a/chalk/plugins/viewplugins/performancetest/perftest.cc b/chalk/plugins/viewplugins/performancetest/perftest.cc deleted file mode 100644 index f728043c..00000000 --- a/chalk/plugins/viewplugins/performancetest/perftest.cc +++ /dev/null @@ -1,1198 +0,0 @@ -/* - * perftest.cc -- Part of Chalk - * - * Copyright (c) 2004 Boudewijn Rempt - * - * 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 - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "kis_meta_registry.h" -#include -#include "kis_cursor.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "perftest.h" -#include "kis_filter_config_widget.h" -#include "kis_factory.h" - -#include "dlg_perftest.h" -#include "wdg_perftest.h" - -#define USE_CALLGRIND 0 - -#if USE_CALLGRIND -#include -#endif - - -typedef KGenericFactory PerfTestFactory; -K_EXPORT_COMPONENT_FACTORY( chalkperftest, PerfTestFactory( "chalk" ) ) - -PerfTest::PerfTest(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - if ( parent->inherits("KisView") ) - { - setInstance(PerfTestFactory::instance()); - setXMLFile(locate("data","chalkplugins/perftest.rc"), true); - - (void) new TDEAction(i18n("&Performance Test..."), 0, 0, this, TQT_SLOT(slotPerfTest()), actionCollection(), "perf_test"); - - m_view = (KisView*) parent; - } -} - -PerfTest::~PerfTest() -{ - m_view = 0; -} - -void PerfTest::slotPerfTest() -{ - KisImageSP image = m_view->canvasSubject()->currentImg(); - - if (!image) return; - - DlgPerfTest * dlgPerfTest = new DlgPerfTest(m_view, "PerfTest"); - TQ_CHECK_PTR(dlgPerfTest); - - dlgPerfTest->setCaption(i18n("Performance Test")); - - TQString report = TQString(""); - - if (dlgPerfTest->exec() == TQDialog::Accepted) { - - TQ_INT32 testCount = (TQ_INT32)tqRound(dlgPerfTest->page()->intTestCount->value()); - - if (dlgPerfTest->page()->chkBitBlt->isChecked()) { - kdDebug() << "bltTest:\n"; - TQString s = bltTest(testCount); - report = report.append(s); - kdDebug() << s << "\n"; - } - if (dlgPerfTest->page()->chkFill->isChecked()) { - kdDebug() << "Filltest\n"; - TQString s= fillTest(testCount); - report = report.append(s); - kdDebug() << s << "\n"; - } - if (dlgPerfTest->page()->chkGradient->isChecked()) { - kdDebug() << "Gradienttest\n"; - TQString s = gradientTest(testCount); - report = report.append(s); - kdDebug() << s << "\n"; - } - if (dlgPerfTest->page()->chkPixel->isChecked()) { - kdDebug() << "Pixeltest\n"; - TQString s = pixelTest(testCount); - report = report.append(s); - kdDebug() << s << "\n"; - } - if (dlgPerfTest->page()->chkShape->isChecked()) { - kdDebug() << "Shapetest\n"; - TQString s = shapeTest(testCount); - report = report.append(s); - kdDebug() << s << "\n"; - } - if (dlgPerfTest->page()->chkLayer->isChecked()) { - kdDebug() << "LayerTest\n"; - TQString s = layerTest(testCount); - report = report.append(s); - kdDebug() << s << "\n"; - } - if (dlgPerfTest->page()->chkScale->isChecked()) { - kdDebug() << "Scaletest\n"; - TQString s = scaleTest(testCount); - report = report.append(s); - kdDebug() << s << "\n"; - } - if (dlgPerfTest->page()->chkRotate->isChecked()) { - kdDebug() << "Rotatetest\n"; - TQString s = rotateTest(testCount); - report = report.append(s); - kdDebug() << s << "\n"; - } - if (dlgPerfTest->page()->chkRender->isChecked()) { - kdDebug() << "Rendertest\n"; - TQString s = renderTest(testCount); - report = report.append(s); - kdDebug() << s << "\n"; - } - if (dlgPerfTest->page()->chkSelection->isChecked()) { - kdDebug() << "Selectiontest\n"; - TQString s = selectionTest(testCount); - report = report.append(s); - kdDebug() << s << "\n"; - } - if (dlgPerfTest->page()->chkColorConversion->isChecked()) { - kdDebug() << "Colorconversiontest\n"; - TQString s = colorConversionTest(testCount); - report = report.append(s); - kdDebug() << s << "\n"; - } - if (dlgPerfTest->page()->chkFilter-> isChecked()) { - kdDebug() << "filtertest\n"; - TQString s = filterTest(testCount); - report = report.append(s); - kdDebug() << s << "\n"; - } - if (dlgPerfTest->page()->chkReadBytes->isChecked()) { - kdDebug() << "Readbytes test\n"; - TQString s = readBytesTest(testCount); - report = report.append(s); - kdDebug() << s << "\n"; - } - if (dlgPerfTest->page()->chkWriteBytes-> isChecked()) { - kdDebug() << "Writebytes test\n"; - TQString s = writeBytesTest(testCount); - report = report.append(s); - kdDebug() << s << "\n"; - } - if (dlgPerfTest->page()->chkIterators->isChecked()) { - kdDebug() << "Iterators test\n"; - TQString s = iteratorTest(testCount); - report = report.append(s); - kdDebug() << s << "\n"; - } - if (dlgPerfTest->page()->chkPaintView->isChecked()) { - kdDebug() << "paintview test\n"; - TQString s = paintViewTest(testCount); - report = report.append(s); - kdDebug() << s << "\n"; - } - if (dlgPerfTest->page()->chkPaintViewFPS->isChecked()) { - kdDebug() << "paint current view (fps) test\n"; - TQString s = paintViewFPSTest(); - report = report.append(s); - kdDebug() << s << "\n"; - } - KDialogBase * d = new KDialogBase(m_view, "", true, "", KDialogBase::Ok); - TQ_CHECK_PTR(d); - - d->setCaption("Performance test results"); - TQTextEdit * e = new TQTextEdit(d); - TQ_CHECK_PTR(e); - d->setMainWidget(e); - e->setText(report); - e->setMinimumWidth(600); - e->setMinimumHeight(600); - d->exec(); - delete d; - - } - delete dlgPerfTest; -} - -TQString PerfTest::bltTest(TQ_UINT32 testCount) -{ - TQString report = TQString("* bitBlt test\n"); - - KisDoc * doc = m_view->canvasSubject()->document(); - KisIDList l = KisMetaRegistry::instance()->csRegistry()->listKeys(); - - for (KisIDList::Iterator it = l.begin(); it != l.end(); ++it) { - - kdDebug() << "Image->" << (*it).name() << "\n"; - - report = report.append( " Testing blitting on " + (*it).name() + "\n"); - - KisImageSP img = doc->newImage("blt-" + (*it).name(), 1000, 1000, - KisMetaRegistry::instance()->csRegistry()->getColorSpace(*it,"")); - - report = report.append(doBlit(COMPOSITE_OVER, *it, OPACITY_OPAQUE, testCount, img)); - report = report.append( "\n"); - report = report.append(doBlit(COMPOSITE_OVER, *it, OPACITY_OPAQUE / 2, testCount, img)); - report = report.append( "\n"); - report = report.append(doBlit(COMPOSITE_COPY, *it, OPACITY_OPAQUE, testCount, img)); - report = report.append( "\n"); - report = report.append(doBlit(COMPOSITE_COPY, *it, OPACITY_OPAQUE / 2, testCount, img)); - report = report.append( "\n"); - } - - return report; - - -} - - -TQString PerfTest::doBlit(const KisCompositeOp& op, - KisID cspace, - TQ_UINT8 opacity, - TQ_UINT32 testCount, - KisImageSP img) -{ - - TQTime t; - TQString report; - - // ------------------------------------------------------------------------------ - // Small - - KisPaintDeviceSP small = new KisPaintDevice(KisMetaRegistry::instance()->csRegistry()->getColorSpace(cspace,""), "small blit"); - TQ_CHECK_PTR(small); - - KisFillPainter pf(small.data()) ; - pf.fillRect(0, 0, 32, 32, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); - pf.end(); - - t.restart(); - KisPainter p(img->activeDevice()); - for (TQ_UINT32 i = 0; i < testCount; ++i) { - p.bitBlt(0, 0, op, small.data(),0,0,32, 32); - } - p.end(); - - report = report.append(TQString(" %1 blits of rectangles < tilesize with opacity %2 and composite op %3: %4ms\n") - .arg(testCount) - .arg(opacity) - .arg(op.id().name()) - .arg(t.elapsed())); - - - // ------------------------------------------------------------------------------ - // Medium - KisPaintDeviceSP medium = new KisPaintDevice(KisMetaRegistry::instance()->csRegistry()->getColorSpace(cspace,""), "medium blit"); - TQ_CHECK_PTR(medium); - - pf.begin(medium.data()) ; - pf.fillRect(0, 0, 64 * 3, 64 * 3, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); - pf.end(); - - t.restart(); - p.begin(img->activeDevice().data()); - for (TQ_UINT32 i = 0; i < testCount; ++i) { - p.bitBlt(0, 0, op, medium.data(),0,0,96, 96); - } - p.end(); - - report = report.append(TQString(" %1 blits of rectangles 3 * tilesize with opacity %2 and composite op %3: %4ms\n") - .arg(testCount) - .arg(opacity) - .arg(op.id().name()) - .arg(t.elapsed())); - - - // ------------------------------------------------------------------------------ - // Big - KisPaintDeviceSP big = new KisPaintDevice(KisMetaRegistry::instance()->csRegistry()->getColorSpace(cspace,""), "big blit"); - TQ_CHECK_PTR(big); - - pf.begin(big.data()) ; - pf.fillRect(0, 0, 800, 800, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); - pf.end(); - - t.restart(); - p.begin(img->activeDevice().data()); - for (TQ_UINT32 i = 0; i < testCount; ++i) { - p.bitBlt(0, 0, op, big.data(),0,0,800,800); - - } - p.end(); - report = report.append(TQString(" %1 blits of rectangles 800 x 800 with opacity %2 and composite op %3: %4ms\n") - .arg(testCount) - .arg(opacity) - .arg(op.id().name()) - .arg(t.elapsed())); - - - // ------------------------------------------------------------------------------ - // Outside - - KisPaintDeviceSP outside = new KisPaintDevice(KisMetaRegistry::instance()->csRegistry()->getColorSpace(cspace,""), "outside blit"); - TQ_CHECK_PTR(outside); - pf.begin(outside.data()) ; - pf.fillRect(0, 0, 500, 500, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); - pf.end(); - - t.restart(); - p.begin(img->activeDevice().data()); - for (TQ_UINT32 i = 0; i < testCount; ++i) { - p.bitBlt(600, 600, op, outside.data(),0,0,500,500); - - } - p.end(); - report = report.append(TQString(" %1 blits of rectangles 500 x 500 at 600,600 with opacity %2 and composite op %3: %4ms\n") - .arg(testCount) - .arg(opacity) - .arg(op.id().name()) - .arg(t.elapsed())); - - // ------------------------------------------------------------------------------ - // Small with varied source opacity - - KisPaintDeviceSP small_with_alpha = new KisPaintDevice(KisMetaRegistry::instance()->csRegistry()->getColorSpace(cspace,""), "small blit with alpha"); - TQ_CHECK_PTR(small_with_alpha); - - pf.begin(small_with_alpha.data()) ; - pf.fillRect(0, 0, 32, 32, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()), OPACITY_TRANSPARENT); - pf.fillRect(4, 4, 24, 24, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()), OPACITY_OPAQUE / 2); - pf.fillRect(8, 8, 16, 16, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()), OPACITY_OPAQUE); - pf.end(); - - t.restart(); - p.begin(img->activeDevice().data()); - for (TQ_UINT32 i = 0; i < testCount; ++i) { - p.bitBlt(0, 0, op, small_with_alpha.data(), 0, 0, 32, 32); - } - p.end(); - - report = report.append(TQString(" %1 blits of rectangles < tilesize with source alpha, with opacity %2 and composite op %3: %4ms\n") - .arg(testCount) - .arg(opacity) - .arg(op.id().name()) - .arg(t.elapsed())); - - return report; - -} - -TQString PerfTest::fillTest(TQ_UINT32 testCount) -{ - TQString report = TQString("* Fill test\n"); - - KisDoc * doc = m_view->canvasSubject()->document(); - KisIDList l = KisMetaRegistry::instance()->csRegistry()->listKeys(); - - for (KisIDList::Iterator it = l.begin(); it != l.end(); ++it) { - kdDebug() << "Filltest on " << (*it).name() + "\n"; - - report = report.append( " Testing blitting on " + (*it).name() + "\n"); - - KisImageSP img = doc->newImage("fill-" + (*it).name(), 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(*it,"")); - KisPaintDeviceSP l = img->activeDevice(); - - // Rect fill - KisFillPainter p(l.data()); - TQTime t; - t.restart(); - for (TQ_UINT32 i = 0; i < testCount; ++i) { - p.eraseRect(0, 0, 1000, 1000); - } - report = report.append(TQString(" Erased 1000 x 1000 layer %1 times: %2\n").arg(testCount).arg(t.elapsed())); - - - t.restart(); - for (TQ_UINT32 i = 0; i < testCount; ++i) { - p.eraseRect(50, 50, 500, 500); - } - report = report.append(TQString(" Erased 500 x 500 layer %1 times: %2\n").arg(testCount).arg(t.elapsed())); - - - t.restart(); - for (TQ_UINT32 i = 0; i < testCount; ++i) { - p.eraseRect(-50, -50, 1100, 1100); - } - report = report.append(TQString(" Erased rect bigger than layer %1 times: %2\n").arg(testCount).arg(t.elapsed())); - - - // Opaque Rect fill - t.restart(); - for (TQ_UINT32 i = 0; i < testCount; ++i) { - p.fillRect(0, 0, 1000, 1000, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); - } - report = report.append(TQString(" Opaque fill 1000 x 1000 layer %1 times: %2\n").arg(testCount).arg(t.elapsed())); - - - t.restart(); - for (TQ_UINT32 i = 0; i < testCount; ++i) { - p.fillRect(50, 50, 500, 500, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); - } - report = report.append(TQString(" Opaque fill 500 x 500 layer %1 times: %2\n").arg(testCount).arg(t.elapsed())); - - - t.restart(); - for (TQ_UINT32 i = 0; i < testCount; ++i) { - p.fillRect(-50, -50, 1100, 1100, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); - } - report = report.append(TQString(" Opaque fill rect bigger than layer %1 times: %2\n").arg(testCount).arg(t.elapsed())); - - // Transparent rect fill - - t.restart(); - for (TQ_UINT32 i = 0; i < testCount; ++i) { - p.fillRect(0, 0, 1000, 1000, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()), OPACITY_OPAQUE / 2); - } - report = report.append(TQString(" Opaque fill 1000 x 1000 layer %1 times: %2\n").arg(testCount).arg(t.elapsed())); - - - t.restart(); - for (TQ_UINT32 i = 0; i < testCount; ++i) { - p.fillRect(50, 50, 500, 500, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()), OPACITY_OPAQUE / 2); - } - report = report.append(TQString(" Opaque fill 500 x 500 layer %1 times: %2\n").arg(testCount).arg(t.elapsed())); - - - t.restart(); - for (TQ_UINT32 i = 0; i < testCount; ++i) { - p.fillRect(-50, -50, 1100, 1100, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()), OPACITY_OPAQUE / 2); - } - report = report.append(TQString(" Opaque fill rect bigger than layer %1 times: %2\n").arg(testCount).arg(t.elapsed())); - - // Colour fill - - t.restart(); - for (TQ_UINT32 i = 0; i < testCount; ++i) { - p.eraseRect(0, 0, 1000, 1000); -// p.paintEllipse(500, 1000, 100, 0, 0); - p.setPaintColor(KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); - p.setFillThreshold(15); - p.setCompositeOp(COMPOSITE_OVER); - p.fillColor(0,0); - } - report = report.append(TQString(" Opaque floodfill of whole circle (incl. erase and painting of circle) %1 times: %2\n").arg(testCount).arg(t.elapsed())); - - - // Pattern fill - t.restart(); - for (TQ_UINT32 i = 0; i < testCount; ++i) { - p.eraseRect(0, 0, 1000, 1000); -// p.paintEllipse(500, 1000, 100, 0, 0); - p.setPaintColor(KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); - KisResourceServerBase* r = KisResourceServerRegistry::instance()->get("PatternServer"); - TQ_CHECK_PTR(r); - p.setPattern((KisPattern*)r->resources().first()); - p.setFillThreshold(15); - p.setCompositeOp(COMPOSITE_OVER); - p.fillPattern(0,0); - } - report = report.append(TQString(" Opaque patternfill of whole circle (incl. erase and painting of circle) %1 times: %2\n").arg(testCount).arg(t.elapsed())); - - - - } - - - - return report; - -} - -TQString PerfTest::gradientTest(TQ_UINT32 testCount) -{ - return TQString("Gradient test\n"); -} - -TQString PerfTest::pixelTest(TQ_UINT32 testCount) -{ - TQString report = TQString("* pixel/setpixel test\n"); - - KisDoc * doc = m_view->canvasSubject()->document(); - KisIDList l = KisMetaRegistry::instance()->csRegistry()->listKeys(); - - - for (KisIDList::Iterator it = l.begin(); it != l.end(); ++it) { - report = report.append( " Testing pixel/setpixel on " + (*it).name() + "\n"); - - KisImageSP img = doc->newImage("fill-" + (*it).name(), 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(*it,"")); - - KisPaintDeviceSP l = img->activeDevice(); - - TQTime t; - t.restart(); - - TQColor c = TQt::black; - TQ_UINT8 opacity = OPACITY_OPAQUE; - for (TQ_UINT32 i = 0; i < testCount; ++i) { - for (TQ_UINT32 x = 0; x < 1000; ++x) { - for (TQ_UINT32 y = 0; y < 1000; ++y) { - l->pixel(x, y, &c, &opacity); - } - } - } - report = report.append(TQString(" read 1000 x 1000 pixels %1 times: %2\n").arg(testCount).arg(t.elapsed())); - - c= TQt::black; - t.restart(); - for (TQ_UINT32 i = 0; i < testCount; ++i) { - for (TQ_UINT32 x = 0; x < 1000; ++x) { - for (TQ_UINT32 y = 0; y < 1000; ++y) { - l->setPixel(x, y, c, 128); - } - } - } - report = report.append(TQString(" written 1000 x 1000 pixels %1 times: %2\n").arg(testCount).arg(t.elapsed())); - - } - - - - - return report; - -} - -TQString PerfTest::shapeTest(TQ_UINT32 testCount) -{ - return TQString("Shape test\n"); -} - -TQString PerfTest::layerTest(TQ_UINT32 testCount) -{ - return TQString("Layer test\n"); -} - -TQString PerfTest::scaleTest(TQ_UINT32 testCount) -{ - return TQString("Scale test\n"); -} - -TQString PerfTest::rotateTest(TQ_UINT32 testCount) -{ - TQString report = TQString("* Rotate test\n"); - - KisDoc * doc = m_view->canvasSubject()->document(); - KisIDList l = KisMetaRegistry::instance()->csRegistry()->listKeys(); - for (KisIDList::Iterator it = l.begin(); it != l.end(); ++it) { - - doc->undoAdapter()->setUndo( false ); - TQTime t; - - for (uint i = 0; i < testCount; ++i) { - for (double angle = 0; angle < 360; ++angle) { - kdDebug() << "Rotating " << (*it).name() << " at " << angle << " degrees\n"; - KisImage * img = doc->newImage("cs-" + (*it).name(), 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(*it,"")); - img->rotate(angle, m_view->canvasSubject()->progressDisplay()); - kdDebug() << "Size: " << img->projection()->extent() << endl; - delete img; - } - } - report = report.append(TQString(" rotated 1000 x 1000 pixels over 360 degrees, degree by degree, %1 times: %2\n").arg(testCount).arg(t.elapsed())); - } - return report; -} - -TQString PerfTest::renderTest(TQ_UINT32 restCount) -{ - return TQString("Render test\n"); -} - -TQString PerfTest::selectionTest(TQ_UINT32 testCount) -{ - return TQString("Selection test\n"); -} - -TQString PerfTest::colorConversionTest(TQ_UINT32 testCount) -{ - TQString report = TQString("* Colorspace conversion test\n"); - - KisDoc * doc = m_view->canvasSubject()->document(); - KisIDList l = KisMetaRegistry::instance()->csRegistry()->listKeys(); - for (KisIDList::Iterator it = l.begin(); it != l.end(); ++it) { - - KisImage * img = doc->newImage("cs-" + (*it).name(), 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(*it,"")); - - TQTime t; - - KisIDList l2 = KisMetaRegistry::instance()->csRegistry()->listKeys(); - for (KisIDList::Iterator it2 = l2.begin(); it2 != l2.end(); ++it2) { - kdDebug() << "test conversion from " << (*it).name() << " to " << (*it2).name() << endl; - - t.restart(); - for (uint i = 0; i < testCount; ++i) { - KisImage * img2 = new KisImage(*img); - img2->convertTo(KisMetaRegistry::instance()->csRegistry()->getColorSpace(*it2,"")); - delete img2; - } - report = report.append(TQString(" converted from " + (*it).name() + " to " + (*it2).name() + " 1000 x 1000 pixels %1 times: %2\n").arg(testCount).arg(t.elapsed())); - - } - - delete img; - - } - return report; - -} - -TQString PerfTest::filterTest(TQ_UINT32 testCount) -{ - - TQString report = TQString("* Filter test\n"); - - KisIDList filters = KisFilterRegistry::instance()->listKeys(); - KisDoc * doc = m_view->canvasSubject()->document(); - KisIDList l = KisMetaRegistry::instance()->csRegistry()->listKeys(); - - for (KisIDList::Iterator it = l.begin(); it != l.end(); ++it) { - report = report.append( " Testing filtering on " + (*it).name() + "\n"); - - KisImageSP img = doc->newImage("filter-" + (*it).name(), 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(*it,"")); - KisPaintDeviceSP l = img->activeDevice(); - - TQTime t; - - for (KisIDList::Iterator it = filters.begin(); it != filters.end(); ++it) { - - KisFilterSP f = KisFilterRegistry::instance()->get(*it); - t.restart(); - kdDebug() << "test filter " << f->id().name() << " on " << img->colorSpace()->id().name() << endl; - for (TQ_UINT32 i = 0; i < testCount; ++i) { - f->enableProgress(); - f->process(l.data(), l.data(), f->configuration(f->createConfigurationWidget(m_view, l.data())), TQRect(0, 0, 1000, 1000)); - f->disableProgress(); - } - report = report.append(TQString(" filtered " + (*it).name() + "1000 x 1000 pixels %1 times: %2\n").arg(testCount).arg(t.elapsed())); - - } - - } - return report; - -} - -TQString PerfTest::readBytesTest(TQ_UINT32 testCount) -{ - TQString report = TQString("* Read bytes test\n\n"); - - // On default tiles - KisDoc * doc = m_view->canvasSubject()->document(); - KisImageSP img = doc->newImage("Readbytes ", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA",""),"")); - KisPaintDeviceSP l = img->activeDevice(); - - TQTime t; - t.restart(); - - for (TQ_UINT32 i = 0; i < testCount; ++i) { - TQ_UINT8 * newData = new TQ_UINT8[1000 * 1000 * l->pixelSize()]; - TQ_CHECK_PTR(newData); - l->readBytes(newData, 0, 0, 1000, 1000); - delete[] newData; - } - - report = report.append(TQString(" read 1000 x 1000 pixels %1 times from empty image: %2\n").arg(testCount).arg(t.elapsed())); - - // On tiles with data - - KisFillPainter p(l.data()); - p.fillRect(0, 0, 1000, 1000, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); - p.end(); - - t.restart(); - - for (TQ_UINT32 i = 0; i < testCount; ++i) { - TQ_UINT8 * newData = new TQ_UINT8[1000 * 1000 * l->pixelSize()]; - TQ_CHECK_PTR(newData); - l->readBytes(newData, 0, 0, 1000, 1000); - delete[] newData; - } - - report = report.append(TQString(" read 1000 x 1000 pixels %1 times from filled image: %2\n").arg(testCount).arg(t.elapsed())); - - return report; -} - - -TQString PerfTest::writeBytesTest(TQ_UINT32 testCount) -{ - TQString report = TQString("* Write bytes test"); - - // On default tiles - KisDoc * doc = m_view->canvasSubject()->document(); - KisImageSP img = doc->newImage("Writebytes ", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); - KisPaintDeviceSP l = img->activeDevice(); - KisFillPainter p(l.data()); - p.fillRect(0, 0, 1000, 1000, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); - p.end(); - - - TQ_UINT8 * data = new TQ_UINT8[1000 * 1000 * l->pixelSize()]; - TQ_CHECK_PTR(data); - l->readBytes(data, 0, 0, 1000, 1000); - - TQTime t; - t.restart(); - for (TQ_UINT32 i = 0; i < testCount; ++i) { - l->writeBytes(data, 0, 0, 1000, 1000); - } - delete[] data; - report = report.append(TQString(" written 1000 x 1000 pixels %1 times: %2\n").arg(testCount).arg(t.elapsed())); - return report; - - -} - -/////// Iterator tests - - -TQString hlineRODefault(KisDoc * doc, TQ_UINT32 testCount) -{ - KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); - KisPaintDeviceSP l = img->activeDevice(); - - TQTime t; - t.restart(); - - - for (TQ_UINT32 i = 0; i < testCount; ++i) { - int adv; - - for(TQ_INT32 y2 = 0; y2 < 0 + 1000; y2++) - { - KisHLineIterator hiter = l->createHLineIterator(0, y2, 1000, false); - while(! hiter.isDone()) - { - adv = hiter.nConseqHPixels(); - hiter += adv; - } - } - - } - - return TQString(" hline iterated read-only 1000 x 1000 pixels %1 times over default tile: %2\n").arg(testCount).arg(t.elapsed()); - - -} - -TQString hlineRO(KisDoc * doc, TQ_UINT32 testCount) -{ - KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); - KisPaintDeviceSP l = img->activeDevice(); - - KisFillPainter p(l.data()); - p.fillRect(0, 0, 1000, 1000, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); - p.end(); - - TQTime t; - t.restart(); - - for (TQ_UINT32 i = 0; i < testCount; ++i) { - int adv; - - for(TQ_INT32 y2 = 0; y2 < 0 + 1000; y2++) - { - KisHLineIterator hiter = l->createHLineIterator(0, y2, 1000, false); - while(! hiter.isDone()) - { - adv = hiter.nConseqHPixels(); - hiter += adv; - } - } - - } - - return TQString(" hline iterated read-only 1000 x 1000 pixels %1 times over existing tile: %2\n").arg(testCount).arg(t.elapsed()); - -} - -TQString hlineWRDefault(KisDoc * doc, TQ_UINT32 testCount) -{ - KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); - KisPaintDeviceSP l = img->activeDevice(); - - TQTime t; - t.restart(); - - for (TQ_UINT32 i = 0; i < testCount; ++i) { - int adv; - - for(TQ_INT32 y2 = 0; y2 < 0 + 1000; y2++) - { - KisHLineIterator hiter = l->createHLineIterator(0, y2, 1000, true); - while(! hiter.isDone()) - { - adv = hiter.nConseqHPixels(); - hiter += adv; - } - } - - } - - return TQString(" hline iterated writable 1000 x 1000 pixels %1 times over default tile: %2\n").arg(testCount).arg(t.elapsed()); - -} - -TQString hlineWR(KisDoc * doc, TQ_UINT32 testCount) -{ - KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); - KisPaintDeviceSP l = img->activeDevice(); - - KisFillPainter p(l.data()); - p.fillRect(0, 0, 1000, 1000, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); - p.end(); - - - TQTime t; - t.restart(); - - for (TQ_UINT32 i = 0; i < testCount; ++i) { - int adv; - for(TQ_INT32 y2 = 0; y2 < 0 + 1000; y2++) - { - KisHLineIterator hiter = l->createHLineIterator(0, y2, 1000, true); - while(! hiter.isDone()) - { - adv = hiter.nConseqHPixels(); - hiter += adv; - } - } - - } - - return TQString(" hline iterated writable 1000 x 1000 pixels %1 times over existing tile: %2\n").arg(testCount).arg(t.elapsed()); - -} - - -TQString vlineRODefault(KisDoc * doc, TQ_UINT32 testCount) -{ - KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); - KisPaintDeviceSP l = img->activeDevice(); - - TQTime t; - t.restart(); - - for (TQ_UINT32 i = 0; i < testCount; ++i) { - for(TQ_INT32 y2 = 0; y2 < 0 + 1000; y2++) - { - KisVLineIterator hiter = l->createVLineIterator(y2, 0, 1000, true); - while(! hiter.isDone()) - { - ++hiter; - } - } - - } - - return TQString(" vline iterated read-only 1000 x 1000 pixels %1 times over default tile: %2\n").arg(testCount).arg(t.elapsed()); - -} - -TQString vlineRO(KisDoc * doc, TQ_UINT32 testCount) -{ - KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); - KisPaintDeviceSP l = img->activeDevice(); - - KisFillPainter p(l.data()); - p.fillRect(0, 0, 1000, 1000, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); - p.end(); - - - TQTime t; - t.restart(); - - for (TQ_UINT32 i = 0; i < testCount; ++i) { - for(TQ_INT32 y2 = 0; y2 < 0 + 1000; y2++) - { - KisVLineIterator hiter = l->createVLineIterator(y2, 0, 1000, true); - while(! hiter.isDone()) - { - ++hiter; - } - } - - } - - return TQString(" vline iterated read-only 1000 x 1000 pixels %1 times over existing tile: %2\n").arg(testCount).arg(t.elapsed()); - -} - -TQString vlineWRDefault(KisDoc * doc, TQ_UINT32 testCount) -{ - KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); - KisPaintDeviceSP l = img->activeDevice(); - - TQTime t; - t.restart(); - - for (TQ_UINT32 i = 0; i < testCount; ++i) { - - for(TQ_INT32 y2 = 0; y2 < 0 + 1000; y2++) - { - KisVLineIterator hiter = l->createVLineIterator(y2, 0, 1000, true); - while(! hiter.isDone()) - { - ++hiter; - } - } - - } - - return TQString(" vline iterated writable 1000 x 1000 pixels %1 times over default tile: %2\n").arg(testCount).arg(t.elapsed()); -} - -TQString vlineWR(KisDoc * doc, TQ_UINT32 testCount) -{ - - KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); - KisPaintDeviceSP l = img->activeDevice(); - - KisFillPainter p(l.data()); - p.fillRect(0, 0, 1000, 1000, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); - p.end(); - - TQTime t; - t.restart(); - - for (TQ_UINT32 i = 0; i < testCount; ++i) { - for(TQ_INT32 y2 = 0; y2 < 0 + 1000; y2++) - { - KisHLineIterator hiter = l->createHLineIterator(y2, 0, 1000, true); - while(! hiter.isDone()) - { - ++hiter; - } - } - - } - - return TQString(" vline iterated writable 1000 x 1000 pixels %1 times over existing tile: %2\n").arg(testCount).arg(t.elapsed()); - -} - -TQString rectRODefault(KisDoc * doc, TQ_UINT32 testCount) -{ - KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); - KisPaintDeviceSP l = img->activeDevice(); -; - TQTime t; - t.restart(); - - for (TQ_UINT32 i = 0; i < testCount; ++i) { - KisRectIterator r = l->createRectIterator(0, 0, 1000, 1000, false); - while(! r.isDone()) - { - ++r; - } - } - - return TQString(" rect iterated read-only 1000 x 1000 pixels %1 times over default tile: %2\n").arg(testCount).arg(t.elapsed()); - - -} - -TQString rectRO(KisDoc * doc, TQ_UINT32 testCount) -{ - KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); - KisPaintDeviceSP l = img->activeDevice(); - - KisFillPainter p(l.data()); - p.fillRect(0, 0, 1000, 1000, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); - p.end(); - - TQTime t; - t.restart(); - - for (TQ_UINT32 i = 0; i < testCount; ++i) { - KisRectIterator r = l->createRectIterator(0, 0, 1000, 1000, false); - while(! r.isDone()) - { - ++r; - } - } - - return TQString(" rect iterated read-only 1000 x 1000 pixels %1 times over existing tile: %2\n").arg(testCount).arg(t.elapsed()); - -} - -TQString rectWRDefault(KisDoc * doc, TQ_UINT32 testCount) -{ - - - KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); - KisPaintDeviceSP l = img->activeDevice(); - - TQTime t; - t.restart(); - - for (TQ_UINT32 i = 0; i < testCount; ++i) { - KisRectIterator r = l->createRectIterator(0, 0, 1000, 1000, true); - while(! r.isDone()) - { - ++r; - } - } - - return TQString(" rect iterated writable 1000 x 1000 pixels %1 times over default tile: %2\n").arg(testCount).arg(t.elapsed()); - -} - -TQString rectWR(KisDoc * doc, TQ_UINT32 testCount) -{ - KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); - KisPaintDeviceSP l = img->activeDevice(); - - KisFillPainter p(l.data()); - p.fillRect(0, 0, 1000, 1000, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); - p.end(); - - - TQTime t; - t.restart(); - - - for (TQ_UINT32 i = 0; i < testCount; ++i) { - KisRectIterator r = l->createRectIterator(0, 0, 1000, 1000, true); - while(! r.isDone()) - { - ++r; - } - } - - - return TQString(" rect iterated writable 1000 x 1000 pixels %1 times over existing tile: %2\n").arg(testCount).arg(t.elapsed()); - - -} -TQString PerfTest::iteratorTest(TQ_UINT32 testCount) -{ - TQString report = "Iterator test"; - - KisDoc * doc = m_view->canvasSubject()->document(); - - report = report.append(hlineRODefault(doc, testCount)); - report = report.append(hlineRO(doc, testCount)); - report = report.append(hlineWRDefault(doc, testCount)); - report = report.append(hlineWR(doc, testCount)); - - report = report.append(vlineRODefault(doc, testCount)); - report = report.append(vlineRO(doc, testCount)); - report = report.append(vlineWRDefault(doc, testCount)); - report = report.append(vlineWR(doc, testCount)); - - report = report.append(rectRODefault(doc, testCount)); - report = report.append(rectRO(doc, testCount)); - report = report.append(rectWRDefault(doc, testCount)); - report = report.append(rectWR(doc, testCount)); - - return report; - - -} - -TQString PerfTest::paintViewTest(TQ_UINT32 testCount) -{ - TQString report = TQString("* paintView test\n\n"); - - KisDoc * doc = m_view->canvasSubject()->document(); - - KisImageSP img = doc->currentImage(); - img->resize(512,512); - - - KisPaintDeviceSP l = img->activeDevice(); - - KisFillPainter p(l.data()); - p.fillRect(0, 0, 512, 512, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); - p.end(); - - TQTime t; - t.restart(); - -#if USE_CALLGRIND - CALLGRIND_ZERO_STATS(); -#endif - - for (TQ_UINT32 i = 0; i < testCount; ++i) { - m_view->getCanvasController()->updateCanvas(TQRect(0, 0, 512, 512)); - } - -#if USE_CALLGRIND - CALLGRIND_DUMP_STATS(); -#endif - - report = report.append(TQString(" painted a 512 x 512 image %1 times: %2 ms\n").arg(testCount).arg(t.elapsed())); - - img->newLayer("layer 2", OPACITY_OPAQUE); - l = img->activeDevice(); - - p.begin(l.data()); - p.fillRect(0, 0, 512, 512, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); - p.end(); - - img->newLayer("layer 3", OPACITY_OPAQUE); - l = img->activeDevice(); - - p.begin(l.data()); - p.fillRect(0, 0, 512, 512, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); - p.end(); - - t.restart(); - - for (TQ_UINT32 i = 0; i < testCount; ++i) { - m_view->getCanvasController()->updateCanvas(TQRect(0, 0, 512, 512)); - } - - report = report.append(TQString(" painted a 512 x 512 image with 3 layers %1 times: %2 ms\n").arg(testCount).arg(t.elapsed())); - - return report; -} - -TQString PerfTest::paintViewFPSTest() -{ - TQString report = TQString("* paintView (fps) test\n\n"); - - TQTime t; - t.restart(); - -#if USE_CALLGRIND - CALLGRIND_ZERO_STATS(); -#endif - - int numViewsPainted = 0; - const int millisecondsPerSecond = 1000; - - while (t.elapsed() < millisecondsPerSecond) { - m_view->getCanvasController()->updateCanvas(); - numViewsPainted++; - } - -#if USE_CALLGRIND - CALLGRIND_DUMP_STATS(); -#endif - - report = report.append(TQString(" painted current view at %1 frames per second\n").arg(numViewsPainted)); - - return report; -} - -#include "perftest.moc" diff --git a/chalk/plugins/viewplugins/performancetest/perftest.cpp b/chalk/plugins/viewplugins/performancetest/perftest.cpp new file mode 100644 index 00000000..fa544551 --- /dev/null +++ b/chalk/plugins/viewplugins/performancetest/perftest.cpp @@ -0,0 +1,1198 @@ +/* + * perftest.cpp -- Part of Chalk + * + * Copyright (c) 2004 Boudewijn Rempt + * + * 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 + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "kis_meta_registry.h" +#include +#include "kis_cursor.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "perftest.h" +#include "kis_filter_config_widget.h" +#include "kis_factory.h" + +#include "dlg_perftest.h" +#include "wdg_perftest.h" + +#define USE_CALLGRIND 0 + +#if USE_CALLGRIND +#include +#endif + + +typedef KGenericFactory PerfTestFactory; +K_EXPORT_COMPONENT_FACTORY( chalkperftest, PerfTestFactory( "chalk" ) ) + +PerfTest::PerfTest(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + if ( parent->inherits("KisView") ) + { + setInstance(PerfTestFactory::instance()); + setXMLFile(locate("data","chalkplugins/perftest.rc"), true); + + (void) new TDEAction(i18n("&Performance Test..."), 0, 0, this, TQT_SLOT(slotPerfTest()), actionCollection(), "perf_test"); + + m_view = (KisView*) parent; + } +} + +PerfTest::~PerfTest() +{ + m_view = 0; +} + +void PerfTest::slotPerfTest() +{ + KisImageSP image = m_view->canvasSubject()->currentImg(); + + if (!image) return; + + DlgPerfTest * dlgPerfTest = new DlgPerfTest(m_view, "PerfTest"); + TQ_CHECK_PTR(dlgPerfTest); + + dlgPerfTest->setCaption(i18n("Performance Test")); + + TQString report = TQString(""); + + if (dlgPerfTest->exec() == TQDialog::Accepted) { + + TQ_INT32 testCount = (TQ_INT32)tqRound(dlgPerfTest->page()->intTestCount->value()); + + if (dlgPerfTest->page()->chkBitBlt->isChecked()) { + kdDebug() << "bltTest:\n"; + TQString s = bltTest(testCount); + report = report.append(s); + kdDebug() << s << "\n"; + } + if (dlgPerfTest->page()->chkFill->isChecked()) { + kdDebug() << "Filltest\n"; + TQString s= fillTest(testCount); + report = report.append(s); + kdDebug() << s << "\n"; + } + if (dlgPerfTest->page()->chkGradient->isChecked()) { + kdDebug() << "Gradienttest\n"; + TQString s = gradientTest(testCount); + report = report.append(s); + kdDebug() << s << "\n"; + } + if (dlgPerfTest->page()->chkPixel->isChecked()) { + kdDebug() << "Pixeltest\n"; + TQString s = pixelTest(testCount); + report = report.append(s); + kdDebug() << s << "\n"; + } + if (dlgPerfTest->page()->chkShape->isChecked()) { + kdDebug() << "Shapetest\n"; + TQString s = shapeTest(testCount); + report = report.append(s); + kdDebug() << s << "\n"; + } + if (dlgPerfTest->page()->chkLayer->isChecked()) { + kdDebug() << "LayerTest\n"; + TQString s = layerTest(testCount); + report = report.append(s); + kdDebug() << s << "\n"; + } + if (dlgPerfTest->page()->chkScale->isChecked()) { + kdDebug() << "Scaletest\n"; + TQString s = scaleTest(testCount); + report = report.append(s); + kdDebug() << s << "\n"; + } + if (dlgPerfTest->page()->chkRotate->isChecked()) { + kdDebug() << "Rotatetest\n"; + TQString s = rotateTest(testCount); + report = report.append(s); + kdDebug() << s << "\n"; + } + if (dlgPerfTest->page()->chkRender->isChecked()) { + kdDebug() << "Rendertest\n"; + TQString s = renderTest(testCount); + report = report.append(s); + kdDebug() << s << "\n"; + } + if (dlgPerfTest->page()->chkSelection->isChecked()) { + kdDebug() << "Selectiontest\n"; + TQString s = selectionTest(testCount); + report = report.append(s); + kdDebug() << s << "\n"; + } + if (dlgPerfTest->page()->chkColorConversion->isChecked()) { + kdDebug() << "Colorconversiontest\n"; + TQString s = colorConversionTest(testCount); + report = report.append(s); + kdDebug() << s << "\n"; + } + if (dlgPerfTest->page()->chkFilter-> isChecked()) { + kdDebug() << "filtertest\n"; + TQString s = filterTest(testCount); + report = report.append(s); + kdDebug() << s << "\n"; + } + if (dlgPerfTest->page()->chkReadBytes->isChecked()) { + kdDebug() << "Readbytes test\n"; + TQString s = readBytesTest(testCount); + report = report.append(s); + kdDebug() << s << "\n"; + } + if (dlgPerfTest->page()->chkWriteBytes-> isChecked()) { + kdDebug() << "Writebytes test\n"; + TQString s = writeBytesTest(testCount); + report = report.append(s); + kdDebug() << s << "\n"; + } + if (dlgPerfTest->page()->chkIterators->isChecked()) { + kdDebug() << "Iterators test\n"; + TQString s = iteratorTest(testCount); + report = report.append(s); + kdDebug() << s << "\n"; + } + if (dlgPerfTest->page()->chkPaintView->isChecked()) { + kdDebug() << "paintview test\n"; + TQString s = paintViewTest(testCount); + report = report.append(s); + kdDebug() << s << "\n"; + } + if (dlgPerfTest->page()->chkPaintViewFPS->isChecked()) { + kdDebug() << "paint current view (fps) test\n"; + TQString s = paintViewFPSTest(); + report = report.append(s); + kdDebug() << s << "\n"; + } + KDialogBase * d = new KDialogBase(m_view, "", true, "", KDialogBase::Ok); + TQ_CHECK_PTR(d); + + d->setCaption("Performance test results"); + TQTextEdit * e = new TQTextEdit(d); + TQ_CHECK_PTR(e); + d->setMainWidget(e); + e->setText(report); + e->setMinimumWidth(600); + e->setMinimumHeight(600); + d->exec(); + delete d; + + } + delete dlgPerfTest; +} + +TQString PerfTest::bltTest(TQ_UINT32 testCount) +{ + TQString report = TQString("* bitBlt test\n"); + + KisDoc * doc = m_view->canvasSubject()->document(); + KisIDList l = KisMetaRegistry::instance()->csRegistry()->listKeys(); + + for (KisIDList::Iterator it = l.begin(); it != l.end(); ++it) { + + kdDebug() << "Image->" << (*it).name() << "\n"; + + report = report.append( " Testing blitting on " + (*it).name() + "\n"); + + KisImageSP img = doc->newImage("blt-" + (*it).name(), 1000, 1000, + KisMetaRegistry::instance()->csRegistry()->getColorSpace(*it,"")); + + report = report.append(doBlit(COMPOSITE_OVER, *it, OPACITY_OPAQUE, testCount, img)); + report = report.append( "\n"); + report = report.append(doBlit(COMPOSITE_OVER, *it, OPACITY_OPAQUE / 2, testCount, img)); + report = report.append( "\n"); + report = report.append(doBlit(COMPOSITE_COPY, *it, OPACITY_OPAQUE, testCount, img)); + report = report.append( "\n"); + report = report.append(doBlit(COMPOSITE_COPY, *it, OPACITY_OPAQUE / 2, testCount, img)); + report = report.append( "\n"); + } + + return report; + + +} + + +TQString PerfTest::doBlit(const KisCompositeOp& op, + KisID cspace, + TQ_UINT8 opacity, + TQ_UINT32 testCount, + KisImageSP img) +{ + + TQTime t; + TQString report; + + // ------------------------------------------------------------------------------ + // Small + + KisPaintDeviceSP small = new KisPaintDevice(KisMetaRegistry::instance()->csRegistry()->getColorSpace(cspace,""), "small blit"); + TQ_CHECK_PTR(small); + + KisFillPainter pf(small.data()) ; + pf.fillRect(0, 0, 32, 32, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + pf.end(); + + t.restart(); + KisPainter p(img->activeDevice()); + for (TQ_UINT32 i = 0; i < testCount; ++i) { + p.bitBlt(0, 0, op, small.data(),0,0,32, 32); + } + p.end(); + + report = report.append(TQString(" %1 blits of rectangles < tilesize with opacity %2 and composite op %3: %4ms\n") + .arg(testCount) + .arg(opacity) + .arg(op.id().name()) + .arg(t.elapsed())); + + + // ------------------------------------------------------------------------------ + // Medium + KisPaintDeviceSP medium = new KisPaintDevice(KisMetaRegistry::instance()->csRegistry()->getColorSpace(cspace,""), "medium blit"); + TQ_CHECK_PTR(medium); + + pf.begin(medium.data()) ; + pf.fillRect(0, 0, 64 * 3, 64 * 3, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + pf.end(); + + t.restart(); + p.begin(img->activeDevice().data()); + for (TQ_UINT32 i = 0; i < testCount; ++i) { + p.bitBlt(0, 0, op, medium.data(),0,0,96, 96); + } + p.end(); + + report = report.append(TQString(" %1 blits of rectangles 3 * tilesize with opacity %2 and composite op %3: %4ms\n") + .arg(testCount) + .arg(opacity) + .arg(op.id().name()) + .arg(t.elapsed())); + + + // ------------------------------------------------------------------------------ + // Big + KisPaintDeviceSP big = new KisPaintDevice(KisMetaRegistry::instance()->csRegistry()->getColorSpace(cspace,""), "big blit"); + TQ_CHECK_PTR(big); + + pf.begin(big.data()) ; + pf.fillRect(0, 0, 800, 800, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + pf.end(); + + t.restart(); + p.begin(img->activeDevice().data()); + for (TQ_UINT32 i = 0; i < testCount; ++i) { + p.bitBlt(0, 0, op, big.data(),0,0,800,800); + + } + p.end(); + report = report.append(TQString(" %1 blits of rectangles 800 x 800 with opacity %2 and composite op %3: %4ms\n") + .arg(testCount) + .arg(opacity) + .arg(op.id().name()) + .arg(t.elapsed())); + + + // ------------------------------------------------------------------------------ + // Outside + + KisPaintDeviceSP outside = new KisPaintDevice(KisMetaRegistry::instance()->csRegistry()->getColorSpace(cspace,""), "outside blit"); + TQ_CHECK_PTR(outside); + pf.begin(outside.data()) ; + pf.fillRect(0, 0, 500, 500, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + pf.end(); + + t.restart(); + p.begin(img->activeDevice().data()); + for (TQ_UINT32 i = 0; i < testCount; ++i) { + p.bitBlt(600, 600, op, outside.data(),0,0,500,500); + + } + p.end(); + report = report.append(TQString(" %1 blits of rectangles 500 x 500 at 600,600 with opacity %2 and composite op %3: %4ms\n") + .arg(testCount) + .arg(opacity) + .arg(op.id().name()) + .arg(t.elapsed())); + + // ------------------------------------------------------------------------------ + // Small with varied source opacity + + KisPaintDeviceSP small_with_alpha = new KisPaintDevice(KisMetaRegistry::instance()->csRegistry()->getColorSpace(cspace,""), "small blit with alpha"); + TQ_CHECK_PTR(small_with_alpha); + + pf.begin(small_with_alpha.data()) ; + pf.fillRect(0, 0, 32, 32, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()), OPACITY_TRANSPARENT); + pf.fillRect(4, 4, 24, 24, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()), OPACITY_OPAQUE / 2); + pf.fillRect(8, 8, 16, 16, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()), OPACITY_OPAQUE); + pf.end(); + + t.restart(); + p.begin(img->activeDevice().data()); + for (TQ_UINT32 i = 0; i < testCount; ++i) { + p.bitBlt(0, 0, op, small_with_alpha.data(), 0, 0, 32, 32); + } + p.end(); + + report = report.append(TQString(" %1 blits of rectangles < tilesize with source alpha, with opacity %2 and composite op %3: %4ms\n") + .arg(testCount) + .arg(opacity) + .arg(op.id().name()) + .arg(t.elapsed())); + + return report; + +} + +TQString PerfTest::fillTest(TQ_UINT32 testCount) +{ + TQString report = TQString("* Fill test\n"); + + KisDoc * doc = m_view->canvasSubject()->document(); + KisIDList l = KisMetaRegistry::instance()->csRegistry()->listKeys(); + + for (KisIDList::Iterator it = l.begin(); it != l.end(); ++it) { + kdDebug() << "Filltest on " << (*it).name() + "\n"; + + report = report.append( " Testing blitting on " + (*it).name() + "\n"); + + KisImageSP img = doc->newImage("fill-" + (*it).name(), 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(*it,"")); + KisPaintDeviceSP l = img->activeDevice(); + + // Rect fill + KisFillPainter p(l.data()); + TQTime t; + t.restart(); + for (TQ_UINT32 i = 0; i < testCount; ++i) { + p.eraseRect(0, 0, 1000, 1000); + } + report = report.append(TQString(" Erased 1000 x 1000 layer %1 times: %2\n").arg(testCount).arg(t.elapsed())); + + + t.restart(); + for (TQ_UINT32 i = 0; i < testCount; ++i) { + p.eraseRect(50, 50, 500, 500); + } + report = report.append(TQString(" Erased 500 x 500 layer %1 times: %2\n").arg(testCount).arg(t.elapsed())); + + + t.restart(); + for (TQ_UINT32 i = 0; i < testCount; ++i) { + p.eraseRect(-50, -50, 1100, 1100); + } + report = report.append(TQString(" Erased rect bigger than layer %1 times: %2\n").arg(testCount).arg(t.elapsed())); + + + // Opaque Rect fill + t.restart(); + for (TQ_UINT32 i = 0; i < testCount; ++i) { + p.fillRect(0, 0, 1000, 1000, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + } + report = report.append(TQString(" Opaque fill 1000 x 1000 layer %1 times: %2\n").arg(testCount).arg(t.elapsed())); + + + t.restart(); + for (TQ_UINT32 i = 0; i < testCount; ++i) { + p.fillRect(50, 50, 500, 500, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + } + report = report.append(TQString(" Opaque fill 500 x 500 layer %1 times: %2\n").arg(testCount).arg(t.elapsed())); + + + t.restart(); + for (TQ_UINT32 i = 0; i < testCount; ++i) { + p.fillRect(-50, -50, 1100, 1100, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + } + report = report.append(TQString(" Opaque fill rect bigger than layer %1 times: %2\n").arg(testCount).arg(t.elapsed())); + + // Transparent rect fill + + t.restart(); + for (TQ_UINT32 i = 0; i < testCount; ++i) { + p.fillRect(0, 0, 1000, 1000, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()), OPACITY_OPAQUE / 2); + } + report = report.append(TQString(" Opaque fill 1000 x 1000 layer %1 times: %2\n").arg(testCount).arg(t.elapsed())); + + + t.restart(); + for (TQ_UINT32 i = 0; i < testCount; ++i) { + p.fillRect(50, 50, 500, 500, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()), OPACITY_OPAQUE / 2); + } + report = report.append(TQString(" Opaque fill 500 x 500 layer %1 times: %2\n").arg(testCount).arg(t.elapsed())); + + + t.restart(); + for (TQ_UINT32 i = 0; i < testCount; ++i) { + p.fillRect(-50, -50, 1100, 1100, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8()), OPACITY_OPAQUE / 2); + } + report = report.append(TQString(" Opaque fill rect bigger than layer %1 times: %2\n").arg(testCount).arg(t.elapsed())); + + // Colour fill + + t.restart(); + for (TQ_UINT32 i = 0; i < testCount; ++i) { + p.eraseRect(0, 0, 1000, 1000); +// p.paintEllipse(500, 1000, 100, 0, 0); + p.setPaintColor(KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + p.setFillThreshold(15); + p.setCompositeOp(COMPOSITE_OVER); + p.fillColor(0,0); + } + report = report.append(TQString(" Opaque floodfill of whole circle (incl. erase and painting of circle) %1 times: %2\n").arg(testCount).arg(t.elapsed())); + + + // Pattern fill + t.restart(); + for (TQ_UINT32 i = 0; i < testCount; ++i) { + p.eraseRect(0, 0, 1000, 1000); +// p.paintEllipse(500, 1000, 100, 0, 0); + p.setPaintColor(KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + KisResourceServerBase* r = KisResourceServerRegistry::instance()->get("PatternServer"); + TQ_CHECK_PTR(r); + p.setPattern((KisPattern*)r->resources().first()); + p.setFillThreshold(15); + p.setCompositeOp(COMPOSITE_OVER); + p.fillPattern(0,0); + } + report = report.append(TQString(" Opaque patternfill of whole circle (incl. erase and painting of circle) %1 times: %2\n").arg(testCount).arg(t.elapsed())); + + + + } + + + + return report; + +} + +TQString PerfTest::gradientTest(TQ_UINT32 testCount) +{ + return TQString("Gradient test\n"); +} + +TQString PerfTest::pixelTest(TQ_UINT32 testCount) +{ + TQString report = TQString("* pixel/setpixel test\n"); + + KisDoc * doc = m_view->canvasSubject()->document(); + KisIDList l = KisMetaRegistry::instance()->csRegistry()->listKeys(); + + + for (KisIDList::Iterator it = l.begin(); it != l.end(); ++it) { + report = report.append( " Testing pixel/setpixel on " + (*it).name() + "\n"); + + KisImageSP img = doc->newImage("fill-" + (*it).name(), 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(*it,"")); + + KisPaintDeviceSP l = img->activeDevice(); + + TQTime t; + t.restart(); + + TQColor c = TQt::black; + TQ_UINT8 opacity = OPACITY_OPAQUE; + for (TQ_UINT32 i = 0; i < testCount; ++i) { + for (TQ_UINT32 x = 0; x < 1000; ++x) { + for (TQ_UINT32 y = 0; y < 1000; ++y) { + l->pixel(x, y, &c, &opacity); + } + } + } + report = report.append(TQString(" read 1000 x 1000 pixels %1 times: %2\n").arg(testCount).arg(t.elapsed())); + + c= TQt::black; + t.restart(); + for (TQ_UINT32 i = 0; i < testCount; ++i) { + for (TQ_UINT32 x = 0; x < 1000; ++x) { + for (TQ_UINT32 y = 0; y < 1000; ++y) { + l->setPixel(x, y, c, 128); + } + } + } + report = report.append(TQString(" written 1000 x 1000 pixels %1 times: %2\n").arg(testCount).arg(t.elapsed())); + + } + + + + + return report; + +} + +TQString PerfTest::shapeTest(TQ_UINT32 testCount) +{ + return TQString("Shape test\n"); +} + +TQString PerfTest::layerTest(TQ_UINT32 testCount) +{ + return TQString("Layer test\n"); +} + +TQString PerfTest::scaleTest(TQ_UINT32 testCount) +{ + return TQString("Scale test\n"); +} + +TQString PerfTest::rotateTest(TQ_UINT32 testCount) +{ + TQString report = TQString("* Rotate test\n"); + + KisDoc * doc = m_view->canvasSubject()->document(); + KisIDList l = KisMetaRegistry::instance()->csRegistry()->listKeys(); + for (KisIDList::Iterator it = l.begin(); it != l.end(); ++it) { + + doc->undoAdapter()->setUndo( false ); + TQTime t; + + for (uint i = 0; i < testCount; ++i) { + for (double angle = 0; angle < 360; ++angle) { + kdDebug() << "Rotating " << (*it).name() << " at " << angle << " degrees\n"; + KisImage * img = doc->newImage("cs-" + (*it).name(), 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(*it,"")); + img->rotate(angle, m_view->canvasSubject()->progressDisplay()); + kdDebug() << "Size: " << img->projection()->extent() << endl; + delete img; + } + } + report = report.append(TQString(" rotated 1000 x 1000 pixels over 360 degrees, degree by degree, %1 times: %2\n").arg(testCount).arg(t.elapsed())); + } + return report; +} + +TQString PerfTest::renderTest(TQ_UINT32 restCount) +{ + return TQString("Render test\n"); +} + +TQString PerfTest::selectionTest(TQ_UINT32 testCount) +{ + return TQString("Selection test\n"); +} + +TQString PerfTest::colorConversionTest(TQ_UINT32 testCount) +{ + TQString report = TQString("* Colorspace conversion test\n"); + + KisDoc * doc = m_view->canvasSubject()->document(); + KisIDList l = KisMetaRegistry::instance()->csRegistry()->listKeys(); + for (KisIDList::Iterator it = l.begin(); it != l.end(); ++it) { + + KisImage * img = doc->newImage("cs-" + (*it).name(), 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(*it,"")); + + TQTime t; + + KisIDList l2 = KisMetaRegistry::instance()->csRegistry()->listKeys(); + for (KisIDList::Iterator it2 = l2.begin(); it2 != l2.end(); ++it2) { + kdDebug() << "test conversion from " << (*it).name() << " to " << (*it2).name() << endl; + + t.restart(); + for (uint i = 0; i < testCount; ++i) { + KisImage * img2 = new KisImage(*img); + img2->convertTo(KisMetaRegistry::instance()->csRegistry()->getColorSpace(*it2,"")); + delete img2; + } + report = report.append(TQString(" converted from " + (*it).name() + " to " + (*it2).name() + " 1000 x 1000 pixels %1 times: %2\n").arg(testCount).arg(t.elapsed())); + + } + + delete img; + + } + return report; + +} + +TQString PerfTest::filterTest(TQ_UINT32 testCount) +{ + + TQString report = TQString("* Filter test\n"); + + KisIDList filters = KisFilterRegistry::instance()->listKeys(); + KisDoc * doc = m_view->canvasSubject()->document(); + KisIDList l = KisMetaRegistry::instance()->csRegistry()->listKeys(); + + for (KisIDList::Iterator it = l.begin(); it != l.end(); ++it) { + report = report.append( " Testing filtering on " + (*it).name() + "\n"); + + KisImageSP img = doc->newImage("filter-" + (*it).name(), 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(*it,"")); + KisPaintDeviceSP l = img->activeDevice(); + + TQTime t; + + for (KisIDList::Iterator it = filters.begin(); it != filters.end(); ++it) { + + KisFilterSP f = KisFilterRegistry::instance()->get(*it); + t.restart(); + kdDebug() << "test filter " << f->id().name() << " on " << img->colorSpace()->id().name() << endl; + for (TQ_UINT32 i = 0; i < testCount; ++i) { + f->enableProgress(); + f->process(l.data(), l.data(), f->configuration(f->createConfigurationWidget(m_view, l.data())), TQRect(0, 0, 1000, 1000)); + f->disableProgress(); + } + report = report.append(TQString(" filtered " + (*it).name() + "1000 x 1000 pixels %1 times: %2\n").arg(testCount).arg(t.elapsed())); + + } + + } + return report; + +} + +TQString PerfTest::readBytesTest(TQ_UINT32 testCount) +{ + TQString report = TQString("* Read bytes test\n\n"); + + // On default tiles + KisDoc * doc = m_view->canvasSubject()->document(); + KisImageSP img = doc->newImage("Readbytes ", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA",""),"")); + KisPaintDeviceSP l = img->activeDevice(); + + TQTime t; + t.restart(); + + for (TQ_UINT32 i = 0; i < testCount; ++i) { + TQ_UINT8 * newData = new TQ_UINT8[1000 * 1000 * l->pixelSize()]; + TQ_CHECK_PTR(newData); + l->readBytes(newData, 0, 0, 1000, 1000); + delete[] newData; + } + + report = report.append(TQString(" read 1000 x 1000 pixels %1 times from empty image: %2\n").arg(testCount).arg(t.elapsed())); + + // On tiles with data + + KisFillPainter p(l.data()); + p.fillRect(0, 0, 1000, 1000, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + p.end(); + + t.restart(); + + for (TQ_UINT32 i = 0; i < testCount; ++i) { + TQ_UINT8 * newData = new TQ_UINT8[1000 * 1000 * l->pixelSize()]; + TQ_CHECK_PTR(newData); + l->readBytes(newData, 0, 0, 1000, 1000); + delete[] newData; + } + + report = report.append(TQString(" read 1000 x 1000 pixels %1 times from filled image: %2\n").arg(testCount).arg(t.elapsed())); + + return report; +} + + +TQString PerfTest::writeBytesTest(TQ_UINT32 testCount) +{ + TQString report = TQString("* Write bytes test"); + + // On default tiles + KisDoc * doc = m_view->canvasSubject()->document(); + KisImageSP img = doc->newImage("Writebytes ", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); + KisPaintDeviceSP l = img->activeDevice(); + KisFillPainter p(l.data()); + p.fillRect(0, 0, 1000, 1000, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + p.end(); + + + TQ_UINT8 * data = new TQ_UINT8[1000 * 1000 * l->pixelSize()]; + TQ_CHECK_PTR(data); + l->readBytes(data, 0, 0, 1000, 1000); + + TQTime t; + t.restart(); + for (TQ_UINT32 i = 0; i < testCount; ++i) { + l->writeBytes(data, 0, 0, 1000, 1000); + } + delete[] data; + report = report.append(TQString(" written 1000 x 1000 pixels %1 times: %2\n").arg(testCount).arg(t.elapsed())); + return report; + + +} + +/////// Iterator tests + + +TQString hlineRODefault(KisDoc * doc, TQ_UINT32 testCount) +{ + KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); + KisPaintDeviceSP l = img->activeDevice(); + + TQTime t; + t.restart(); + + + for (TQ_UINT32 i = 0; i < testCount; ++i) { + int adv; + + for(TQ_INT32 y2 = 0; y2 < 0 + 1000; y2++) + { + KisHLineIterator hiter = l->createHLineIterator(0, y2, 1000, false); + while(! hiter.isDone()) + { + adv = hiter.nConseqHPixels(); + hiter += adv; + } + } + + } + + return TQString(" hline iterated read-only 1000 x 1000 pixels %1 times over default tile: %2\n").arg(testCount).arg(t.elapsed()); + + +} + +TQString hlineRO(KisDoc * doc, TQ_UINT32 testCount) +{ + KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); + KisPaintDeviceSP l = img->activeDevice(); + + KisFillPainter p(l.data()); + p.fillRect(0, 0, 1000, 1000, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + p.end(); + + TQTime t; + t.restart(); + + for (TQ_UINT32 i = 0; i < testCount; ++i) { + int adv; + + for(TQ_INT32 y2 = 0; y2 < 0 + 1000; y2++) + { + KisHLineIterator hiter = l->createHLineIterator(0, y2, 1000, false); + while(! hiter.isDone()) + { + adv = hiter.nConseqHPixels(); + hiter += adv; + } + } + + } + + return TQString(" hline iterated read-only 1000 x 1000 pixels %1 times over existing tile: %2\n").arg(testCount).arg(t.elapsed()); + +} + +TQString hlineWRDefault(KisDoc * doc, TQ_UINT32 testCount) +{ + KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); + KisPaintDeviceSP l = img->activeDevice(); + + TQTime t; + t.restart(); + + for (TQ_UINT32 i = 0; i < testCount; ++i) { + int adv; + + for(TQ_INT32 y2 = 0; y2 < 0 + 1000; y2++) + { + KisHLineIterator hiter = l->createHLineIterator(0, y2, 1000, true); + while(! hiter.isDone()) + { + adv = hiter.nConseqHPixels(); + hiter += adv; + } + } + + } + + return TQString(" hline iterated writable 1000 x 1000 pixels %1 times over default tile: %2\n").arg(testCount).arg(t.elapsed()); + +} + +TQString hlineWR(KisDoc * doc, TQ_UINT32 testCount) +{ + KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); + KisPaintDeviceSP l = img->activeDevice(); + + KisFillPainter p(l.data()); + p.fillRect(0, 0, 1000, 1000, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + p.end(); + + + TQTime t; + t.restart(); + + for (TQ_UINT32 i = 0; i < testCount; ++i) { + int adv; + for(TQ_INT32 y2 = 0; y2 < 0 + 1000; y2++) + { + KisHLineIterator hiter = l->createHLineIterator(0, y2, 1000, true); + while(! hiter.isDone()) + { + adv = hiter.nConseqHPixels(); + hiter += adv; + } + } + + } + + return TQString(" hline iterated writable 1000 x 1000 pixels %1 times over existing tile: %2\n").arg(testCount).arg(t.elapsed()); + +} + + +TQString vlineRODefault(KisDoc * doc, TQ_UINT32 testCount) +{ + KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); + KisPaintDeviceSP l = img->activeDevice(); + + TQTime t; + t.restart(); + + for (TQ_UINT32 i = 0; i < testCount; ++i) { + for(TQ_INT32 y2 = 0; y2 < 0 + 1000; y2++) + { + KisVLineIterator hiter = l->createVLineIterator(y2, 0, 1000, true); + while(! hiter.isDone()) + { + ++hiter; + } + } + + } + + return TQString(" vline iterated read-only 1000 x 1000 pixels %1 times over default tile: %2\n").arg(testCount).arg(t.elapsed()); + +} + +TQString vlineRO(KisDoc * doc, TQ_UINT32 testCount) +{ + KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); + KisPaintDeviceSP l = img->activeDevice(); + + KisFillPainter p(l.data()); + p.fillRect(0, 0, 1000, 1000, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + p.end(); + + + TQTime t; + t.restart(); + + for (TQ_UINT32 i = 0; i < testCount; ++i) { + for(TQ_INT32 y2 = 0; y2 < 0 + 1000; y2++) + { + KisVLineIterator hiter = l->createVLineIterator(y2, 0, 1000, true); + while(! hiter.isDone()) + { + ++hiter; + } + } + + } + + return TQString(" vline iterated read-only 1000 x 1000 pixels %1 times over existing tile: %2\n").arg(testCount).arg(t.elapsed()); + +} + +TQString vlineWRDefault(KisDoc * doc, TQ_UINT32 testCount) +{ + KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); + KisPaintDeviceSP l = img->activeDevice(); + + TQTime t; + t.restart(); + + for (TQ_UINT32 i = 0; i < testCount; ++i) { + + for(TQ_INT32 y2 = 0; y2 < 0 + 1000; y2++) + { + KisVLineIterator hiter = l->createVLineIterator(y2, 0, 1000, true); + while(! hiter.isDone()) + { + ++hiter; + } + } + + } + + return TQString(" vline iterated writable 1000 x 1000 pixels %1 times over default tile: %2\n").arg(testCount).arg(t.elapsed()); +} + +TQString vlineWR(KisDoc * doc, TQ_UINT32 testCount) +{ + + KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); + KisPaintDeviceSP l = img->activeDevice(); + + KisFillPainter p(l.data()); + p.fillRect(0, 0, 1000, 1000, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + p.end(); + + TQTime t; + t.restart(); + + for (TQ_UINT32 i = 0; i < testCount; ++i) { + for(TQ_INT32 y2 = 0; y2 < 0 + 1000; y2++) + { + KisHLineIterator hiter = l->createHLineIterator(y2, 0, 1000, true); + while(! hiter.isDone()) + { + ++hiter; + } + } + + } + + return TQString(" vline iterated writable 1000 x 1000 pixels %1 times over existing tile: %2\n").arg(testCount).arg(t.elapsed()); + +} + +TQString rectRODefault(KisDoc * doc, TQ_UINT32 testCount) +{ + KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); + KisPaintDeviceSP l = img->activeDevice(); +; + TQTime t; + t.restart(); + + for (TQ_UINT32 i = 0; i < testCount; ++i) { + KisRectIterator r = l->createRectIterator(0, 0, 1000, 1000, false); + while(! r.isDone()) + { + ++r; + } + } + + return TQString(" rect iterated read-only 1000 x 1000 pixels %1 times over default tile: %2\n").arg(testCount).arg(t.elapsed()); + + +} + +TQString rectRO(KisDoc * doc, TQ_UINT32 testCount) +{ + KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); + KisPaintDeviceSP l = img->activeDevice(); + + KisFillPainter p(l.data()); + p.fillRect(0, 0, 1000, 1000, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + p.end(); + + TQTime t; + t.restart(); + + for (TQ_UINT32 i = 0; i < testCount; ++i) { + KisRectIterator r = l->createRectIterator(0, 0, 1000, 1000, false); + while(! r.isDone()) + { + ++r; + } + } + + return TQString(" rect iterated read-only 1000 x 1000 pixels %1 times over existing tile: %2\n").arg(testCount).arg(t.elapsed()); + +} + +TQString rectWRDefault(KisDoc * doc, TQ_UINT32 testCount) +{ + + + KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); + KisPaintDeviceSP l = img->activeDevice(); + + TQTime t; + t.restart(); + + for (TQ_UINT32 i = 0; i < testCount; ++i) { + KisRectIterator r = l->createRectIterator(0, 0, 1000, 1000, true); + while(! r.isDone()) + { + ++r; + } + } + + return TQString(" rect iterated writable 1000 x 1000 pixels %1 times over default tile: %2\n").arg(testCount).arg(t.elapsed()); + +} + +TQString rectWR(KisDoc * doc, TQ_UINT32 testCount) +{ + KisImageSP img = doc->newImage("", 1000, 1000, KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("RGBA", ""),"")); + KisPaintDeviceSP l = img->activeDevice(); + + KisFillPainter p(l.data()); + p.fillRect(0, 0, 1000, 1000, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + p.end(); + + + TQTime t; + t.restart(); + + + for (TQ_UINT32 i = 0; i < testCount; ++i) { + KisRectIterator r = l->createRectIterator(0, 0, 1000, 1000, true); + while(! r.isDone()) + { + ++r; + } + } + + + return TQString(" rect iterated writable 1000 x 1000 pixels %1 times over existing tile: %2\n").arg(testCount).arg(t.elapsed()); + + +} +TQString PerfTest::iteratorTest(TQ_UINT32 testCount) +{ + TQString report = "Iterator test"; + + KisDoc * doc = m_view->canvasSubject()->document(); + + report = report.append(hlineRODefault(doc, testCount)); + report = report.append(hlineRO(doc, testCount)); + report = report.append(hlineWRDefault(doc, testCount)); + report = report.append(hlineWR(doc, testCount)); + + report = report.append(vlineRODefault(doc, testCount)); + report = report.append(vlineRO(doc, testCount)); + report = report.append(vlineWRDefault(doc, testCount)); + report = report.append(vlineWR(doc, testCount)); + + report = report.append(rectRODefault(doc, testCount)); + report = report.append(rectRO(doc, testCount)); + report = report.append(rectWRDefault(doc, testCount)); + report = report.append(rectWR(doc, testCount)); + + return report; + + +} + +TQString PerfTest::paintViewTest(TQ_UINT32 testCount) +{ + TQString report = TQString("* paintView test\n\n"); + + KisDoc * doc = m_view->canvasSubject()->document(); + + KisImageSP img = doc->currentImage(); + img->resize(512,512); + + + KisPaintDeviceSP l = img->activeDevice(); + + KisFillPainter p(l.data()); + p.fillRect(0, 0, 512, 512, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + p.end(); + + TQTime t; + t.restart(); + +#if USE_CALLGRIND + CALLGRIND_ZERO_STATS(); +#endif + + for (TQ_UINT32 i = 0; i < testCount; ++i) { + m_view->getCanvasController()->updateCanvas(TQRect(0, 0, 512, 512)); + } + +#if USE_CALLGRIND + CALLGRIND_DUMP_STATS(); +#endif + + report = report.append(TQString(" painted a 512 x 512 image %1 times: %2 ms\n").arg(testCount).arg(t.elapsed())); + + img->newLayer("layer 2", OPACITY_OPAQUE); + l = img->activeDevice(); + + p.begin(l.data()); + p.fillRect(0, 0, 512, 512, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + p.end(); + + img->newLayer("layer 3", OPACITY_OPAQUE); + l = img->activeDevice(); + + p.begin(l.data()); + p.fillRect(0, 0, 512, 512, KisColor(TQt::black, KisMetaRegistry::instance()->csRegistry()->getRGB8())); + p.end(); + + t.restart(); + + for (TQ_UINT32 i = 0; i < testCount; ++i) { + m_view->getCanvasController()->updateCanvas(TQRect(0, 0, 512, 512)); + } + + report = report.append(TQString(" painted a 512 x 512 image with 3 layers %1 times: %2 ms\n").arg(testCount).arg(t.elapsed())); + + return report; +} + +TQString PerfTest::paintViewFPSTest() +{ + TQString report = TQString("* paintView (fps) test\n\n"); + + TQTime t; + t.restart(); + +#if USE_CALLGRIND + CALLGRIND_ZERO_STATS(); +#endif + + int numViewsPainted = 0; + const int millisecondsPerSecond = 1000; + + while (t.elapsed() < millisecondsPerSecond) { + m_view->getCanvasController()->updateCanvas(); + numViewsPainted++; + } + +#if USE_CALLGRIND + CALLGRIND_DUMP_STATS(); +#endif + + report = report.append(TQString(" painted current view at %1 frames per second\n").arg(numViewsPainted)); + + return report; +} + +#include "perftest.moc" diff --git a/chalk/plugins/viewplugins/rotateimage/Makefile.am b/chalk/plugins/viewplugins/rotateimage/Makefile.am index 23839eca..e5d84219 100644 --- a/chalk/plugins/viewplugins/rotateimage/Makefile.am +++ b/chalk/plugins/viewplugins/rotateimage/Makefile.am @@ -13,7 +13,7 @@ INCLUDES = -I$(srcdir)/../../../sdk \ kde_module_LTLIBRARIES = chalkrotateimage.la -chalkrotateimage_la_SOURCES = wdg_rotateimage.ui rotateimage.cc dlg_rotateimage.cc +chalkrotateimage_la_SOURCES = wdg_rotateimage.ui rotateimage.cpp dlg_rotateimage.cpp noinst_HEADERS = wdg_rotateimage.h dlg_rotateimage.h rotateimage.h chalkrotateimage_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) $(LIB_QT) -ltdecore -ltdeui -lkjs -ltdefx -ltdeio -ltdeparts diff --git a/chalk/plugins/viewplugins/rotateimage/dlg_rotateimage.cc b/chalk/plugins/viewplugins/rotateimage/dlg_rotateimage.cc deleted file mode 100644 index 84c11ffb..00000000 --- a/chalk/plugins/viewplugins/rotateimage/dlg_rotateimage.cc +++ /dev/null @@ -1,147 +0,0 @@ -/* - * dlg_rotateimage.cc - part of KimageShop^WKrayon^WChalk - * - * Copyright (c) 2004 Michael Thaler - * - * 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 - -#include - -#include - -using namespace std; - -#include -#include -#include -#include - -#include -#include -#include - -#include "dlg_rotateimage.h" -#include "wdg_rotateimage.h" - - -DlgRotateImage::DlgRotateImage( TQWidget * parent, - const char * name) - : super (parent, name, true, i18n("Rotate Image"), Ok | Cancel, Ok) -{ - m_lock = false; - - m_page = new WdgRotateImage(this, "rotate_image"); - TQ_CHECK_PTR(m_page); - - setMainWidget(m_page); - resize(m_page->sizeHint()); - - connect(this, TQT_SIGNAL(okClicked()), - this, TQT_SLOT(okClicked())); - connect( m_page->doubleCustom, TQT_SIGNAL( valueChanged ( double ) ), - this, TQT_SLOT( slotAngleValueChanged( double ) ) ); - -} - -DlgRotateImage::~DlgRotateImage() -{ - delete m_page; -} - -void DlgRotateImage::slotAngleValueChanged( double ) -{ - m_page->radioCustom->setChecked(true); -} - -void DlgRotateImage::setAngle(double angle) -{ - if (angle == 90) { - m_page->radio90->setChecked(true); - } - else if (angle == 180) { - m_page->radio180->setChecked(true); - } - else if (angle == 270) { - m_page->radio270->setChecked(true); - } - else { - m_page->radioCustom->setChecked(true); - m_page->doubleCustom->setValue(angle); - } - - if (m_oldAngle != angle) - resetPreview(); - - m_oldAngle = angle; - -} - -double DlgRotateImage::angle() -{ - double angle = 0; - if (m_page->radio90->isChecked()) { - angle = 90; - } - else if (m_page->radio180->isChecked()) { - angle = 180; - } - else if (m_page->radio270->isChecked()) { - angle = 270; - } - else { - angle = tqRound(m_page->doubleCustom->value()); - } - if (m_page->radioCW->isChecked()) { - return angle; - } - else { - return -angle; - } -} - -void DlgRotateImage::setDirection (enumRotationDirection direction) -{ - if (direction == CLOCKWISE) { - m_page->radioCW->setChecked(true); - } - else if (direction== COUNTERCLOCKWISE) { - m_page->radioCCW->setChecked(true); - } -} - -enumRotationDirection DlgRotateImage::direction() -{ - if (m_page->radioCCW->isChecked()) { - return COUNTERCLOCKWISE; - } - else { - return CLOCKWISE; - } -} - -void DlgRotateImage::okClicked() -{ - accept(); -} - -void DlgRotateImage::resetPreview() -{ - // Code to update preview here. -} - -#include "dlg_rotateimage.moc" diff --git a/chalk/plugins/viewplugins/rotateimage/dlg_rotateimage.cpp b/chalk/plugins/viewplugins/rotateimage/dlg_rotateimage.cpp new file mode 100644 index 00000000..e7c3a8ce --- /dev/null +++ b/chalk/plugins/viewplugins/rotateimage/dlg_rotateimage.cpp @@ -0,0 +1,147 @@ +/* + * dlg_rotateimage.cpp - part of KimageShop^WKrayon^WChalk + * + * Copyright (c) 2004 Michael Thaler + * + * 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 + +#include + +#include + +using namespace std; + +#include +#include +#include +#include + +#include +#include +#include + +#include "dlg_rotateimage.h" +#include "wdg_rotateimage.h" + + +DlgRotateImage::DlgRotateImage( TQWidget * parent, + const char * name) + : super (parent, name, true, i18n("Rotate Image"), Ok | Cancel, Ok) +{ + m_lock = false; + + m_page = new WdgRotateImage(this, "rotate_image"); + TQ_CHECK_PTR(m_page); + + setMainWidget(m_page); + resize(m_page->sizeHint()); + + connect(this, TQT_SIGNAL(okClicked()), + this, TQT_SLOT(okClicked())); + connect( m_page->doubleCustom, TQT_SIGNAL( valueChanged ( double ) ), + this, TQT_SLOT( slotAngleValueChanged( double ) ) ); + +} + +DlgRotateImage::~DlgRotateImage() +{ + delete m_page; +} + +void DlgRotateImage::slotAngleValueChanged( double ) +{ + m_page->radioCustom->setChecked(true); +} + +void DlgRotateImage::setAngle(double angle) +{ + if (angle == 90) { + m_page->radio90->setChecked(true); + } + else if (angle == 180) { + m_page->radio180->setChecked(true); + } + else if (angle == 270) { + m_page->radio270->setChecked(true); + } + else { + m_page->radioCustom->setChecked(true); + m_page->doubleCustom->setValue(angle); + } + + if (m_oldAngle != angle) + resetPreview(); + + m_oldAngle = angle; + +} + +double DlgRotateImage::angle() +{ + double angle = 0; + if (m_page->radio90->isChecked()) { + angle = 90; + } + else if (m_page->radio180->isChecked()) { + angle = 180; + } + else if (m_page->radio270->isChecked()) { + angle = 270; + } + else { + angle = tqRound(m_page->doubleCustom->value()); + } + if (m_page->radioCW->isChecked()) { + return angle; + } + else { + return -angle; + } +} + +void DlgRotateImage::setDirection (enumRotationDirection direction) +{ + if (direction == CLOCKWISE) { + m_page->radioCW->setChecked(true); + } + else if (direction== COUNTERCLOCKWISE) { + m_page->radioCCW->setChecked(true); + } +} + +enumRotationDirection DlgRotateImage::direction() +{ + if (m_page->radioCCW->isChecked()) { + return COUNTERCLOCKWISE; + } + else { + return CLOCKWISE; + } +} + +void DlgRotateImage::okClicked() +{ + accept(); +} + +void DlgRotateImage::resetPreview() +{ + // Code to update preview here. +} + +#include "dlg_rotateimage.moc" diff --git a/chalk/plugins/viewplugins/rotateimage/rotateimage.cc b/chalk/plugins/viewplugins/rotateimage/rotateimage.cc deleted file mode 100644 index 8a0985cc..00000000 --- a/chalk/plugins/viewplugins/rotateimage/rotateimage.cc +++ /dev/null @@ -1,134 +0,0 @@ -/* - * rotateimage.cc -- Part of Chalk - * - * Copyright (c) 2004 Michael Thaler - * - * 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 - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "rotateimage.h" -#include "dlg_rotateimage.h" - -typedef KGenericFactory RotateImageFactory; -K_EXPORT_COMPONENT_FACTORY( chalkrotateimage, RotateImageFactory( "chalk" ) ) - -// XXX: this plugin could also provide layer scaling/resizing -RotateImage::RotateImage(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - - if ( parent->inherits("KisView") ) { - setInstance(RotateImageFactory::instance()); - setXMLFile(locate("data","chalkplugins/rotateimage.rc"), true); - m_view = (KisView*) parent; - (void) new TDEAction(i18n("&Rotate Image..."), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(slotRotateImage()), actionCollection(), "rotateimage"); - (void) new TDEAction(i18n("Rotate Image CW"), "object-rotate-right", 0, TQT_TQOBJECT(this), TQT_SLOT(slotRotateImage90()), actionCollection(), "rotateImageCW90"); - (void) new TDEAction(i18n("Rotate Image 1&80"), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(slotRotateImage180()), actionCollection(), "rotateImage180"); - (void) new TDEAction(i18n("Rotate Image CCW"), "object-rotate-left", 0, TQT_TQOBJECT(this), TQT_SLOT(slotRotateImage270()), actionCollection(), "rotateImageCCW90"); - - (void) new TDEAction(i18n("&Rotate Layer..."), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(slotRotateLayer()), actionCollection(), "rotatelayer"); - - (void)new TDEAction(i18n("Rotate 1&80"), 0, TQT_TQOBJECT(m_view), TQT_SLOT(rotateLayer180()), actionCollection(), "rotateLayer180"); - (void)new TDEAction(i18n("Rotate CCW"), "object-rotate-left", 0, TQT_TQOBJECT(m_view), TQT_SLOT(rotateLayerLeft90()), actionCollection(), "rotateLayerCCW90"); - (void)new TDEAction(i18n("Rotate CW"), "object-rotate-right", 0, TQT_TQOBJECT(m_view), TQT_SLOT(rotateLayerRight90()), actionCollection(), "rotateLayerCW90"); - } -} - -RotateImage::~RotateImage() -{ - m_view = 0; -} - -void RotateImage::slotRotateImage() -{ - KisImageSP image = m_view->canvasSubject()->currentImg(); - - if (!image) return; - - DlgRotateImage * dlgRotateImage = new DlgRotateImage(m_view, "RotateImage"); - TQ_CHECK_PTR(dlgRotateImage); - - dlgRotateImage->setCaption(i18n("Rotate Image")); - - if (dlgRotateImage->exec() == TQDialog::Accepted) { - double angle = dlgRotateImage->angle(); - angle *= M_PI/180; - m_view->rotateCurrentImage(angle); - } - delete dlgRotateImage; -} - -void RotateImage::slotRotateImage90() -{ - m_view->rotateCurrentImage( M_PI/2); -} - -void RotateImage::slotRotateImage180() -{ - m_view->rotateCurrentImage( M_PI ); -} - - -void RotateImage::slotRotateImage270() -{ - m_view->rotateCurrentImage( - M_PI/2 + M_PI*2 ); -} - -void RotateImage::slotRotateLayer() -{ - KisImageSP image = m_view->canvasSubject()->currentImg(); - - if (!image) return; - - DlgRotateImage * dlgRotateImage = new DlgRotateImage(m_view, "RotateLayer"); - TQ_CHECK_PTR(dlgRotateImage); - - dlgRotateImage->setCaption(i18n("Rotate Layer")); - - if (dlgRotateImage->exec() == TQDialog::Accepted) { - double angle = dlgRotateImage->angle(); - angle *= M_PI/180; - m_view->rotateLayer(angle); - } - delete dlgRotateImage; -} - -#include "rotateimage.moc" diff --git a/chalk/plugins/viewplugins/rotateimage/rotateimage.cpp b/chalk/plugins/viewplugins/rotateimage/rotateimage.cpp new file mode 100644 index 00000000..f58f7816 --- /dev/null +++ b/chalk/plugins/viewplugins/rotateimage/rotateimage.cpp @@ -0,0 +1,134 @@ +/* + * rotateimage.cpp -- Part of Chalk + * + * Copyright (c) 2004 Michael Thaler + * + * 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 + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "rotateimage.h" +#include "dlg_rotateimage.h" + +typedef KGenericFactory RotateImageFactory; +K_EXPORT_COMPONENT_FACTORY( chalkrotateimage, RotateImageFactory( "chalk" ) ) + +// XXX: this plugin could also provide layer scaling/resizing +RotateImage::RotateImage(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + + if ( parent->inherits("KisView") ) { + setInstance(RotateImageFactory::instance()); + setXMLFile(locate("data","chalkplugins/rotateimage.rc"), true); + m_view = (KisView*) parent; + (void) new TDEAction(i18n("&Rotate Image..."), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(slotRotateImage()), actionCollection(), "rotateimage"); + (void) new TDEAction(i18n("Rotate Image CW"), "object-rotate-right", 0, TQT_TQOBJECT(this), TQT_SLOT(slotRotateImage90()), actionCollection(), "rotateImageCW90"); + (void) new TDEAction(i18n("Rotate Image 1&80"), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(slotRotateImage180()), actionCollection(), "rotateImage180"); + (void) new TDEAction(i18n("Rotate Image CCW"), "object-rotate-left", 0, TQT_TQOBJECT(this), TQT_SLOT(slotRotateImage270()), actionCollection(), "rotateImageCCW90"); + + (void) new TDEAction(i18n("&Rotate Layer..."), 0, 0, TQT_TQOBJECT(this), TQT_SLOT(slotRotateLayer()), actionCollection(), "rotatelayer"); + + (void)new TDEAction(i18n("Rotate 1&80"), 0, TQT_TQOBJECT(m_view), TQT_SLOT(rotateLayer180()), actionCollection(), "rotateLayer180"); + (void)new TDEAction(i18n("Rotate CCW"), "object-rotate-left", 0, TQT_TQOBJECT(m_view), TQT_SLOT(rotateLayerLeft90()), actionCollection(), "rotateLayerCCW90"); + (void)new TDEAction(i18n("Rotate CW"), "object-rotate-right", 0, TQT_TQOBJECT(m_view), TQT_SLOT(rotateLayerRight90()), actionCollection(), "rotateLayerCW90"); + } +} + +RotateImage::~RotateImage() +{ + m_view = 0; +} + +void RotateImage::slotRotateImage() +{ + KisImageSP image = m_view->canvasSubject()->currentImg(); + + if (!image) return; + + DlgRotateImage * dlgRotateImage = new DlgRotateImage(m_view, "RotateImage"); + TQ_CHECK_PTR(dlgRotateImage); + + dlgRotateImage->setCaption(i18n("Rotate Image")); + + if (dlgRotateImage->exec() == TQDialog::Accepted) { + double angle = dlgRotateImage->angle(); + angle *= M_PI/180; + m_view->rotateCurrentImage(angle); + } + delete dlgRotateImage; +} + +void RotateImage::slotRotateImage90() +{ + m_view->rotateCurrentImage( M_PI/2); +} + +void RotateImage::slotRotateImage180() +{ + m_view->rotateCurrentImage( M_PI ); +} + + +void RotateImage::slotRotateImage270() +{ + m_view->rotateCurrentImage( - M_PI/2 + M_PI*2 ); +} + +void RotateImage::slotRotateLayer() +{ + KisImageSP image = m_view->canvasSubject()->currentImg(); + + if (!image) return; + + DlgRotateImage * dlgRotateImage = new DlgRotateImage(m_view, "RotateLayer"); + TQ_CHECK_PTR(dlgRotateImage); + + dlgRotateImage->setCaption(i18n("Rotate Layer")); + + if (dlgRotateImage->exec() == TQDialog::Accepted) { + double angle = dlgRotateImage->angle(); + angle *= M_PI/180; + m_view->rotateLayer(angle); + } + delete dlgRotateImage; +} + +#include "rotateimage.moc" diff --git a/chalk/plugins/viewplugins/scripting/Makefile.am b/chalk/plugins/viewplugins/scripting/Makefile.am index be88f9b8..f4084a46 100644 --- a/chalk/plugins/viewplugins/scripting/Makefile.am +++ b/chalk/plugins/viewplugins/scripting/Makefile.am @@ -15,7 +15,7 @@ INCLUDES = -I$(top_srcdir)/chalk/sdk \ $(KOFFICE_INCLUDES) \ $(all_includes) -chalkscripting_la_SOURCES = scripting.cc +chalkscripting_la_SOURCES = scripting.cpp kde_module_LTLIBRARIES = chalkscripting.la noinst_HEADERS = scripting.h diff --git a/chalk/plugins/viewplugins/scripting/scripting.cc b/chalk/plugins/viewplugins/scripting/scripting.cc deleted file mode 100644 index 207bc0ce..00000000 --- a/chalk/plugins/viewplugins/scripting/scripting.cc +++ /dev/null @@ -1,111 +0,0 @@ -/* - * This file is part of the KDE project - * - * Copyright (c) 2005 Cyrille Berger - * 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 "scripting.h" - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define KROSS_MAIN_EXPORT KDE_EXPORT -#include
-#include
-#include
- -#include - -#include -#include -#include -#include -#include -#include - -#include "chalkscripting/kis_script_progress.h" -#include "chalkscripting/kis_script_monitor.h" - -typedef KGenericFactory ChalkScriptingFactory; -K_EXPORT_COMPONENT_FACTORY( chalkscripting, ChalkScriptingFactory( "chalk" ) ) - -Scripting::Scripting(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - setInstance(ChalkScriptingFactory::instance()); - - - if ( parent->inherits("KisView") ) - { - setInstance(Scripting::instance()); - m_view = (KisView*) parent; - m_scriptguiclient = new Kross::Api::ScriptGUIClient( m_view, m_view ); -// m_scriptguiclient ->setXMLFile(locate("data","chalkplugins/scripting.rc"), true); - //BEGIN TODO: understand why the ScriptGUIClient doesn't "link" its actions to the menu - setXMLFile(locate("data","chalkplugins/scripting.rc"), true); - new TDEAction(i18n("Execute Script File..."), 0, 0, m_scriptguiclient, TQT_SLOT(executeScriptFile()), actionCollection(), "executescriptfile"); - new TDEAction(i18n("Script Manager..."), 0, 0, m_scriptguiclient, TQT_SLOT(showScriptManager()), actionCollection(), "configurescripts"); - //END TODO - - TQWidget * w = new Kross::Api::WdgScriptsManager(m_scriptguiclient, m_view); - - m_view->canvasSubject()->paletteManager()->addWidget(w, "Scripts Manager", chalk::LAYERBOX, 10, PALETTE_DOCKER, false); - - connect(m_scriptguiclient, TQT_SIGNAL(executionFinished( const Kross::Api::ScriptAction* )), this, TQT_SLOT(executionFinished(const Kross::Api::ScriptAction*))); - connect(m_scriptguiclient, TQT_SIGNAL(executionStarted( const Kross::Api::ScriptAction* )), this, TQT_SLOT(executionStarted(const Kross::Api::ScriptAction*))); - KisScriptMonitor::instance()->monitor( m_scriptguiclient ); - - Kross::Api::Manager::scriptManager()->addTQObject(m_view->canvasSubject()->document(), "ChalkDocument"); - Kross::Api::Manager::scriptManager()->addTQObject(TQT_TQOBJECT(m_view), "ChalkView"); - m_scriptProgress = new KisScriptProgress(m_view); - Kross::Api::Manager::scriptManager()->addTQObject(m_scriptProgress, "ChalkScriptProgress"); - - } - -} - -Scripting::~Scripting() -{ -} - -void Scripting::executionFinished(const Kross::Api::ScriptAction*) -{ - m_view->canvasSubject()->document()->setModified(true); - m_view->canvasSubject()->document()->currentImage()->activeLayer()->setDirty(); - m_scriptProgress->progressDone(); - TQApplication::restoreOverrideCursor(); -} - -void Scripting::executionStarted(const Kross::Api::ScriptAction* act) -{ - kdDebug(41011) << act->getPackagePath() << endl; - m_scriptProgress->setPackagePath( act->getPackagePath() ); -} - - -#include "scripting.moc" diff --git a/chalk/plugins/viewplugins/scripting/scripting.cpp b/chalk/plugins/viewplugins/scripting/scripting.cpp new file mode 100644 index 00000000..207bc0ce --- /dev/null +++ b/chalk/plugins/viewplugins/scripting/scripting.cpp @@ -0,0 +1,111 @@ +/* + * This file is part of the KDE project + * + * Copyright (c) 2005 Cyrille Berger + * 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 "scripting.h" + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define KROSS_MAIN_EXPORT KDE_EXPORT +#include
+#include
+#include
+ +#include + +#include +#include +#include +#include +#include +#include + +#include "chalkscripting/kis_script_progress.h" +#include "chalkscripting/kis_script_monitor.h" + +typedef KGenericFactory ChalkScriptingFactory; +K_EXPORT_COMPONENT_FACTORY( chalkscripting, ChalkScriptingFactory( "chalk" ) ) + +Scripting::Scripting(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + setInstance(ChalkScriptingFactory::instance()); + + + if ( parent->inherits("KisView") ) + { + setInstance(Scripting::instance()); + m_view = (KisView*) parent; + m_scriptguiclient = new Kross::Api::ScriptGUIClient( m_view, m_view ); +// m_scriptguiclient ->setXMLFile(locate("data","chalkplugins/scripting.rc"), true); + //BEGIN TODO: understand why the ScriptGUIClient doesn't "link" its actions to the menu + setXMLFile(locate("data","chalkplugins/scripting.rc"), true); + new TDEAction(i18n("Execute Script File..."), 0, 0, m_scriptguiclient, TQT_SLOT(executeScriptFile()), actionCollection(), "executescriptfile"); + new TDEAction(i18n("Script Manager..."), 0, 0, m_scriptguiclient, TQT_SLOT(showScriptManager()), actionCollection(), "configurescripts"); + //END TODO + + TQWidget * w = new Kross::Api::WdgScriptsManager(m_scriptguiclient, m_view); + + m_view->canvasSubject()->paletteManager()->addWidget(w, "Scripts Manager", chalk::LAYERBOX, 10, PALETTE_DOCKER, false); + + connect(m_scriptguiclient, TQT_SIGNAL(executionFinished( const Kross::Api::ScriptAction* )), this, TQT_SLOT(executionFinished(const Kross::Api::ScriptAction*))); + connect(m_scriptguiclient, TQT_SIGNAL(executionStarted( const Kross::Api::ScriptAction* )), this, TQT_SLOT(executionStarted(const Kross::Api::ScriptAction*))); + KisScriptMonitor::instance()->monitor( m_scriptguiclient ); + + Kross::Api::Manager::scriptManager()->addTQObject(m_view->canvasSubject()->document(), "ChalkDocument"); + Kross::Api::Manager::scriptManager()->addTQObject(TQT_TQOBJECT(m_view), "ChalkView"); + m_scriptProgress = new KisScriptProgress(m_view); + Kross::Api::Manager::scriptManager()->addTQObject(m_scriptProgress, "ChalkScriptProgress"); + + } + +} + +Scripting::~Scripting() +{ +} + +void Scripting::executionFinished(const Kross::Api::ScriptAction*) +{ + m_view->canvasSubject()->document()->setModified(true); + m_view->canvasSubject()->document()->currentImage()->activeLayer()->setDirty(); + m_scriptProgress->progressDone(); + TQApplication::restoreOverrideCursor(); +} + +void Scripting::executionStarted(const Kross::Api::ScriptAction* act) +{ + kdDebug(41011) << act->getPackagePath() << endl; + m_scriptProgress->setPackagePath( act->getPackagePath() ); +} + + +#include "scripting.moc" diff --git a/chalk/plugins/viewplugins/selectopaque/Makefile.am b/chalk/plugins/viewplugins/selectopaque/Makefile.am index 731e091c..63efe384 100644 --- a/chalk/plugins/viewplugins/selectopaque/Makefile.am +++ b/chalk/plugins/viewplugins/selectopaque/Makefile.am @@ -7,7 +7,7 @@ INCLUDES = -I$(srcdir)/../../../sdk \ kde_module_LTLIBRARIES = chalkselectopaque.la -chalkselectopaque_la_SOURCES = selectopaque.cc +chalkselectopaque_la_SOURCES = selectopaque.cpp noinst_HEADERS = selectopaque.h chalkselectopaque_la_LIBADD = $(LIB_KOFFICEUI) ../../../libchalkcommon.la \ diff --git a/chalk/plugins/viewplugins/selectopaque/selectopaque.cc b/chalk/plugins/viewplugins/selectopaque/selectopaque.cc deleted file mode 100644 index 61d85634..00000000 --- a/chalk/plugins/viewplugins/selectopaque/selectopaque.cc +++ /dev/null @@ -1,116 +0,0 @@ -/* - * selectopague.h -- Part of Chalk - * - * Copyright (c) 2004 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 - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "selectopaque.h" - -typedef KGenericFactory SelectOpaqueFactory; -K_EXPORT_COMPONENT_FACTORY( chalkselectopaque, SelectOpaqueFactory( "chalk" ) ) - -SelectOpaque::SelectOpaque(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - - if (parent->inherits("KisView")) { - setInstance(SelectOpaqueFactory::instance()); - setXMLFile(locate("data","chalkplugins/selectopaque.rc"), true); - m_view = dynamic_cast(parent); - m_view->canvasSubject()->selectionManager()->addSelectionAction( new TDEAction(i18n("&Select All Opaque Pixels..."), 0, 0, this, TQT_SLOT(slotActivated()), actionCollection(), "selectopaque") ); - - } -} - -SelectOpaque::~SelectOpaque() -{ -} - -void SelectOpaque::slotActivated() -{ - KisSelectedTransaction *transaction; - - KisPaintDeviceSP layer = m_view->canvasSubject()->currentImg()->activeDevice(); - if (!layer) return; - TQApplication::setOverrideCursor(KisCursor::waitCursor()); - - if (layer->image()->undo()) transaction = new KisSelectedTransaction(i18n("Select Opaque Pixels"), layer); - // XXX: Multithread this! - TQ_INT32 x, y, w, h; - layer->exactBounds(x, y, w, h); - - KisColorSpace * cs = layer->colorSpace(); - - if(! layer->hasSelection()) - layer->selection()->clear(); - KisSelectionSP selection = layer->selection(); - - KisHLineIterator hiter = layer->createHLineIterator(x, y, w, false); - KisHLineIterator selIter = selection ->createHLineIterator(x, y, w, true); - - for (int row = 0; row < h; ++row) { - while (!hiter.isDone()) { - // Don't try to select transparent pixels. - if (cs->getAlpha( hiter.rawData() ) > OPACITY_TRANSPARENT) { - *(selIter.rawData()) = MAX_SELECTED; - } - ++hiter; - ++selIter; - } - hiter.nextRow(); - selIter.nextRow(); - } - TQApplication::restoreOverrideCursor(); - layer->setDirty(); - layer->emitSelectionChanged(); - - if (layer->image()->undo()) m_view->canvasSubject()->undoAdapter()->addCommand(transaction); - -} - -#include "selectopaque.moc" - diff --git a/chalk/plugins/viewplugins/selectopaque/selectopaque.cpp b/chalk/plugins/viewplugins/selectopaque/selectopaque.cpp new file mode 100644 index 00000000..61d85634 --- /dev/null +++ b/chalk/plugins/viewplugins/selectopaque/selectopaque.cpp @@ -0,0 +1,116 @@ +/* + * selectopague.h -- Part of Chalk + * + * Copyright (c) 2004 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 + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "selectopaque.h" + +typedef KGenericFactory SelectOpaqueFactory; +K_EXPORT_COMPONENT_FACTORY( chalkselectopaque, SelectOpaqueFactory( "chalk" ) ) + +SelectOpaque::SelectOpaque(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + + if (parent->inherits("KisView")) { + setInstance(SelectOpaqueFactory::instance()); + setXMLFile(locate("data","chalkplugins/selectopaque.rc"), true); + m_view = dynamic_cast(parent); + m_view->canvasSubject()->selectionManager()->addSelectionAction( new TDEAction(i18n("&Select All Opaque Pixels..."), 0, 0, this, TQT_SLOT(slotActivated()), actionCollection(), "selectopaque") ); + + } +} + +SelectOpaque::~SelectOpaque() +{ +} + +void SelectOpaque::slotActivated() +{ + KisSelectedTransaction *transaction; + + KisPaintDeviceSP layer = m_view->canvasSubject()->currentImg()->activeDevice(); + if (!layer) return; + TQApplication::setOverrideCursor(KisCursor::waitCursor()); + + if (layer->image()->undo()) transaction = new KisSelectedTransaction(i18n("Select Opaque Pixels"), layer); + // XXX: Multithread this! + TQ_INT32 x, y, w, h; + layer->exactBounds(x, y, w, h); + + KisColorSpace * cs = layer->colorSpace(); + + if(! layer->hasSelection()) + layer->selection()->clear(); + KisSelectionSP selection = layer->selection(); + + KisHLineIterator hiter = layer->createHLineIterator(x, y, w, false); + KisHLineIterator selIter = selection ->createHLineIterator(x, y, w, true); + + for (int row = 0; row < h; ++row) { + while (!hiter.isDone()) { + // Don't try to select transparent pixels. + if (cs->getAlpha( hiter.rawData() ) > OPACITY_TRANSPARENT) { + *(selIter.rawData()) = MAX_SELECTED; + } + ++hiter; + ++selIter; + } + hiter.nextRow(); + selIter.nextRow(); + } + TQApplication::restoreOverrideCursor(); + layer->setDirty(); + layer->emitSelectionChanged(); + + if (layer->image()->undo()) m_view->canvasSubject()->undoAdapter()->addCommand(transaction); + +} + +#include "selectopaque.moc" + diff --git a/chalk/plugins/viewplugins/separate_channels/Makefile.am b/chalk/plugins/viewplugins/separate_channels/Makefile.am index eef7853d..15cdc0fd 100644 --- a/chalk/plugins/viewplugins/separate_channels/Makefile.am +++ b/chalk/plugins/viewplugins/separate_channels/Makefile.am @@ -12,8 +12,8 @@ INCLUDES = -I$(srcdir)/../../../sdk \ kde_module_LTLIBRARIES = chalkseparatechannels.la chalkseparatechannels_la_SOURCES = wdg_separations.ui \ - kis_channel_separator.cc dlg_separate.cc \ - kis_separate_channels_plugin.cc + kis_channel_separator.cpp dlg_separate.cpp \ + kis_separate_channels_plugin.cpp noinst_HEADERS = wdg_separations.h kis_separate_channels_plugin.h \ kis_channel_separator.h dlg_separate.h diff --git a/chalk/plugins/viewplugins/separate_channels/dlg_separate.cc b/chalk/plugins/viewplugins/separate_channels/dlg_separate.cc deleted file mode 100644 index 6d2a59c3..00000000 --- a/chalk/plugins/viewplugins/separate_channels/dlg_separate.cc +++ /dev/null @@ -1,110 +0,0 @@ -/* - * dlg_separate.cc - part of KimageShop^WKrayon^WChalk - * - * Copyright (c) 2004 Boudewijn Rempt - * - * 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 -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "dlg_separate.h" -#include "wdg_separations.h" - -DlgSeparate::DlgSeparate( const TQString & imageCS, - const TQString & layerCS, - TQWidget * parent, - const char * name) - : super (parent, name, true, i18n("Separate Image"), Ok | Cancel, Ok), - m_imageCS(imageCS), - m_layerCS(layerCS) -{ - m_page = new WdgSeparations(this, "separate_image"); - TQ_CHECK_PTR(m_page); - setMainWidget(m_page); - resize(m_page->sizeHint()); - - m_page->lblColormodel->setText(layerCS); - m_page->grpOutput->hide(); - connect(m_page->grpSource, TQT_SIGNAL(clicked(int)), this, TQT_SLOT(slotSetColorSpaceLabel(int))); - connect(m_page->chkColors, TQT_SIGNAL(toggled(bool)), m_page->chkDownscale, TQT_SLOT(setDisabled(bool))); - - connect(this, TQT_SIGNAL(okClicked()), - this, TQT_SLOT(okClicked())); -} - -DlgSeparate::~DlgSeparate() -{ - delete m_page; -} - - - -enumSepAlphaOptions DlgSeparate::getAlphaOptions() -{ - return (enumSepAlphaOptions)m_page->grpAlpha->selectedId(); -} - -enumSepSource DlgSeparate::getSource() -{ - return (enumSepSource)m_page->grpSource->selectedId(); -} - -enumSepOutput DlgSeparate::getOutput() -{ - return (enumSepOutput)m_page->grpOutput->selectedId(); -} - - -bool DlgSeparate::getDownscale() -{ - return m_page->chkDownscale->isChecked(); -} - -bool DlgSeparate::getToColor() -{ - return m_page->chkColors->isChecked(); -} - -// SLOTS - -void DlgSeparate::okClicked() -{ - accept(); -} - -void DlgSeparate::slotSetColorSpaceLabel(int buttonid) -{ - if (buttonid == 0) { - m_page->lblColormodel->setText(m_layerCS); - } - else { - m_page->lblColormodel->setText(m_imageCS); - } -} -void DlgSeparate::enableDownscale(bool enable) { - m_page->chkDownscale->setEnabled(enable); -} - -#include "dlg_separate.moc" diff --git a/chalk/plugins/viewplugins/separate_channels/dlg_separate.cpp b/chalk/plugins/viewplugins/separate_channels/dlg_separate.cpp new file mode 100644 index 00000000..d650a045 --- /dev/null +++ b/chalk/plugins/viewplugins/separate_channels/dlg_separate.cpp @@ -0,0 +1,110 @@ +/* + * dlg_separate.cpp - part of KimageShop^WKrayon^WChalk + * + * Copyright (c) 2004 Boudewijn Rempt + * + * 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 +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "dlg_separate.h" +#include "wdg_separations.h" + +DlgSeparate::DlgSeparate( const TQString & imageCS, + const TQString & layerCS, + TQWidget * parent, + const char * name) + : super (parent, name, true, i18n("Separate Image"), Ok | Cancel, Ok), + m_imageCS(imageCS), + m_layerCS(layerCS) +{ + m_page = new WdgSeparations(this, "separate_image"); + TQ_CHECK_PTR(m_page); + setMainWidget(m_page); + resize(m_page->sizeHint()); + + m_page->lblColormodel->setText(layerCS); + m_page->grpOutput->hide(); + connect(m_page->grpSource, TQT_SIGNAL(clicked(int)), this, TQT_SLOT(slotSetColorSpaceLabel(int))); + connect(m_page->chkColors, TQT_SIGNAL(toggled(bool)), m_page->chkDownscale, TQT_SLOT(setDisabled(bool))); + + connect(this, TQT_SIGNAL(okClicked()), + this, TQT_SLOT(okClicked())); +} + +DlgSeparate::~DlgSeparate() +{ + delete m_page; +} + + + +enumSepAlphaOptions DlgSeparate::getAlphaOptions() +{ + return (enumSepAlphaOptions)m_page->grpAlpha->selectedId(); +} + +enumSepSource DlgSeparate::getSource() +{ + return (enumSepSource)m_page->grpSource->selectedId(); +} + +enumSepOutput DlgSeparate::getOutput() +{ + return (enumSepOutput)m_page->grpOutput->selectedId(); +} + + +bool DlgSeparate::getDownscale() +{ + return m_page->chkDownscale->isChecked(); +} + +bool DlgSeparate::getToColor() +{ + return m_page->chkColors->isChecked(); +} + +// SLOTS + +void DlgSeparate::okClicked() +{ + accept(); +} + +void DlgSeparate::slotSetColorSpaceLabel(int buttonid) +{ + if (buttonid == 0) { + m_page->lblColormodel->setText(m_layerCS); + } + else { + m_page->lblColormodel->setText(m_imageCS); + } +} +void DlgSeparate::enableDownscale(bool enable) { + m_page->chkDownscale->setEnabled(enable); +} + +#include "dlg_separate.moc" diff --git a/chalk/plugins/viewplugins/separate_channels/kis_channel_separator.cc b/chalk/plugins/viewplugins/separate_channels/kis_channel_separator.cc deleted file mode 100644 index ba8c6b84..00000000 --- a/chalk/plugins/viewplugins/separate_channels/kis_channel_separator.cc +++ /dev/null @@ -1,301 +0,0 @@ -/* - * This file is part of Chalk - * - * Copyright (c) 2005 Michael Thaler - * - * ported from Gimp, Copyright (C) 1997 Eiichi Takamori - * original pixelize.c for GIMP 0.54 by Tracy Scott - * - * 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 - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#include - -#include -#include -#include "kis_meta_registry.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "kis_channel_separator.h" - -KisChannelSeparator::KisChannelSeparator(KisView * view) - : m_view(view) -{ -} - -void KisChannelSeparator::separate(KisProgressDisplayInterface * progress, enumSepAlphaOptions alphaOps, enumSepSource sourceOps, enumSepOutput outputOps, bool downscale, bool toColor) -{ - KisImageSP image = m_view->canvasSubject()->currentImg(); - if (!image) return; - - KisLayerSP layer = image->activeLayer(); - if (!layer) return; - - KisPaintDeviceSP src = image->activeDevice(); - if (!src) return; - - m_cancelRequested = false; - if ( progress ) - progress->setSubject(this, true, true); - emit notifyProgressStage(i18n("Separating image..."), 0); - - KisColorSpace * dstCs = 0; - - TQ_UINT32 numberOfChannels = src->nChannels(); - KisColorSpace * srcCs = src->colorSpace(); - TQValueVector channels = srcCs->channels(); - - // Use the flattened image, if required - switch(sourceOps) { - - case(ALL_LAYERS): - src = image->mergedImage(); - break; - default: - break; - } - - vKisPaintDeviceSP layers; - - TQValueVector::const_iterator begin = channels.begin(); - TQValueVector::const_iterator end = channels.end(); - - - TQRect rect = src->exactBounds(); - - int i = 0; - TQ_UINT32 channelIndex = 0; - for (TQValueVector::const_iterator it = begin; it != end; ++it, ++channelIndex) - { - - KisChannelInfo * ch = (*it); - - if (ch->channelType() == KisChannelInfo::ALPHA && alphaOps != CREATE_ALPHA_SEPARATION) { - continue; - } - - TQ_INT32 channelSize = ch->size(); - TQ_INT32 channelPos = ch->pos(); - TQ_INT32 destSize = 1; - - KisPaintDeviceSP dev; - if (toColor) { - // We don't downscale if we separate to color channels - dev = new KisPaintDevice(srcCs, "color separations"); - } - else { - if (channelSize == 1 || downscale) { - dev = new KisPaintDevice( KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("GRAYA",""),"" ), "8 bit grayscale sep"); - } - else { - dev = new KisPaintDevice( KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("GRAYA16",""),"" ), "16 bit grayscale sep"); - destSize = 2; - } - } - - dstCs = dev->colorSpace(); - - layers.push_back(dev); - - for (TQ_INT32 row = 0; row < rect.height(); ++row) { - - KisHLineIteratorPixel srcIt = src->createHLineIterator(rect.x(), rect.y() + row, rect.width(), false); - KisHLineIteratorPixel dstIt = dev->createHLineIterator(rect.x(), rect.y() + row, rect.width(), true); - - while( ! srcIt.isDone() ) - { - if (srcIt.isSelected()) - { - if (toColor) { - dstCs->getSingleChannelPixel(dstIt.rawData(), srcIt.rawData(), channelIndex); - - if (alphaOps == COPY_ALPHA_TO_SEPARATIONS) { - //dstCs->setAlpha(dstIt.rawData(), srcIt.rawData()[srcAlphaPos], 1); - dstCs->setAlpha(dstIt.rawData(), srcCs->getAlpha(srcIt.rawData()), 1); - } - else { - dstCs->setAlpha(dstIt.rawData(), OPACITY_OPAQUE, 1); - } - } - else { - - // To grayscale - - // Decide wether we need downscaling - if (channelSize == 1 && destSize == 1) { - - // Both 8-bit channels - dstIt.rawData()[0] = srcIt.rawData()[channelPos]; - - if (alphaOps == COPY_ALPHA_TO_SEPARATIONS) { - dstCs->setAlpha(dstIt.rawData(), srcCs->getAlpha(srcIt.rawData()), 1); - } - else { - dstCs->setAlpha(dstIt.rawData(), OPACITY_OPAQUE, 1); - } - } - else if (channelSize == 2 && destSize == 2) { - - // Both 16-bit - dstIt.rawData()[0] = srcIt.rawData()[channelPos]; - dstIt.rawData()[1] = srcIt.rawData()[channelPos + 1]; - - if (alphaOps == COPY_ALPHA_TO_SEPARATIONS) { - dstCs->setAlpha(dstIt.rawData(), srcCs->getAlpha(srcIt.rawData()), 1); - } - else { - dstCs->setAlpha(dstIt.rawData(), OPACITY_OPAQUE, 1); - } - } - else if (channelSize != 1 && destSize == 1) { - // Downscale - memset(dstIt.rawData(), srcCs->scaleToU8(srcIt.rawData(), channelPos), 1); - - // XXX: Do alpha - dstCs->setAlpha(dstIt.rawData(), OPACITY_OPAQUE, 1); - } - else if (channelSize != 2 && destSize == 2) { - // Upscale - dstIt.rawData()[0] = srcCs->scaleToU8(srcIt.rawData(), channelPos); - - // XXX: Do alpha - dstCs->setAlpha(dstIt.rawData(), OPACITY_OPAQUE, 1); - - } - } - } - ++dstIt; - ++srcIt; - } - } - ++i; - - emit notifyProgress((i * 100) / numberOfChannels); - if (m_cancelRequested) { - break; - } - } - - vKisPaintDeviceSP_it deviceIt = layers.begin(); - - emit notifyProgressDone(); - - if (!m_cancelRequested) { - - KisUndoAdapter * undo = 0; - if ((undo = image->undoAdapter()) && undo->undo()) { - undo->beginMacro(i18n("Separate Image")); - } - - // Flatten the image if required - switch(sourceOps) { - case(ALL_LAYERS): - image->flatten(); - break; - default: - break; - } - - for (TQValueVector::const_iterator it = begin; it != end; ++it) - { - - KisChannelInfo * ch = (*it); - - if (ch->channelType() == KisChannelInfo::ALPHA && alphaOps != CREATE_ALPHA_SEPARATION) { - // Don't make an separate separation of the alpha channel if the user didn't ask for it. - continue; - } - - if (outputOps == TO_LAYERS) { - KisPaintLayerSP l = new KisPaintLayer( image, ch->name(), OPACITY_OPAQUE, *deviceIt); - image->addLayer( dynamic_cast(l.data()), image->rootLayer(), 0); - } - else { - TQStringList listMimeFilter = KoFilterManager::mimeFilter("application/x-chalk", KoFilterManager::Export); - TQString mimelist = listMimeFilter.join(" "); - - KFileDialog fd (TQString(), mimelist, m_view, "Export Layer", true); - fd.setCaption(i18n("Export Layer") + "(" + ch->name() + ")"); - fd.setMimeFilter(listMimeFilter); - fd.setOperationMode(KFileDialog::Saving); - fd.setURL(KURL(ch->name())); - if (!fd.exec()) return; - - KURL url = fd.selectedURL(); - TQString mimefilter = fd.currentMimeFilter(); - - if (url.isEmpty()) - return; - - KisPaintLayerSP l = new KisPaintLayer( image, ch->name(), OPACITY_OPAQUE, *deviceIt); - TQRect r = l->exactBounds(); - - KisDoc d; - d.prepareForImport(); - - KisImageSP dst = new KisImage(d.undoAdapter(), r.width(), r.height(), (*deviceIt)->colorSpace(), l->name()); - d.setCurrentImage( dst ); - dst->addLayer(l->clone(), dst->rootLayer(), 0); - - d.setOutputMimeType(mimefilter.latin1()); - d.exp0rt(url); - - } - - ++deviceIt; - } - - if (undo && undo->undo()) { - undo->endMacro(); - } - - m_view->canvasSubject()->document()->setModified(true); - } -} - - - - -#include "kis_channel_separator.moc" diff --git a/chalk/plugins/viewplugins/separate_channels/kis_channel_separator.cpp b/chalk/plugins/viewplugins/separate_channels/kis_channel_separator.cpp new file mode 100644 index 00000000..ba8c6b84 --- /dev/null +++ b/chalk/plugins/viewplugins/separate_channels/kis_channel_separator.cpp @@ -0,0 +1,301 @@ +/* + * This file is part of Chalk + * + * Copyright (c) 2005 Michael Thaler + * + * ported from Gimp, Copyright (C) 1997 Eiichi Takamori + * original pixelize.c for GIMP 0.54 by Tracy Scott + * + * 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 + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#include + +#include +#include +#include "kis_meta_registry.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "kis_channel_separator.h" + +KisChannelSeparator::KisChannelSeparator(KisView * view) + : m_view(view) +{ +} + +void KisChannelSeparator::separate(KisProgressDisplayInterface * progress, enumSepAlphaOptions alphaOps, enumSepSource sourceOps, enumSepOutput outputOps, bool downscale, bool toColor) +{ + KisImageSP image = m_view->canvasSubject()->currentImg(); + if (!image) return; + + KisLayerSP layer = image->activeLayer(); + if (!layer) return; + + KisPaintDeviceSP src = image->activeDevice(); + if (!src) return; + + m_cancelRequested = false; + if ( progress ) + progress->setSubject(this, true, true); + emit notifyProgressStage(i18n("Separating image..."), 0); + + KisColorSpace * dstCs = 0; + + TQ_UINT32 numberOfChannels = src->nChannels(); + KisColorSpace * srcCs = src->colorSpace(); + TQValueVector channels = srcCs->channels(); + + // Use the flattened image, if required + switch(sourceOps) { + + case(ALL_LAYERS): + src = image->mergedImage(); + break; + default: + break; + } + + vKisPaintDeviceSP layers; + + TQValueVector::const_iterator begin = channels.begin(); + TQValueVector::const_iterator end = channels.end(); + + + TQRect rect = src->exactBounds(); + + int i = 0; + TQ_UINT32 channelIndex = 0; + for (TQValueVector::const_iterator it = begin; it != end; ++it, ++channelIndex) + { + + KisChannelInfo * ch = (*it); + + if (ch->channelType() == KisChannelInfo::ALPHA && alphaOps != CREATE_ALPHA_SEPARATION) { + continue; + } + + TQ_INT32 channelSize = ch->size(); + TQ_INT32 channelPos = ch->pos(); + TQ_INT32 destSize = 1; + + KisPaintDeviceSP dev; + if (toColor) { + // We don't downscale if we separate to color channels + dev = new KisPaintDevice(srcCs, "color separations"); + } + else { + if (channelSize == 1 || downscale) { + dev = new KisPaintDevice( KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("GRAYA",""),"" ), "8 bit grayscale sep"); + } + else { + dev = new KisPaintDevice( KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("GRAYA16",""),"" ), "16 bit grayscale sep"); + destSize = 2; + } + } + + dstCs = dev->colorSpace(); + + layers.push_back(dev); + + for (TQ_INT32 row = 0; row < rect.height(); ++row) { + + KisHLineIteratorPixel srcIt = src->createHLineIterator(rect.x(), rect.y() + row, rect.width(), false); + KisHLineIteratorPixel dstIt = dev->createHLineIterator(rect.x(), rect.y() + row, rect.width(), true); + + while( ! srcIt.isDone() ) + { + if (srcIt.isSelected()) + { + if (toColor) { + dstCs->getSingleChannelPixel(dstIt.rawData(), srcIt.rawData(), channelIndex); + + if (alphaOps == COPY_ALPHA_TO_SEPARATIONS) { + //dstCs->setAlpha(dstIt.rawData(), srcIt.rawData()[srcAlphaPos], 1); + dstCs->setAlpha(dstIt.rawData(), srcCs->getAlpha(srcIt.rawData()), 1); + } + else { + dstCs->setAlpha(dstIt.rawData(), OPACITY_OPAQUE, 1); + } + } + else { + + // To grayscale + + // Decide wether we need downscaling + if (channelSize == 1 && destSize == 1) { + + // Both 8-bit channels + dstIt.rawData()[0] = srcIt.rawData()[channelPos]; + + if (alphaOps == COPY_ALPHA_TO_SEPARATIONS) { + dstCs->setAlpha(dstIt.rawData(), srcCs->getAlpha(srcIt.rawData()), 1); + } + else { + dstCs->setAlpha(dstIt.rawData(), OPACITY_OPAQUE, 1); + } + } + else if (channelSize == 2 && destSize == 2) { + + // Both 16-bit + dstIt.rawData()[0] = srcIt.rawData()[channelPos]; + dstIt.rawData()[1] = srcIt.rawData()[channelPos + 1]; + + if (alphaOps == COPY_ALPHA_TO_SEPARATIONS) { + dstCs->setAlpha(dstIt.rawData(), srcCs->getAlpha(srcIt.rawData()), 1); + } + else { + dstCs->setAlpha(dstIt.rawData(), OPACITY_OPAQUE, 1); + } + } + else if (channelSize != 1 && destSize == 1) { + // Downscale + memset(dstIt.rawData(), srcCs->scaleToU8(srcIt.rawData(), channelPos), 1); + + // XXX: Do alpha + dstCs->setAlpha(dstIt.rawData(), OPACITY_OPAQUE, 1); + } + else if (channelSize != 2 && destSize == 2) { + // Upscale + dstIt.rawData()[0] = srcCs->scaleToU8(srcIt.rawData(), channelPos); + + // XXX: Do alpha + dstCs->setAlpha(dstIt.rawData(), OPACITY_OPAQUE, 1); + + } + } + } + ++dstIt; + ++srcIt; + } + } + ++i; + + emit notifyProgress((i * 100) / numberOfChannels); + if (m_cancelRequested) { + break; + } + } + + vKisPaintDeviceSP_it deviceIt = layers.begin(); + + emit notifyProgressDone(); + + if (!m_cancelRequested) { + + KisUndoAdapter * undo = 0; + if ((undo = image->undoAdapter()) && undo->undo()) { + undo->beginMacro(i18n("Separate Image")); + } + + // Flatten the image if required + switch(sourceOps) { + case(ALL_LAYERS): + image->flatten(); + break; + default: + break; + } + + for (TQValueVector::const_iterator it = begin; it != end; ++it) + { + + KisChannelInfo * ch = (*it); + + if (ch->channelType() == KisChannelInfo::ALPHA && alphaOps != CREATE_ALPHA_SEPARATION) { + // Don't make an separate separation of the alpha channel if the user didn't ask for it. + continue; + } + + if (outputOps == TO_LAYERS) { + KisPaintLayerSP l = new KisPaintLayer( image, ch->name(), OPACITY_OPAQUE, *deviceIt); + image->addLayer( dynamic_cast(l.data()), image->rootLayer(), 0); + } + else { + TQStringList listMimeFilter = KoFilterManager::mimeFilter("application/x-chalk", KoFilterManager::Export); + TQString mimelist = listMimeFilter.join(" "); + + KFileDialog fd (TQString(), mimelist, m_view, "Export Layer", true); + fd.setCaption(i18n("Export Layer") + "(" + ch->name() + ")"); + fd.setMimeFilter(listMimeFilter); + fd.setOperationMode(KFileDialog::Saving); + fd.setURL(KURL(ch->name())); + if (!fd.exec()) return; + + KURL url = fd.selectedURL(); + TQString mimefilter = fd.currentMimeFilter(); + + if (url.isEmpty()) + return; + + KisPaintLayerSP l = new KisPaintLayer( image, ch->name(), OPACITY_OPAQUE, *deviceIt); + TQRect r = l->exactBounds(); + + KisDoc d; + d.prepareForImport(); + + KisImageSP dst = new KisImage(d.undoAdapter(), r.width(), r.height(), (*deviceIt)->colorSpace(), l->name()); + d.setCurrentImage( dst ); + dst->addLayer(l->clone(), dst->rootLayer(), 0); + + d.setOutputMimeType(mimefilter.latin1()); + d.exp0rt(url); + + } + + ++deviceIt; + } + + if (undo && undo->undo()) { + undo->endMacro(); + } + + m_view->canvasSubject()->document()->setModified(true); + } +} + + + + +#include "kis_channel_separator.moc" diff --git a/chalk/plugins/viewplugins/separate_channels/kis_separate_channels_plugin.cc b/chalk/plugins/viewplugins/separate_channels/kis_separate_channels_plugin.cc deleted file mode 100644 index db356a16..00000000 --- a/chalk/plugins/viewplugins/separate_channels/kis_separate_channels_plugin.cc +++ /dev/null @@ -1,96 +0,0 @@ -/* - * This file is part of the KDE project - * - * Copyright (c) 2005 Michael Thaler - * - * 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 -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "kis_separate_channels_plugin.h" -#include "kis_channel_separator.h" -#include "dlg_separate.h" - -K_EXPORT_COMPONENT_FACTORY( chalkseparatechannels, KGenericFactory( "chalk" ) ) - -KisSeparateChannelsPlugin::KisSeparateChannelsPlugin(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - - if ( parent->inherits("KisView") ) { - setInstance(KGenericFactory::instance()); - setXMLFile(locate("data","chalkplugins/imageseparate.rc"), true); - m_view = (KisView*) parent; - (void) new TDEAction(i18n("Separate Image..."), 0, 0, this, TQT_SLOT(slotSeparate()), actionCollection(), "separate"); - } -} - -KisSeparateChannelsPlugin::~KisSeparateChannelsPlugin() -{ -} - -void KisSeparateChannelsPlugin::slotSeparate() -{ - KisImageSP image = m_view->canvasSubject()->currentImg(); - if (!image) return; - - KisLayerSP l = image->activeLayer(); - if (!l) return; - - KisPaintDeviceSP dev = image->activeDevice(); - if (!dev) return; - - DlgSeparate * dlgSeparate = new DlgSeparate(dev->colorSpace()->id().name(), - image->colorSpace()->id().name(), m_view, "Separate"); - TQ_CHECK_PTR(dlgSeparate); - - dlgSeparate->setCaption(i18n("Separate Image")); - - // If we're 8-bits, disable the downscale option - if (dev->pixelSize() == dev->nChannels()) { - dlgSeparate->enableDownscale(false); - } - - if (dlgSeparate->exec() == TQDialog::Accepted) { - - KisChannelSeparator separator(m_view); - separator.separate(m_view->canvasSubject()->progressDisplay(), - dlgSeparate->getAlphaOptions(), - dlgSeparate->getSource(), - dlgSeparate->getOutput(), - dlgSeparate->getDownscale(), - dlgSeparate->getToColor()); - - } - - delete dlgSeparate; - -} - -#include "kis_separate_channels_plugin.moc" diff --git a/chalk/plugins/viewplugins/separate_channels/kis_separate_channels_plugin.cpp b/chalk/plugins/viewplugins/separate_channels/kis_separate_channels_plugin.cpp new file mode 100644 index 00000000..db356a16 --- /dev/null +++ b/chalk/plugins/viewplugins/separate_channels/kis_separate_channels_plugin.cpp @@ -0,0 +1,96 @@ +/* + * This file is part of the KDE project + * + * Copyright (c) 2005 Michael Thaler + * + * 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 +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "kis_separate_channels_plugin.h" +#include "kis_channel_separator.h" +#include "dlg_separate.h" + +K_EXPORT_COMPONENT_FACTORY( chalkseparatechannels, KGenericFactory( "chalk" ) ) + +KisSeparateChannelsPlugin::KisSeparateChannelsPlugin(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + + if ( parent->inherits("KisView") ) { + setInstance(KGenericFactory::instance()); + setXMLFile(locate("data","chalkplugins/imageseparate.rc"), true); + m_view = (KisView*) parent; + (void) new TDEAction(i18n("Separate Image..."), 0, 0, this, TQT_SLOT(slotSeparate()), actionCollection(), "separate"); + } +} + +KisSeparateChannelsPlugin::~KisSeparateChannelsPlugin() +{ +} + +void KisSeparateChannelsPlugin::slotSeparate() +{ + KisImageSP image = m_view->canvasSubject()->currentImg(); + if (!image) return; + + KisLayerSP l = image->activeLayer(); + if (!l) return; + + KisPaintDeviceSP dev = image->activeDevice(); + if (!dev) return; + + DlgSeparate * dlgSeparate = new DlgSeparate(dev->colorSpace()->id().name(), + image->colorSpace()->id().name(), m_view, "Separate"); + TQ_CHECK_PTR(dlgSeparate); + + dlgSeparate->setCaption(i18n("Separate Image")); + + // If we're 8-bits, disable the downscale option + if (dev->pixelSize() == dev->nChannels()) { + dlgSeparate->enableDownscale(false); + } + + if (dlgSeparate->exec() == TQDialog::Accepted) { + + KisChannelSeparator separator(m_view); + separator.separate(m_view->canvasSubject()->progressDisplay(), + dlgSeparate->getAlphaOptions(), + dlgSeparate->getSource(), + dlgSeparate->getOutput(), + dlgSeparate->getDownscale(), + dlgSeparate->getToColor()); + + } + + delete dlgSeparate; + +} + +#include "kis_separate_channels_plugin.moc" diff --git a/chalk/plugins/viewplugins/shearimage/Makefile.am b/chalk/plugins/viewplugins/shearimage/Makefile.am index 65a3a735..e478bf0c 100644 --- a/chalk/plugins/viewplugins/shearimage/Makefile.am +++ b/chalk/plugins/viewplugins/shearimage/Makefile.am @@ -15,7 +15,7 @@ kde_module_LTLIBRARIES = chalkshearimage.la kde_services_DATA = chalkshearimage.desktop -chalkshearimage_la_SOURCES = wdg_shearimage.ui shearimage.cc dlg_shearimage.cc +chalkshearimage_la_SOURCES = wdg_shearimage.ui shearimage.cpp dlg_shearimage.cpp noinst_HEADERS = wdg_shearimage.h dlg_shearimage.h shearimage.h chalkshearimage_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) $(LIB_QT) -ltdecore -ltdeui -lkjs -ltdefx -ltdeio -ltdeparts diff --git a/chalk/plugins/viewplugins/shearimage/dlg_shearimage.cc b/chalk/plugins/viewplugins/shearimage/dlg_shearimage.cc deleted file mode 100644 index e7a63180..00000000 --- a/chalk/plugins/viewplugins/shearimage/dlg_shearimage.cc +++ /dev/null @@ -1,96 +0,0 @@ -/* - * dlg_shearimage.cc - part of KimageShop^WKrayon^WChalk - * - * Copyright (c) 2004 Michael Thaler - * - * 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 - -#include - -#include - -using namespace std; - -#include -#include -#include -#include - -#include -#include -#include - -#include "dlg_shearimage.h" -#include "wdg_shearimage.h" - - -DlgShearImage::DlgShearImage( TQWidget * parent, - const char * name) - : super (parent, name, true, i18n("Shear Image"), Ok | Cancel, Ok) -{ - m_lock = false; - - m_page = new WdgShearImage(this, "shear_image"); - m_page->layout()->setMargin(0); - TQ_CHECK_PTR(m_page); - - setMainWidget(m_page); - resize(m_page->sizeHint()); - - connect(this, TQT_SIGNAL(okClicked()), - this, TQT_SLOT(okClicked())); - -} - -DlgShearImage::~DlgShearImage() -{ - delete m_page; -} - -void DlgShearImage::setAngleX(TQ_UINT32 angle) -{ - m_page->shearAngleX->setValue(angle); - m_oldAngle = angle; - -} - -void DlgShearImage::setAngleY(TQ_UINT32 angle) -{ - m_page->shearAngleY->setValue(angle); - m_oldAngle = angle; - -} - -TQ_INT32 DlgShearImage::angleX() -{ - return (TQ_INT32)tqRound(m_page->shearAngleX->value()); -} - -TQ_INT32 DlgShearImage::angleY() -{ - return (TQ_INT32)tqRound(m_page->shearAngleY->value()); -} - -// SLOTS - -void DlgShearImage::okClicked() -{ - accept(); -} - -#include "dlg_shearimage.moc" diff --git a/chalk/plugins/viewplugins/shearimage/dlg_shearimage.cpp b/chalk/plugins/viewplugins/shearimage/dlg_shearimage.cpp new file mode 100644 index 00000000..d295493d --- /dev/null +++ b/chalk/plugins/viewplugins/shearimage/dlg_shearimage.cpp @@ -0,0 +1,96 @@ +/* + * dlg_shearimage.cpp - part of KimageShop^WKrayon^WChalk + * + * Copyright (c) 2004 Michael Thaler + * + * 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 + +#include + +#include + +using namespace std; + +#include +#include +#include +#include + +#include +#include +#include + +#include "dlg_shearimage.h" +#include "wdg_shearimage.h" + + +DlgShearImage::DlgShearImage( TQWidget * parent, + const char * name) + : super (parent, name, true, i18n("Shear Image"), Ok | Cancel, Ok) +{ + m_lock = false; + + m_page = new WdgShearImage(this, "shear_image"); + m_page->layout()->setMargin(0); + TQ_CHECK_PTR(m_page); + + setMainWidget(m_page); + resize(m_page->sizeHint()); + + connect(this, TQT_SIGNAL(okClicked()), + this, TQT_SLOT(okClicked())); + +} + +DlgShearImage::~DlgShearImage() +{ + delete m_page; +} + +void DlgShearImage::setAngleX(TQ_UINT32 angle) +{ + m_page->shearAngleX->setValue(angle); + m_oldAngle = angle; + +} + +void DlgShearImage::setAngleY(TQ_UINT32 angle) +{ + m_page->shearAngleY->setValue(angle); + m_oldAngle = angle; + +} + +TQ_INT32 DlgShearImage::angleX() +{ + return (TQ_INT32)tqRound(m_page->shearAngleX->value()); +} + +TQ_INT32 DlgShearImage::angleY() +{ + return (TQ_INT32)tqRound(m_page->shearAngleY->value()); +} + +// SLOTS + +void DlgShearImage::okClicked() +{ + accept(); +} + +#include "dlg_shearimage.moc" diff --git a/chalk/plugins/viewplugins/shearimage/shearimage.cc b/chalk/plugins/viewplugins/shearimage/shearimage.cc deleted file mode 100644 index 8e20b58d..00000000 --- a/chalk/plugins/viewplugins/shearimage/shearimage.cc +++ /dev/null @@ -1,113 +0,0 @@ -/* - * shearimage.cc -- Part of Chalk - * - * Copyright (c) 2004 Michael Thaler - * - * 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 - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "shearimage.h" -#include "dlg_shearimage.h" - -typedef KGenericFactory ShearImageFactory; -K_EXPORT_COMPONENT_FACTORY( chalkshearimage, ShearImageFactory( "chalk" ) ) - -// XXX: this plugin could also provide layer scaling/resizing -ShearImage::ShearImage(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - if ( parent->inherits("KisView") ) - { - setInstance(ShearImageFactory::instance()); - setXMLFile(locate("data","chalkplugins/shearimage.rc"), true); - - (void) new TDEAction(i18n("&Shear Image..."), 0, 0, this, TQT_SLOT(slotShearImage()), actionCollection(), "shearimage"); - (void) new TDEAction(i18n("&Shear Layer..."), 0, 0, this, TQT_SLOT(slotShearLayer()), actionCollection(), "shearlayer"); - - m_view = (KisView*) parent; - } -} - -ShearImage::~ShearImage() -{ - m_view = 0; -} - -void ShearImage::slotShearImage() -{ - KisImageSP image = m_view->canvasSubject()->currentImg(); - - if (!image) return; - - DlgShearImage * dlgShearImage = new DlgShearImage(m_view, "ShearImage"); - TQ_CHECK_PTR(dlgShearImage); - - dlgShearImage->setCaption(i18n("Shear Image")); - - if (dlgShearImage->exec() == TQDialog::Accepted) { - TQ_INT32 angleX = dlgShearImage->angleX(); - TQ_INT32 angleY = dlgShearImage->angleY(); - m_view->shearCurrentImage(angleX, angleY); - } - delete dlgShearImage; -} - -void ShearImage::slotShearLayer() -{ - KisImageSP image = m_view->canvasSubject()->currentImg(); - - if (!image) return; - - DlgShearImage * dlgShearImage = new DlgShearImage(m_view, "ShearLayer"); - TQ_CHECK_PTR(dlgShearImage); - - dlgShearImage->setCaption(i18n("Shear Layer")); - - if (dlgShearImage->exec() == TQDialog::Accepted) { - TQ_INT32 angleX = dlgShearImage->angleX(); - TQ_INT32 angleY = dlgShearImage->angleY(); - m_view->shearLayer(angleX, angleY); - - } - delete dlgShearImage; -} - -#include "shearimage.moc" diff --git a/chalk/plugins/viewplugins/shearimage/shearimage.cpp b/chalk/plugins/viewplugins/shearimage/shearimage.cpp new file mode 100644 index 00000000..2596e62e --- /dev/null +++ b/chalk/plugins/viewplugins/shearimage/shearimage.cpp @@ -0,0 +1,113 @@ +/* + * shearimage.cpp -- Part of Chalk + * + * Copyright (c) 2004 Michael Thaler + * + * 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 + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "shearimage.h" +#include "dlg_shearimage.h" + +typedef KGenericFactory ShearImageFactory; +K_EXPORT_COMPONENT_FACTORY( chalkshearimage, ShearImageFactory( "chalk" ) ) + +// XXX: this plugin could also provide layer scaling/resizing +ShearImage::ShearImage(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + if ( parent->inherits("KisView") ) + { + setInstance(ShearImageFactory::instance()); + setXMLFile(locate("data","chalkplugins/shearimage.rc"), true); + + (void) new TDEAction(i18n("&Shear Image..."), 0, 0, this, TQT_SLOT(slotShearImage()), actionCollection(), "shearimage"); + (void) new TDEAction(i18n("&Shear Layer..."), 0, 0, this, TQT_SLOT(slotShearLayer()), actionCollection(), "shearlayer"); + + m_view = (KisView*) parent; + } +} + +ShearImage::~ShearImage() +{ + m_view = 0; +} + +void ShearImage::slotShearImage() +{ + KisImageSP image = m_view->canvasSubject()->currentImg(); + + if (!image) return; + + DlgShearImage * dlgShearImage = new DlgShearImage(m_view, "ShearImage"); + TQ_CHECK_PTR(dlgShearImage); + + dlgShearImage->setCaption(i18n("Shear Image")); + + if (dlgShearImage->exec() == TQDialog::Accepted) { + TQ_INT32 angleX = dlgShearImage->angleX(); + TQ_INT32 angleY = dlgShearImage->angleY(); + m_view->shearCurrentImage(angleX, angleY); + } + delete dlgShearImage; +} + +void ShearImage::slotShearLayer() +{ + KisImageSP image = m_view->canvasSubject()->currentImg(); + + if (!image) return; + + DlgShearImage * dlgShearImage = new DlgShearImage(m_view, "ShearLayer"); + TQ_CHECK_PTR(dlgShearImage); + + dlgShearImage->setCaption(i18n("Shear Layer")); + + if (dlgShearImage->exec() == TQDialog::Accepted) { + TQ_INT32 angleX = dlgShearImage->angleX(); + TQ_INT32 angleY = dlgShearImage->angleY(); + m_view->shearLayer(angleX, angleY); + + } + delete dlgShearImage; +} + +#include "shearimage.moc" diff --git a/chalk/plugins/viewplugins/substrate/Makefile.am b/chalk/plugins/viewplugins/substrate/Makefile.am index c4eca055..e708a90d 100644 --- a/chalk/plugins/viewplugins/substrate/Makefile.am +++ b/chalk/plugins/viewplugins/substrate/Makefile.am @@ -14,7 +14,7 @@ INCLUDES = -I$(srcdir)/../../../sdk \ kde_module_LTLIBRARIES = chalksubstrate.la -chalksubstrate_la_SOURCES = substrate.cc dlg_substrate.cc wdgsubstrate.ui kis_repeating_substrate.cc +chalksubstrate_la_SOURCES = substrate.cpp dlg_substrate.cpp wdgsubstrate.ui kis_repeating_substrate.cpp noinst_HEADERS = wdgsubstrate.h dlg_substrate.h kis_repeating_substrate.h substrate.h chalksubstrate_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) $(LIB_QT) -ltdecore -ltdeui -lkjs -ltdefx -ltdeio -ltdeparts diff --git a/chalk/plugins/viewplugins/substrate/dlg_substrate.cc b/chalk/plugins/viewplugins/substrate/dlg_substrate.cc deleted file mode 100644 index a0dbc5aa..00000000 --- a/chalk/plugins/viewplugins/substrate/dlg_substrate.cc +++ /dev/null @@ -1,59 +0,0 @@ -/* - * dlg_substrate.cc - part of KimageShop^WKrayon^WChalk - * - * Copyright (c) 2004 Boudewijn Rempt - * - * 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 - -#include "dlg_substrate.h" -#include "wdgsubstrate.h" - - -DlgSubstrate::DlgSubstrate( TQWidget * parent, - const char * name) - : super (parent, name, true, i18n("Color Range"), Ok | Cancel, Ok) -{ - m_previewPix = TQPixmap(); - m_page = new WdgSubstrate(this, "substrate"); - TQ_CHECK_PTR(m_page); - setCaption(i18n("Substrate")); - setMainWidget(m_page); - resize(m_page -> size()); - - connect(this, TQT_SIGNAL(okClicked()), - this, TQT_SLOT(okClicked())); -} - -DlgSubstrate::~DlgSubstrate() -{ - delete m_page; -} - -void DlgSubstrate::setPixmap(TQPixmap pix) -{ - m_previewPix = pix; - m_previewPix.detach(); -} - -void DlgSubstrate::okClicked() -{ - accept(); -} - -#include "dlg_substrate.moc" - diff --git a/chalk/plugins/viewplugins/substrate/dlg_substrate.cpp b/chalk/plugins/viewplugins/substrate/dlg_substrate.cpp new file mode 100644 index 00000000..78847f05 --- /dev/null +++ b/chalk/plugins/viewplugins/substrate/dlg_substrate.cpp @@ -0,0 +1,59 @@ +/* + * dlg_substrate.cpp - part of KimageShop^WKrayon^WChalk + * + * Copyright (c) 2004 Boudewijn Rempt + * + * 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 + +#include "dlg_substrate.h" +#include "wdgsubstrate.h" + + +DlgSubstrate::DlgSubstrate( TQWidget * parent, + const char * name) + : super (parent, name, true, i18n("Color Range"), Ok | Cancel, Ok) +{ + m_previewPix = TQPixmap(); + m_page = new WdgSubstrate(this, "substrate"); + TQ_CHECK_PTR(m_page); + setCaption(i18n("Substrate")); + setMainWidget(m_page); + resize(m_page -> size()); + + connect(this, TQT_SIGNAL(okClicked()), + this, TQT_SLOT(okClicked())); +} + +DlgSubstrate::~DlgSubstrate() +{ + delete m_page; +} + +void DlgSubstrate::setPixmap(TQPixmap pix) +{ + m_previewPix = pix; + m_previewPix.detach(); +} + +void DlgSubstrate::okClicked() +{ + accept(); +} + +#include "dlg_substrate.moc" + diff --git a/chalk/plugins/viewplugins/substrate/kis_repeating_substrate.cc b/chalk/plugins/viewplugins/substrate/kis_repeating_substrate.cc deleted file mode 100644 index e69de29b..00000000 diff --git a/chalk/plugins/viewplugins/substrate/kis_repeating_substrate.cpp b/chalk/plugins/viewplugins/substrate/kis_repeating_substrate.cpp new file mode 100644 index 00000000..e69de29b diff --git a/chalk/plugins/viewplugins/substrate/substrate.cc b/chalk/plugins/viewplugins/substrate/substrate.cc deleted file mode 100644 index ce13710b..00000000 --- a/chalk/plugins/viewplugins/substrate/substrate.cc +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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. - */ -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "substrate.h" -#include "dlg_substrate.h" - -typedef KGenericFactory SubstrateFactory; -K_EXPORT_COMPONENT_FACTORY( chalksubstrate, SubstrateFactory( "chalk" ) ) - -SubstratePlugin::SubstratePlugin(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - - if ( parent->inherits("KisView") ) - { - setInstance(SubstrateFactory::instance()); - setXMLFile(locate("data","chalkplugins/substrate.rc"), true); - - (void) new TDEAction(i18n("&Substrate..."), 0, 0, this, TQT_SLOT(slotSubstrateActivated()), actionCollection(), "substrate"); - - m_view = (KisView*) parent; - } -} - -SubstratePlugin::~SubstratePlugin() -{ -} - -void SubstratePlugin::slotSubstrateActivated() -{ - DlgSubstrate * dlgSubstrate = new DlgSubstrate(m_view, "Substrate"); - TQ_CHECK_PTR(dlgSubstrate); - if (dlgSubstrate -> exec() == TQDialog::Accepted) { - // Retrieve changes made by dialog - // Apply changes to layer (selection) - } - delete dlgSubstrate; -} - -#include "substrate.moc" - diff --git a/chalk/plugins/viewplugins/substrate/substrate.cpp b/chalk/plugins/viewplugins/substrate/substrate.cpp new file mode 100644 index 00000000..ce13710b --- /dev/null +++ b/chalk/plugins/viewplugins/substrate/substrate.cpp @@ -0,0 +1,78 @@ +/* + * 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. + */ +#include + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "substrate.h" +#include "dlg_substrate.h" + +typedef KGenericFactory SubstrateFactory; +K_EXPORT_COMPONENT_FACTORY( chalksubstrate, SubstrateFactory( "chalk" ) ) + +SubstratePlugin::SubstratePlugin(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + + if ( parent->inherits("KisView") ) + { + setInstance(SubstrateFactory::instance()); + setXMLFile(locate("data","chalkplugins/substrate.rc"), true); + + (void) new TDEAction(i18n("&Substrate..."), 0, 0, this, TQT_SLOT(slotSubstrateActivated()), actionCollection(), "substrate"); + + m_view = (KisView*) parent; + } +} + +SubstratePlugin::~SubstratePlugin() +{ +} + +void SubstratePlugin::slotSubstrateActivated() +{ + DlgSubstrate * dlgSubstrate = new DlgSubstrate(m_view, "Substrate"); + TQ_CHECK_PTR(dlgSubstrate); + if (dlgSubstrate -> exec() == TQDialog::Accepted) { + // Retrieve changes made by dialog + // Apply changes to layer (selection) + } + delete dlgSubstrate; +} + +#include "substrate.moc" + diff --git a/chalk/plugins/viewplugins/variations/Makefile.am b/chalk/plugins/viewplugins/variations/Makefile.am index 3b1d4c78..f35bd875 100644 --- a/chalk/plugins/viewplugins/variations/Makefile.am +++ b/chalk/plugins/viewplugins/variations/Makefile.am @@ -14,7 +14,7 @@ INCLUDES = -I$(srcdir)/../../../sdk \ kde_module_LTLIBRARIES = chalkvariations.la -chalkvariations_la_SOURCES = variations.cc dlg_variations.cc wdg_variations.ui +chalkvariations_la_SOURCES = variations.cpp dlg_variations.cpp wdg_variations.ui noinst_HEADERS = wdg_variations.h chalkvariations_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) $(LIB_QT) -ltdecore -ltdeui -lkjs -ltdefx -ltdeio -ltdeparts diff --git a/chalk/plugins/viewplugins/variations/dlg_variations.cc b/chalk/plugins/viewplugins/variations/dlg_variations.cc deleted file mode 100644 index afa6a3d7..00000000 --- a/chalk/plugins/viewplugins/variations/dlg_variations.cc +++ /dev/null @@ -1,58 +0,0 @@ -/* - * dlg_variations.cc - part of KimageShop^WKrayon^WChalk - * - * Copyright (c) 2004 Boudewijn Rempt - * - * 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 - -#include "dlg_variations.h" -#include "wdg_variations.h" - - -DlgVariations::DlgVariations( TQWidget * parent, - const char * name) - : super (parent, name, true, i18n("Color Range"), Ok | Cancel, Ok) -{ - m_previewPix = TQPixmap(); - m_page = new WdgVariations(this, "variations"); - TQ_CHECK_PTR(m_page); - setCaption(i18n("Variations")); - setMainWidget(m_page); - resize(m_page -> size()); - - connect(this, TQT_SIGNAL(okClicked()), - this, TQT_SLOT(okClicked())); -} - -DlgVariations::~DlgVariations() -{ - delete m_page; -} - -void DlgVariations::setPixmap(TQPixmap pix) -{ - m_previewPix = pix; - m_previewPix.detach(); -} - -void DlgVariations::okClicked() -{ - accept(); -} - -#include "dlg_variations.moc" diff --git a/chalk/plugins/viewplugins/variations/dlg_variations.cpp b/chalk/plugins/viewplugins/variations/dlg_variations.cpp new file mode 100644 index 00000000..4decbbd4 --- /dev/null +++ b/chalk/plugins/viewplugins/variations/dlg_variations.cpp @@ -0,0 +1,58 @@ +/* + * dlg_variations.cpp - part of KimageShop^WKrayon^WChalk + * + * Copyright (c) 2004 Boudewijn Rempt + * + * 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 + +#include "dlg_variations.h" +#include "wdg_variations.h" + + +DlgVariations::DlgVariations( TQWidget * parent, + const char * name) + : super (parent, name, true, i18n("Color Range"), Ok | Cancel, Ok) +{ + m_previewPix = TQPixmap(); + m_page = new WdgVariations(this, "variations"); + TQ_CHECK_PTR(m_page); + setCaption(i18n("Variations")); + setMainWidget(m_page); + resize(m_page -> size()); + + connect(this, TQT_SIGNAL(okClicked()), + this, TQT_SLOT(okClicked())); +} + +DlgVariations::~DlgVariations() +{ + delete m_page; +} + +void DlgVariations::setPixmap(TQPixmap pix) +{ + m_previewPix = pix; + m_previewPix.detach(); +} + +void DlgVariations::okClicked() +{ + accept(); +} + +#include "dlg_variations.moc" diff --git a/chalk/plugins/viewplugins/variations/variations.cc b/chalk/plugins/viewplugins/variations/variations.cc deleted file mode 100644 index 5e2d65ba..00000000 --- a/chalk/plugins/viewplugins/variations/variations.cc +++ /dev/null @@ -1,88 +0,0 @@ -/* - * variation.h -- Part of Chalk - * - * Copyright (c) 2004 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 - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "variations.h" -#include "dlg_variations.h" - -typedef KGenericFactory VariationsFactory; -K_EXPORT_COMPONENT_FACTORY( chalkvariations, VariationsFactory( "chalk" ) ) - -Variations::Variations(TQObject *parent, const char *name, const TQStringList &) - : KParts::Plugin(parent, name) -{ - - if ( parent->inherits("KisView") ) - { - setInstance(VariationsFactory::instance()); - setXMLFile(locate("data","chalkplugins/variations.rc"), true); - - (void) new TDEAction(i18n("&Variations..."), 0, 0, this, TQT_SLOT(slotVariationsActivated()), actionCollection(), "variations"); - - m_view = (KisView*) parent; - } -} - -Variations::~Variations() -{ -} - -void Variations::slotVariationsActivated() -{ - DlgVariations * dlgVariations = new DlgVariations(m_view, "Variations"); - TQ_CHECK_PTR(dlgVariations); - // Render layer to a TQIMage -- keep in mind possibility of selection - - // Scale TQImage - - // Set original TQImage in dialog - - if (dlgVariations -> exec() == TQDialog::Accepted) { - // Retrieve changes made by dialog - // Apply changes to layer (selection) - } - delete dlgVariations; -} - -#include "variations.moc" - diff --git a/chalk/plugins/viewplugins/variations/variations.cpp b/chalk/plugins/viewplugins/variations/variations.cpp new file mode 100644 index 00000000..5e2d65ba --- /dev/null +++ b/chalk/plugins/viewplugins/variations/variations.cpp @@ -0,0 +1,88 @@ +/* + * variation.h -- Part of Chalk + * + * Copyright (c) 2004 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 + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "variations.h" +#include "dlg_variations.h" + +typedef KGenericFactory VariationsFactory; +K_EXPORT_COMPONENT_FACTORY( chalkvariations, VariationsFactory( "chalk" ) ) + +Variations::Variations(TQObject *parent, const char *name, const TQStringList &) + : KParts::Plugin(parent, name) +{ + + if ( parent->inherits("KisView") ) + { + setInstance(VariationsFactory::instance()); + setXMLFile(locate("data","chalkplugins/variations.rc"), true); + + (void) new TDEAction(i18n("&Variations..."), 0, 0, this, TQT_SLOT(slotVariationsActivated()), actionCollection(), "variations"); + + m_view = (KisView*) parent; + } +} + +Variations::~Variations() +{ +} + +void Variations::slotVariationsActivated() +{ + DlgVariations * dlgVariations = new DlgVariations(m_view, "Variations"); + TQ_CHECK_PTR(dlgVariations); + // Render layer to a TQIMage -- keep in mind possibility of selection + + // Scale TQImage + + // Set original TQImage in dialog + + if (dlgVariations -> exec() == TQDialog::Accepted) { + // Retrieve changes made by dialog + // Apply changes to layer (selection) + } + delete dlgVariations; +} + +#include "variations.moc" + -- cgit v1.2.1