Geometrize  1.0
An application for geometrizing images into geometric primitives
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros
Public Member Functions | Private Member Functions | Private Attributes | List of all members
geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl Class Reference
Collaboration diagram for geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl:
Collaboration graph
[legend]

Public Member Functions

 ImageTaskWindowImpl (ImageTaskWindow *pQ)
 
ImageTaskWindowImploperator= (const ImageTaskWindowImpl &)=delete
 
 ImageTaskWindowImpl (const ImageTaskWindowImpl &)=delete
 
 ~ImageTaskWindowImpl ()
 
void close ()
 
task::ImageTaskgetImageTask ()
 
void setImageTask (task::ImageTask *task)
 
void revealLaunchWindow ()
 
void setConsoleVisibility (const bool visible)
 
void setPixmapViewVisibility (const bool visible)
 
void setVectorViewVisibility (const bool visible)
 
void loadSettingsTemplate ()
 
void loadSettingsTemplate (task::ImageTask *task, const std::string &path)
 
void saveSettingsTemplate () const
 
void saveSettingsTemplate (task::ImageTask *task, const std::string &path) const
 
void onLanguageChange ()
 

Private Member Functions

void populateUi ()
 
bool isRunning () const
 
bool shouldKeepStepping () const
 
void setShouldKeepStepping (const bool stepping)
 
void updateStartStopButtonText ()
 
void stepModel ()
 
void clearModel ()
 
void switchTargetImage (Bitmap &bitmap)
 
void switchCurrentImage (Bitmap &bitmap)
 
void updateStats ()
 
void disconnectTask ()
 
void setTargetImage (const QImage &image)
 
void addPostStepCb (const std::function< void()> &f)
 
void clearPostStepCbs ()
 
void processPostStepCbs ()
 

Private Attributes

std::unique_ptr
< Ui::ImageTaskWindow > 
ui {nullptr}
 
ImageTaskWindowq {nullptr}
 
task::ImageTaskm_task {nullptr}
 
QMetaObject::Connection m_taskPreferencesSetConnection {}
 

The image task currently set and manipulated via this window

More...
 
QMetaObject::Connection m_taskWillStepConnection {}
 

Connection for telling the dialog when the image task preferences are set

More...
 
QMetaObject::Connection m_taskDidStepConnection {}
 

Connection for the window to do work just prior the image task starts a step

More...
 
std::vector< std::function
< void()> > 
m_onPostStepCbs
 

Connection for the window to do work just after the image task finishes a step

More...
 
geometrize::task::ShapeCollection m_shapes
 

One-shot callbacks triggered when the image task finishes a step

More...
 
geometrize::scene::ImageTaskSceneManager m_sceneManager
 

Collection of shapes added so far

More...
 
geometrize::scene::ImageTaskGraphicsViewm_pixmapView {nullptr}
 

Manager for scenes containing the pixmap/vector-based representations of the shapes etc

More...
 
geometrize::scene::ImageTaskGraphicsViewm_svgView {nullptr}
 

The view that holds the raster/pixel-based scene

More...
 
bool m_shouldKeepStepping {false}
 

The view that holds the vector-based scene

More...
 
QTimer m_timeRunningTimer
 

Whether to continually step i.e. whether to start another step after stepping once

More...
 
float m_timeRunning {0.0f}
 

Timer used to keep track of how long the image task has been in the "running" state

More...
 
const float m_timeRunningTimerResolutionMs {100.0f}
 

Total time that the image task has been in the "running" state

More...
 
QTimer m_scriptEngineUpdateTimer
 

Resolution of the time running timer in milliseconds

More...
 
float m_scriptEngineUpdateTimerResolution {100.0f}
 

Timer used to call an update function on the script engine of the associated image task

More...
 

Constructor & Destructor Documentation

geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::ImageTaskWindowImpl ( ImageTaskWindow pQ)
inline
82  :
83  ui{std::make_unique<Ui::ImageTaskWindow>()},
84  q{pQ}
85  {
86  ui->setupUi(q);
87  populateUi();
88  q->setAttribute(Qt::WA_DeleteOnClose);
89 
90  // Set up the dock widgets
91  q->tabifyDockWidget(ui->runnerSettingsDock, ui->scriptsDock);
92  q->tabifyDockWidget(ui->runnerSettingsDock, ui->exporterDock);
93 
94  ui->runnerSettingsDock->raise(); // Make sure runner settings dock is selected
95 
96  ui->consoleWidget->setVisible(false); // Make sure console widget is hidden by default
97 
98  // Set up the image task geometrization views
99  m_pixmapView = new geometrize::scene::ImageTaskGraphicsView(ui->imageViewContainer);
100  m_pixmapView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
101  m_pixmapView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
102  ui->imageViewContainer->layout()->addWidget(m_pixmapView);
103 
104  m_svgView = new geometrize::scene::ImageTaskGraphicsView(ui->imageViewContainer);
105  m_svgView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
106  m_svgView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
107  ui->imageViewContainer->layout()->addWidget(m_svgView);
108 
110 
111  // Set initial view visibility
113  setConsoleVisibility(prefs.shouldShowImageTaskConsoleByDefault());
114  setPixmapViewVisibility(prefs.shouldShowImageTaskPixmapViewByDefault());
115  setVectorViewVisibility(prefs.shouldShowImageTaskVectorViewByDefault());
116 
117  // Handle clicks on checkable title bar items
118  connect(ui->actionScript_Console, &QAction::toggled, [this](const bool checked) {
119  setConsoleVisibility(checked);
120  });
121  connect(ui->actionPixmap_Results_View, &QAction::toggled, [this](const bool checked) {
122  setPixmapViewVisibility(checked);
123  });
124  connect(ui->actionVector_Results_View, &QAction::toggled, [this](const bool checked) {
125  setVectorViewVisibility(checked);
126  });
127 
128  // Handle request to set the image task on the task window
129  connect(q, &ImageTaskWindow::willSwitchImageTask, [this](task::ImageTask* lastTask, task::ImageTask* nextTask) {
130  // Disconnect the last image task, which will soon be replaced by the next image task
131  disconnectTask();
132 
133  m_shapes.clear();
134  ui->imageTaskRunnerWidget->setImageTask(nextTask);
135  ui->scriptsWidget->setImageTask(nextTask);
136  ui->imageTaskExportWidget->setImageTask(nextTask, &m_shapes.getShapeVector());
137 
138  const auto taskIdForSerialization = [](const task::ImageTask& task) {
139  std::string s = std::to_string(task.getWidth()) + "_" + std::to_string(task.getHeight()) + "_";
140 
141  QCryptographicHash hash(QCryptographicHash::Md5);
142  hash.addData(reinterpret_cast<const char*>(task.getTarget().getDataRef().data()), task.getTarget().getDataRef().size());
143  const QByteArray result = hash.result().toHex();
144  const std::string hashStr = std::string(result.begin(), result.end());
145  return s + hashStr;
146  };
147 
148  // Autosave the preferences for the task being switched away from, if there was one
150  const std::string path{geometrize::preferences::getImageTaskPreferencesAutoSavePath(taskIdForSerialization(*lastTask))};
151  if(path.empty()) {
152  assert(0 && "Auto save path for image task file must not be empty");
153  }
154  saveSettingsTemplate(lastTask, path);
155  }
156 
157  // Autoload the preferences for the task being switched to, if there is one
158  if(nextTask != nullptr && geometrize::preferences::getGlobalPreferences().shouldAutoLoadImageTaskSettings()) {
159  const std::string path{geometrize::preferences::getImageTaskPreferencesAutoSavePath(taskIdForSerialization(*nextTask))};
160  if(path.empty()) {
161  assert(0 && "Auto load path for image task file must not be empty");
162  }
163  loadSettingsTemplate(nextTask, path);
164  }
165  });
166  connect(q, &ImageTaskWindow::didSwitchImageTask, [this](task::ImageTask* lastTask, task::ImageTask* currentTask) {
168  ui->imageTaskRunnerWidget->syncUserInterface();
169  ui->scriptsWidget->syncUserInterface();
170  });
171 
172  m_taskWillStepConnection = connect(currentTask, &task::ImageTask::signal_modelWillStep, [this]() {
173  ui->statsDockContents->setCurrentStatus(geometrize::dialog::ImageTaskStatsWidget::RUNNING);
174 
175  // Apply the latest scripts and engine state prior to stepping
176  auto& geometrizer = m_task->getGeometrizer();
177 
178  m_task->getPreferences().setScripts(ui->scriptsWidget->getScripts());
179 
180  chaiscript::ChaiScript* engine = geometrizer.getEngine();
181  engine->set_global(chaiscript::var(static_cast<int>(m_task->getWidth())), "xBound");
182  engine->set_global(chaiscript::var(static_cast<int>(m_task->getHeight())), "yBound");
183  engine->set_global(chaiscript::var(m_shapes.getShapeVector().size()), "currentShapeCount");
184 
185  ui->scriptsWidget->evaluateBeforeStepScripts();
186  });
187 
188  m_taskDidStepConnection = connect(currentTask, &task::ImageTask::signal_modelDidStep, [this](std::vector<geometrize::ShapeResult> shapes) {
190 
191  // If the first shape added background rectangle then fit the scenes to it
192  if(m_shapes.empty()) {
194  }
195  m_shapes.appendShapes(shapes);
196 
197  updateStats();
198 
199  ui->scriptsWidget->evaluateAfterStepScripts();
200 
201  if(shouldKeepStepping()) {
202  stepModel();
203  }
204  });
205 
206  const QString windowTitle = [currentTask]() {
209  if(currentTask != nullptr) {
210  title.append(" ").append(QString::fromStdString(currentTask->getDisplayName()));
211  }
212  return title;
213  }();
214  q->setWindowTitle(windowTitle);
215 
216  if(currentTask != nullptr) {
217  const QPixmap target{image::createPixmap(m_task->getTarget())};
219  } else {
220  m_sceneManager.setTargetPixmap(QPixmap());
221  }
222 
223  if(currentTask != nullptr) {
224  const auto getStartingColor = [this]() {
226  if(prefs.shouldUseCustomImageTaskBackgroundOverrideColor()) {
227  const auto color = prefs.getCustomImageTaskBackgroundOverrideColor();
228  return geometrize::rgba{ static_cast<std::uint8_t>(color[0]), static_cast<std::uint8_t>(color[1]), static_cast<std::uint8_t>(color[2]), static_cast<std::uint8_t>(color[3]) };
229  }
230  return geometrize::commonutil::getAverageImageColor(m_task->getTarget());
231  };
232  currentTask->drawBackgroundRectangle(getStartingColor());
233  }
234 
235  if(currentTask != nullptr) {
236  ui->consoleWidget->setEngine(currentTask->getGeometrizer().getEngine());
237  } else {
238  ui->consoleWidget->setEngine(nullptr);
239  }
240 
241  ui->imageTaskRunnerWidget->syncUserInterface();
242  ui->scriptsWidget->syncUserInterface();
243 
244  if(currentTask != nullptr) {
245  ui->imageTaskImageWidget->setTargetImage(image::createImage(currentTask->getTarget()));
246  } else {
247  ui->imageTaskImageWidget->setTargetImage(QImage());
248  }
249 
250  m_timeRunning = 0.0f;
251 
252  #if defined DATASLINGER_INCLUDED
253  // Bind keyboard shortcuts, setup UI for sending images out over the network etc
254  geometrize::installImageSlingerUserInterface(q);
255  #endif
256 
257  // As a final step, dispose of the old image task, if there was one
258  if(lastTask != nullptr) {
259  destroyTask(lastTask);
260  }
261  });
262 
263  // Handle requested target image overlay opacity changes
264  connect(ui->imageTaskImageWidget, &ImageTaskImageWidget::targetImageOpacityChanged, [this](const unsigned int value) {
265  const float opacity{value * (1.0f / 255.0f)};
267  });
268 
269  // Handle a request to change the target image
270  connect(ui->imageTaskImageWidget, &ImageTaskImageWidget::targetImageSelected, [this](const QImage& image) {
271  assert(!image.isNull());
272 
273  // Validate the target image size
274  const geometrize::Bitmap& target{m_task->getTarget()};
275  const int targetWidth{static_cast<int>(target.getWidth())};
276  const int targetHeight{static_cast<int>(target.getHeight())};
277  if(targetWidth != image.width() || targetHeight != image.height()) {
278  const QString selectedImageSize(tr("%1x%2", "Dimensions of an image e.g. width-x-height, 1024x800").arg(QLocale().toString(image.width())).arg(QLocale().toString(image.height())));
279  const QString targetImageSize(tr("%1x%2", "Dimensions of an image e.g. width-x-height, 1024x800").arg(QLocale().toString(targetWidth)).arg(QLocale().toString(targetHeight)));
280  QMessageBox::warning(
281  q,
282  tr("Image has incorrect dimensions", "Title of an error dialog shown when the user selects an image that was the wrong resolution/size"),
283  tr("Selected image must have the same dimensions as the current target image. Size was %1, but should have been %2",
284  "Error message shown when the user selects an image that was the wrong resolution/size").arg(selectedImageSize).arg(targetImageSize));
285 
286  return;
287  }
288 
289  setTargetImage(image);
290  });
291 
292  // Handle a request to change the target image that has passed size checks and validation
293  connect(ui->imageTaskImageWidget, &ImageTaskImageWidget::targetImageSet, [this](const QImage& image) {
294  // If the task is running then defer the target image change to the next step, else do it immediately
295  if(isRunning()) {
296  const QImage imageCopy{image.copy()};
297  addPostStepCb([this, imageCopy]() {
298  Bitmap target = geometrize::image::createBitmap(imageCopy);
299  switchTargetImage(target);
300  });
301  } else {
302  Bitmap target = geometrize::image::createBitmap(image);
303  switchTargetImage(target);
304  }
305  });
306 
307  // Handle runner button presses
308  connect(ui->imageTaskRunnerWidget, &ImageTaskRunnerWidget::runStopButtonClicked, [this]() {
310 
311  // Request another image task step if user clicked start here
312  if(shouldKeepStepping()) {
313  stepModel();
314  }
315  });
316  connect(ui->imageTaskRunnerWidget, &ImageTaskRunnerWidget::stepButtonClicked, [this]() {
317  stepModel();
318  });
319  connect(ui->imageTaskRunnerWidget, &ImageTaskRunnerWidget::clearButtonClicked, [this]() {
320  clearModel();
321  });
322 
323  connect(q, &ImageTaskWindow::didLoadSettingsTemplate, [this]() {
324  ui->imageTaskRunnerWidget->syncUserInterface();
325  ui->scriptsWidget->syncUserInterface();
326  });
327 
328  // Track how long the task has been in the running state
329  connect(&m_timeRunningTimer, &QTimer::timeout, [this]() {
330  if(isRunning()) {
332  updateStats();
333  }
334  });
335 
336  connect(&m_scriptEngineUpdateTimer, &QTimer::timeout, [this]() {
337  ui->scriptsWidget->evaluateOnTimedUpdateEventScripts();
338  });
339 
340  // Before shapes are added, evaluate he pre-add shape callbacks
341  connect(&m_shapes, &geometrize::task::ShapeCollection::signal_beforeAppendShapes, [this](const std::vector<geometrize::ShapeResult>&) {
342  ui->scriptsWidget->evaluateBeforeAddShapeScripts();
343  });
344 
345  // After shapes are added, evaluate the post-add shape callbacks and stop conditions
346  connect(&m_shapes, &geometrize::task::ShapeCollection::signal_afterAppendShapes, [this](const std::vector<geometrize::ShapeResult>&) {
347  chaiscript::ChaiScript* engine = m_task->getGeometrizer().getEngine();
348  engine->set_global(chaiscript::var(m_shapes.back().shape->clone()), "lastAddedShape");
349  engine->set_global(chaiscript::var(m_shapes.back().score), "lastAddedShapeScore");
350  engine->set_global(chaiscript::var(m_shapes.back().color), "lastAddedShapeColor");
351 
352  ui->scriptsWidget->evaluateAfterAddShapeScripts();
353 
354  if(!ui->scriptsWidget->evaluateStopConditionScripts()) {
355  return;
356  }
357  setShouldKeepStepping(false);
359  });
360 
361  // Update the graphical image views after shapes are added
362  connect(&m_shapes, &geometrize::task::ShapeCollection::signal_afterAppendShapes, [this](const std::vector<geometrize::ShapeResult>& shapes) {
363  const QPixmap pixmap{image::createPixmap(m_task->getCurrent())};
364  m_sceneManager.updateScenes(pixmap, shapes);
365  });
366 
367  #if defined DATASLINGER_INCLUDED
368  // Send the newly added SVG shape data out to listening clients
369  connect(&m_shapes, &geometrize::task::ShapeCollection::signal_afterAppendShapes, [](const std::vector<geometrize::ShapeResult>& shapes) {
370 
371  // Exporting rotated ellipses as polygons, since OpenFL's SVG library can't handle regular rotated SVG ellipse or paths
372  geometrize::exporter::SVGExportOptions options;
373  options.rotatedEllipseExportMode = geometrize::exporter::RotatedEllipseSVGExportMode::POLYGON;
374 
375  for(const auto& result : shapes) {
376  geometrize::sendSvgShapeData(geometrize::exporter::getSingleShapeSVGData(result.color, *result.shape, options));
377  }
378  });
379  #endif
380 
381  // Update the graphical image views when the number of shapes changes (e.g. when cleared)
382  connect(&m_shapes, &geometrize::task::ShapeCollection::signal_sizeChanged, [this](const std::size_t size) {
383  if(size == 0) {
385  }
386  });
387 
388  // Pass the latest mouse event info to the current image task's script engine
389  connect(&m_sceneManager, &geometrize::scene::ImageTaskSceneManager::signal_onTargetImageHoverMoveEvent, [this](double lastX, double lastY, double x, double y, bool /*ctrlModifier*/) {
390  chaiscript::ChaiScript* engine = m_task->getGeometrizer().getEngine();
391  engine->set_global(chaiscript::var(lastX), "targetImageLastMouseX");
392  engine->set_global(chaiscript::var(lastY), "targetImageLastMouseY");
393  engine->set_global(chaiscript::var(x), "targetImageMouseX");
394  engine->set_global(chaiscript::var(y), "targetImageMouseY");
395 
396  ui->scriptsWidget->evaluateOnMouseMoveEventScripts();
397  });
398  connect(&m_sceneManager, &geometrize::scene::ImageTaskSceneManager::signal_onTargetImageMousePressEvent, [this](double x, double y, bool /*ctrlModifier*/) {
399  chaiscript::ChaiScript* engine = m_task->getGeometrizer().getEngine();
400  engine->set_global(chaiscript::var(x), "targetImageLastMouseX");
401  engine->set_global(chaiscript::var(y), "targetImageLastMouseY");
402  engine->set_global(chaiscript::var(x), "targetImageMouseX");
403  engine->set_global(chaiscript::var(y), "targetImageMouseY");
404 
405  ui->scriptsWidget->evaluateOnMouseDownEventScripts();
406  });
407  connect(&m_sceneManager, &geometrize::scene::ImageTaskSceneManager::signal_onTargetImageMouseMoveEvent, [this](double lastX, double lastY, double x, double y, bool /*ctrlModifier*/) {
408  // NOTE not triggered currently, hover move events are used instead
409  chaiscript::ChaiScript* engine = m_task->getGeometrizer().getEngine();
410  engine->set_global(chaiscript::var(lastX), "targetImageLastMouseX");
411  engine->set_global(chaiscript::var(lastY), "targetImageLastMouseY");
412  engine->set_global(chaiscript::var(x), "targetImageMouseX");
413  engine->set_global(chaiscript::var(y), "targetImageMouseY");
414 
415  ui->scriptsWidget->evaluateOnMouseMoveEventScripts();
416  });
417  connect(&m_sceneManager, &geometrize::scene::ImageTaskSceneManager::signal_onTargetImageMouseReleaseEvent, [this](double x, double y, bool /*ctrlModifier*/) {
418  chaiscript::ChaiScript* engine = m_task->getGeometrizer().getEngine();
419  engine->set_global(chaiscript::var(x), "targetImageLastMouseX");
420  engine->set_global(chaiscript::var(y), "targetImageLastMouseY");
421  engine->set_global(chaiscript::var(x), "targetImageMouseX");
422  engine->set_global(chaiscript::var(y), "targetImageMouseY");
423 
424  ui->scriptsWidget->evaluateOnMouseUpEventScripts();
425  });
426  connect(&m_sceneManager, &geometrize::scene::ImageTaskSceneManager::signal_onTargetImageWheelEvent, [this](double x, double y, int amount, bool /*ctrlModifier*/) {
427  chaiscript::ChaiScript* engine = m_task->getGeometrizer().getEngine();
428  engine->set_global(chaiscript::var(x), "targetImageLastMouseX");
429  engine->set_global(chaiscript::var(y), "targetImageLastMouseY");
430  engine->set_global(chaiscript::var(x), "targetImageMouseX");
431  engine->set_global(chaiscript::var(y), "targetImageMouseY");
432  engine->set_global(chaiscript::var(amount), "targetImageWheelMoveAmount");
433 
434  ui->scriptsWidget->evaluateOnMouseWheelEventScripts();
435  });
436 
437  // Pass the latest key event info to the current image task's script engine
439  chaiscript::ChaiScript* engine = m_task->getGeometrizer().getEngine();
440  const std::string keyString = QKeySequence(key).toString().toStdString();
441 
442  // Update vars for pressed keys in the engine (cleared on key release)
443  engine->set_global(chaiscript::var(keyString), "targetImageLastKeyDown");
444  engine->set_global(chaiscript::var(true), "targetImageKeyDown_" + keyString);
445  engine->set_global(chaiscript::var(ctrlModifier), "targetImageControlModifierDown");
446 
447  // Last pressed key in the engine, not cleared on key release
448  engine->set_global(chaiscript::var(keyString), "targetImageLastKeyDownPersistent");
449 
450  ui->scriptsWidget->evaluateOnKeyDownEventScripts();
451  });
453  chaiscript::ChaiScript* engine = m_task->getGeometrizer().getEngine();
454  const std::string keyString = QKeySequence(key).toString().toStdString();
455 
456  // Update vars for pressed keys in the engine
457  engine->set_global(chaiscript::var(""), "targetImageLastKeyDown");
458  engine->set_global(chaiscript::var(false), "targetImageKeyDown_" + keyString);
459  engine->set_global(chaiscript::var(ctrlModifier), "targetImageControlModifierDown");
460 
461  ui->scriptsWidget->evaluateOnKeyUpEventScripts();
462  });
463 
464  // Pass the latest tablet event info to the current image task's script engine
466  if(!m_task) {
467  return;
468  }
469 
470  const geometrize::scene::TabletEventData data = event.getData();
471  chaiscript::ChaiScript* engine = m_task->getGeometrizer().getEngine();
472  engine->set_global(chaiscript::var(data), "lastTabletEvent");
473  engine->set_global(chaiscript::var(static_cast<int>(m_task->getWidth())), "xBound");
474  engine->set_global(chaiscript::var(static_cast<int>(m_task->getHeight())), "yBound");
475 
476  ui->scriptsWidget->evaluateOnPenInputEventScripts();
477 
478  try {
479  std::shared_ptr<geometrize::Shape> aoiShape = engine->eval<std::shared_ptr<geometrize::Shape>>("aoi");
480  engine->set_global(chaiscript::var(aoiShape->clone()), "aoi"); // Work around fail to assign shape to shape in the script
482  } catch(...) {
483  // The pen input scripts should setup an area of influence shape
484  }
485  });
486 
487  // Connect the global pen input proximity event filter signals
488  // Note these are separate from the other tablet events, since they are application-wide
489  // and proximity events don't seem to include useful data e.g. position etc
490  auto& sharedTabletProximityEventFilter = geometrize::getSharedTabletProximityEventFilterInstance();
491  connect(&sharedTabletProximityEventFilter, &geometrize::TabletProximityEventFilter::signal_onTabletEnterProximity, q, [this]() {
492  ui->scriptsWidget->evaluateOnPenProximityEnterEventScripts();
493  });
494  connect(&sharedTabletProximityEventFilter, &geometrize::TabletProximityEventFilter::signal_onTabletLeaveProximity, q, [this]() {
495  ui->scriptsWidget->evaluateOnPenProximityExitEventScripts();
496  });
497 
498  /*
499  // TODO do stuff with the area of influence shape, or tell the script engine, when input happens
500  connect(&m_sceneManager, &geometrize::scene::ImageTaskSceneManager::signal_onAreaOfInfluenceShapeHoverMoveEvent, [this](const int lastX, const int lastY, const int x, const int y, const bool ctrlModifier) {
501  if(!ctrlModifier) {
502  return;
503  }
504  //translateShape(x - lastX, y - lastY);
505  });
506  connect(&m_sceneManager, &geometrize::scene::ImageTaskSceneManager::signal_onAreaOfInfluenceShapeMouseWheelEvent, [this](const int, const int, const double amount, const bool ctrlModifier) {
507  if(!ctrlModifier) {
508  return;
509  }
510  //scaleShape(amount > 0 ? 1.03f : 0.97f);
511  });
512  connect(&m_sceneManager, &geometrize::scene::ImageTaskSceneManager::signal_onAreaOfInfluenceShapeKeyPressEvent, [this](const int key, const bool) {
513  if(key == Qt::Key_R) { // Rotate
514  //rotateShape(3);
515  }
516  if(key == Qt::Key_Q) { // Scale down
517  //scaleShape(0.97f);
518  }
519  if(key == Qt::Key_A) { // Scale up
520  //scaleShape(1.03f);
521  }
522  });
523  */
524 
525  // Set initial target image opacity
526  const float initialTargetImageOpacity{0};
527  ui->imageTaskImageWidget->setTargetImageOpacity(static_cast<unsigned int>(initialTargetImageOpacity));
528 
529  // Start the timer used to track how long the image task has been in the running state
530  m_timeRunningTimer.start(static_cast<int>(m_timeRunningTimerResolutionMs));
531 
532  // Start the timer used to regularly update the associated image task's script engine (if any)
534  }
geometrize::task::ShapeCollection m_shapes
One-shot callbacks triggered when the image task finishes a step
Definition: imagetaskwindow.cpp:780
bool isRunning() const
Definition: imagetaskwindow.cpp:663
void addPostStepCb(const std::function< void()> &f)
Definition: imagetaskwindow.cpp:753
void setAreaOfInfluenceShape(const geometrize::Shape &shape)
setAreaOfInfluenceShape Sets up a area of influence visual for the given shape.
Definition: imagetaskscenemanager.cpp:193
void signal_preferencesSet()
signal_preferencesSet Signal that is emitted immediately after the image task preferences are set...
std::string getImageTaskPreferencesAutoSavePath(const std::string &hashOfFirstTargetImage)
getImageTaskPreferencesAutoSavePath Gets the absolute path to where the image task preferences config...
Definition: imagetaskpreferences.cpp:24
chaiscript::ChaiScript * getEngine()
getEngine Gets a pointer to the script engine used by the shape mutation engine.
Definition: geometrizerengine.cpp:52
QImage createImage(const Bitmap &data)
createImage Creates an image from the bitmap data object. Assumes RGBA8888 format.
Definition: imageloader.cpp:46
void setTargetPixmap(const QPixmap &pixmap)
setTargetPixmap Sets the pixmap that provides the target/goal image visualization.
Definition: imagetaskscenemanager.cpp:158
Bitmap & getTarget()
getTarget Gets the target bitmap.
Definition: imagetask.cpp:260
void showImageTaskStopConditionMetMessage(QWidget *parent)
showImageTaskStopConditionMetMessage Shows a messagebox stating that the stop conditions for geometri...
Definition: imagetaskscriptingwidget.cpp:56
void setPixmapViewVisibility(const bool visible)
Definition: imagetaskwindow.cpp:584
The GlobalPreferences class models the preferences associated with the application as a whole...
Definition: globalpreferences.h:43
void loadSettingsTemplate()
Definition: imagetaskwindow.cpp:608
geometrize::scene::ImageTaskGraphicsView * m_pixmapView
Manager for scenes containing the pixmap/vector-based representations of the shapes etc ...
Definition: imagetaskwindow.cpp:783
Definition: imagetaskstatswidget.h:25
void signal_modelDidStep(std::vector< geometrize::ShapeResult > shapes)
signal_modelDidStep Signal that is emitted immediately after the underlying image task model is stepp...
void signal_onTargetImageHoverMoveEvent(double lastX, double lastY, double x, double y, bool ctrlModifier)
void populateUi()
Definition: imagetaskwindow.cpp:657
geometrize::preferences::ImageTaskPreferences & getPreferences()
getPreferences Gets a reference to the current preferences of this task.
Definition: imagetask.cpp:330
void appendShapes(const std::vector< geometrize::ShapeResult > &shapes)
Definition: shapecollection.cpp:34
void signal_sizeChanged(std::size_t to)
geometrize::scene::ImageTaskGraphicsView * m_svgView
The view that holds the raster/pixel-based scene
Definition: imagetaskwindow.cpp:784
bool shouldAutoSaveImageTaskSettings() const
shouldAutoSaveImageTaskSettings Gets the preference for whether to automatically save the last task s...
Definition: globalpreferences.cpp:528
QMetaObject::Connection m_taskWillStepConnection
Connection for telling the dialog when the image task preferences are set
Definition: imagetaskwindow.cpp:776
void updateScenes(const QPixmap &pixmap, const std::vector< geometrize::ShapeResult > &shapes)
updateScenes Updates the scenes to show the latest image/shapes.
Definition: imagetaskscenemanager.cpp:168
The CustomTabletEvent class represents a tablet event (specifically from a Wacom Pro pen) that can be...
Definition: customtabletevent.h:87
QTimer m_timeRunningTimer
Whether to continually step i.e. whether to start another step after stepping once ...
Definition: imagetaskwindow.cpp:787
void switchTargetImage(Bitmap &bitmap)
Definition: imagetaskwindow.cpp:703
TabletProximityEventFilter & getSharedTabletProximityEventFilterInstance()
getSharedTabletProximityEventFilterInstance Gets a reference to the shared instance of the tablet pro...
Definition: tabletproximityeventfilter.cpp:32
void clearModel()
Definition: imagetaskwindow.cpp:696
void willSwitchImageTask(task::ImageTask *lastTask, task::ImageTask *nextTask)
willSwitchImageTask Signal dispatched immediately before an image task is set on the image task windo...
void processPostStepCbs()
Definition: imagetaskwindow.cpp:763
float m_timeRunning
Timer used to keep track of how long the image task has been in the "running" state ...
Definition: imagetaskwindow.cpp:788
void setTargetPixmapOpacity(float opacity)
setTargetPixmapOpacity Sets the opacity of the target pixmap.
Definition: imagetaskscenemanager.cpp:163
void saveSettingsTemplate() const
Definition: imagetaskwindow.cpp:629
void disconnectTask()
Definition: imagetaskwindow.cpp:735
std::uint32_t getHeight() const
getHeight Gets the height of the images used by the image task.
Definition: imagetask.cpp:285
void signal_onTargetImageMouseMoveEvent(double lastX, double lastY, double x, double y, bool ctrlModifier)
geometrize::ShapeResult & back()
Definition: shapecollection.cpp:42
bool empty() const
Definition: shapecollection.cpp:13
void signal_modelWillStep()
signal_modelWillStep Signal that is emitted immediately before the underlying image task model is ste...
void didSwitchImageTask(task::ImageTask *lastTask, task::ImageTask *currentTask)
didSwitchImageTask Signal dispatched immediately after an image task is set on the image task window...
void signal_onTabletLeaveProximity()
signal_onTabletLeaveProximity Signal dispatched when a Wacom tablet leave proximity event is received...
std::unique_ptr< Ui::ImageTaskWindow > ui
Definition: imagetaskwindow.cpp:771
void stepModel()
Definition: imagetaskwindow.cpp:691
const std::vector< geometrize::ShapeResult > & getShapeVector() const
Definition: shapecollection.cpp:29
float m_scriptEngineUpdateTimerResolution
Timer used to call an update function on the script engine of the associated image task ...
Definition: imagetaskwindow.cpp:792
geometrize::scene::ImageTaskSceneManager m_sceneManager
Collection of shapes added so far
Definition: imagetaskwindow.cpp:782
void setTargetImage(const QImage &image)
Definition: imagetaskwindow.cpp:748
void signal_onTargetImageMousePressEvent(double x, double y, bool ctrlModifier)
void targetImageSelected(const QImage &image)
targetImageSelected Signal dispatched when a candidate target image is selected, typically by the use...
The TabletEventData class represents data produced from a Wacom pen/tablet event (in the context of a...
Definition: customtabletevent.h:55
geometrize::preferences::GlobalPreferences & getGlobalPreferences()
getGlobalPreferences Shorthand function that gets a reference to the shared global preferences object...
Definition: globalpreferences.cpp:32
The ImageTaskGraphicsView class models a graphics view for viewing the images and shapes used and/or ...
Definition: imagetaskgraphicsview.h:21
QPixmap createPixmap(const Bitmap &data)
createPixmap Creates a pixmap from the bitmap data object. Assumes RGBA8888 format.
Definition: imageloader.cpp:57
Bitmap & getCurrent()
getCurrent Gets the current bitmap.
Definition: imagetask.cpp:265
void targetImageOpacityChanged(unsigned int opacity)
targetImageOpacityChanged Signal dispatched when the target image opacity is changed.
QTimer m_scriptEngineUpdateTimer
Resolution of the time running timer in milliseconds
Definition: imagetaskwindow.cpp:791
void didLoadSettingsTemplate()
didLoadSettingsTemplate Signal dispatched immediately after a settings template is applied to the ima...
Bitmap createBitmap(const QImage &image)
createBitmap Creates a bitmap data object from the given image.
Definition: imageloader.cpp:20
geometrize::script::GeometrizerEngine & getGeometrizer()
getGeometrizer Gets a reference to the script-based engine used to turn images into shapes...
Definition: imagetask.cpp:340
QMetaObject::Connection m_taskDidStepConnection
Connection for the window to do work just prior the image task starts a step
Definition: imagetaskwindow.cpp:777
bool shouldKeepStepping() const
Definition: imagetaskwindow.cpp:671
QString getApplicationVersionString()
getApplicationVersionString Gets the application version as a string in VERSION.MAJOR.MINOR format e.g. "1.0.0", "2.7.13".
Definition: versioninfo.cpp:13
const float m_timeRunningTimerResolutionMs
Total time that the image task has been in the "running" state
Definition: imagetaskwindow.cpp:789
void setShouldKeepStepping(const bool stepping)
Definition: imagetaskwindow.cpp:676
void updateStats()
Definition: imagetaskwindow.cpp:715
ImageTaskWindow * q
Definition: imagetaskwindow.cpp:772
void signal_onTargetImageMouseReleaseEvent(double x, double y, bool ctrlModifier)
void targetImageSet(const QImage &image)
targetImageSet Signal dispatched when a target image is set and made visible in this widget (and is p...
std::array< std::int32_t, 4 > getCustomImageTaskBackgroundOverrideColor() const
getCustomImageTaskBackgroundOverrideColor Gets the preference for the custom image task background ov...
Definition: globalpreferences.cpp:498
void signal_beforeAppendShapes(const std::vector< geometrize::ShapeResult > &)
void fitScenesInViews(ImageTaskGraphicsView &pixmapView, ImageTaskGraphicsView &svgView)
fitScenesInViews Fits the scenes into their respective views.
Definition: imagetaskscenemanager.cpp:188
void setVectorViewVisibility(const bool visible)
Definition: imagetaskwindow.cpp:596
void setConsoleVisibility(const bool visible)
Definition: imagetaskwindow.cpp:576
task::ImageTask * m_task
Definition: imagetaskwindow.cpp:774
void clear()
Definition: shapecollection.cpp:23
void setScripts(const std::map< std::string, std::string > &scripts)
Definition: imagetaskpreferences.cpp:257
void signal_onTargetImageWheelEvent(double x, double y, int amount, bool ctrlModifier)
void reset()
reset Resets the state of the scenes, removing shapes etc.
Definition: imagetaskscenemanager.cpp:173
void signal_afterAppendShapes(const std::vector< geometrize::ShapeResult > &)
void signal_onTargetImageKeyReleaseEvent(int key, bool ctrlModifier)
static QString getApplicationName()
getApplicationName Gets the name of the application.
Definition: strings.cpp:9
QMetaObject::Connection m_taskPreferencesSetConnection
The image task currently set and manipulated via this window
Definition: imagetaskwindow.cpp:775
void signal_onTargetImageKeyPressEvent(int key, bool ctrlModifier)
std::uint32_t getWidth() const
getWidth Gets the width of the images used by the image task.
Definition: imagetask.cpp:280
void setViews(ImageTaskGraphicsView &pixmapView, ImageTaskGraphicsView &svgView)
setViews Associates the given views with the scenes managed by this class.
Definition: imagetaskscenemanager.cpp:153
void signal_onTargetImageTabletEvent(const geometrize::scene::CustomTabletEvent &event)
void signal_onTabletEnterProximity()
signal_onTabletEnterProximity Signal dispatched when a Wacom tablet enter proximity event is received...

Here is the call graph for this function:

geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::ImageTaskWindowImpl ( const ImageTaskWindowImpl )
delete
geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::~ImageTaskWindowImpl ( )
inline
538  {
539  // Sets the task in the UI etc to nothing (potentially autosaving stuff etc), then dispose of the task
540  task::ImageTask* lastTask = getImageTask();
541  setImageTask(nullptr);
542 
543  if(lastTask != nullptr) {
544  destroyTask(lastTask);
545  }
546  }
task::ImageTask * getImageTask()
Definition: imagetaskwindow.cpp:553
void setImageTask(task::ImageTask *task)
Definition: imagetaskwindow.cpp:558

Member Function Documentation

void geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::addPostStepCb ( const std::function< void()> &  f)
inlineprivate
754  {
755  m_onPostStepCbs.push_back(f);
756  }
std::vector< std::function< void()> > m_onPostStepCbs
Connection for the window to do work just after the image task finishes a step
Definition: imagetaskwindow.cpp:778
void geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::clearModel ( )
inlineprivate
697  {
700  setImageTask(task);
701  }
Bitmap & getTarget()
getTarget Gets the target bitmap.
Definition: imagetask.cpp:260
geometrize::preferences::ImageTaskPreferences & getPreferences()
getPreferences Gets a reference to the current preferences of this task.
Definition: imagetask.cpp:330
void setImageTask(task::ImageTask *task)
Definition: imagetaskwindow.cpp:558
std::string getDisplayName() const
getDisplayName Gets the display name of the image task.
Definition: imagetask.cpp:290
The ImageTask class transforms a source image into a collection of shapes approximating the source im...
Definition: imagetask.h:50
void setPreferences(preferences::ImageTaskPreferences preferences)
setPreferences Sets the preferences for this task.
Definition: imagetask.cpp:335
task::ImageTask * m_task
Definition: imagetaskwindow.cpp:774

Here is the call graph for this function:

void geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::clearPostStepCbs ( )
inlineprivate
759  {
760  m_onPostStepCbs.clear();
761  }
std::vector< std::function< void()> > m_onPostStepCbs
Connection for the window to do work just after the image task finishes a step
Definition: imagetaskwindow.cpp:778
void geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::close ( )
inline
549  {
550  q->close();
551  }
ImageTaskWindow * q
Definition: imagetaskwindow.cpp:772
void geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::disconnectTask ( )
inlineprivate
736  {
738  disconnect(m_taskPreferencesSetConnection);
739  }
741  disconnect(m_taskWillStepConnection);
742  }
744  disconnect(m_taskDidStepConnection);
745  }
746  }
QMetaObject::Connection m_taskWillStepConnection
Connection for telling the dialog when the image task preferences are set
Definition: imagetaskwindow.cpp:776
QMetaObject::Connection m_taskDidStepConnection
Connection for the window to do work just prior the image task starts a step
Definition: imagetaskwindow.cpp:777
QMetaObject::Connection m_taskPreferencesSetConnection
The image task currently set and manipulated via this window
Definition: imagetaskwindow.cpp:775
task::ImageTask* geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::getImageTask ( )
inline
554  {
555  return m_task;
556  }
task::ImageTask * m_task
Definition: imagetaskwindow.cpp:774
bool geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::isRunning ( ) const
inlineprivate
664  {
665  if(!m_task) {
666  return false;
667  }
668  return m_task->isStepping();
669  }
bool isStepping() const
isStepping Returns true if the internal model is currently stepping.
Definition: imagetask.cpp:300
task::ImageTask * m_task
Definition: imagetaskwindow.cpp:774
void geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::loadSettingsTemplate ( )
inline
609  {
610  const QString path{common::ui::openLoadImageTaskSettingsDialog(q)};
611  if(path.isEmpty()) {
612  return;
613  }
614  loadSettingsTemplate(m_task, path.toStdString());
615  }
QString openLoadImageTaskSettingsDialog(QWidget *parent)
Definition: uiactions.cpp:212
void loadSettingsTemplate()
Definition: imagetaskwindow.cpp:608
ImageTaskWindow * q
Definition: imagetaskwindow.cpp:772
task::ImageTask * m_task
Definition: imagetaskwindow.cpp:774

