diff --git a/src/core/filters/output/CMakeLists.txt b/src/core/filters/output/CMakeLists.txt index aef15b4c5..f4c516c25 100644 --- a/src/core/filters/output/CMakeLists.txt +++ b/src/core/filters/output/CMakeLists.txt @@ -52,6 +52,7 @@ SET( DepthPerception.cpp DepthPerception.h OrderByModeProvider.cpp OrderByModeProvider.h OrderBySourceColor.cpp OrderBySourceColor.h + OrderByDewarpingModeProvider.cpp OrderByDewarpingModeProvider.h ${exiv2_sources} ) SOURCE_GROUP("Sources" FILES ${sources}) diff --git a/src/core/filters/output/Filter.cpp b/src/core/filters/output/Filter.cpp index 2ae80c22d..cdea130bf 100644 --- a/src/core/filters/output/Filter.cpp +++ b/src/core/filters/output/Filter.cpp @@ -39,6 +39,7 @@ #include "ImageViewTab.h" #include "OrderByModeProvider.h" #include "OrderBySourceColor.h" +#include "OrderByDewarpingModeProvider.h" #include "version.h" #include "FillColorProperty.h" @@ -60,9 +61,11 @@ Filter::Filter( ProviderPtr const default_order; ProviderPtr const order_by_mode(new OrderByModeProvider(m_ptrSettings)); ProviderPtr const order_by_source_color(new OrderBySourceColor(m_ptrSettings, pages)); + ProviderPtr const order_by_dewarping_mode(new OrderByDewarpingModeProvider(m_ptrSettings)); m_pageOrderOptions.push_back(PageOrderOption(tr("Natural order"), default_order)); m_pageOrderOptions.push_back(PageOrderOption(QObject::tr("Processed then unprocessed"), ProviderPtr(new OrderByReadiness()))); m_pageOrderOptions.push_back(PageOrderOption(tr("Order by mode"), order_by_mode)); + m_pageOrderOptions.push_back(PageOrderOption(tr("Order by dewarping mode"), order_by_dewarping_mode)); m_pageOrderOptions.push_back(PageOrderOption(tr("Grayscale sources on top"), order_by_source_color, tr("Groups the pages by presence\nof a non grey color in the source files"))); } diff --git a/src/core/filters/output/OrderByDewarpingModeProvider.cpp b/src/core/filters/output/OrderByDewarpingModeProvider.cpp new file mode 100644 index 000000000..1ccdaf6be --- /dev/null +++ b/src/core/filters/output/OrderByDewarpingModeProvider.cpp @@ -0,0 +1,67 @@ +/* + Scan Tailor - Interactive post-processing tool for scanned pages. + Copyright (C) Joseph Artsimovich + Copyright (C) Alexander Trufanov + + 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 . +*/ + +#include "OrderByDewarpingModeProvider.h" +#include "Params.h" +#include +#include +#include + +namespace output +{ + +OrderByDewarpingModeProvider::OrderByDewarpingModeProvider(IntrusivePtr const& settings) + : m_ptrSettings(settings) +{ +} + +bool +OrderByDewarpingModeProvider::precedes( + PageId const& lhs_page, bool const /*lhs_incomplete*/, + PageId const& rhs_page, bool const /*rhs_incomplete*/) const +{ + DewarpingMode const l_param(m_ptrSettings->getParams(lhs_page).dewarpingMode()); + DewarpingMode const r_param(m_ptrSettings->getParams(rhs_page).dewarpingMode()); + + if (l_param != r_param) { + return l_param < r_param; + } + + return lhs_page < rhs_page; +} + +QString dewarpingMode2String(DewarpingMode const mode) +{ + switch (mode) { + case DewarpingMode::OFF: return QObject::tr("off"); + case DewarpingMode::MANUAL: return QObject::tr("manual"); + case DewarpingMode::MARGINAL: return QObject::tr("marginal"); + case DewarpingMode::AUTO: return QObject::tr("auto"); + default: return QString(); + } +} + +QString +OrderByDewarpingModeProvider::hint(PageId const& page) const +{ + DewarpingMode const param(m_ptrSettings->getParams(page).dewarpingMode()); + return dewarpingMode2String(param); +} + +} // namespace output diff --git a/src/core/filters/output/OrderByDewarpingModeProvider.h b/src/core/filters/output/OrderByDewarpingModeProvider.h new file mode 100644 index 000000000..148d7765c --- /dev/null +++ b/src/core/filters/output/OrderByDewarpingModeProvider.h @@ -0,0 +1,46 @@ +/* + Scan Tailor - Interactive post-processing tool for scanned pages. + Copyright (C) Joseph Artsimovich + Copyright (C) Alexander Trufanov + + 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 . +*/ + +#ifndef ORDER_BY_DEWARPING_MODE_PROVIDER_H_ +#define ORDER_BY_DEWARPING_MODE_PROVIDER_H_ + +#include "Settings.h" +#include "IntrusivePtr.h" +#include "PageOrderProvider.h" + +namespace output +{ + +class OrderByDewarpingModeProvider : public PageOrderProvider +{ +public: + OrderByDewarpingModeProvider(IntrusivePtr const& settings); + + virtual bool precedes( + PageId const& lhs_page, bool lhs_incomplete, + PageId const& rhs_page, bool rhs_incomplete) const; + + virtual QString hint(PageId const& page) const; +private: + IntrusivePtr m_ptrSettings; +}; + +} // namespace output + +#endif //ORDER_BY_DEWARPING_MODE_PROVIDER_H_ diff --git a/src/core/filters/output/OrderByModeProvider.cpp b/src/core/filters/output/OrderByModeProvider.cpp index c35e5527f..bbfa2d20a 100644 --- a/src/core/filters/output/OrderByModeProvider.cpp +++ b/src/core/filters/output/OrderByModeProvider.cpp @@ -83,4 +83,4 @@ OrderByModeProvider::hint(PageId const& page) const return /*res.arg(*/colorMode2String(param.colorMode())/*)*/; } -} // namespace page_split +} // namespace output diff --git a/src/core/filters/output/OrderByModeProvider.h b/src/core/filters/output/OrderByModeProvider.h index e54b1da9e..f2088b581 100644 --- a/src/core/filters/output/OrderByModeProvider.h +++ b/src/core/filters/output/OrderByModeProvider.h @@ -17,8 +17,8 @@ along with this program. If not, see . */ -#ifndef PAGE_SPLIT_ORDER_BY_MODE_PROVIDER_H_ -#define PAGE_SPLIT_ORDER_BY_MODE_PROVIDER_H_ +#ifndef OUTPUT_ORDER_BY_MODE_PROVIDER_H_ +#define OUTPUT_ORDER_BY_MODE_PROVIDER_H_ #include "Settings.h" #include "IntrusivePtr.h" @@ -41,6 +41,6 @@ class OrderByModeProvider : public PageOrderProvider IntrusivePtr m_ptrSettings; }; -} // namespace page_split +} // namespace output -#endif //PAGE_SPLIT_ORDER_BY_MODE_PROVIDER_H_ +#endif //OUTPUT_ORDER_BY_MODE_PROVIDER_H_