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 | Static Private Member Functions | Private Attributes | List of all members
geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl Class Reference
Collaboration diagram for geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl:
Collaboration graph
[legend]

Public Member Functions

 ImageTaskScriptingWidgetImpl (ImageTaskScriptingWidget *pQ)
 
 ~ImageTaskScriptingWidgetImpl ()=default
 
ImageTaskScriptingWidgetImpl operator= (const ImageTaskScriptingWidgetImpl &)=delete
 
 ImageTaskScriptingWidgetImpl (const ImageTaskScriptingWidgetImpl &)=delete
 
void setImageTask (task::ImageTask *task)
 
void syncUserInterface ()
 
std::map< std::string,
std::string > 
getShapeMutationScripts ()
 
std::map< std::string,
std::string > 
getScripts () const
 
bool evaluateStopConditionScripts () const
 
void evaluateScriptsWithNoReturnValue (const std::string &scriptGroupNamePrefix) const
 
void evaluateBeforeStepScripts () const
 
void evaluateAfterStepScripts () const
 
void evaluateBeforeAddShapeScripts () const
 
void evaluateAfterAddShapeScripts () const
 
void evaluateOnPenInputEventScripts () const
 
void evaluateOnPenProximityEnterEventScripts () const
 
void evaluateOnPenProximityExitEventScripts () const
 
void evaluateOnKeyDownEventScripts () const
 
void evaluateOnKeyUpEventScripts () const
 
void evaluateOnMouseDownEventScripts () const
 
void evaluateOnMouseUpEventScripts () const
 
void evaluateOnMouseMoveEventScripts () const
 
void evaluateOnMouseWheelEventScripts () const
 
void evaluateOnTimedUpdateEventScripts () const
 
void onLanguageChange ()
 

Private Member Functions

void addScriptWidget (const std::string &scriptDisplayName, const std::string &scriptIdPrefix, const std::string &scriptCode)
 
void addBeforeStepCallbackWidget (const std::string &scriptCode)
 
void addAfterStepCallbackWidget (const std::string &scriptCode)
 
void addCustomStopConditionWidget (const std::string &scriptCode)
 
void addBeforeAddShapeCallbackWidget (const std::string &scriptCode)
 
void addAfterAddShapeCallbackWidget (const std::string &scriptCode)
 
void addOnPenInputWidget (const std::string &scriptCode)
 
void addOnPenProximityEnterWidget (const std::string &scriptCode)
 
void addOnPenProximityExitWidget (const std::string &scriptCode)
 
void addOnKeyDownWidget (const std::string &scriptCode)
 
void addOnKeyUpWidget (const std::string &scriptCode)
 
void addOnMouseDownWidget (const std::string &scriptCode)
 
void addOnMouseUpWidget (const std::string &scriptCode)
 
void addOnMouseMoveWidget (const std::string &scriptCode)
 
void addOnMouseWheelWidget (const std::string &scriptCode)
 
void addOnTimedUpdateWidget (const std::string &scriptCode)
 
void revealShapeScriptingPanel ()
 
void setScripts (const std::map< std::string, std::string > &scripts)
 
dialog::ScriptEditorWidgetfindEditor (const std::string &editorId)
 
geometrize::dialog::ImageTaskShapeScriptingPanelgetShapeScriptingPanel () const
 
void populateUi ()
 
void populateScriptSelectionComboBox (QComboBox *combo, const std::map< std::string, std::string > &scripts)
 
std::string getScriptForSelectedComboBoxItem (QComboBox *combo)
 
void buildScriptSelectionComboBoxes ()
 

Static Private Member Functions

static bool startsWith (const std::string &s, const std::string &prefix)
 

Private Attributes

task::ImageTaskm_task {nullptr}
 
ImageTaskScriptingWidgetq
 
std::unique_ptr
< Ui::ImageTaskScriptingWidget > 
ui
 

Constructor & Destructor Documentation

geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::ImageTaskScriptingWidgetImpl ( ImageTaskScriptingWidget pQ)
inline
72  : q{pQ}, ui{std::make_unique<Ui::ImageTaskScriptingWidget>()}
73  {
74  ui->setupUi(q);
75  populateUi();
76 
78 
79  // Populate the preset script comboboxes with the default/built-in scripts
81 
82  connect(ui->clearScriptsButton, &QPushButton::clicked, [this]() {
83  QLayoutItem* item = nullptr;
84  while((item = ui->customScriptsEditorLayout->takeAt(0)) != nullptr) {
85  delete item->widget();
86  delete item;
87  }
88  });
89  connect(ui->rescanScriptsButton, &QPushButton::clicked, [this]() {
91  });
92 
93  connect(ui->editShapeScriptsButton, &QPushButton::clicked, [this]() {
95  });
96 
97  connect(ui->addBeforeStepEvent, &QPushButton::clicked, [this]() {
98  addBeforeStepCallbackWidget(getScriptForSelectedComboBoxItem(ui->addBeforeStepPresetScriptsComboBox));
99  });
100  connect(ui->addAfterStepEvent, &QPushButton::clicked, [this]() {
101  addAfterStepCallbackWidget(getScriptForSelectedComboBoxItem(ui->addAfterStepPresetScriptsComboBox));
102  });
103  connect(ui->addStopConditionButton, &QPushButton::clicked, [this]() {
104  addCustomStopConditionWidget(getScriptForSelectedComboBoxItem(ui->addStopConditionPresetScriptsComboBox));
105  });
106  connect(ui->addBeforeAddShapeEvent, &QPushButton::clicked, [this]() {
107  addBeforeAddShapeCallbackWidget(getScriptForSelectedComboBoxItem(ui->addBeforeAddShapePresetScriptsComboBox));
108  });
109  connect(ui->addAfterAddShapeEvent, &QPushButton::clicked, [this]() {
110  addAfterAddShapeCallbackWidget(getScriptForSelectedComboBoxItem(ui->addAfterAddShapePresetScriptsComboBox));
111  });
112  connect(ui->onScenePenInputEvent, &QPushButton::clicked, [this]() {
113  addOnPenInputWidget(getScriptForSelectedComboBoxItem(ui->onScenePenInputEventPresetScriptsComboBox));
114  });
115  connect(ui->onPenProximityEnterEvent, &QPushButton::clicked, [this]() {
116  addOnPenProximityEnterWidget(getScriptForSelectedComboBoxItem(ui->onPenProximityEnterEventPresetScriptsComboBox));
117  });
118  connect(ui->onPenProximityExitEvent, &QPushButton::clicked, [this]() {
119  addOnPenProximityExitWidget(getScriptForSelectedComboBoxItem(ui->onPenProximityExitEventPresetScriptsComboBox));
120  });
121  connect(ui->onKeyDownEvent, &QPushButton::clicked, [this]() {
122  addOnKeyDownWidget(getScriptForSelectedComboBoxItem(ui->onKeyDownEventPresetScriptsComboBox));
123  });
124  connect(ui->onKeyUpEvent, &QPushButton::clicked, [this]() {
125  addOnKeyUpWidget(getScriptForSelectedComboBoxItem(ui->onKeyUpEventPresetScriptsComboBox));
126  });
127  connect(ui->onMouseDownEvent, &QPushButton::clicked, [this]() {
128  addOnMouseDownWidget(getScriptForSelectedComboBoxItem(ui->onMouseDownEventPresetScriptsComboBox));
129  });
130  connect(ui->onMouseUpEvent, &QPushButton::clicked, [this]() {
131  addOnMouseUpWidget(getScriptForSelectedComboBoxItem(ui->onMouseUpEventPresetScriptsComboBox));
132  });
133  connect(ui->onMouseMoveEvent, &QPushButton::clicked, [this]() {
134  addOnMouseMoveWidget(getScriptForSelectedComboBoxItem(ui->onMouseMoveEventPresetScriptsComboBox));
135  });
136  connect(ui->onMouseWheelEvent, &QPushButton::clicked, [this]() {
137  addOnMouseWheelWidget(getScriptForSelectedComboBoxItem(ui->onMouseWheelEventPresetScriptsComboBox));
138  });
139  connect(ui->onUpdateEvent, &QPushButton::clicked, [this]() {
140  addOnTimedUpdateWidget(getScriptForSelectedComboBoxItem(ui->onUpdateEventPresetScriptsComboBox));
141  });
142 
143  // Update the script code when the editor modifies them
144  connect(q, &geometrize::dialog::ImageTaskScriptingWidget::signal_scriptChanged, [this](const std::string& functionName, const std::string& code) {
145  if(m_task) {
146  m_task->getPreferences().setScript(functionName, code);
147  }
148  });
149 
150  // Reveal shape scripting panel if global preferences are set this way
152  if(prefs.shouldShowImageTaskScriptEditorByDefault()) {
154  }
155  }
std::unique_ptr< Ui::ImageTaskScriptingWidget > ui
Definition: imagetaskscriptingwidget.cpp:529
void addOnPenProximityExitWidget(const std::string &scriptCode)
Definition: imagetaskscriptingwidget.cpp:403
void populateUi()
Definition: imagetaskscriptingwidget.cpp:484
The GlobalPreferences class models the preferences associated with the application as a whole...
Definition: globalpreferences.h:43
void addOnMouseMoveWidget(const std::string &scriptCode)
Definition: imagetaskscriptingwidget.cpp:428
void revealShapeScriptingPanel()
Definition: imagetaskscriptingwidget.cpp:444
geometrize::preferences::ImageTaskPreferences & getPreferences()
getPreferences Gets a reference to the current preferences of this task.
Definition: imagetask.cpp:330
void addCustomStopConditionWidget(const std::string &scriptCode)
Definition: imagetaskscriptingwidget.cpp:378
void addOnKeyDownWidget(const std::string &scriptCode)
Definition: imagetaskscriptingwidget.cpp:408
task::ImageTask * m_task
Definition: imagetaskscriptingwidget.cpp:526
void signal_scriptChanged(const std::string &functionName, const std::string &code)
void addAfterAddShapeCallbackWidget(const std::string &scriptCode)
Definition: imagetaskscriptingwidget.cpp:388
void buildScriptSelectionComboBoxes()
Definition: imagetaskscriptingwidget.cpp:502
std::string getScriptForSelectedComboBoxItem(QComboBox *combo)
Definition: imagetaskscriptingwidget.cpp:497
void setScript(const std::string &scriptName, const std::string &code)
Definition: imagetaskpreferences.cpp:252
void addBeforeStepCallbackWidget(const std::string &scriptCode)
Definition: imagetaskscriptingwidget.cpp:368
void addOnMouseDownWidget(const std::string &scriptCode)
Definition: imagetaskscriptingwidget.cpp:418
The ImageTaskShapeScriptingPanel models the UI for the script editors for controlling image task shap...
Definition: imagetaskshapescriptingpanel.h:35
geometrize::preferences::GlobalPreferences & getGlobalPreferences()
getGlobalPreferences Shorthand function that gets a reference to the shared global preferences object...
Definition: globalpreferences.cpp:32
void addOnMouseUpWidget(const std::string &scriptCode)
Definition: imagetaskscriptingwidget.cpp:423
void addOnPenProximityEnterWidget(const std::string &scriptCode)
Definition: imagetaskscriptingwidget.cpp:398
ImageTaskScriptingWidget * q
Definition: imagetaskscriptingwidget.cpp:528
void addOnTimedUpdateWidget(const std::string &scriptCode)
Definition: imagetaskscriptingwidget.cpp:438
void addOnKeyUpWidget(const std::string &scriptCode)
Definition: imagetaskscriptingwidget.cpp:413
void addOnPenInputWidget(const std::string &scriptCode)
Definition: imagetaskscriptingwidget.cpp:393
void addBeforeAddShapeCallbackWidget(const std::string &scriptCode)
Definition: imagetaskscriptingwidget.cpp:383
void addAfterStepCallbackWidget(const std::string &scriptCode)
Definition: imagetaskscriptingwidget.cpp:373
void addOnMouseWheelWidget(const std::string &scriptCode)
Definition: imagetaskscriptingwidget.cpp:433
geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::~ImageTaskScriptingWidgetImpl ( )
default
geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::ImageTaskScriptingWidgetImpl ( const ImageTaskScriptingWidgetImpl )
delete