Here is the call graph for this function:

void geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::loadSettingsTemplate ( task::ImageTask task,
const std::string &  path 
)
inline
618  {
619  if(task == nullptr) {
620  return; // Can't load settings for a non-existent task
621  }
622  if(path.empty()) {
623  assert(0 && "Auto load path for image task file must not be empty");
624  }
625  task->getPreferences().load(path);
626  emit q->didLoadSettingsTemplate();
627  }
void didLoadSettingsTemplate()
didLoadSettingsTemplate Signal dispatched immediately after a settings template is applied to the ima...
ImageTaskWindow * q
Definition: imagetaskwindow.cpp:772

Here is the call graph for this function:

void geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::onLanguageChange ( )
inline
651  {
652  ui->retranslateUi(q);
653  populateUi();
654  }
void populateUi()
Definition: imagetaskwindow.cpp:657
std::unique_ptr< Ui::ImageTaskWindow > ui
Definition: imagetaskwindow.cpp:771
ImageTaskWindow * q
Definition: imagetaskwindow.cpp:772
ImageTaskWindowImpl& geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::operator= ( const ImageTaskWindowImpl )
delete
void geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::populateUi ( )
inlineprivate
658  {
661  }
void updateStartStopButtonText()
Definition: imagetaskwindow.cpp:682
ImageTaskWindow * q
Definition: imagetaskwindow.cpp:772
static QString getApplicationName()
getApplicationName Gets the name of the application.
Definition: strings.cpp:9

