当前位置: 首页>>代码示例>>Python>>正文


Python InstanceContainer.InstanceContainer类代码示例

本文整理汇总了Python中UM.Settings.InstanceContainer.InstanceContainer的典型用法代码示例。如果您正苦于以下问题:Python InstanceContainer类的具体用法?Python InstanceContainer怎么用?Python InstanceContainer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了InstanceContainer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: definition_changes_container

def definition_changes_container() -> InstanceContainer:
    definition_changes_container = InstanceContainer(container_id = "Test Definition Changes")
    definition_changes_container.setMetaDataEntry("type", "definition_changes")
    # Add current setting version to the instance container
    from cura.CuraApplication import CuraApplication
    definition_changes_container.getMetaData()["setting_version"] = CuraApplication.SettingVersion
    return definition_changes_container
开发者ID:rwreynolds,项目名称:Cura,代码行数:7,代码来源:conftest.py

示例2: _findQualityChangesContainerInCuraFolder

    def _findQualityChangesContainerInCuraFolder(self, name):
        quality_changes_dir = Resources.getPath(CuraApplication.ResourceTypes.QualityInstanceContainer)

        instance_container = None

        for item in os.listdir(quality_changes_dir):
            file_path = os.path.join(quality_changes_dir, item)
            if not os.path.isfile(file_path):
                continue

            parser = configparser.ConfigParser()
            try:
                parser.read([file_path])
            except:
                # skip, it is not a valid stack file
                continue

            if not parser.has_option("general", "name"):
                continue

            if parser["general"]["name"] == name:
                # load the container
                container_id = os.path.basename(file_path).replace(".inst.cfg", "")

                instance_container = InstanceContainer(container_id)
                with open(file_path, "r") as f:
                    serialized = f.read()
                instance_container.deserialize(serialized, file_path)
                self.addContainer(instance_container)
                break

        return instance_container
开发者ID:olemis,项目名称:Cura,代码行数:32,代码来源:CuraContainerRegistry.py

示例3: findAllQualitiesForMachineMaterial

    def findAllQualitiesForMachineMaterial(self, machine_definition: "DefinitionContainerInterface", material_container: InstanceContainer) -> List[InstanceContainer]:
        criteria = {"type": "quality"}
        result = self._getFilteredContainersForStack(machine_definition, [material_container.getMetaData()], **criteria)
        if not result:
            basic_materials = self._getBasicMaterialMetadatas(material_container.getMetaData())
            if basic_materials:
                result = self._getFilteredContainersForStack(machine_definition, basic_materials, **criteria)

        return result
开发者ID:olemis,项目名称:Cura,代码行数:9,代码来源:QualityManager.py

示例4: _updateMetaData

    def _updateMetaData(self, container: InstanceContainer) -> None:
        index = self.find("id", container.id)

        if self._section_property:
            self.setProperty(index, "section", container.getMetaDataEntry(self._section_property, ""))

        self.setProperty(index, "metadata", container.getMetaData())
        self.setProperty(index, "name", container.getName())
        self.setProperty(index, "id", container.getId())
开发者ID:Ultimaker,项目名称:Uranium,代码行数:9,代码来源:InstanceContainersModel.py

示例5: readQualityProfileFromString

def readQualityProfileFromString(profile_string):
    # Create an empty profile - the id and name will be changed by the ContainerRegistry
    profile = InstanceContainer("")
    try:
        profile.deserialize(profile_string)
    except Exception as e:  # Not a valid g-code file.
        Logger.log("e", "Unable to serialise the profile: %s", str(e))
        return None
    return profile
开发者ID:Cycloneee,项目名称:Cura,代码行数:9,代码来源:GCodeProfileReader.py

示例6: _loadProfile

 def _loadProfile(self, serialized, profile_id):
     # Create an empty profile.
     profile = InstanceContainer(profile_id)
     profile.addMetaDataEntry("type", "quality_changes")
     try:
         profile.deserialize(serialized)
     except Exception as e:  # Parsing error. This is not a (valid) Cura profile then.
         Logger.log("e", "Error while trying to parse profile: %s", str(e))
         return None
     return profile
