Geometrize  1.0
An application for geometrizing images into geometric primitives
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros
Namespaces | Classes | Functions
geometrize::script Namespace Reference

Namespaces

 bindings
 

Classes

class  GeometrizerEngine
 The GeometrizerEngine class encapsulates script-based setup and mutation methods for geometrizing shapes. More...
 

Functions

std::unique_ptr
< chaiscript::ChaiScript > 
createDefaultEngine ()
 createDefaultEngine Creates a default Chaiscript engine object, with the default bindings (Geometrize-specific utility functions etc). More...
 
std::unique_ptr
< chaiscript::ChaiScript > 
createLaunchWindowEngine ()
 createLaunchWindowEngine Creates a Chaiscript engine object for the launch window. More...
 
std::unique_ptr
< chaiscript::ChaiScript > 
createImageTaskEngine ()
 createImageTaskEngine Creates a Chaiscript engine for an image task window. More...
 
std::unique_ptr
< chaiscript::ChaiScript > 
createBatchImageTaskEngine ()
 createBatchImageTaskEngine Creates a Chaiscript engine for creating and processing multiple image tasks. More...
 
std::unique_ptr
< chaiscript::ChaiScript > 
createShapeMutatorEngine ()
 createShapeMutatorEngine Creates a Chaiscript engine object for mutating shapes. More...
 
std::unique_ptr
< chaiscript::ChaiScript > 
createFunctionalTestRunnerEngine ()
 createFunctionalTestRunnerEngine Creates a Chaiscript engine object for running functional tests. More...
 
void runScript (const std::string &code, chaiscript::ChaiScript &runner)
 runScript Evaluates the provided script code. More...
 
void runScript (const std::string &code)
 runScript Evaluates the provided script code, creating a fresh engine to evaluate the script. More...
 
void sleep (std::size_t ms)
 sleep Causes the calling thread to sleep for the given length of time. More...
 
std::vector< std::string > getEngineFunctionNames (const chaiscript::ChaiScript &engine)
 getEngineFunctionNames Gets the names of the functions registered with the given engine. More...
 
std::map< std::string,
std::string > 
getScripts (const std::string &folder)
 getDefaultScripts Gets a map of the scripts in the given folder. Path to the folder containing the ChaiScript scripts to retrieve. The files must have the ".chai" file extension. More...
 
std::map< std::string,
std::string > 
getDefaultShapeMutatorScripts ()
 getDefaultScripts Gets a map of the default scripts used for shape creation and mutation in image tasks. More...
 
std::map< std::string,
std::string > 
getPointerAreaOfInterestShapeMutatorScripts ()
 getPointerAreaOfInterestScripts Gets a map of the scripts used for shape creation and mutation based around user input/pointer interaction. More...
 
std::map< std::string,
std::string > 
getBeforeStepCallbackScripts ()
 getBeforeStepCallbackScripts Gets a map of scripts that are useful to call prior to stepping an image task (i.e. before starting work to find a shape to add). More...
 
std::map< std::string,
std::string > 
getAfterStepCallbackScripts ()
 getAfterStepCallbackScripts Gets a map of scripts that are useful to call after stepping an image task (i.e. after completing work to find a shape to add). More...
 
std::map< std::string,
std::string > 
getStopConditionScripts ()
 getStopConditionScripts Gets a map of scripts that get to true/false, and can be used to check whether to stop an image task (usually after stepping). More...
 
std::map< std::string,
std::string > 
getBeforeAddShapeCallbackScripts ()
 getBeforeAddShapeCallbackScripts Gets a map of scripts that are useful to call before adding a shape to the image task views. More...
 
std::map< std::string,
std::string > 
getAfterAddShapeCallbackScripts ()
 getAfterAddShapeCallbackScripts Gets a map of scripts that are useful to call after adding a shape to the image task views. More...
 
std::map< std::string,
std::string > 
getOnPenInputCallbackScripts ()
 getOnPenInputCallbackScripts Gets a map of scripts that are useful to call after receiving pen input to the image task views. More...
 
