예제 #1
0
    def __init__(self, param, whoclass, meshfunc, scope, name=None,
                 separator_func=None):
        self.meshfunc = meshfunc
        self.whoclass = whoclass
        self.chooser = chooser.ChooserWidget([], callback=self.chooserCB,
                                             name=name,
                                             separator_func=separator_func)
        parameterwidgets.ParameterWidget.__init__(self, self.chooser.gtk, scope)
        self.meshwidget = scope.findWidget(
            lambda w: isinstance(w, whowidget.WhoWidget)
            and w.whoclass is whoclass)
        assert self.meshwidget is not None
        if self.meshwidget is None:
            raise ooferror.ErrPyProgrammingError("Can't find WhoWidget for %s"
                                                 % `whoclass`)
        self.sbcallbacks = [
            switchboard.requestCallbackMain(self.meshwidget, self.update),
            switchboard.requestCallbackMain("mesh changed", self.meshChangeCB),
            switchboard.requestCallbackMain("subproblem changed",
                                            self.meshChangeCB)
            ]

        self.update(interactive=0)
        
        if TESTINGPAPER:
            if param.value is not None:
                self.set_value(param.value)
        else:
            self.set_value(param.value)
예제 #2
0
 def signals(self):
     return [
         switchboard.requestCallbackMain("named analyses changed",
                                         self.update),
         switchboard.requestCallbackMain("named boundary analyses changed",
                                         self.update)
         ]
예제 #3
0
 def __init__(self, param, scope=None, name=None):
     debug.mainthreadTest()
     hbox = gtk.HBox()
     xlabel = gtk.Label("x:")
     xlabel.set_alignment(1.0, 0.5)
     self.xwidget = FloatWidget(parameter.FloatParameter('Tweedledum', 0),
                                name="X")
     ylabel = gtk.Label("y:")
     ylabel.set_alignment(1.0, 0.5)
     self.ywidget = FloatWidget(parameter.FloatParameter('Tweedledee', 0),
                                name="Y")
     hbox.pack_start(xlabel, expand=0, fill=0, padding=2)
     hbox.pack_start(self.xwidget.gtk, expand=1, fill=1)
     hbox.pack_start(ylabel, expand=0, fill=0, padding=2)
     hbox.pack_start(self.ywidget.gtk, expand=1, fill=1)
     self.sbcallbacks=[
         switchboard.requestCallbackMain(self.xwidget,
                                         self.widgetChangeCB),
         switchboard.requestCallbackMain(self.ywidget,
                                         self.widgetChangeCB)
         ]
     ParameterWidget.__init__(self, hbox, scope=scope, name=name)
     self.set_value(param.value)
     self.widgetChanged(self.xwidget.isValid() and self.ywidget.isValid(),
                        interactive=0)
예제 #4
0
    def makeSingleWidget(self, param, tablepos, scope):
        debug.mainthreadTest()
        widget = param.makeWidget(scope=scope)
        self.widgets.append(widget)

        self.sbcallbacks += [
            switchboard.requestCallbackMain(('validity', widget), self.vcheck,
                                            tablepos),
            switchboard.requestCallbackMain(widget, self.widgetChangeCB)
            ]
        self.validities[tablepos] = widget.isValid()
        
        label = gtk.Label(param.name + ' =')
        label.set_alignment(1.0, 0.5)
        self.labels.append(label)
        if param.tip:
            tooltips.set_tooltip_text(label,param.tip)
        if widget.expandable:
            yoptions = gtk.EXPAND | gtk.FILL
            self.expandable = True
        else:
            yoptions = 0
        if self.showLabels:
            self.gtk.attach(label, 0, 1, tablepos, tablepos+1, xpadding=5,
                            xoptions=gtk.FILL, yoptions=yoptions)
        self.gtk.attach(widget.gtk, 1, 2, tablepos, tablepos+1, xpadding=5,
                        xoptions=gtk.EXPAND|gtk.FILL, yoptions=yoptions)
 def activate(self):
     genericselectGUI.GenericSelectToolboxGUI.activate(self)
     self.activecallbacks = [
         switchboard.requestCallbackMain((self.gfxwindow(),
                                          'layers changed'),
                                         self.layerChangeCB) ,
         switchboard.requestCallbackMain(self.mode.changedselectionsignal,
                                         self.changedSelection)
         ]
예제 #6
0
    def __init__(self, pixelinfotoolbox):
        debug.mainthreadTest()
        toolboxGUI.GfxToolbox.__init__(self, "Pixel Info", pixelinfotoolbox)
        mainbox = gtk.VBox()
        self.gtk.add(mainbox)

        self.table = gtk.Table(rows=3, columns=2)
        mainbox.pack_start(self.table, expand=0, fill=0)
        
        label = gtk.Label('x=')
        label.set_alignment(1.0, 0.5)
        self.table.attach(label, 0,1, 0,1, xpadding=5, xoptions=gtk.FILL)
        self.xtext = gtk.Entry()
        gtklogger.setWidgetName(self.xtext, "X")
        self.xtext.set_size_request(10*guitop.top().digitsize, -1)
        self.table.attach(self.xtext, 1,2, 0,1,
                          xpadding=5, xoptions=gtk.EXPAND|gtk.FILL)
        label = gtk.Label('y=')
        label.set_alignment(1.0, 0.5)
        self.table.attach(label, 0,1, 1,2, xpadding=5, xoptions=gtk.FILL)
        self.ytext = gtk.Entry()
        gtklogger.setWidgetName(self.ytext, "Y")
        self.ytext.set_size_request(10*guitop.top().digitsize, -1)
        self.table.attach(self.ytext, 1,2, 1,2,
                          xpadding=5, xoptions=gtk.EXPAND|gtk.FILL)


        self.xtsignal = gtklogger.connect(self.xtext, 'changed',
                                          self.pointChanged)
        self.ytsignal = gtklogger.connect(self.ytext, 'changed',
                                          self.pointChanged)

        box = gtk.HBox(homogeneous=True, spacing=2)
        self.updatebutton = gtkutils.StockButton(gtk.STOCK_REFRESH, 'Update')
        box.pack_start(self.updatebutton, expand=1, fill=1)
        gtklogger.setWidgetName(self.updatebutton, "Update")
        gtklogger.connect(self.updatebutton, 'clicked', self.updateButtonCB)
        self.clearbutton = gtkutils.StockButton(gtk.STOCK_CLEAR, 'Clear')
        box.pack_start(self.clearbutton, expand=1, fill=1)
        gtklogger.setWidgetName(self.clearbutton, "Clear")
        gtklogger.connect(self.clearbutton, 'clicked', self.clearButtonCB)
        self.table.attach(box, 0,2, 2,3,
                          xpadding=5, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0)

        self.updatebutton.set_sensitive(0)
        self.clearbutton.set_sensitive(0)
        self.buildGUI()
        
        self.sbcallbacks = [
            switchboard.requestCallbackMain(pixelinfotoolbox,
                                            self.update),
            switchboard.requestCallbackMain('new pixelinfo plugin',
                                            self.buildGUI),
            switchboard.requestCallbackMain((self.gfxwindow(),
                                             'layers changed'), self.update)
            ]
예제 #7
0
 def __init__(self, param, scope=None, name=None):
     self.chooser = chooser.ChooserWidget([], callback=self.chooserCB,
                                          name=name)
     parameterwidgets.ParameterWidget.__init__(self, self.chooser.gtk, scope)
     self.sbcallbacks = [
         switchboard.requestCallbackMain("new_material", self.update),
         switchboard.requestCallbackMain("remove_material", self.update)
         ]
     self.update()
     if param.value is not None:
         self.set_value(param.value)
예제 #8
0
 def __init__(self, param, scope, name=None):
     self.chooser = chooser.ChooserWidget([], callback=self.chooserCB,
                                          name=name)
     parameterwidgets.ParameterWidget.__init__(self, self.chooser.gtk, scope)
     self.meshwidget = scope.findWidget(
         lambda w: isinstance(w, whowidget.WhoWidget)
         and w.whoclass is mesh.meshes)
     assert self.meshwidget is not None
     self.sbcallbacks = [
         switchboard.requestCallbackMain(self.meshwidget, self.update),
         switchboard.requestCallbackMain("scheduled outputs changed",
                                         self.update)
         ]
     self.update(interactive=False)
예제 #9
0
    def __init__(self, obj=None, title=None, callback=None,
                 fill=0, expand=0, scope=None, name=None, widgetdict={},
                 domainClass=None, operationClass=None,
                 *args, **kwargs):
        self.sample_types = []
        self.directness = False

        regclassfactory.RegisteredClassFactory.__init__(
            self, analysissample.SampleSet.registry, obj,
            title, callback, fill, expand, scope,
            name, widgetdict, *args, **kwargs)

        self.sbcallbacks = []

        # If the domainClass arg is specified, then this widget will
        # only be used on a particular type of domain, and it won't be
        # necessary to synchronize with a Domain widget.
        if domainClass is None:
            # Find widget to synch with.
            self.domainWidget = self.findWidget(
                lambda w: (isinstance(w, regclassfactory.RegisteredClassFactory)
                           and w.registry is analysisdomain.Domain.registry))
            assert self.domainWidget is not None
            self.newDomain()
            self.sbcallbacks.append(
                switchboard.requestCallbackMain(self.domainWidget,
                                                self.domainCB))
        else:                   # domainClass was specified
            # Find the registration for the class
            for reg in analysisdomain.Domain.registry:
                if reg.subclass is domainClass:
                    self.sample_types = reg.sample_types

        # Ditto for the operationClass.
        if operationClass is None:
            self.operationWidget = self.findWidget(
                lambda w: (isinstance(w, regclassfactory.RegisteredClassFactory)
                           and w.registry is analyze.DataOperation.registry))
            assert self.operationWidget is not None
            self.newOperation()
            self.sbcallbacks.append(
                switchboard.requestCallbackMain(self.operationWidget,
                                                self.operationCB))
        else: # operationClass is not None, set directness accordingly
            for reg in analyze.DataOperation.registry:
                if reg.subclass is operationClass:
                    self.directness = reg.direct
                    break
        self.refresh(obj)
예제 #10
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) 
예제 #11
0
    def __init__(self, tree, expand=1, callback=None, name=None,
                 *callbackargs, **callbackkwargs):
        debug.mainthreadTest()
        self.tree = tree                # associated LabelTree
        self.callback = callback
        self.callbackargs = callbackargs
        self.callbackkwargs = callbackkwargs

        self.rccb = None

        # Create a TreeStore that mirrors the LabelTree.  The first
        # column is the label, and the second is the LabelTree node.
        self.treestore = gtk.TreeStore(gobject.TYPE_STRING,
                                       gobject.TYPE_PYOBJECT)
        self.gtk = gtk.TreeView(model=self.treestore)
        gtklogger.setWidgetName(self.gtk, name)
        self.gtk.set_property("headers-visible", False)
        tvcol = gtk.TreeViewColumn()
        self.gtk.append_column(tvcol)
        cell = gtk.CellRendererText()
        tvcol.pack_start(cell, expand=False)
        tvcol.set_attributes(cell, text=0) # display column 0 of the tree store
        
        selection = self.gtk.get_selection()
        gtklogger.adoptGObject(selection, self.gtk,
                              access_method=self.gtk.get_selection)
        self.selection_signal = gtklogger.connect(selection, 'changed',
                                                 self.selectionChangedCB)
        selection.set_select_function(self.selectFn)
        gtklogger.connect(self.gtk, 'row-activated', self.activateRowCB)
        gtklogger.connect_passive(self.gtk, 'row-expanded')
        gtklogger.connect_passive(self.gtk, 'row-collapsed')
        self.lt2treeiter = {}

        self.current_selection = None   # a LabelTreeNode

        for node in tree.nodes:
            self.constructGUI(node, None)

        self.gtk.connect("destroy", self.destroyCB)
        self.autoSelect()
        self.gtk.show_all()

        self.sbcallbacks = [
            switchboard.requestCallbackMain((tree, "insert"), self.insertCB),
            switchboard.requestCallbackMain((tree, "delete"), self.deleteCB),
            switchboard.requestCallbackMain((tree, "rename"), self.renameCB)
            ]
예제 #12
0
    def __init__(self, whoclass, value=None, scope=None, name=None):
        self.skelwidget = scope.findWidget(
            lambda x: isinstance(x, whowidget.WhoWidget)
            and x.whoclass is skeletonContexts)
        whowidget.WhoParameterWidgetBase.__init__(self, whoclass,
                                                  value=value, scope=scope,
                                                  name=name)

        # switchboard callbacks
        self.sbcallbacks = [
            switchboard.requestCallbackMain(self.skelwidget,
                                            self.skelwidgetChanged),
            switchboard.requestCallbackMain(('who changed', 'Skeleton'),
                                            self.skelModified),
            switchboard.requestCallbackMain('mesh status changed',
                                            self.meshStatusChanged)]
예제 #13
0
    def __init__(self, enumclass, param, scope=None, name=None):
        parameterwidgets.EnumWidget.__init__(self, enumclass, param, scope, name)
        self.skelwidget = scope.findWidget(
            lambda x: isinstance(x, whowidget.WhoWidget) and x.whoclass is skeletoncontext.skeletonContexts
        )

        ##        self.aggwidget = scope.findWidget(
        ##            lambda x: \
        ##            isinstance(x, skeletongroupwidgets.SkeletonAggregateWidget))

        ##        self.segmenter = skeletongroupwidgets.segmenter[
        ##            self.aggwidget.__class__]

        self.interfacewidget = scope.findWidget(lambda x: isinstance(x, interfacewidget.InterfacesWidget))

        # We don't need to worry about the skeleton changing, because we
        # live in a modal dialog box and the skeleton is set on
        # the task page.  So, might as well get the context
        # now.
        self.skelcontext = skeletoncontext.skeletonContexts[self.skelwidget.get_value()]
        # Do worry about when the aggregate changes.
        ##        self.agg_callback = switchboard.requestCallbackMain(
        ##            self.aggwidget, self.newAggregate)
        self.interface_callback = switchboard.requestCallbackMain(self.interfacewidget, self.newInterface)
        self.param = param
        self.update()
예제 #14
0
 def __init__(self, param, scope=None, name=None):
     self.meshwidget = scope.findWidget(
         lambda w: isinstance(w, whowidget.WhoWidget)
         and w.whoclass in (mesh.meshes, subproblemcontext.subproblems))
     MaterialWidget.__init__(self, param, scope, name)
     self.sbcallbacks.append(
         switchboard.requestCallbackMain(self.meshwidget, self.update))
예제 #15
0
    def __init__(self, param, scope, name=None):
        meshparamwidgets.SubProblemFluxParameterWidget.__init__(self, param,
                                                                scope, name)

        self.meshChangedCB()
        self.sbcallbacks += [switchboard.requestCallbackMain(
            ('new who', 'Mesh'), self.meshChangedCB)]
예제 #16
0
 def __init__(self, param, scope, name=None):
     MeshParamWidget.__init__(self, param,
                               mesh.Mesh.visiblePointBoundaryNames,
                               scope, name=name)
     self.sbcallbacks.append(
         switchboard.requestCallbackMain('mesh boundaries changed',
                                     self.newBdys) )
예제 #17
0
    def __init__(
        self, registry, obj=None, title=None, callback=None, fill=0, expand=0, scope=None, name=None, *args, **kwargs
    ):

        self.scheduleTypeWidget = scope.findWidget(
            lambda w: (
                isinstance(w, regclassfactory.RegisteredClassFactory)
                and w.registry is outputschedule.ScheduleType.registry
            )
        )

        regclassfactory.RegisteredClassFactory.__init__(
            self,
            registry,
            obj=obj,
            title=title,
            callback=callback,
            fill=fill,
            expand=expand,
            scope=scope,
            name=name,
            *args,
            **kwargs
        )

        self.sbcb = switchboard.requestCallbackMain(self.scheduleTypeWidget, self.typechanged)
예제 #18
0
 def __init__(self, registry, obj=None, scope=None, name=None):
     self.nonlinSolverWidget = scope.findWidget(
         lambda w: (isinstance(w, regclassfactory.RegisteredClassFactory)
                    and w.registry is nonlinearsolver.NonlinearSolverBase.registry))
     regclassfactory.RegisteredClassFactory.__init__(
         self, registry, obj=obj, scope=scope, name=name)
     self.sbcb = switchboard.requestCallbackMain(self.nonlinSolverWidget,
                                                 self.linchanged)
예제 #19
0
    def __init__(self, scope, name=None):
        # Find the associated mesh widget
        self.meshwidget = scope.findWidget(
            lambda x: isinstance(x, whowidget.WhoWidget)
            and x.whoclass is mesh.meshes)

        MeshTimeWidgetBase.__init__(self, scope, name)
        self.getTimes()

        self.widgetChanged(self.currentMeshContext() is not None,
                           interactive=False)
        self.sbcallbacks.extend([
            switchboard.requestCallbackMain(self.meshwidget, self.meshwidgetCB),
            switchboard.requestCallbackMain("mesh changed", self.meshwidgetCB),
            switchboard.requestCallbackMain("mesh data changed",
                                            self.meshwidgetCB)
            ])
예제 #20
0
 def activate(self):
     toolboxGUI.GfxToolbox.activate(self)
     self.gfxwindow().setMouseHandler(self)
     if config.dimension() == 2: 
         gtklogger.log_motion_events(self.gfxwindow().oofcanvas.rootitem())
     self.sbcallbacks = [
         switchboard.requestCallbackMain(('who changed', 'Skeleton'),
                                         self.skelChanged),
         switchboard.requestCallbackMain((self.gfxwindow(),
                                          'layers changed'),
                                         self.update),
         switchboard.requestCallbackMain("new pinned nodes",
                                         self.newPinState)
         ]
     self.update()
     if config.dimension() == 3:
         self.gfxwindow().toolbar.setSelect()
예제 #21
0
    def __init__(self, pixelselecttoolbox, method):
        debug.mainthreadTest()
        if config.dimension() == 2:
            name = "Pixel Selection"
        elif config.dimension() == 3:
            name = "Voxel Selection"
        genericselectGUI.GenericSelectToolboxGUI.__init__(self, name, pixelselecttoolbox, method)

        # Switchboard callbacks that should be performed even when the
        # toolbox isn't active go here.  Callbacks that are performed
        # only when the toolbox IS active are installed in activate().
        self.sbcallbacks.extend(
            [
                switchboard.requestCallbackMain("new pixel selection", self.newSelection),
                switchboard.requestCallbackMain((self.gfxwindow(), "layers changed"), self.layerChangeCB),
            ]
        )
예제 #22
0
    def __init__(self, *parameters, **kwargs):
        debug.mainthreadTest()
        # A title for the dialog box can be specified by a REQUIRED
        # 'title' keyword argument.  A WidgetScope can be specified
        # with a 'scope' keyword.  If a parent window is specified
        # with the 'parentwindow' argument, the dialog will be brought
        # up as a transient window for it.
        try:
            scope = kwargs['scope']
        except KeyError:
            scope = None
        widgetscope.WidgetScope.__init__(self, scope)

        try:
            data_dict = kwargs['dialog_data']
        except KeyError:
            pass
        else:
            self.__dict__.update(data_dict)

        try:
            parentwindow = kwargs['parentwindow']
        except KeyError:
            parentwindow=None

        try:
            scopedata = kwargs['data']
        except KeyError:
            pass
        else:
            for key,value in scopedata.items():
                self.setData(key, value)
            
        self.parameters = parameters
        self.dialog = gtklogger.Dialog(parent=parentwindow,
                                       flags=gtk.DIALOG_MODAL)
        try:
            title = kwargs['title']
        except KeyError:
            raise ooferror.ErrPyProgrammingError("Untitled dialog!")
        gtklogger.newTopLevelWidget(self.dialog, 'Dialog-'+kwargs['title'])

        self.dialog.set_title(title)
        hbox = gtk.HBox()
        self.dialog.vbox.pack_start(hbox, expand=0, fill=0, padding=5)
        hbox.pack_start(gtk.Label(title), expand=1, fill=1, padding=10)

        self._button_hook()

        self.table = ParameterTable(parameters, scope=self)
        self.sbcallback = switchboard.requestCallbackMain(
            ('validity', self.table),
            self.validityCB)
        self.dialog.vbox.pack_start(self.table.gtk,
                                    expand=self.table.expandable,
                                    fill=True)
        self.response = None
        self.sensitize()
예제 #23
0
 def __init__(self, value, scope, name):
     self.invariandwidget = scope.findWidget(
         lambda w: isinstance(w, meshparamwidgets.InvariandWidget))
     self.findInvariand()
     regclassfactory.RegisteredClassFactory.__init__(
         self, invariant.InvariantPtr.registry, scope=scope, name=name)
     if value is not None:
         self.set(value, interactive=0)
     self.sbcallback = switchboard.requestCallbackMain(
         self.invariandwidget, self.invWidgetChanged)
