summaryrefslogtreecommitdiffstats
path: root/krita/plugins/viewplugins/selectopaque
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 01:29:50 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 01:29:50 +0000
commit8362bf63dea22bbf6736609b0f49c152f975eb63 (patch)
tree0eea3928e39e50fae91d4e68b21b1e6cbae25604 /krita/plugins/viewplugins/selectopaque
downloadkoffice-8362bf63dea22bbf6736609b0f49c152f975eb63.tar.gz
koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.zip
Added old abandoned KDE3 version of koffice
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1077364 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'krita/plugins/viewplugins/selectopaque')
-rw-r--r--krita/plugins/viewplugins/selectopaque/Makefile.am24
-rw-r--r--krita/plugins/viewplugins/selectopaque/kritaselectopaque.desktop26
-rw-r--r--krita/plugins/viewplugins/selectopaque/selectopaque.cc116
-rw-r--r--krita/plugins/viewplugins/selectopaque/selectopaque.h44
-rw-r--r--krita/plugins/viewplugins/selectopaque/selectopaque.rc10
5 files changed, 220 insertions, 0 deletions
diff --git a/krita/plugins/viewplugins/selectopaque/Makefile.am b/krita/plugins/viewplugins/selectopaque/Makefile.am
new file mode 100644
index 00000000..2c382ce3
--- /dev/null
+++ b/krita/plugins/viewplugins/selectopaque/Makefile.am
@@ -0,0 +1,24 @@
+INCLUDES = -I$(srcdir)/../../../sdk \
+ -I$(srcdir)/../../../core \
+ -I$(srcdir)/../../../kritacolor/ \
+ -I$(srcdir)/../../../ui \
+ $(KOFFICE_INCLUDES) \
+ $(all_includes)
+
+kde_module_LTLIBRARIES = kritaselectopaque.la
+
+kritaselectopaque_la_SOURCES = selectopaque.cc
+noinst_HEADERS = selectopaque.h
+
+kritaselectopaque_la_LIBADD = ../../../libkritacommon.la
+kritaselectopaque_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
+
+kritarcdir = $(kde_datadir)/kritaplugins
+kritarc_DATA = selectopaque.rc
+EXTRA_DIST = $(kritarc_DATA)
+
+kde_services_DATA = kritaselectopaque.desktop
+
+kritaselectopaque_la_METASOURCES = AUTO
+
+KDE_OPTIONS = nofinal
diff --git a/krita/plugins/viewplugins/selectopaque/kritaselectopaque.desktop b/krita/plugins/viewplugins/selectopaque/kritaselectopaque.desktop
new file mode 100644
index 00000000..69690306
--- /dev/null
+++ b/krita/plugins/viewplugins/selectopaque/kritaselectopaque.desktop
@@ -0,0 +1,26 @@
+[Desktop Entry]
+Name=SelectOpaque
+Name[bg]=Негатив
+Name[da]=Markér ugennemsigtig
+Name[de]=UndurchsichtigeAuswählen
+Name[et]=Läbipaistmatute pikslite valik
+Name[fy]=Untrochsichtige selektearje
+Name[it]=Seleziona i pixel opachi
+Name[km]=ជ្រើស​ស្រអាប់
+Name[nds]=Decken utsöken
+Name[ne]=अपारदर्शी चयन
+Name[nl]=Ondoorzichtige selecteren
+Name[pl]=Zaznaczanie nieprzezroczystości
+Name[pt]=Selecção Opaca
+Name[pt_BR]=Seleção Opaca
+Name[ru]=Выделение непрозрачных областей
+Name[sk]=Invertovať Výber
+Name[sr]=Избор непрозирног
+Name[sr@Latn]=Izbor neprozirnog
+Name[sv]=Markera ogenomskinliga
+Name[uk]=Виділення непрозорих ділянок
+Name[zh_TW]=選擇不透明
+ServiceTypes=Krita/ViewPlugin
+Type=Service
+X-KDE-Library=kritaselectopaque
+X-Krita-Version=2
diff --git a/krita/plugins/viewplugins/selectopaque/selectopaque.cc b/krita/plugins/viewplugins/selectopaque/selectopaque.cc
new file mode 100644
index 00000000..cfbcb4e7
--- /dev/null
+++ b/krita/plugins/viewplugins/selectopaque/selectopaque.cc
@@ -0,0 +1,116 @@
+/*
+ * selectopague.h -- Part of Krita
+ *
+ * Copyright (c) 2004 Boudewijn Rempt ([email protected])
+ *
+ * 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 <math.h>
+
+#include <stdlib.h>
+
+#include <qcursor.h>
+#include <qapplication.h>
+
+#include <klocale.h>
+#include <kiconloader.h>
+#include <kinstance.h>
+#include <kmessagebox.h>
+#include <kstandarddirs.h>
+#include <ktempfile.h>
+#include <kdebug.h>
+#include <kgenericfactory.h>
+
+#include <kis_selected_transaction.h>
+#include <kis_cursor.h>
+#include <kis_doc.h>
+#include <kis_image.h>
+#include <kis_layer.h>
+#include <kis_paint_device.h>
+#include <kis_iterator.h>
+#include <kis_iterators_pixel.h>
+#include <kis_global.h>
+#include <kis_types.h>
+#include <kis_view.h>
+#include <kis_selection.h>
+#include <kis_selection_manager.h>
+#include "selectopaque.h"
+
+typedef KGenericFactory<SelectOpaque> SelectOpaqueFactory;
+K_EXPORT_COMPONENT_FACTORY( kritaselectopaque, SelectOpaqueFactory( "krita" ) )
+
+SelectOpaque::SelectOpaque(QObject *parent, const char *name, const QStringList &)
+ : KParts::Plugin(parent, name)
+{
+
+ if (parent->inherits("KisView")) {
+ setInstance(SelectOpaqueFactory::instance());
+ setXMLFile(locate("data","kritaplugins/selectopaque.rc"), true);
+ m_view = dynamic_cast<KisView*>(parent);
+ m_view->canvasSubject()->selectionManager()->addSelectionAction( new KAction(i18n("&Select All Opaque Pixels..."), 0, 0, this, SLOT(slotActivated()), actionCollection(), "selectopaque") );
+
+ }
+}
+
+SelectOpaque::~SelectOpaque()
+{
+}
+
+void SelectOpaque::slotActivated()
+{
+ KisSelectedTransaction *transaction;
+
+ KisPaintDeviceSP layer = m_view->canvasSubject()->currentImg()->activeDevice();
+ if (!layer) return;
+ QApplication::setOverrideCursor(KisCursor::waitCursor());
+
+ if (layer->image()->undo()) transaction = new KisSelectedTransaction(i18n("Select Opaque Pixels"), layer);
+ // XXX: Multithread this!
+ Q_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();
+ }
+ QApplication::restoreOverrideCursor();
+ layer->setDirty();
+ layer->emitSelectionChanged();
+
+ if (layer->image()->undo()) m_view->canvasSubject()->undoAdapter()->addCommand(transaction);
+
+}
+
+#include "selectopaque.moc"
+
diff --git a/krita/plugins/viewplugins/selectopaque/selectopaque.h b/krita/plugins/viewplugins/selectopaque/selectopaque.h
new file mode 100644
index 00000000..5215ecfe
--- /dev/null
+++ b/krita/plugins/viewplugins/selectopaque/selectopaque.h
@@ -0,0 +1,44 @@
+/*
+ * selectopaque.h -- Part of Krita
+ *
+ * Copyright (c) 2004 Boudewijn Rempt ([email protected])
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef SELECTOPAQUE_H
+#define SELECTOPAQUE_H
+
+#include <kparts/plugin.h>
+
+class KisView;
+
+class SelectOpaque : public KParts::Plugin
+{
+ Q_OBJECT
+ public:
+ SelectOpaque(QObject *parent, const char *name, const QStringList &);
+ virtual ~SelectOpaque();
+
+ private slots:
+ void slotActivated();
+
+ private:
+ KisView * m_view;
+ KisPainter * m_painter;
+
+};
+
+#endif // SELECTOPAQUE_H
diff --git a/krita/plugins/viewplugins/selectopaque/selectopaque.rc b/krita/plugins/viewplugins/selectopaque/selectopaque.rc
new file mode 100644
index 00000000..1696d3d0
--- /dev/null
+++ b/krita/plugins/viewplugins/selectopaque/selectopaque.rc
@@ -0,0 +1,10 @@
+<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
+<kpartgui library="kritaselectopaque" version="1">
+<MenuBar>
+ <Menu name="Select"><text>Select</text>
+ <Separator/>
+ <Action name="selectopaque"/>
+ <Separator/>
+ </Menu>
+</MenuBar>
+</kpartgui>