std::map< std::string,
std::string > 
getOnPenProximityEnterCallbackScripts ()
 getOnPenProximityEnterCallbackScripts Gets a map of scripts that are useful to call after receiving a pen proximity enter event. This is application global, not bound to a particular view. More...
 
std::map< std::string,
std::string > 
getOnPenProximityExitCallbackScripts ()
 getOnPenProximityExitCallbackScripts Gets a map of scripts that are useful to call after receiving a pen proximity exit event. This is application global, not bound to a particular view. More...
 
std::map< std::string,
std::string > 
getOnKeyDownEventScripts ()
 getOnKeyDownEventScripts Gets a map of scripts that are useful to call after receiving a key down event to the image task views. More...
 
std::map< std::string,
std::string > 
getOnKeyUpEventScripts ()
 getOnKeyUpEventScripts Gets a map of scripts that are useful to call after receiving a key up event to the image task views. More...
 
std::map< std::string,
std::string > 
getOnMouseDownEventScripts ()
 getOnMouseDownEventScripts Gets a map of scripts that are useful to call after receiving a mouse down event to the image task views. More...
 
std::map< std::string,
std::string > 
getOnMouseUpEventScripts ()
 getOnMouseUpEventScripts Gets a map of scripts that are useful to call after receiving a mouse up event to the image task views. More...
 
std::map< std::string,
std::string > 
getOnMouseMoveEventScripts ()
 getOnMouseMoveEventScripts Gets a map of scripts that are useful to call after receiving a mouse move event to the image task views. More...
 
std::map< std::string,
std::string > 
getOnMouseWheelEventScripts ()
 getOnMouseWheelEventScripts Gets a map of scripts that are useful to call after receiving a mouse wheel event to the image task views. More...
 
std::map< std::string,
std::string > 
getOnTimedUpdateEventScripts ()
 getOnTimedUpdateEventScripts Gets a map of scripts that are useful to regularly periodically call i.e. on update More...
 

Function Documentation

std::unique_ptr< chaiscript::ChaiScript > geometrize::script::createBatchImageTaskEngine ( )

createBatchImageTaskEngine Creates a Chaiscript engine for creating and processing multiple image tasks.

Returns
The Chaiscript engine object.
67 {
68  std::unique_ptr<chaiscript::ChaiScript> chai = std::make_unique<chaiscript::ChaiScript>();
69 
72 
73  chai->add(bindings::createImageBindings());
76 
77  addPrintRedirect(chai);
78 
79  return chai;
80 }
std::shared_ptr< chaiscript::Module > createImageTaskWindowBindings()
createImageTaskWindowBindings Creates the Chaiscript to C++ binding for the Geometrize image task win...
Definition: bindingscreator.cpp:181
std::shared_ptr< chaiscript::Module > createImageBindings()
createImageBindings Creates the Chaiscript to C++ bindings for image manipulation.
Definition: bindingscreator.cpp:206
std::shared_ptr< chaiscript::Module > createGeometrizeLibraryBindings()
createGeometrizeLibraryBindings Creates the Chaiscript to C++ bindings for all of the functionality i...
Definition: bindingscreator.cpp:318
std::shared_ptr< chaiscript::Module > createImageTaskBindings()
createImageTaskBindings Creates the Chaiscript to C++ bindings for Geometrize image tasks...
Definition: bindingscreator.cpp:238
std::shared_ptr< chaiscript::Module > createDefaultBindings()
createDefaultBindings Creates the default Chaiscript to C++ bindings.
Definition: bindingscreator.cpp:82

Here is the call graph for this function:

Here is the caller graph for this function:

std::unique_ptr< chaiscript::ChaiScript > geometrize::script::createDefaultEngine ( )

createDefaultEngine Creates a default Chaiscript engine object, with the default bindings (Geometrize-specific utility functions etc).