Member Function Documentation

void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::addAfterAddShapeCallbackWidget ( const std::string &  scriptCode)
inlineprivate
389  {
390  addScriptWidget(tr("After Add Shape Callback").toStdString(), ::afterAddShapeCallbackPrefix, scriptCode);
391  }
void addScriptWidget(const std::string &scriptDisplayName, const std::string &scriptIdPrefix, const std::string &scriptCode)
Definition: imagetaskscriptingwidget.cpp:339
void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::addAfterStepCallbackWidget ( const std::string &  scriptCode)
inlineprivate
374  {
375  addScriptWidget(tr("After Step Callback").toStdString(), ::afterStepCallbackPrefix, scriptCode);
376  }
void addScriptWidget(const std::string &scriptDisplayName, const std::string &scriptIdPrefix, const std::string &scriptCode)
Definition: imagetaskscriptingwidget.cpp:339
void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::addBeforeAddShapeCallbackWidget ( const std::string &  scriptCode)
inlineprivate
384  {
385  addScriptWidget(tr("Before Add Shape Callback").toStdString(), ::beforeAddShapeCallbackPrefix, scriptCode);
386  }
void addScriptWidget(const std::string &scriptDisplayName, const std::string &scriptIdPrefix, const std::string &scriptCode)
Definition: imagetaskscriptingwidget.cpp:339
void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::addBeforeStepCallbackWidget ( const std::string &  scriptCode)
inlineprivate
369  {
370  addScriptWidget(tr("Before Step Callback").toStdString(), ::beforeStepCallbackPrefix, scriptCode);
371  }
void addScriptWidget(const std::string &scriptDisplayName, const std::string &scriptIdPrefix, const std::string &scriptCode)
Definition: imagetaskscriptingwidget.cpp:339
void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::addCustomStopConditionWidget ( const std::string &  scriptCode)
inlineprivate
379  {
380  addScriptWidget(tr("Custom Stop Condition").toStdString(), ::stopConditionIdPrefix, scriptCode);
381  }
void addScriptWidget(const std::string &scriptDisplayName, const std::string &scriptIdPrefix, const std::string &scriptCode)
Definition: imagetaskscriptingwidget.cpp:339
void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::addOnKeyDownWidget ( const std::string &  scriptCode)
inlineprivate
409  {
410  addScriptWidget(tr("On Key Down Callback").toStdString(), ::onKeyDownCallbackPrefix, scriptCode);
411  }
void addScriptWidget(const std::string &scriptDisplayName, const std::string &scriptIdPrefix, const std::string &scriptCode)
Definition: imagetaskscriptingwidget.cpp:339
void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::addOnKeyUpWidget ( const std::string &  scriptCode)
inlineprivate
414  {
415  addScriptWidget(tr("On Key Up Callback").toStdString(), ::onKeyUpCallbackPrefix, scriptCode);
416  }
void addScriptWidget(const std::string &scriptDisplayName, const std::string &scriptIdPrefix, const std::string &scriptCode)
Definition: imagetaskscriptingwidget.cpp:339
void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::addOnMouseDownWidget ( const std::string &  scriptCode)
inlineprivate
419  {
420  addScriptWidget(tr("On Mouse Down Callback").toStdString(), ::onMouseDownCallbackPrefix, scriptCode);
421  }
void addScriptWidget(const std::string &scriptDisplayName, const std::string &scriptIdPrefix, const std::string &scriptCode)
Definition: imagetaskscriptingwidget.cpp:339
void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::addOnMouseMoveWidget ( const std::string &  scriptCode)
inlineprivate
429  {
430  addScriptWidget(tr("On Mouse Move Callback").toStdString(), ::onMouseMoveCallbackPrefix, scriptCode);
431  }
void addScriptWidget(const std::string &scriptDisplayName, const std::string &scriptIdPrefix, const std::string &scriptCode)
Definition: imagetaskscriptingwidget.cpp:339
void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::addOnMouseUpWidget ( const std::string &  scriptCode)
inlineprivate
424  {
425  addScriptWidget(tr("On Mouse Up Callback").toStdString(), ::onMouseUpCallbackPrefix, scriptCode);
426  }
void addScriptWidget(const std::string &scriptDisplayName, const std::string &scriptIdPrefix, const std::string &scriptCode)
Definition: imagetaskscriptingwidget.cpp:339
void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::addOnMouseWheelWidget ( const std::string &  scriptCode)
inlineprivate
434  {
435  addScriptWidget(tr("On Mouse Wheel Callback").toStdString(), ::onMouseWheelCallbackPrefix, scriptCode);
436  }
void addScriptWidget(const std::string &scriptDisplayName, const std::string &scriptIdPrefix, const std::string &scriptCode)
Definition: imagetaskscriptingwidget.cpp:339
void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::addOnPenInputWidget ( const std::string &  scriptCode)
inlineprivate
394  {
395  addScriptWidget(tr("On Pen Input Callback").toStdString(), ::onPenInputCallbackPrefix, scriptCode);
396  }
void addScriptWidget(const std::string &scriptDisplayName, const std::string &scriptIdPrefix, const std::string &scriptCode)
Definition: imagetaskscriptingwidget.cpp:339
void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::addOnPenProximityEnterWidget ( const std::string &  scriptCode)
inlineprivate
399  {
400  addScriptWidget(tr("On Pen Proximity Enter Callback").toStdString(), ::onPenProximityEnterCallbackPrefix, scriptCode);
401  }
void addScriptWidget(const std::string &scriptDisplayName, const std::string &scriptIdPrefix, const std::string &scriptCode)
Definition: imagetaskscriptingwidget.cpp:339
void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::addOnPenProximityExitWidget ( const std::string &  scriptCode)
inlineprivate
404  {
405  addScriptWidget(tr("On Pen Proximity Exit Callback").toStdString(), ::onPenProximityExitCallbackPrefix, scriptCode);
406  }
void addScriptWidget(const std::string &scriptDisplayName, const std::string &scriptIdPrefix, const std::string &scriptCode)
Definition: imagetaskscriptingwidget.cpp:339
void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::addOnTimedUpdateWidget ( const std::string &  scriptCode)
inlineprivate
439  {
440  addScriptWidget(tr("On Timed Update Callback").toStdString(), ::onTimedUpdateCallbackPrefix, scriptCode);
441  }
void addScriptWidget(const std::string &scriptDisplayName, const std::string &scriptIdPrefix, const std::string &scriptCode)
Definition: imagetaskscriptingwidget.cpp:339
void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::addScriptWidget ( const std::string &  scriptDisplayName,
const std::string &  scriptIdPrefix,
const std::string &  scriptCode 
)
inlineprivate
340  {
341  if(!startsWith(scriptIdPrefix, ::stopConditionIdPrefix) &&
342  !startsWith(scriptIdPrefix, ::beforeAddShapeCallbackPrefix) &&
343  !startsWith(scriptIdPrefix, ::afterAddShapeCallbackPrefix) &&
344  !startsWith(scriptIdPrefix, ::beforeStepCallbackPrefix) &&
345  !startsWith(scriptIdPrefix, ::afterStepCallbackPrefix) &&
346  !startsWith(scriptIdPrefix, ::onPenInputCallbackPrefix) &&
347  !startsWith(scriptIdPrefix, ::onPenProximityEnterCallbackPrefix) &&
348  !startsWith(scriptIdPrefix, ::onPenProximityExitCallbackPrefix) &&
349  !startsWith(scriptIdPrefix, ::onKeyDownCallbackPrefix) &&
350  !startsWith(scriptIdPrefix, ::onKeyUpCallbackPrefix) &&
351  !startsWith(scriptIdPrefix, ::onMouseDownCallbackPrefix) &&
352  !startsWith(scriptIdPrefix, ::onMouseUpCallbackPrefix) &&
353  !startsWith(scriptIdPrefix, ::onMouseMoveCallbackPrefix) &&
354  !startsWith(scriptIdPrefix, ::onMouseWheelCallbackPrefix) &&
355  !startsWith(scriptIdPrefix, ::onTimedUpdateCallbackPrefix))
356  {
357  return;
358  }
359 
360  const std::string functionName = scriptIdPrefix + QUuid::createUuid().toString().toStdString();
361  auto widget = new geometrize::dialog::ScriptEditorWidget(scriptDisplayName, functionName, scriptCode, ui->customScriptsGroupBox);
362  connect(widget, &ScriptEditorWidget::signal_scriptChanged, [this](ScriptEditorWidget* /*self*/, const std::string& functionName, const std::string& code) {
363  emit q->signal_scriptChanged(functionName, code);
364  });
365  ui->customScriptsEditorLayout->addWidget(widget);
366  }
std::unique_ptr< Ui::ImageTaskScriptingWidget > ui
Definition: imagetaskscriptingwidget.cpp:529
void signal_scriptChanged(ScriptEditorWidget *self, const std::string &functionName, const std::string &code)
signal_scriptChanged Signal emitted when the user change the script code of a function.
The ScriptEditorWidget class implements a widget for interactively editing a Chaiscript function...
Definition: scripteditorwidget.h:19
static bool startsWith(const std::string &s, const std::string &prefix)
Definition: imagetaskscriptingwidget.cpp:334
void signal_scriptChanged(const std::string &functionName, const std::string &code)
ImageTaskScriptingWidget * q
Definition: imagetaskscriptingwidget.cpp:528
void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::buildScriptSelectionComboBoxes ( )
inlineprivate
503  {
504  std::vector<std::pair<QComboBox*, std::map<std::string, std::string>>> presetScriptData;
505  presetScriptData.push_back(std::make_pair(ui->addBeforeStepPresetScriptsComboBox, geometrize::script::getBeforeStepCallbackScripts()));
506  presetScriptData.push_back(std::make_pair(ui->addAfterStepPresetScriptsComboBox, geometrize::script::getAfterStepCallbackScripts()));
507  presetScriptData.push_back(std::make_pair(ui->addStopConditionPresetScriptsComboBox, geometrize::script::getStopConditionScripts()));
508  presetScriptData.push_back(std::make_pair(ui->addBeforeAddShapePresetScriptsComboBox, geometrize::script::getBeforeAddShapeCallbackScripts()));
509  presetScriptData.push_back(std::make_pair(ui->addAfterAddShapePresetScriptsComboBox, geometrize::script::getAfterAddShapeCallbackScripts()));
510  presetScriptData.push_back(std::make_pair(ui->onScenePenInputEventPresetScriptsComboBox, geometrize::script::getOnPenInputCallbackScripts()));
511  presetScriptData.push_back(std::make_pair(ui->onPenProximityEnterEventPresetScriptsComboBox, geometrize::script::getOnPenProximityEnterCallbackScripts()));
512  presetScriptData.push_back(std::make_pair(ui->onPenProximityExitEventPresetScriptsComboBox, geometrize::script::getOnPenProximityExitCallbackScripts()));
513  presetScriptData.push_back(std::make_pair(ui->onKeyDownEventPresetScriptsComboBox, geometrize::script::getOnKeyDownEventScripts()));
514  presetScriptData.push_back(std::make_pair(ui->onKeyUpEventPresetScriptsComboBox, geometrize::script::getOnKeyUpEventScripts()));
515  presetScriptData.push_back(std::make_pair(ui->onMouseDownEventPresetScriptsComboBox, geometrize::script::getOnMouseDownEventScripts()));
516  presetScriptData.push_back(std::make_pair(ui->onMouseUpEventPresetScriptsComboBox, geometrize::script::getOnMouseUpEventScripts()));
517  presetScriptData.push_back(std::make_pair(ui->onMouseMoveEventPresetScriptsComboBox, geometrize::script::getOnMouseMoveEventScripts()));
518  presetScriptData.push_back(std::make_pair(ui->onMouseWheelEventPresetScriptsComboBox, geometrize::script::getOnMouseWheelEventScripts()));
519  presetScriptData.push_back(std::make_pair(ui->onUpdateEventPresetScriptsComboBox, geometrize::script::getOnTimedUpdateEventScripts()));
520 
521  for(const auto& item : presetScriptData) {
522  populateScriptSelectionComboBox(item.first, item.second);
523  }
524  }
std::map< std::string, std::string > getAfterStepCallbackScripts()
getAfterStepCallbackScripts Gets a map of scripts that are useful to call after stepping an image tas...
Definition: scriptutil.cpp:78
std::map< std::string, std::string > getOnMouseWheelEventScripts()
getOnMouseWheelEventScripts Gets a map of scripts that are useful to call after receiving a mouse whe...
Definition: scriptutil.cpp:138
std::map< std::string, std::string > getBeforeStepCallbackScripts()
getBeforeStepCallbackScripts Gets a map of scripts that are useful to call prior to stepping an image...
Definition: scriptutil.cpp:73
std::unique_ptr< Ui::ImageTaskScriptingWidget > ui
Definition: imagetaskscriptingwidget.cpp:529
void populateScriptSelectionComboBox(QComboBox *combo, const std::map< std::string, std::string > &scripts)
Definition: imagetaskscriptingwidget.cpp:488
std::map< std::string, std::string > getOnPenProximityEnterCallbackScripts()
getOnPenProximityEnterCallbackScripts Gets a map of scripts that are useful to call after receiving a...
Definition: scriptutil.cpp:103
std::map< std::string, std::string > getOnKeyUpEventScripts()
getOnKeyUpEventScripts Gets a map of scripts that are useful to call after receiving a key up event t...
Definition: scriptutil.cpp:118
std::map< std::string, std::string > getOnMouseUpEventScripts()
getOnMouseUpEventScripts Gets a map of scripts that are useful to call after receiving a mouse up eve...
Definition: scriptutil.cpp:128
std::map< std::string, std::string > getOnTimedUpdateEventScripts()
getOnTimedUpdateEventScripts Gets a map of scripts that are useful to regularly periodically call i...
Definition: scriptutil.cpp:143
std::map< std::string, std::string > getOnPenProximityExitCallbackScripts()
getOnPenProximityExitCallbackScripts Gets a map of scripts that are useful to call after receiving a ...
Definition: scriptutil.cpp:108
std::map< std::string, std::string > getOnKeyDownEventScripts()
getOnKeyDownEventScripts Gets a map of scripts that are useful to call after receiving a key down eve...
Definition: scriptutil.cpp:113
std::map< std::string, std::string > getOnMouseMoveEventScripts()
getOnMouseMoveEventScripts Gets a map of scripts that are useful to call after receiving a mouse move...
Definition: scriptutil.cpp:133
std::map< std::string, std::string > getAfterAddShapeCallbackScripts()
getAfterAddShapeCallbackScripts Gets a map of scripts that are useful to call after adding a shape to...
Definition: scriptutil.cpp:93
std::map< std::string, std::string > getOnMouseDownEventScripts()
getOnMouseDownEventScripts Gets a map of scripts that are useful to call after receiving a mouse down...
Definition: scriptutil.cpp:123
std::map< std::string, std::string > getOnPenInputCallbackScripts()
getOnPenInputCallbackScripts Gets a map of scripts that are useful to call after receiving pen input ...
Definition: scriptutil.cpp:98
std::map< std::string, std::string > getStopConditionScripts()
getStopConditionScripts Gets a map of scripts that get to true/false, and can be used to check whethe...
Definition: scriptutil.cpp:83
std::map< std::string, std::string > getBeforeAddShapeCallbackScripts()
getBeforeAddShapeCallbackScripts Gets a map of scripts that are useful to call before adding a shape ...
Definition: scriptutil.cpp:88

