Beispiel #1
0
 def checker(self, x):
     if type(x) is not types.ListType:
         raise TypeError("Expected a list of Material names!")
     names = materialmanager.getMaterialNames()
     for n in x:
         if n not in names:
             raise TypeError("Expected a list of Material names!")
Beispiel #2
0
 def checker(self, x):
     #The checker gets called before the BulkMaterialWidget gets initialized
     #when the parameter is part of a registeredclass. Have to supress
     #the exception in this case when the material gets deleted.
     if x in materialmanager.getMaterialNames():
         if x not in materialmanager.getBulkMaterialNames():
             raise TypeError("Expected a Bulk Material name!")
Beispiel #3
0
 def checker(self, x):
     #The checker gets called before the BulkMaterialWidget gets initialized
     #when the parameter is part of a registeredclass. Have to supress
     #the exception in this case when the material gets deleted.
     if x in materialmanager.getMaterialNames():
         if x not in materialmanager.getBulkMaterialNames():
             raise TypeError("Expected a Bulk Material name!")
Beispiel #4
0
 def checker(self, x):
     if type(x) is not types.ListType:
         raise TypeError("Expected a list of Material names!")
     names = materialmanager.getMaterialNames()
     for n in x:
         if n not in names:
             raise TypeError("Expected a list of Material names!")
Beispiel #5
0
def copymaterialNameResolver(param, startname):
    if param.automatic():
        matactual = materialmanager.getMaterial(param.group['name'].value)
        # Outside of surface_mode, MATERIALTYPE_INTERFACE is not defined.
        if runtimeflags.surface_mode:
            if matactual.type() == MATERIALTYPE_INTERFACE:
                basename = 'interfacematerial'
            else:
                basename = 'material'
        else:
            basename = 'material'
    else:
        basename = startname
    return utils.uniqueName(basename, materialmanager.getMaterialNames())
Beispiel #6
0
def copymaterialNameResolver(param, startname):
    if param.automatic():
        matactual=materialmanager.getMaterial(param.group['name'].value)
        # Outside of surface_mode, MATERIALTYPE_INTERFACE is not defined.
        if runtimeflags.surface_mode:
            if matactual.type()==MATERIALTYPE_INTERFACE:
                basename = 'interfacematerial'
            else:
                basename = 'material'
        else:
            basename = 'material'
    else:
        basename = startname
    return utils.uniqueName(basename, materialmanager.getMaterialNames())
Beispiel #7
0
 def __init__(self, param, scope=None, name=None):
     names = materialmanager.getMaterialNames()
     names.sort()
     self.widget = chooser.ScrolledMultiListWidget(names,
                                                   callback=self.widgetCB,
                                                   name=name)
     parameterwidgets.ParameterWidget.__init__(self, self.widget.gtk, scope,
                                               expandable=True)
     self.widget.set_selection(param.value)
     self.sbcallbacks = [
         switchboard.requestCallbackMain('new_material', self.newMaterial),
         switchboard.requestCallbackMain('remove_material',
                                         self.newMaterial)
         ]
     self.widgetChanged((param.value is not None), interactive=0) 
Beispiel #8
0
 def __init__(self, param, scope=None, name=None):
     names = materialmanager.getMaterialNames()
     names.sort()
     self.widget = chooser.ScrolledMultiListWidget(names,
                                                   callback=self.widgetCB,
                                                   name=name)
     parameterwidgets.ParameterWidget.__init__(self,
                                               self.widget.gtk,
                                               scope,
                                               expandable=True)
     self.widget.set_selection(param.value)
     self.sbcallbacks = [
         switchboard.requestCallbackMain('new_material', self.newMaterial),
         switchboard.requestCallbackMain('remove_material',
                                         self.newMaterial)
     ]
     self.widgetChanged((param.value is not None), interactive=0)