Returns
The Chaiscript engine object.
27 {
28  std::unique_ptr<chaiscript::ChaiScript> chai = std::make_unique<chaiscript::ChaiScript>();
29 
31 
32  addPrintRedirect(chai);
33 
34  return chai;
35 }
std::shared_ptr< chaiscript::Module > createDefaultBindings()
createDefaultBindings Creates the default Chaiscript to C++ bindings.
Definition: bindingscreator.cpp:82

Here is the call graph for this function:

Here is the caller graph for this function:

std::unique_ptr< chaiscript::ChaiScript > geometrize::script::createFunctionalTestRunnerEngine ( )

createFunctionalTestRunnerEngine Creates a Chaiscript engine object for running functional tests.

Returns
The Chaiscript engine object.
95 {
96  std::unique_ptr<chaiscript::ChaiScript> chai = std::make_unique<chaiscript::ChaiScript>();
97 
102 
103  return chai;
104 }
std::shared_ptr< chaiscript::Module > createImageTaskBindings()
createImageTaskBindings Creates the Chaiscript to C++ bindings for Geometrize image tasks...
Definition: bindingscreator.cpp:238
std::shared_ptr< chaiscript::Module > createDefaultBindings()
createDefaultBindings Creates the default Chaiscript to C++ bindings.
Definition: bindingscreator.cpp:82
std::shared_ptr< chaiscript::Module > createUserInterfacePuppeteerBindings()
createUserInterfacePuppeteerBindings Creates ChaiScript to C++ bindings for driving the user interfac...
Definition: bindingscreator.cpp:539
std::shared_ptr< chaiscript::Module > createLaunchWindowBindings()
createLaunchWindowBindings Creates the Chaiscript to C++ bindings for the Geometrize launch window...
Definition: bindingscreator.cpp:158

Here is the call graph for this function:

Here is the caller graph for this function:

std::unique_ptr< chaiscript::ChaiScript > geometrize::script::createImageTaskEngine ( )

createImageTaskEngine Creates a Chaiscript engine for an image task window.

Returns
The Chaiscript engine object.
50 {
51  std::unique_ptr<chaiscript::ChaiScript> chai = std::make_unique<chaiscript::ChaiScript>();
52 
55 
56  chai->add(bindings::createImageBindings());
60 
61  addPrintRedirect(chai);
62 
63  return chai;
64 }
std::shared_ptr< chaiscript::Module > createImageExportBindings()
createImageExportBindings Creates the Chaiscript to C++ bindings for saving images.
Definition: bindingscreator.cpp:294
std::shared_ptr< chaiscript::Module > createImageBindings()
createImageBindings Creates the Chaiscript to C++ bindings for image manipulation.
Definition: bindingscreator.cpp:206
std::shared_ptr< chaiscript::Module > createGeometrizeLibraryBindings()
createGeometrizeLibraryBindings Creates the Chaiscript to C++ bindings for all of the functionality i...
Definition: bindingscreator.cpp:318
std::shared_ptr< chaiscript::Module > createImageTaskBindings()
createImageTaskBindings Creates the Chaiscript to C++ bindings for Geometrize image tasks...
Definition: bindingscreator.cpp:238
std::shared_ptr< chaiscript::Module > createAnimatedGifExportBindings()
createGifExportBindings Creates the ChaiScript to C++ bindings for saving animated GIFs...
Definition: bindingscreator.cpp:307
std::shared_ptr< chaiscript::Module > createDefaultBindings()
createDefaultBindings Creates the default Chaiscript to C++ bindings.
Definition: bindingscreator.cpp:82

Here is the call graph for this function:

std::unique_ptr< chaiscript::ChaiScript > geometrize::script::createLaunchWindowEngine ( )

createLaunchWindowEngine Creates a Chaiscript engine object for the launch window.

Returns
The Chaiscript engine object.
38 {
39  std::unique_ptr<chaiscript::ChaiScript> chai = std::make_unique<chaiscript::ChaiScript>();
40 
43 
44  addPrintRedirect(chai);
45 
46  return chai;
47 }
std::shared_ptr< chaiscript::Module > createDefaultBindings()
createDefaultBindings Creates the default Chaiscript to C++ bindings.
Definition: bindingscreator.cpp:82
std::shared_ptr< chaiscript::Module > createLaunchWindowBindings()
createLaunchWindowBindings Creates the Chaiscript to C++ bindings for the Geometrize launch window...
Definition: bindingscreator.cpp:158