Here is the call graph for this function:

void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::evaluateAfterAddShapeScripts ( ) const
inline
273  {
274  evaluateScriptsWithNoReturnValue(::afterAddShapeCallbackPrefix);
275  }
void evaluateScriptsWithNoReturnValue(const std::string &scriptGroupNamePrefix) const
Definition: imagetaskscriptingwidget.cpp:231
void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::evaluateAfterStepScripts ( ) const
inline
263  {
264  evaluateScriptsWithNoReturnValue(::afterStepCallbackPrefix);
265  }
void evaluateScriptsWithNoReturnValue(const std::string &scriptGroupNamePrefix) const
Definition: imagetaskscriptingwidget.cpp:231
void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::evaluateBeforeAddShapeScripts ( ) const
inline
268  {
269  evaluateScriptsWithNoReturnValue(::beforeAddShapeCallbackPrefix);
270  }
void evaluateScriptsWithNoReturnValue(const std::string &scriptGroupNamePrefix) const
Definition: imagetaskscriptingwidget.cpp:231
void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::evaluateBeforeStepScripts ( ) const
inline
258  {
259  evaluateScriptsWithNoReturnValue(::beforeStepCallbackPrefix);
260  }
void evaluateScriptsWithNoReturnValue(const std::string &scriptGroupNamePrefix) const
Definition: imagetaskscriptingwidget.cpp:231
void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::evaluateOnKeyDownEventScripts ( ) const
inline
293  {
294  evaluateScriptsWithNoReturnValue(::onKeyDownCallbackPrefix);
295  }
void evaluateScriptsWithNoReturnValue(const std::string &scriptGroupNamePrefix) const
Definition: imagetaskscriptingwidget.cpp:231
void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::evaluateOnKeyUpEventScripts ( ) const
inline
298  {
299  evaluateScriptsWithNoReturnValue(::onKeyUpCallbackPrefix);
300  }
void evaluateScriptsWithNoReturnValue(const std::string &scriptGroupNamePrefix) const
Definition: imagetaskscriptingwidget.cpp:231
void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::evaluateOnMouseDownEventScripts ( ) const
inline
303  {
304  evaluateScriptsWithNoReturnValue(::onMouseDownCallbackPrefix);
305  }
void evaluateScriptsWithNoReturnValue(const std::string &scriptGroupNamePrefix) const
Definition: imagetaskscriptingwidget.cpp:231
void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::evaluateOnMouseMoveEventScripts ( ) const
inline
313  {
314  evaluateScriptsWithNoReturnValue(::onMouseMoveCallbackPrefix);
315  }
void evaluateScriptsWithNoReturnValue(const std::string &scriptGroupNamePrefix) const
Definition: imagetaskscriptingwidget.cpp:231
void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::evaluateOnMouseUpEventScripts ( ) const
inline
308  {
309  evaluateScriptsWithNoReturnValue(::onMouseUpCallbackPrefix);
310  }
void evaluateScriptsWithNoReturnValue(const std::string &scriptGroupNamePrefix) const
Definition: imagetaskscriptingwidget.cpp:231
void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::evaluateOnMouseWheelEventScripts ( ) const
inline
318  {
319  evaluateScriptsWithNoReturnValue(::onMouseWheelCallbackPrefix);
320  }
void evaluateScriptsWithNoReturnValue(const std::string &scriptGroupNamePrefix) const
Definition: imagetaskscriptingwidget.cpp:231
void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::evaluateOnPenInputEventScripts ( ) const
inline
278  {
279  evaluateScriptsWithNoReturnValue(::onPenInputCallbackPrefix);
280  }
void evaluateScriptsWithNoReturnValue(const std::string &scriptGroupNamePrefix) const
Definition: imagetaskscriptingwidget.cpp:231
void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::evaluateOnPenProximityEnterEventScripts ( ) const
inline
283  {
284  evaluateScriptsWithNoReturnValue(::onPenProximityEnterCallbackPrefix);
285  }
void evaluateScriptsWithNoReturnValue(const std::string &scriptGroupNamePrefix) const
Definition: imagetaskscriptingwidget.cpp:231
void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::evaluateOnPenProximityExitEventScripts ( ) const
inline
288  {
289  evaluateScriptsWithNoReturnValue(::onPenProximityExitCallbackPrefix);
290  }
void evaluateScriptsWithNoReturnValue(const std::string &scriptGroupNamePrefix) const
Definition: imagetaskscriptingwidget.cpp:231
void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::evaluateOnTimedUpdateEventScripts ( ) const
inline
323  {
324  evaluateScriptsWithNoReturnValue(::onTimedUpdateCallbackPrefix);
325  }
void evaluateScriptsWithNoReturnValue(const std::string &scriptGroupNamePrefix) const
Definition: imagetaskscriptingwidget.cpp:231
void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::evaluateScriptsWithNoReturnValue ( const std::string &  scriptGroupNamePrefix) const
inline
232  {
233  const auto engine = m_task->getGeometrizer().getEngine();
234  if(!engine) {
235  return;
236  }
237 
238  const auto scriptWidgets = ui->customScriptsGroupBox->findChildren<geometrize::dialog::ScriptEditorWidget*>();
239  for(const auto& widget : scriptWidgets) {
240  if(widget->getFunctionName().substr(0, scriptGroupNamePrefix.length()) != scriptGroupNamePrefix) {
241  continue;
242  }
243 
244  try {
245  engine->eval(widget->getCurrentCode());
246  widget->onScriptEvaluationSucceeded();
247  } catch(const chaiscript::exception::eval_error& e) {
248  widget->onScriptEvaluationFailed(e.pretty_print());
249  } catch(const std::exception& e) {
250  widget->onScriptEvaluationFailed(e.what());
251  } catch(...) {
252  widget->onScriptEvaluationFailed("Unknown script evaluation error");
253  }
254  }
255  }
std::unique_ptr< Ui::ImageTaskScriptingWidget > ui
Definition: imagetaskscriptingwidget.cpp:529
The ScriptEditorWidget class implements a widget for interactively editing a Chaiscript function...
Definition: scripteditorwidget.h:19
chaiscript::ChaiScript * getEngine()
getEngine Gets a pointer to the script engine used by the shape mutation engine.
Definition: geometrizerengine.cpp:52
task::ImageTask * m_task
Definition: imagetaskscriptingwidget.cpp:526
geometrize::script::GeometrizerEngine & getGeometrizer()
getGeometrizer Gets a reference to the script-based engine used to turn images into shapes...
Definition: imagetask.cpp:340
void onScriptEvaluationSucceeded()
Definition: scripteditorwidget.cpp:210