Beispiel #9
0
def materialNameResolver(param, startname):
    if param.automatic():
        #Interface branch
        material_type = param.group['material_type'].value

        # Slightly convoluted conditional -- in surface mode, you have
        # to check to see if you have an interface material.  Outside
        # of surface mode, this is impossible, and
        # MATERIALTYPE_INTERFACE is not defined, so checking for it is
        # an error.
        if runtimeflags.surface_mode:
            if material_type==MATERIALTYPE_INTERFACE:
                basename = 'interfacematerial'
            else:
                basename = 'material'
        else:
            basename = 'material'
    else:
        basename = startname
    return utils.uniqueName(basename, materialmanager.getMaterialNames())
Beispiel #10
0
def materialNameResolver(param, startname):
    if param.automatic():
        #Interface branch
        material_type = param.group['material_type'].value

        # Slightly convoluted conditional -- in surface mode, you have
        # to check to see if you have an interface material.  Outside
        # of surface mode, this is impossible, and
        # MATERIALTYPE_INTERFACE is not defined, so checking for it is
        # an error.
        if runtimeflags.surface_mode:
            if material_type == MATERIALTYPE_INTERFACE:
                basename = 'interfacematerial'
            else:
                basename = 'material'
        else:
            basename = 'material'
    else:
        basename = startname
    return utils.uniqueName(basename, materialmanager.getMaterialNames())
Beispiel #11
0
 def newMaterial(self, *args):
     names = materialmanager.getMaterialNames()
     names.sort()
     self.widget.update(names)
Beispiel #12
0
 def checker(self, x):
     if (x not in materialmanager.getMaterialNames()
             and x not in self.extranames):
         raise TypeError("Expected a Material name, or '<Any>' or '<None>'")
Beispiel #13
0
 def checker(self, x):
     if x not in materialmanager.getMaterialNames():
         raise TypeError("Expected a Material name!")
Beispiel #14
0
 def del_mat(self, material):        # switchboard "remove_material"
     self.materialName.update(materialmanager.getMaterialNames())
     self.updatePropList()
     self.sensitize()
Beispiel #15
0
 def update(self, *args):
     names = materialmanager.getMaterialNames()
     names.sort()
     self.chooser.update(names)
     self.widgetChanged(len(names) > 0, interactive=0)
Beispiel #16
0
 def newMaterial(self, *args):
     names = materialmanager.getMaterialNames()
     names.sort()
     self.widget.update(names)
Beispiel #17
0
 def update(self, *args):
     names = materialmanager.getMaterialNames()
     names.sort()
     self.chooser.update(materialparameter.AnyMaterialParameter.extranames +
                         names)
     self.widgetChanged(validity=1, interactive=0)
Beispiel #18
0
 def new_mat(self, name):            # switchboard "new_material"
     names = materialmanager.getMaterialNames()
     self.materialName.update(names)
     self.materialName.set_state(name)
     self.updatePropList()
     self.sensitize()
Beispiel #19
0
 def new_mat(self, name):  # switchboard "new_material"
     names = materialmanager.getMaterialNames()
     self.materialName.update(names)
     self.materialName.set_state(name)
     self.updatePropList()
     self.sensitize()
Beispiel #20
0
 def checker(self, x):
     if x not in materialmanager.getMaterialNames():
         raise TypeError("Expected a Material name!")
Beispiel #21
0
 def checker(self, x):
     if x not in materialmanager.getMaterialNames() and x not in self.extranames:
         raise TypeError("Expected a Material name, or '<Any>' or '<None>'")
Beispiel #22
0
 def update(self, *args):
     names = materialmanager.getMaterialNames()
     names.sort()
     self.chooser.update(materialparameter.AnyMaterialParameter.extranames
                         + names)
     self.widgetChanged(validity=1, interactive=0)
