Geometrize  1.0
An application for geometrizing images into geometric primitives
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros
imagetaskworker.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <atomic>
4 #include <memory>
5 
6 #include <QObject>
7 
8 #include "geometrize/core.h"
9 #include "geometrize/bitmap/bitmap.h"
10 #include "geometrize/runner/imagerunner.h"
11 #include "geometrize/runner/imagerunneroptions.h"
12 #include "geometrize/shaperesult.h"
13 
14 namespace geometrize
15 {
16 
17 namespace task
18 {
19 
24 class ImageTaskWorker : public QObject
25 {
26  Q_OBJECT
27 public:
28  explicit ImageTaskWorker(Bitmap& bitmap);
29  ImageTaskWorker(Bitmap& bitmap, const Bitmap& initial);
30  ImageTaskWorker& operator=(const ImageTaskWorker&) = delete;
31  ImageTaskWorker(const ImageTaskWorker&) = delete;
32  virtual ~ImageTaskWorker();
33 
40  void step(geometrize::ImageRunnerOptions options, std::function<std::shared_ptr<geometrize::Shape>()> shapeCreator, geometrize::core::EnergyFunction energyFunction = nullptr);
41 
46  bool isStepping() const;
47 
53  void drawShape(std::shared_ptr<geometrize::Shape> shape, geometrize::rgba color);
54 
59  geometrize::Bitmap& getCurrent();
60 
65  geometrize::Bitmap& getTarget();
66 
71  const geometrize::Bitmap& getCurrent() const;
72 
77  const geometrize::Bitmap& getTarget() const;
78 
79  ImageRunner& getRunner();
80 
81 signals:
82  void signal_willStep();
83  void signal_didStep(std::vector<geometrize::ShapeResult> shapes);
84 
85 private:
86  ImageRunner m_runner;
87  std::atomic<bool> m_working;
88 };
89 
90 }
91 
92 }
ImageRunner m_runner
Definition: imagetaskworker.h:86
bool isStepping() const
isStepping Returns true if the internal model is currently stepping.
Definition: imagetaskworker.cpp:71
geometrize::Bitmap & getCurrent()
getCurrent Gets the current working bitmap.
Definition: imagetaskworker.cpp:46
std::atomic< bool > m_working
Definition: imagetaskworker.h:87
geometrize::Bitmap & getTarget()
getTarget Gets the current target bitmap.
Definition: imagetaskworker.cpp:51
ImageTaskWorker & operator=(const ImageTaskWorker &)=delete
virtual ~ImageTaskWorker()
Definition: imagetaskworker.cpp:24
void signal_didStep(std::vector< geometrize::ShapeResult > shapes)
ImageTaskWorker(Bitmap &bitmap)
Definition: imagetaskworker.cpp:16
ImageRunner & getRunner()
Definition: imagetaskworker.cpp:66
The ImageTaskWorker class transforms a source image into a collection of shapes. It is made to be run...
Definition: imagetaskworker.h:24
void step(geometrize::ImageRunnerOptions options, std::function< std::shared_ptr< geometrize::Shape >()> shapeCreator, geometrize::core::EnergyFunction energyFunction=nullptr)
step Steps the image task worker. Emits the willStep signal when called, and didStep signal on comple...
Definition: imagetaskworker.cpp:28
void drawShape(std::shared_ptr< geometrize::Shape > shape, geometrize::rgba color)
drawShape Draws a shape with the given color to the image task. Emits the willStep signal when called...
Definition: imagetaskworker.cpp:37