Here is the call graph for this function:

bool geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::evaluateStopConditionScripts ( ) const
inline
200  {
201  const auto engine = m_task->getGeometrizer().getEngine();
202  if(!engine) {
203  return false;
204  }
205 
206  const auto scriptWidgets = ui->customScriptsGroupBox->findChildren<geometrize::dialog::ScriptEditorWidget*>();
207  bool scriptStopConditionMet = false;
208  for(const auto& widget : scriptWidgets) {
209  if(widget->getFunctionName().substr(0, stopConditionIdPrefix.length()) != stopConditionIdPrefix) {
210  continue; // Skip anything other than stop conditions
211  }
212 
213  try {
214  auto stopCondition = engine->eval<bool>(widget->getCurrentCode());
215  if(stopCondition) {
216  scriptStopConditionMet = true;
217  }
218  widget->onScriptEvaluationSucceeded();
219  } catch(const chaiscript::exception::eval_error& e) {
220  widget->onScriptEvaluationFailed(e.pretty_print());
221  } catch(const std::exception& e) {
222  widget->onScriptEvaluationFailed(e.what());
223  } catch(...) {
224  widget->onScriptEvaluationFailed("Unknown script evaluation error");
225  }
226  }
227 
228  return scriptStopConditionMet;
229  }
std::unique_ptr< Ui::ImageTaskScriptingWidget > ui
Definition: imagetaskscriptingwidget.cpp:529
The ScriptEditorWidget class implements a widget for interactively editing a Chaiscript function...
Definition: scripteditorwidget.h:19
chaiscript::ChaiScript * getEngine()
getEngine Gets a pointer to the script engine used by the shape mutation engine.
Definition: geometrizerengine.cpp:52
task::ImageTask * m_task
Definition: imagetaskscriptingwidget.cpp:526
geometrize::script::GeometrizerEngine & getGeometrizer()
getGeometrizer Gets a reference to the script-based engine used to turn images into shapes...
Definition: imagetask.cpp:340
void onScriptEvaluationSucceeded()
Definition: scripteditorwidget.cpp:210