Here is the call graph for this function:

Here is the caller graph for this function:

void geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::processPostStepCbs ( )
inlineprivate
764  {
765  for(const auto& f : m_onPostStepCbs) {
766  f();
767  }
769  }
std::vector< std::function< void()> > m_onPostStepCbs
Connection for the window to do work just after the image task finishes a step
Definition: imagetaskwindow.cpp:778
void clearPostStepCbs()
Definition: imagetaskwindow.cpp:758
void geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::revealLaunchWindow ( )
inline
568  {
571  } else {
573  }
574  }
void openLaunchWindow()
Definition: uiactions.cpp:42
void bringLaunchWindowToFront()
Definition: uiactions.cpp:56
bool isLaunchWindowOpen()
Definition: uiactions.cpp:51

Here is the call graph for this function:

void geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::saveSettingsTemplate ( ) const
inline
630  {
631  const QString path{common::ui::openSaveImageTaskSettingsDialog(q)};
632  if(path.isEmpty()) {
633  return;
634  }
635  saveSettingsTemplate(m_task, path.toStdString());
636  }
void saveSettingsTemplate() const
Definition: imagetaskwindow.cpp:629
QString openSaveImageTaskSettingsDialog(QWidget *parent)
Definition: uiactions.cpp:220
ImageTaskWindow * q
Definition: imagetaskwindow.cpp:772
task::ImageTask * m_task
Definition: imagetaskwindow.cpp:774