开发者ID:olemis,项目名称:Cura,代码行数:10,代码来源:CuraProfileReader.py

示例7: createGlobalStack

    def createGlobalStack(cls, new_stack_id: str, definition: DefinitionContainer, **kwargs) -> GlobalStack:
        stack = GlobalStack(new_stack_id)
        stack.setDefinition(definition)

        user_container = InstanceContainer(new_stack_id + "_user")
        user_container.addMetaDataEntry("type", "user")
        user_container.addMetaDataEntry("machine", new_stack_id)
        from cura.CuraApplication import CuraApplication
        user_container.addMetaDataEntry("setting_version", CuraApplication.SettingVersion)
        user_container.setDefinition(definition)

        stack.setUserChanges(user_container)

        # Important! The order here matters, because that allows the stack to
        # assume the material and variant have already been set.
        if "definition_changes" in kwargs:
            stack.setDefinitionChangesById(kwargs["definition_changes"])

        if "variant" in kwargs:
            stack.setVariantById(kwargs["variant"])

        if "material" in kwargs:
            stack.setMaterialById(kwargs["material"])

        if "quality" in kwargs:
            stack.setQualityById(kwargs["quality"])

        if "quality_changes" in kwargs:
            stack.setQualityChangesById(kwargs["quality_changes"])

        registry = ContainerRegistry.getInstance()
        registry.addContainer(stack)
        registry.addContainer(user_container)

        return stack
开发者ID:senttech,项目名称:Cura,代码行数:35,代码来源:CuraStackBuilder.py

示例8: _createDefinitionChangesContainer

    def _createDefinitionChangesContainer(self, global_container_stack, container_index = None):
        definition_changes_container = InstanceContainer(global_container_stack.getName() + "_settings")
        definition = global_container_stack.getBottom()
        definition_changes_container.setDefinition(definition)
        definition_changes_container.addMetaDataEntry("type", "definition_changes")

        self._container_registry.addContainer(definition_changes_container)
        # Insert definition_changes between the definition and the variant
        global_container_stack.insertContainer(-1, definition_changes_container)

        return definition_changes_container
开发者ID:daid,项目名称:Cura,代码行数:11,代码来源:MachineSettingsAction.py

示例9: test_findInstanceContainers

def test_findInstanceContainers(container_registry, data):
    for container in data["containers"]: # Fill the registry with mock containers.
        container = container.copy()
        container_id = container["id"]
        del container["id"]
        instance_container = InstanceContainer(container_id)
        for key, value in container.items(): # Copy data into metadata.
            instance_container.getMetaData()[key] = value
        container_registry.addContainer(instance_container)

    results = container_registry.findInstanceContainers(**data["filter"]) # The actual function call we're testing.

    _verifyMetaDataMatches(results, data["result"])
开发者ID:senttech,项目名称:Uranium,代码行数:13,代码来源:TestContainerRegistry.py

示例10: _loadProfile

 def _loadProfile(self, serialized, profile_id):
     # Create an empty profile.
     profile = InstanceContainer(profile_id)
     profile.setMetaDataEntry("type", "quality_changes")
     try:
         profile.deserialize(serialized)
     except ContainerFormatError as e:
         Logger.log("e", "Error in the format of a container: %s", str(e))
         return None
     except Exception as e:
         Logger.log("e", "Error while trying to parse profile: %s", str(e))
         return None
     return profile
开发者ID:TinkerGnome,项目名称:Cura,代码行数:13,代码来源:CuraProfileReader.py

示例11: _createFlattenedContainerInstance

    def _createFlattenedContainerInstance(self, instance_container1, instance_container2):
        flat_container = InstanceContainer(instance_container2.getName())
        flat_container.setDefinition(instance_container2.getDefinition())
        flat_container.setMetaData(instance_container2.getMetaData())

        for key in instance_container2.getAllKeys():
            flat_container.setProperty(key, "value", instance_container2.getProperty(key, "value"))

        for key in instance_container1.getAllKeys():
            flat_container.setProperty(key, "value", instance_container1.getProperty(key, "value"))
        return flat_container
