diff --git a/src/core/BubbleAnimation.cpp b/src/core/BubbleAnimation.cpp index 4cce91782..0df70293d 100644 --- a/src/core/BubbleAnimation.cpp +++ b/src/core/BubbleAnimation.cpp @@ -32,7 +32,7 @@ bool BubbleAnimation::nextFrame(const QColor& head_color, const QPointF center(rect.center()); const double radius = std::min(center.x() - rect.x(), center.y() - rect.y()); - const double PI = imageproc::constants::PI; + const double PI = constants::PI; const double arc_fraction_as_radius = 0.25; // We have the following system of equations: // bubble_radius = arc_between_bubbles * arc_fraction_as_radius; diff --git a/src/core/ImageMetadata.cpp b/src/core/ImageMetadata.cpp index 92661b970..5f558876b 100644 --- a/src/core/ImageMetadata.cpp +++ b/src/core/ImageMetadata.cpp @@ -4,7 +4,7 @@ #include "ImageMetadata.h" #include -using namespace imageproc::constants; +using namespace constants; bool ImageMetadata::operator==(const ImageMetadata& other) const { if (m_size != other.m_size) { diff --git a/src/core/ProjectPages.cpp b/src/core/ProjectPages.cpp index aeb4c9728..44e8717de 100644 --- a/src/core/ProjectPages.cpp +++ b/src/core/ProjectPages.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include "AbstractRelinker.h" #include "ImageFileInfo.h" diff --git a/src/core/TiffWriter.cpp b/src/core/TiffWriter.cpp index c155ae0c1..f68b021d2 100644 --- a/src/core/TiffWriter.cpp +++ b/src/core/TiffWriter.cpp @@ -166,7 +166,7 @@ bool TiffWriter::writeImage(QIODevice& device, const QImage& image) { * Set the physical resolution, if it's defined. */ void TiffWriter::setDpm(const TiffHandle& tif, const Dpm& dpm) { - using namespace imageproc::constants; + using namespace constants; if (dpm.isNull()) { return; diff --git a/src/core/filters/deskew/ImageView.cpp b/src/core/filters/deskew/ImageView.cpp index 6a2245529..feb888c27 100644 --- a/src/core/filters/deskew/ImageView.cpp +++ b/src/core/filters/deskew/ImageView.cpp @@ -14,7 +14,7 @@ namespace deskew { const double ImageView::m_maxRotationDeg = 45.0; -const double ImageView::m_maxRotationSin = std::sin(m_maxRotationDeg * imageproc::constants::DEG2RAD); +const double ImageView::m_maxRotationSin = std::sin(m_maxRotationDeg * constants::DEG2RAD); const int ImageView::m_cellSize = 20; ImageView::ImageView(const QImage& image, const QImage& downscaled_image, const ImageTransformation& xform) @@ -184,7 +184,7 @@ void ImageView::handleMoveRequest(int idx, const QPointF& pos) { if (idx == 0) { angle_rad = -angle_rad; } - double angle_deg = angle_rad * imageproc::constants::RAD2DEG; + double angle_deg = angle_rad * constants::RAD2DEG; angle_deg = qBound(-m_maxRotationDeg, angle_deg, m_maxRotationDeg); if (angle_deg == m_xform.postRotation()) { return; diff --git a/src/core/filters/output/DewarpingView.cpp b/src/core/filters/output/DewarpingView.cpp index 5abd8eb3b..6f0395ca9 100644 --- a/src/core/filters/output/DewarpingView.cpp +++ b/src/core/filters/output/DewarpingView.cpp @@ -16,8 +16,6 @@ #include "spfit/SplineFitter.h" namespace output { -using namespace imageproc; - DewarpingView::DewarpingView(const QImage& image, const ImagePixmapUnion& downscaled_image, const QTransform& image_to_virt, diff --git a/src/core/filters/output/OutputGenerator.cpp b/src/core/filters/output/OutputGenerator.cpp index 58183305e..6e5703a2d 100644 --- a/src/core/filters/output/OutputGenerator.cpp +++ b/src/core/filters/output/OutputGenerator.cpp @@ -1114,7 +1114,8 @@ void movePointToBottomMargin(BinaryImage& bw_image, std::vector& polyli } inline float vertBorderSkewAngle(const QPointF& top, const QPointF& bottom) { - return static_cast(std::abs(std::atan((bottom.x() - top.x()) / (bottom.y() - top.y())) * 180.0 / M_PI)); + return static_cast( + std::abs(std::atan((bottom.x() - top.x()) / (bottom.y() - top.y())) * 180.0 / constants::PI)); } QImage smoothToGrayscale(const QImage& src, const Dpi& dpi) { diff --git a/src/core/filters/page_layout/OptionsWidget.cpp b/src/core/filters/page_layout/OptionsWidget.cpp index abbb0235e..3fc6987d7 100644 --- a/src/core/filters/page_layout/OptionsWidget.cpp +++ b/src/core/filters/page_layout/OptionsWidget.cpp @@ -13,7 +13,7 @@ #include "Settings.h" using namespace core; -using namespace imageproc::constants; +using namespace constants; namespace page_layout { OptionsWidget::OptionsWidget(intrusive_ptr settings, const PageSelectionAccessor& page_selection_accessor) diff --git a/src/foundation/CMakeLists.txt b/src/foundation/CMakeLists.txt index c7c746885..903ca3950 100644 --- a/src/foundation/CMakeLists.txt +++ b/src/foundation/CMakeLists.txt @@ -1,4 +1,5 @@ set(sources + Constants.h Constants.cpp NonCopyable.h intrusive_ptr.h ref_countable.h AlignedArray.h FastQueue.h diff --git a/src/imageproc/Constants.cpp b/src/foundation/Constants.cpp similarity index 86% rename from src/imageproc/Constants.cpp rename to src/foundation/Constants.cpp index 66ff1f8a7..aed82db91 100644 --- a/src/imageproc/Constants.cpp +++ b/src/foundation/Constants.cpp @@ -3,11 +3,10 @@ #include "Constants.h" -namespace imageproc { namespace constants { const double SQRT_2 = 1.4142135623730950488016887242097; -const double PI = 3.141592653589793; +const double PI = 3.141592653589793238462643383279502884; const double DEG2RAD = PI / 180.0; @@ -21,4 +20,3 @@ const double DPM2DPI = 0.0254; const double DPI2DPM = 1.0 / DPM2DPI; } // namespace constants -} // namespace imageproc diff --git a/src/imageproc/Constants.h b/src/foundation/Constants.h similarity index 94% rename from src/imageproc/Constants.h rename to src/foundation/Constants.h index 25e26a9ff..150891878 100644 --- a/src/imageproc/Constants.h +++ b/src/foundation/Constants.h @@ -4,7 +4,6 @@ #ifndef IMAGEPROC_CONSTANTS_H_ #define IMAGEPROC_CONSTANTS_H_ -namespace imageproc { namespace constants { extern const double PI; @@ -40,5 +39,4 @@ extern const double DPI2DPM; */ extern const double DPM2DPI; } // namespace constants -} // namespace imageproc #endif diff --git a/src/imageproc/CMakeLists.txt b/src/imageproc/CMakeLists.txt index d1731939e..a3c712f90 100644 --- a/src/imageproc/CMakeLists.txt +++ b/src/imageproc/CMakeLists.txt @@ -1,5 +1,4 @@ set(sources - Constants.h Constants.cpp BinaryImage.cpp BinaryImage.h BinaryThreshold.cpp BinaryThreshold.h SlicedHistogram.cpp SlicedHistogram.h diff --git a/src/imageproc/Dpi.cpp b/src/imageproc/Dpi.cpp index 48c19093a..81d6b8891 100644 --- a/src/imageproc/Dpi.cpp +++ b/src/imageproc/Dpi.cpp @@ -7,8 +7,6 @@ #include #include "Dpm.h" -using namespace imageproc; - Dpi::Dpi() : m_xDpi(0), m_yDpi(0) {} Dpi::Dpi(int horizontal, int vertical) : m_xDpi(horizontal), m_yDpi(vertical) {} diff --git a/src/imageproc/Dpm.cpp b/src/imageproc/Dpm.cpp index 38f40567e..177a55792 100644 --- a/src/imageproc/Dpm.cpp +++ b/src/imageproc/Dpm.cpp @@ -6,8 +6,6 @@ #include "Dpi.h" #include -using namespace imageproc; - Dpm::Dpm(const QSize size) : m_xDpm(size.width()), m_yDpm(size.height()) {} Dpm::Dpm(const Dpi dpi)