Skip to content

Commit

Permalink
Version 1.0.14
Browse files Browse the repository at this point in the history
  • Loading branch information
4lex4 committed Apr 9, 2018
2 parents 91211e0 + 2937ffe commit f6dadc3
Show file tree
Hide file tree
Showing 123 changed files with 450 additions and 764 deletions.
27 changes: 4 additions & 23 deletions AbstractCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,12 @@
#include "ref_countable.h"
#include "intrusive_ptr.h"

template<typename R>
class AbstractCommand0 : public ref_countable {
template<typename Res, typename... ArgTypes>
class AbstractCommand : public ref_countable {
public:
typedef intrusive_ptr<AbstractCommand0> Ptr;
typedef intrusive_ptr<AbstractCommand> Ptr;

virtual R operator()() = 0;
virtual Res operator()(ArgTypes... args) = 0;
};


template<typename R, typename A1>
class AbstractCommand1 : public ref_countable {
public:
typedef intrusive_ptr<AbstractCommand1> Ptr;

virtual R operator()(A1 arg1) = 0;
};


template<typename R, typename T1, typename T2>
class AbstractCommand2 : public ref_countable {
public:
typedef intrusive_ptr<AbstractCommand2> Ptr;

virtual R operator()(T1 arg1, T2 arg2) = 0;
};


#endif // ifndef ABSTRACTCOMMAND_H_
4 changes: 2 additions & 2 deletions BackgroundExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class BackgroundExecutor {
DECLARE_NON_COPYABLE(BackgroundExecutor)

public:
typedef intrusive_ptr<AbstractCommand0<void>> TaskResultPtr;
typedef intrusive_ptr<AbstractCommand0<TaskResultPtr>> TaskPtr;
typedef intrusive_ptr<AbstractCommand<void>> TaskResultPtr;
typedef intrusive_ptr<AbstractCommand<TaskResultPtr>> TaskPtr;

BackgroundExecutor();

Expand Down
2 changes: 1 addition & 1 deletion BackgroundTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <QAtomicInt>
#include <exception>

class BackgroundTask : public AbstractCommand0<FilterResultPtr>, public TaskStatus {
class BackgroundTask : public AbstractCommand<FilterResultPtr>, public TaskStatus {
public:
enum Type { INTERACTIVE, BATCH };

Expand Down
103 changes: 0 additions & 103 deletions BlackOnWhiteEstimator.cpp

This file was deleted.

35 changes: 0 additions & 35 deletions BlackOnWhiteEstimator.h

This file was deleted.

4 changes: 2 additions & 2 deletions BubbleAnimation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ bool BubbleAnimation::nextFrame(const QColor& head_color,

for (int i = 0; i < m_numBubbles; ++i) {
const double angle = -0.5 * PI + 2.0 * PI * (m_curFrame - i) / m_numBubbles;
const double s = sin(angle);
const double c = cos(angle);
const double s = std::sin(angle);
const double c = std::cos(angle);
const QPointF vec(c * reduced_radius, s * reduced_radius);
QRectF r(0.0, 0.0, 2.0 * bubble_radius, 2.0 * bubble_radius);
r.moveCenter(center + vec);
Expand Down
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,6 @@ SET(
DefaultParamsProvider.cpp DefaultParamsProvider.h
DeviationProvider.h
OrderByDeviationProvider.cpp OrderByDeviationProvider.h
BlackOnWhiteEstimator.cpp BlackOnWhiteEstimator.h
ImageSettings.cpp ImageSettings.h
version.h
config.h.in
Expand Down
4 changes: 2 additions & 2 deletions ConsoleBatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ BackgroundTaskPtr ConsoleBatch::createCompositeTask(const PageInfo& page, const
}
assert(fix_orientation_task);

return BackgroundTaskPtr(
new LoadFileTask(BackgroundTask::BATCH, page, m_ptrThumbnailCache, m_ptrPages, fix_orientation_task));
return make_intrusive<LoadFileTask>(BackgroundTask::BATCH, page, m_ptrThumbnailCache, m_ptrPages,
fix_orientation_task);
} // ConsoleBatch::createCompositeTask

// process the image vector **images** and save output to **output_dir**
Expand Down
3 changes: 2 additions & 1 deletion ContentSpanFinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@

using namespace imageproc;

void ContentSpanFinder::findImpl(const SlicedHistogram& histogram, VirtualFunction1<void, Span>& handler) const {
void ContentSpanFinder::findImpl(const SlicedHistogram& histogram,
const VirtualFunction<void, const Span&>& handler) const {
const auto hist_size = static_cast<const int>(histogram.size());

int i = 0;
Expand Down
9 changes: 4 additions & 5 deletions ContentSpanFinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,16 @@ class ContentSpanFinder {
void find(const imageproc::SlicedHistogram& histogram, T handler) const;

private:
void findImpl(const imageproc::SlicedHistogram& histogram, VirtualFunction1<void, Span>& handler) const;
void findImpl(const imageproc::SlicedHistogram& histogram, const VirtualFunction<void, const Span&>& handler) const;

int m_minContentWidth;
int m_minWhitespaceWidth;
};


template<typename T>
void ContentSpanFinder::find(const imageproc::SlicedHistogram& histogram, T handler) const {
ProxyFunction1<T, void, Span> proxy(handler);
findImpl(histogram, proxy);
template<typename Callable>
void ContentSpanFinder::find(const imageproc::SlicedHistogram& histogram, Callable handler) const {
findImpl(histogram, ProxyFunction<Callable, void, const Span&>(handler));
}

#endif // ifndef CONTENTSPANFINDER_H_
9 changes: 4 additions & 5 deletions DebugImageView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <QPointer>
#include <utility>

class DebugImageView::ImageLoadResult : public AbstractCommand0<void> {
class DebugImageView::ImageLoadResult : public AbstractCommand<void> {
public:
ImageLoadResult(QPointer<DebugImageView> owner, const QImage& image)
: m_ptrOwner(std::move(owner)), m_image(image) {
Expand All @@ -44,15 +44,15 @@ class DebugImageView::ImageLoadResult : public AbstractCommand0<void> {
};


class DebugImageView::ImageLoader : public AbstractCommand0<BackgroundExecutor::TaskResultPtr> {
class DebugImageView::ImageLoader : public AbstractCommand<BackgroundExecutor::TaskResultPtr> {
public:
ImageLoader(DebugImageView* owner, const QString& file_path) : m_ptrOwner(owner), m_filePath(file_path) {
}

BackgroundExecutor::TaskResultPtr operator()() override {
QImage image(m_filePath);

return BackgroundExecutor::TaskResultPtr(new ImageLoadResult(m_ptrOwner, image));
return make_intrusive<ImageLoadResult>(m_ptrOwner, image);
}

private:
Expand All @@ -74,8 +74,7 @@ DebugImageView::DebugImageView(AutoRemovingFile file,

void DebugImageView::setLive(const bool live) {
if (live && !m_isLive) {
ImageViewBase::backgroundExecutor().enqueueTask(
BackgroundExecutor::TaskPtr(new ImageLoader(this, m_file.get())));
ImageViewBase::backgroundExecutor().enqueueTask(make_intrusive<ImageLoader>(this, m_file.get()));
} else if (!live && m_isLive) {
if (QWidget* wgt = currentWidget()) {
if (wgt != m_pPlaceholderWidget) {
Expand Down
5 changes: 3 additions & 2 deletions DefaultParams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "DefaultParams.h"
#include "XmlUnmarshaller.h"
#include "XmlMarshaller.h"
#include "Utils.h"

using namespace page_split;
using namespace output;
Expand Down Expand Up @@ -156,7 +157,7 @@ DefaultParams::DeskewParams::DeskewParams(const QDomElement& el)

QDomElement DefaultParams::DeskewParams::toXml(QDomDocument& doc, const QString& name) const {
QDomElement el(doc.createElement(name));
el.setAttribute("deskewAngleDeg", deskewAngleDeg);
el.setAttribute("deskewAngleDeg", Utils::doubleToString(deskewAngleDeg));
el.setAttribute("mode", (mode == MODE_AUTO) ? "auto" : "manual");

return el;
Expand Down Expand Up @@ -405,7 +406,7 @@ QDomElement DefaultParams::OutputParams::toXml(QDomDocument& doc, const QString&
el.appendChild(colorParams.toXml(doc, "colorParams"));
el.appendChild(splittingOptions.toXml(doc, "splittingOptions"));
el.appendChild(pictureShapeOptions.toXml(doc, "pictureShapeOptions"));
el.setAttribute("depthPerception", depthPerception.value());
el.setAttribute("depthPerception", Utils::doubleToString(depthPerception.value()));
el.appendChild(dewarpingOptions.toXml(doc, "dewarpingOptions"));
el.setAttribute("despeckleLevel", despeckleLevelToString(despeckleLevel));

Expand Down
4 changes: 2 additions & 2 deletions Despeckle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ namespace {
* We want horizontal proximity to have greater weight, so we
* multiply the vertical component distances by VERTICAL_SCALE,
* so that the distance is not:\n
* sqrt(dx^2 + dy^2)\n
* std::sqrt(dx^2 + dy^2)\n
* but:\n
* sqrt(dx^2 + (VERTICAL_SCALE*dy)^2)\n
* std::sqrt(dx^2 + (VERTICAL_SCALE*dy)^2)\n
* Keep in mind that we actually operate on squared distances,
* so we don't need to take that square root.
*/
Expand Down
2 changes: 1 addition & 1 deletion DeviationProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void DeviationProvider<K, Hash>::update() const {

template<typename K, typename Hash>
void DeviationProvider<K, Hash>::setComputeValueByKey(const std::function<double(const K&)>& computeValueByKey) {
DeviationProvider::computeValueByKey = computeValueByKey;
this->computeValueByKey = std::move(computeValueByKey);
}

template<typename K, typename Hash>
Expand Down
2 changes: 1 addition & 1 deletion EstimateBackground.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ using namespace imageproc;

struct AbsoluteDifference {
static uint8_t transform(uint8_t src, uint8_t dst) {
return static_cast<uint8_t>(abs(int(src) - int(dst)));
return static_cast<uint8_t>(std::abs(int(src) - int(dst)));
}
};

Expand Down
4 changes: 0 additions & 4 deletions FilterData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ const imageproc::GrayImage& FilterData::grayImage() const {
return m_grayImage;
}

bool FilterData::isBlackOnWhite() const {
return m_imageParams.isBlackOnWhite();
}

void FilterData::updateImageParams(const ImageSettings::PageParams& imageParams) {
m_imageParams = imageParams;
}
2 changes: 0 additions & 2 deletions FilterData.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ class FilterData {

const imageproc::GrayImage& grayImage() const;

bool isBlackOnWhite() const;

void updateImageParams(const ImageSettings::PageParams& imageParams);

private:
Expand Down
2 changes: 1 addition & 1 deletion FilterUiInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class FilterUiInterface {
/**
* Returns a callable object that when called will open a relinking dialog.
*/
virtual intrusive_ptr<AbstractCommand0<void>> relinkingDialogRequester() = 0;
virtual intrusive_ptr<AbstractCommand<void>> relinkingDialogRequester() = 0;
};


Expand Down
4 changes: 2 additions & 2 deletions ImageMetadataLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void ImageMetadataLoader::registerLoader(intrusive_ptr<ImageMetadataLoader> load
}

ImageMetadataLoader::Status ImageMetadataLoader::loadImpl(QIODevice& io_device,
VirtualFunction1<void, const ImageMetadata&>& out) {
const VirtualFunction<void, const ImageMetadata&>& out) {
auto it(m_sLoaders.begin());
const auto end(m_sLoaders.end());
for (; it != end; ++it) {
Expand All @@ -43,7 +43,7 @@ ImageMetadataLoader::Status ImageMetadataLoader::loadImpl(QIODevice& io_device,
}

ImageMetadataLoader::Status ImageMetadataLoader::loadImpl(const QString& file_path,
VirtualFunction1<void, const ImageMetadata&>& out) {
const VirtualFunction<void, const ImageMetadata&>& out) {
QFile file(file_path);
if (!file.open(QIODevice::ReadOnly)) {
return GENERIC_ERROR;
Expand Down
Loading

0 comments on commit f6dadc3

Please sign in to comment.