예제 #24
0
 def __init__(self, fpsw, scope=None, label=""):
     debug.mainthreadTest()
     self.fpsw = fpsw  # parent FluxProfileSetWidget
     self.gtk = gtk.HBox()
     self.label = gtk.Label(label + " = ")
     self.widget = regclassfactory.RegisteredClassFactory(profile.ProfileXT.registry, scope=scope, name=label)
     self.sbcb = switchboard.requestCallbackMain(self.widget, self.rcfCB)
     self.gtk.pack_start(self.label, expand=0, fill=0)
     self.gtk.pack_start(self.widget.gtk, expand=1, fill=1)
     self.show()
예제 #25
0
 def __init__(self, param, scope=None, name=None):
     self.groupchooser = chooser.ChooserWidget([], name=name)
     parameterwidgets.ParameterWidget.__init__(self, self.groupchooser.gtk,
                                               scope=scope)
     self.mswidget = self.scope.findWidget(
         lambda w: isinstance(w, whowidget.WhoWidget)
         and w.whoclass is ooflib.common.microstructure.microStructures)
     self.update()
     if param.value is not None:
         self.set_value(param.value)
     self.sbcallbacks = [
         switchboard.requestCallbackMain(self.mswidget, self.update),
         switchboard.requestCallbackMain("new pixel group", self.update),
         switchboard.requestCallbackMain("renamed pixel group",
                                         self.update),
         switchboard.requestCallbackMain("destroy pixel group",
                                         self.update),
         switchboard.requestCallbackMain(self.groupchooser, self.chooserCB)
         ]
예제 #26
0
 def __init__(self, param, scope=None, name=None):
     parameterwidgets.BooleanWidget.__init__(self, param, scope, name)
     self.fileSelector = self.scope.findWidget(
         lambda x: (isinstance(x, (WriteFileSelectorWidget,
                                   FakeFileSelectorWidget))))
     if self.fileSelector is None:
         raise ooferror.ErrPyProgrammingError("Can't find file selector")
     self.set_validity()
     self.sbcallback = switchboard.requestCallbackMain(self.fileSelector,
                                                       self.fileSelectorCB)
예제 #27
0
 def __init__(self, value, scope=None, name=None,
              condition=whoville.noSecretClasses):
     self.chooser = chooser.ChooserWidget(whoville.classNames(condition),
                                          callback=self.chooserCB,
                                          name=name)
     parameterwidgets.ParameterWidget.__init__(self, self.chooser.gtk, scope)
     self.sb = switchboard.requestCallbackMain('new who class',
                                               self.newWhoClass)
     self.set_value(value)
     self.condition = condition
예제 #28
0
    def __init__(self, param, scope=None, name=None):
        self.widget = chooser.ScrolledMultiListWidget([],
                                                      callback=self.widgetCB)

        parameterwidgets.ParameterWidget.__init__(self, self.widget.gtk,
                                                  scope=scope, name=name,
                                                  expandable=True)
        self.mswidget = self.scope.findWidget(
            lambda w: isinstance(w, whowidget.WhoWidget)
            and w.whoclass is ooflib.common.microstructure.microStructures)
        self.interfacematwidget = self.scope.findWidget(
            lambda w: isinstance(w, materialwidget.InterfaceMaterialWidget))
        self.update()
        if param.value is not None:
            self.widget.set_selection(param.value)
        self.sbcallbacks = [
            switchboard.requestCallbackMain(self.mswidget, self.update),
            switchboard.requestCallbackMain(self.interfacematwidget, self.update)
            ]
예제 #29
0
 def __init__(self, param, scope=None, name=None):
     self.chooser = chooser.ChooserWidget([], name=name)
     parameterwidgets.ParameterWidget.__init__(self, self.chooser.gtk, scope)
     self.update()
     if param.value is not None:
         self.set_value(param.value)
     self.sbcallbacks = [
         switchboard.requestCallbackMain("named analyses changed",
                                         self.update)
         ]
예제 #30
0
 def __init__(self, mode, tb):
     self.mode = mode
     genericselectGUI.GenericSelectToolboxGUI.__init__(self, mode.name,
                                                       tb, mode.methodclass)
     # Switchboard callbacks that should be performed even when the
     # toolbox isn't active go here.  Callbacks that are performed
     # only when the toolbox IS active are installed in activate().
     self.sbcallbacks.append(
         switchboard.requestCallbackMain(self.mode.newselectionsignal,
                                         self.newSelection)
         )
예제 #31
0
    try:
        _updatePBdisplayNow(progressid)
    finally:
        gtk.gdk.threads_leave()
    return False


def _updatePBdisplayNow(progressid):
    debug.mainthreadTest()
    # Don't do anything unless threads are enabled and the gui has
    # been started.
    if thread_enable.query() and guitop.top():
        prog = progress.findProgressByID(progressid)
        if prog is not None and not (prog.finished() or prog.stopped()):
            # Create just one activity viewer.  If it's been opened
            # and closed already, don't reopen it automatically.
            if not _activityViewerOpened:
                # The newly created Activity Viewer window
                # automatically calls installBar for every existing
                # Progress object, including the one identified by the
                # argument to this routine.
                openActivityViewer()
            else:
                # The Activity Viewer might have been closed, in which
                # case activityViewer is None.
                if activityViewer is not None:
                    activityViewer.addGTKBar(prog)


switchboard.requestCallbackMain("new progress", delayed_add_ProgressBar)
예제 #32
0
 def activate(self):
     genericselectGUI.GenericSelectToolboxGUI.activate(self)
     self.activecallbacks = [
         switchboard.requestCallbackMain('pixel selection changed',
                                         self.changedSelection)
     ]
예제 #33
0

def _warning_pop_up(message):
    if reporter.messagemanager.get_warning_pop_up():
        popup = WarningPopUp(message)
        result = popup.run()
        popup.close()
        if result == WarningPopUp.NO_MORE:
            ## This used to call OOF.Help.Popup_warnings(0), but menu
            ## items shouldn't call other menu items, and the warning
            ## was presumably triggered by a menu item, so it can't
            ## call OOF.Help.etc here.
            reporter.messagemanager.set_warning_pop_up(False)


switchboard.requestCallbackMain("messagemanager warning", _warning_pop_up)

#=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=#

# The error pop up optionally allows you to view the traceback,
# and save it to a file.  The file is automatically named.


class ErrorPopUp:
    OK = 1
    ABORT = 2

    def __init__(self, e_type, value, tbacklist):
        debug.mainthreadTest()

        errorstrings = []  # list of strings
예제 #34
0
    fontname = fontselector.getFontName()
    if fontname:
        menuitem.callWithDefaults(fontname=fontname)


mainmenu.OOF.Settings.Fonts.Widgets.add_gui_callback(setFont_gui)


def reallySetFont(fontname):
    debug.mainthreadTest()
    settings = gtk.settings_get_default()
    settings.set_property("gtk-font-name", fontname)
    switchboard.notify('gtk font changed')


switchboard.requestCallbackMain('change font', reallySetFont)

##############################

# The text font is actually set by the widgets that use it. This code
# here just sets up the callback to get the font, and also stores it
# where it can be found by new widgets.

fixedfont = "Mono 12"
mainmenu.OOF.Settings.Fonts.Fixed.add_gui_callback(setFont_gui)


def setFixedFont(fontname):
    global fixedfont
    fixedfont = fontname
예제 #35
0
 def newLayer(self):
     toolbox = self.gfxwindow.getToolboxByName("Voxel Info")
     self.tbcallback = switchboard.requestCallbackMain(toolbox, self.update)
     return canvaslayers.SingleVoxelLayer(self.gfxwindow.oofcanvas,
                                          "PixelInfo")
예제 #36
0
    def __init__(self):
        oofGUI.MainPage.__init__(
            self, name="Solver",
            ordering=240,
            tip="Find solutions for static and time-dependent problems.")
        mainbox = gtk.VBox(spacing=2)
        self.gtk.add(mainbox)

        align = gtk.Alignment(xalign=0.5)
        mainbox.pack_start(align, expand=0, fill=0)
        centerbox = gtk.HBox(spacing=3)
        align.add(centerbox)
        self.meshwidget = whowidget.WhoWidget(ooflib.engine.mesh.meshes,
                                              scope=self)
        switchboard.requestCallbackMain(self.meshwidget, self.meshCB)
        label = gtk.Label("Microstructure=")
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        centerbox.pack_start(self.meshwidget.gtk[0], expand=0, fill=0)

        label = gtk.Label("Skeleton=")
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        centerbox.pack_start(self.meshwidget.gtk[1], expand=0, fill=0)

        label = gtk.Label("Mesh=")
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        centerbox.pack_start(self.meshwidget.gtk[2], expand=0, fill=0)

        mainvpane = gtk.VPaned()
        gtklogger.setWidgetName(mainvpane, 'VPane')
        mainbox.pack_start(mainvpane, expand=1, fill=1)
        gtklogger.connect_passive(mainvpane, 'notify::position')

        # Subproblem pane

        ## TODO 3.1: Make it possible to reorder the subproblems by
        ## drag and drop.

        subprobframe = gtk.Frame('Solvers')
        gtklogger.setWidgetName(subprobframe, "Subproblems")
        subprobframe.set_shadow_type(gtk.SHADOW_IN)
        mainvpane.pack1(subprobframe, resize=1, shrink=0)
        subpvbox = gtk.VBox()   # contains scrolled list and buttons
        subpvbox.set_border_width(3)
        subprobframe.add(subpvbox)
        innerframe = gtk.Frame()
        innerframe.set_shadow_type(gtk.SHADOW_IN)
        subpvbox.pack_start(innerframe, expand=1, fill=1)
        self.subpScroll = gtk.ScrolledWindow()
        gtklogger.logScrollBars(self.subpScroll, "SubproblemScroll")
        self.subpScroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        innerframe.add(self.subpScroll)

        self.subprobList = gtk.ListStore(gobject.TYPE_PYOBJECT)
        self.subpListView = gtk.TreeView(self.subprobList)
        gtklogger.setWidgetName(self.subpListView, "SubproblemList")
        self.subpScroll.add(self.subpListView)
        gtklogger.adoptGObject(self.subprobList, self.subpListView,
                               access_method=self.subpListView.get_model)
        # Catch selection changes
        gtklogger.adoptGObject(self.subpListView.get_selection(),
                               self.subpListView,
                               access_method=self.subpListView.get_selection)
        self.subpselsig = gtklogger.connect(self.subpListView.get_selection(),
                                            'changed', self.subpSelectCB)
        # Catch double clicks or returns
        gtklogger.connect(self.subpListView, 'row-activated',
                          self.subpActivateRowCB)

        # Order number in the first column
        ordercell = gtk.CellRendererText()
        ordercol = gtk.TreeViewColumn("Order")
        ordercol.set_resizable(False)
        ordercol.pack_start(ordercell, expand=False)
        ordercol.set_cell_data_func(ordercell, self.renderSubproblemOrder)
        self.subpListView.append_column(ordercol)
        # Checkbox in the second column
        solvecell = gtk.CellRendererToggle()
        solvecol = gtk.TreeViewColumn("Solve?")
        solvecol.pack_start(solvecell, expand=False)
        solvecol.set_cell_data_func(solvecell, self.renderSolveCell)
        self.subpListView.append_column(solvecol)
        gtklogger.adoptGObject(solvecell, self.subpListView,
                               access_function=gtklogger.findCellRenderer,
                               access_kwargs={'col':1, 'rend':0})
        gtklogger.connect(solvecell, 'toggled', self.solvecellCB)
        # Subproblem name in the third column
        namecell = gtk.CellRendererText()
        namecol = gtk.TreeViewColumn("Subproblem")
        namecol.set_resizable(True)
        namecol.pack_start(namecell, expand=True)
        namecol.set_cell_data_func(namecell, self.renderSubproblemName)
        self.subpListView.append_column(namecol)
        # Solver in the fourth column
        solvercell = gtk.CellRendererText()
        solvercol = gtk.TreeViewColumn("Solver")
        solvercol.set_resizable(True)
        solvercol.pack_start(solvercell, expand=True)
        solvercol.set_cell_data_func(solvercell, self.renderSubproblemSolver)
        self.subpListView.append_column(solvercol)

        # Buttons at the bottom of the subproblem pane
        subpbbox = gtk.HBox(homogeneous=True)
        subpvbox.pack_start(subpbbox, expand=0, fill=0)
        # Set Solver
        self.setSolverButton = gtkutils.StockButton(gtk.STOCK_ADD, "Set...")
        gtklogger.setWidgetName(self.setSolverButton, "Set")
        gtklogger.connect(self.setSolverButton, 'clicked', self.setSolverCB)
        subpbbox.pack_start(self.setSolverButton, expand=0, fill=1)
        tooltips.set_tooltip_text(self.setSolverButton,
            "Assign a solver to the selected subproblem.")
        # Copy Solver
        self.copySolverButton = gtkutils.StockButton(gtk.STOCK_COPY, "Copy...")
        gtklogger.setWidgetName(self.copySolverButton, "Copy")
        gtklogger.connect(self.copySolverButton, 'clicked', self.copySolverCB)
        subpbbox.pack_start(self.copySolverButton, expand=0, fill=1)
        tooltips.set_tooltip_text(
            self.copySolverButton,
            "Copy the selected solver to another subproblem,"
            " possibly in another mesh.")
        # Copy All Solvers
        self.copyAllSolversButton = gtkutils.StockButton(gtk.STOCK_COPY,
                                                         "Copy All...")
        gtklogger.setWidgetName(self.copyAllSolversButton, "CopyAll")
        gtklogger.connect(self.copyAllSolversButton, 'clicked',
                          self.copyAllSolversCB)
        subpbbox.pack_start(self.copyAllSolversButton, expand=0, fill=1)
        tooltips.set_tooltip_text(
            self.copyAllSolversButton,
            "Copy all solvers to identically named subproblems in another mesh.")
        # Remove Solver
        self.removeSolverButton = gtkutils.StockButton(gtk.STOCK_REMOVE,
                                                       "Remove")
        gtklogger.setWidgetName(self.removeSolverButton, "Remove")
        gtklogger.connect(self.removeSolverButton, 'clicked',
                          self.removeSolverCB)
        subpbbox.pack_start(self.removeSolverButton, expand=0, fill=1)
        tooltips.set_tooltip_text(self.removeSolverButton,
            "Delete the solver from the selected subproblem.")
        # Remove all solvers
        self.removeAllSolversButton = gtkutils.StockButton(gtk.STOCK_CLEAR,
                                                           "Remove All")
        gtklogger.setWidgetName(self.removeAllSolversButton, "RemoveAll")
        gtklogger.connect(self.removeAllSolversButton, 'clicked',
                          self.removeAllSolversCB)
        subpbbox.pack_start(self.removeAllSolversButton, expand=0, fill=1)
        tooltips.set_tooltip_text(self.removeAllSolversButton,
            "Remove the solver from all subproblems.")
        # Second row of buttons at the bottom of the subproblem pane
        subpbbox = gtk.HBox(homogeneous=True)
        subpvbox.pack_start(subpbbox, expand=0, fill=0)
        # Solve this subproblem first
        self.firstButton = gtkutils.StockButton(gtk.STOCK_GOTO_FIRST, "First",
                                                align=0.0)
        gtklogger.setWidgetName(self.firstButton, "First")
        gtklogger.connect(self.firstButton, 'clicked', self.firstButtonCB)
        subpbbox.pack_start(self.firstButton, expand=0, fill=1)
        tooltips.set_tooltip_text(
            self.firstButton,
            "Solve the selected subproblem first when iterating"
            " over subproblems.")
        # Solve this subproblem earlier
        self.earlierButton = gtkutils.StockButton(gtk.STOCK_GO_BACK, "Earlier",
                                                  align=0.0)
        gtklogger.setWidgetName(self.earlierButton, "Earlier")
        gtklogger.connect(self.earlierButton, 'clicked', self.earlierButtonCB)
        subpbbox.pack_start(self.earlierButton, expand=0, fill=1)
        tooltips.set_tooltip_text(
            self.earlierButton,
            "Solve the selected subproblem before the one above it"
            " in the list when iterating over subproblems.")
        # Solve this subproblem later
        self.laterButton = gtkutils.StockButton(gtk.STOCK_GO_FORWARD, "Later",
                                                reverse=True, align=1.0)
        gtklogger.setWidgetName(self.laterButton, "Later")
        gtklogger.connect(self.laterButton, 'clicked', self.laterButtonCB)
        subpbbox.pack_start(self.laterButton, expand=0, fill=1)
        tooltips.set_tooltip_text(
            self.laterButton,
            "Solve the selected subproblem after the next one in the"
            " list when iterating over subproblems.")
        # Solve this subproblem last
        self.lastButton = gtkutils.StockButton(gtk.STOCK_GOTO_LAST, "Last",
                                               reverse=True, align=1.0)
        gtklogger.setWidgetName(self.lastButton, "Last")
        gtklogger.connect(self.lastButton, 'clicked', self.lastButtonCB)
        subpbbox.pack_start(self.lastButton, expand=0, fill=1)
        tooltips.set_tooltip_text(
            self.lastButton,
            "Solve the selected subproblem last when iterating"
            " over subproblems.")

        # Field Initializers
        initframe = gtk.Frame('Initialization')
        gtklogger.setWidgetName(initframe, "FieldInit")
        initframe.set_shadow_type(gtk.SHADOW_IN)
        mainvpane.pack2(initframe, resize=1, shrink=0)
        ivbox = gtk.VBox()
        ivbox.set_border_width(3)
        initframe.add(ivbox)
        self.initscroll = gtk.ScrolledWindow()
        gtklogger.logScrollBars(self.initscroll, "Scroll")
        self.initscroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.initscroll.set_shadow_type(gtk.SHADOW_IN)
        ivbox.pack_start(self.initscroll, expand=1, fill=1)
        # The ListStore just contains the defined Fields.  The
        # TreeView displays their names and initializers.
        self.initlist = gtk.ListStore(gobject.TYPE_PYOBJECT)
        self.initview = gtk.TreeView(self.initlist)
        gtklogger.setWidgetName(self.initview, 'Initializers')
        self.initscroll.add(self.initview)
        self.initview.set_headers_clickable(False)
        fieldnamecell = gtk.CellRendererText()
        fieldnamecol = gtk.TreeViewColumn('Field or BC')
        self.initview.append_column(fieldnamecol)
        fieldnamecol.pack_start(fieldnamecell, expand=False)
        fieldnamecol.set_cell_data_func(fieldnamecell, self.renderFieldName)

        fieldinitcell = gtk.CellRendererText()
        fieldinitcol = gtk.TreeViewColumn('Initializer')
        self.initview.append_column(fieldinitcol)
        fieldinitcol.pack_start(fieldinitcell, expand=True)
        fieldinitcol.set_cell_data_func(fieldinitcell, self.renderFieldInit)

        selection = self.initview.get_selection()
        gtklogger.adoptGObject(selection, self.initview,
                               access_method=self.initview.get_selection)
        self.initselsignal = gtklogger.connect(selection, 'changed',
                                               self.initSelectCB)
        gtklogger.connect(self.initview, 'row-activated',
                          self.initActivateRowCB)

        bbox = gtk.HBox(homogeneous=True)
        ivbox.pack_start(bbox, expand=0, fill=0)
        # Set button
        self.fieldinitbutton=gtkutils.StockButton(gtk.STOCK_ADD, 'Set...')
        gtklogger.setWidgetName(self.fieldinitbutton, "Set")
        gtklogger.connect(self.fieldinitbutton, 'clicked',
                          self.fieldinitbuttonCB)
        tooltips.set_tooltip_text(
            self.fieldinitbutton,'Initialized the selected field.')
        bbox.pack_start(self.fieldinitbutton, expand=0, fill=1)
        # Copy button
        self.copyinitbutton = gtkutils.StockButton(gtk.STOCK_COPY,
                                                   "Copy All...")
        gtklogger.setWidgetName(self.copyinitbutton, 'CopyInit')
        gtklogger.connect(self.copyinitbutton, 'clicked', self.copyinitCB)
        bbox.pack_start(self.copyinitbutton, expand=0, fill=1)
        tooltips.set_tooltip_text(self.copyinitbutton,
            "Copy field initializers from the current mesh to another mesh.")
        # Clear Initializer button
        self.clearinitbutton = gtkutils.StockButton(gtk.STOCK_REMOVE, "Clear")
        gtklogger.setWidgetName(self.clearinitbutton, "Clear")
        gtklogger.connect(self.clearinitbutton, 'clicked', self.clearinitCB)
        bbox.pack_start(self.clearinitbutton, expand=0, fill=1)
        tooltips.set_tooltip_text(self.clearinitbutton,
            "Remove the selected field initializer from the current mesh.")
        # Clear All Initializers button
        self.clearallinitsbutton = gtkutils.StockButton(gtk.STOCK_CLEAR,
                                                        "Clear All")
        gtklogger.setWidgetName(self.clearallinitsbutton, 'ClearAll')
        gtklogger.connect(self.clearallinitsbutton, 'clicked',
                          self.clearallinitsCB)
        bbox.pack_start(self.clearallinitsbutton, expand=0, fill=1)
        tooltips.set_tooltip_text(self.clearallinitsbutton,
            "Remove the field initializers from the current mesh.")

        # Second row of buttons in the Field Initialization pane
        bbox = gtk.HBox(homogeneous=True)
        ivbox.pack_start(bbox, expand=0, fill=1)
        # Apply button
        self.applyinitbutton = gtkutils.StockButton(gtk.STOCK_APPLY, "Apply")
        gtklogger.setWidgetName(self.applyinitbutton, "Apply")
        gtklogger.connect(self.applyinitbutton, 'clicked', self.applyinitCB)
        tooltips.set_tooltip_text(self.applyinitbutton,
            "Apply initializers to all fields at the current time.")
        bbox.pack_start(self.applyinitbutton, expand=0, fill=1)
        # Apply At button
        self.applyinitattimebutton = gtkutils.StockButton(gtk.STOCK_APPLY,
                                                          "Apply at time...")
        gtklogger.setWidgetName(self.applyinitattimebutton, "ApplyAt")
        gtklogger.connect(self.applyinitattimebutton, 'clicked',
                          self.applyinitatCB)
        tooltips.set_tooltip_text(self.applyinitattimebutton,
            "Reset the current time and apply all field initializers.")
        bbox.pack_start(self.applyinitattimebutton, expand=0, fill=1)

        # Table containing status, time entries and Solve button
        table = gtk.Table(rows=2, columns=4)
        mainbox.pack_start(table, expand=0, fill=1)

        # The start time isn't set directly by the user, except by
        # applying field initializers at a given time.  It's displayed
        # in a desensitized gtk.Entry.
        label = gtk.Label('current time=')
        label.set_alignment(1.0, 0.5)
        table.attach(label, 0,1, 0,1, xpadding=3, xoptions=~gtk.EXPAND)
        self.currentTimeEntry = gtk.Entry()
        self.currentTimeEntry.set_sensitive(False) # never sensitive
        table.attach(self.currentTimeEntry, 1,2, 0,1, xpadding=3)
        
        # End time is set by the user.
        label = gtk.Label('end time=')
        label.set_alignment(1.0, 0.5)
        table.attach(label, 0,1, 1,2, xpadding=3, xoptions=~gtk.EXPAND)
        self.endtimeEntry = gtk.Entry()
        gtklogger.setWidgetName(self.endtimeEntry, 'end')
        gtklogger.connect(self.endtimeEntry, 'changed', self.timeChangeCB)
        table.attach(self.endtimeEntry, 1,2, 1,2, xpadding=3)

        statusFrame = gtk.Frame("Status")
        statusFrame.set_shadow_type(gtk.SHADOW_IN)
        vbox = gtk.VBox()
        statusFrame.add(vbox)
        self.statusLabel = gtk.Label()
        self.statusLabel.set_alignment(0.5, 0.5)
        table.attach(statusFrame, 2,3, 0,3, xpadding=3)
        vbox.pack_start(self.statusLabel, expand=0, fill=0)
        align = gtk.Alignment(xalign=0.5)
        vbox.pack_start(align, expand=0, fill=0, padding=3)
        self.statusDetailButton = gtk.Button("Details...")
        gtklogger.setWidgetName(self.statusDetailButton, 'status')
        gtklogger.connect(self.statusDetailButton, 'clicked', self.statusCB)
        align.add(self.statusDetailButton)

        solveFrame0 = gtk.Frame()
        solveFrame0.set_shadow_type(gtk.SHADOW_OUT)
        solveFrame1 = gtk.Frame()
        solveFrame1.set_shadow_type(gtk.SHADOW_IN)
        solveFrame0.add(solveFrame1)
        table.attach(solveFrame0, 3,4, 0,3, xpadding=3,
                     xoptions=~gtk.EXPAND)
        self.solveButton = gtkutils.StockButton(gtk.STOCK_EXECUTE,
                                                '<b>Solve</b>', markup=True)
        self.solveButton.set_border_width(4)
        gtklogger.setWidgetName(self.solveButton, 'solve')
        gtklogger.connect(self.solveButton, 'clicked', self.solveCB)
        solveFrame1.add(self.solveButton)

        switchboard.requestCallbackMain("field defined", self.defineFldCB)
        switchboard.requestCallbackMain("field initializer set", self.initFldCB)
        switchboard.requestCallbackMain("subproblem changed",
                                        self.subproblemsChangedCB)
        switchboard.requestCallbackMain("mesh changed",
                                        self.subproblemsChangedCB)
        switchboard.requestCallbackMain("subproblem solvability changed",
                                        self.subpSolverChangedCB)
        switchboard.requestCallbackMain("subproblem solver changed",
                                        self.subpSolverChangedCB)
        switchboard.requestCallbackMain("subproblem solvers changed",
                                        self.subpSolversChangedCB),
        switchboard.requestCallbackMain("subproblems reordered",
                                        self.subproblemsChangedCB),
        switchboard.requestCallbackMain(("new who", "SubProblem"),
                                        self.subproblemsChangedCB)
        switchboard.requestCallbackMain(("rename who", "SubProblem"),
                                        self.subproblemsChangedCB)
        switchboard.requestCallbackMain(("remove who", "SubProblem"),
                                        self.subproblemsChangedCB)
        switchboard.requestCallbackMain("time changed",
                                        self.meshTimeChangedCB)
        switchboard.requestCallbackMain("mesh solved", self.meshSolvedCB)
        switchboard.requestCallbackMain("mesh status changed",
                                        self.statusChangedCB)
        switchboard.requestCallbackMain("made reservation",
                                        self.reservationCB)
        switchboard.requestCallbackMain("cancelled reservation",
                                        self.reservationCB)
