Skip to content

Commit 4c574a3

Browse files
committed
Marco Module edited
1 parent 9e688a5 commit 4c574a3

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

mevislab.github.io/content/tutorials/basicmechanisms/macromodules.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,29 +65,35 @@ Packages are the way MeVisLab organizes different development projects. You can
6565

6666
### Inputs, Outputs, and Fields:
6767
You can add inputs and outputs to your macro module to connect it with the other modules:
68-
* **Inputs:** These are connection points through which the module receives data from other modules. You define inputs in the *\*.script* file using the Input keyword. You can also define the type for each input.
69-
* **Outputs:** These are connection points through which the module sends processed data to other modules. You define outputs in the *\*.script* file using the Output keyword. You can also define the type for each output.
68+
* **Inputs:** These are connection points through which the module receives data from other modules. You define inputs in the *\*.script* file using the *Input* keyword. You can also define the type for each input.
69+
* **Outputs:** These are connection points through which the module sends processed data to other modules. You define outputs in the *\*.script* file using the *Output* keyword. You can also define the type for each output.
7070

7171
You can add fields to your macro module. Fields allow you to change parameters for your module or to see the values of results. Fields can also be added to the panel of the macro module so that the user can change them.
72-
* **Fields:** These are parameters that control the module's behavior, typically visible in the module's panel or in the Module Inspector. You define fields in the *\*.script* file using the Field keyword, specifying the data type, default value, and other properties.
72+
* **Fields:** These are parameters that control the module's behavior, typically visible in the module's panel or in the Module Inspector. You define fields in the *\*.script* file using the *Field* keyword, specifying the data type, default value, and other properties.
7373
The below figure shows the input, output and fields:
74-
![Inputs, Outputs, and Fields](/images/tutorials/basicmechanics/fields.png "Inputs, Outputs, and Fields")
74+
You have two options when adding fields to your macro module:
75+
76+
1. **Define your own fields:**
77+
You can create new fields by specifying their name, type, and default value in the *\*.script* file. This allows you to provide custom parameters for your macro module, tailored to your specific needs.
78+
79+
2. **Reuse fields from the internal network:**
80+
Instead of defining a new field, you can expose an existing field from one of the modules inside your macro module's internal network. To do this, you reference the `internalName` of the internal field you want to reuse. This makes the internal field accessible at the macro module level, allowing users to interact with it directly without duplicating parameters.
7581

7682
### Files Associated with a Macro Module:
7783
Macro modules typically contain the following files:
7884
* **Definition file (*\*.def*):** The module definition file contains the definition and information about the module like name, author, package, etc. **Definition files are only available for global macro modules**.
7985

8086
* **Script file (*\*.script*):** The script file defines inputs, outputs, fields and the user interface of the macro module. In case you want to add Python code, it includes the reference to the Python script file. The *\*.script* file allows you to define Python functions to be called on field changes and user interactions.
8187

82-
* **Module Initialization**: You can add the *initCommand* to the *Commands* section and the given Python function is called whenever the module is added to the workspace or reloaded.
88+
* **Module initialization**: You can add the *initCommand* to the *Commands* section and the given Python function is called whenever the module is added to the workspace or reloaded.
8389
* **Window creation**: You can add the *initCommand* to the *Window* section and the given Python function is called whenever the panel of the module is opened.
8490
* **User interaction**: You can add commands to any user interface element like *Buttons* to call Python functions on user interactions with this element. The image below shows you the user interface and the internal interface:
8591
![user interface and the internal interface](/images/tutorials/basicmechanics/mycountourFilter.png "user interface and the internal interface")
8692

8793
* **Field changes**: You can also react on any changes of fields in your module and create Field Listeners. See below for details.
88-
* **Python file (*\*.py*):** *(Optional)*: The Python file contains the Python code that is used by the module. You can add Python functions to fields or UI elements to react on user interactions in the *\*.script* file.
89-
* **MeVisLab network file (*\*.mlab*):** Stores the internal network of modules that make up the macro module. This file essentially defines the macro module's internal structure and connections.
90-
* **Macro help file (*\*.help*):***(Optional)*:Provides help documentation for the macro module. This file is used to display information to users about the module’s functionality, usage, and any specific instructions.
94+
* **Python file (*\*.py*):** *(Optional)* The Python file contains the Python code that is used by the module. You can add Python functions to fields or UI elements to react on user interactions in the *\*.script* file.
95+
* **MeVisLab network file (*\*.mlab*):** *(Optional)* Stores the internal network of modules that make up the macro module. This file essentially defines the macro module's internal structure and connections.
96+
* **Macro help file (*\*.help*):** *(Optional)* Provides help documentation for the macro module. This file is used to display information to users about the module’s functionality, usage, and any specific instructions.
9197
### Field Listeners:
9298
Field listeners are mechanisms to execute Python code automatically when the value of a field changes. This allows you to create dynamic responses to user interactions in the module's parameter panel.
9399

@@ -96,7 +102,7 @@ You create field listeners within the *Commands* sections of the *\*.script* fil
96102
For an example see [Example 2.5.2: Module interactions via Python scripting](/tutorials/basicmechanisms/macromodules/scriptingexample2/).
97103

98104
## Summary
99-
* Macro Module: a custom block in MeVisLab used to group a network of modules or custom Python code into a single reusable unit.
105+
* Macro modules allow you to add your own functionality to MeVisLab. You can add inputs and outputs and connect existing modules to your new macro module.
100106

101107
* Benefits:
102108
* Organized structure.

0 commit comments

Comments
 (0)