Here is the call graph for this function:

Here is the caller graph for this function:

std::unique_ptr< chaiscript::ChaiScript > geometrize::script::createShapeMutatorEngine ( )

createShapeMutatorEngine Creates a Chaiscript engine object for mutating shapes.

Returns
The Chaiscript engine object.
83 {
84  std::unique_ptr<chaiscript::ChaiScript> chai = std::make_unique<chaiscript::ChaiScript>();
85 
88  chai->add(bindings::createMathBindings());
90 
91  return chai;
92 }
std::shared_ptr< chaiscript::Module > createGeometrizeLibraryBindings()
createGeometrizeLibraryBindings Creates the Chaiscript to C++ bindings for all of the functionality i...
Definition: bindingscreator.cpp:318
std::shared_ptr< chaiscript::Module > createDefaultBindings()
createDefaultBindings Creates the default Chaiscript to C++ bindings.
Definition: bindingscreator.cpp:82
std::shared_ptr< chaiscript::Module > createTabletEventBindings()
createTabletEventBindings Creates the Chaiscript to C++ bindings for tablet events (e...
Definition: bindingscreator.cpp:490
std::shared_ptr< chaiscript::Module > createMathBindings()
createMathBindings Creates the Chaiscript to C++ bindings for common math functions.
Definition: bindingscreator.cpp:534

Here is the call graph for this function:

Here is the caller graph for this function:

std::map< std::string, std::string > geometrize::script::getAfterAddShapeCallbackScripts ( )

getAfterAddShapeCallbackScripts Gets a map of scripts that are useful to call after adding a shape to the image task views.

Returns
A map of Chaiscript script function names to function bodies.
94 {
95  return getScriptsFromFolder(":/scripts/scripts/after_add_shape_callbacks/");
96 }

Here is the caller graph for this function:

std::map< std::string, std::string > geometrize::script::getAfterStepCallbackScripts ( )

getAfterStepCallbackScripts Gets a map of scripts that are useful to call after stepping an image task (i.e. after completing work to find a shape to add).

Returns
A map of Chaiscript script function names to function bodies.
79 {
80  return getScriptsFromFolder(":/scripts/scripts/after_step_callbacks/");
81 }

Here is the caller graph for this function:

std::map< std::string, std::string > geometrize::script::getBeforeAddShapeCallbackScripts ( )

getBeforeAddShapeCallbackScripts Gets a map of scripts that are useful to call before adding a shape to the image task views.

Returns
A map of Chaiscript script function names to function bodies.
89 {
90  return getScriptsFromFolder(":/scripts/scripts/before_add_shape_callbacks/");
91 }

Here is the caller graph for this function:

std::map< std::string, std::string > geometrize::script::getBeforeStepCallbackScripts ( )

getBeforeStepCallbackScripts Gets a map of scripts that are useful to call prior to stepping an image task (i.e. before starting work to find a shape to add).

Returns
A map of Chaiscript script function names to function bodies.
74 {
75  return getScriptsFromFolder(":/scripts/scripts/before_step_callbacks/");
76 }

Here is the caller graph for this function:

std::map< std::string, std::string > geometrize::script::getDefaultShapeMutatorScripts ( )

getDefaultScripts Gets a map of the default scripts used for shape creation and mutation in image tasks.

Returns
A map of Chaiscript script function names to function bodies.
64 {
65  return getScriptsFromFolder(":/scripts/scripts/default_shape_mutators/");
66 }

Here is the caller graph for this function:

std::vector< std::string > geometrize::script::getEngineFunctionNames ( const chaiscript::ChaiScript &  engine)

getEngineFunctionNames Gets the names of the functions registered with the given engine.

Parameters
engineThe engine whose function names will be fetched.
Returns
The names registered with the given engine.
49 {
50  std::vector<std::string> functions;
51  const auto funcs{engine.get_state().engine_state.m_functions};
52  for(auto it = funcs.begin(); it != funcs.end(); ++it) {
53  functions.push_back(it->first);
54  }
55  return functions;
56 }

Here is the caller graph for this function:

std::map< std::string, std::string > geometrize::script::getOnKeyDownEventScripts ( )

getOnKeyDownEventScripts Gets a map of scripts that are useful to call after receiving a key down event to the image task views.

Returns
A map of Chaiscript script function names to function bodies.
114 {
115  return getScriptsFromFolder(":/scripts/scripts/on_key_down_callbacks/");
116 }

Here is the caller graph for this function:

std::map< std::string, std::string > geometrize::script::getOnKeyUpEventScripts ( )

getOnKeyUpEventScripts Gets a map of scripts that are useful to call after receiving a key up event to the image task views.

Returns
A map of Chaiscript script function names to function bodies.
119 {
120  return getScriptsFromFolder(":/scripts/scripts/on_key_up_callbacks/");
121 }

Here is the caller graph for this function:

std::map< std::string, std::string > geometrize::script::getOnMouseDownEventScripts ( )

getOnMouseDownEventScripts Gets a map of scripts that are useful to call after receiving a mouse down event to the image task views.

Returns
A map of Chaiscript script function names to function bodies.
124 {
125  return getScriptsFromFolder(":/scripts/scripts/on_mouse_down_callbacks/");
126 }

Here is the caller graph for this function:

std::map< std::string, std::string > geometrize::script::getOnMouseMoveEventScripts ( )

getOnMouseMoveEventScripts Gets a map of scripts that are useful to call after receiving a mouse move event to the image task views.

Returns
A map of Chaiscript script function names to function bodies.
134 {
135  return getScriptsFromFolder(":/scripts/scripts/on_mouse_move_callbacks/");
136 }

Here is the caller graph for this function:

std::map< std::string, std::string > geometrize::script::getOnMouseUpEventScripts ( )

getOnMouseUpEventScripts Gets a map of scripts that are useful to call after receiving a mouse up event to the image task views.

Returns
A map of Chaiscript script function names to function bodies.
129 {
130  return getScriptsFromFolder(":/scripts/scripts/on_mouse_up_callbacks/");
131 }

Here is the caller graph for this function:

std::map< std::string, std::string > geometrize::script::getOnMouseWheelEventScripts ( )

getOnMouseWheelEventScripts Gets a map of scripts that are useful to call after receiving a mouse wheel event to the image task views.

Returns
A map of Chaiscript script function names to function bodies.
139 {
140  return getScriptsFromFolder(":/scripts/scripts/on_mouse_wheel_callbacks/");
141 }

Here is the caller graph for this function:

std::map< std::string, std::string > geometrize::script::getOnPenInputCallbackScripts ( )

getOnPenInputCallbackScripts Gets a map of scripts that are useful to call after receiving pen input to the image task views.

Returns
A map of Chaiscript script function names to function bodies.
99 {
100  return getScriptsFromFolder(":/scripts/scripts/on_pen_input_callbacks/");
101 }

Here is the caller graph for this function:

std::map< std::string, std::string > geometrize::script::getOnPenProximityEnterCallbackScripts ( )

getOnPenProximityEnterCallbackScripts Gets a map of scripts that are useful to call after receiving a pen proximity enter event. This is application global, not bound to a particular view.

Returns
A map of Chaiscript script function names to function bodies.
104 {
105  return getScriptsFromFolder(":/scripts/scripts/on_pen_proximity_enter_callbacks/");
106 }

Here is the caller graph for this function:

std::map< std::string, std::string > geometrize::script::getOnPenProximityExitCallbackScripts ( )

getOnPenProximityExitCallbackScripts Gets a map of scripts that are useful to call after receiving a pen proximity exit event. This is application global, not bound to a particular view.

Returns
A map of Chaiscript script function names to function bodies.
109 {
110  return getScriptsFromFolder(":/scripts/scripts/on_pen_proximity_exit_callbacks/");
111 }

Here is the caller graph for this function:

std::map< std::string, std::string > geometrize::script::getOnTimedUpdateEventScripts ( )

getOnTimedUpdateEventScripts Gets a map of scripts that are useful to regularly periodically call i.e. on update

Returns
A map of Chaiscript script function names to function bodies.
144 {
145  return getScriptsFromFolder(":/scripts/scripts/on_update_callbacks/");
146 }

Here is the caller graph for this function:

std::map< std::string, std::string > geometrize::script::getPointerAreaOfInterestShapeMutatorScripts ( )

getPointerAreaOfInterestScripts Gets a map of the scripts used for shape creation and mutation based around user input/pointer interaction.

Returns
A map of Chaiscript script function names to function bodies.
69 {
70  return getScriptsFromFolder(":/scripts/scripts/pointer_area_of_interest_mutators/");
71 }

Here is the caller graph for this function:

std::map< std::string, std::string > geometrize::script::getScripts ( const std::string &  folder)

getDefaultScripts Gets a map of the scripts in the given folder. Path to the folder containing the ChaiScript scripts to retrieve. The files must have the ".chai" file extension.

Returns
A map of Chaiscript script function names to function bodies.
59 {
60  return getScriptsFromFolder(QString::fromStdString(folder));
61 }

Here is the caller graph for this function:

std::map< std::string, std::string > geometrize::script::getStopConditionScripts ( )

getStopConditionScripts Gets a map of scripts that get to true/false, and can be used to check whether to stop an image task (usually after stepping).

Returns
A map of Chaiscript script function names to function bodies.
84 {
85  return getScriptsFromFolder(":/scripts/scripts/stop_condition_callbacks/");
86 }

Here is the caller graph for this function:

void geometrize::script::runScript ( const std::string &  code,
chaiscript::ChaiScript &  runner 
)

runScript Evaluates the provided script code.

Parameters
codeThe script code to evaluate.
runnerThe engine that will evaluate the script.
17 {
18  const QString errorTitle{QCoreApplication::translate("Script evaluation error dialog title", "Script evaluation failure", "Title of an error message dialog shown when the app fails to run a script")};
19  const QString errorPreamble{QCoreApplication::translate("Script evaluation error message", "Could not evaluate script: %1", "Error message text shown when the app fails to run a script")};
20  const QString unknownError{QCoreApplication::translate("Script evaluation unknown error", "Unknown script evaluation error", "Error message shown when the app fails to run a script, and has no additional information about the error")};
21 
22  try {
23  runner.eval(code);
24  } catch (const std::string& s) {
25  QMessageBox::warning(nullptr, errorTitle, errorPreamble.arg(QString::fromStdString(s)));
26  } catch (const std::exception& e) {
27  QMessageBox::warning(nullptr, errorTitle, errorPreamble.arg(QString::fromStdString(e.what())));
28  } catch (...) {
29  QMessageBox::warning(nullptr, errorTitle, errorPreamble.arg(unknownError));
30  }
31 }

Here is the caller graph for this function:

void geometrize::script::runScript ( const std::string &  code)

runScript Evaluates the provided script code, creating a fresh engine to evaluate the script.

Parameters
codeThe script code to evaluate.
34 {
35  auto engine{createDefaultEngine()};
36  runScript(script, *engine);
37 }
std::unique_ptr< chaiscript::ChaiScript > createDefaultEngine()
createDefaultEngine Creates a default Chaiscript engine object, with the default bindings (Geometrize...
Definition: chaiscriptcreator.cpp:26
void runScript(const std::string &script)
runScript Evaluates the provided script code, creating a fresh engine to evaluate the script...
Definition: scriptrunner.cpp:33

Here is the call graph for this function:

void geometrize::script::sleep ( std::size_t  ms)

sleep Causes the calling thread to sleep for the given length of time.

Parameters
msThe number of milliseconds to sleep for.
44 {
45  std::this_thread::sleep_for(std::chrono::milliseconds(ms));
46 }

Here is the caller graph for this function: