 |
Geometrize
1.0
An application for geometrizing images into geometric primitives
|
|
static std::size_t | getId () |
|
◆ ImageTaskImpl() [1/3]
geometrize::task::ImageTask::ImageTaskImpl::ImageTaskImpl |
( |
ImageTask * |
pQ, |
|
|
const std::string & |
displayName, |
|
|
Bitmap & |
bitmap, |
|
|
Qt::ConnectionType |
workerConnectionType |
|
) |
| |
|
inline |
39 init(workerConnectionType);
◆ ImageTaskImpl() [2/3]
geometrize::task::ImageTask::ImageTaskImpl::ImageTaskImpl |
( |
ImageTask * |
pQ, |
|
|
const std::string & |
displayName, |
|
|
Bitmap & |
bitmap, |
|
|
const Bitmap & |
initial, |
|
|
Qt::ConnectionType |
workerConnectionType |
|
) |
| |
|
inline |
45 init(workerConnectionType);
◆ ~ImageTaskImpl()
geometrize::task::ImageTask::ImageTaskImpl::~ImageTaskImpl |
( |
| ) |
|
|
inline |
◆ ImageTaskImpl() [3/3]
geometrize::task::ImageTask::ImageTaskImpl::ImageTaskImpl |
( |
const ImageTaskImpl & |
| ) |
|
|
delete |
◆ connectSignals()
void geometrize::task::ImageTask::ImageTaskImpl::connectSignals |
( |
const Qt::ConnectionType |
connectionType | ) |
|
|
inlineprivate |
◆ disconnectAll()
void geometrize::task::ImageTask::ImageTaskImpl::disconnectAll |
( |
| ) |
|
|
inlineprivate |
◆ drawBackgroundRectangle()
void geometrize::task::ImageTask::ImageTaskImpl::drawBackgroundRectangle |
( |
const geometrize::rgba |
color | ) |
|
|
inline |
211 const std::shared_ptr<geometrize::Rectangle> rectangle = std::make_shared<geometrize::Rectangle>(0, 0, w, h);
212 rectangle->rasterize = [w, h](
const geometrize::Shape& s) {
return geometrize::rasterize(
static_cast<const geometrize::Rectangle&
>(s), 0, 0, w, h); };
◆ drawShape()
void geometrize::task::ImageTask::ImageTaskImpl::drawShape |
( |
const std::shared_ptr< geometrize::Shape > |
shape, |
|
|
const geometrize::rgba |
color |
|
) |
| |
|
inline |
◆ getCurrent() [1/2]
Bitmap& geometrize::task::ImageTask::ImageTaskImpl::getCurrent |
( |
| ) |
|
|
inline |
◆ getCurrent() [2/2]
const Bitmap& geometrize::task::ImageTask::ImageTaskImpl::getCurrent |
( |
| ) |
const |
|
inline |
◆ getDisplayName()
std::string geometrize::task::ImageTask::ImageTaskImpl::getDisplayName |
( |
| ) |
const |
|
inline |
◆ getGeometrizer()
◆ getHeight()
std::uint32_t geometrize::task::ImageTask::ImageTaskImpl::getHeight |
( |
| ) |
const |
|
inline |
◆ getId()
static std::size_t geometrize::task::ImageTask::ImageTaskImpl::getId |
( |
| ) |
|
|
inlinestaticprivate |
241 static std::atomic<std::size_t>
id{0U};
◆ getPreferences()
◆ getTarget() [1/2]
Bitmap& geometrize::task::ImageTask::ImageTaskImpl::getTarget |
( |
| ) |
|
|
inline |
◆ getTarget() [2/2]
const Bitmap& geometrize::task::ImageTask::ImageTaskImpl::getTarget |
( |
| ) |
const |
|
inline |
◆ getTaskId()
std::size_t geometrize::task::ImageTask::ImageTaskImpl::getTaskId |
( |
| ) |
const |
|
inline |
◆ getWidth()
std::uint32_t geometrize::task::ImageTask::ImageTaskImpl::getWidth |
( |
| ) |
const |
|
inline |
◆ init()
void geometrize::task::ImageTask::ImageTaskImpl::init |
( |
const Qt::ConnectionType |
connectionType | ) |
|
|
inlineprivate |
251 const auto [xMin, yMin, xMax, yMax] = geometrize::commonutil::mapShapeBoundsToImage(shapeBounds,
getTarget());
258 qRegisterMetaType<std::vector<geometrize::ShapeResult>>();
259 qRegisterMetaType<geometrize::ImageRunnerOptions>();
260 qRegisterMetaType<std::function<std::shared_ptr<geometrize::Shape>()>>();
261 qRegisterMetaType<std::shared_ptr<geometrize::Shape>>();
262 qRegisterMetaType<geometrize::rgba>();
263 qRegisterMetaType<geometrize::core::EnergyFunction>();
264 qRegisterMetaType<geometrize::ShapeAcceptancePreconditionFunction>();
◆ isStepping()
bool geometrize::task::ImageTask::ImageTaskImpl::isStepping |
( |
| ) |
const |
|
inline |
◆ modelDidStep()
void geometrize::task::ImageTask::ImageTaskImpl::modelDidStep |
( |
const std::vector< geometrize::ShapeResult > |
shapes | ) |
|
|
inline |
◆ modelWillStep()
void geometrize::task::ImageTask::ImageTaskImpl::modelWillStep |
( |
| ) |
|
|
inline |
◆ operator=()
◆ setPreferences()
◆ stepModel()
void geometrize::task::ImageTask::ImageTaskImpl::stepModel |
( |
| ) |
|
|
inline |
121 std::vector<std::pair<std::string, std::string>> addShapePreconditionScripts;
123 if(QString::fromStdString(script.first).startsWith(
"add_shape_precondition_")) {
124 addShapePreconditionScripts.push_back(std::make_pair(script.first, script.second));
128 const auto addShapePreconditionFunction =
129 [
this](
const std::vector<std::pair<std::string, std::string>>& scripts)
130 -> geometrize::ShapeAcceptancePreconditionFunction
132 if(scripts.empty()) {
136 const geometrize::ShapeAcceptancePreconditionFunction g = [
this, scripts](
double lastScore,
138 const geometrize::Shape& shape,
139 const std::vector<geometrize::Scanline>& lines,
140 const geometrize::rgba& color,
141 const geometrize::Bitmap& before,
142 const geometrize::Bitmap& after,
143 const geometrize::Bitmap& target) {
144 std::vector<bool> retValues;
155 for(
const auto& script : scripts) {
158 return std::all_of(retValues.begin(), retValues.end(), [](
const bool b) { return b == true; });
159 }
catch(std::exception& e) {
160 std::cout << e.what() << std::endl;
165 }(addShapePreconditionScripts);
168 if(!isScriptModeEnabled) {
169 emit
q->
signal_step(imageRunnerOptions,
nullptr,
nullptr, addShapePreconditionFunction);
175 const auto bounds = geometrize::commonutil::mapShapeBoundsToImage(imageRunnerOptions.shapeBounds, target);
180 const auto geometrizerEngineClone = [
this]() {
181 auto engine = std::make_shared<geometrize::script::GeometrizerEngine>(
m_geometrizer.
getEngine()->get_state());
187 const auto shapeCreator = [geometrizerEngineClone, imageRunnerOptions, bounds]() {
189 const auto [xMin, yMin, xMax, yMax] = bounds;
190 return geometrizerEngineClone->makeShapeCreator(imageRunnerOptions.shapeTypes, xMin, yMin, xMax, yMax);
194 const geometrize::core::EnergyFunction energyFunction = [geometrizerEngineClone]() {
196 return geometrizerEngineClone->makeEnergyFunction();
199 emit
q->
signal_step(imageRunnerOptions, shapeCreator, energyFunction, addShapePreconditionFunction);
◆ m_displayName
const std::string geometrize::task::ImageTask::ImageTaskImpl::m_displayName |
|
private |
Runtime configuration parameters for the runner.
◆ m_geometrizer
◆ m_id
const std::size_t geometrize::task::ImageTask::ImageTaskImpl::m_id |
|
private |
The display name of the image task.
◆ m_preferences
◆ m_worker
Thread that the image task worker runs on.
◆ m_workerThread
QThread geometrize::task::ImageTask::ImageTaskImpl::m_workerThread |
|
private |
A unique id for the image task.
ImageTask* geometrize::task::ImageTask::ImageTaskImpl::q |
|
private |
The documentation for this class was generated from the following file:
- /home/appveyor/projects/geometrize-docs/geometrize/geometrize/task/imagetask.cpp
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 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
chaiscript::ChaiScript * getEngine()
getEngine Gets a pointer to the script engine used by the shape mutation engine.
Definition: geometrizerengine.cpp:52
ImageTask * q
Definition: imagetask.cpp:289
void init(const Qt::ConnectionType connectionType)
Definition: imagetask.cpp:245
std::map< std::string, std::string > getScripts() const
Definition: imagetaskpreferences.cpp:335
Bitmap & getTarget()
Definition: imagetask.cpp:67
geometrize::Bitmap & getCurrent()
getCurrent Gets the current working bitmap.
Definition: imagetaskworker.cpp:49
geometrize::ImageRunnerOptions getImageRunnerOptions() const
getImageRunnerOptions Gets a copy of the image runner options.
Definition: imagetaskpreferences.cpp:235
void disconnectAll()
Definition: imagetask.cpp:281
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
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
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.
const std::string m_displayName
Runtime configuration parameters for the runner.
Definition: imagetask.cpp:291
void signal_didStep(std::vector< geometrize::ShapeResult > shapes)
preferences::ImageTaskPreferences m_preferences
Definition: imagetask.cpp:290
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 m_geometrizer
The image task worker.
Definition: imagetask.cpp:295
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
void signal_preferencesSet()
signal_preferencesSet Signal that is emitted immediately after the image task preferences are set.
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