예제 #37
0
    def __init__thread(self, gfxwindow, time, position, output):
        debug.mainthreadTest()
        allMeshDataWindows.append(self)
        widgetscope.WidgetScope.__init__(self, None)

        current_count = MeshDataGUI.count
        MeshDataGUI.count += 1
        self._name = "Mesh_Data_%d" % current_count
        self.output = output
        self.time = time
        self.position = position
        self.sbcallbacks = []
        self.gsbcallbacks = []          # callbacks from a specific gfx window
        self.updateLock = lock.Lock()

        self.outputparam = \
                     ooflib.engine.IO.output.ValueOutputParameter('output')

        # Although it's not displayed, we need a mesh widget in the
        # widgetscope, or the OutputParameterWidget won't work.
        # TODO 3.1: Is this ugly, or what?
        self.meshWidget = whowidget.WhoWidget(mesh.meshes, scope=self,
                                              name="Godot")

        self.gtk = gtk.Window(gtk.WINDOW_TOPLEVEL)
        title = utils.underscore2space(self._name)
        self.gtk.set_title(title)
        gtklogger.newTopLevelWidget(self.gtk, title)
        gtklogger.connect_passive(self.gtk, 'delete-event')
        gtklogger.connect_passive(self.gtk, 'configure-event')
        self.mainbox = gtk.VBox()
        self.gtk.add(self.mainbox)

        # Put this window into the Windows menu.  The menu item can't
        # be logged, since the creation and operation of the window
        # aren't logged, so scripts shouldn't refer to it at all.
        mainmenu.OOF.Windows.Mesh_Data.addItem(oofmenu.OOFMenuItem(
            self._name,
            no_log=1,
            help="Raise Mesh Data window %d." % current_count,
            threadable=oofmenu.UNTHREADABLE,
            callback=self.raiseWindow))

        expander = gtk.Expander("Source")
        gtklogger.setWidgetName(expander, 'ViewSource')
        gtklogger.connect_passive_after(expander, 'activate')
        self.mainbox.pack_start(expander)
        expander.set_expanded(1)
        
        self.table = gtk.Table(rows=config.dimension()+4, columns=2)
        expander.add(self.table)

        label = gtk.Label("Source Window:")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label, 0,1, 0,1, xpadding=3, xoptions=gtk.FILL)
        tooltips.set_tooltip_text(label,
            "Display data for mouse clicks in this Graphics window.")

        self.gfxWindowChooser = chooser.ChooserWidget([],
                                                      callback=self.chooserCB,
                                                      name='GfxWindow')
        self.table.attach(self.gfxWindowChooser.gtk, 1,2, 0,1,
                     xpadding=3, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0)


        label = gtk.Label("Mesh:")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label, 0,1, 1,2,
                          xpadding=3, xoptions=gtk.FILL, yoptions=0)
        tooltips.set_tooltip_text(label,
                                  "Data is displayed for values on this mesh.")

        self.meshText = gtk.Entry()
        gtklogger.setWidgetName(self.meshText, "meshname")
        self.meshText.set_editable(False)
        self.meshText.set_size_request(12*guitop.top().charsize, -1)
        self.table.attach(self.meshText, 1,2, 1,2,
                          xpadding=3, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0)

        # Position controls
        label = gtk.Label("position x:")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label, 0,1, 2,3,
                          xpadding=3, xoptions=gtk.FILL, yoptions=0)
        self.xText = gtk.Entry()
        gtklogger.setWidgetName(self.xText, 'x')
        self.xText.set_size_request(12*guitop.top().digitsize, -1)
        self.table.attach(self.xText, 1,2, 2,3,
                          xpadding=3, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0)
        self.xsignal = gtklogger.connect(self.xText, 'changed',
                                         self.posChangedCB)

        label = gtk.Label("position y:")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label, 0,1, 3,4,
                          xpadding=3, xoptions=gtk.FILL, yoptions=0)
        self.yText = gtk.Entry()
        gtklogger.setWidgetName(self.yText, 'y')
        self.yText.set_size_request(12*guitop.top().digitsize, -1)
        self.table.attach(self.yText, 1,2, 3,4,
                          xpadding=3, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0)
        self.ysignal = gtklogger.connect(self.yText, 'changed',
                                         self.posChangedCB)

        if config.dimension() == 3:
            label = gtk.Label("position z:")
            label.set_alignment(1.0, 0.5)
            self.table.attach(label, 0,1, 4,5,
                              xpadding=3, xoptions=gtk.FILL, yoptions=0)
            self.zText = gtk.Entry()
            gtklogger.setWidgetName(self.zText, 'z')
            self.zText.set_size_request(12*guitop.top().digitsize, -1)
            self.table.attach(self.zText, 1,2, 4,5, xpadding=3, 
                              xoptions=gtk.EXPAND|gtk.FILL, yoptions=0)
            self.zsignal = gtklogger.connect(self.zText, 'changed', 
                                             self.posChangedCB)
            timerow = 5
        else:
            timerow = 6

        # Time controls.  Typing in the time widget does not
        # immediately update the displayed data, because interpolating
        # to a new time is an expensive computation, and shouldn't be
        # done while the user is in the middle of typing.  Instead,
        # the time widget is normally desensitized and uneditable.
        # When the user clicks the "Edit" button, the widget becomes
        # editable, the rest of the window is desensitized, and the
        # "Edit" button changes do a "Done" button.  When the user
        # clicks "Done" the data is updated and the time widget
        # becomes uneditable again.
        label = gtk.Label("time:")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label, 0,1, timerow,timerow+1,
                          xpadding=3, xoptions=gtk.FILL, yoptions=0)
        tBox = gtk.HBox(spacing=3)
        self.table.attach(tBox, 1,2, timerow,timerow+1,
                          xpadding=3, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0)
        self.tText = gtk.Entry()
        self.tText.set_editable(False)
        self.tText.set_sensitive(False)
        tBox.pack_start(self.tText, expand=1, fill=1)
        gtklogger.setWidgetName(self.tText, 't')
        self.tText.set_size_request(12*guitop.top().digitsize, -1)
        self.tEditButton = gtk.Button("Edit")
        tBox.pack_start(self.tEditButton, expand=0, fill=0)
        gtklogger.setWidgetName(self.tEditButton, "tEdit")
        gtklogger.connect(self.tEditButton, 'clicked', self.tEditCB)
        self.tEditMode = False
 
        # Output selection
        label = gtk.Label("Output:")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label, 0,1, timerow+2,timerow+3,
                          xpadding=3, xoptions=gtk.FILL, yoptions=0)
        tooltips.set_tooltip_text(label,"Choose which data is displayed.")
        
        self.outputwidget = self.outputparam.makeWidget(scope=self)
        self.table.attach(self.outputwidget.gtk, 1,2, timerow+2,timerow+3,
                          xpadding=3, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0)
        switchboard.requestCallback(self.outputwidget, self.outputwidgetCB)

        # Data display panel
        hbox = gtk.HBox()
        self.mainbox.pack_start(hbox, expand=1, fill=1, padding=5)
        frame = gtk.Frame("Data")
        gtklogger.setWidgetName(frame, 'Data')
        frame.set_shadow_type(gtk.SHADOW_IN)
        hbox.pack_start(frame, expand=1, fill=1, padding=5)
        vbox = gtk.VBox()
        frame.add(vbox)
        self.databox = gtk.HBox()
        vbox.pack_start(self.databox, expand=1, fill=1, padding=3)
        self.datawidget = None       # set by updateData

        # Buttons at the bottom of the window
        buttonbox = gtk.HBox()
        self.mainbox.pack_start(buttonbox, expand=0, fill=0, padding=3)
        # Freeze buttons 
        freezeframe = gtk.Frame("Freeze")
        gtklogger.setWidgetName(freezeframe, "Freeze")
        buttonbox.pack_start(freezeframe, expand=1, fill=1, padding=3)
        hbox = gtk.HBox()
        freezeframe.add(hbox)
        # Freeze Space button
        self.freezeSpaceFlag = False
        self.freezeSpaceButton = gtk.CheckButton('Space')
        gtklogger.setWidgetName(self.freezeSpaceButton, 'Space')
        hbox.pack_start(self.freezeSpaceButton, expand=1, fill=0, padding=0)
        self.freezeSpaceButton.set_active(self.freezeSpaceFlag)
        gtklogger.connect(self.freezeSpaceButton, 'clicked', 
                          self.freezeSpaceButtonCB)
        tooltips.set_tooltip_text(self.freezeSpaceButton,
                        "Prevent the data in this window from being updated when the sample position changes.")
        # Freeze Time button
        self.freezeTimeFlag = False
        self.freezeTimeButton = gtk.CheckButton('Time')
        gtklogger.setWidgetName(self.freezeTimeButton, "Time")
        hbox.pack_start(self.freezeTimeButton, expand=1, fill=0, padding=0)
        self.freezeTimeButton.set_active(self.freezeTimeFlag)
        gtklogger.connect(self.freezeTimeButton,'clicked',
                          self.freezeTimeButtonCB)
        tooltips.set_tooltip_text(self.freezeTimeButton,
            "Prevent the data in this window from being updated when the Mesh's time changes.")

        # Clone button
        self.cloneButton = gtkutils.StockButton(gtk.STOCK_COPY, 'Clone')
        gtklogger.setWidgetName(self.cloneButton, 'Clone')
        gtklogger.connect(self.cloneButton, 'clicked', self.cloneButtonCB)
        buttonbox.pack_start(self.cloneButton, expand=0, fill=0, padding=3)
        tooltips.set_tooltip_text(self.cloneButton,
            "Make a copy of this window with its current settings.")

        # Close button
        self.closeButton = gtk.Button(stock=gtk.STOCK_CLOSE)
        gtklogger.setWidgetName(self.closeButton, 'Close')
        gtklogger.connect(self.closeButton, 'clicked', self.closeButtonCB)
        buttonbox.pack_end(self.closeButton, expand=0, fill=0, padding=3)

        self.gtk.connect('destroy', self.destroyCB)

        self.updateGfxWindowChooser()
        if gfxwindow:
            self.gfxWindowChooser.set_state(gfxwindow.name)
        if position is not None:
            self.updatePosition(position)
        self.currentMesh = None
        self.updateMesh()

        self.setupSwitchboard()         # gfx window dependent callbacks
        self.sbcallbacks += [
            switchboard.requestCallbackMain('open graphics window',
                                            self.gfxwindowChanged),
            switchboard.requestCallbackMain('close graphics window',
                                            self.gfxwindowChanged),
            switchboard.requestCallbackMain('mesh data changed',
                                            self.meshDataChanged),
            switchboard.requestCallbackMain((gfxwindow, "time changed"),
                                            self.timeChanged)
            ]

        
        self.gtk.show_all()
예제 #38
0
newfromimagebutton.set_sensitive(0)


def sensitizeNewFromImageButton():
    newfromimagebutton.set_sensitive(imagecontext.imageContexts.nActual() > 0)


microstructurePage.addNewButton(newfromimagebutton,
                                sensitizeNewFromImageButton)


def newwhoCB(path):
    sensitizeNewFromImageButton()


switchboard.requestCallbackMain(('new who', 'Image'), newwhoCB)
switchboard.requestCallbackMain(('remove who', 'Image'), newwhoCB)

##############


def newMSfromImageFile(button):
    menuitem = microstructuremenu.micromenu.Create_From_ImageFile
    if parameterwidgets.getParameters(
            title='Load Image and create Microstructure', *menuitem.params):
        menuitem.callWithDefaults()


from ooflib.common.IO.GUI import fileselector

예제 #39
0
    def __init__(self):
        oofGUI.MainPage.__init__(
            self,
            name="Analysis",
            ordering=259,
            tip="Query the mesh, examine fields and fluxes.")

        self.timeparam = placeholder.TimeParameter('time', value=0.0)

        mainbox = gtk.VBox()
        self.gtk.add(mainbox)

        align = gtk.Alignment(xalign=0.5)
        mainbox.pack_start(align, expand=0, fill=0)
        centerbox = gtk.HBox(spacing=3)
        align.add(centerbox)
        self.meshwidget = whowidget.WhoWidget(ooflib.engine.mesh.meshes,
                                              scope=self)
        # The mesh widget callback is not required, because the field
        # and flux widgets in the "output" widget (which are members
        # of a parameter table, which is a component of the
        # OutputWidget) are context-sensitive and update themselves
        # automatically.
        label = gtk.Label("Microstructure=")
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        centerbox.pack_start(self.meshwidget.gtk[0], expand=0, fill=0)
        label = gtk.Label("Skeleton=")
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        centerbox.pack_start(self.meshwidget.gtk[1], expand=0, fill=0)
        label = gtk.Label("Mesh=")
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        centerbox.pack_start(self.meshwidget.gtk[2], expand=0, fill=0)

        align = gtk.Alignment(xalign=0.5)
        mainbox.pack_start(align, expand=0, fill=0)
        centerbox = gtk.HBox(spacing=3)
        align.add(centerbox)
        self.timeWidget = self.timeparam.makeWidget(scope=self)
        centerbox.pack_start(gtk.Label("Time:"), expand=0, fill=0)
        centerbox.pack_start(self.timeWidget.gtk, expand=0, fill=0)

        mainvpane = gtk.VPaned()
        mainbox.pack_start(mainvpane, expand=1, fill=1)
        self.topPane = gtk.HPaned()
        gtklogger.setWidgetName(self.topPane, 'top')
        mainvpane.pack1(self.topPane, resize=1, shrink=0)
        self.btmPane = gtk.HPaned()
        gtklogger.setWidgetName(self.btmPane, 'bottom')
        mainvpane.pack2(self.btmPane, resize=1, shrink=0)
        # The four panes (Output, Domain, Operation, and Sampling) are
        # contained in the top and bottom HPaneds.  The dividers
        # between the sub panes are synchronized with each other.
        # Since Paneds don't have a dedicated signal indicating that
        # their dividers have been moved, we have to use the the
        # generic 'notify' signal.
        self.paneSignals = {
            self.topPane:
            gtklogger.connect(self.topPane, 'notify::position',
                              self.paneMovedCB, self.btmPane),
            self.btmPane:
            gtklogger.connect(self.btmPane, 'notify::position',
                              self.paneMovedCB, self.topPane)
        }

        # Output
        self.outputframe = gtk.Frame(label="Output")
        self.outputframe.set_shadow_type(gtk.SHADOW_IN)
        output_scroll = gtk.ScrolledWindow()
        gtklogger.logScrollBars(output_scroll, "Output")
        output_scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        self.outputframe.add(output_scroll)
        output_box = gtk.VBox()

        self.output_obj = outputwidget.ValueOutputParameterWidget(
            value=None, scope=self, name="Outputs")
        output_box.pack_start(self.output_obj.gtk, expand=0, fill=0)

        output_scroll.add_with_viewport(output_box)
        self.topPane.pack1(self.outputframe, resize=1, shrink=pshrink)

        # Operation
        self.operationframe = gtk.Frame(label="Operation")
        self.operationframe.set_shadow_type(gtk.SHADOW_IN)
        op_scroll = gtk.ScrolledWindow()
        gtklogger.logScrollBars(op_scroll, "Operation")
        op_scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        self.op_obj = regclassfactory.RegisteredClassFactory(
            analyze.DataOperation.registry,
            scope=self,
            name="OperationRCF",
            callback=self.newOperationCB)
        self.operationframe.add(op_scroll)

        operation_box = gtk.VBox()
        operation_box.pack_start(self.op_obj.gtk, expand=0, fill=0)
        op_scroll.add_with_viewport(operation_box)
        self.btmPane.pack1(self.operationframe, resize=1, shrink=pshrink)

        # Domain
        self.domainframe = gtk.Frame(label="Domain")
        self.domainframe.set_shadow_type(gtk.SHADOW_IN)
        dom_scroll = gtk.ScrolledWindow()
        gtklogger.logScrollBars(dom_scroll, "Domain")
        dom_scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        self.domain_obj = regclassfactory.RegisteredClassFactory(
            analysisdomain.Domain.registry,
            scope=self,
            name="DomainRCF",
            callback=self.newDomainCB)
        self.domainframe.add(dom_scroll)
        dom_scroll.add_with_viewport(self.domain_obj.gtk)
        self.topPane.pack2(self.domainframe, resize=1, shrink=pshrink)

        # Sampling.  The SampleRCF class uses the WidgetScope
        # mechanism to find the Operation and Domain widgets, so that
        # it can display only the relevant SampleSet classes.
        self.sampleframe = gtk.Frame(label="Sampling")
        self.sampleframe.set_shadow_type(gtk.SHADOW_IN)
        sam_scroll = gtk.ScrolledWindow()
        gtklogger.logScrollBars(sam_scroll, "Sampling")
        sam_scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        self.sample_obj = sampleregclassfactory.SampleRCF(
            scope=self, name="Sampling", callback=self.newSampleCB)
        self.sampleframe.add(sam_scroll)
        sam_scroll.add_with_viewport(self.sample_obj.gtk)
        self.btmPane.pack2(self.sampleframe, resize=1, shrink=pshrink)

        self.buildBottomRow(mainbox)

        # Whenever fields or fluxes are defined or undefined on the
        # mesh, we need to update the output object widget, and
        # possibly invalidate the currently-displayed data, once we
        # start displaying data.

        switchboard.requestCallbackMain(("new who", "Mesh"), self.new_mesh)
        switchboard.requestCallbackMain(("new who", "Skeleton"), self.new_skel)

        switchboard.requestCallbackMain(self.timeWidget,
                                        self.sensitize_widgets)
        switchboard.requestCallbackMain(self.domain_obj,
                                        self.sensitize_widgets)
        switchboard.requestCallbackMain(self.op_obj, self.sensitize_widgets)
        switchboard.requestCallbackMain(self.output_obj,
                                        self.sensitize_widgets)
        switchboard.requestCallbackMain(self.destwidget,
                                        self.sensitize_widgets)

        switchboard.requestCallbackMain("named analyses changed",
                                        self.analysesChanged)
        switchboard.requestCallbackMain("mesh status changed",
                                        self.sensitize_widgets)

        switchboard.requestCallbackMain(self.domain_obj,
                                        self.setNamedAnalysisChooser)
        switchboard.requestCallbackMain(self.op_obj,
                                        self.setNamedAnalysisChooser)
        switchboard.requestCallbackMain(self.output_obj,
                                        self.setNamedAnalysisChooser)
        switchboard.requestCallbackMain(self.sample_obj,
                                        self.setNamedAnalysisChooser)
