Skip to content

Commit

Permalink
Added New Python Filter Parameter Docs (#425)
Browse files Browse the repository at this point in the history
* Documentation for creating a python filter

* Documentation for filter parameters

* Update Filter_General_Instructions.md

* Update use_case_02.py

* Added ChoiceFP

* Fixed formatting.

* Added documentation for 2 data array FPs

* Added new FP docs
  • Loading branch information
mhitzem authored and imikejackson committed Feb 22, 2023
1 parent f6b8f88 commit b7748ea
Show file tree
Hide file tree
Showing 13 changed files with 264 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Source/SIMPLib/CoreFilters/RotateSampleRefFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
#include "SIMPLib/FilterParameters/FloatVec3FilterParameter.h"
#include "SIMPLib/Filtering/AbstractFilter.h"

#include <QtCore/QDateTime>

/**
* @brief The RotateSampleRefFrame class. See [Filter documentation](@ref rotatesamplerefframe) for details.
*/
Expand Down
51 changes: 51 additions & 0 deletions Wrapping/Python/Docs/BooleanFilterParameter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# LinkedBooleanFilterParameter

## Description

The **LinkedBooleanFilterParameter** gives the user a binary choice. If chosen, additional filter parameters are shown to the user.


## Python Code Parts

In init:
```(lang-python)
self.linked_bool: bool = False
```

Setter method:
```(lang-python)
def _set_linked_bool(self, value) -> None:
self.linked_bool = value
```
Getter method:
```(lang-python)
def _get_linked_bool(self) -> bool:
return self.linked_bool
```

In setup_parameters:
```(lang-python)
LinkedBooleanFilterParameter('Select for additional features', 'linked_bool', self.linked_bool, FilterParameter.Category.Parameter, self._set_linked_bool, self._get_linked_bool, ['param_1', 'param_2'], -1)
```

*'Select for additional features'* = label that shows up for user in DREAM3D

*linked_bool* = string value used to identify filter parameter in code

*self.linked_bool* = name of Boolean variable

*self._set_linked_bool* = setter method for Boolean variable

*self._get_linked_bool* = getter method for Boolean variable

*['param_1', 'param_2']* = list containing names of filter parameters to show when box is checked

## Example Code and GUI
```(lang-python)
LinkedBooleanFilterParameter('Add new numbers', 'linked_bool', self.linked_bool, FilterParameter.Category.Parameter, self._set_linked_bool, self._get_linked_bool, ['num_1', 'num_2'], -1)
```
*self.linked_bool = False*
![linked_bool_unchecked_gui](Images/linked_bool_unchecked_gui.png)

*self.linked_bool = True*
![linked_bool_checked_gui](Images/linked_bool_checked_gui.png)
Binary file added Wrapping/Python/Docs/Images/boolean_gui.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Wrapping/Python/Docs/Images/input_file_gui.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Wrapping/Python/Docs/Images/input_path_gui.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Wrapping/Python/Docs/Images/output_file_gui.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions Wrapping/Python/Docs/InputFileFilterParameter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# InputFileFilterParameter

## Description

The **InputFileFilterParameter** allows the user to choose a file for input.


## Python Code Parts

In init:
```(lang-python)
self.input_file_param: str = ""
```

Setter method:
```(lang-python)
def _set_input_file(self, value: str) -> None:
self.input_file_param = value
```
Getter method:
```(lang-python)
def _get_input_file(self) -> str:
return self.input_file_param
```

In setup_parameters:
```(lang-python)
InputFileFilterParameter('Input File', 'input_file_param', self.input_file_param, FilterParameter.Category.Parameter, self._set_input_file, self._get_input_file, '*.file_type', 'File type', -1)
```

*'Input File'* = label that shows up for user in DREAM3D

*‘input_file_param’* = string value used to identify filter parameter in code

*self.input_file_param* = name of String variable for file name

*self._set_input_file* = setter method for String variable

*self._get_input_file* = getter method for String variable

*'\*\.file_type'* = file extension

*'File type'* = description of input file type

## Example Code and GUI
```(lang-python)
InputFileFilterParameter('Input File', 'input_file_param', self.input_file_param, FilterParameter.Category.Parameter, self._set_input_file, self._get_input_file, '*.ang', 'EDAX Ang', -1)
```
![input_file_gui](Images/input_file_gui.png)
45 changes: 45 additions & 0 deletions Wrapping/Python/Docs/InputPathFilterParameter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# InputPathFilterParameter

## Description

The **InputPathFilterParameter** allows the user to choose an input folder.


## Python Code Parts

In init:
```(lang-python)
self.input_path_param: str = ""
```

Setter method:
```(lang-python)
def _set_input_path_param(self, value: str) -> None:
self.input_path_param = value
```
Getter method:
```(lang-python)
def _get_input_path_param(self) -> str:
return self.input_path_param
```

In setup_parameters:
```(lang-python)
InputPathFilterParameter('Input Directory', 'input_path_param', self.input_path_param, FilterParameter.Category.Parameter, self._set_input_path_param, self._get_input_path_param, -1)
```

*'Input Directory'* = label that shows up for user in DREAM3D

*‘input_path_param’* = string value used to identify filter parameter in code

*self.input_path_param* = name of String variable for input path name

*self._set_input_path_param* = setter method for String variable

*self._get_input_path_param* = getter method for String variable

## Example Code and GUI
```(lang-python)
InputPathFilterParameter('Input Directory', 'input_path_param', self.input_path_param, FilterParameter.Category.Parameter, self._set_input_path_param, self._get_input_path_param, -1)
```
![input_path_gui](Images/input_path_gui.png)
66 changes: 66 additions & 0 deletions Wrapping/Python/Docs/MultiDataArraySelectionFilterParameter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# MultiDataArraySelectionFilterParameter

## Description

The **MultiDataArraySelectionFilterParameter** allows the user to select DREAM3D data arrays from either the file explorer or from the pipeline.

## Requirement Type

```(lang-python)
MultiDataArraySelectionFilterParameter.RequirementType()
```
**Properties**

*amTypes* = type of AttributeMatrix required for array

*dcGeometryTypes* = type of Geometry required for array

*componentDimensions* = component dimensions required for the array

*daTypes* = data type(s) required for the array



## Python Code Parts

In init:
```(lang-python)
self.selected_data_array_paths: List[DataArrayPath] = []
```

Setter method:
```(lang-python)
def _set_selected_data_array_paths(self, value: List[DataArrayPath]) -> None:
self.selected_data_array_paths = value
```
Getter method:
```(lang-python)
def _get_selected_data_array_paths(self) -> List[DataArrayPath]:
return self.selected_data_array_paths
```

In setup_parameters:
```(lang-python)
req = MultiDataArraySelectionFilterParameter.RequirementType()
req.dcGeometryTypes = [IGeometry.Type.Image] #replace Image with type needed
req.amTypes = [AttributeMatrix.Type.Cell] #replace Cell with type needed
req.daTypes = ["float", "double", "int32_t"] #replace dtype names with dtypes needed
req.componentDimensions = [VectorSizeT([1])] #replace 1 with dimensions needed
MultiDataArraySelectionFilterParameter('Input Data Arrays', 'selected_data_array_paths', self.selected_data_array_paths, FilterParameter.Category.RequiredArray, self._set_selected_data_array_paths, self._get_selected_data_array_paths, req, -1)
```

*'Input Data Arrays’* = label that shows up for user in DREAM3D

*'selected_data_array_paths’* = string value used to identify filter parameter in code

*self.selected_data_array_paths* = list of DataArrayPath variables used to keep track of path for array

*self._set_selected_data_array_paths* = setter method for DataArrayPath list variable

*self._get_selected_data_array_paths* = getter method for DataArrayPath list variable

## Example Code and GUI
```(lang-python)
MultiDataArraySelectionFilterParameter('Input Data Arrays', 'selected_data_array_path', self.selected_data_array_path, FilterParameter.Category.RequiredArray, self._set_selected_data_array_path, self._get_selected_data_array_path, MultiDataArraySelectionFilterParameter.RequirementType(), -1)
```
![multi_data_array_selection_gui](Images/multi_data_array_selection_gui.png)
51 changes: 51 additions & 0 deletions Wrapping/Python/Docs/OutputFileFilterParameter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# OutputFileFilterParameter

## Description

The **OutputFileFilterParameter** allows the user to select an output file.

## Python Code Parts

In init:
```(lang-python)
self.output_file: str = ''
```

Setter method:
```(lang-python)
def _set_output_file(self, value: str) -> None:
self.output_file = value
```
Getter method:
```(lang-python)
def _get_output_file(self) -> str:
return self.output_file
```

In setup_parameters:
```(lang-python)
OutputFileFilterParameter('Output File', 'output_file', self.output_file, FilterParameter.Category.Parameter, self._set_output_file, self._get_output_file, '*.file_type', 'File Type', -1)
```

*‘Output File'* = label that shows up for user in DREAM3D

*'output_file'* = string value used to identify filter parameter in code

*self.output_file* = name of str variable used to keep track of user-inputted string

*self._set_output_file* = setter method for str variable

*self._get_output_file* = getter method for str variable

*'\*\.file_type'* = file extension

*'File type'* = description of output file type

## Example Code and GUI

```(lang-python)
OutputFileFilterParameter('Output File', 'output_file', self.output_file, FilterParameter.Category.Parameter, self._set_output_file, self._get_output_file, '*.ang', 'EDAX Ang', -1)
```


![output_file_gui](Images/output_file_gui.png)

0 comments on commit b7748ea

Please sign in to comment.