Rename to CuraFormulaFunctions

to avoid confusion with "SettingFunction" in Uranium.
This commit is contained in:
Lipu Fei 2018-10-01 11:24:31 +02:00
parent 329b38663e
commit f69005fef9
4 changed files with 15 additions and 15 deletions

View file

@ -107,7 +107,7 @@ from cura.Settings.MaterialSettingsVisibilityHandler import MaterialSettingsVisi
from cura.Settings.ContainerManager import ContainerManager from cura.Settings.ContainerManager import ContainerManager
from cura.Settings.SidebarCustomMenuItemsModel import SidebarCustomMenuItemsModel from cura.Settings.SidebarCustomMenuItemsModel import SidebarCustomMenuItemsModel
import cura.Settings.cura_empty_instance_containers import cura.Settings.cura_empty_instance_containers
from cura.Settings.CustomSettingFunctions import CustomSettingFunctions from cura.Settings.CuraFormulaFunctions import CuraFormulaFunctions
from cura.ObjectsModel import ObjectsModel from cura.ObjectsModel import ObjectsModel
@ -175,7 +175,7 @@ class CuraApplication(QtApplication):
self._single_instance = None self._single_instance = None
self._custom_setting_functions = None self._cura_formula_functions = None
self._cura_package_manager = None self._cura_package_manager = None
@ -320,7 +320,7 @@ class CuraApplication(QtApplication):
# Adds custom property types, settings types, and extra operators (functions) that need to be registered in # Adds custom property types, settings types, and extra operators (functions) that need to be registered in
# SettingDefinition and SettingFunction. # SettingDefinition and SettingFunction.
def __initializeSettingDefinitionsAndFunctions(self): def __initializeSettingDefinitionsAndFunctions(self):
self._custom_setting_functions = CustomSettingFunctions(self) self._cura_formula_functions = CuraFormulaFunctions(self)
# Need to do this before ContainerRegistry tries to load the machines # Need to do this before ContainerRegistry tries to load the machines
SettingDefinition.addSupportedProperty("settable_per_mesh", DefinitionPropertyType.Any, default = True, read_only = True) SettingDefinition.addSupportedProperty("settable_per_mesh", DefinitionPropertyType.Any, default = True, read_only = True)
@ -342,10 +342,10 @@ class CuraApplication(QtApplication):
SettingDefinition.addSettingType("optional_extruder", None, str, None) SettingDefinition.addSettingType("optional_extruder", None, str, None)
SettingDefinition.addSettingType("[int]", None, str, None) SettingDefinition.addSettingType("[int]", None, str, None)
SettingFunction.registerOperator("extruderValue", self._custom_setting_functions.getValueInExtruder) SettingFunction.registerOperator("extruderValue", self._cura_formula_functions.getValueInExtruder)
SettingFunction.registerOperator("extruderValues", self._custom_setting_functions.getValuesInAllExtruders) SettingFunction.registerOperator("extruderValues", self._cura_formula_functions.getValuesInAllExtruders)
SettingFunction.registerOperator("resolveOrValue", self._custom_setting_functions.getResolveOrValue) SettingFunction.registerOperator("resolveOrValue", self._cura_formula_functions.getResolveOrValue)
SettingFunction.registerOperator("defaultExtruderPosition", self._custom_setting_functions.getDefaultExtruderPosition) SettingFunction.registerOperator("defaultExtruderPosition", self._cura_formula_functions.getDefaultExtruderPosition)
# Adds all resources and container related resources. # Adds all resources and container related resources.
def __addAllResourcesAndContainerResources(self) -> None: def __addAllResourcesAndContainerResources(self) -> None:
@ -809,8 +809,8 @@ class CuraApplication(QtApplication):
def getSettingVisibilityPresetsModel(self, *args) -> SettingVisibilityPresetsModel: def getSettingVisibilityPresetsModel(self, *args) -> SettingVisibilityPresetsModel:
return self._setting_visibility_presets_model return self._setting_visibility_presets_model
def getCustomSettingFunctions(self, *args) -> CustomSettingFunctions: def getCuraFormulaFunctions(self, *args) -> "CuraFormulaFunctions":
return self._custom_setting_functions return self._cura_formula_functions
def getMachineErrorChecker(self, *args) -> MachineErrorChecker: def getMachineErrorChecker(self, *args) -> MachineErrorChecker:
return self._machine_error_checker return self._machine_error_checker

View file

@ -12,10 +12,10 @@ if TYPE_CHECKING:
# #
# This class contains all Cura-related custom setting functions. Some functions requires information such as the # This class contains all Cura-related custom functions that can be used in formulas. Some functions requires
# currently active machine, so this is made into a class instead of standalone functions. # information such as the currently active machine, so this is made into a class instead of standalone functions.
# #
class CustomSettingFunctions: class CuraFormulaFunctions:
def __init__(self, application: "CuraApplication") -> None: def __init__(self, application: "CuraApplication") -> None:
self._application = application self._application = application

View file

@ -373,7 +373,7 @@ class ExtruderManager(QObject):
# \return String representing the extruder values # \return String representing the extruder values
@pyqtSlot(str, result="QVariant") @pyqtSlot(str, result="QVariant")
def getInstanceExtruderValues(self, key: str) -> List: def getInstanceExtruderValues(self, key: str) -> List:
return self._application.getCustomSettingFunctions().getValuesInAllExtruders(key) return self._application.getCuraFormulaFunctions().getValuesInAllExtruders(key)
## Get the resolve value or value for a given key ## Get the resolve value or value for a given key
# #

View file

@ -42,7 +42,7 @@ class UserChangesModel(ListModel):
def _update(self): def _update(self):
application = Application.getInstance() application = Application.getInstance()
machine_manager = application.getMachineManager() machine_manager = application.getMachineManager()
custom_setting_functions = application.getCustomSettingFunctions() cura_formula_functions = application.getCuraFormulaFunctions()
item_dict = OrderedDict() item_dict = OrderedDict()
item_list = [] item_list = []
@ -77,7 +77,7 @@ class UserChangesModel(ListModel):
# Override "getExtruderValue" with "getDefaultExtruderValue" so we can get the default values # Override "getExtruderValue" with "getDefaultExtruderValue" so we can get the default values
user_changes = containers.pop(0) user_changes = containers.pop(0)
default_value_resolve_context = custom_setting_functions.createContextForDefaultValueEvaluation(stack) default_value_resolve_context = cura_formula_functions.createContextForDefaultValueEvaluation(stack)
for setting_key in user_changes.getAllKeys(): for setting_key in user_changes.getAllKeys():
original_value = None original_value = None