Here is the call graph for this function:

dialog::ScriptEditorWidget* geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::findEditor ( const std::string &  editorId)
inlineprivate
469  {
470  const auto& editors = ui->customScriptsGroupBox->findChildren<geometrize::dialog::ScriptEditorWidget*>();
471  for(const auto& editor : editors) {
472  if(editor->getFunctionName() == editorId) {
473  return editor;
474  }
475  }
476  return nullptr;
477  }
std::unique_ptr< Ui::ImageTaskScriptingWidget > ui
Definition: imagetaskscriptingwidget.cpp:529
The ScriptEditorWidget class implements a widget for interactively editing a Chaiscript function...
Definition: scripteditorwidget.h:19
std::string geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::getScriptForSelectedComboBoxItem ( QComboBox *  combo)
inlineprivate
498  {
499  return combo->itemData(combo->currentIndex()).toString().toStdString();
500  }
std::map<std::string, std::string> geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::getScripts ( ) const
inline
184  {
185  // Gather the scripts from the editor boxes
186  const auto& editors = ui->customScriptsGroupBox->findChildren<geometrize::dialog::ScriptEditorWidget*>();
187  std::map<std::string, std::string> scripts;
188  for(ScriptEditorWidget* editor : editors) {
189  scripts[editor->getFunctionName()] = editor->getCurrentCode();
190  }
191 
192  // Gather the scripts from the shape scripting panel
193  const std::map<std::string, std::string> shapeScripts = getShapeScriptingPanel()->getScripts();
194  scripts.insert(shapeScripts.begin(), shapeScripts.end());
195 
196  return scripts;
197  }
std::unique_ptr< Ui::ImageTaskScriptingWidget > ui
Definition: imagetaskscriptingwidget.cpp:529
The ScriptEditorWidget class implements a widget for interactively editing a Chaiscript function...
Definition: scripteditorwidget.h:19
std::string getCurrentCode() const
Definition: scripteditorwidget.cpp:200
geometrize::dialog::ImageTaskShapeScriptingPanel * getShapeScriptingPanel() const
Definition: imagetaskscriptingwidget.cpp:479
std::map< std::string, std::string > getScripts() const
Definition: imagetaskshapescriptingpanel.cpp:269

