... | ... | @@ -79,23 +79,38 @@ public: |
|
|
IPlugin() = default;
|
|
|
virtual ~IPlugin() = default;
|
|
|
|
|
|
virtual bool initialize(IPluginEnvironment &env) = 0;
|
|
|
// Initializes all resources (e.g., hardware handles, file assets, ports, etc) the plugin will use.
|
|
|
virtual bool initialize(
|
|
|
// `env` encapsulates the environment variables on which IceSL operates.
|
|
|
// The class `IPluginEnvironment` is subject to change as the environment of IceSL changes.
|
|
|
IPluginEnvironment &env
|
|
|
) = 0;
|
|
|
|
|
|
// Disposes of the resources used by the plugin.
|
|
|
virtual void dispose() = 0;
|
|
|
|
|
|
virtual bool addPluginSettings(EnumerableSettingsInterface& enumerable_settings) = 0;
|
|
|
// Adds printing settings specific to the plugin to IceSL's settings panel.
|
|
|
virtual bool addPluginSettings(
|
|
|
// 'enumarable_settings' controls the printing setttings of IceSL.
|
|
|
// The `EnumerableSettingsInterface` class is the interface through which the user
|
|
|
// can query existing parameters or add new parameteres specific to the plugin.
|
|
|
// It is explained in detail on the next section.
|
|
|
EnumerableSettingsInterface& enumerable_settings
|
|
|
) = 0;
|
|
|
|
|
|
virtual void gui(bool postService) = 0;
|
|
|
// Executes UI commands specific to the plugin.
|
|
|
virtual void gui(
|
|
|
// 'postService' is `true` whenever IceSL is done slicing the geometry and `false` otherwise.
|
|
|
bool postService
|
|
|
) = 0;
|
|
|
|
|
|
// These functions provide basic details of the plugin and are used by IceSL for UI purposes.
|
|
|
virtual std::string name() const = 0;
|
|
|
virtual std::string author() const = 0;
|
|
|
virtual std::string comment() const = 0;
|
|
|
};
|
|
|
```
|
|
|
|
|
|
- ```bool initialize(IPluginEnvironment &env)```
|
|
|
|
|
|
Initializes all resources (e.g., hardware handles, file assets, ports, etc) the plugin will use. The parameter `env` encapsulates the environment variables on which IceSL operates. The class `IPluginEnvironment` is subject to change as the environment of IceSL changes.
|
|
|
|
|
|
```c++
|
|
|
class IPluginEnvironment
|
|
|
{
|
... | ... | @@ -103,29 +118,14 @@ public: |
|
|
IPluginEnvironment() = default;
|
|
|
virtual ~IPluginEnvironment() = default;
|
|
|
|
|
|
// Set or gets the context of the UI library `ImGui` which is used by IceSL to
|
|
|
// manage interface elements.
|
|
|
void setImGuiContext(ImGuiContext* ctx);
|
|
|
ImGuiContext* getImGuiContext() const;
|
|
|
};
|
|
|
```
|
|
|
Functions `setImGuiContext(ImGuiContext* ctx)` and `getImGuiContext()` set and get the context of the UI library `ImGui` which is used by IceSL to manage interface elements.
|
|
|
|
|
|
- ```void dispose()```
|
|
|
|
|
|
Disposes of the resources used by the plugin.
|
|
|
|
|
|
- ```bool addPluginSettings(EnumerableSettingsInterface& enumerable_settings)```
|
|
|
|
|
|
Adds printing settings specific to the plugin to IceSL's settings panel. The `EnumerableSettingsInterface` class is explained in detail on the next section.
|
|
|
|
|
|
- ```gui(bool postService)```
|
|
|
|
|
|
Executes UI commands specific to the plugin. Parameter `postService` is `true` whenever IceSL is done slicing the geometry and `false` otherwise.
|
|
|
|
|
|
- ```std::string name()```, ```std::string author()``` and ```std::string comment()```
|
|
|
|
|
|
These functions provide basic details of the plugin and are used by IceSL for UI purposes.
|
|
|
|
|
|
### Settings Interface <a name="interface"></a>
|
|
|
### Settings Interface <a name="settings></a>
|
|
|
|
|
|
The interface of `EnumerableSettingsInterface` is the following:
|
|
|
|
... | ... | @@ -134,6 +134,7 @@ class EnumerableSettingsInterface |
|
|
{
|
|
|
public:
|
|
|
|
|
|
// Data type of setting
|
|
|
enum e_Type {
|
|
|
e_Empty, // No type
|
|
|
e_Float, // Decimal number
|
... | ... | @@ -146,6 +147,8 @@ public: |
|
|
e_Button, // UI Button
|
|
|
e_OverhangPointList // List of 3D points to support
|
|
|
};
|
|
|
|
|
|
// Data unit of setting
|
|
|
enum e_Units {
|
|
|
e_NoUnit, // No unit
|
|
|
e_MM, // Millimeter
|
... | ... | @@ -154,6 +157,8 @@ public: |
|
|
e_Percent, // Percentage (0-100)
|
|
|
e_Zoning, // Field where values below 0.5 are false and otherwise true
|
|
|
e_Angle }; // Angle (in degrees)
|
|
|
|
|
|
// Flags of setting
|
|
|
enum e_Flags {
|
|
|
e_NoFlag, // No flags
|
|
|
e_CanBePerLayer, // Can have a per-layer value
|
... | ... | @@ -162,32 +167,61 @@ public: |
|
|
e_HasParameters // Function triggered by setting has parameters
|
|
|
};
|
|
|
|
|
|
...
|
|
|
|
|
|
```
|
|
|
|
|
|
A printing parameter in IceSL is represented by the nested class `SettingInterface`, its interface is fairly straightforward.
|
|
|
|
|
|
```c++
|
|
|
class SettingInterface
|
|
|
{
|
|
|
public:
|
|
|
|
|
|
// Queries whether the setting is constant (i.e., 'isConstantSetting') throughout the geometry
|
|
|
// to be printed, or has a different value per printed layer (i.e., 'isPerLayerSetting')
|
|
|
// or as a specific value based on 3D position (i.e., 'isFieldSetting')
|
|
|
bool isConstantSetting() const;
|
|
|
virtual bool isPerLayerSetting() const = 0;
|
|
|
virtual bool isFieldSetting() const = 0;
|
|
|
|
|
|
// Gets the setting's value into parameter `value`. The behavior is undefined if the setting's
|
|
|
// type does not match the type of `value`.
|
|
|
virtual void getValue(bool& value) const = 0;
|
|
|
virtual void getValue(int& value) const = 0;
|
|
|
virtual void getValue(float& value) const = 0;
|
|
|
virtual void getValue(std::string& value) const = 0;
|
|
|
|
|
|
// Sets the setting's value to parameter `value`. The behavior is undefined if the setting's
|
|
|
// type does not match the type of `value`.
|
|
|
virtual void setValue(bool value) = 0;
|
|
|
virtual void setValue(int value) = 0;
|
|
|
virtual void setValue(float value) = 0;
|
|
|
virtual void setValue(std::string value) = 0;
|
|
|
|
|
|
// Gets the type, units and flags of the setting.
|
|
|
virtual e_Type getType() const = 0;
|
|
|
virtual e_Units getUnits() const = 0;
|
|
|
virtual e_Flags getFlags() const = 0;
|
|
|
|
|
|
virtual double valueAtHeight(double h) const = 0;
|
|
|
virtual double valueAtPosition(v3f pos) const = 0;
|
|
|
// Gets setting value at a certain height if `isPerLayerSetting()` returns `true`. Requires the
|
|
|
// setting to be of type `e_Float`.
|
|
|
virtual double valueAtHeight(
|
|
|
double h // height to query in millimeters w.r.t. bed level
|
|
|
) const = 0;
|
|
|
|
|
|
// Gets setting value at a certain position if `isFieldSetting()` return `true`. Requires the
|
|
|
// setting to be of type `e_Float`.
|
|
|
virtual double valueAtPosition(
|
|
|
v3f pos // 3D position in millimeters w.r.t. field's lower-left-forward corner
|
|
|
) const = 0;
|
|
|
};
|
|
|
|
|
|
...
|
|
|
|
|
|
```
|
|
|
|
|
|
```c++
|
|
|
virtual std::unique_ptr<SettingInterface> getSettingByName(const std::string& internalName) const = 0;
|
|
|
|
|
|
template<typename T> std::unique_ptr<SettingInterface> addSettingFromPlugin(
|
... | ... | @@ -221,27 +255,26 @@ public: |
|
|
virtual int getNumberOfExtruders() const;
|
|
|
```
|
|
|
|
|
|
A printing parameter in IceSL is represented by the nested class `SettingInterface`, its interface is fairly straightforward.
|
|
|
|
|
|
|
|
|
- ```bool isConstantSetting()```, ```bool isPerLayerSetting()``` and ```bool isFieldSetting()```
|
|
|
|
|
|
Queries whether the setting is constant throughout the geometry to be printer, or has a different value per resulting printed layer or as a specific value based on 3D position.
|
|
|
.
|
|
|
|
|
|
- ```getValue(bool& value)```, ```getValue(int& value)```, ```getValue(float& value)``` and ```getValue(std::string& value)```
|
|
|
|
|
|
Gets the setting's value into parameter `value`. The behavior is undefined if the setting's type does not match the type of `value`.
|
|
|
|
|
|
|
|
|
- ```setValue(bool value)```, ```setValue(int value)```, ```setValue(float value)``` and ```setValue(std::string value)```
|
|
|
|
|
|
Sets the setting's value to parameter `value`. The behavior is undefined if the setting's type does not match the type of `value`.
|
|
|
|
|
|
|
|
|
- ```e_Type getType()```, ```e_Units getUnits()``` and ```e_Flags getFlags()```
|
|
|
|
|
|
Gets the type, units and flags of the setting. All these descriptions are explained in the enumeration definition above.
|
|
|
|
|
|
|
|
|
- ```double valueAtHeight(double h)``` and ```double valueAtPosition(v3f pos)```
|
|
|
|
|
|
Gets the value at certain height `h` if `isPerLayerSetting()` returns `true` or at position `pos` if `isFieldSetting()` return `true`. Both require the setting to be of type `e_Float`
|
|
|
|
|
|
To either get or add a printing setting from IceSL, we have the following functions:
|
|
|
|
... | ... | @@ -253,6 +286,19 @@ Gets a setting through its internal name `internalName`. For a complete list of |
|
|
|
|
|
Adds a setting specific to the plugin with internal name `internalName`, display name (i.e., UI) `displayName`, setting group (e.g., slicing, supports, brush N, etc) `group`, description text `description`, order w.r.t. other settings (i.e., 0 = first) `rank`, active status (through a lambda function called by IceSL) `active_if`, units `units` and flags `flags`. `value` is the default value, `value_min` and `value_max` are the setting's min and max values respectively and al three should match the type of the setting.
|
|
|
|
|
|
- ```std::unique_ptr<SettingInterface> addSelectionFromPlugin(int* value, const std::string& internalName, const std::vector<std::string>& selections, const std::string& displayName, const std::string& group, const std::string& description, int rank, void(*selection_callback)(void*) = nullptr, void* userdata = nullptr, std::function<bool()> active_if = std::function<bool()>(), e_Units units = e_NoUnit, e_Flags flags = e_NoFlag);```
|
|
|
```
|
|
|
std::unique_ptr<SettingInterface> addSelectionFromPlugin(
|
|
|
int* value,
|
|
|
const std::string& internalName,
|
|
|
const std::vector<std::string>& selections,
|
|
|
const std::string& displayName,
|
|
|
const std::string& group,
|
|
|
const std::string& description,
|
|
|
int rank,
|
|
|
void(*selection_callback)(void*) = nullptr,
|
|
|
void* userdata = nullptr,
|
|
|
std::function<bool()> active_if = std::function<bool()>(),
|
|
|
e_Units units = e_NoUnit, e_Flags flags = e_NoFlag);
|
|
|
```
|
|
|
|
|
|
Same as `addSettingFromPlugin` but `value` refers to an element of `selections` by index and `selection_callback` is a C-style function callback whenever the setting is changed with structure `userdata` as parameter to this callback. |
|
|
\ No newline at end of file |