예제 #40
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)
예제 #41
0
    def __init__(self, parent):
        debug.mainthreadTest()
        self.parent = parent
        # Property selection state lives here.  When not None,
        # current_property is a tuple, (name, propertyregistration).
        # current_property mirrors the selection state of the
        # GfxLabelTree self.propertytree.
        self.current_property = None

        self.gtk = gtk.Frame('Property')
        gtklogger.setWidgetName(self.gtk, 'Property')
        self.gtk.set_shadow_type(gtk.SHADOW_IN)
        vbox = gtk.VBox(spacing=3)

        self.gtk.add(vbox)

        # Button box above the Property Tree
        buttonbox = gtk.HBox()
        vbox.pack_start(buttonbox, expand=0, fill=0)

        self.copybutton = gtkutils.StockButton(gtk.STOCK_COPY, 'Copy...')
        gtklogger.setWidgetName(self.copybutton, 'Copy')
        gtklogger.connect(self.copybutton, 'clicked', self.on_copy_property)
        tooltips.set_tooltip_text(
            self.copybutton,
            'Create a named copy of the currently selected property')
        buttonbox.pack_start(self.copybutton, expand=1, fill=0)

        self.parambutton = gtkutils.StockButton(gtk.STOCK_EDIT,
                                                'Parametrize...')
        gtklogger.setWidgetName(self.parambutton, 'Parametrize')
        gtklogger.connect(self.parambutton, 'clicked', self.parametrize)
        tooltips.set_tooltip_text(
            self.parambutton,
            "Set parameters for the currently selected Property.")
        buttonbox.pack_start(self.parambutton, expand=1, fill=0)

        self.deletebutton = gtkutils.StockButton(gtk.STOCK_DELETE, 'Delete')
        gtklogger.setWidgetName(self.deletebutton, 'Delete')
        gtklogger.connect(self.deletebutton, 'clicked', self.GUIdelete)
        tooltips.set_tooltip_text(self.deletebutton,
                                  "Delete the currently selected Property.")
        buttonbox.pack_start(self.deletebutton, expand=1, fill=0)

        # Scrolling window containing the Property Tree
        scroll = gtk.ScrolledWindow()
        gtklogger.logScrollBars(scroll, "PropertyScroll")
        scroll.set_shadow_type(gtk.SHADOW_IN)
        vbox.pack_start(scroll, expand=1, fill=1)
        scroll.set_policy(gtk.POLICY_ALWAYS, gtk.POLICY_ALWAYS)
        self.propertytree = gfxLabelTree.GfxLabelTree(AllProperties.data,
                                                      expand=None,
                                                      callback=self.proptreeCB,
                                                      name="PropertyTree")
        self.propertytree.setRightClickCB(self.parametrize)
        scroll.add(self.propertytree.gtk)

        # The Load button.
        self.loadbutton = gtkutils.StockButton(gtk.STOCK_GO_FORWARD,
                                               "Add Property to Material",
                                               reverse=True)
        gtklogger.setWidgetName(self.loadbutton, 'Add')
        align = gtk.Alignment(xalign=0.5)
        align.add(self.loadbutton)
        vbox.pack_start(align, expand=0, fill=0, padding=3)
        tooltips.set_tooltip_text(
            self.loadbutton,
            "Load the currently selected property into the current material.")
        gtklogger.connect(self.loadbutton, 'clicked', self.on_prop_load)

        # Utility callbacks.
        self.propertytree.gtk.connect("destroy", self.on_destroy)

        switchboard.requestCallbackMain("new property", self.newPropCB)
예제 #42
0
    def __init__(self):
        oofGUI.MainPage.__init__(
            self,
            name="Scheduled Output",
            ordering=235,
            tip="Set output quantities to be computed during time evolution.")
        mainbox = gtk.VBox(spacing=2)
        self.gtk.add(mainbox)

        align = gtk.Alignment(xalign=0.5)
        mainbox.pack_start(align, expand=0, fill=0)
        centerbox = gtk.HBox(spacing=3)
        align.add(centerbox)
        self.meshwidget = whowidget.WhoWidget(ooflib.engine.mesh.meshes,
                                              scope=self)
        switchboard.requestCallbackMain(self.meshwidget, self.meshCB)
        label = gtk.Label("Microstructure=")
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        centerbox.pack_start(self.meshwidget.gtk[0], expand=0, fill=0)

        label = gtk.Label("Skeleton=")
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        centerbox.pack_start(self.meshwidget.gtk[1], expand=0, fill=0)

        label = gtk.Label("Mesh=")
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        centerbox.pack_start(self.meshwidget.gtk[2], expand=0, fill=0)

        align = gtk.Alignment(xalign=0.5)
        mainbox.pack_start(align, expand=0, fill=0, padding=3)
        align.add(
            gtk.Label(
                "Skip this page if you're only solving static problems."))

        outputFrame = gtk.Frame()
        gtklogger.setWidgetName(outputFrame, 'Output')
        outputFrame.set_shadow_type(gtk.SHADOW_IN)
        mainbox.pack_start(outputFrame, expand=1, fill=1)
        outputBox = gtk.VBox(spacing=2)
        outputFrame.add(outputBox)

        # Buttons for creating, editing, and removing Outputs

        bbox = gtk.HBox(homogeneous=True, spacing=2)
        outputBox.pack_start(bbox, expand=False, fill=False)
        # New Output
        self.newOutputButton = gtkutils.StockButton(gtk.STOCK_NEW, "New")
        gtklogger.setWidgetName(self.newOutputButton, "New")
        gtklogger.connect(self.newOutputButton, 'clicked', self.newOutputCB)
        bbox.pack_start(self.newOutputButton, expand=True, fill=True)
        tooltips.set_tooltip_text(self.newOutputButton,
                                  "Define a new output operation.")
        # Rename Output
        self.renameOutputButton = gtkutils.StockButton(gtk.STOCK_EDIT,
                                                       "Rename")
        gtklogger.setWidgetName(self.renameOutputButton, "Rename")
        gtklogger.connect(self.renameOutputButton, 'clicked', self.renameCB)
        bbox.pack_start(self.renameOutputButton, expand=True, fill=True)
        tooltips.set_tooltip_text(self.renameOutputButton,
                                  "Rename the selected output operation.")
        # Edit Output
        self.editOutputButton = gtkutils.StockButton(gtk.STOCK_EDIT, "Edit")
        gtklogger.setWidgetName(self.editOutputButton, "Edit")
        gtklogger.connect(self.editOutputButton, 'clicked', self.editOutputCB)
        bbox.pack_start(self.editOutputButton, expand=True, fill=True)
        tooltips.set_tooltip_text(self.editOutputButton,
                                  "Redefine the selected output operation.")
        # Copy Output
        self.copyOutputButton = gtkutils.StockButton(gtk.STOCK_COPY, "Copy")
        gtklogger.setWidgetName(self.copyOutputButton, "Copy")
        gtklogger.connect(self.copyOutputButton, 'clicked', self.copyOutputCB)
        bbox.pack_start(self.copyOutputButton, expand=True, fill=True)
        tooltips.set_tooltip_text(self.copyOutputButton,
                                  "Copy the selected output.")
        # Second row of buttons
        bbox = gtk.HBox(homogeneous=True, spacing=2)
        outputBox.pack_start(bbox, expand=False, fill=False)
        # Delete Output
        self.deleteOutputButton = gtkutils.StockButton(gtk.STOCK_DELETE,
                                                       "Delete")
        gtklogger.setWidgetName(self.deleteOutputButton, "Delete")
        gtklogger.connect(self.deleteOutputButton, 'clicked',
                          self.deleteOutputCB)
        tooltips.set_tooltip_text(self.deleteOutputButton,
                                  "Delete the selected output operation.")
        bbox.pack_start(self.deleteOutputButton, expand=True, fill=True)
        # Delete all outputs
        self.deleteAllButton = gtkutils.StockButton(gtk.STOCK_DELETE,
                                                    "Delete All")
        gtklogger.setWidgetName(self.deleteAllButton, "DeleteAll")
        gtklogger.connect(self.deleteAllButton, 'clicked', self.deleteAllCB)
        bbox.pack_start(self.deleteAllButton, expand=True, fill=True)
        tooltips.set_tooltip_text(self.deleteAllButton,
                                  "Delete all output operations")
        # Rewind
        self.rewindDestButton = gtkutils.StockButton(gtk.STOCK_MEDIA_REWIND,
                                                     "Rewind")
        gtklogger.setWidgetName(self.rewindDestButton, "Rewind")
        gtklogger.connect(self.rewindDestButton, 'clicked',
                          self.rewindDestinationCB)
        bbox.pack_start(self.rewindDestButton, expand=True, fill=True)
        tooltips.set_tooltip_text(self.rewindDestButton,
                                  "Go back to the start of the output file.")
        # Rewind All
        self.rewindAllDestsButton = gtkutils.StockButton(
            gtk.STOCK_MEDIA_REWIND, "Rewind All")
        gtklogger.setWidgetName(self.rewindAllDestsButton, "RewindAll")
        gtklogger.connect(self.rewindAllDestsButton, 'clicked',
                          self.rewindAllDestinationsCB)
        bbox.pack_start(self.rewindAllDestsButton, expand=True, fill=True)
        tooltips.set_tooltip_text(self.rewindAllDestsButton,
                                  "Go back to the start of all output files.")

        # List of Outputs
        outputScroll = gtk.ScrolledWindow()
        gtklogger.logScrollBars(outputScroll, "OutputScroll")
        outputBox.pack_start(outputScroll, expand=True, fill=True)
        outputScroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)

        self.outputList = gtk.ListStore(gobject.TYPE_PYOBJECT)
        self.outputView = gtk.TreeView(self.outputList)
        outputScroll.add(self.outputView)
        gtklogger.setWidgetName(self.outputView, "OutputList")
        # Catch double clicks
        gtklogger.connect(self.outputView, 'row-activated',
                          self.outputDoubleClickCB)
        # Catch selection changes
        gtklogger.adoptGObject(self.outputView.get_selection(),
                               self.outputView,
                               access_method=self.outputView.get_selection)
        self.selectionSignal = gtklogger.connect(
            self.outputView.get_selection(), 'changed', self.selectionCB)

        # Enable/disable column
        enableCell = gtk.CellRendererToggle()
        enableCol = gtk.TreeViewColumn("Enable")
        enableCol.pack_start(enableCell, expand=False)
        enableCol.set_resizable(False)
        enableCol.set_cell_data_func(enableCell, self.renderEnableCell)
        self.outputView.append_column(enableCol)
        gtklogger.adoptGObject(enableCell,
                               self.outputView,
                               access_function=gtklogger.findCellRenderer,
                               access_kwargs={
                                   'col': 0,
                                   'rend': 0
                               })
        gtklogger.connect(enableCell, 'toggled', self.enableCellCB)

        # Output name column
        self.outputCell = gtk.CellRendererText()
        outputCol = gtk.TreeViewColumn("Output")
        outputCol.pack_start(self.outputCell, expand=True)
        outputCol.set_cell_data_func(self.outputCell, self.renderOutputCell)
        self.outputView.append_column(outputCol)

        # Output schedule column
        self.schedCell = gtk.CellRendererText()
        schedCol = gtk.TreeViewColumn("Schedule")
        schedCol.pack_start(self.schedCell, expand=True)
        schedCol.set_cell_data_func(self.schedCell, self.renderScheduleCB)
        self.outputView.append_column(schedCol)

        # Output destination column
        self.destCell = gtk.CellRendererText()
        destCol = gtk.TreeViewColumn("Destination")
        destCol.pack_start(self.destCell, expand=True)
        destCol.set_cell_data_func(self.destCell, self.renderDestinationCB)
        self.outputView.append_column(destCol)

        switchboard.requestCallbackMain("scheduled outputs changed",
                                        self.outputsChangedCB)
        switchboard.requestCallbackMain("new scheduled output",
                                        self.newOutputSBCB)
예제 #43
0
 def signals(self):
     return [
         switchboard.requestCallbackMain("named analyses changed",
                                         self.update)
     ]
예제 #44
0
    def __init__(self):
        oofGUI.MainPage.__init__(self,
                                 name="Image",
                                 ordering=50,
                                 tip='Manipulate Images')

        mainbox = gtk.VBox(spacing=2)
        self.gtk.add(mainbox)

        align = gtk.Alignment(xalign=0.5)
        mainbox.pack_start(align, expand=0, fill=0)
        centerbox = gtk.HBox(spacing=3)
        align.add(centerbox)
        label = gtk.Label('Microstructure=')
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        self.imagewidget = whowidget.WhoWidget(imagecontext.imageContexts)
        centerbox.pack_start(self.imagewidget.gtk[0], expand=0, fill=0)
        label = gtk.Label('Image=')
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        centerbox.pack_start(self.imagewidget.gtk[1], expand=0, fill=0)

        align = gtk.Alignment(xalign=0.5)
        mainbox.pack_start(align, expand=0, fill=0)
        centerbox = gtk.HBox(homogeneous=1, spacing=3)
        align.add(centerbox)

        self.loadbutton = gtk.Button('Load...')
        gtklogger.setWidgetName(self.loadbutton, 'Load')
        centerbox.pack_start(self.loadbutton, expand=1, fill=1)
        gtklogger.connect(self.loadbutton, 'clicked', self.loadCB)
        tooltips.set_tooltip_text(
            self.loadbutton,
            'Load a new image into an existing Microstructure')

        self.copybutton = gtkutils.StockButton(gtk.STOCK_COPY, 'Copy...')
        gtklogger.setWidgetName(self.copybutton, 'Copy')
        gtklogger.connect(self.copybutton, 'clicked', self.copyCB)
        centerbox.pack_start(self.copybutton, expand=1, fill=1)
        tooltips.set_tooltip_text(
            self.copybutton,
            'Copy the current image.  The copy can be in the same or a different Microstructure.'
        )

        self.renamebutton = gtkutils.StockButton(gtk.STOCK_EDIT, 'Rename...')
        gtklogger.setWidgetName(self.renamebutton, 'Rename')
        gtklogger.connect(self.renamebutton, 'clicked', self.renameCB)
        tooltips.set_tooltip_text(self.renamebutton,
                                  'Rename the current image.')
        centerbox.pack_start(self.renamebutton, expand=1, fill=1)

        self.deletebutton = gtkutils.StockButton(gtk.STOCK_DELETE, 'Delete')
        gtklogger.setWidgetName(self.deletebutton, 'Delete')
        gtklogger.connect(self.deletebutton, 'clicked', self.deleteCB)
        tooltips.set_tooltip_text(self.deletebutton,
                                  'Delete the current image.')
        centerbox.pack_start(self.deletebutton, expand=1, fill=1)

        self.savebutton = gtkutils.StockButton(gtk.STOCK_SAVE, 'Save...')
        gtklogger.setWidgetName(self.savebutton, 'Save')
        gtklogger.connect(self.savebutton, 'clicked', self.saveCB)
        tooltips.set_tooltip_text(self.savebutton,
                                  'Save the current image to a file.')
        centerbox.pack_start(self.savebutton, expand=1, fill=1)

        self.autogroupbutton = gtk.Button('Group...')
        gtklogger.setWidgetName(self.autogroupbutton, 'Group')
        gtklogger.connect(self.autogroupbutton, 'clicked', self.autogroupCB)
        centerbox.pack_start(self.autogroupbutton, expand=1, fill=1, padding=2)
        if config.dimension() == 2:
            tooltips.set_tooltip_text(
                self.autogroupbutton,
                "Create a pixel group in the current image's microstructure for each color pixel in the image."
            )
        elif config.dimension() == 3:
            tooltips.set_tooltip_text(
                self.autogroupbutton,
                "Create a voxel group in the current image's microstructure for each color voxel in the image."
            )

        mainpane = gtk.HPaned()
        gtklogger.setWidgetName(mainpane, 'Pane')
        mainbox.pack_start(mainpane, expand=1, fill=1)
        gtklogger.connect_passive(mainpane, 'notify::position')

        frame = gtk.Frame('Image Information')
        frame.set_shadow_type(gtk.SHADOW_IN)
        mainpane.pack1(frame, resize=True, shrink=False)
        scroll = gtk.ScrolledWindow()
        gtklogger.logScrollBars(scroll, "StatusScroll")
        scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        frame.add(scroll)

        self.infoarea = fixedwidthtext.FixedWidthTextView()
        self.infoarea.set_wrap_mode(gtk.WRAP_WORD)
        self.infoarea.set_editable(False)
        self.infoarea.set_cursor_visible(False)
        scroll.add_with_viewport(self.infoarea)

        frame = gtk.Frame('Image Modification')
        frame.set_shadow_type(gtk.SHADOW_IN)
        mainpane.pack2(frame, resize=False, shrink=False)
        vbox = gtk.VBox()
        frame.add(vbox)
        ##        scroll = gtk.ScrolledWindow()    # scroll window for image mod method
        ##        scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        ##        vbox.pack_start(scroll, expand=1, fill=1)
        self.imageModFactory = regclassfactory.RegisteredClassFactory(
            imagemodifier.ImageModifier.registry,
            title="Method:",
            name="Method")
        ##        scroll.add_with_viewport(self.imageModFactory.gtk)
        vbox.pack_start(self.imageModFactory.gtk, expand=1, fill=1)
        self.historian = historian.Historian(self.imageModFactory.set,
                                             self.sensitizeHistory,
                                             setCBkwargs={'interactive': 1})
        self.imageModFactory.set_callback(self.historian.stateChangeCB)

        # Prev, OK, and Next buttons
        hbox = gtk.HBox()
        vbox.pack_start(hbox, expand=0, fill=0, padding=2)
        self.prevmethodbutton = gtkutils.prevButton()
        gtklogger.connect(self.prevmethodbutton, 'clicked',
                          self.historian.prevCB)
        hbox.pack_start(self.prevmethodbutton, expand=0, fill=0, padding=2)
        tooltips.set_tooltip_text(
            self.prevmethodbutton,
            'Recall the previous image modification operation.')
        self.okbutton = gtk.Button(stock=gtk.STOCK_OK)
        gtklogger.setWidgetName(self.okbutton, 'OK')
        hbox.pack_start(self.okbutton, expand=1, fill=1, padding=5)
        gtklogger.connect(self.okbutton, 'clicked', self.okbuttonCB)
        tooltips.set_tooltip_text(
            self.okbutton,
            'Perform the image modification operation defined above.')
        self.nextmethodbutton = gtkutils.nextButton()
        gtklogger.connect(self.nextmethodbutton, 'clicked',
                          self.historian.nextCB)
        hbox.pack_start(self.nextmethodbutton, expand=0, fill=0, padding=2)
        tooltips.set_tooltip_text(
            self.nextmethodbutton,
            "Recall the next image modification operation.")

        # Undo and Redo buttons
        hbox = gtk.HBox()
        vbox.pack_start(hbox, expand=0, fill=0, padding=2)
        self.undobutton = gtk.Button(stock=gtk.STOCK_UNDO)
        gtklogger.setWidgetName(self.undobutton, 'Undo')
        gtklogger.connect(self.undobutton, 'clicked', self.undoCB)
        tooltips.set_tooltip_text(self.undobutton,
                                  'Undo the latest image modification.')
        hbox.pack_start(self.undobutton, expand=1, fill=0, padding=10)
        self.redobutton = gtk.Button(stock=gtk.STOCK_REDO)
        gtklogger.setWidgetName(self.redobutton, 'Redo')
        gtklogger.connect(self.redobutton, 'clicked', self.redoCB)
        tooltips.set_tooltip_text(
            self.redobutton, 'Redo the latest undone image modification.')
        hbox.pack_start(self.redobutton, expand=1, fill=0, padding=10)

        self.sensitize()
        self.sensitizeHistory()

        self.sbcallbacks = [
            switchboard.requestCallbackMain(('new who', 'Microstructure'),
                                            self.newMicrostructureCB),
            switchboard.requestCallbackMain(('new who', 'Image'),
                                            self.newImageCB),
            switchboard.requestCallbackMain(('remove who', 'Image'),
                                            self.rmWhoCB),
            switchboard.requestCallbackMain('modified image',
                                            self.modifiedImageCB),
            switchboard.requestCallbackMain(imagemodifier.ImageModifier,
                                            self.updateImageModifiers),
            switchboard.requestCallbackMain(self.imagewidget,
                                            self.iWidgetChanged),
            switchboard.requestCallbackMain(('validity', self.imageModFactory),
                                            self.validityChangeCB),
            switchboard.requestCallbackMain(
                ('WhoDoUndo buffer change', 'Image'), self.whoBufChangeCB)
        ]

        subthread.execute(self.displayImageInfo)
