mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Fix code-style
This commit is contained in:
parent
e983a9a9e7
commit
762a1b1bfd
13 changed files with 47 additions and 33 deletions
|
@ -97,8 +97,9 @@ class Arrange:
|
||||||
|
|
||||||
# Ensure that the object is above the build platform
|
# Ensure that the object is above the build platform
|
||||||
node.removeDecorator(ZOffsetDecorator.ZOffsetDecorator)
|
node.removeDecorator(ZOffsetDecorator.ZOffsetDecorator)
|
||||||
if node.getBoundingBox():
|
bbox = node.getBoundingBox()
|
||||||
center_y = node.getWorldPosition().y - node.getBoundingBox().bottom
|
if bbox:
|
||||||
|
center_y = node.getWorldPosition().y - bbox.bottom
|
||||||
else:
|
else:
|
||||||
center_y = 0
|
center_y = 0
|
||||||
|
|
||||||
|
|
|
@ -49,9 +49,10 @@ class CuraActions(QObject):
|
||||||
def homeCamera(self) -> None:
|
def homeCamera(self) -> None:
|
||||||
scene = cura.CuraApplication.CuraApplication.getInstance().getController().getScene()
|
scene = cura.CuraApplication.CuraApplication.getInstance().getController().getScene()
|
||||||
camera = scene.getActiveCamera()
|
camera = scene.getActiveCamera()
|
||||||
camera.setPosition(Vector(-80, 250, 700))
|
if camera:
|
||||||
camera.setPerspective(True)
|
camera.setPosition(Vector(-80, 250, 700))
|
||||||
camera.lookAt(Vector(0, 0, 0))
|
camera.setPerspective(True)
|
||||||
|
camera.lookAt(Vector(0, 0, 0))
|
||||||
|
|
||||||
## Center all objects in the selection
|
## Center all objects in the selection
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
|
|
|
@ -84,6 +84,7 @@ from cura.Settings.SettingInheritanceManager import SettingInheritanceManager
|
||||||
from cura.Settings.SimpleModeSettingsManager import SimpleModeSettingsManager
|
from cura.Settings.SimpleModeSettingsManager import SimpleModeSettingsManager
|
||||||
|
|
||||||
from cura.Machines.VariantManager import VariantManager
|
from cura.Machines.VariantManager import VariantManager
|
||||||
|
from plugins.SliceInfoPlugin.SliceInfo import SliceInfo
|
||||||
|
|
||||||
from .SingleInstance import SingleInstance
|
from .SingleInstance import SingleInstance
|
||||||
from .AutoSave import AutoSave
|
from .AutoSave import AutoSave
|
||||||
|
@ -1722,11 +1723,13 @@ class CuraApplication(QtApplication):
|
||||||
if not Selection.hasSelection():
|
if not Selection.hasSelection():
|
||||||
node = self.getController().getScene().findObject(cast(SelectionPass, self.getRenderer().getRenderPass("selection")).getIdAtPosition(x, y))
|
node = self.getController().getScene().findObject(cast(SelectionPass, self.getRenderer().getRenderPass("selection")).getIdAtPosition(x, y))
|
||||||
if node:
|
if node:
|
||||||
while(node.getParent() and node.getParent().callDecoration("isGroup")):
|
parent = node.getParent()
|
||||||
node = node.getParent()
|
while(parent and parent.callDecoration("isGroup")):
|
||||||
|
node = parent
|
||||||
|
parent = node.getParent()
|
||||||
|
|
||||||
Selection.add(node)
|
Selection.add(node)
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def showMoreInformationDialogForAnonymousDataCollection(self):
|
def showMoreInformationDialogForAnonymousDataCollection(self):
|
||||||
self._plugin_registry.getPluginObject("SliceInfoPlugin").showMoreInfoDialog()
|
cast(SliceInfo, self._plugin_registry.getPluginObject("SliceInfoPlugin")).showMoreInfoDialog()
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
from collections import defaultdict, OrderedDict
|
from collections import defaultdict, OrderedDict
|
||||||
import copy
|
import copy
|
||||||
import uuid
|
import uuid
|
||||||
from typing import Dict
|
from typing import Dict, cast
|
||||||
from typing import Optional, TYPE_CHECKING
|
from typing import Optional, TYPE_CHECKING
|
||||||
|
|
||||||
from PyQt5.Qt import QTimer, QObject, pyqtSignal, pyqtSlot
|
from PyQt5.Qt import QTimer, QObject, pyqtSignal, pyqtSlot
|
||||||
|
@ -416,13 +416,14 @@ class MaterialManager(QObject):
|
||||||
|
|
||||||
## Get default material for given global stack, extruder position and extruder variant name
|
## Get default material for given global stack, extruder position and extruder variant name
|
||||||
# you can provide the extruder_definition and then the position is ignored (useful when building up global stack in CuraStackBuilder)
|
# you can provide the extruder_definition and then the position is ignored (useful when building up global stack in CuraStackBuilder)
|
||||||
def getDefaultMaterial(self, global_stack: "GlobalStack", position: str, extruder_variant_name: Optional[str], extruder_definition: Optional["ExtruderStack"] = None) -> Optional["MaterialNode"]:
|
def getDefaultMaterial(self, global_stack: "GlobalStack", position: str, extruder_variant_name: Optional[str], extruder_definition: Optional["DefinitionContainer"] = None) -> Optional["MaterialNode"]:
|
||||||
node = None
|
node = None
|
||||||
machine_definition = global_stack.definition
|
machine_definition = global_stack.definition
|
||||||
if extruder_definition is None:
|
if extruder_definition is None:
|
||||||
extruder_definition = global_stack.extruders[position].definition
|
extruder_definition = global_stack.extruders[position].definition
|
||||||
if parseBool(global_stack.getMetaDataEntry("has_materials", False)):
|
if parseBool(global_stack.getMetaDataEntry("has_materials", False)):
|
||||||
material_diameter = extruder_definition.getProperty("material_diameter", "value")
|
# At this point the extruder_definition is not None
|
||||||
|
material_diameter = cast(DefinitionContainer, extruder_definition).getProperty("material_diameter", "value")
|
||||||
if isinstance(material_diameter, SettingFunction):
|
if isinstance(material_diameter, SettingFunction):
|
||||||
material_diameter = material_diameter(global_stack)
|
material_diameter = material_diameter(global_stack)
|
||||||
approximate_material_diameter = str(round(material_diameter))
|
approximate_material_diameter = str(round(material_diameter))
|
||||||
|
|
|
@ -104,6 +104,6 @@ class QualityProfilesDropDownMenuModel(ListModel):
|
||||||
else:
|
else:
|
||||||
# Look for layer_height in the GlobalStack from material -> definition
|
# Look for layer_height in the GlobalStack from material -> definition
|
||||||
container = global_stack.definition
|
container = global_stack.definition
|
||||||
if container.hasProperty("layer_height", "value"):
|
if container and container.hasProperty("layer_height", "value"):
|
||||||
layer_height = container.getProperty("layer_height", "value")
|
layer_height = container.getProperty("layer_height", "value")
|
||||||
return float(layer_height)
|
return float(layer_height)
|
||||||
|
|
|
@ -61,7 +61,7 @@ class PrinterOutputDevice(QObject, OutputDevice):
|
||||||
uniqueConfigurationsChanged = pyqtSignal()
|
uniqueConfigurationsChanged = pyqtSignal()
|
||||||
|
|
||||||
def __init__(self, device_id: str, parent: QObject = None) -> None:
|
def __init__(self, device_id: str, parent: QObject = None) -> None:
|
||||||
super().__init__(device_id = device_id, parent = parent)
|
super().__init__(device_id = device_id, parent = parent) # type: ignore # MyPy complains with the multiple inheritance
|
||||||
|
|
||||||
self._printers = [] # type: List[PrinterOutputModel]
|
self._printers = [] # type: List[PrinterOutputModel]
|
||||||
self._unique_configurations = [] # type: List[ConfigurationModel]
|
self._unique_configurations = [] # type: List[ConfigurationModel]
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
import os
|
import os
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
import uuid
|
import uuid
|
||||||
|
from typing import Any
|
||||||
from typing import Dict, Union
|
from typing import Dict, Union
|
||||||
|
|
||||||
from PyQt5.QtCore import QObject, QUrl, QVariant
|
from PyQt5.QtCore import QObject, QUrl, QVariant
|
||||||
|
@ -43,7 +44,7 @@ class ContainerManager(QObject):
|
||||||
self._machine_manager = self._application.getMachineManager()
|
self._machine_manager = self._application.getMachineManager()
|
||||||
self._material_manager = self._application.getMaterialManager()
|
self._material_manager = self._application.getMaterialManager()
|
||||||
self._quality_manager = self._application.getQualityManager()
|
self._quality_manager = self._application.getQualityManager()
|
||||||
self._container_name_filters = {}
|
self._container_name_filters = {} # type: Dict[str, Dict[str, Any]]
|
||||||
|
|
||||||
@pyqtSlot(str, str, result=str)
|
@pyqtSlot(str, str, result=str)
|
||||||
def getContainerMetaDataEntry(self, container_id, entry_name):
|
def getContainerMetaDataEntry(self, container_id, entry_name):
|
||||||
|
|
|
@ -244,8 +244,9 @@ class CuraContainerStack(ContainerStack):
|
||||||
#
|
#
|
||||||
# \throws InvalidContainerStackError Raised when no definition can be found for the stack.
|
# \throws InvalidContainerStackError Raised when no definition can be found for the stack.
|
||||||
@override(ContainerStack)
|
@override(ContainerStack)
|
||||||
def deserialize(self, contents: str, file_name: Optional[str] = None) -> None:
|
def deserialize(self, serialized: str, file_name: Optional[str] = None) -> str:
|
||||||
super().deserialize(contents, file_name)
|
# update the serialized data first
|
||||||
|
serialized = super().deserialize(serialized, file_name)
|
||||||
|
|
||||||
new_containers = self._containers.copy()
|
new_containers = self._containers.copy()
|
||||||
while len(new_containers) < len(_ContainerIndexes.IndexTypeMap):
|
while len(new_containers) < len(_ContainerIndexes.IndexTypeMap):
|
||||||
|
@ -253,10 +254,11 @@ class CuraContainerStack(ContainerStack):
|
||||||
|
|
||||||
# Validate and ensure the list of containers matches with what we expect
|
# Validate and ensure the list of containers matches with what we expect
|
||||||
for index, type_name in _ContainerIndexes.IndexTypeMap.items():
|
for index, type_name in _ContainerIndexes.IndexTypeMap.items():
|
||||||
|
container = None
|
||||||
try:
|
try:
|
||||||
container = new_containers[index]
|
container = new_containers[index]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
container = None
|
pass
|
||||||
|
|
||||||
if type_name == "definition":
|
if type_name == "definition":
|
||||||
if not container or not isinstance(container, DefinitionContainer):
|
if not container or not isinstance(container, DefinitionContainer):
|
||||||
|
@ -283,6 +285,9 @@ class CuraContainerStack(ContainerStack):
|
||||||
from cura.Settings.CuraStackBuilder import CuraStackBuilder
|
from cura.Settings.CuraStackBuilder import CuraStackBuilder
|
||||||
CuraStackBuilder.createDefinitionChangesContainer(self, self.getId() + "_settings")
|
CuraStackBuilder.createDefinitionChangesContainer(self, self.getId() + "_settings")
|
||||||
|
|
||||||
|
## TODO; Deserialize the containers.
|
||||||
|
return serialized
|
||||||
|
|
||||||
## protected:
|
## protected:
|
||||||
|
|
||||||
# Helper to make sure we emit a PyQt signal on container changes.
|
# Helper to make sure we emit a PyQt signal on container changes.
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
import time
|
import time
|
||||||
from typing import Any, Callable, List, Dict, TYPE_CHECKING, Optional
|
from typing import Any, Callable, List, Dict, TYPE_CHECKING, Optional, cast
|
||||||
|
|
||||||
from UM.ConfigurationErrorMessage import ConfigurationErrorMessage
|
from UM.ConfigurationErrorMessage import ConfigurationErrorMessage
|
||||||
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
|
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
|
||||||
|
@ -1137,7 +1137,7 @@ class MachineManager(QObject):
|
||||||
quality_changes_container = self._empty_quality_changes_container
|
quality_changes_container = self._empty_quality_changes_container
|
||||||
quality_container = self._empty_quality_container
|
quality_container = self._empty_quality_container
|
||||||
if quality_changes_group.node_for_global and quality_changes_group.node_for_global.getContainer():
|
if quality_changes_group.node_for_global and quality_changes_group.node_for_global.getContainer():
|
||||||
quality_changes_container = quality_changes_group.node_for_global.getContainer()
|
quality_changes_container = cast(InstanceContainer, quality_changes_group.node_for_global.getContainer())
|
||||||
if quality_group is not None and quality_group.node_for_global and quality_group.node_for_global.getContainer():
|
if quality_group is not None and quality_group.node_for_global and quality_group.node_for_global.getContainer():
|
||||||
quality_container = quality_group.node_for_global.getContainer()
|
quality_container = quality_group.node_for_global.getContainer()
|
||||||
|
|
||||||
|
@ -1153,7 +1153,7 @@ class MachineManager(QObject):
|
||||||
quality_changes_container = self._empty_quality_changes_container
|
quality_changes_container = self._empty_quality_changes_container
|
||||||
quality_container = self._empty_quality_container
|
quality_container = self._empty_quality_container
|
||||||
if quality_changes_node and quality_changes_node.getContainer():
|
if quality_changes_node and quality_changes_node.getContainer():
|
||||||
quality_changes_container = quality_changes_node.getContainer()
|
quality_changes_container = cast(InstanceContainer, quality_changes_node.getContainer())
|
||||||
if quality_node and quality_node.getContainer():
|
if quality_node and quality_node.getContainer():
|
||||||
quality_container = quality_node.getContainer()
|
quality_container = quality_node.getContainer()
|
||||||
|
|
||||||
|
@ -1279,7 +1279,7 @@ class MachineManager(QObject):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# The current material is not available, find the preferred one
|
# The current material is not available, find the preferred one
|
||||||
material_node = self._material_manager.getDefaultMaterial(self._global_container_stack, position, current_variant_name)
|
material_node = self._material_manager.getDefaultMaterial(self._global_container_stack, position_item, current_variant_name)
|
||||||
if material_node is not None:
|
if material_node is not None:
|
||||||
self._setMaterial(position_item, material_node)
|
self._setMaterial(position_item, material_node)
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,8 @@ class PerObjectContainerStack(CuraContainerStack):
|
||||||
context.pushContainer(self)
|
context.pushContainer(self)
|
||||||
|
|
||||||
global_stack = Application.getInstance().getGlobalContainerStack()
|
global_stack = Application.getInstance().getGlobalContainerStack()
|
||||||
|
if not global_stack:
|
||||||
|
return None
|
||||||
|
|
||||||
# Return the user defined value if present, otherwise, evaluate the value according to the default routine.
|
# Return the user defined value if present, otherwise, evaluate the value according to the default routine.
|
||||||
if self.getContainer(0).hasProperty(key, property_name):
|
if self.getContainer(0).hasProperty(key, property_name):
|
||||||
|
|
|
@ -171,7 +171,8 @@ class SettingInheritanceManager(QObject):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
## Also check if the top container is not a setting function (this happens if the inheritance is restored).
|
## Also check if the top container is not a setting function (this happens if the inheritance is restored).
|
||||||
if isinstance(stack.getTop().getProperty(key, "value"), SettingFunction):
|
user_container = stack.getTop()
|
||||||
|
if user_container and isinstance(user_container.getProperty(key, "value"), SettingFunction):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
## Mash all containers for all the stacks together.
|
## Mash all containers for all the stacks together.
|
||||||
|
|
|
@ -4,8 +4,7 @@
|
||||||
from configparser import ConfigParser
|
from configparser import ConfigParser
|
||||||
import zipfile
|
import zipfile
|
||||||
import os
|
import os
|
||||||
from typing import Dict, List, Tuple
|
from typing import Dict, List, Tuple, cast
|
||||||
|
|
||||||
|
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
|
|
||||||
|
@ -98,13 +97,13 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
||||||
self._3mf_mesh_reader = None
|
self._3mf_mesh_reader = None
|
||||||
self._container_registry = ContainerRegistry.getInstance()
|
self._container_registry = ContainerRegistry.getInstance()
|
||||||
|
|
||||||
# suffixes registered with the MineTypes don't start with a dot '.'
|
# suffixes registered with the MimeTypes don't start with a dot '.'
|
||||||
self._definition_container_suffix = "." + ContainerRegistry.getMimeTypeForContainer(DefinitionContainer).preferredSuffix
|
self._definition_container_suffix = "." + cast(MimeType, ContainerRegistry.getMimeTypeForContainer(DefinitionContainer)).preferredSuffix
|
||||||
self._material_container_suffix = None # We have to wait until all other plugins are loaded before we can set it
|
self._material_container_suffix = None # We have to wait until all other plugins are loaded before we can set it
|
||||||
self._instance_container_suffix = "." + ContainerRegistry.getMimeTypeForContainer(InstanceContainer).preferredSuffix
|
self._instance_container_suffix = "." + cast(MimeType, ContainerRegistry.getMimeTypeForContainer(InstanceContainer)).preferredSuffix
|
||||||
self._container_stack_suffix = "." + ContainerRegistry.getMimeTypeForContainer(ContainerStack).preferredSuffix
|
self._container_stack_suffix = "." + cast(MimeType, ContainerRegistry.getMimeTypeForContainer(ContainerStack)).preferredSuffix
|
||||||
self._extruder_stack_suffix = "." + ContainerRegistry.getMimeTypeForContainer(ExtruderStack).preferredSuffix
|
self._extruder_stack_suffix = "." + cast(MimeType, ContainerRegistry.getMimeTypeForContainer(ExtruderStack)).preferredSuffix
|
||||||
self._global_stack_suffix = "." + ContainerRegistry.getMimeTypeForContainer(GlobalStack).preferredSuffix
|
self._global_stack_suffix = "." + cast(MimeType, ContainerRegistry.getMimeTypeForContainer(GlobalStack)).preferredSuffix
|
||||||
|
|
||||||
# Certain instance container types are ignored because we make the assumption that only we make those types
|
# Certain instance container types are ignored because we make the assumption that only we make those types
|
||||||
# of containers. They are:
|
# of containers. They are:
|
||||||
|
|
|
@ -34,13 +34,13 @@ def main():
|
||||||
os.putenv("MYPYPATH", ":".join(mypyPathParts))
|
os.putenv("MYPYPATH", ":".join(mypyPathParts))
|
||||||
|
|
||||||
# Mypy really needs to be run via its Python script otherwise it can't find its data files.
|
# Mypy really needs to be run via its Python script otherwise it can't find its data files.
|
||||||
mypyExe = where("mypy.bat" if sys.platform == "win32" else "mypy")
|
mypyExe = where("mypy.exe" if sys.platform == "win32" else "mypy")
|
||||||
mypyModule = os.path.join(os.path.dirname(mypyExe), "mypy")
|
mypyModule = os.path.join(os.path.dirname(mypyExe), "mypy.exe")
|
||||||
|
|
||||||
plugins = findModules("plugins")
|
plugins = findModules("plugins")
|
||||||
plugins.sort()
|
plugins.sort()
|
||||||
|
|
||||||
mods = ["cura"] + plugins + findModules("plugins/VersionUpgrade")
|
mods = plugins + findModules("plugins/VersionUpgrade")
|
||||||
|
|
||||||
for mod in mods:
|
for mod in mods:
|
||||||
print("------------- Checking module {mod}".format(**locals()))
|
print("------------- Checking module {mod}".format(**locals()))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue