Permalink
Browse files

Initial import.

git-svn-id: https://scantailor.svn.sourceforge.net/svnroot/scantailor/trunk@4 80b70061-164d-0410-b7b7-e274ec932871
  • Loading branch information...
1 parent eb543f8 commit e3f80065fc10b90cf9aecbe05f1c77a40f137d4c jart committed May 13, 2008
Showing 1,932 changed files with 289,494 additions and 0 deletions.
View
@@ -0,0 +1,45 @@
+/*
+ Scan Tailor - Interactive post-processing tool for scanned pages.
+ Copyright (C) 2007-2008 Joseph Artsimovich <joseph_a@mail.ru>
+
+ 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef ABSTRACTCOMMAND_H_
+#define ABSTRACTCOMMAND_H_
+
+#include "RefCountable.h"
+
+template<typename R>
+class AbstractCommand0 : public RefCountable
+{
+public:
+ virtual R operator()() = 0;
+};
+
+template<typename R, typename A1>
+class AbstractCommand1 : public RefCountable
+{
+public:
+ virtual R operator()(A1 arg1) = 0;
+};
+
+template<typename R, typename T1, typename T2>
+class AbstractCommand2 : public RefCountable
+{
+public:
+ virtual R operator()(T1 arg1, T2 arg2) = 0;
+};
+
+#endif
View
@@ -0,0 +1,51 @@
+/*
+ Scan Tailor - Interactive post-processing tool for scanned pages.
+ Copyright (C) 2007-2008 Joseph Artsimovich <joseph_a@mail.ru>
+
+ 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef ABSTRACTFILTER_H_
+#define ABSTRACTFILTER_H_
+
+#include "RefCountable.h"
+#include "PageSequence.h"
+
+class FilterUiInterface;
+class PageId;
+class ProjectReader;
+class ProjectWriter;
+class QString;
+class QDomDocument;
+class QDomElement;
+
+class AbstractFilter : public RefCountable
+{
+public:
+ virtual ~AbstractFilter() {}
+
+ virtual QString getName() const = 0;
+
+ virtual PageSequence::View getView() const = 0;
+
+ virtual void preUpdateUI(FilterUiInterface* ui, PageId const& page_id) = 0;
+
+ virtual QDomElement saveSettings(
+ ProjectWriter const& writer, QDomDocument& doc) const = 0;
+
+ virtual void loadSettings(
+ ProjectReader const& reader, QDomElement const& filters_el) = 0;
+};
+
+#endif
View
@@ -0,0 +1,77 @@
+/*
+ Scan Tailor - Interactive post-processing tool for scanned pages.
+ Copyright (C) 2007-2008 Joseph Artsimovich <joseph_a@mail.ru>
+
+ 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "Application.h.moc"
+#include "NewOpenProjectDialog.h"
+#include "ProjectCreationContext.h"
+#include "ProjectOpeningContext.h"
+
+Application::Application(int& argc, char** argv)
+: QApplication(argc, argv),
+ m_pNewOpenProjectDialog(0)
+{
+}
+
+void
+Application::showNewOpenProjectDialog()
+{
+ if (!m_pNewOpenProjectDialog) {
+ m_pNewOpenProjectDialog = new NewOpenProjectDialog;
+ connect(
+ m_pNewOpenProjectDialog, SIGNAL(newProject()),
+ this, SLOT(newProject())
+ );
+ connect(
+ m_pNewOpenProjectDialog, SIGNAL(openProject()),
+ this, SLOT(openProject())
+ );
+ }
+
+ m_pNewOpenProjectDialog->show();
+}
+
+void
+Application::newProject()
+{
+ m_pNewOpenProjectDialog->hide();
+ ProjectCreationContext* context = new ProjectCreationContext();
+ connect(
+ context, SIGNAL(destroyed(QObject*)),
+ this, SLOT(projectContextDestroyed())
+ );
+}
+
+void
+Application::openProject()
+{
+ m_pNewOpenProjectDialog->hide();
+ ProjectOpeningContext* context = new ProjectOpeningContext();
+ connect(
+ context, SIGNAL(destroyed(QObject*)),
+ this, SLOT(projectContextDestroyed())
+ );
+ context->openProject();
+}
+
+void
+Application::projectContextDestroyed()
+{
+ if (topLevelWidgets().size() == 1) {
+ showNewOpenProjectDialog();
+ }
+}
View
@@ -0,0 +1,47 @@
+/*
+ Scan Tailor - Interactive post-processing tool for scanned pages.
+ Copyright (C) 2007-2008 Joseph Artsimovich <joseph_a@mail.ru>
+
+ 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef APPLICATION_H_
+#define APPLICATION_H_
+
+#include <QApplication>
+
+class NewOpenProjectDialog;
+
+class Application : public QApplication
+{
+ Q_OBJECT
+public:
+ Application(int& argc, char** argv);
+
+ static Application* instance() {
+ return qobject_cast<Application*>(QCoreApplication::instance());
+ }
+
+ void showNewOpenProjectDialog();
+private slots:
+ void newProject();
+
+ void openProject();
+
+ void projectContextDestroyed();
+private:
+ NewOpenProjectDialog* m_pNewOpenProjectDialog;
+};
+
+#endif
View
@@ -0,0 +1,28 @@
+/*
+ Scan Tailor - Interactive post-processing tool for scanned pages.
+ Copyright (C) 2007-2008 Joseph Artsimovich <joseph_a@mail.ru>
+
+ 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef AUTOMANUALMODE_H_
+#define AUTOMANUALMODE_H_
+
+enum AutoManualMode
+{
+ MODE_AUTO,
+ MODE_MANUAL
+};
+
+#endif
View
@@ -0,0 +1,34 @@
+/*
+ Scan Tailor - Interactive post-processing tool for scanned pages.
+ Copyright (C) 2007-2008 Joseph Artsimovich <joseph_a@mail.ru>
+
+ 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "BackgroundTask.h"
+
+char const*
+BackgroundTask::CancelledException::what() const throw()
+{
+ return "BackgroundTask cancelled";
+}
+
+void
+BackgroundTask::throwIfCancelled() const
+{
+ if (isCancelled()) {
+ throw CancelledException();
+ }
+}
+
View
@@ -0,0 +1,54 @@
+/*
+ Scan Tailor - Interactive post-processing tool for scanned pages.
+ Copyright (C) 2007-2008 Joseph Artsimovich <joseph_a@mail.ru>
+
+ 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef BACKGROUNDTASK_H_
+#define BACKGROUNDTASK_H_
+
+#include "AbstractCommand.h"
+#include "IntrusivePtr.h"
+#include "FilterResult.h"
+#include "TaskStatus.h"
+#include <QAtomicInt>
+#include <exception>
+
+class BackgroundTask : public AbstractCommand0<FilterResultPtr>, public TaskStatus
+{
+public:
+ class CancelledException : public std::exception
+ {
+ public:
+ virtual char const* what() const throw();
+ };
+
+ virtual void cancel() { m_cancelFlag.fetchAndStoreRelaxed(1); }
+
+ virtual bool isCancelled() const {
+ return m_cancelFlag.fetchAndAddRelaxed(0) != 0;
+ }
+
+ /**
+ * \brief If cancelled, throws CancelledException.
+ */
+ virtual void throwIfCancelled() const;
+private:
+ mutable QAtomicInt m_cancelFlag;
+};
+
+typedef IntrusivePtr<BackgroundTask> BackgroundTaskPtr;
+
+#endif
View
@@ -0,0 +1,52 @@
+/*
+ Scan Tailor - Interactive post-processing tool for scanned pages.
+ Copyright (C) 2007-2008 Joseph Artsimovich <joseph_a@mail.ru>
+
+ 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "BasicImageView.h.moc"
+
+BasicImageView::BasicImageView(QImage const& image)
+: ImageViewBase(image)
+{
+}
+
+BasicImageView::~BasicImageView()
+{
+}
+
+void
+BasicImageView::wheelEvent(QWheelEvent* const event)
+{
+ handleZooming(event);
+}
+
+void
+BasicImageView::mousePressEvent(QMouseEvent* const event)
+{
+ handleImageDragging(event);
+}
+
+void
+BasicImageView::mouseReleaseEvent(QMouseEvent* const event)
+{
+ handleImageDragging(event);
+}
+
+void
+BasicImageView::mouseMoveEvent(QMouseEvent* const event)
+{
+ handleImageDragging(event);
+}
Oops, something went wrong.

0 comments on commit e3f8006

Please sign in to comment.