Here is the call graph for this function:

void geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::saveSettingsTemplate ( task::ImageTask task,
const std::string &  path 
) const
inline
639  {
640  if(task == nullptr) {
641  return; // Can't save settings for a non-existent task
642  }
643  if(path.empty()) {
644  assert(0 && "Auto save path for image task file must not be empty");
645  }
646  task->getPreferences().save(path);
647  emit q->didSaveSettingsTemplate();
648  }
void didSaveSettingsTemplate()
didSaveSettingsTemplate Signal dispatched immediately after a settings template based on the current ...
ImageTaskWindow * q
Definition: imagetaskwindow.cpp:772

Here is the call graph for this function:

void geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::setConsoleVisibility ( const bool  visible)
inline
577  {
578  if(ui->actionScript_Console->isChecked() != visible) {
579  ui->actionScript_Console->setChecked(visible);
580  }
581  ui->consoleWidget->setVisible(visible);
582  }
std::unique_ptr< Ui::ImageTaskWindow > ui
Definition: imagetaskwindow.cpp:771

Here is the caller graph for this function:

void geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::setImageTask ( task::ImageTask task)
inline
559  {
560  task::ImageTask* lastTask{m_task};
561  task::ImageTask* nextTask{task};
562  q->willSwitchImageTask(lastTask, nextTask);
563  m_task = nextTask;
564  q->didSwitchImageTask(lastTask, nextTask);
565  }
void willSwitchImageTask(task::ImageTask *lastTask, task::ImageTask *nextTask)
willSwitchImageTask Signal dispatched immediately before an image task is set on the image task windo...
void didSwitchImageTask(task::ImageTask *lastTask, task::ImageTask *currentTask)
didSwitchImageTask Signal dispatched immediately after an image task is set on the image task window...
ImageTaskWindow * q
Definition: imagetaskwindow.cpp:772
task::ImageTask * m_task
Definition: imagetaskwindow.cpp:774
void geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::setPixmapViewVisibility ( const bool  visible)
inline
585  {
586  if(ui->actionPixmap_Results_View->isChecked() != visible) {
587  ui->actionPixmap_Results_View->setChecked(visible);
588  }
589 
590  m_pixmapView->setVisible(visible);
591  if(visible) {
593  }
594  }
geometrize::scene::ImageTaskGraphicsView * m_pixmapView
Manager for scenes containing the pixmap/vector-based representations of the shapes etc ...
Definition: imagetaskwindow.cpp:783
std::unique_ptr< Ui::ImageTaskWindow > ui
Definition: imagetaskwindow.cpp:771
geometrize::scene::ImageTaskSceneManager m_sceneManager
Collection of shapes added so far
Definition: imagetaskwindow.cpp:782
void fitPixmapSceneInView(ImageTaskGraphicsView &pixmapView)
fitPixmapSceneInView Fits the pixmap scene into the given view.
Definition: imagetaskscenemanager.cpp:178

