Geometrize  1.0
An application for geometrizing images into geometric primitives
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros
Signals | Public Member Functions | Private Attributes | List of all members
geometrize::task::ImageTaskWorker Class Reference

The ImageTaskWorker class transforms a source image into a collection of shapes. It is made to be run on its own thread to avoid blocking the UI. More...

#include <imagetaskworker.h>

Inheritance diagram for geometrize::task::ImageTaskWorker:
Inheritance graph
[legend]
Collaboration diagram for geometrize::task::ImageTaskWorker:
Collaboration graph
[legend]

Signals

void signal_willStep ()
 
void signal_didStep (std::vector< geometrize::ShapeResult > shapes)
 

Public Member Functions

 ImageTaskWorker (Bitmap &bitmap)
 
 ImageTaskWorker (Bitmap &bitmap, const Bitmap &initial)
 
ImageTaskWorkeroperator= (const ImageTaskWorker &)=delete
 
 ImageTaskWorker (const ImageTaskWorker &)=delete
 
virtual ~ImageTaskWorker ()
 
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 completion. More...
 
bool isStepping () const
 isStepping Returns true if the internal model is currently stepping. More...
 
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, and didStep signal on completion. More...
 
geometrize::Bitmap & getCurrent ()
 getCurrent Gets the current working bitmap. More...
 
geometrize::Bitmap & getTarget ()
 getTarget Gets the current target bitmap. More...
 
const geometrize::Bitmap & getCurrent () const
 getCurrent Gets the current working bitmap, const-edition. More...
 
const geometrize::Bitmap & getTarget () const
 getTarget Gets the current target bitmap, const-edition. More...
 
ImageRunner & getRunner ()
 

Private Attributes

ImageRunner m_runner
 
std::atomic< bool > m_working
 

Detailed Description

The ImageTaskWorker class transforms a source image into a collection of shapes. It is made to be run on its own thread to avoid blocking the UI.

Constructor & Destructor Documentation

geometrize::task::ImageTaskWorker::ImageTaskWorker ( Bitmap &  bitmap)
explicit
16  : QObject(), m_runner{bitmap}, m_working{false}
17 {
18 }
ImageRunner m_runner
Definition: imagetaskworker.h:86
std::atomic< bool > m_working
Definition: imagetaskworker.h:87
geometrize::task::ImageTaskWorker::ImageTaskWorker ( Bitmap &  bitmap,
const Bitmap &  initial 
)
20  : QObject(), m_runner{bitmap, initial}, m_working{false}
21 {
22 }
ImageRunner m_runner
Definition: imagetaskworker.h:86
std::atomic< bool > m_working
Definition: imagetaskworker.h:87
geometrize::task::ImageTaskWorker::ImageTaskWorker ( const ImageTaskWorker )
delete
geometrize::task::ImageTaskWorker::~ImageTaskWorker ( )
virtual
25 {
26 }

Member Function Documentation

void geometrize::task::ImageTaskWorker::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, and didStep signal on completion.

Parameters
shapeThe shape to draw.
colorThe color of the shape to draw.
38 {
39  emit signal_willStep();
40  m_working = true;
41  const geometrize::ShapeResult result{m_runner.getModel().drawShape(shape, color)};
42  m_working = false;
43  emit signal_didStep({ result });
44 }
ImageRunner m_runner
Definition: imagetaskworker.h:86
std::atomic< bool > m_working
Definition: imagetaskworker.h:87
void signal_didStep(std::vector< geometrize::ShapeResult > shapes)

Here is the caller graph for this function:

geometrize::Bitmap & geometrize::task::ImageTaskWorker::getCurrent ( )

getCurrent Gets the current working bitmap.

Returns
The current working bitmap.
47 {
48  return m_runner.getCurrent();
49 }
ImageRunner m_runner
Definition: imagetaskworker.h:86

Here is the caller graph for this function:

const geometrize::Bitmap & geometrize::task::ImageTaskWorker::getCurrent ( ) const

getCurrent Gets the current working bitmap, const-edition.

Returns
The current working bitmap.
57 {
58  return m_runner.getCurrent();
59 }
ImageRunner m_runner
Definition: imagetaskworker.h:86
geometrize::ImageRunner & geometrize::task::ImageTaskWorker::getRunner ( )
67 {
68  return m_runner;
69 }
ImageRunner m_runner
Definition: imagetaskworker.h:86
geometrize::Bitmap & geometrize::task::ImageTaskWorker::getTarget ( )

getTarget Gets the current target bitmap.

Returns
The current target bitmap.
52 {
53  return m_runner.getTarget();
54 }
ImageRunner m_runner
Definition: imagetaskworker.h:86

Here is the caller graph for this function:

const geometrize::Bitmap & geometrize::task::ImageTaskWorker::getTarget ( ) const

getTarget Gets the current target bitmap, const-edition.

Returns
The current target bitmap.
62 {
63  return m_runner.getTarget();
64 }
ImageRunner m_runner
Definition: imagetaskworker.h:86
bool geometrize::task::ImageTaskWorker::isStepping ( ) const

isStepping Returns true if the internal model is currently stepping.

Returns
True if the internal model is currently stepping, else false.
72 {
73  return m_working;
74 }
std::atomic< bool > m_working
Definition: imagetaskworker.h:87

Here is the caller graph for this function:

ImageTaskWorker& geometrize::task::ImageTaskWorker::operator= ( const ImageTaskWorker )
delete
void geometrize::task::ImageTaskWorker::signal_didStep ( std::vector< geometrize::ShapeResult >  shapes)
signal

Here is the caller graph for this function:

void geometrize::task::ImageTaskWorker::signal_willStep ( )
signal

Here is the caller graph for this function:

void geometrize::task::ImageTaskWorker::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 completion.

Parameters
optionsThe options to provide the image runner when stepping.
shapeCreatorA function that produces the shapes when stepping.
energyFunctionAn optional function to calculate the energy (if unspecified a default implementation is used).
29 {
30  emit signal_willStep();
31  m_working = true;
32  const std::vector<geometrize::ShapeResult> results{m_runner.step(options, shapeCreator, energyFunction)};
33  m_working = false;
34  emit signal_didStep(results);
35 }
ImageRunner m_runner
Definition: imagetaskworker.h:86
std::atomic< bool > m_working
Definition: imagetaskworker.h:87
void signal_didStep(std::vector< geometrize::ShapeResult > shapes)

Here is the caller graph for this function:

Member Data Documentation

ImageRunner geometrize::task::ImageTaskWorker::m_runner
private
std::atomic<bool> geometrize::task::ImageTaskWorker::m_working
private

The documentation for this class was generated from the following files: