Geometrize  1.0
An application for geometrizing images into geometric primitives
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros
imagetask.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <functional>
4 #include <memory>
5 #include <string>
6 #include <vector>
7 
8 #include <QObject>
9 
10 #include "geometrize/core.h"
11 #include "geometrize/bitmap/bitmap.h"
12 #include "geometrize/bitmap/rgba.h"
13 #include "geometrize/shaperesult.h"
14 #include "geometrize/runner/imagerunneroptions.h"
15 #include "geometrize/shape/shape.h"
16 
18 
19 namespace geometrize
20 {
21 
22 namespace script
23 {
24 class GeometrizerEngine;
25 }
26 
27 }
28 
29 namespace chaiscript
30 {
31 class ChaiScript;
32 }
33 
34 Q_DECLARE_METATYPE(std::vector<geometrize::ShapeResult>)
35 Q_DECLARE_METATYPE(geometrize::ImageRunnerOptions)
36 Q_DECLARE_METATYPE(std::function<std::shared_ptr<geometrize::Shape>()>)
37 Q_DECLARE_METATYPE(std::shared_ptr<geometrize::Shape>)
38 Q_DECLARE_METATYPE(geometrize::rgba)
39 Q_DECLARE_METATYPE(geometrize::core::EnergyFunction);
40 
41 namespace geometrize
42 {
43 
44 namespace task
45 {
46 
50 class ImageTask : public QObject
51 {
52  Q_OBJECT
53 public:
54  ImageTask(Bitmap& target, Qt::ConnectionType workerConnectionType = Qt::QueuedConnection);
55  ImageTask(Bitmap& target, Bitmap& background, Qt::ConnectionType workerConnectionType = Qt::QueuedConnection);
56  ImageTask(const std::string& displayName, Bitmap& bitmap, Qt::ConnectionType workerConnectionType = Qt::QueuedConnection);
57  ImageTask(const std::string& displayName, Bitmap& bitmap, const Bitmap& initial, Qt::ConnectionType workerConnectionType = Qt::QueuedConnection);
58 
59  ImageTask& operator=(const ImageTask&) = delete;
60  ImageTask(const ImageTask&) = delete;
61  virtual ~ImageTask();
62 
67  geometrize::script::GeometrizerEngine& getGeometrizer();
68 
73  Bitmap& getTarget();
74 
79  Bitmap& getCurrent();
80 
85  const Bitmap& getTarget() const;
86 
91  const Bitmap& getCurrent() const;
92 
97  std::uint32_t getWidth() const;
98 
103  std::uint32_t getHeight() const;
104 
109  std::string getDisplayName() const;
110 
115  std::size_t getTaskId() const;
116 
121  bool isStepping() const;
122 
126  void stepModel();
127 
133  void drawShape(const std::shared_ptr<geometrize::Shape> shape, geometrize::rgba color);
134 
139  void drawBackgroundRectangle(geometrize::rgba color);
140 
146 
151  void setPreferences(preferences::ImageTaskPreferences preferences);
152 
153 signals:
157  void signal_step(geometrize::ImageRunnerOptions options, std::function<std::shared_ptr<geometrize::Shape>()> shapeCreator, geometrize::core::EnergyFunction energyFunction);
158 
164  void signal_drawShape(std::shared_ptr<geometrize::Shape> shape, geometrize::rgba color);
165 
169  void signal_modelWillStep();
170 
175  void signal_modelDidStep(std::vector<geometrize::ShapeResult> shapes);
176 
180  void signal_preferencesSet();
181 
182 private:
183  void modelWillStep();
184  void modelDidStep(std::vector<geometrize::ShapeResult> shapes);
185 
187  std::unique_ptr<ImageTaskImpl> d;
188 };
189 
190 }
191 
192 }
The ImageTaskPreferences class models the preferences associated with an image task.
Definition: imagetaskpreferences.h:28
The GeometrizerEngine class encapsulates script-based setup and mutation methods for geometrizing sha...
Definition: geometrizerengine.h:57
std::unique_ptr< ImageTaskImpl > d
Definition: imagetask.h:186
Definition: imagetask.cpp:33
The ImageTask class transforms a source image into a collection of shapes approximating the source im...
Definition: imagetask.h:50