예제 #45
0
    def __init__(self):
        oofGUI.MainPage.__init__(
            self,
            name="Scheduled Output",
            ordering=235,
            tip="Set output quantities to be computed during time evolution.")
        mainbox = gtk.VBox(spacing=2)
        self.gtk.add(mainbox)

        align = gtk.Alignment(xalign=0.5)
        mainbox.pack_start(align, expand=0, fill=0)
        centerbox = gtk.HBox(spacing=3)
        align.add(centerbox)
        self.meshwidget = whowidget.WhoWidget(ooflib.engine.mesh.meshes,
                                              scope=self)
        switchboard.requestCallbackMain(self.meshwidget, self.meshCB)
        label = gtk.Label("Microstructure=")
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        centerbox.pack_start(self.meshwidget.gtk[0], expand=0, fill=0)

        label = gtk.Label("Skeleton=")
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        centerbox.pack_start(self.meshwidget.gtk[1], expand=0, fill=0)

        label = gtk.Label("Mesh=")
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        centerbox.pack_start(self.meshwidget.gtk[2], expand=0, fill=0)

        align = gtk.Alignment(xalign=0.5)
        mainbox.pack_start(align, expand=0, fill=0, padding=3)
        align.add(
            gtk.Label(
                "Skip this page if you're only solving static problems."))

        # The four columns (enable, output, schedule, and destination)
        # are each displayed in their own gtk.TreeView, each of which
        # is in a pane of a gtk.HPaned.  It would have been better to
        # put each column in a different gtk.TreeViewColumn in the
        # same gtk.TreeView, but that would have made it hard to put
        # buttons at the bottom of each column.

        hpane0 = gtk.HPaned()
        gtklogger.setWidgetName(hpane0, 'HPane0')
        gtklogger.connect_passive(hpane0, 'notify::position')
        mainbox.pack_start(hpane0, expand=1, fill=1)

        hpaneL = gtk.HPaned()
        gtklogger.setWidgetName(hpaneL, 'HPaneL')
        gtklogger.connect_passive(hpaneL, 'notify::position')
        hpane0.pack1(hpaneL, resize=True, shrink=False)

        hpaneR = gtk.HPaned()
        gtklogger.setWidgetName(hpaneR, 'HPane2')
        gtklogger.connect_passive(hpaneR, 'notify::position')
        hpane0.pack2(hpaneR, resize=True, shrink=False)

        self.outputList = gtk.ListStore(gobject.TYPE_PYOBJECT)

        # The "Enable" column has a check box for each output
        self.enableFrame = gtk.Frame()
        self.enableFrame.set_shadow_type(gtk.SHADOW_IN)
        hpaneL.pack1(self.enableFrame, resize=False, shrink=False)
        vbox = gtk.VBox()
        self.enableFrame.add(vbox)
        self.enableView = gtk.TreeView(self.outputList)
        gtklogger.setWidgetName(self.enableView, "enable")
        vbox.pack_start(self.enableView, expand=True, fill=True)
        self.enablecell = gtk.CellRendererToggle()
        enablecol = gtk.TreeViewColumn("")
        enablecol.set_resizable(False)
        enablecol.pack_start(self.enablecell, expand=False)
        enablecol.set_cell_data_func(self.enablecell, self.renderEnableCell)
        self.enableView.append_column(enablecol)
        gtklogger.adoptGObject(self.enablecell,
                               self.enableView,
                               access_function=gtklogger.findCellRenderer,
                               access_kwargs={
                                   'col': 0,
                                   'rend': 0
                               })
        gtklogger.connect(self.enablecell, 'toggled', self.enableCellCB)
        # Extra space at the bottom of the column.  The other columns
        # have button boxes at the bottom, so this one needs a strut
        # to keep its rows aligned with the others.
        self.enableStrut = gtk.VBox()
        vbox.pack_start(self.enableStrut, expand=False, fill=False)

        # The "Output" pane lists the name of each output
        self.outputFrame = gtk.Frame()
        self.outputFrame.set_shadow_type(gtk.SHADOW_IN)
        gtklogger.setWidgetName(self.outputFrame, "Output")
        hpaneL.pack2(self.outputFrame, resize=True, shrink=False)
        outputVBox = gtk.VBox()
        self.outputFrame.add(outputVBox)
        self.outputView = gtk.TreeView(self.outputList)
        gtklogger.setWidgetName(self.outputView, "list")
        outputVBox.pack_start(self.outputView, expand=True, fill=True)
        self.outputHScroll = gtk.HScrollbar()
        outputVBox.pack_start(self.outputHScroll, expand=False, fill=False)
        self.outputView.set_hadjustment(self.outputHScroll.get_adjustment())
        self.outputcell = gtk.CellRendererText()
        outputcol = gtk.TreeViewColumn("Output")
        outputcol.pack_start(self.outputcell, expand=True)
        outputcol.set_cell_data_func(self.outputcell, self.renderOutputCell)
        self.outputView.append_column(outputcol)
        gtklogger.connect(self.outputView, 'row-activated',
                          self.outputDoubleClickCB)
        # Buttons for the Output pane.  The extra VBox is used so that
        # the sizes of the button boxes can be synchronized.
        self.outputBBox = gtk.VBox(homogeneous=True)
        outputVBox.pack_start(self.outputBBox, expand=False, fill=False)
        bbox = gtk.HBox(homogeneous=False)
        self.outputBBox.pack_start(bbox, expand=True, fill=True)
        # New Output
        self.newOutputButton = gtkutils.StockButton(gtk.STOCK_NEW, "New")
        gtklogger.setWidgetName(self.newOutputButton, "New")
        gtklogger.connect(self.newOutputButton, 'clicked', self.newOutputCB)
        bbox.pack_start(self.newOutputButton, expand=True, fill=True)
        tooltips.set_tooltip_text(self.newOutputButton,
                                  "Define a new output operation.")
        # Edit Output
        self.editOutputButton = gtkutils.StockButton(gtk.STOCK_EDIT, "Edit")
        gtklogger.setWidgetName(self.editOutputButton, "Edit")
        gtklogger.connect(self.editOutputButton, 'clicked', self.editOutputCB)
        bbox.pack_start(self.editOutputButton, expand=True, fill=True)
        tooltips.set_tooltip_text(self.editOutputButton,
                                  "Redefine the selected output operation.")
        # Copy Output
        self.copyOutputButton = gtkutils.StockButton(gtk.STOCK_COPY, "Copy")
        gtklogger.setWidgetName(self.copyOutputButton, "Copy")
        gtklogger.connect(self.copyOutputButton, 'clicked', self.copyOutputCB)
        bbox.pack_start(self.copyOutputButton, expand=True, fill=True)
        tooltips.set_tooltip_text(
            self.copyOutputButton,
            "Copy the selected output and its schedule and destination.")
        # Second row of buttons
        bbox = gtk.HBox(homogeneous=False)
        self.outputBBox.pack_start(bbox, expand=True, fill=True)
        # Rename Output
        self.renameOutputButton = gtkutils.StockButton(gtk.STOCK_EDIT,
                                                       "Rename")
        gtklogger.setWidgetName(self.renameOutputButton, "Rename")
        gtklogger.connect(self.renameOutputButton, 'clicked', self.renameCB)
        bbox.pack_start(self.renameOutputButton, expand=True, fill=True)
        tooltips.set_tooltip_text(self.renameOutputButton,
                                  "Rename the selected output operation.")
        # Delete Output
        self.deleteOutputButton = gtkutils.StockButton(gtk.STOCK_DELETE,
                                                       "Delete")
        gtklogger.setWidgetName(self.deleteOutputButton, "Delete")
        gtklogger.connect(self.deleteOutputButton, 'clicked',
                          self.deleteOutputCB)
        tooltips.set_tooltip_text(self.deleteOutputButton,
                                  "Delete the selected output operation.")
        bbox.pack_start(self.deleteOutputButton, expand=True, fill=True)
        # Delete all outputs
        self.deleteAllButton = gtkutils.StockButton(gtk.STOCK_DELETE,
                                                    "Delete All")
        gtklogger.setWidgetName(self.deleteAllButton, "DeleteAll")
        gtklogger.connect(self.deleteAllButton, 'clicked', self.deleteAllCB)
        bbox.pack_start(self.deleteAllButton, expand=True, fill=True)
        tooltips.set_tooltip_text(self.deleteAllButton,
                                  "Delete all output operations")

        # Schedule pane
        self.schedFrame = gtk.Frame()
        self.schedFrame.set_shadow_type(gtk.SHADOW_IN)
        gtklogger.setWidgetName(self.schedFrame, "Schedule")
        hpaneR.pack1(self.schedFrame, resize=True, shrink=False)
        scheduleVBox = gtk.VBox()
        self.schedFrame.add(scheduleVBox)
        self.schedView = gtk.TreeView(self.outputList)
        gtklogger.setWidgetName(self.schedView, "list")
        scheduleVBox.pack_start(self.schedView, expand=True, fill=True)
        schedHScroll = gtk.HScrollbar()
        scheduleVBox.pack_start(schedHScroll, expand=False, fill=False)
        self.schedView.set_hadjustment(schedHScroll.get_adjustment())
        self.schedcell = gtk.CellRendererText()
        schedcol = gtk.TreeViewColumn("Schedule")
        schedcol.pack_start(self.schedcell, expand=True)
        schedcol.set_cell_data_func(self.schedcell, self.renderScheduleCB)
        self.schedView.append_column(schedcol)
        gtklogger.connect(self.schedView, 'row-activated',
                          self.schedDoubleClickCB)
        # Buttons for the Schedule pane.
        self.schedBBox = gtk.VBox(homogeneous=True)
        scheduleVBox.pack_start(self.schedBBox, expand=False, fill=False)
        bbox = gtk.HBox(homogeneous=False)
        self.schedBBox.pack_start(bbox, expand=True, fill=True)
        # Set Schedule
        self.setScheduleButton = gtkutils.StockButton(gtk.STOCK_NEW, "Set")
        gtklogger.setWidgetName(self.setScheduleButton, "New")
        gtklogger.connect(self.setScheduleButton, 'clicked', self.setSchedCB)
        bbox.pack_start(self.setScheduleButton, expand=True, fill=True)
        tooltips.set_tooltip_text(self.setScheduleButton,
                                  "Add a Schedule to the selected Output")
        # Copy Schedule
        self.copyScheduleButton = gtkutils.StockButton(gtk.STOCK_COPY, "Copy")
        gtklogger.setWidgetName(self.copyScheduleButton, "Copy")
        gtklogger.connect(self.copyScheduleButton, 'clicked', self.copySchedCB)
        bbox.pack_start(self.copyScheduleButton, expand=True, fill=True)
        tooltips.set_tooltip_text(
            self.copyScheduleButton,
            "Copy the selected Schedule to another Output")
        # Second row of buttons in the Schedule pane
        bbox = gtk.HBox(homogeneous=False)
        self.schedBBox.pack_start(bbox, expand=True, fill=True)
        # Delete Schedule
        self.deleteScheduleButton = gtkutils.StockButton(
            gtk.STOCK_DELETE, "Delete")
        gtklogger.setWidgetName(self.deleteScheduleButton, "Delete")
        gtklogger.connect(self.deleteScheduleButton, 'clicked',
                          self.deleteSchedCB)
        bbox.pack_start(self.deleteScheduleButton, expand=True, fill=True)
        tooltips.set_tooltip_text(self.deleteScheduleButton,
                                  "Delete the selected Schedule.")

        # Destination pane
        self.destFrame = gtk.Frame()
        self.destFrame.set_shadow_type(gtk.SHADOW_IN)
        gtklogger.setWidgetName(self.destFrame, "Destination")
        hpaneR.pack2(self.destFrame, resize=True, shrink=False)
        destVBox = gtk.VBox()
        self.destFrame.add(destVBox)
        destScroll = gtk.ScrolledWindow()
        destScroll.set_shadow_type(gtk.SHADOW_NONE)
        destScroll.set_policy(gtk.POLICY_ALWAYS, gtk.POLICY_ALWAYS)
        destVBox.pack_start(destScroll, expand=True, fill=True)
        self.destView = gtk.TreeView(self.outputList)
        gtklogger.setWidgetName(self.destView, "list")
        destScroll.add(self.destView)
        self.destcell = gtk.CellRendererText()
        destcol = gtk.TreeViewColumn("Destination")
        destcol.pack_start(self.destcell, expand=True)
        destcol.set_cell_data_func(self.destcell, self.renderDestinationCB)
        self.destView.append_column(destcol)
        gtklogger.connect(self.destView, 'row-activated',
                          self.destDoubleClickCB)
        # Buttons for the Destination pane
        self.destBBox = gtk.VBox(homogeneous=True)
        destVBox.pack_start(self.destBBox, expand=False, fill=True)
        bbox = gtk.HBox(homogeneous=False)
        self.destBBox.pack_start(bbox, expand=True, fill=True)
        # Set Destination
        self.setDestinationButton = gtkutils.StockButton(gtk.STOCK_NEW, "Set")
        gtklogger.setWidgetName(self.setDestinationButton, "Set")
        gtklogger.connect(self.setDestinationButton, 'clicked',
                          self.setDestinationCB)
        bbox.pack_start(self.setDestinationButton, expand=True, fill=True)
        tooltips.set_tooltip_text(
            self.setDestinationButton,
            "Assign a destination to the selected Output")
        # Delete Dest
        self.deleteDestButton = gtkutils.StockButton(gtk.STOCK_DELETE,
                                                     "Delete")
        gtklogger.setWidgetName(self.deleteDestButton, "Delete")
        gtklogger.connect(self.deleteDestButton, 'clicked', self.deleteDestCB)
        bbox.pack_start(self.deleteDestButton, expand=True, fill=True)
        tooltips.set_tooltip_text(self.deleteDestButton,
                                  "Delete the selected Destination.")
        # Second row of buttons in the Dest pane
        bbox = gtk.HBox(homogeneous=False)
        self.destBBox.pack_start(bbox, expand=True, fill=True)
        # Rewind
        self.rewindDestButton = gtkutils.StockButton(gtk.STOCK_MEDIA_REWIND,
                                                     "Rewind")
        gtklogger.setWidgetName(self.rewindDestButton, "Rewind")
        gtklogger.connect(self.rewindDestButton, 'clicked',
                          self.rewindDestinationCB)
        bbox.pack_start(self.rewindDestButton, expand=True, fill=True)
        tooltips.set_tooltip_text(self.rewindDestButton,
                                  "Go back to the start of the output file.")
        # Rewind All
        self.rewindAllDestsButton = gtkutils.StockButton(
            gtk.STOCK_MEDIA_REWIND, "Rewind All")
        gtklogger.setWidgetName(self.rewindAllDestsButton, "RewindAll")
        gtklogger.connect(self.rewindAllDestsButton, 'clicked',
                          self.rewindAllDestinationsCB)
        bbox.pack_start(self.rewindAllDestsButton, expand=True, fill=True)
        tooltips.set_tooltip_text(self.rewindAllDestsButton,
                                  "Go back to the start of all output files.")

        # Synchronize the vertical scrolling of all the panes.
        self.schedView.set_vadjustment(destScroll.get_vadjustment())
        self.outputView.set_vadjustment(destScroll.get_vadjustment())
        self.enableView.set_vadjustment(destScroll.get_vadjustment())

        self.allViews = (self.enableView, self.outputView, self.schedView,
                         self.destView)

        # This is a hack.  Some of the dialogs use widgets that need
        # to find out what the current Output is, using the
        # WidgetScope mechanism.  The TreeView isn't a
        # ParameterWidget, so it doesn't use WidgetScopes.  So here we
        # construct a ParameterWidget just so that it can be found.
        # It's kept up to date with the selected Output.  It's not
        # actually placed in the GUI.
        self.dummyOutputParam = parameter.RegisteredParameter(
            'output', scheduledoutput.ScheduledOutput)
        self.dummyOutputWidget = self.dummyOutputParam.makeWidget(scope=self)

        # Catch selection changes in the lists
        self.selectionsignals = {}
        for view in self.allViews:
            gtklogger.adoptGObject(view.get_selection(),
                                   view,
                                   access_method=view.get_selection)
            self.selectionsignals[view] = gtklogger.connect(
                view.get_selection(), 'changed', self.selectionCB)

        switchboard.requestCallbackMain("scheduled outputs changed",
                                        self.outputsChangedCB)
        switchboard.requestCallbackMain("new scheduled output",
                                        self.newOutputSBCB)

        switchboard.requestCallbackMain("gtk font changed", self.setSizes)