Here is the caller graph for this function:

void geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::setShouldKeepStepping ( const bool  stepping)
inlineprivate
677  {
678  m_shouldKeepStepping = stepping;
680  }
void updateStartStopButtonText()
Definition: imagetaskwindow.cpp:682
bool m_shouldKeepStepping
The view that holds the vector-based scene
Definition: imagetaskwindow.cpp:786
void geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::setTargetImage ( const QImage &  image)
inlineprivate
749  {
750  ui->imageTaskImageWidget->setTargetImage(image);
751  }
std::unique_ptr< Ui::ImageTaskWindow > ui
Definition: imagetaskwindow.cpp:771
void geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::setVectorViewVisibility ( const bool  visible)
inline
597  {
598  if(ui->actionVector_Results_View->isChecked() != visible) {
599  ui->actionVector_Results_View->setChecked(visible);
600  }
601 
602  m_svgView->setVisible(visible);
603  if(visible) {
605  }
606  }
geometrize::scene::ImageTaskGraphicsView * m_svgView
The view that holds the raster/pixel-based scene
Definition: imagetaskwindow.cpp:784
std::unique_ptr< Ui::ImageTaskWindow > ui
Definition: imagetaskwindow.cpp:771
void fitVectorSceneInView(ImageTaskGraphicsView &svgView)
fitVectorSceneInView Fits the SVG/vector scene into the given view.
Definition: imagetaskscenemanager.cpp:183
geometrize::scene::ImageTaskSceneManager m_sceneManager
Collection of shapes added so far
Definition: imagetaskwindow.cpp:782

