Beispiel #1
0
    def delete(self, name):
        doomed = self.materials[name]

        if config.dimension() == 2 and runtimeflags.surface_mode:
            #Interface branch
            material_type = doomed.actual.type()
            #Do the following before the switchboard call to remove_material
            for ms in microStructures.actualMembers():
                interfacemsplugin = ms.getObject().getPlugIn("Interfaces")
                interfacemsplugin.deleteMaterial(name, material_type)

        if doomed:
            doomed.delete_all_props()
            del self.materials[doomed.name]
            switchboard.notify("remove_material", doomed)

        # Ensure that all MaterialAttribute objects which refer to
        # this material are notified of its untimely demise.
        for ms in microStructures.actualMembers():
            # cleanAttributes forces microstructure recategorization
            # only if the doomed material is actually used in the
            # microstructure.  It returns True if the material is
            # used.
            if doomed.actual.cleanAttributes(ms.getObject()):
                switchboard.notify("materials changed in microstructure",
                                   ms.getObject())
        switchboard.notify("redraw")
Beispiel #2
0
    def delete(self, name):
        doomed = self.materials[name]

        if config.dimension() == 2 and runtimeflags.surface_mode:
            #Interface branch
            material_type = doomed.actual.type()
            #Do the following before the switchboard call to remove_material
            for ms in microStructures.actualMembers():
                interfacemsplugin=ms.getObject().getPlugIn("Interfaces")
                interfacemsplugin.deleteMaterial(name,material_type)

        if doomed:
            doomed.delete_all_props()
            del self.materials[doomed.name]
            switchboard.notify("remove_material",doomed)
            
        # Ensure that all MaterialAttribute objects which refer to
        # this material are notified of its untimely demise.
        for ms in microStructures.actualMembers():
            # cleanAttributes forces microstructure recategorization
            # only if the doomed material is actually used in the
            # microstructure.  It returns True if the material is
            # used.
            if doomed.actual.cleanAttributes(ms.getObject()):
                switchboard.notify("materials changed in microstructure",
                                   ms.getObject())
        switchboard.notify("redraw")
Beispiel #3
0
    def new_material(self,
                     name,
                     materialtype=material.MATERIALTYPE_BULK,
                     *props):
        # If a Material already exists with the same name, just
        # redefine it by deleting its old Properties and adding the
        # new ones.  *Don't* try deleting the Material entirely and
        # recreating it from scratch, which seems like the easy way to
        # go. Deleting the Material would delete it from any
        # Microstructures and Meshes that use it.
        try:
            matprop = self.materials[name]
        except KeyError:
            matprop = MaterialProps(name, materialtype)
            self.materials[name] = matprop
        else:
            matprop.delete_all_props()

        mat = matprop.actual
        for p in props:
            mat.addProperty(p)
            reg = p.registration()
            path = AllProperties.data.reverse_dict[reg].path()
            matprop.add_prop_ref(path, reg)
            reg.materials[name] = (matprop, p)

        switchboard.notify("new_material", name)
        for ms in microStructures.actualMembers():
            if mat in material.getMaterials(ms.getObject()):
                switchboard.notify("materials changed in microstructure",
                                   ms.getObject())
Beispiel #4
0
    def new_material(self, name,
                     materialtype=material.MATERIALTYPE_BULK,
                     *props):
        # If a Material already exists with the same name, just
        # redefine it by deleting its old Properties and adding the
        # new ones.  *Don't* try deleting the Material entirely and
        # recreating it from scratch, which seems like the easy way to
        # go. Deleting the Material would delete it from any
        # Microstructures and Meshes that use it.
        try:
            matprop = self.materials[name]
        except KeyError:
            matprop = MaterialProps(name, materialtype)
            self.materials[name] = matprop
        else:
            matprop.delete_all_props()

        mat = matprop.actual
        for p in props:
            mat.addProperty(p)
            reg = p.registration()
            path = AllProperties.data.reverse_dict[reg].path()
            matprop.add_prop_ref(path, reg)
            reg.materials[name]=(matprop, p)

        switchboard.notify("new_material", name)
        for ms in microStructures.actualMembers():
            if mat in material.getMaterials(ms.getObject()):
                switchboard.notify("materials changed in microstructure",
                                   ms.getObject())
Beispiel #5
0
    def rename(self, oldname, newname):
        mat_prop = self.materials[oldname]
        c_mat = mat_prop.actual

        mat_prop.name = newname
        #Also change the names in the propertyregistration
        mat_prop.rename_material(newname,oldname)
        del self.materials[oldname]
        self.materials[newname]=mat_prop

        #Interface branch
        material_type=c_mat.type()
        #Do the following before the switchboard call to remove_material
        if runtimeflags.surface_mode:
            for ms in microStructures.actualMembers():
                interfacemsplugin=ms.getObject().getPlugIn("Interfaces")
                interfacemsplugin.renameMaterial(oldname,newname,material_type)

        c_mat.rename(newname)
        switchboard.notify("remove_material", oldname)
        switchboard.notify("new_material", newname)
Beispiel #6
0
    def rename(self, oldname, newname):
        mat_prop = self.materials[oldname]
        c_mat = mat_prop.actual

        mat_prop.name = newname
        #Also change the names in the propertyregistration
        mat_prop.rename_material(newname, oldname)
        del self.materials[oldname]
        self.materials[newname] = mat_prop

        #Interface branch
        material_type = c_mat.type()
        #Do the following before the switchboard call to remove_material
        if runtimeflags.surface_mode:
            for ms in microStructures.actualMembers():
                interfacemsplugin = ms.getObject().getPlugIn("Interfaces")
                interfacemsplugin.renameMaterial(oldname, newname,
                                                 material_type)

        c_mat.rename(newname)
        switchboard.notify("remove_material", oldname)
        switchboard.notify("new_material", newname)