Skip to content

Commit ebc3a73

Browse files
committed
edited macro
1 parent 02bb652 commit ebc3a73

1 file changed

Lines changed: 17 additions & 14 deletions

File tree

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

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "Example 2: Macro modules and Module Interaction"
3-
date: 19-05-2025
3+
date: 2025-05-19
44
draft: false
55
weight: 370
66
status: "OK"
@@ -18,12 +18,13 @@ menu:
1818
## Macro Module
1919
A macro module can be used to develop your own functionality in MeVisLab. You have two main options for how to use it:
2020

21-
* **With Internal Networks**: Use a macro module to reuse a network of modules. For example, if you build a network that applies a specific image filter and you want to use this setup in multiple projects, you can wrap the entire network into a single macro module. This way, you don’t need to manually reconnect all the individual modules each time — you just use your macro module.You can see in the left side of the image is the Internal network. You can see an example in [Basic Mechanics of MeVisLab (Example: Building a Contour Filter)](/tutorials/basicmechanisms#TutorialMacroModules).
21+
* **With Internal Networks**: Use a macro module to reuse a network of modules. For example, if you build a network that applies a specific image filter and you want to use this setup in multiple projects, you can wrap the entire network into a single macro module. This way, you don’t need to manually reconnect all the individual modules each time — you just use your macro module. You can see the internal network at the left side of the image below. You can see an example in [Basic Mechanics of MeVisLab (Example: Building a Contour Filter)](/tutorials/basicmechanisms#TutorialMacroModules).
2222

2323
* **Without Internal Networks**: Use a macro module to add your own Python code. If MeVisLab is missing a specific functionality, you can write your own Python script and include it in a macro module.
24-
This allows you to extend the software with custom behavior that integrates smoothly into your project. You can see the right side of the image the python code.
24+
This allows you to extend the software with custom behavior that integrates smoothly into your project. You can see the Python code at the right side of the image.
2525

26-
The figure below is a Macro Module with Internal Processing and Python Interaction:
26+
27+
You can combine both approaches: have a macro module containing a module network, and additionally Python code to add your own logic or functionality:
2728

2829
![Internal Processing and Python Interaction](/images/tutorials/basicmechanics/with.png "Internal Processing and Python Interaction")
2930

@@ -40,7 +41,7 @@ It takes an existing network of modules or Python code. To the user, interacting
4041
* **Implementation:**
4142
Macro modules are primarily defined using the MeVisLab Definition Language (MDL) and often incorporate Python scripting for more dynamic behavior. You don't need to write C++ code to create a macro module.
4243
* **User Interface:**
43-
You can define your own User Interface for macro modules.
44+
You can define your own User Interface for macro modules using MDL.
4445
* **Scope:**
4546
Macro modules can be either global (available in all your MeVisLab projects) or local (specific to the current network you are working on).
4647

@@ -59,24 +60,24 @@ A Local Macro in MeVisLab is a macro module that exists only within the context
5960
* A global macro is listed in the Modules panel and module search.
6061

6162
{{<alert class="info" caption="Info">}}
62-
Packages are the way MeVisLab organizes different development projects. You can organize zour own modules, test cases or C++ modules in a package.
63+
Packages are the way MeVisLab organizes different development projects. You can organize your own modules, test cases or C++ modules in a package.
6364
{{</alert>}}
6465

6566
### Inputs, Outputs, and Fields:
66-
You can addd inputs and outputs to your macro module to connect it with the other modules:
67+
You can add inputs and outputs to your macro module to connect it with the other modules:
6768
* **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.
6869
* **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.
6970

70-
You can also 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.
71-
* **Fields:** These are parameters that control the module's behavior, typically visible in the modules 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-
The below figure shows the input , outoutand feilds :
71+
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.
73+
The below figure shows the input, output and fields:
7374
![Inputs, Outputs, and Fields](/images/tutorials/basicmechanics/fields.png "Inputs, Outputs, and Fields")
7475

7576
### Files Associated with a Macro Module:
7677
Macro modules typically contain the following files:
77-
* **Definition file (*\*.def*):** The module definition file contains the definition and information about the module like name, author, package, etc. **Defintion files are only available for global macro modules**.
78+
* **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**.
7879

79-
* **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 for multiple situations.
80+
* **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.
8081

8182
* **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.
8283
* **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.
@@ -107,12 +108,14 @@ For an example see [Example 2.5.2: Module interactions via Python scripting](/tu
107108

108109
* Files
109110
* (*\*.script*): Defines inputs, outputs, fields, and user interface.
110-
* (*\*.py*): Optional, contains Python code.
111+
* (*\*.py*): Contains Python code.
111112
* (*\*.def*): Definition file (only for global macros).
113+
* (*\*.mlab*): Stores the internal network of modules within the macro module.
114+
* (*\*.mhelp*): Provides documentation or user assistance for the module.
112115

113116
* Components
114117
* Inputs/Outputs: For connecting the module with other modules.
115118
* Fields: Parameters for user control
116119
* Field Listeners: Run Python code when a field value changes
117120

118-
* Package: are the way MeVisLab organizes different development projects. Required for global macros.
121+
* Packages: are the way MeVisLab organizes different development projects. Required for global macros.

0 commit comments

Comments
 (0)