Here is the caller graph for this function:

bool geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::shouldKeepStepping ( ) const
inlineprivate
672  {
673  return m_shouldKeepStepping;
674  }
bool m_shouldKeepStepping
The view that holds the vector-based scene
Definition: imagetaskwindow.cpp:786
void geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::stepModel ( )
inlineprivate
692  {
693  m_task->stepModel();
694  }
void stepModel()
stepModel Steps the internal model, typically adding a shape.
Definition: imagetask.cpp:305
task::ImageTask * m_task
Definition: imagetaskwindow.cpp:774
void geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::switchCurrentImage ( Bitmap &  bitmap)
inlineprivate
710  {
711  Bitmap& currentBitmap{m_task->getCurrent()};
712  currentBitmap = bitmap;
713  }
Bitmap & getCurrent()
getCurrent Gets the current bitmap.
Definition: imagetask.cpp:265
task::ImageTask * m_task
Definition: imagetaskwindow.cpp:774
void geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::switchTargetImage ( Bitmap &  bitmap)
inlineprivate
704  {
705  Bitmap& targetBitmap{m_task->getTarget()};
706  targetBitmap = bitmap;
707  }
Bitmap & getTarget()
getTarget Gets the target bitmap.
Definition: imagetask.cpp:260
task::ImageTask * m_task
Definition: imagetaskwindow.cpp:774
void geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::updateStartStopButtonText ( )
inlineprivate
683  {
684  if(!shouldKeepStepping()) {
685  ui->imageTaskRunnerWidget->setRunStopButtonText(tr("Start", "Text on a button that the user presses to make the app start/begin transforming an image into shapes"));
686  } else {
687  ui->imageTaskRunnerWidget->setRunStopButtonText(tr("Stop", "Text on a button that the user presses to make the app stop/pause transforming an image into shapes"));
688  }
689  }
std::unique_ptr< Ui::ImageTaskWindow > ui
Definition: imagetaskwindow.cpp:771
bool shouldKeepStepping() const
Definition: imagetaskwindow.cpp:671
void geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::updateStats ( )
inlineprivate
716  {
717  ui->statsDockContents->setTaskId(m_task->getTaskId());
718  ui->statsDockContents->setImageDimensions(m_task->getWidth(), m_task->getHeight());
719 
720  // Note this is "stopped" when !isRunning alone, but this prevents flashing while
721  // the user has it continually adding shapes
722  if(!isRunning() && !shouldKeepStepping()) {
723  ui->statsDockContents->setCurrentStatus(geometrize::dialog::ImageTaskStatsWidget::STOPPED);
724  }
725 
726  ui->statsDockContents->setShapeCount(m_shapes.size());
727 
728  if(!m_shapes.empty()) {
729  ui->statsDockContents->setSimilarity(m_shapes.back().score * 100.0f);
730  }
731 
732  ui->statsDockContents->setTimeRunning(static_cast<int>(m_timeRunning / 1000.0f));
733  }
geometrize::task::ShapeCollection m_shapes
One-shot callbacks triggered when the image task finishes a step
Definition: imagetaskwindow.cpp:780
bool isRunning() const
Definition: imagetaskwindow.cpp:663
std::size_t getTaskId() const
getTaskId Gets the unique id of the image task.
Definition: imagetask.cpp:295
float m_timeRunning
Timer used to keep track of how long the image task has been in the "running" state ...
Definition: imagetaskwindow.cpp:788
std::uint32_t getHeight() const
getHeight Gets the height of the images used by the image task.
Definition: imagetask.cpp:285
geometrize::ShapeResult & back()
Definition: shapecollection.cpp:42
bool empty() const
Definition: shapecollection.cpp:13
std::unique_ptr< Ui::ImageTaskWindow > ui
Definition: imagetaskwindow.cpp:771
std::size_t size() const
Definition: shapecollection.cpp:18
bool shouldKeepStepping() const
Definition: imagetaskwindow.cpp:671
task::ImageTask * m_task
Definition: imagetaskwindow.cpp:774
std::uint32_t getWidth() const
getWidth Gets the width of the images used by the image task.
Definition: imagetask.cpp:280
Definition: imagetaskstatswidget.h:24

