imfusion.gui#
Submodule for GUI-related types.
- class imfusion.gui.Annotation#
Bases:
pybind11_object- class AnnotationType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
Enum- BOX = 0#
- CIRCLE = 1#
- LINE = 2#
- POINT = 3#
- POLY_LINE = 4#
- RECTANGLE = 5#
- on_editing_finished(self: Annotation, callback: Callable) SignalConnection#
Register a callback which is called when the annotation has been fully defined by the user.
The callback must not require any arguments.
>>> a = imfusion.app.annotation_model.create_annotation(imfusion.gui.Annotation.LINE) >>> def callback(): ... print("All points are defined") >>> a.on_editing_finished(callback) >>> a.start_editing()
- on_points_changed(self: Annotation, callback: Callable) SignalConnection#
Register a callback which is called when any of the points have changed their position.
The callback must not require any arguments.
>>> a = imfusion.app.annotation_model.create_annotation(imfusion.gui.Annotation.LINE) >>> def callback(): ... print("Points changed") >>> a.on_points_changed(callback) >>> a.start_editing()
- start_editing(self: Annotation) None#
Start interactive placement of the annotation.
This can currently only be called once.
- BOX = 0#
- CIRCLE = 1#
- LINE = 2#
- POINT = 3#
- POLY_LINE = 4#
- RECTANGLE = 5#
- property color#
Color of the annotation as a normalized RGB tuple.
- Type:
Annotated[numpy.typing.NDArray[numpy.float64], ”[3, 1]”]
- property max_points#
The maximum amount of points this annotation supports.
A -1 indicates that this annotation supports any number of points.
- Type:
- property points#
The points which define the annotation in world coordinates.
It is possible to not immediately set all the points that the specific annotation requires: in this case the annotation is required to be manually completed using the mouse in the ImFusionSuite. It is not supported to partially set the points of multiple annotations at once: please complete the current partially-defined annotation before setting the points of another annotation.
Besides, it is not possible to set more points than the specific annotation requires.
- property type#
Return the type of this annotation.
Raises if the annotation is no longer valid or if the annotation is not supported in Python.
- Type:
- class imfusion.gui.AnnotationModel#
Bases:
pybind11_object- create_annotation(self: AnnotationModel, arg0: AnnotationType) Annotation#
- property annotations#
- Type:
- class imfusion.gui.ApplicationController#
Bases:
pybind11_objectA ApplicationController instance serves as the center of the ImFusionSDK.
It provides an OpenGL context, a
DataModel, executes algorithms and more. While multiple instances are possible, in general there is only one instance.- add_algorithm(self: ApplicationController, id: str, data: list = [], properties: Properties = None) object#
Add the algorithm with the given name to the application.
The algorithm will only be created if it is compatible with the given data. The optional Properties object will be used to configure the algorithm. Returns the created algorithm or
Noneif no compatible algorithm could be found.>>> app.add_algorithm("Create Synthetic Data", []) <imfusion.BaseAlgorithm object at ...>
- close_all(self: ApplicationController) None#
Delete all algorithms and datasets. Make sure to not reference any deleted objects after calling this!
- execute_algorithm(self: ApplicationController, id: str, data: list = [], properties: Properties = None) list#
Execute the algorithm with the given name and returns its output.
The algorithm will only be executed if it is compatible with the given data. The optional
Propertiesobject will be used to configure the algorithm before executing it. Any data created by the algorithm is added to theDataModelbefore being returned.
- load_workspace(self: ApplicationController, path: str, **kwargs) bool#
Loads a workspace file and returns True if the loading was successful. Placeholders can be specified as keyword arguments, for example: >>> app.load_workspace(“path/to/workspace.iws”, sweep=sweep, case=case)
- open(self: ApplicationController, path: str) list#
Tries to open the given filepath as data. If successful the data is added to
DataModeland returned. Otherwise raises a FileNotFoundError.
- remove_algorithm(self: ApplicationController, algorithm: Algorithm) None#
Remove and deletes the given algorithm from the application. Don’t reference the given algorithm afterwards!
- save_workspace(self: ApplicationController, path: str) bool#
Saves current workspace to a iws file
- select_data(self: ApplicationController, arg0: Data) None#
- select_data(self: ApplicationController, arg0: Sequence[Data]) None
Function overload documentation:
- select_data(self: ApplicationController, arg0: Data) None
- select_data(self: ApplicationController, arg0: Sequence[Data]) None
- update(self: ApplicationController) None#
- update_display(self: ApplicationController) None#
- property annotation_model#
- Type:
- class imfusion.gui.ConsoleController(self: ConsoleController, name: str = 'ImFusion Python SDK')#
Bases:
ApplicationControllerApplicationController without a UI interface.
This class is not available in the embedded Python interpreter in the ImFusionSuite.
- class imfusion.gui.DataModel#
Bases:
pybind11_objectThe DataModel instance holds all datasets of an ApplicationController.
- __getitem__(self: DataModel, index: SupportsInt | SupportsIndex) Data#
- __getitem__(self: DataModel, indices: Sequence[SupportsInt | SupportsIndex]) list[Data]
- __getitem__(self: DataModel, slice: slice) list[Data]
Function overload documentation:
- __getitem__(self: DataModel, index: SupportsInt | SupportsIndex) Data
- __getitem__(self: DataModel, indices: Sequence[SupportsInt | SupportsIndex]) list[Data]
- add(self: DataModel, data: Data, name: str = '') Data#
- add(self: DataModel, data_list: Sequence[Data]) list
Function overload documentation:
- create_group(self: DataModel, arg0: Sequence[Data]) DataGroup#
Groups a list of Data in the model. Only Data that is already part of the model can be grouped.
- get_common_parent(self: DataModel, data_list: Sequence[Data]) DataGroup#
Return the most common parent of all given Data
- get_parent(self: DataModel, data: Data) DataGroup#
Return the parent DataGroup of the given Data or None if it is not part of the model. For top-level data this function will return
get_root_node().
- index(self: DataModel, data: Data) int#
Return index of data. The index is depth-first for all groups.
- remove(self: DataModel, data: Data) None#
Remove and delete data from the model. Afterwards data must not be reference anymore!
- property root_node#
Return the parent DataGroup of the given Data or None if it does not have a parent
- Type:
- class imfusion.gui.LayoutMode(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
Enum- LAYOUT_CUSTOM = 100#
- LAYOUT_FOCUS_PLUS_ROWS = 2#
- LAYOUT_FOCUS_PLUS_STACK = 1#
- LAYOUT_ROWS = 0#
- LAYOUT_SIDE_BY_SIDE = 3#
- class imfusion.gui.SignalConnection#
Bases:
pybind11_object- disconnect(self: SignalConnection) bool#
- class imfusion.gui.View#
Bases:
pybind11_object
- class imfusion.gui.VisualizerHandle#
Bases:
pybind11_objectThe handle to a visualizer. It allows to close a specific visualizer when needed. Example:
>>> visualizer_handle = imfusion.show(data_list, title="MyData") >>> assert visualizer_handle.title() == "MyData" >>> ... >>> visualizer_handle.close()
- close(self: VisualizerHandle) None#
Close the visualizer associated to this handle.
Note for Jupyter notebook users: closing the visualizer programmatically (via this method or by leaving the
withblock when used as a context manager) does not save the screenshot into the Jupyter notebook. The inline screenshot is only produced when the visualizer window is closed manually.
- title(self: VisualizerHandle) str#
Get the title of the visualizer associated to this handle.
- imfusion.gui.list_viewers() list[VisualizerHandle]#
Return a list of visualization handles that were created with
show(). Please note that this method may return viewers that have been closed withoutVisualizerHandle.close()orclose_viewers().
- imfusion.gui.open_in_suite(data: Sequence[Data]) None#
Starts the ImFusion Suite with the input data list. The ImFusionSuite executable must be in your PATH.
- imfusion.gui.show(data: Data | Sequence[Data], *, title: str | None = None, block: bool | None = None) VisualizerHandle#
- imfusion.gui.show(path: PathLike | str | bytes, *, title: str | None = None, block: bool | None = None) VisualizerHandle
Function overload documentation:
- imfusion.gui.show(data: Data | Sequence[Data], *, title: str | None = None, block: bool | None = None) VisualizerHandle
Launch a visualizer displaying the input
Data(e.g. aSharedImageSet).- Parameters:
data – Input data to be displayed.
title – Optional window title.
block – Option to control whether to block or not the python interpreter while the visualizer is running. In case of None, the visualizer automatically becomes non-blocking when the Python interpreter is in interactive mode.
- Returns:
A
VisualizerHandlefor the opened visualizer.
- imfusion.gui.show(path: PathLike | str | bytes, *, title: str | None = None, block: bool | None = None) VisualizerHandle
Launch a visualizer displaying the content of the file at the requested path.
- Parameters:
path – Path to the file to be displayed. Please note that only .imf files are supported at this point.
title – Optional window title.
block – Option to control whether to block or not the python interpreter while the visualizer is running. In case of None, the visualizer automatically becomes non-blocking when the Python interpreter is in interactive mode.
- Returns:
A
VisualizerHandlefor the opened visualizer.