Here is the call graph for this function:

std::map<std::string, std::string> geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::getShapeMutationScripts ( )
inline
177  {
179  }
geometrize::dialog::ImageTaskShapeScriptingPanel * getShapeScriptingPanel() const
Definition: imagetaskscriptingwidget.cpp:479
std::map< std::string, std::string > getScripts() const
Definition: imagetaskshapescriptingpanel.cpp:269
geometrize::dialog::ImageTaskShapeScriptingPanel* geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::getShapeScriptingPanel ( ) const
inlineprivate
480  {
482  }
The ImageTaskShapeScriptingPanel models the UI for the script editors for controlling image task shap...
Definition: imagetaskshapescriptingpanel.h:35
ImageTaskScriptingWidget * q
Definition: imagetaskscriptingwidget.cpp:528
void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::onLanguageChange ( )
inline
328  {
329  ui->retranslateUi(q);
330  populateUi();
331  }
std::unique_ptr< Ui::ImageTaskScriptingWidget > ui
Definition: imagetaskscriptingwidget.cpp:529
void populateUi()
Definition: imagetaskscriptingwidget.cpp:484
ImageTaskScriptingWidget * q
Definition: imagetaskscriptingwidget.cpp:528
ImageTaskScriptingWidgetImpl geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::operator= ( const ImageTaskScriptingWidgetImpl )
delete
void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::populateScriptSelectionComboBox ( QComboBox *  combo,
const std::map< std::string, std::string > &  scripts 
)
inlineprivate
489  {
490  combo->clear();
491  for(const auto& item : scripts) {
492  combo->addItem(QString::fromStdString(item.first), QString::fromStdString(item.second));
493  }
494  combo->setCurrentIndex(0);
495  }
void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::populateUi ( )
inlineprivate
485  {
486  }
void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::revealShapeScriptingPanel ( )
inlineprivate
445  {
446  auto scriptingPanel = getShapeScriptingPanel();
447  scriptingPanel->setWindowState(scriptingPanel->windowState() & ~Qt::WindowMinimized);
448  QApplication::setActiveWindow(scriptingPanel);
449  scriptingPanel->raise();
450  scriptingPanel->show();
451  }
geometrize::dialog::ImageTaskShapeScriptingPanel * getShapeScriptingPanel() const
Definition: imagetaskscriptingwidget.cpp:479
void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::setImageTask ( task::ImageTask task)
inline
161  {
162  m_task = task;
164  }
task::ImageTask * m_task
Definition: imagetaskscriptingwidget.cpp:526
geometrize::dialog::ImageTaskShapeScriptingPanel * getShapeScriptingPanel() const
Definition: imagetaskscriptingwidget.cpp:479
void setImageTask(task::ImageTask *task)
setImageTask Sets the current image task manipulated by the scripting panel.
Definition: imagetaskshapescriptingpanel.cpp:259
void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::setScripts ( const std::map< std::string, std::string > &  scripts)
inlineprivate
454  {
455  // Look for matching script editor widgets, and set their contents if found
456  for(const auto& script : scripts) {
457  if(dialog::ScriptEditorWidget* editor = findEditor(script.first)) {
458  if(!script.second.empty()) {
459  editor->setCurrentCode(script.second);
460  }
461  } else {
462  // If no such editor exists, create a new panel (but only for scripts with names we recognize)
463  addScriptWidget(script.first, script.first, script.second);
464  }
465  }
466  }
dialog::ScriptEditorWidget * findEditor(const std::string &editorId)
Definition: imagetaskscriptingwidget.cpp:468
void addScriptWidget(const std::string &scriptDisplayName, const std::string &scriptIdPrefix, const std::string &scriptCode)
Definition: imagetaskscriptingwidget.cpp:339
static bool geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::startsWith ( const std::string &  s,
const std::string &  prefix 
)
inlinestaticprivate
335  {
336  return s.rfind(prefix, 0) == 0;
337  }
void geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::syncUserInterface ( )
inline
167  {
168  if(m_task == nullptr) {
169  return;
170  }
171 
174  }
geometrize::preferences::ImageTaskPreferences & getPreferences()
getPreferences Gets a reference to the current preferences of this task.
Definition: imagetask.cpp:330
void setScripts(const std::map< std::string, std::string > &scripts)
Definition: imagetaskscriptingwidget.cpp:453
task::ImageTask * m_task
Definition: imagetaskscriptingwidget.cpp:526
geometrize::dialog::ImageTaskShapeScriptingPanel * getShapeScriptingPanel() const
Definition: imagetaskscriptingwidget.cpp:479
std::map< std::string, std::string > getScripts() const
Definition: imagetaskpreferences.cpp:262
void syncUserInterface()
syncUserInterface Syncs the user interface with the current image task. This should be called after s...
Definition: imagetaskshapescriptingpanel.cpp:264

Member Data Documentation

task::ImageTask* geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::m_task {nullptr}
private
ImageTaskScriptingWidget* geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::q
private
std::unique_ptr<Ui::ImageTaskScriptingWidget> geometrize::dialog::ImageTaskScriptingWidget::ImageTaskScriptingWidgetImpl::ui
private

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