예제 #46
0
    def __init__(self):
        self.built = False
        oofGUI.MainPage.__init__(self,
                                 name="Boundary Analysis",
                                 ordering=271,
                                 tip="Examine the boundaries of the system.")

        self.timeparam = placeholder.TimeParameter('time', value=0.0)

        mainbox = gtk.VBox(spacing=2)
        self.gtk.add(mainbox)

        align = gtk.Alignment(xalign=0.5)
        mainbox.pack_start(align, expand=0, fill=0)
        centerbox = gtk.HBox(spacing=3)
        align.add(centerbox)
        self.meshwidget = whowidget.WhoWidget(ooflib.engine.mesh.meshes,
                                              callback=self.meshCB,
                                              scope=self)
        label = gtk.Label("Microstructure=")
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        centerbox.pack_start(self.meshwidget.gtk[0], expand=0, fill=0)
        label = gtk.Label("Skeleton=")
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        centerbox.pack_start(self.meshwidget.gtk[1], expand=0, fill=0)
        label = gtk.Label("Mesh=")
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        centerbox.pack_start(self.meshwidget.gtk[2], expand=0, fill=0)

        align = gtk.Alignment(xalign=0.5)
        mainbox.pack_start(align, expand=0, fill=0)
        centerbox = gtk.HBox(spacing=3)
        align.add(centerbox)
        self.timeWidget = self.timeparam.makeWidget(scope=self)
        centerbox.pack_start(gtk.Label("Time:"), expand=0, fill=0)
        centerbox.pack_start(self.timeWidget.gtk, expand=0, fill=0)

        mainpane = gtk.HPaned()
        gtklogger.setWidgetName(mainpane, 'Pane')
        mainbox.pack_start(mainpane, expand=1, fill=1)
        gtklogger.connect_passive(mainpane, 'notify::position')

        leftbox = gtk.VBox()
        mainpane.pack1(leftbox, resize=1, shrink=0)  # ??

        boundarylistframe = gtk.Frame("Boundaries")
        gtklogger.setWidgetName(boundarylistframe, 'frame')
        boundarylistframe.set_shadow_type(gtk.SHADOW_IN)
        leftbox.pack_start(boundarylistframe, expand=1, fill=1)

        self.bdylist = chooser.ScrolledChooserListWidget(
            callback=self.boundarylistCB,
            dbcallback=self.doubleclickCB,
            autoselect=1,
            name="BoundaryList")
        boundarylistframe.add(self.bdylist.gtk)

        rightbox = gtk.VBox()
        mainpane.pack2(rightbox, resize=1, shrink=0)  # ??

        analyzerframe = gtk.Frame("Boundary Operation")
        analyzerframe.set_shadow_type(gtk.SHADOW_IN)
        rightbox.pack_start(analyzerframe, expand=1, fill=1)
        self.analysisWidget = regclassfactory.RegisteredClassFactory(
            meshbdyanalysis.MeshBdyAnalyzer.registry,
            scope=self,
            name="BdyAnalyzerRCF")
        analyzerframe.add(self.analysisWidget.gtk)

        self.buildBottomRow(mainbox)
        # hbox2 = gtk.HBox(homogeneous=True)
        # namebox.pack_start(hbox2, expand=0, fill=0)

        # self.create_button = gtkutils.StockButton(gtk.STOCK_NEW, 'Create...')
        # hbox2.pack_start(self.create_button, expand=1, fill=1)
        # gtklogger.setWidgetName(self.create_button, 'Set')
        # gtklogger.connect(self.create_button, 'clicked', self.createCB)
        # tooltips.set_tooltip_text(
        #     self.create_button,
        #     "Assign a name to the current analysis operation,"
        #     " so that it can be retrieved later.")

        # self.retrieve_button = gtkutils.StockButton(gtk.STOCK_REFRESH,
        #                                             'Retrieve...')
        # hbox2.pack_start(self.retrieve_button, expand=1, fill=1)
        # gtklogger.connect(self.retrieve_button, 'clicked', self.retrieveCB)
        # tooltips.set_tooltip_text(self.retrieve_button,
        #                           'Retrieve a name analysis.')

        # hbox3 = gtk.HBox(homogeneous=True)
        # namebox.pack_start(hbox3, expand=0, fill=0)

        # self.savenamed_button = gtkutils.StockButton(gtk.STOCK_SAVE_AS,
        #                                              'Save...')
        # hbox3.pack_start(self.savenamed_button, expand=1, fill=1)
        # gtklogger.setWidgetName(self.savenamed_button, 'Save')
        # gtklogger.connect(self.savenamed_button, 'clicked', self.savenamedCB)
        # tooltips.set_tooltip_text(self.savenamed_button,
        #                      'Save definitions of named analyses to a file.')

        # self.delete_button = gtkutils.StockButton(gtk.STOCK_DELETE, 'Delete...')
        # hbox3.pack_start(self.delete_button, expand=1, fill=1)
        # gtklogger.setWidgetName(self.delete_button, 'Delete')
        # gtklogger.connect(self.delete_button, 'clicked', self.deleteCB)
        # tooltips.set_tooltip_text(self.delete_button,
        #                      "Delete a named analysis operation")

        # # Destination
        # destframe = gtk.Frame("Destination")
        # destframe.set_shadow_type(gtk.SHADOW_IN)
        # hbox.pack_start(destframe, expand=1, fill=1, padding=3)
        # destbox = gtk.HBox()
        # destframe.add(destbox)
        # self.destwidget = outputdestinationwidget.TextDestinationWidget(
        #     name="Destination", framed=False)
        # destbox.pack_start(self.destwidget.gtk, expand=1, fill=1, padding=2)

        # # Go button
        # self.gobutton = gtkutils.StockButton(gtk.STOCK_EXECUTE, "Go!")
        # gtklogger.setWidgetName(self.gobutton, 'Go')
        # gtklogger.connect(self.gobutton, "clicked", self.goCB)
        # tooltips.set_tooltip_text(self.gobutton,
        #                           "Send the output to the destination.")
        # hbox.pack_end(self.gobutton, expand=1, fill=1, padding=2)

        self.built = True

        switchboard.requestCallbackMain(("new who", "Mesh"), self.newmeshCB)
        switchboard.requestCallbackMain(("new who", "Skeleton"),
                                        self.newskelCB)
        switchboard.requestCallbackMain(self.meshwidget, self.meshwidgetCB)
        switchboard.requestCallbackMain("mesh changed", self.meshchangedCB)
        switchboard.requestCallbackMain(self.analysisWidget,
                                        self.analysisWidgetCB)
        switchboard.requestCallbackMain("new boundary created", self.newbdyCB)
        switchboard.requestCallbackMain("boundary removed", self.newbdyCB)
        switchboard.requestCallbackMain("boundary renamed", self.newbdyCB)
        switchboard.requestCallbackMain("named boundary analyses changed",
                                        self.analysesChangedCB)
        switchboard.requestCallbackMain("retrieve boundary analysis",
                                        self.retrieve_analysis)
        switchboard.requestCallbackMain(('validity', self.timeWidget),
                                        self.validityChangeCB)
        switchboard.requestCallbackMain("mesh status changed",
                                        self.meshchangedCB)
예제 #47
0
    def __init__(self):
        oofGUI.MainPage.__init__(self,
                                 name="Pin Nodes",
                                 ordering=120.1,
                                 tip='Pin and unpin nodes')

        mainbox = gtk.VBox(spacing=2)
        self.gtk.add(mainbox)

        align = gtk.Alignment(xalign=0.5)
        mainbox.pack_start(align, expand=0, fill=0)
        centerbox = gtk.HBox(spacing=3)
        align.add(centerbox)
        self.skelwidget = whowidget.WhoWidget(whoville.getClass('Skeleton'),
                                              callback=self.select_skeletonCB)
        label = gtk.Label('Microstructure=')
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        centerbox.pack_start(self.skelwidget.gtk[0], expand=0, fill=0)
        label = gtk.Label('Skeleton=')
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        centerbox.pack_start(self.skelwidget.gtk[1], expand=0, fill=0)

        mainpane = gtk.HPaned()
        gtklogger.setWidgetName(mainpane, 'Pane')
        mainbox.pack_start(mainpane, expand=1, fill=1)
        gtklogger.connect_passive(mainpane, 'notify::position')

        # Pinned nodes status in the left half of the main pane
        pnsframe = gtk.Frame("Pinned Nodes Status")
        pnsframe.set_shadow_type(gtk.SHADOW_IN)
        self.datascroll = gtk.ScrolledWindow()
        gtklogger.logScrollBars(self.datascroll, "StatusScroll")
        pnsframe.add(self.datascroll)
        self.datascroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.psdata = fixedwidthtext.FixedWidthTextView()
        self.psdata.set_editable(False)
        self.psdata.set_wrap_mode(gtk.WRAP_WORD)
        self.psdata.set_cursor_visible(False)
        self.datascroll.add_with_viewport(self.psdata)
        mainpane.pack1(pnsframe, resize=1, shrink=0)

        # Pin nodes method
        modframe = gtk.Frame("Pin Nodes Methods")
        gtklogger.setWidgetName(modframe, 'Modify')
        modframe.set_shadow_type(gtk.SHADOW_IN)
        modbox = gtk.VBox()  # will have "methods" and "buttons"
        modframe.add(modbox)
        self.pinModFactory = regclassfactory.RegisteredClassFactory(
            pinnodesmodifier.PinNodesModifier.registry,
            title="Method:",
            scope=self,
            name="Method")
        modbox.pack_start(self.pinModFactory.gtk, expand=1, fill=1, padding=2)

        # buttons
        hbox1 = gtk.HBox()
        modbox.pack_start(hbox1, expand=0, fill=0, padding=2)
        self.okbutton = gtk.Button(stock=gtk.STOCK_OK)
        gtklogger.setWidgetName(self.okbutton, 'OK')
        gtklogger.connect(self.okbutton, "clicked", self.okCB)
        tooltips.set_tooltip_text(self.okbutton,
                                  "Pin nodes with the selected method.")
        self.undobutton = gtk.Button(stock=gtk.STOCK_UNDO)
        gtklogger.setWidgetName(self.undobutton, 'Undo')
        gtklogger.connect(self.undobutton, "clicked", self.undoCB)
        tooltips.set_tooltip_text(self.undobutton, "Undo the latest action.")
        self.redobutton = gtk.Button(stock=gtk.STOCK_REDO)
        gtklogger.setWidgetName(self.redobutton, 'Redo')
        gtklogger.connect(self.redobutton, "clicked", self.redoCB)
        tooltips.set_tooltip_text(self.redobutton,
                                  "Redo the latest undone action.")
        hbox1.pack_start(self.undobutton, expand=0, fill=1, padding=2)
        hbox1.pack_start(self.okbutton, expand=1, fill=1, padding=2)
        hbox1.pack_end(self.redobutton, expand=0, fill=1, padding=2)

        hbox2 = gtk.HBox(homogeneous=1)
        modbox.pack_start(hbox2, expand=0, fill=0, padding=2)
        self.unpinallbutton = gtk.Button("Unpin All")
        gtklogger.setWidgetName(self.unpinallbutton, 'Unpin All')
        gtklogger.connect(self.unpinallbutton, "clicked", self.unpinallCB)
        tooltips.set_tooltip_text(self.unpinallbutton,
                                  "Unpin all the pinned nodes.")
        self.invertbutton = gtk.Button("Invert")
        gtklogger.setWidgetName(self.invertbutton, 'Invert')
        gtklogger.connect(self.invertbutton, "clicked", self.invertCB)
        tooltips.set_tooltip_text(
            self.invertbutton,
            "Invert - pin the unpinned and unpin the pinned.")
        hbox2.pack_start(self.unpinallbutton, expand=1, fill=1, padding=2)
        hbox2.pack_start(self.invertbutton, expand=1, fill=1, padding=2)

        mainpane.pack2(modframe, resize=0, shrink=0)

        # Switchboard callbacks
        switchboard.requestCallbackMain(('who changed', 'Skeleton'),
                                        self.changeSkeleton)
        switchboard.requestCallbackMain(('new who', 'Microstructure'),
                                        self.newMS)
        switchboard.requestCallbackMain("new pinned nodes",
                                        self.newNodesPinned)
        switchboard.requestCallbackMain(self.skelwidget, self.skel_update)
        switchboard.requestCallbackMain("made reservation",
                                        self.reservationChanged)
        switchboard.requestCallbackMain("cancelled reservation",
                                        self.reservationChanged)
예제 #48
0
    def __init__(self, name, infotb):
        toolboxGUI.GfxToolbox.__init__(self, name, infotb)
        self.mainbox = gtk.VBox()
        self.gtk.add(self.mainbox)

        ## TODO 3.1: Save the gui mode objects in the non-gui objects, and
        ## access them by asking the non-gui toolbox for the mode
        ## object (by name), and ask the mode object for the gui mode
        ## object.
        self.modeobjdict = {}  # key = mode name, value = mode instance

        self.clickIDs = {}

        clickframe = gtk.Frame()
        gtklogger.setWidgetName(clickframe, 'Click')
        clickframe.set_shadow_type(gtk.SHADOW_IN)
        self.mainbox.pack_start(clickframe, expand=0, fill=0)
        clickbox = gtk.VBox()
        clickframe.add(clickbox)

        hbox = gtk.HBox()
        clickbox.pack_start(hbox, expand=0, fill=0)
        hbox.pack_start(gtk.Label("Click on an: "), expand=0, fill=0)

        firstbutton = None
        firstmode = None
        self.modebuttonsignals = {}
        self.modebuttondict = {}
        buttons = []

        # Each subclass of GenericInfoToolboxGUI defines
        # modeClassDict(), which returns an ordered dictionary of
        # subclasses of GenericInfoModeGUI keyed by name.  The
        # dictionary is ordered just to make the initially selected
        # mode predictable.

        for modename, modeclass in self.modeClassDict().items():
            # Construct the GenericInfoModeGUI instances, which create
            # the widgets for the mode.
            mode = self.modeobjdict[modename] = modeclass(self)
            self.toolbox.getMode(modename).setGfxMode(mode)
            # Construct buttons for switching modes.
            if firstbutton is None:
                button = gtk.RadioButton(label=modename)
                firstbutton = button
                firstmode = mode
                # button.set_active(True)
                self.currentMode = modename
            else:
                button = gtk.RadioButton(label=modename, group=firstbutton)
                # button.set_active(False)
            buttons.append(button)
            gtklogger.setWidgetName(button, modename)
            self.modebuttondict[mode] = button
            tooltips.set_tooltip_text(button,
                                      "Show " + modename + " information.")
            self.modebuttonsignals[mode] = gtklogger.connect(
                button, 'clicked', self.changeModeCB, modename)

        firstbutton.set_active(True)

        # Place the button widgets in the hbox.  This is done by the
        # derived class, because the best arrangement may depend on
        # the number of buttons or other criteria.
        self.packModeButtons(hbox, buttons)

        # In 2D, information about the mouse click position is
        # displayed here.  It's not done in 3D because the conversion
        # from screen to physical coordinates depends on the query
        # mode.

        # Frame for info about the queried object.
        self.infoframe = gtk.Frame()
        self.infoframe.set_shadow_type(gtk.SHADOW_NONE)
        self.mainbox.pack_start(self.infoframe, expand=1, fill=1)

        # Install the first set of widgets.
        self.installInfoGUI(firstmode)

        # Subclasses may add extra buttons via this hook:
        self.addExtraWidgets(self.mainbox)

        # History buttons
        buttonbox = gtk.HBox()
        self.mainbox.pack_start(buttonbox, expand=0, fill=0)
        self.prev = gtkutils.prevButton()
        tooltips.set_tooltip_text(self.prev, "Go back to the previous object.")
        gtklogger.connect(self.prev, 'clicked', self.prevQuery)
        buttonbox.pack_start(self.prev, expand=0, fill=0, padding=2)

        self.clear = gtk.Button(stock=gtk.STOCK_CLEAR)
        gtklogger.setWidgetName(self.clear, 'Clear')
        gtklogger.connect(self.clear, 'clicked', self.clearButtonCB)
        tooltips.set_tooltip_text(self.clear, "Clear the current query.")
        buttonbox.pack_start(self.clear, expand=1, fill=1, padding=2)

        self.next = gtkutils.nextButton()
        tooltips.set_tooltip_text(self.next, "Go to the next object.")
        gtklogger.connect(self.next, 'clicked', self.nextQuery)
        buttonbox.pack_start(self.next, expand=0, fill=0, padding=2)

        self.mainbox.show_all()
        self.clearClickIDs()  # must be called after modeobjdict is filled
        self.sensitize()

        self.sbcallbacks = [
            switchboard.requestCallback((self.toolbox, "query"), self.queryCB),
            switchboard.requestCallbackMain((self.toolbox, "peek"),
                                            self.peekCB),
            switchboard.requestCallback((self.toolbox, "clear"), self.clearCB)
        ]
예제 #49
0
# if we're shutting down, as indicated by the shuttingdown flag, we
# just skip parts of the process.

# Note that renaming "shuttingdown" to "_shuttingdown" is a bad idea
# because Python destroys objects with names beginning with an
# underscore before it destroys other objects.

shuttingdown = False


def cleanUp():
    global shuttingdown
    shuttingdown = True


switchboard.requestCallbackMain("shutdown", cleanUp)

#=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=##=--=#

# BaseOutputStream does the work for OutputStream, which writes Output
# data to a file.  More than one OutputStream can write to the same
# file, which they do by sharing a single BaseOutputStream.

_allStreams = utils.OrderedDict()  # All BaseOutputStreams, keyed by filename
_streamsLock = lock.SLock()  # Controls access to _allStreams


class BaseOutputStream(object):
    def __init__(self, filename, mode, openfile):
        self.filename = filename
        self.file = None
예제 #50
0
파일: pixelPage.py 프로젝트: santiama/OOF3D
    def __init__(self):
        debug.mainthreadTest()
        oofGUI.MainPage.__init__(
            self,
            name="%s Selection"%Pixstring, ordering=71,
            tip="Modify the set of selected %ss."%pixstring)

        mainbox = gtk.VBox(spacing=2)
        self.gtk.add(mainbox)

        # Microstructure widget, centered at the top of the page.
        align = gtk.Alignment(xalign=0.5)
        mainbox.pack_start(align, expand=0, fill=0)
        centerbox = gtk.HBox(spacing=3)
        align.add(centerbox)
        label = gtk.Label('Microstructure=')
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        self.mswidget = whowidget.WhoWidget(microstructure.microStructures,
                                            scope=self)
        centerbox.pack_start(self.mswidget.gtk[0], expand=0, fill=0)
        
        mainpane = gtk.HPaned()
        gtklogger.setWidgetName(mainpane, 'Pane')
        mainbox.pack_start(mainpane, expand=1, fill=1)
        gtklogger.connect_passive(mainpane, 'notify::position')

        # Pixel selection status in the left half of the main pane
        pssframe = gtk.Frame( "%s Selection Status"%Pixstring)
        pssframe.set_shadow_type(gtk.SHADOW_IN)
        mainpane.pack1(pssframe, resize=1, shrink=0)
        self.datascroll = gtk.ScrolledWindow()
        gtklogger.logScrollBars(self.datascroll, "DataScroll")
        pssframe.add(self.datascroll)
        self.datascroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.psdata = fixedwidthtext.FixedWidthTextView()
        gtklogger.setWidgetName(self.psdata, 'DataView')
        self.psdata.set_editable(0)
        self.psdata.set_cursor_visible(False)
        self.psdata.set_wrap_mode(gtk.WRAP_WORD)
        self.datascroll.add_with_viewport(self.psdata)

        # Selection method in the right half of the main pane
        modframe = gtk.Frame("%s Selection Modification"%Pixstring)
        gtklogger.setWidgetName(modframe, "SelectionModification")
        modframe.set_shadow_type(gtk.SHADOW_IN)
        mainpane.pack2(modframe, resize=0, shrink=0)
        vbox = gtk.VBox()
        modframe.add(vbox)
##        scroll = gtk.ScrolledWindow()
##        scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
##        vbox.add(scroll)
        self.selectionModFactory = regclassfactory.RegisteredClassFactory(
            pixelselectionmod.SelectionModifier.registry, title="Method:",
            scope=self, name="Method")
        vbox.pack_start(self.selectionModFactory.gtk, expand=1, fill=1)
##        scroll.add_with_viewport(self.selectionModFactory.gtk)
        self.historian = historian.Historian(self.selectionModFactory.set,
                                             self.sensitizeHistory,
                                             setCBkwargs={'interactive':1})
        self.selectionModFactory.set_callback(self.historian.stateChangeCB)
        
        # Prev, OK, and Next buttons
        hbox = gtk.HBox()
        vbox.pack_start(hbox, expand=0, fill=0, padding=2)
        self.prevmethodbutton = gtkutils.prevButton()
        gtklogger.connect(self.prevmethodbutton, 'clicked',
                          self.historian.prevCB)
        hbox.pack_start(self.prevmethodbutton, expand=0, fill=0, padding=2)
        tooltips.set_tooltip_text(self.prevmethodbutton,
                     'Recall the previous selection modification operation.')
        self.okbutton = gtk.Button(stock=gtk.STOCK_OK)
        gtklogger.setWidgetName(self.okbutton, "OK")
        hbox.pack_start(self.okbutton, expand=1, fill=1, padding=2)
        gtklogger.connect(self.okbutton, 'clicked', self.okbuttonCB)
        tooltips.set_tooltip_text(self.okbutton,
              'Perform the selection modification operation defined above.')
        self.nextmethodbutton = gtkutils.nextButton()
        gtklogger.connect(self.nextmethodbutton, 'clicked',
                          self.historian.nextCB)
        hbox.pack_start(self.nextmethodbutton, expand=0, fill=0, padding=2)
        tooltips.set_tooltip_text(self.nextmethodbutton,
                        "Recall the next selection modification operation.")

        # Undo, Redo, and Clear buttons
        hbox = gtk.HBox()
        vbox.pack_start(hbox, expand=0, fill=0, padding=2)
        self.undobutton = gtk.Button(stock=gtk.STOCK_UNDO)
        self.redobutton = gtk.Button(stock=gtk.STOCK_REDO)
        hbox.pack_start(self.undobutton, expand=1, fill=0)
        hbox.pack_start(self.redobutton, expand=1, fill=0)
        gtklogger.setWidgetName(self.undobutton, "Undo")
        gtklogger.setWidgetName(self.redobutton, "Redo")
        gtklogger.connect(self.undobutton, 'clicked', self.undoCB)
        gtklogger.connect(self.redobutton, 'clicked', self.redoCB)
        tooltips.set_tooltip_text(
            self.undobutton,
            "Undo the previous %s selection operation."%pixstring)
        tooltips.set_tooltip_text(
            self.redobutton,
            "Redo an undone %s selection operation."%pixstring)
        self.clearbutton = gtk.Button(stock=gtk.STOCK_CLEAR)
        hbox.pack_start(self.clearbutton, expand=1, fill=0)
        gtklogger.setWidgetName(self.clearbutton, "Clear")
        gtklogger.connect(self.clearbutton, 'clicked', self.clearCB)
        tooltips.set_tooltip_text(self.clearbutton,
                                  "Unselect all %ss."%pixstring)

        self.sbcallbacks = [
            switchboard.requestCallbackMain(self.mswidget,
                                            self.mswidgetCB),
            switchboard.requestCallbackMain('pixel selection changed',
                                            self.selectionChanged),
            switchboard.requestCallbackMain('modified pixel selection',
                                            self.updateHistory),
            switchboard.requestCallbackMain(
                pixelselectionmod.SelectionModifier,
                self.updateSelectionModifiers),
            switchboard.requestCallbackMain(('validity',
                                             self.selectionModFactory),
                                            self.validityChangeCB),
            switchboard.requestCallbackMain("made reservation",
                                            self.reservationCB),
            switchboard.requestCallbackMain("cancelled reservation",
                                            self.reservationCB)
            ]

        self.updatePSInfo()
        self.sensitize()
        self.sensitizeHistory()