Beispiel #23
0
    def __init__(self, parent):
        debug.mainthreadTest()
        self.parent = parent

        self.gtk = gtk.Frame('Material')
        gtklogger.setWidgetName(self.gtk, 'Material')
        self.gtk.set_shadow_type(gtk.SHADOW_IN)
        vbox = gtk.VBox()
        self.gtk.add(vbox)

        buttonbox = gtk.HBox()
        vbox.pack_start(buttonbox, expand=0, fill=0)

        self.newmaterial = gtkutils.StockButton(gtk.STOCK_NEW, 'New...')
        gtklogger.setWidgetName(self.newmaterial, 'New')
        buttonbox.pack_start(self.newmaterial, expand=1, fill=0)
        tooltips.set_tooltip_text(self.newmaterial, 'Create a new Material.')
        gtklogger.connect(self.newmaterial, "clicked", self.on_newmaterial)

        self.renamematerial = gtkutils.StockButton(gtk.STOCK_EDIT, 'Rename...')
        gtklogger.setWidgetName(self.renamematerial, 'Rename')
        buttonbox.pack_start(self.renamematerial, expand=1, fill=0)
        tooltips.set_tooltip_text(self.renamematerial, 'Rename this material.')
        gtklogger.connect(self.renamematerial, "clicked", self.on_rename)

        self.copymaterial = gtkutils.StockButton(gtk.STOCK_COPY, 'Copy...')
        gtklogger.setWidgetName(self.copymaterial, 'Copy')
        buttonbox.pack_start(self.copymaterial, expand=1, fill=0)
        tooltips.set_tooltip_text(self.copymaterial,
                                  'Create a copy of this material.')
        gtklogger.connect(self.copymaterial, "clicked", self.on_copy)

        self.deletebutton = gtkutils.StockButton(gtk.STOCK_DELETE, 'Delete')
        gtklogger.setWidgetName(self.deletebutton, 'Delete')
        buttonbox.pack_start(self.deletebutton, expand=1, fill=0)
        tooltips.set_tooltip_text(self.deletebutton, 'Delete this material.')
        gtklogger.connect(self.deletebutton, "clicked", self.on_delete)

        self.savebutton = gtkutils.StockButton(gtk.STOCK_SAVE, 'Save...')
        gtklogger.setWidgetName(self.savebutton, 'Save')
        buttonbox.pack_start(self.savebutton, expand=1, fill=0)
        tooltips.set_tooltip_text(self.savebutton,
                                  'Save this material in a file.')
        gtklogger.connect(self.savebutton, 'clicked', self.on_save)

        self.materialName = chooser.ChooserWidget(
            materialmanager.getMaterialNames(),
            callback=self.newMatSelection,
            update_callback=self.newMatSelection,
            name="MaterialList")
        self.materialName.gtk.set_border_width(3)

        vbox.pack_start(self.materialName.gtk, expand=0, fill=0)
        tooltips.set_tooltip_text(self.materialName.gtk,
                                  'Choose a Material to edit.')

        # The list of Properties belonging to a Material
        self.matproplist = chooser.ScrolledChooserListWidget(
            callback=self.matproplistCB, autoselect=False, name="PropertyList")
        self.matproplist.gtk.set_border_width(3)
        vbox.pack_start(self.matproplist.gtk, expand=1, fill=1)

        self.removebutton = gtk.Button('Remove Property from Material')
        gtklogger.setWidgetName(self.removebutton, "RemoveProperty")
        self.removebutton.set_border_width(3)
        vbox.pack_start(self.removebutton, expand=0, fill=0, padding=3)
        tooltips.set_tooltip_text(
            self.removebutton,
            'Remove the currently selected property from this material.')
        gtklogger.connect(self.removebutton, "clicked", self.on_remove)

        # Assignment of materials to pixels and removal of materials
        # from pixels may belong in a separate GUI page.  For now,
        # it's done via the dialog boxes raised by the buttons defined
        # here.
        assignframe = gtk.Frame()
        assignframe.set_shadow_type(gtk.SHADOW_IN)
        assignframe.set_border_width(3)
        vbox.pack_start(assignframe, expand=0, fill=0)

        # NB surface-mode flag is operative here.

        if runtimeflags.surface_mode:
            inner2vbox_pair = gtk.VBox()
        align = gtk.Alignment(xalign=0.5)
        inner2hbox_both = gtk.HBox()
        inner2vbox = gtk.VBox()
        if runtimeflags.surface_mode:
            assignframe.add(inner2hbox_both)
        else:
            assignframe.add(align)
            align.add(inner2hbox_both)
        inner2hbox_both.pack_start(inner2vbox)
        if runtimeflags.surface_mode:
            inner2hbox_both.pack_start(inner2vbox_pair)

        # Assign materials to pixels
        self.assignbutton = gtk.Button('Assign Material to %ss...' % Pixstring)
        gtklogger.setWidgetName(self.assignbutton, "Assign")
        self.assignbutton.set_border_width(3)
        inner2vbox.pack_start(self.assignbutton, expand=0, fill=0)
        tooltips.set_tooltip_text(
            self.assignbutton,
            'Assign the currently selected Material to %ss in a Microstructure.'
            % pixstring)
        gtklogger.connect(self.assignbutton, 'clicked', self.on_assignment)

        # Remove materials from pixels
        self.removematbutton = gtk.Button('Remove Materials from %ss...' %
                                          Pixstring)
        gtklogger.setWidgetName(self.removematbutton, "RemoveMaterial")
        self.removematbutton.set_border_width(3)
        inner2vbox.pack_start(self.removematbutton, expand=0, fill=0)
        tooltips.set_tooltip_text(
            self.removematbutton,
            'Remove all Materials from %ss in a Microstructure.' % pixstring)
        gtklogger.connect(self.removematbutton, 'clicked',
                          self.on_MS_remove_material)

        if runtimeflags.surface_mode:

            self.assigninterfacebutton = gtk.Button('Assign to interface...')
            gtklogger.setWidgetName(self.assigninterfacebutton,
                                    "AssignInterface")
            self.assigninterfacebutton.set_border_width(3)
            inner2vbox_pair.pack_start(self.assigninterfacebutton,
                                       expand=0,
                                       fill=0)
            tooltips.set_tooltip_text(
                self.assigninterfacebutton,
                'Assign the currently selected Material to an interface in a Microstructure.'
            )
            gtklogger.connect(self.assigninterfacebutton, 'clicked',
                              self.on_interface_assign)

            # Remove material from interface
            self.removeinterfacebutton = gtk.Button('Remove from interface...')
            gtklogger.setWidgetName(self.removeinterfacebutton,
                                    "RemoveInterface")
            self.removeinterfacebutton.set_border_width(3)
            inner2vbox_pair.pack_start(self.removeinterfacebutton,
                                       expand=0,
                                       fill=0)
            tooltips.set_tooltip_text(
                self.removeinterfacebutton,
                'Remove Material from an interface in a Microstructure.')
            gtklogger.connect(self.removeinterfacebutton, 'clicked',
                              self.on_interface_remove)

        # End of surface-mode block.

        self.updatePropList()
        self.gtk.show_all()

        # Switchboard callbacks.
        switchboard.requestCallbackMain("new_material", self.new_mat)
        switchboard.requestCallbackMain("remove_material", self.del_mat)
        switchboard.requestCallbackMain("prop_added_to_material",
                                        self.prop_added)
        switchboard.requestCallbackMain("prop_removed_from_material",
                                        self.prop_removed)
        switchboard.requestCallbackMain(('new who', 'Microstructure'),
                                        self.sensitize)
        switchboard.requestCallbackMain(('remove who', 'Microstructure'),
                                        self.sensitize)
