Skip to content

Commit c5eba39

Browse files
committed
~ Move constants into foundation module
1 parent 2efcbcb commit c5eba39

File tree

14 files changed

+11
-19
lines changed

14 files changed

+11
-19
lines changed

src/core/BubbleAnimation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ bool BubbleAnimation::nextFrame(const QColor& head_color,
3232
const QPointF center(rect.center());
3333
const double radius = std::min(center.x() - rect.x(), center.y() - rect.y());
3434

35-
const double PI = imageproc::constants::PI;
35+
const double PI = constants::PI;
3636
const double arc_fraction_as_radius = 0.25;
3737
// We have the following system of equations:
3838
// bubble_radius = arc_between_bubbles * arc_fraction_as_radius;

src/core/ImageMetadata.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "ImageMetadata.h"
55
#include <Constants.h>
66

7-
using namespace imageproc::constants;
7+
using namespace constants;
88

99
bool ImageMetadata::operator==(const ImageMetadata& other) const {
1010
if (m_size != other.m_size) {

src/core/ProjectPages.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <boost/multi_index/ordered_index.hpp>
99
#include <boost/multi_index/sequenced_index.hpp>
1010
#include <boost/multi_index_container.hpp>
11+
#include <cassert>
1112
#include <unordered_map>
1213
#include "AbstractRelinker.h"
1314
#include "ImageFileInfo.h"

src/core/TiffWriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ bool TiffWriter::writeImage(QIODevice& device, const QImage& image) {
166166
* Set the physical resolution, if it's defined.
167167
*/
168168
void TiffWriter::setDpm(const TiffHandle& tif, const Dpm& dpm) {
169-
using namespace imageproc::constants;
169+
using namespace constants;
170170

171171
if (dpm.isNull()) {
172172
return;

src/core/filters/deskew/ImageView.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
namespace deskew {
1616
const double ImageView::m_maxRotationDeg = 45.0;
17-
const double ImageView::m_maxRotationSin = std::sin(m_maxRotationDeg * imageproc::constants::DEG2RAD);
17+
const double ImageView::m_maxRotationSin = std::sin(m_maxRotationDeg * constants::DEG2RAD);
1818
const int ImageView::m_cellSize = 20;
1919

2020
ImageView::ImageView(const QImage& image, const QImage& downscaled_image, const ImageTransformation& xform)
@@ -184,7 +184,7 @@ void ImageView::handleMoveRequest(int idx, const QPointF& pos) {
184184
if (idx == 0) {
185185
angle_rad = -angle_rad;
186186
}
187-
double angle_deg = angle_rad * imageproc::constants::RAD2DEG;
187+
double angle_deg = angle_rad * constants::RAD2DEG;
188188
angle_deg = qBound(-m_maxRotationDeg, angle_deg, m_maxRotationDeg);
189189
if (angle_deg == m_xform.postRotation()) {
190190
return;

src/core/filters/output/DewarpingView.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
#include "spfit/SplineFitter.h"
1717

1818
namespace output {
19-
using namespace imageproc;
20-
2119
DewarpingView::DewarpingView(const QImage& image,
2220
const ImagePixmapUnion& downscaled_image,
2321
const QTransform& image_to_virt,

src/core/filters/output/OutputGenerator.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,8 @@ void movePointToBottomMargin(BinaryImage& bw_image, std::vector<QPointF>& polyli
11141114
}
11151115

11161116
inline float vertBorderSkewAngle(const QPointF& top, const QPointF& bottom) {
1117-
return static_cast<float>(std::abs(std::atan((bottom.x() - top.x()) / (bottom.y() - top.y())) * 180.0 / M_PI));
1117+
return static_cast<float>(
1118+
std::abs(std::atan((bottom.x() - top.x()) / (bottom.y() - top.y())) * 180.0 / constants::PI));
11181119
}
11191120

11201121
QImage smoothToGrayscale(const QImage& src, const Dpi& dpi) {

src/core/filters/page_layout/OptionsWidget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include "Settings.h"
1414

1515
using namespace core;
16-
using namespace imageproc::constants;
16+
using namespace constants;
1717

1818
namespace page_layout {
1919
OptionsWidget::OptionsWidget(intrusive_ptr<Settings> settings, const PageSelectionAccessor& page_selection_accessor)

src/foundation/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
set(sources
2+
Constants.h Constants.cpp
23
NonCopyable.h intrusive_ptr.h ref_countable.h
34
AlignedArray.h
45
FastQueue.h

src/imageproc/Constants.cpp renamed to src/foundation/Constants.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33

44
#include "Constants.h"
55

6-
namespace imageproc {
76
namespace constants {
87
const double SQRT_2 = 1.4142135623730950488016887242097;
98

10-
const double PI = 3.141592653589793;
9+
const double PI = 3.141592653589793238462643383279502884;
1110

1211
const double DEG2RAD = PI / 180.0;
1312

@@ -21,4 +20,3 @@ const double DPM2DPI = 0.0254;
2120

2221
const double DPI2DPM = 1.0 / DPM2DPI;
2322
} // namespace constants
24-
} // namespace imageproc

0 commit comments

Comments
 (0)