예제 #51
0
    def __init__(self, gfxwindow):
        self.gfxwindow = gfxwindow
        
        ## TODO 3.1: buttonrow should really have a gtklogger name
        ## assigned to it.  That would require all of the gui scripts
        ## to be updated.
        buttonrow = gtk.HBox()

        self.selectbutton = gtk.RadioButton(label='Select')
        buttonrow.pack_start(self.selectbutton, expand=0, fill=0)
        gtklogger.setWidgetName(self.selectbutton, 'select')
        gtklogger.connect(self.selectbutton, 'clicked', self.selectCB)
        tooltips.set_tooltip_text(
            self.selectbutton,
            "Click on the graphics window to select objects"
            " according to the current selection mode.")

        tumblebutton = gtk.RadioButton(label='Tumble', group=self.selectbutton)
        buttonrow.pack_start(tumblebutton, expand=0, fill=0)
        gtklogger.setWidgetName(tumblebutton, 'tumble')
        gtklogger.connect(tumblebutton, 'clicked', self.tumbleCB)
        tooltips.set_tooltip_text(
            tumblebutton,
            "Click and drag on the graphics window to rotate the view.")

        dollybutton = gtk.RadioButton(label='Dolly', group=self.selectbutton)
        buttonrow.pack_start(dollybutton, expand=0, fill=0)
        gtklogger.setWidgetName(dollybutton, 'dolly')
        gtklogger.connect(dollybutton, 'clicked', self.dollyCB)
        tooltips.set_tooltip_text(
            dollybutton,
            "Click and drag on the graphics window to move the viewpoint"
            " closer to or further from the displayed objects.")

        trackbutton = gtk.RadioButton(label='Track', group=self.selectbutton)
        buttonrow.pack_start(trackbutton, expand=0, fill=0)
        gtklogger.setWidgetName(trackbutton, 'track')
        gtklogger.connect(trackbutton, 'clicked', self.trackCB)
        tooltips.set_tooltip_text(
            trackbutton,
            "Click and drag on the graphics window to move the"
            " displayed objects.")
        
        self.fillbutton = gtk.Button("Fill")
        gtklogger.setWidgetName(self.fillbutton, "fill")
        buttonrow.pack_start(self.fillbutton, expand=0, fill=0)
        tooltips.set_tooltip_text(
            self.fillbutton,
            "Dolly in or out such that visible objects approximately"
            " fill the viewport")
        gtklogger.connect(self.fillbutton, "clicked", self.fillCB)


        viewbox = gtk.HBox()
        buttonrow.pack_end(viewbox, expand=0, fill=0)

        self.prevButton = gtkutils.StockButton(gtk.STOCK_GO_BACK)
        viewbox.pack_start(self.prevButton, expand=0, fill=0)
        gtklogger.setWidgetName(self.prevButton, "PrevView")
        gtklogger.connect(self.prevButton, 'clicked', self.prevViewCB)
        tooltips.set_tooltip_text(self.prevButton, 
                                  "Reinstate the previous view.")

        self.viewChooser = chooser.ChooserWidget(viewertoolbox.viewNames(),
                                                 callback=self.setView,
                                                 name="viewChooser")
        viewbox.pack_start(self.viewChooser.gtk, expand=0, fill=0)
        self.gfxwindow.addSwitchboardCallback(
            switchboard.requestCallbackMain("view changed", self.viewChangedCB),
            switchboard.requestCallbackMain("view restored", self.viewChangedCB)
        )

        self.nextButton = gtkutils.StockButton(gtk.STOCK_GO_FORWARD)
        viewbox.pack_start(self.nextButton, expand=0, fill=0)
        gtklogger.setWidgetName(self.nextButton, "NextView")
        gtklogger.connect(self.nextButton, 'clicked', self.nextViewCB)
        tooltips.set_tooltip_text(self.nextButton, "Reinstate the next view.")

        # TODO 3.1: more useful things in the toolbar?
        self.gtk = buttonrow

        self.tumbleHandler = TumbleMouseHandler(gfxwindow)
        self.dollyHandler = DollyMouseHandler(gfxwindow)
        self.trackHandler = TrackMouseHandler(gfxwindow)
예제 #52
0
    def __init__(self, pixelinfotoolbox):
        debug.mainthreadTest()
        toolboxGUI.GfxToolbox.__init__(self, "Pixel Info", pixelinfotoolbox)
        mainbox = gtk.VBox()
        self.gtk.add(mainbox)

        self.table = gtk.Table(rows=3, columns=2)
        mainbox.pack_start(self.table, expand=0, fill=0)

        label = gtk.Label('x=')
        label.set_alignment(1.0, 0.5)
        self.table.attach(label, 0, 1, 0, 1, xpadding=5, xoptions=gtk.FILL)
        self.xtext = gtk.Entry()
        gtklogger.setWidgetName(self.xtext, "X")
        self.xtext.set_size_request(10 * guitop.top().digitsize, -1)
        self.table.attach(self.xtext,
                          1,
                          2,
                          0,
                          1,
                          xpadding=5,
                          xoptions=gtk.EXPAND | gtk.FILL)
        label = gtk.Label('y=')
        label.set_alignment(1.0, 0.5)
        self.table.attach(label, 0, 1, 1, 2, xpadding=5, xoptions=gtk.FILL)
        self.ytext = gtk.Entry()
        gtklogger.setWidgetName(self.ytext, "Y")
        self.ytext.set_size_request(10 * guitop.top().digitsize, -1)
        self.table.attach(self.ytext,
                          1,
                          2,
                          1,
                          2,
                          xpadding=5,
                          xoptions=gtk.EXPAND | gtk.FILL)

        self.xtsignal = gtklogger.connect(self.xtext, 'changed',
                                          self.pointChanged)
        self.ytsignal = gtklogger.connect(self.ytext, 'changed',
                                          self.pointChanged)

        box = gtk.HBox(homogeneous=True, spacing=2)
        self.updatebutton = gtkutils.StockButton(gtk.STOCK_REFRESH, 'Update')
        box.pack_start(self.updatebutton, expand=1, fill=1)
        gtklogger.setWidgetName(self.updatebutton, "Update")
        gtklogger.connect(self.updatebutton, 'clicked', self.updateButtonCB)
        self.clearbutton = gtkutils.StockButton(gtk.STOCK_CLEAR, 'Clear')
        box.pack_start(self.clearbutton, expand=1, fill=1)
        gtklogger.setWidgetName(self.clearbutton, "Clear")
        gtklogger.connect(self.clearbutton, 'clicked', self.clearButtonCB)
        self.table.attach(box,
                          0,
                          2,
                          2,
                          3,
                          xpadding=5,
                          xoptions=gtk.EXPAND | gtk.FILL,
                          yoptions=0)

        self.updatebutton.set_sensitive(0)
        self.clearbutton.set_sensitive(0)
        self.buildGUI()

        self.sbcallbacks = [
            switchboard.requestCallbackMain(pixelinfotoolbox, self.update),
            switchboard.requestCallbackMain('new pixelinfo plugin',
                                            self.buildGUI),
            switchboard.requestCallbackMain(
                (self.gfxwindow(), 'layers changed'), self.update)
        ]
예제 #53
0
    def __init__(self):
        debug.mainthreadTest()
        self.menu_name = "MessageWindow_%d" % MessageWindow.count
        self.title = "%s Messages %d" % (subWindow.oofname(),
                                         MessageWindow.count)
        self.windows_menu_name = "Message_%d" % MessageWindow.count

        subWindow.SubWindow.__init__(self,
                                     title=self.title,
                                     menu=self.menu_name)

        # We are locally responsible for the windows submenu items.
        self.gtk.connect("destroy", self.destroy)

        # raise_window function is provided by the SubWindow class.
        OOF.Windows.Messages.addItem(
            oofmenu.OOFMenuItem(self.windows_menu_name,
                                help="Raise Message window %d." %
                                MessageWindow.count,
                                cli_only=0,
                                no_log=1,
                                gui_callback=self.raise_window))

        MessageWindow.count += 1

        allMessageWindows.add(self)

        # Control box, with buttons.  These could be menu items.
        controlbox = gtk.Frame()
        controlbox.set_shadow_type(gtk.SHADOW_OUT)
        self.mainbox.pack_start(controlbox, expand=0, fill=0)
        controlinnards = gtk.VBox()
        controlbox.add(controlinnards)
        buttonbox = gtk.HBox()
        controlinnards.pack_start(buttonbox, expand=0, padding=2)
        savebutton = gtkutils.StockButton(gtk.STOCK_SAVE, "Save...")
        tooltips.set_tooltip_text(
            savebutton, "Save the contents of this window to a file.")
        buttonbox.pack_start(savebutton, expand=0, fill=0, padding=2)
        gtklogger.setWidgetName(savebutton, "Save")
        gtklogger.connect(savebutton, 'clicked', self.saveButtonCB)

        self.button_dict = {}
        self.signal_dict = {}
        for m in reversed(reporter.messageclasses):
            button = gtk.CheckButton(m)
            gtklogger.setWidgetName(button, m)
            buttonbox.pack_end(button, fill=0, expand=0, padding=2)
            self.signal_dict[m] = gtklogger.connect(button, "clicked",
                                                    self.button_click)
            self.button_dict[m] = button
            tooltips.set_tooltip_text(
                button, "Show or hide " + reporter.messagedescriptions[m])
        buttonbox.pack_end(gtk.Label("Show:"), fill=0, expand=0, padding=2)

        messagepane = gtk.ScrolledWindow()
        ## The ScrolledWindow's scrollbars are *not* logged in the
        ## gui, because blocking the adjustment "changed" signals in
        ## the write_message function, below, doesn't work to suppress
        ## logging.  This means that programmatic changes to the
        ## scrollbars are logged along with user changes, which fills
        ## up the log file with extraneous lines.
        messagepane.set_border_width(4)
        messagepane.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        self.mainbox.add(messagepane)

        self.messages = gtk.TextView()
        gtklogger.setWidgetName(self.messages, "Text")
        self.messages.set_editable(False)
        self.messages.set_cursor_visible(False)
        self.messages.set_wrap_mode(gtk.WRAP_WORD)
        self.changeFont(mainmenuGUI.getFixedFont())

        self.gtk.set_default_size(90 * gtkutils.widgetCharSize(self.messages),
                                  200)

        # Get two marks to be used for automatic scrolling
        bfr = self.messages.get_buffer()
        enditer = bfr.get_end_iter()
        self.endmark = bfr.create_mark(None, enditer, False)
        self.midmark = bfr.create_mark(None, enditer, False)

        messagepane.add(self.messages)

        self.state_dict = {}
        for m in reporter.messageclasses:
            self.state_dict[m] = 1

        self.sbcbs = [
            switchboard.requestCallbackMain("write message",
                                            self.write_message),
            switchboard.requestCallbackMain("change fixed font",
                                            self.changeFont)
        ]

        self.draw()
예제 #54
0
    def __init__(self):
        oofGUI.MainPage.__init__(
            self,
            name="Boundary Conditions",
            ordering=230,
            tip=
            "Set field and flux boundary conditions on the mesh's boundaries.")
        mainbox = gtk.VBox(spacing=2)
        self.gtk.add(mainbox)

        align = gtk.Alignment(xalign=0.5)
        mainbox.pack_start(align, expand=0, fill=0)
        centerbox = gtk.HBox(spacing=3)
        align.add(centerbox)
        self.meshwidget = whowidget.WhoWidget(ooflib.engine.mesh.meshes,
                                              callback=self.meshCB,
                                              scope=self)
        label = gtk.Label("Microstructure=")
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        centerbox.pack_start(self.meshwidget.gtk[0], expand=0, fill=0)
        label = gtk.Label("Skeleton=")
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        centerbox.pack_start(self.meshwidget.gtk[1], expand=0, fill=0)
        label = gtk.Label("Mesh=")
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        centerbox.pack_start(self.meshwidget.gtk[2], expand=0, fill=0)
        switchboard.requestCallbackMain(self.meshwidget, self.meshwidgetCB)

        bcbuildframe = gtk.Frame("Condition")
        gtklogger.setWidgetName(bcbuildframe, 'Condition')
        bcbuildframe.set_shadow_type(gtk.SHADOW_IN)
        mainbox.pack_start(bcbuildframe, expand=1, fill=1)
        bcbuildbox = gtk.VBox(spacing=2)
        bcbuildframe.add(bcbuildbox)

        # Buttons for creating, editing and removing boundary conditions

        align = gtk.Alignment(xalign=0.5)
        bcbuildbox.pack_start(align, expand=0, fill=0, padding=3)
        bcbuttons = gtk.HBox(homogeneous=1, spacing=3)
        align.add(bcbuttons)

        self.bcNew = gtk.Button("New...")
        gtklogger.setWidgetName(self.bcNew, 'New')
        gtklogger.connect(self.bcNew, "clicked", self.bcNew_CB)
        tooltips.set_tooltip_text(
            self.bcNew, "Create a new boundary condition in the current mesh.")
        bcbuttons.pack_start(self.bcNew, expand=1, fill=1)

        self.bcRename = gtk.Button("Rename...")
        gtklogger.setWidgetName(self.bcRename, 'Rename')
        gtklogger.connect(self.bcRename, 'clicked', self.bcRename_CB)
        tooltips.set_tooltip_text(self.bcRename,
                                  "Rename the selected boundary condition.")
        bcbuttons.pack_start(self.bcRename, expand=1, fill=1)

        self.bcEdit = gtk.Button("Edit...")
        gtklogger.setWidgetName(self.bcEdit, 'Edit')
        gtklogger.connect(self.bcEdit, 'clicked', self.bcEdit_CB)
        tooltips.set_tooltip_text(self.bcEdit,
                                  "Edit the selected boundary condition.")
        bcbuttons.pack_start(self.bcEdit, expand=1, fill=1)

        self.bcCopy = gtk.Button("Copy...")
        gtklogger.setWidgetName(self.bcCopy, 'Copy')
        gtklogger.connect(self.bcCopy, 'clicked', self.bcCopy_CB)
        tooltips.set_tooltip_text(
            self.bcCopy,
            "Copy the selected boundary condition to another mesh.")
        bcbuttons.pack_start(self.bcCopy, expand=1, fill=1)

        self.bcCopyAll = gtk.Button("Copy All...")
        gtklogger.setWidgetName(self.bcCopyAll, 'CopyAll')
        gtklogger.connect(self.bcCopyAll, 'clicked', self.bcCopyAll_CB)
        tooltips.set_tooltip_text(
            self.bcCopyAll,
            "Copy all the boundary conditions to another mesh.")
        bcbuttons.pack_start(self.bcCopyAll, expand=1, fill=1)

        self.bcDel = gtk.Button("Delete")
        gtklogger.setWidgetName(self.bcDel, 'Delete')
        gtklogger.connect(self.bcDel, "clicked", self.bcDel_CB)
        tooltips.set_tooltip_text(self.bcDel,
                                  "Remove the selected boundary condition.")
        bcbuttons.pack_start(self.bcDel, expand=1, fill=1)

        # List of boundary conditions
        bcscroll = gtk.ScrolledWindow()
        gtklogger.logScrollBars(bcscroll, "BCScroll")
        bcbuildbox.pack_start(bcscroll, expand=1, fill=1)
        bcscroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.bclist = BCList(self)
        bcscroll.add(self.bclist.gtk)

        self.bclist.update(None)

        switchboard.requestCallbackMain(("new who", "Microstructure"),
                                        self.newMSorSkeleton)
        switchboard.requestCallbackMain(("new who", "Skeleton"),
                                        self.newMSorSkeleton)

        # Callbacks for when the mesh changes state internally.
        switchboard.requestCallbackMain("boundary conditions changed",
                                        self.newBCs)
        switchboard.requestCallbackMain("boundary conditions toggled",
                                        self.toggleBCs)
        switchboard.requestCallbackMain("field defined", self.fieldDefined)
        switchboard.requestCallbackMain("equation activated",
                                        self.eqnActivated)
        switchboard.requestCallbackMain("made reservation",
                                        self.reservationChanged)
        switchboard.requestCallbackMain("cancelled reservation",
                                        self.reservationChanged)
        switchboard.requestCallbackMain("mesh boundaries changed",
                                        self.newMeshBoundaries)
        switchboard.requestCallbackMain("mesh status changed",
                                        self.statusChanged)
예제 #55
0
    def __init__(self, meshinfo):
        toolboxGUI.GfxToolbox.__init__(self, "Mesh Info", meshinfo)
        self.mainbox = gtk.VBox()
        self.gtk.add(self.mainbox)

        self.modeclass = ElementMode
        self.modeobj = None
        self.modeobjdict = {}

        clickframe = gtk.Frame()
        gtklogger.setWidgetName(clickframe, 'Click')
        clickframe.set_shadow_type(gtk.SHADOW_IN)
        self.mainbox.pack_start(clickframe, expand=0, fill=0)
        clickbox = gtk.VBox()
        clickframe.add(clickbox)

        hbox = gtk.HBox()
        clickbox.pack_start(hbox, expand=0, fill=0)
        hbox.pack_start(gtk.Label("Click on an: "), expand=0, fill=0)

        self.modebuttons = []
        self.modebuttonsignals = []
        for mode in modes:
            if self.modebuttons:
                button = gtk.RadioButton(label=mode.targetname,
                                        group=self.modebuttons[0])
            else:
                button = gtk.RadioButton(label=mode.targetname)
            gtklogger.setWidgetName(button, mode.targetname)
            self.modebuttons.append(button)
            tooltips.set_tooltip_text(button,
                               "Show " + mode.targetname + " information")
            hbox.pack_start(button, expand=0, fill=0)
            button.set_active(self.modeclass is mode)
            self.modebuttonsignals.append(
                gtklogger.connect(button, 'clicked', self.changeModeCB, mode))
                        
        # Display mouse click coordinates
        self.table = gtk.Table(columns=2, rows=config.dimension()+1)
        clickbox.pack_start(self.table, expand=0, fill=0)

        label = gtk.Label('x=')
        label.set_alignment(1.0, 0.5)
        self.table.attach(label, 0,1, 0,1, xpadding=5, xoptions=gtk.FILL)
        self.xtext = gtk.Entry()
        gtklogger.setWidgetName(self.xtext,'X')
        self.xtext.set_editable(0)
        self.xtext.set_size_request(13*guitop.top().charsize, -1)
        self.table.attach(self.xtext, 1,2, 0,1,
                          xpadding=5, xoptions=gtk.EXPAND|gtk.FILL)
        tooltips.set_tooltip_text(self.xtext,"x coordinate of the mouse click")
        label = gtk.Label('y=')
        label.set_alignment(1.0, 0.5)
        self.table.attach(label, 0,1, 1,2, xpadding=5, xoptions=gtk.FILL)
        self.ytext = gtk.Entry()
        gtklogger.setWidgetName(self.ytext,'Y')
        self.ytext.set_size_request(13*guitop.top().charsize, -1)
        self.ytext.set_editable(0)
        self.table.attach(self.ytext, 1,2, 1,2,
                          xpadding=5, xoptions=gtk.EXPAND|gtk.FILL)
        tooltips.set_tooltip_text(self.ytext,"y coordinate of the mouse click")
        if config.dimension() == 3:
            label = gtk.Label('z=')
            label.set_alignment(1.0, 0.5)
            self.table.attach(label, 0,1, 2,3, xpadding=5, xoptions=gtk.FILL)
            self.ztext = gtk.Entry()
            gtklogger.setWidgetName(self.ztext,'Z')
            self.ztext.set_size_request(13*guitop.top().charsize, -1)
            self.ztext.set_editable(0)
            self.table.attach(self.ztext, 1,2, 2,3,
                              xpadding=5, xoptions=gtk.EXPAND|gtk.FILL)
            tooltips.set_tooltip_text(self.ztext,"z coordinate of the mouse click")
            

        # End of clicked point display

        self.infoframe = gtk.Frame()
        self.infoframe.set_shadow_type(gtk.SHADOW_NONE)
        self.mainbox.pack_start(self.infoframe, expand=1, fill=1)
        self.meshcontext = self.toolbox.meshcontext()
        self.buildInfoGUI(self.modeclass)
        # End of query data display

        align = gtk.Alignment(xalign=0.5)
        self.mainbox.pack_start(align, expand=0, fill=0, padding=2)
        centerbox = gtk.HBox()
        align.add(centerbox)
        self.meshdatabutton = gtkutils.StockButton(gtk.STOCK_DIALOG_INFO,
                                                   'New Data Viewer...')
        gtklogger.setWidgetName(self.meshdatabutton, "NewDataViewer")
        centerbox.pack_start(self.meshdatabutton, expand=0, fill=0)
        gtklogger.connect(self.meshdatabutton, 'clicked', self.meshdataCB)
        tooltips.set_tooltip_text(self.meshdatabutton,
                             "Open a window to display fields, fluxes, and other quantities evaluated at the mouse click location.")

        buttonbox = gtk.HBox()
        self.mainbox.pack_start(buttonbox, expand=0, fill=0)
        self.prev = gtkutils.prevButton()
        tooltips.set_tooltip_text(self.prev,"Go back to the previous object.")
        gtklogger.connect(self.prev, 'clicked', self.prevQuery)
        buttonbox.pack_start(self.prev, expand=0, fill=0, padding=2)
        
        self.clear = gtk.Button(stock=gtk.STOCK_CLEAR)
        gtklogger.setWidgetName(self.clear, 'Clear')
        gtklogger.connect(self.clear, 'clicked', self.clearQuery)
        tooltips.set_tooltip_text(self.clear,"Clear the current query.")
        buttonbox.pack_start(self.clear, expand=1, fill=1, padding=2)

        self.next = gtkutils.nextButton()
        tooltips.set_tooltip_text(self.next,"Go to the next object.")
        gtklogger.connect(self.next, 'clicked', self.nextQuery)
        buttonbox.pack_start(self.next, expand=0, fill=0, padding=2)

        self.mainbox.show_all()
        self.sensitize()

        self.mouse_xposition = None
        self.mouse_yposition = None
        self.mesh_xposition = None
        self.mesh_yposition = None
        if config.dimension() == 3:
            self.mouse_zposition = None
            self.mesh_zposition = None
        
        self.sbcallbacks = [
            switchboard.requestCallbackMain((self.toolbox.gfxwindow(),
                                             "query mesh"),
                                            self.updateQuery),
            switchboard.requestCallbackMain("mesh changed",
                                            self.meshChanged),
            switchboard.requestCallbackMain("mesh data changed",
                                            self.meshDataChanged),
            switchboard.requestCallbackMain("subproblem changed",
                                            self.subproblemChanged),
            switchboard.requestCallbackMain( (self.toolbox, "new layers"),
                                             self.newLayers),
            switchboard.requestCallbackMain( (self.toolbox, "clear"),
                                             self.toolboxClear),
            switchboard.requestCallbackMain((self.toolbox.gfxwindow(),
                                             "time changed"),
                                            self.updateQuery)
            ]