Beispiel #24
0
 def update(self, *args):
     names = materialmanager.getMaterialNames()
     names.sort()
     self.chooser.update(names)
     self.widgetChanged(len(names) > 0, interactive=0)
Beispiel #25
0
 def del_mat(self, material):  # switchboard "remove_material"
     self.materialName.update(materialmanager.getMaterialNames())
     self.updatePropList()
     self.sensitize()
Beispiel #26
0
    def __init__(self, parent):
        debug.mainthreadTest()
        self.parent = parent

        self.gtk = gtk.Frame('Material')
        gtklogger.setWidgetName(self.gtk, 'Material')
        self.gtk.set_shadow_type(gtk.SHADOW_IN)
        vbox = gtk.VBox()
        self.gtk.add(vbox)

        buttonbox = gtk.HBox()
        vbox.pack_start(buttonbox, expand=0, fill=0)

        self.newmaterial = gtkutils.StockButton(gtk.STOCK_NEW, 'New...')
        gtklogger.setWidgetName(self.newmaterial, 'New')
        buttonbox.pack_start(self.newmaterial, expand=1, fill=0)
        tooltips.set_tooltip_text(self.newmaterial,'Create a new Material.')
        gtklogger.connect(self.newmaterial, "clicked",self.on_newmaterial)

        self.renamematerial = gtkutils.StockButton(gtk.STOCK_EDIT,
                                                   'Rename...')
        gtklogger.setWidgetName(self.renamematerial,'Rename')
        buttonbox.pack_start(self.renamematerial, expand=1, fill=0)
        tooltips.set_tooltip_text(self.renamematerial,
                             'Rename this material.')
        gtklogger.connect(self.renamematerial, "clicked", self.on_rename)
        
        self.copymaterial = gtkutils.StockButton(gtk.STOCK_COPY, 'Copy...')
        gtklogger.setWidgetName(self.copymaterial, 'Copy')
        buttonbox.pack_start(self.copymaterial, expand=1, fill=0)
        tooltips.set_tooltip_text(self.copymaterial,
                             'Create a copy of this material.')
        gtklogger.connect(self.copymaterial, "clicked", self.on_copy)

        self.deletebutton = gtkutils.StockButton(gtk.STOCK_DELETE, 'Delete')
        gtklogger.setWidgetName(self.deletebutton, 'Delete')
        buttonbox.pack_start(self.deletebutton, expand=1, fill=0)
        tooltips.set_tooltip_text(self.deletebutton,'Delete this material.')
        gtklogger.connect(self.deletebutton, "clicked", self.on_delete)

        self.savebutton = gtkutils.StockButton(gtk.STOCK_SAVE, 'Save...')
        gtklogger.setWidgetName(self.savebutton, 'Save')
        buttonbox.pack_start(self.savebutton, expand=1, fill=0)
        tooltips.set_tooltip_text(self.savebutton,'Save this material in a file.')
        gtklogger.connect(self.savebutton, 'clicked', self.on_save)

        self.materialName = chooser.ChooserWidget(
            materialmanager.getMaterialNames(),
            callback=self.newMatSelection,
            update_callback=self.newMatSelection,
            name="MaterialList")
        self.materialName.gtk.set_border_width(3)

        vbox.pack_start(self.materialName.gtk, expand=0, fill=0)
        tooltips.set_tooltip_text(self.materialName.gtk,
                             'Choose a Material to edit.')

        # The list of Properties belonging to a Material
        self.matproplist = chooser.ScrolledChooserListWidget(
            callback=self.matproplistCB, autoselect=False, name="PropertyList")
        self.matproplist.gtk.set_border_width(3)
        vbox.pack_start(self.matproplist.gtk, expand=1, fill=1)

        self.removebutton = gtk.Button('Remove Property from Material')
        gtklogger.setWidgetName(self.removebutton, "RemoveProperty")
        self.removebutton.set_border_width(3)
        vbox.pack_start(self.removebutton, expand=0, fill=0, padding=3)
        tooltips.set_tooltip_text(self.removebutton,
               'Remove the currently selected property from this material.')
        gtklogger.connect(self.removebutton, "clicked", self.on_remove)

        # Assignment of materials to pixels and removal of materials
        # from pixels may belong in a separate GUI page.  For now,
        # it's done via the dialog boxes raised by the buttons defined
        # here.
        assignframe = gtk.Frame()
        assignframe.set_shadow_type(gtk.SHADOW_IN)
        assignframe.set_border_width(3)
        vbox.pack_start(assignframe, expand=0, fill=0)

        # NB surface-mode flag is operative here.

        if runtimeflags.surface_mode:
            inner2vbox_pair=gtk.VBox()
        align = gtk.Alignment(xalign=0.5)
        inner2hbox_both=gtk.HBox()
        inner2vbox = gtk.VBox()
        if runtimeflags.surface_mode:
            assignframe.add(inner2hbox_both)
        else:
            assignframe.add(align) 
            align.add(inner2hbox_both) 
        inner2hbox_both.pack_start(inner2vbox)
        if runtimeflags.surface_mode:
            inner2hbox_both.pack_start(inner2vbox_pair) 
        
        # Assign materials to pixels
        self.assignbutton = gtk.Button('Assign Material to %ss...'%Pixstring)
        gtklogger.setWidgetName(self.assignbutton, "Assign")
        self.assignbutton.set_border_width(3)
        inner2vbox.pack_start(self.assignbutton, expand=0, fill=0)
        tooltips.set_tooltip_text(self.assignbutton,
                             'Assign the currently selected Material to %ss in a Microstructure.'%pixstring)
        gtklogger.connect(self.assignbutton, 'clicked', self.on_assignment)
        
        # Remove materials from pixels
        self.removematbutton = gtk.Button('Remove Materials from %ss...'%Pixstring)
        gtklogger.setWidgetName(self.removematbutton, "RemoveMaterial")
        self.removematbutton.set_border_width(3)
        inner2vbox.pack_start(self.removematbutton, expand=0, fill=0)
        tooltips.set_tooltip_text(self.removematbutton,
                             'Remove all Materials from %ss in a Microstructure.'%pixstring)
        gtklogger.connect(self.removematbutton, 'clicked',
                          self.on_MS_remove_material)


        if runtimeflags.surface_mode:

            self.assigninterfacebutton = gtk.Button('Assign to interface...')
            gtklogger.setWidgetName(self.assigninterfacebutton,
                                    "AssignInterface")
            self.assigninterfacebutton.set_border_width(3)
            inner2vbox_pair.pack_start(self.assigninterfacebutton,
                                       expand=0, fill=0)
            tooltips.set_tooltip_text(self.assigninterfacebutton,
                                      'Assign the currently selected Material to an interface in a Microstructure.')
            gtklogger.connect(self.assigninterfacebutton, 'clicked', self.on_interface_assign)
        
            # Remove material from interface
            self.removeinterfacebutton = gtk.Button('Remove from interface...')
            gtklogger.setWidgetName(self.removeinterfacebutton,
                                    "RemoveInterface")
            self.removeinterfacebutton.set_border_width(3)
            inner2vbox_pair.pack_start(self.removeinterfacebutton, expand=0, fill=0)
            tooltips.set_tooltip_text(self.removeinterfacebutton,
                                      'Remove Material from an interface in a Microstructure.')
            gtklogger.connect(self.removeinterfacebutton, 'clicked',
                              self.on_interface_remove)
        
        # End of surface-mode block.


        self.updatePropList()
        self.gtk.show_all()

        # Switchboard callbacks.
        switchboard.requestCallbackMain("new_material",self.new_mat)
        switchboard.requestCallbackMain("remove_material",self.del_mat)
        switchboard.requestCallbackMain("prop_added_to_material",
                                        self.prop_added)
        switchboard.requestCallbackMain("prop_removed_from_material",
                                        self.prop_removed)
        switchboard.requestCallbackMain(('new who', 'Microstructure'),
                                        self.sensitize)
        switchboard.requestCallbackMain(('remove who', 'Microstructure'),
                                        self.sensitize)