 |
Geometrize
1.0
An application for geometrizing images into geometric primitives
|
Go to the documentation of this file.
10 #include "geometrize/core.h"
11 #include "geometrize/bitmap/bitmap.h"
12 #include "geometrize/bitmap/rgba.h"
13 #include "geometrize/model.h"
14 #include "geometrize/shaperesult.h"
15 #include "geometrize/runner/imagerunneroptions.h"
16 #include "geometrize/shape/shape.h"
25 class GeometrizerEngine;
56 ImageTask(Bitmap& target, Qt::ConnectionType workerConnectionType = Qt::QueuedConnection);
57 ImageTask(Bitmap& target, Bitmap& background, Qt::ConnectionType workerConnectionType = Qt::QueuedConnection);
58 ImageTask(
const std::string& displayName, Bitmap& bitmap, Qt::ConnectionType workerConnectionType = Qt::QueuedConnection);
59 ImageTask(
const std::string& displayName, Bitmap& bitmap,
const Bitmap& initial, Qt::ConnectionType workerConnectionType = Qt::QueuedConnection);
75 Bitmap& getTargetMutable();
81 Bitmap& getCurrentMutable();
87 const Bitmap& getTarget()
const;
93 const Bitmap& getCurrent()
const;
99 std::uint32_t getWidth()
const;
105 std::uint32_t getHeight()
const;
111 std::string getDisplayName()
const;
117 std::size_t getTaskId()
const;
123 bool isStepping()
const;
135 void drawShape(
const std::shared_ptr<geometrize::Shape> shape, geometrize::rgba color);
141 void drawBackgroundRectangle(geometrize::rgba color);
159 void signal_step(geometrize::ImageRunnerOptions options, std::function<std::shared_ptr<geometrize::Shape>()> shapeCreator, geometrize::core::EnergyFunction energyFunction, geometrize::ShapeAcceptancePreconditionFunction addShapePrecondition);
185 void modelWillStep();
186 void modelDidStep(std::vector<geometrize::ShapeResult> shapes);
189 std::unique_ptr<ImageTaskImpl>
d;
std::string getDisplayName() const
Definition: imagetask.cpp:97
Definition: imagetask.cpp:34
virtual ~ImageTask()
Definition: imagetask.cpp:318
void signal_modelWillStep()
signal_modelWillStep Signal that is emitted immediately before the underlying image task model is ste...
bool isScriptModeEnabled() const
Definition: imagetaskpreferences.cpp:320
void stepModel()
Definition: imagetask.cpp:112
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:40
const std::size_t m_id
The display name of the image task.
Definition: imagetask.cpp:292
const Bitmap & getTarget() const
getTarget Gets the target bitmap, const-edition.
Definition: imagetask.cpp:332
chaiscript::ChaiScript * getEngine()
getEngine Gets a pointer to the script engine used by the shape mutation engine.
Definition: geometrizerengine.cpp:52
~ImageTaskImpl()
Definition: imagetask.cpp:48
ImageTask * q
Definition: imagetask.cpp:289
void drawShape(const std::shared_ptr< geometrize::Shape > shape, const geometrize::rgba color)
Definition: imagetask.cpp:202
void init(const Qt::ConnectionType connectionType)
Definition: imagetask.cpp:245
void drawBackgroundRectangle(const geometrize::rgba color)
Definition: imagetask.cpp:207
std::uint32_t getWidth() const
Definition: imagetask.cpp:87
ImageTaskImpl(const ImageTaskImpl &)=delete
std::map< std::string, std::string > getScripts() const
Definition: imagetaskpreferences.cpp:335
ImageTask(const ImageTask &)=delete
Bitmap & getTarget()
Definition: imagetask.cpp:67
std::unique_ptr< ImageTaskImpl > d
Definition: imagetask.h:188
std::uint32_t getHeight() const
Definition: imagetask.cpp:92
Bitmap & getCurrent()
Definition: imagetask.cpp:72
const Bitmap & getCurrent() const
getCurrent Gets the current bitmap, const-edition.
Definition: imagetask.cpp:337
void drawBackgroundRectangle(geometrize::rgba color)
drawBackgroundRectangle Convenience function that draws a background rectangle shape.
Definition: imagetask.cpp:377
std::uint32_t getHeight() const
getHeight Gets the height of the images used by the image task.
Definition: imagetask.cpp:347
geometrize::Bitmap & getCurrent()
getCurrent Gets the current working bitmap.
Definition: imagetaskworker.cpp:49
ImageTaskImpl & operator=(const ImageTaskImpl &)=delete
ImageTask(Bitmap &target, Qt::ConnectionType workerConnectionType=Qt::QueuedConnection)
Definition: imagetask.cpp:298
Definition: commandlineedit.h:11
std::size_t getTaskId() const
getTaskId Gets the unique id of the image task.
Definition: imagetask.cpp:357
The ImageTaskPreferences class models the preferences associated with an image task.
Definition: imagetaskpreferences.h:29
geometrize::ImageRunnerOptions getImageRunnerOptions() const
getImageRunnerOptions Gets a copy of the image runner options.
Definition: imagetaskpreferences.cpp:235
void drawShape(const std::shared_ptr< geometrize::Shape > shape, geometrize::rgba color)
drawShape Draws a shape with the given color to the internal model.
Definition: imagetask.cpp:372
void disconnectAll()
Definition: imagetask.cpp:281
const Bitmap & getCurrent() const
Definition: imagetask.cpp:82
preferences::ImageTaskPreferences & getPreferences()
Definition: imagetask.cpp:227
void modelDidStep(std::vector< geometrize::ShapeResult > shapes)
Definition: imagetask.cpp:387
geometrize::Bitmap & getTarget()
getTarget Gets the current target bitmap.
Definition: imagetaskworker.cpp:54
QThread m_workerThread
A unique id for the image task.
Definition: imagetask.cpp:293
const Bitmap & getTarget() const
Definition: imagetask.cpp:77
Bitmap & getCurrentMutable()
getCurrent Gets the current bitmap, non-const edition.
Definition: imagetask.cpp:327
void modelWillStep()
Definition: imagetask.cpp:217
Definition: commandlineparser.cpp:73
void setPreferences(const preferences::ImageTaskPreferences preferences)
Definition: imagetask.cpp:232
ImageTaskImpl(ImageTask *pQ, const std::string &displayName, Bitmap &bitmap, const Bitmap &initial, Qt::ConnectionType workerConnectionType)
Definition: imagetask.cpp:42
The ImageTaskWorker class transforms a source image into a collection of shapes. It is made to be run...
Definition: imagetaskworker.h:25
bool isStepping() const
isStepping Returns true if the internal model is currently stepping.
Definition: imagetaskworker.cpp:74
void step(geometrize::ImageRunnerOptions options, std::function< std::shared_ptr< geometrize::Shape >()> shapeCreator, geometrize::core::EnergyFunction energyFunction=nullptr, geometrize::ShapeAcceptancePreconditionFunction addShapePreconditionFunction=nullptr)
step Steps the image task worker. Emits the willStep signal when called, and didStep signal on comple...
Definition: imagetaskworker.cpp:28
Q_DECLARE_METATYPE(std::vector< geometrize::ShapeResult >) Q_DECLARE_METATYPE(geometrize Q_DECLARE_METATYPE(geometrize::ShapeAcceptancePreconditionFunction)
< Energy function passed to the image task worker thread.
void connectSignals(const Qt::ConnectionType connectionType)
Definition: imagetask.cpp:273
void signal_step(geometrize::ImageRunnerOptions options, std::function< std::shared_ptr< geometrize::Shape >()> shapeCreator, geometrize::core::EnergyFunction energyFunction, geometrize::ShapeAcceptancePreconditionFunction addShapePrecondition)
signal_step Signal that the image task emits to make the internal model step.
Bitmap & getTargetMutable()
getTarget Gets the target bitmap, non-const edition.
Definition: imagetask.cpp:322
geometrize::script::GeometrizerEngine & getGeometrizer()
getGeometrizer Gets a reference to the script-based engine used to turn images into shapes.
Definition: imagetask.cpp:402
const std::string m_displayName
Runtime configuration parameters for the runner.
Definition: imagetask.cpp:291
void signal_didStep(std::vector< geometrize::ShapeResult > shapes)
std::uint32_t getWidth() const
getWidth Gets the width of the images used by the image task.
Definition: imagetask.cpp:342
preferences::ImageTaskPreferences m_preferences
Definition: imagetask.cpp:290
void setPreferences(preferences::ImageTaskPreferences preferences)
setPreferences Sets the preferences for this task.
Definition: imagetask.cpp:397
void modelDidStep(const std::vector< geometrize::ShapeResult > shapes)
Definition: imagetask.cpp:222
The ImageTask class transforms a source image into a collection of shapes approximating the source im...
Definition: imagetask.h:53
void installScripts(const std::map< std::string, std::string > &scripts)
Definition: geometrizerengine.cpp:57
ImageTaskWorker m_worker
Thread that the image task worker runs on.
Definition: imagetask.cpp:294
geometrize::script::GeometrizerEngine & getGeometrizer()
Definition: imagetask.cpp:62
ImageTask & operator=(const ImageTask &)=delete
std::size_t getTaskId() const
Definition: imagetask.cpp:102
geometrize::script::GeometrizerEngine m_geometrizer
The image task worker.
Definition: imagetask.cpp:295
bool isStepping() const
isStepping Returns true if the internal model is currently stepping.
Definition: imagetask.cpp:362
bool isStepping() const
Definition: imagetask.cpp:107
The GeometrizerEngine class encapsulates script-based setup and mutation methods for geometrizing sha...
Definition: geometrizerengine.h:58
void signal_modelDidStep(std::vector< geometrize::ShapeResult > shapes)
signal_modelDidStep Signal that is emitted immediately after the underlying image task model is stepp...
void modelWillStep()
Definition: imagetask.cpp:382
ImageTaskImpl(ImageTask *pQ, const std::string &displayName, Bitmap &bitmap, Qt::ConnectionType workerConnectionType)
Definition: imagetask.cpp:36
geometrize::preferences::ImageTaskPreferences & getPreferences()
getPreferences Gets a reference to the current preferences of this task.
Definition: imagetask.cpp:392
void signal_preferencesSet()
signal_preferencesSet Signal that is emitted immediately after the image task preferences are set.
void stepModel()
stepModel Steps the internal model, typically adding a shape.
Definition: imagetask.cpp:367
std::string getDisplayName() const
getDisplayName Gets the display name of the image task.
Definition: imagetask.cpp:352
void signal_drawShape(std::shared_ptr< geometrize::Shape > shape, geometrize::rgba color)
signal_drawShape Signal that the image task emits to draw a shape to the internal model.
static std::size_t getId()
Definition: imagetask.cpp:239