예제 #56
0
    def __init__(self):
        oofGUI.MainPage.__init__(self,
                                 name="Equations",
                                 ordering=220,
                                 tip="Define equations for the mesh to solve.")
        mainbox = gtk.VBox()
        self.gtk.add(mainbox)

        align = gtk.Alignment(xalign=0.5)
        mainbox.pack_start(align, expand=0, fill=0)
        centerbox = gtk.HBox(spacing=3)
        align.add(centerbox)
        self.subpwidget = whowidget.WhoWidget(whoville.getClass('SubProblem'),
                                              scope=self)
        switchboard.requestCallbackMain(self.subpwidget, self.subpwidgetCB)
        label = gtk.Label("Microstructure=")
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        centerbox.pack_start(self.subpwidget.gtk[0], expand=0, fill=0)
        label = gtk.Label("Skeleton=")
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        centerbox.pack_start(self.subpwidget.gtk[1], expand=0, fill=0)
        label = gtk.Label("Mesh=")
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        centerbox.pack_start(self.subpwidget.gtk[2], expand=0, fill=0)
        label = gtk.Label("SubProblem=")
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        centerbox.pack_start(self.subpwidget.gtk[3], expand=0, fill=0)

        eqnframe = gtk.Frame("Equations")
        eqnframe.set_shadow_type(gtk.SHADOW_IN)
        scroll = gtk.ScrolledWindow()
        gtklogger.logScrollBars(scroll, "Equations")
        scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        eqnframe.add(scroll)
        bbox = gtk.VBox(
        )  # extra layer keeps table from expanding inside scroll
        scroll.add_with_viewport(bbox)
        self.eqntable = gtk.Table()
        bbox.pack_start(self.eqntable, expand=0, fill=0)
        self.eqnbuttons = {}
        self.build_eqnTable()
        switchboard.requestCallbackMain("new equation", self.newEquationCB)
        switchboard.requestCallbackMain("equation activated",
                                        self.activateEqnCB)
        #         switchboard.requestCallbackMain("kinetics activated",
        #                                         self.activateKinCB)
        #         switchboard.requestCallbackMain("dynamics activated",
        #                                         self.activateDynCB)
        mainbox.pack_start(eqnframe, expand=1, fill=1)

        copybox = gtk.HBox(spacing=3)
        self.copybutton = gtk.Button("Copy Equation State")
        gtklogger.setWidgetName(self.copybutton, "Copy")
        gtklogger.connect(self.copybutton, "clicked", self.copyeqstateCB)
        copybox.pack_start(self.copybutton, expand=1, fill=0)
        mainbox.pack_start(copybox, expand=0, fill=0)
        tooltips.set_tooltip_text(
            self.copybutton,
            "Copy the status of all equations from the current mesh to another mesh."
        )

        switchboard.requestCallbackMain(("new who", "Microstructure"),
                                        self.newSkeletonOrMesh)
        switchboard.requestCallbackMain(("new who", "Skeleton"),
                                        self.newSkeletonOrMesh)
        switchboard.requestCallbackMain(("new who", "Mesh"),
                                        self.newSkeletonOrMesh)
        ##        switchboard.requestCallbackMain(("new who", "SubProblem"),
        ##                                        self.newSubProblem)
        ##        switchboard.requestCallbackMain(("remove who", "SubProblem"),
        ##                                        self.removeSubProblem)
        switchboard.requestCallbackMain("made reservation",
                                        self.reservationChanged)
        switchboard.requestCallbackMain("cancelled reservation",
                                        self.reservationChanged)
예제 #57
0
 def __init__(self, param, scope, name=None):
     MeshParamWidget.__init__(self, param, mesh.Mesh.subproblems, scope,
                              name)
     self.sbcallbacks.append(
         switchboard.requestCallbackMain(("new who", "SubProblem"),
                                         self.newSubProblemCB))
예제 #58
0
    def __init__(self,
                 whoclass,
                 value,
                 callback,
                 scope,
                 condition,
                 sort,
                 widgettype,
                 verbose=False):
        debug.mainthreadTest()
        self.whoclass = whoclass
        self.scope = scope  # WidgetScope object
        self.verbose = verbose
        # condition(obj) is a function that returns 1 if the object
        # should be listed.
        self.condition = condition

        # sort is a function that takes a list of names and sorts them
        # into the order in which they should appear in the GUI.
        self.sort = sort

        # widgettype must be either 'Chooser' or 'Combo'.  It
        # specifies the type of subwidget to use for the lowest widget
        # in the Who hierarchy.
        self.widgettype = widgettype

        if scope:
            scope.addWidget(self)

        # If the WidgetScope contains 'fixed whoclass' data, then the
        # given class and its parent classes aren't allowed to be
        # changed. Make their widgets insensitive.  The data's key is
        # "fixed whoclass", and its value is a tuple,
        # (WhoClass name, colon separated who path).
        try:
            fixedname, fixedwho = scope.findData('fixed whoclass')
        except:
            self.fixeddepth = -1
        else:
            self.fixeddepth = \
                [w.name() for w in whoclass.hierarchy()].index(fixedname)
        if self.fixeddepth >= 0:
            value = fixedwho

        self.callback = callback
        depth = len(whoclass.hierarchy())
        self.proxy_names = []
        self.widgets = [None] * depth
        self.gtk = [None] * depth
        self.currentPath = [''] * depth
        self.destroysignals = [None] * depth
        self.buildWidgets(value)  # sets currentPath, widgets, and gtk
        self.sbcallbacks = []
        for whoklass in whoclass.hierarchy():
            self.sbcallbacks += [
                switchboard.requestCallbackMain(('new who', whoklass.name()),
                                                self.newWhoCB),
                switchboard.requestCallbackMain(
                    ('remove who', whoklass.name()), self.newWhoCB),
                switchboard.requestCallbackMain(
                    ('rename who', whoklass.name()), self.renameWhoCB)
            ]
예제 #59
0
    def __init__(self, toolbox, table, row):
        debug.mainthreadTest()
        pixelinfoplugin.PixelInfoPlugIn.__init__(self, toolbox)

        # Colorv is set by "update" and "nonsense", it can be None (no
        # color), -1 (Nonsense), or a color.Color object.
        # Statefulness is needed to remain consistent when a user
        # switches from RGB to HSV or vice versa.
        self.colorv = None

        label = gtk.Label('image=')
        label.set_alignment(1.0, 0.5)
        table.attach(label, 0, 1, row, row + 1, xpadding=5, xoptions=gtk.FILL)
        self.imagetext = gtk.Entry()
        gtklogger.setWidgetName(self.imagetext, "Image")
        self.imagetext.set_size_request(12 * guitop.top().charsize, -1)
        self.imagetext.set_editable(0)
        table.attach(self.imagetext,
                     1,
                     2,
                     row,
                     row + 1,
                     xpadding=5,
                     xoptions=gtk.EXPAND | gtk.FILL)

        selectorbox = gtk.HBox()
        self.rgb_selector = gtk.RadioButton(group=None, label="RGB")
        tooltips.set_tooltip_text(
            self.rgb_selector, "View color values in Red-Green-Blue format.")
        selectorbox.add(self.rgb_selector)
        self.hsv_selector = gtk.RadioButton(group=self.rgb_selector,
                                            label="HSV")
        tooltips.set_tooltip_text(
            self.hsv_selector,
            "View color values in Hue-Saturation-Value format.")
        selectorbox.add(self.hsv_selector)
        self.rgb_selector.set_active(1)  # Default.

        # Because this is a two-element group of radio buttons, only
        # need to connect to the toggle signal on one of the buttons.
        # If more buttons get added, this strategy will fail.
        gtklogger.setWidgetName(self.rgb_selector, "RGB selector")
        # "toggle" signal is not actually logged.
        # gtklogger.connect(self.rgb_selector, "toggled", self.selector_cb)

        gtklogger.setWidgetName(self.hsv_selector, "HSV selector")
        gtklogger.connect(self.rgb_selector, "clicked", self.selector_cb)
        gtklogger.connect(self.hsv_selector, "clicked", self.selector_cb)

        table.attach(selectorbox,
                     0,
                     2,
                     row + 1,
                     row + 2,
                     xoptions=gtk.EXPAND | gtk.FILL)

        self.label1 = gtk.Label('red=')
        self.label1.set_alignment(1.0, 0.5)
        table.attach(self.label1,
                     0,
                     1,
                     row + 2,
                     row + 3,
                     xpadding=5,
                     xoptions=gtk.FILL)
        self.text1 = gtk.Entry()
        gtklogger.setWidgetName(self.text1, 'Text 1')
        self.text1.set_size_request(10 * guitop.top().digitsize, -1)
        self.text1.set_editable(0)
        table.attach(self.text1,
                     1,
                     2,
                     row + 2,
                     row + 3,
                     xpadding=5,
                     xoptions=gtk.EXPAND | gtk.FILL)

        self.label2 = gtk.Label('green=')
        self.label2.set_alignment(1.0, 0.5)
        table.attach(self.label2,
                     0,
                     1,
                     row + 3,
                     row + 4,
                     xpadding=5,
                     xoptions=gtk.FILL)
        self.text2 = gtk.Entry()
        gtklogger.setWidgetName(self.text2, 'Text 2')
        self.text2.set_size_request(10 * guitop.top().digitsize, -1)
        self.text2.set_editable(0)
        table.attach(self.text2,
                     1,
                     2,
                     row + 3,
                     row + 4,
                     xpadding=5,
                     xoptions=gtk.EXPAND | gtk.FILL)

        self.label3 = gtk.Label('blue=')
        self.label3.set_alignment(1.0, 0.5)
        table.attach(self.label3,
                     0,
                     1,
                     row + 4,
                     row + 5,
                     xpadding=5,
                     xoptions=gtk.FILL)
        self.text3 = gtk.Entry()
        gtklogger.setWidgetName(self.text3, 'Text 3')
        self.text3.set_size_request(10 * guitop.top().digitsize, -1)
        self.text3.set_editable(0)
        table.attach(self.text3,
                     1,
                     2,
                     row + 4,
                     row + 5,
                     xpadding=5,
                     xoptions=gtk.EXPAND | gtk.FILL)

        self.sbcallbacks = [
            switchboard.requestCallbackMain('modified image',
                                            self.image_changed)
        ]
예제 #60
0
    def __init__(self):
        self.built = False
        oofGUI.MainPage.__init__(self,
                                 name="Active %s" % Spacestring,
                                 ordering=71.1,
                                 tip="Modify active %s." % spacestring)

        mainbox = gtk.VBox(spacing=2)
        self.gtk.add(mainbox)

        # Microstructure widget, centered at the top of the page.
        align = gtk.Alignment(xalign=0.5)
        mainbox.pack_start(align, expand=0, fill=0)
        centerbox = gtk.HBox(spacing=3)
        align.add(centerbox)
        label = gtk.Label('Microstructure=')
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)
        self.mswidget = whowidget.WhoWidget(microstructure.microStructures,
                                            scope=self)
        centerbox.pack_start(self.mswidget.gtk[0], expand=0, fill=0)

        mainpane = gtk.HPaned()
        gtklogger.setWidgetName(mainpane, 'Pane')
        mainbox.pack_start(mainpane, expand=1, fill=1)
        gtklogger.connect_passive(mainpane, 'notify::position')

        # Active area status in the left half of the main pane.
        vbox = gtk.VBox()
        mainpane.pack1(vbox, resize=1, shrink=0)
        aasframe = gtk.Frame("Active %s Status" % Spacestring)
        aasframe.set_shadow_type(gtk.SHADOW_IN)
        vbox.pack_start(aasframe, expand=0, fill=0, padding=2)
        self.aainfo = gtk.Label()
        gtklogger.setWidgetName(self.aainfo, "Status")
        ##        self.aainfo.set_alignment(0.0, 0.5)
        aasframe.add(self.aainfo)

        naaframe = gtk.Frame("Named Active %ss" % Spacestring)
        naaframe.set_shadow_type(gtk.SHADOW_IN)
        vbox.pack_start(naaframe, expand=1, fill=1)
        naabox = gtk.VBox()
        naaframe.add(naabox)
        self.aalist = chooser.ScrolledChooserListWidget(
            callback=self.aalistCB,
            dbcallback=self.aalistCB2,
            name="NamedAreas")
        naabox.pack_start(self.aalist.gtk, expand=1, fill=1, padding=2)
        bbox = gtk.HBox()
        naabox.pack_start(bbox, expand=0, fill=0, padding=2)
        self.storebutton = gtk.Button("Store...")
        bbox.pack_start(self.storebutton, expand=1, fill=0)
        gtklogger.setWidgetName(self.storebutton, "Store")
        gtklogger.connect(self.storebutton, 'clicked', self.storeCB)
        tooltips.set_tooltip_text(
            self.storebutton,
            "Save the current active %s for future use." % spacestring)
        self.renamebutton = gtk.Button("Rename...")
        bbox.pack_start(self.renamebutton, expand=1, fill=0)
        gtklogger.setWidgetName(self.renamebutton, "Rename")
        gtklogger.connect(self.renamebutton, 'clicked', self.renameCB)
        tooltips.set_tooltip_text(
            self.renamebutton,
            "Rename the selected saved active %s." % spacestring)
        self.deletebutton = gtk.Button("Delete")
        bbox.pack_start(self.deletebutton, expand=1, fill=0)
        gtklogger.setWidgetName(self.deletebutton, "Delete")
        gtklogger.connect(self.deletebutton, 'clicked', self.deleteCB)
        tooltips.set_tooltip_text(
            self.deletebutton,
            "Delete the selected saved active %s." % spacestring)
        self.restorebutton = gtk.Button("Restore")
        bbox.pack_start(self.restorebutton, expand=1, fill=0)
        gtklogger.setWidgetName(self.restorebutton, "Restore")
        gtklogger.connect(self.restorebutton, 'clicked', self.restoreCB)
        tooltips.set_tooltip_text(
            self.restorebutton,
            "Use the selected saved active %s." % spacestring)

        # Active area modification methods in the right half of the main pane
        modframe = gtk.Frame("Active %s Modification" % Spacestring)
        gtklogger.setWidgetName(modframe, "Modify")
        modframe.set_shadow_type(gtk.SHADOW_IN)
        mainpane.pack2(modframe, resize=0, shrink=0)
        modbox = gtk.VBox()
        modframe.add(modbox)
        ##        scroll = gtk.ScrolledWindow()
        ##        scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        ##        modbox.pack_start(scroll, expand=1, fill=1)
        self.activeareaModFactory = regclassfactory.RegisteredClassFactory(
            activeareamod.ActiveAreaModifier.registry,
            title="Method:",
            scope=self,
            name="Method")
        ##        scroll.add_with_viewport(self.activeareaModFactory.gtk)
        modbox.pack_start(self.activeareaModFactory.gtk, expand=1, fill=1)
        self.historian = historian.Historian(self.activeareaModFactory.set,
                                             self.sensitizeHistory,
                                             setCBkwargs={'interactive': 1})
        self.activeareaModFactory.set_callback(self.historian.stateChangeCB)

        # Prev, OK, and Next buttons
        hbox = gtk.HBox()
        modbox.pack_start(hbox, expand=0, fill=0, padding=2)
        self.prevbutton = gtkutils.prevButton()
        hbox.pack_start(self.prevbutton, expand=0, fill=0, padding=2)
        gtklogger.connect(self.prevbutton, 'clicked', self.historian.prevCB)
        tooltips.set_tooltip_text(
            self.prevbutton,
            'Recall the previous active %s modification operation.' %
            spacestring)
        self.okbutton = gtk.Button(stock=gtk.STOCK_OK)
        hbox.pack_start(self.okbutton, expand=1, fill=1, padding=2)
        gtklogger.setWidgetName(self.okbutton, "OK")
        gtklogger.connect(self.okbutton, 'clicked', self.okbuttonCB)
        tooltips.set_tooltip_text(
            self.okbutton,
            'Perform the active %s modification operation defined above.' %
            spacestring)
        self.nextbutton = gtkutils.nextButton()
        hbox.pack_start(self.nextbutton, expand=0, fill=0, padding=2)
        gtklogger.connect(self.nextbutton, 'clicked', self.historian.nextCB)
        tooltips.set_tooltip_text(
            self.nextbutton,
            "Recall the next active %s modification operation." % spacestring)

        # Undo, Redo, Override
        hbox = gtk.HBox()
        modbox.pack_start(hbox, expand=0, fill=0, padding=2)
        self.undobutton = gtk.Button(stock=gtk.STOCK_UNDO)
        hbox.pack_start(self.undobutton, expand=1, fill=0)
        gtklogger.setWidgetName(self.undobutton, "Undo")
        gtklogger.connect(self.undobutton, 'clicked', self.undoCB)
        tooltips.set_tooltip_text(self.undobutton,
                                  "Undo the previous operation.")

        self.redobutton = gtk.Button(stock=gtk.STOCK_REDO)
        hbox.pack_start(self.redobutton, expand=1, fill=0)
        gtklogger.setWidgetName(self.redobutton, "Redo")
        gtklogger.connect(self.redobutton, 'clicked', self.redoCB)
        tooltips.set_tooltip_text(self.redobutton, "Redo an undone operation.")

        self.overridebutton = gtk.ToggleButton('Override')
        hbox.pack_start(self.overridebutton, expand=1, fill=0)
        gtklogger.setWidgetName(self.overridebutton, "Override")
        self.overridesignal = gtklogger.connect(self.overridebutton, 'clicked',
                                                self.overrideCB)
        tooltips.set_tooltip_text(
            self.overridebutton,
            "Temporarily activate the entire microstructure.")

        # Switchboard signals
        self.sbcallbacks = [
            switchboard.requestCallback(self.mswidget, self.mswidgetCB),
            switchboard.requestCallback("active area modified",
                                        self.aamodified),
            switchboard.requestCallbackMain("stored active areas changed",
                                            self.storedAAChanged),
            switchboard.requestCallbackMain(
                ('validity', self.activeareaModFactory), self.validityChangeCB)
        ]

        self.built = True