Member Data Documentation

std::vector<std::function<void()> > geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::m_onPostStepCbs
private

Connection for the window to do work just after the image task finishes a step

geometrize::scene::ImageTaskGraphicsView* geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::m_pixmapView {nullptr}
private

Manager for scenes containing the pixmap/vector-based representations of the shapes etc

geometrize::scene::ImageTaskSceneManager geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::m_sceneManager
private

Collection of shapes added so far

QTimer geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::m_scriptEngineUpdateTimer
private

Resolution of the time running timer in milliseconds

float geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::m_scriptEngineUpdateTimerResolution {100.0f}
private

Timer used to call an update function on the script engine of the associated image task

geometrize::task::ShapeCollection geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::m_shapes
private

One-shot callbacks triggered when the image task finishes a step

bool geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::m_shouldKeepStepping {false}
private

The view that holds the vector-based scene

geometrize::scene::ImageTaskGraphicsView* geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::m_svgView {nullptr}
private

The view that holds the raster/pixel-based scene

task::ImageTask* geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::m_task {nullptr}
private
QMetaObject::Connection geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::m_taskDidStepConnection {}
private

Connection for the window to do work just prior the image task starts a step

QMetaObject::Connection geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::m_taskPreferencesSetConnection {}
private

The image task currently set and manipulated via this window

QMetaObject::Connection geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::m_taskWillStepConnection {}
private

Connection for telling the dialog when the image task preferences are set

float geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::m_timeRunning {0.0f}
private

Timer used to keep track of how long the image task has been in the "running" state

QTimer geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::m_timeRunningTimer
private

Whether to continually step i.e. whether to start another step after stepping once

const float geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::m_timeRunningTimerResolutionMs {100.0f}
private

Total time that the image task has been in the "running" state

ImageTaskWindow* geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::q {nullptr}
private
std::unique_ptr<Ui::ImageTaskWindow> geometrize::dialog::ImageTaskWindow::ImageTaskWindowImpl::ui {nullptr}
private

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