开发者ID:Johan3DV,项目名称:Cura,代码行数:11,代码来源:GCodeWriter.py

示例12: _onContainerChanged

    def _onContainerChanged(self, container: InstanceContainer) -> None:
        container_type = container.getMetaDataEntry("type")
        if container_type not in ("quality", "quality_changes"):
            return

        # update the cache table
        self._update_timer.start()
开发者ID:Ultimaker,项目名称:Cura,代码行数:7,代码来源:QualityManager.py

示例13: initialize

    def initialize(self) -> None:
        setting_data = self.getSettingData()
        self._stack = ContainerStack(stack_id=str(id(self)))
        self._stack.setDirty(False)  # This stack does not need to be saved.

        ## Check if the definition of this script already exists. If not, add it to the registry.
        if "key" in setting_data:
            definitions = ContainerRegistry.getInstance().findDefinitionContainers(id=setting_data["key"])
            if definitions:
                # Definition was found
                self._definition = definitions[0]
            else:
                self._definition = DefinitionContainer(setting_data["key"])
                try:
                    self._definition.deserialize(json.dumps(setting_data))
                    ContainerRegistry.getInstance().addContainer(self._definition)
                except ContainerFormatError:
                    self._definition = None
                    return
        if self._definition is None:
            return
        self._stack.addContainer(self._definition)
        self._instance = InstanceContainer(container_id="ScriptInstanceContainer")
        self._instance.setDefinition(self._definition.getId())
        self._instance.setMetaDataEntry("setting_version",
                                        self._definition.getMetaDataEntry("setting_version", default=0))
        self._stack.addContainer(self._instance)
        self._stack.propertyChanged.connect(self._onPropertyChanged)

        ContainerRegistry.getInstance().addContainer(self._stack)
开发者ID:TinkerGnome,项目名称:Cura,代码行数:30,代码来源:Script.py

示例14: __init__

    def __init__(self):
        super().__init__()
        self._settings = None
        self._stack = None

        setting_data = self.getSettingData()
        self._stack = ContainerStack(stack_id=id(self))
        self._stack.setDirty(False)  # This stack does not need to be saved.


        ## Check if the definition of this script already exists. If not, add it to the registry.
        if "key" in setting_data:
            definitions = ContainerRegistry.getInstance().findDefinitionContainers(id = setting_data["key"])
            if definitions:
                # Definition was found
                self._definition = definitions[0]
            else:
                self._definition = DefinitionContainer(setting_data["key"])
                self._definition.deserialize(json.dumps(setting_data))
                ContainerRegistry.getInstance().addContainer(self._definition)
        self._stack.addContainer(self._definition)
        self._instance = InstanceContainer(container_id="ScriptInstanceContainer")
        self._instance.setDefinition(self._definition)
        self._stack.addContainer(self._instance)

        ContainerRegistry.getInstance().addContainer(self._stack)
开发者ID:markwal,项目名称:PostProcessingPlugin,代码行数:26,代码来源:Script.py

示例15: _getBasicMaterials

    def _getBasicMaterials(self, material_container: InstanceContainer):
        base_material = material_container.getMetaDataEntry("material")
        material_container_definition = material_container.getDefinition()
        if material_container_definition and material_container_definition.getMetaDataEntry("has_machine_quality"):
            definition_id = material_container.getDefinition().getMetaDataEntry("quality_definition", material_container.getDefinition().getId())
        else:
            definition_id = "fdmprinter"
        if base_material:
            # There is a basic material specified
            criteria = { "type": "material", "name": base_material, "definition": definition_id }
            containers = ContainerRegistry.getInstance().findInstanceContainers(**criteria)
            containers = [basic_material for basic_material in containers if
                               basic_material.getMetaDataEntry("variant") == material_container.getMetaDataEntry(
                                   "variant")]
            return containers

        return []
开发者ID:hroncok,项目名称:Cura,代码行数:17,代码来源:QualityManager.py


注:本文中的UM.Settings.InstanceContainer.InstanceContainer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。