Skip to content

Commit

Permalink
~ Move constants into foundation module
Browse files Browse the repository at this point in the history
  • Loading branch information
4lex4 committed Aug 16, 2019
1 parent 2efcbcb commit c5eba39
Show file tree
Hide file tree
Showing 14 changed files with 11 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/core/BubbleAnimation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/core/ImageMetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "ImageMetadata.h"
#include <Constants.h>

using namespace imageproc::constants;
using namespace constants;

bool ImageMetadata::operator==(const ImageMetadata& other) const {
if (m_size != other.m_size) {
Expand Down
1 change: 1 addition & 0 deletions src/core/ProjectPages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/sequenced_index.hpp>
#include <boost/multi_index_container.hpp>
#include <cassert>
#include <unordered_map>
#include "AbstractRelinker.h"
#include "ImageFileInfo.h"
Expand Down
2 changes: 1 addition & 1 deletion src/core/TiffWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/core/filters/deskew/ImageView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions src/core/filters/output/DewarpingView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion src/core/filters/output/OutputGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,8 @@ void movePointToBottomMargin(BinaryImage& bw_image, std::vector<QPointF>& polyli
}

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

QImage smoothToGrayscale(const QImage& src, const Dpi& dpi) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/filters/page_layout/OptionsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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> settings, const PageSelectionAccessor& page_selection_accessor)
Expand Down
1 change: 1 addition & 0 deletions src/foundation/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
set(sources
Constants.h Constants.cpp
NonCopyable.h intrusive_ptr.h ref_countable.h
AlignedArray.h
FastQueue.h
Expand Down
4 changes: 1 addition & 3 deletions src/imageproc/Constants.cpp → src/foundation/Constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

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

const double DPI2DPM = 1.0 / DPM2DPI;
} // namespace constants
} // namespace imageproc
2 changes: 0 additions & 2 deletions src/imageproc/Constants.h → src/foundation/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#ifndef IMAGEPROC_CONSTANTS_H_
#define IMAGEPROC_CONSTANTS_H_

namespace imageproc {
namespace constants {
extern const double PI;

Expand Down Expand Up @@ -40,5 +39,4 @@ extern const double DPI2DPM;
*/
extern const double DPM2DPI;
} // namespace constants
} // namespace imageproc
#endif
1 change: 0 additions & 1 deletion src/imageproc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
set(sources
Constants.h Constants.cpp
BinaryImage.cpp BinaryImage.h
BinaryThreshold.cpp BinaryThreshold.h
SlicedHistogram.cpp SlicedHistogram.h
Expand Down
2 changes: 0 additions & 2 deletions src/imageproc/Dpi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
#include <QDomElement>
#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) {}
Expand Down
2 changes: 0 additions & 2 deletions src/imageproc/Dpm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#include "Dpi.h"
#include <Constants.h>

using namespace imageproc;

Dpm::Dpm(const QSize size) : m_xDpm(size.width()), m_yDpm(size.height()) {}

Dpm::Dpm(const Dpi dpi)
Expand Down

0 comments on commit c5eba39

Please sign in to comment.