Geometrize  1.0
An application for geometrizing images into geometric primitives
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, geometrize::ShapeAcceptancePreconditionFunction addShapePreconditionFunction=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

◆ ImageTaskWorker() [1/3]

geometrize::task::ImageTaskWorker::ImageTaskWorker ( Bitmap &  bitmap)
explicit
16  : QObject(), m_runner{bitmap}, m_working{false}
17 {
18 }

◆ ImageTaskWorker() [2/3]

geometrize::task::ImageTaskWorker::ImageTaskWorker ( Bitmap &  bitmap,
const Bitmap &  initial 
)
20  : QObject(), m_runner{bitmap, initial}, m_working{false}
21 {
22 }

◆ ImageTaskWorker() [3/3]

geometrize::task::ImageTaskWorker::ImageTaskWorker ( const ImageTaskWorker )
delete

◆ ~ImageTaskWorker()

geometrize::task::ImageTaskWorker::~ImageTaskWorker ( )
virtual
25 {
26 }

Member Function Documentation

◆ drawShape()

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.
41 {
42  emit signal_willStep();
43  m_working = true;
44  const geometrize::ShapeResult result{m_runner.getModel().drawShape(shape, color)};
45  m_working = false;
46  emit signal_didStep({ result });
47 }
Here is the caller graph for this function:

◆ getCurrent() [1/2]

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

getCurrent Gets the current working bitmap.

Returns
The current working bitmap.
50 {
51  return m_runner.getCurrent();
52 }
Here is the caller graph for this function:

◆ getCurrent() [2/2]

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

getCurrent Gets the current working bitmap, const-edition.

Returns
The current working bitmap.
60 {
61  return m_runner.getCurrent();
62 }

◆ getRunner()

geometrize::ImageRunner & geometrize::task::ImageTaskWorker::getRunner ( )
70 {
71  return m_runner;
72 }

◆ getTarget() [1/2]

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

getTarget Gets the current target bitmap.

Returns
The current target bitmap.
55 {
56  return m_runner.getTarget();
57 }
Here is the caller graph for this function:

◆ getTarget() [2/2]

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

getTarget Gets the current target bitmap, const-edition.

Returns
The current target bitmap.
65 {
66  return m_runner.getTarget();
67 }

◆ isStepping()

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.
75 {
76  return m_working;
77 }
Here is the caller graph for this function:

◆ operator=()

ImageTaskWorker& geometrize::task::ImageTaskWorker::operator= ( const ImageTaskWorker )
delete

◆ signal_didStep

void geometrize::task::ImageTaskWorker::signal_didStep ( std::vector< geometrize::ShapeResult >  shapes)
signal
Here is the caller graph for this function:

◆ signal_willStep

void geometrize::task::ImageTaskWorker::signal_willStep ( )
signal
Here is the caller graph for this function:

◆ step()

void geometrize::task::ImageTaskWorker::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 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).
addShapePreconditionFunctionAn optional function to determine whether to accept a shape (if unspecified a default implementation is used).
32 {
33  emit signal_willStep();
34  m_working = true;
35  const std::vector<geometrize::ShapeResult> results{m_runner.step(options, shapeCreator, energyFunction, addShapePreconditionFunction)};
36  m_working = false;
37  emit signal_didStep(results);
38 }
Here is the caller graph for this function:

Member Data Documentation

◆ m_runner

ImageRunner geometrize::task::ImageTaskWorker::m_runner
private

◆ m_working

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

The documentation for this class was generated from the following files:
geometrize::task::ImageTaskWorker::signal_willStep
void signal_willStep()
geometrize::task::ImageTaskWorker::m_runner
ImageRunner m_runner
Definition: imagetaskworker.h:90
geometrize::task::ImageTaskWorker::m_working
std::atomic< bool > m_working
Definition: imagetaskworker.h:91
geometrize::task::ImageTaskWorker::signal_didStep
void signal_didStep(std::vector< geometrize::ShapeResult > shapes)