[docs]classModule:""" Base class for CoperniFUS Modules """_DEFAULT_PARAMS={}""" Default configuration parameters used when a parameter value is not yet cached """def__init__(self,parent_viewer,module_id,**kwargs)->None:self.module_kwargs=kwargsself.parent_viewer=parent_viewerself._module_id=module_id@propertydefmodule_id(self):""" Holds the module identifier for reference in get_module_object_from_name """ifnotisinstance(self._module_id,str):raiseValueError('Please make sure that self.module_id is defined in the __init__ of the module. module_id should be a string without any dot characters.')elifisinstance(self._module_id,str)and'.'inself._module_id:raiseValueError('Please make sure that self.module_id does not contain any dot characters.')else:returnself._module_id@module_id.setterdefmodule_id(self,value):ifnotisinstance(value,str):raiseValueError('Please make sure that self.module_id is defined in the __init__ of the module. module_id should be a string without any dot characters.')elifisinstance(value,str)and'.'invalue:raiseValueError('Please make sure that self.module_id does not contain any dot characters.')else:self._module_id=value# --- cache wrapper for modules parameters ---
[docs]defget_user_param(self,param_name,default_value=None,additional_identifiers=[]):""" Cache wrapper for modules parameters Get parameters by their name using `param_name`. If the requested parameter is not found in the cache, default values provided in the static attribute `_DEFAULT_PARAMS` will be returned. """ifdefault_valueisNoneandparam_nameinself._DEFAULT_PARAMS:default_value=self._DEFAULT_PARAMS[param_name]param_value=self.parent_viewer.cache.get_attr([self.module_id,*additional_identifiers,param_name],default_value=default_value)returnparam_value
[docs]definit_dock(self):""" Sets up a dock GUI for the module """# Optionnal# # Resize to most comptact height# self.dock.adjustSize()# self.dock.setMinimumHeight(self.dock.sizeHint().height())# self.dock.setMaximumHeight(self.dock.sizeHint().height())pass
[docs]defadd_rendered_object(self):""" Called when adding module-specific elements to the 3D viewer """pass
[docs]defupdate_rendered_object(self):""" Called for the update of module-specific elements already present in the 3D viewer """pass
[docs]defdelete_rendered_object(self):""" Called for the removal of module-specific elements from the 3D viewer """pass