コード例 #1
0
ファイル: introPage.py プロジェクト: shkeshavarz/OOF2
    def __init__(self):
        oofGUI.MainPage.__init__(self, name="Introduction", ordering=0,
                                 tip="Welcome to %s!"%name)
        vbox = gtk.VBox()
        self.gtk.add(vbox)
        scroll = gtk.ScrolledWindow()
        gtklogger.logScrollBars(scroll, "Scroll")
        scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS)
        vbox.pack_start(scroll, expand=1, fill=1)
        self.textarea = fixedwidthtext.FixedWidthTextView()
        scroll.set_shadow_type(gtk.SHADOW_IN)
        scroll.add(self.textarea)
        self.textarea.set_editable(0)
        self.textarea.set_cursor_visible(0)
        self.textarea.set_wrap_mode(gtk.WRAP_WORD)

        buttonbox = gtk.HBox(homogeneous=1, spacing=2)
        buttonbox.set_border_width(2)
        vbox.pack_start(buttonbox, expand=0, fill=0)

        self.labels = ['Welcome', 'Credits', 'Copyright', 'Disclaimer']
        self.buttons = [gtk.ToggleButton(x) for x in self.labels]
        for button, label in zip(self.buttons, self.labels):
            buttonbox.pack_start(button, expand=1, fill=1)
            gtklogger.setWidgetName(button, label)
            gtklogger.connect(button, 'clicked', self.buttonCB, label)

        self.buttons[0].set_active(1)
コード例 #2
0
ファイル: meshinfoGUI.py プロジェクト: anilkunwar/OOF2
    def __init__(self, toolbox, nrows, ncols):
        debug.mainthreadTest()
        self.toolbox = toolbox  # MeshToolboxGUI
        self.menu = self.toolbox.toolbox.menu  # ie, gfxtoolbox.toolbox.menu

        self.gtk = gtk.Frame(self.targetname + " Information")
        self.gtk.set_shadow_type(gtk.SHADOW_IN)
        scroll = gtk.ScrolledWindow()
        gtklogger.logScrollBars(scroll, self.targetname+"Info")
        scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.gtk.add(scroll)
        # This vbox just keeps the table from expanding inside the
        # scrolledwindow.
        vbox = gtk.VBox()
        scroll.add_with_viewport(vbox)
        self.table = gtk.Table(rows=nrows, columns=ncols)
        vbox.pack_start(self.table, expand=0, fill=0)
コード例 #3
0
ファイル: chooser.py プロジェクト: anilkunwar/OOF2
 def __init__(self, objlist=None, displaylist=[], callback=None,
              dbcallback=None, autoselect=True, comparator=None, name=None,
              separator_func=None, markup=False):
     ChooserListWidget.__init__(self,
                                objlist=objlist,
                                displaylist=displaylist,
                                callback=callback,
                                dbcallback=dbcallback,
                                autoselect=autoselect,
                                comparator=comparator,
                                name=name,
                                separator_func=separator_func,
                                markup=markup)
     self.gtk = gtk.ScrolledWindow()
     gtklogger.logScrollBars(self.gtk, name=name+"Scroll")
     self.gtk.set_shadow_type(gtk.SHADOW_IN)
     self.gtk.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
     self.gtk.add(self.treeview)
コード例 #4
0
ファイル: skeletoninfoGUI.py プロジェクト: anilkunwar/OOF2
    def __init__(self, toolbox):
        debug.mainthreadTest()
        self.toolbox = toolbox  # SkeletonInfoToolboxGUI
        self.menu = self.toolbox.toolbox.menu  # ie, gfxtoolbox.toolbox.menu

        self.gtk = gtk.Frame(self.targetname + " Information")
        self.gtk.set_shadow_type(gtk.SHADOW_IN)
        scroll = gtk.ScrolledWindow()
        gtklogger.logScrollBars(scroll, self.targetname+"Information")
        scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.gtk.add(scroll)
        # This vbox just keeps the table from expanding inside the
        # scrolledwindow.
        vbox = gtk.VBox()
        scroll.add_with_viewport(vbox)
        self.table = gtk.Table()
        vbox.pack_start(self.table, expand=0, fill=0)

        self.sbcallbacks = [
            switchboard.requestCallback("groupset member resized",
                                        self.grpsChanged)]
コード例 #5
0
ファイル: pixelinfoplugin.py プロジェクト: anilkunwar/OOF2
    def __init__(self, toolbox, table, row):
        debug.mainthreadTest()
        PixelInfoPlugIn.__init__(self, toolbox)
        label = gtk.Label('microstructure=')
        label.set_alignment(1.0, 0.5)
        table.attach(label, 0,1, row,row+1, xpadding=5, xoptions=gtk.FILL)
        self.microtext = gtk.Entry()
        gtklogger.setWidgetName(self.microtext,'MSText')
        self.microtext.set_size_request(12*guitop.top().charsize, -1)
        self.microtext.set_editable(0)
        table.attach(self.microtext, 1,2, row,row+1,
                     xpadding=5, xoptions=gtk.EXPAND|gtk.FILL)

        label = gtk.Label('pixel groups=')
        label.set_alignment(1.0, 0.5)
        table.attach(label, 0,1, row+1,row+2, xpadding=5, xoptions=gtk.FILL)
        self.grouplist = gtk.TextView()
        self.grouplist.set_size_request(12*guitop.top().charsize, -1)
        self.grouplist.set_editable(False)
        self.grouplist.set_cursor_visible(False)
        self.grouplist.set_wrap_mode(gtk.WRAP_WORD)
        gtklogger.setWidgetName(self.grouplist, 'Group view')
        scroll = gtk.ScrolledWindow()
        gtklogger.logScrollBars(scroll, "MSScroll")
        scroll.set_shadow_type(gtk.SHADOW_IN)
        scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        scroll.add(self.grouplist)
        table.attach(scroll, 1,2, row+1,row+2,
                     xpadding=5, xoptions=gtk.EXPAND|gtk.FILL)

        self.sbcallbacks = [
            switchboard.requestCallbackMain('changed pixel group',
                                            self.grpchanged),
            switchboard.requestCallbackMain('changed pixel groups',
                                            self.grpschngd),
            switchboard.requestCallbackMain('destroy pixel group',
                                            self.grpdestroy),
            switchboard.requestCallbackMain('renamed pixel group',
                                            self.grprenamed)
            ]
コード例 #6
0
ファイル: boundarycondPage.py プロジェクト: anilkunwar/OOF2
    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)
コード例 #7
0
ファイル: activityViewer.py プロジェクト: anilkunwar/OOF2
    def __init__(self):
        debug.mainthreadTest()
        self.listofgtkbars = []
        self.makeMenus()  # Sets self.menu.
        # SubWindow init sets self.gtk and self.mainbox.
        
        subWindow.SubWindow.__init__(
            self, title="%s Activity Viewer"%subWindow.oofname(),
            menu=self.menu)

        self.gtk.connect('destroy', self.closeCB)
        self.gtk.set_default_size(400, 300)
        
        # Area at the top containing the editor widget for the line
        self.control_area = gtk.HBox()       # editor widget goes in here
        self.mainbox.pack_start(self.control_area, expand=0, fill=0, padding=2)

        ## Dismiss All bars
        self.dismissall = gtkutils.StockButton(gtk.STOCK_CANCEL, "Dismiss All")
        gtklogger.setWidgetName(self.dismissall, "DismissAll")
        gtklogger.connect(self.dismissall, "clicked", self.dismissAllCB)
        self.control_area.pack_start(self.dismissall, expand=1, fill=0,
                                     padding=2)

        ## stop-all-threads
        self.stopall = gtkutils.StockButton(gtk.STOCK_STOP, "Stop All")
        gtklogger.setWidgetName(self.stopall, "StopAll")
        gtklogger.connect(self.stopall, "clicked", self.stopAll)
        self.control_area.pack_start(self.stopall, expand=1, fill=0, padding=2)
                
        # Create a scrolled window to pack the bars into
        scrolled_window = gtk.ScrolledWindow()
        scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        gtklogger.logScrollBars(scrolled_window, "Scroll")
        self.mainbox.pack_start(scrolled_window, expand=1, fill=1, padding=2)
        
        ## Create VBox where the progressbars can live happily ever after
        self.bars_play_area = gtk.VBox() # homogeneous=True?
        scrolled_window.add_with_viewport(self.bars_play_area)

        self.proglock = lock.SLock()
        self.proglock.acquire()
        try:
            for worker in threadmanager.threadManager.allWorkers():
                worker.threadstate.acquireProgressLock()
                try:
                    progressnames = worker.threadstate.getProgressNames()
                    for pname in progressnames:
                        try:
                            prgrss = worker.threadstate.findProgress(pname)
                        except ooferror.ErrNoProgress:
                            # Progress object already finished
                            pass
                        else:
                            if prgrss.started():
                                self.installBar(prgrss)
                finally:
                    worker.threadstate.releaseProgressLock()
        finally:
            self.proglock.release()

        self.gtk.show_all()
        self.sensitizeButtons()
コード例 #8
0
ファイル: microstructurePage.py プロジェクト: anilkunwar/OOF2
    def __init__(self):
        debug.mainthreadTest()
        self.built = False

        oofGUI.MainPage.__init__(
            self, name="Microstructure", ordering=10,
            tip="Define Microstructure and %s Group objects."%Pixstring)
        vbox = gtk.VBox(spacing=2)
        self.gtk.add(vbox)

        align = gtk.Alignment(xalign=0.5)
        vbox.pack_start(align, expand=0, fill=0)
        centerbox = gtk.HBox()
        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,
                                            callback=self.msCB)
        centerbox.pack_start(self.mswidget.gtk[0], expand=0, fill=0)
        
        align = gtk.Alignment(xalign=0.5) # first row of ms buttons
        vbox.pack_start(align, expand=0, fill=0)
        self.newbuttonbox = gtk.HBox(homogeneous=0, spacing=3)
        align.add(self.newbuttonbox)

        self.newbutton = gtkutils.StockButton(gtk.STOCK_NEW, 'New...')
        gtklogger.setWidgetName(self.newbutton, "New")
        gtklogger.connect(self.newbutton,'clicked', self.newEmptyCB)
        tooltips.set_tooltip_text(self.newbutton,
            "Create a new microstructure that is NOT associated with images.")
        self.newbuttonbox.pack_start(self.newbutton, expand=1, fill=1)
        
        # Other buttons can be added to the row of "New" buttons by
        # other modules.  When they're added, by addNewButton(), a
        # function can be specified for sensitizing the button.  This
        # is the list of those functions:
        self.sensitizeFns = []

        # Other modules can contribute strings to be displayed on the
        # info page.  This is the list of
        # MicrostructurePageInfoPlugIns that retrieve those strings.
        self.infoplugins = []

        align = gtk.Alignment(xalign=0.5) # second row of ms buttons
        vbox.pack_start(align, expand=0, fill=0)
        centerbox = gtk.HBox(homogeneous=1, spacing=3)
        align.add(centerbox)

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

        self.copybutton = gtkutils.StockButton(gtk.STOCK_COPY, 'Copy...')
        gtklogger.setWidgetName(self.copybutton, "Copy")
        gtklogger.connect(self.copybutton, 'clicked', self.copyMSCB)
        tooltips.set_tooltip_text(self.copybutton,
                                  "Copy the current microstructure.")
        centerbox.pack_start(self.copybutton, expand=1, fill=1)

        self.deletebutton = gtkutils.StockButton(gtk.STOCK_DELETE, 'Delete')
        gtklogger.setWidgetName(self.deletebutton, "Delete")
        gtklogger.connect(self.deletebutton, 'clicked', self.deleteMSCB)
        tooltips.set_tooltip_text(self.deletebutton,
                                  "Delete the current microstructure.")
        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.saveMSCB)
        tooltips.set_tooltip_text(self.savebutton,
            "Save the current microstructure to a file.")
        centerbox.pack_start(self.savebutton, expand=1, fill=1)

        pane = gtk.HPaned()
        gtklogger.setWidgetName(pane, "Pane")
        vbox.pack_start(pane, expand=1, fill=1, padding=2)
        gtklogger.connect_passive(pane, 'notify::position')

        #######
        
        infoframe = gtk.Frame('Microstructure Info')
        infoframe.set_shadow_type(gtk.SHADOW_IN)
        pane.pack1(infoframe, resize=True, shrink=False)
        scroll = gtk.ScrolledWindow()
        gtklogger.logScrollBars(scroll, "InfoFrameScroll")
        scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        scroll.set_shadow_type(gtk.SHADOW_IN)
        infoframe.add(scroll)
        self.infoarea = fixedwidthtext.FixedWidthTextView()
        self.infoarea.set_editable(0)
        self.infoarea.set_cursor_visible(False)
        self.infoarea.set_wrap_mode(gtk.WRAP_WORD)
        scroll.add(self.infoarea)
        
        ########

        self.grouplock = lock.Lock()
        groupframe = gtk.Frame('%s Groups'%Pixstring)
        gtklogger.setWidgetName(groupframe, "%sGroups"%Pixstring)
        groupframe.set_shadow_type(gtk.SHADOW_IN)
        pane.pack2(groupframe, resize=True, shrink=False)
        hbox = gtk.HBox()
        groupframe.add(hbox)
        vbox = gtk.VBox(spacing=2)      # buttons on L side of pixel group list
        hbox.pack_start(vbox, expand=0, fill=0, padding=2)
        frame = gtk.Frame()              # frame for the list of groups
        frame.set_shadow_type(gtk.SHADOW_IN)
        hbox.pack_start(frame)
        grparea = gtk.VBox()
        frame.add(grparea)
        # only one of grplist and grpmsg is visible at a time
        self.grplist = chooser.ScrolledChooserListWidget( # list of pixel groups
            callback=self.listItemChosen, name="GroupList")
        grparea.add(self.grplist.gtk)
        self.grpmsg = gtk.Label()       # helpful message when there are no grps
        grparea.add(self.grpmsg)

        self.newgroupbutton = gtk.Button('New...')
        gtklogger.setWidgetName(self.newgroupbutton, "New")
        vbox.pack_start(self.newgroupbutton, expand=0, fill=0)
        gtklogger.connect(self.newgroupbutton, 'clicked', self.newGroupButtonCB)
        tooltips.set_tooltip_text(self.newgroupbutton,
            "Create a new empty %s group in the current microstructure."
            % pixstring)

        self.renamegroupbutton = gtk.Button('Rename...')
        gtklogger.setWidgetName(self.renamegroupbutton, "Rename")
        vbox.pack_start(self.renamegroupbutton, expand=0, fill=0)
        gtklogger.connect(self.renamegroupbutton, 'clicked',
                         self.renameGroupButtonCB)
        tooltips.set_tooltip_text(self.renamegroupbutton,
            "Rename the selected %s group." % pixstring)

        self.copygroupbutton = gtk.Button('Copy...')
        gtklogger.setWidgetName(self.copygroupbutton, "Copy")
        vbox.pack_start(self.copygroupbutton, expand=0, fill=0)
        gtklogger.connect(self.copygroupbutton, 'clicked',
                         self.copyGroupButtonCB)
        tooltips.set_tooltip_text(self.copygroupbutton,
            "Create a new group containing the same %ss as the selected group."
            % pixstring)

        self.delgroupbutton = gtk.Button('Delete')
        gtklogger.setWidgetName(self.delgroupbutton, "Delete")
        vbox.pack_start(self.delgroupbutton, expand=0, fill=0)
        gtklogger.connect(self.delgroupbutton, 'clicked',
                         self.deleteGroupButtonCB)
        tooltips.set_tooltip_text(self.delgroupbutton,
            "Delete the selected %s group from the microstructure." % pixstring)

        self.delallgroupsbutton = gtk.Button('Delete All')
        gtklogger.setWidgetName(self.delallgroupsbutton, 'DeleteAll')
        vbox.pack_start(self.delallgroupsbutton, expand=0, fill=0)
        gtklogger.connect(self.delallgroupsbutton, 'clicked',
                          self.deleteAllGroupsButtonCB)
        tooltips.set_tooltip_text(self.delallgroupsbutton,
            "Delete all pixel groups from the microstructure.")

        self.meshablebutton = gtk.CheckButton('Meshable')
        gtklogger.setWidgetName(self.meshablebutton, "Meshable")
        vbox.pack_start(self.meshablebutton, expand=0, fill=0)
        self.meshablesignal = gtklogger.connect(self.meshablebutton, 'clicked',
                                                self.meshableGroupCB)
        tooltips.set_tooltip_text(self.meshablebutton,
            "Should adaptive meshes follow the boundaries of the selected %s group?"
            % pixstring)


        # buttons on rhs of pixelgroup list
        vbox = gtk.VBox(spacing=2)
        hbox.pack_start(vbox, expand=0, fill=0, padding=2)

        self.addbutton = gtk.Button('Add')
        gtklogger.setWidgetName(self.addbutton, "Add")
        vbox.pack_start(self.addbutton, expand=0, fill=0)
        gtklogger.connect(self.addbutton, 'clicked', self.addPixelsCB)
        tooltips.set_tooltip_text(self.addbutton,
            "Add the currently selected %ss to the selected group." % pixstring)

        self.removebutton = gtk.Button('Remove')
        gtklogger.setWidgetName(self.removebutton, "Remove")
        vbox.pack_start(self.removebutton, expand=0, fill=0)
        gtklogger.connect(self.removebutton, 'clicked', self.removePixelsCB)
        tooltips.set_tooltip_text(self.removebutton,
            "Remove the currently selected %ss from the selected group."
            % pixstring)

        self.clearbutton = gtk.Button('Clear')
        gtklogger.setWidgetName(self.clearbutton, "Clear")
        vbox.pack_start(self.clearbutton, expand=0, fill=0)
        gtklogger.connect(self.clearbutton, 'clicked', self.clearPixelsCB)
        tooltips.set_tooltip_text(self.clearbutton,
            "Reset the selected group by removing all the %ss from the group."
            % pixstring)
        
        self.infobutton = gtk.Button('Info')
        gtklogger.setWidgetName(self.infobutton, "Info")
        vbox.pack_start(self.infobutton, expand=0, fill=0)
        gtklogger.connect(self.infobutton, 'clicked', self.queryPixelsCB)
        tooltips.set_tooltip_text(self.infobutton,
            "Display information about the selected group in the Messages window.")        

        self.built = True

        self.sbcallbacks = [
            switchboard.requestCallback('new pixel group', self.newpixgrp),
            switchboard.requestCallback('destroy pixel group', self.destpixgrp),
            #
            switchboard.requestCallback('changed pixel group', self.destpixgrp),
            switchboard.requestCallback('changed pixel groups', self.chngdgrps),
            switchboard.requestCallback(('new who', 'Microstructure'),
                                        self.newwhoMS),
            switchboard.requestCallback(('new who', 'Image'), self.newwhoImage),
            switchboard.requestCallback(('rename who', 'Image'),
                                        self.displayMSInfo),
            switchboard.requestCallback('remove who', self.removewho),
            switchboard.requestCallback('renamed pixel group',
                                        self.renamepixgrp),
            switchboard.requestCallback('pixel selection changed',
                                        self.selectionchanged),
            switchboard.requestCallback(
            'images changed in microstructure', self.displayMSInfo)
            ]
コード例 #9
0
ファイル: materialsPage.py プロジェクト: anilkunwar/OOF2
    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)
コード例 #10
0
ファイル: gfxwindow3d.py プロジェクト: anilkunwar/OOF2
    def preinitialize(self, name, gfxmanager, clone):
        debug.mainthreadTest()
        self.gtk = None
        self.closed = None # State data used at window-close time.
        self.name = name
        self.oofcanvas = None
        self.realized = 0
        self.zoomed = 0
        self.settings = ghostgfxwindow.GfxSettings()
        self.mouseHandler = mousehandler.nullHandler # doesn't do anything
        self.rubberband = rubberband.NoRubberBand()
        #self.contourmapdata = None 

        # Build all the GTK objects for the interior of the box.  These
        # actually get added to the window itself after the SubWindow
        # __init__ call.  They need to be created first so the
        # GhostGfxWindow can operate on them, and then create the menus
        # which are handed off to the SubWindow.
        self.mainpane = gtk.VPaned()
        gtklogger.setWidgetName(self.mainpane, 'Pane0')

        # Panes dividing upper pane horizontally into 3 parts.
        # paned1's left half contains paned2.
        self.paned1 = gtk.HPaned()
        gtklogger.setWidgetName(self.paned1, "Pane1")
        self.mainpane.pack1(self.paned1, resize=True)
        gtklogger.connect_passive(self.paned1, 'size-allocate')

        # paned2 is in left half of paned1
        self.paned2 = gtk.HPaned()
        gtklogger.setWidgetName(self.paned2, "Pane2")
        self.paned1.pack1(self.paned2, resize=True)
        gtklogger.connect_passive(self.paned2, 'size-allocate')

        # The toolbox is in the left half of paned2 (ie the left frame of 3)
        toolboxframe = gtk.Frame()
        toolboxframe.set_shadow_type(gtk.SHADOW_IN)
        self.paned2.pack1(toolboxframe, resize=True)
        gtklogger.connect_passive(toolboxframe, 'size-allocate')

        # Box containing the toolbox label and the scroll window for
        # the toolbox itself.
        toolboxbox1 = gtk.VBox()
        toolboxframe.add(toolboxbox1)
        hbox = gtk.HBox()
        toolboxbox1.pack_start(hbox, expand=0, fill=0, padding=2)
        hbox.pack_start(gtk.Label("Toolbox:"), expand=0, fill=0, padding=3)
        
        self.toolboxchooser = chooser.ChooserWidget([],
                                                    callback=self.switchToolbox,
                                                    name="TBChooser")
        hbox.pack_start(self.toolboxchooser.gtk, expand=1, fill=1, padding=3)

        # Scroll window for the toolbox itself.
        toolboxbox2 = gtk.ScrolledWindow()
        gtklogger.logScrollBars(toolboxbox2, 'TBScroll')
        
        toolboxbox2.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        toolboxbox1.pack_start(toolboxbox2, expand=1, fill=1)

        # Actually, the tool box goes inside yet another box, so that
        # we have a gtk.VBox that we can refer to later.
        self.toolboxbody = gtk.VBox()
        toolboxbox2.add_with_viewport(self.toolboxbody)

        self.toolboxGUIs = []           # GUI wrappers for toolboxes.
        self.current_toolbox = None

        # The canvas is in the right half of paned2 (ie the middle
        # pane of 3).
        # TODO: make this a table with compact, view control buttons,
        # for now, just a frame with the gtkglext window.

        self.canvasBox = gtk.VBox()
        self.toolbarFrame = gtk.Frame()
        self.toolbarFrame.set_shadow_type(gtk.SHADOW_IN)
        self.canvasBox.pack_start(self.toolbarFrame, expand=0, fill=0, padding=0)

        self.toolbar = toolbarGUI.ToolBar(self)
        self.toolbarFrame.add(self.toolbar.gtk)
        self.toolbar.gtk.show()

        self.canvasFrame = gtk.Frame()
        self.canvasFrame.set_shadow_type(gtk.SHADOW_IN)
        gtklogger.setWidgetName(self.canvasFrame, "Canvas")
        self.canvasBox.pack_start(self.canvasFrame, expand=1, fill=1, padding=0)

        self.paned2.pack2(self.canvasBox, resize=True)

        # HACK.  Set the position of the toolbox/canvas divider.  This
        # prevents the toolbox pane from coming up minimized.
        self.paned2.set_position(300)


        # Bottom part of main pane is a list of layers.  The actual
        # DisplayLayer objects are stored in self.display.

        layerFrame = gtk.Frame(label='Layers')
        
        self.mainpane.pack2(layerFrame, resize=False)
        self.layerScroll = gtk.ScrolledWindow()
        gtklogger.logScrollBars(self.layerScroll, "LayerScroll")
        self.layerScroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        layerFrame.add(self.layerScroll)

        self.layerList = gtk.ListStore(gobject.TYPE_PYOBJECT)
        self.layerListView = gtk.TreeView(self.layerList)
        gtklogger.setWidgetName(self.layerListView, "LayerList")
        self.layerListView.set_row_separator_func(self.layerRowSepFunc)
        self.layerListView.set_reorderable(True)
        self.layerListView.set_fixed_height_mode(False)
        self.layerScroll.add(self.layerListView)

        gtklogger.adoptGObject(self.layerList, self.layerListView,
                              access_method=self.layerListView.get_model)

        # The row-deleted and row-inserted signals are used to detect
        # when the user has reordered rows manually.  When the program
        # does anything that might cause these signals to be emitted,
        # it must first call suppressRowOpSignals.
        self.rowOpSignals = [
            gtklogger.connect(self.layerList, "row-deleted",
                             self.listRowDeletedCB),
            gtklogger.connect(self.layerList, "row-inserted",
                             self.listRowInsertedCB)
            ]
        self.destination_path = None

        showcell = gtk.CellRendererToggle()
        showcol = gtk.TreeViewColumn("Show")
        showcol.pack_start(showcell, expand=False)
        showcol.set_cell_data_func(showcell, self.renderShowCell)
        self.layerListView.append_column(showcol)
        gtklogger.adoptGObject(showcell, self.layerListView,
                               access_function=gtklogger.findCellRenderer,
                               access_kwargs={'col':0, 'rend':0})
        gtklogger.connect(showcell, 'toggled', self.showcellCB)        

##         cmapcell = gtk.CellRendererToggle()
##         cmapcell.set_radio(True)
##         cmapcol = gtk.TreeViewColumn("Map")
##         cmapcol.pack_start(cmapcell, expand=False)
##         cmapcol.set_cell_data_func(cmapcell, self.renderCMapCell)
##         self.layerListView.append_column(cmapcol)
##         gtklogger.adoptGObject(cmapcell, self.layerListView,
##                                access_function='findCellRenderer',
##                                access_kwargs={'col':1, 'rend':0})
##         gtklogger.connect(cmapcell, 'toggled', self.cmapcellCB)        

        layercell = gtk.CellRendererText()
        layercol = gtk.TreeViewColumn("What")
        layercol.set_resizable(True)
        layercol.pack_start(layercell, expand=True)
        layercol.set_cell_data_func(layercell, self.renderLayerCell)
        self.layerListView.append_column(layercol)

        methodcell = gtk.CellRendererText()
        methodcol = gtk.TreeViewColumn("How")
        methodcol.set_resizable(True)
        methodcol.pack_start(methodcell, expand=True)
        methodcol.set_cell_data_func(methodcell, self.renderMethodCell)
        self.layerListView.append_column(methodcol)

        gtklogger.adoptGObject(self.layerListView.get_selection(),
                              self.layerListView,
                              access_method=self.layerListView.get_selection)
        self.selsignal = gtklogger.connect(self.layerListView.get_selection(), 
                                          'changed', self.selectionChangedCB)
        gtklogger.connect(self.layerListView, 'row-activated',
                         self.layerDoubleClickCB)
コード例 #11
0
ファイル: interfacePage.py プロジェクト: anilkunwar/OOF2
    def __init__(self):
        self.built = False

        oofGUI.MainPage.__init__(self, name="Interfaces",
                                 ordering = 105,
                                 tip = "Create named one-dimensional interfaces.")

        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)

        #skelwidget is really an mswidget
        self.skelwidget = whowidget.WhoWidget(whoville.getClass('Microstructure'),
                                              scope=self)
        switchboard.requestCallbackMain(self.skelwidget,
                                        self.widgetChanged)
        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)
        #We might want to include a skeleton in the widget, if an interface
        #is defined in terms of skeleton segments. For now the interface is
        #only associated with a microstructure
##        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)

        interfacelistframe = gtk.Frame("Interfaces")
        gtklogger.setWidgetName(interfacelistframe, 'Interfaces')
        gtklogger.connect_passive(interfacelistframe, 'size-allocate')
        interfacelistframe.set_shadow_type(gtk.SHADOW_IN)
        mainpane.pack1(interfacelistframe, resize=0, shrink=0)

        interfacelistbox = gtk.VBox()
        interfacelistframe.add(interfacelistbox)

        # List of all the named interfaces
        self.interfacelist = chooser.ScrolledChooserListWidget(
            callback=self.interfacelistCB,
##            dbcallback=self.modifyBoundaryCB,
            autoselect=0,
            name="InterfaceList"
            )
        interfacelistbox.pack_start(self.interfacelist.gtk, expand=1, fill=1)

        interfacebuttonbox = gtk.HBox(homogeneous=1, spacing=2)
        interfacelistbox.pack_start(interfacebuttonbox, expand=0, fill=0)

        # Buttons that actually do stuff.
        self.newbutton = gtk.Button("New...")
        gtklogger.setWidgetName(self.newbutton, 'New')
        gtklogger.connect(self.newbutton, "clicked", self.newInterfaceCB)
        tooltips.set_tooltip_text(self.newbutton,
                             "Construct a new interface in the microstructure and associated meshes.")
        interfacebuttonbox.pack_start(self.newbutton, expand=1, fill=1)

        self.renamebutton = gtk.Button("Rename...")
        gtklogger.setWidgetName(self.renamebutton, 'Rename')
        gtklogger.connect(self.renamebutton, "clicked", self.renameInterfaceCB)
        tooltips.set_tooltip_text(self.renamebutton,
                             "Rename the selected interface.")
        interfacebuttonbox.pack_start(self.renamebutton, expand=1, fill=1)

        self.deletebutton = gtk.Button("Delete")
        gtklogger.setWidgetName(self.deletebutton, 'Delete')
        gtklogger.connect(self.deletebutton, "clicked", self.deleteInterfaceCB)
        tooltips.set_tooltip_text(self.deletebutton,
                             "Delete the selected interface from the microstructure and associated meshes.")
        interfacebuttonbox.pack_start(self.deletebutton, expand=1, fill=1)

        ########## Adding and removing interface materials
        materialbuttonbox = gtk.HBox(homogeneous=1, spacing=2)
        interfacelistbox.pack_start(materialbuttonbox, expand=0, fill=0)
        self.assignmatbutton = gtk.Button("Assign interface material...")
        gtklogger.setWidgetName(self.assignmatbutton, 'Assign material')
        gtklogger.connect(self.assignmatbutton, "clicked", self.assignmatCB)
        tooltips.set_tooltip_text(self.assignmatbutton,
                             "Assign material to interface.")
        materialbuttonbox.pack_start(self.assignmatbutton, expand=1, fill=1)

        self.removematbutton = gtk.Button("Remove material")
        gtklogger.setWidgetName(self.removematbutton, 'Remove material')
        gtklogger.connect(self.removematbutton, "clicked", self.removematCB)
        tooltips.set_tooltip_text(self.removematbutton,
                             "Remove material from interface.")
        materialbuttonbox.pack_start(self.removematbutton, expand=1, fill=1)
        ####################################

        infoframe = gtk.Frame("Interface details")
        infoframe.set_shadow_type(gtk.SHADOW_IN)
        mainpane.pack2(infoframe, resize=1, shrink=1)

        infowindow = gtk.ScrolledWindow()
        gtklogger.logScrollBars(infowindow, "InfoScroll")
        infowindow.set_shadow_type(gtk.SHADOW_IN)
        infoframe.add(infowindow)
        infowindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        
        self.infotext = fixedwidthtext.FixedWidthTextView()
        self.infotext.set_wrap_mode(gtk.WRAP_WORD)
        gtklogger.setWidgetName(self.infotext, 'status')
        self.infotext.set_editable(False)
        infowindow.add(self.infotext)

        self.built = True

        switchboard.requestCallbackMain("new interface created",
                                        self.newInterfaceUpdatePageCB)
        switchboard.requestCallbackMain("interface removed",
                                        self.newInterfaceUpdatePageCB)
        switchboard.requestCallbackMain("interface renamed",
                                        self.newInterfaceUpdatePageCB),
##        switchboard.requestCallbackMain("remove_material",self.del_mat)
        #TODO: Enable something like this later?
##        switchboard.requestCallbackMain(("new who", "Microstructure"),
##                                        self.newMicrostructureCB)

        self.selectsignals = [
            switchboard.requestCallbackMain("interface selected",
                                            self.interfaceSelectedCB),
            switchboard.requestCallbackMain("interface unselected",
                                            self.interfaceUnselectedCB)
            ]
コード例 #12
0
ファイル: tutorialsGUI.py プロジェクト: shkeshavarz/OOF2
    def __init__(self, tutor):
        debug.mainthreadTest()

        for menuitem in mainmenu.OOF.Help.Tutorials.items:
            menuitem.disable()

        subWindow.SubWindow.__init__(self, title=tutor.subject, menu="")

        self.subwindow_menu.File.addItem(oofmenu.OOFMenuItem(
            'Save_Text',
            callback=self.savePrintable,
            params=[filenameparam.WriteFileNameParameter('filename',
                                                         ident="FileMenu"),
                    filenameparam.WriteModeParameter('mode')],
            help="Save the text of this tutorial in a file.",
            no_log=1,
            ordering=-1))

        labelhbox = gtk.HBox()
        self.subject = gtk.Label()
        self.slideIndex = gtk.Label()
        labelhbox.pack_start(self.subject, expand=1, fill=1, padding=2)
        labelhbox.pack_end(self.slideIndex, expand=0, fill=0, padding=2)
        self.mainbox.pack_start(labelhbox, expand=0, fill=0, padding=2)

        self.msgscroll = gtk.ScrolledWindow()
        self.scrollsignals = gtklogger.logScrollBars(self.msgscroll,
                                                     "TutorialScroll")
        self.msgscroll.set_shadow_type(gtk.SHADOW_IN)
        self.msgscroll.set_border_width(2)
        self.msgscroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.mainbox.pack_start(self.msgscroll, expand=1, fill=1)
        self.textview = gtk.TextView()
        self.textview.set_cursor_visible(False)
        self.textview.set_editable(False)
        textattrs = self.textview.get_default_attributes()
        self.boldTag = self.textview.get_buffer().create_tag(
            "bold",
            weight=pango.WEIGHT_BOLD,  # why doesn't this work?
            foreground="blue")
##         self.boldTag = self.textview.get_buffer().create_tag(
##             "bold",
##             weight=pango.WEIGHT_HEAVY,  # why doesn't this work?
##             underline=pango.UNDERLINE_SINGLE)
        self.textview.set_wrap_mode(gtk.WRAP_WORD_CHAR)
        self.msgscroll.add(self.textview)        

        buttonbox = gtk.HBox(homogeneous=1, spacing=2)
        self.mainbox.pack_end(buttonbox, expand=0, fill=0, padding=2)
        self.backbutton = gtkutils.StockButton(gtk.STOCK_GO_BACK, "Back")
        gtklogger.setWidgetName(self.backbutton, "Back")
        gtklogger.connect(self.backbutton, "clicked", self.backCB)
        tooltips.set_tooltip_text(self.backbutton,"Move to the previous slide.")

        self.nextbutton = gtkutils.StockButton(gtk.STOCK_GO_FORWARD, "Next")
        gtklogger.setWidgetName(self.nextbutton, "Next")
        gtklogger.connect(self.nextbutton, "clicked", self.nextCB)
        tooltips.set_tooltip_text(self.nextbutton,"Move to the next slide.")
        
        self.jumpbutton = gtkutils.StockButton(gtk.STOCK_GOTO_LAST, "Jump")
        gtklogger.setWidgetName(self.jumpbutton, "Jump")
        gtklogger.connect(self.jumpbutton, "clicked", self.jumpCB)
        tooltips.set_tooltip_text(self.jumpbutton,"Jump to the leading slide.")

        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 your tutorial session.")

        self.closebutton = gtkutils.StockButton(gtk.STOCK_CLOSE, "Close")
        gtklogger.setWidgetName(self.closebutton, "Close")
        gtklogger.connect(self.closebutton, "clicked", self.closeCB)
        tooltips.set_tooltip_text(self.closebutton,"Quit the tutorial.")
        
        buttonbox.pack_start(self.backbutton, expand=1, fill=1, padding=2)
        buttonbox.pack_start(self.nextbutton, expand=1, fill=1, padding=2)
        buttonbox.pack_start(self.jumpbutton, expand=1, fill=1, padding=2)
        buttonbox.pack_start(self.savebutton, expand=1, fill=1, padding=2)
        buttonbox.pack_end(self.closebutton, expand=1, fill=1, padding=2)

        self.gtk.connect('destroy', self.closeCB)
        self.gtk.set_default_size(500, 300)

        self.progress = 0  # How far has the tutorial gone?
                           # It's not affected by "Back" command.
        self.index = 0     # which slide?
        self.signalReceived = 0  # Received a signal, if any.
        self.tutor = tutor
        self.newLesson()
        self.tutor.lessons[0].activate()
        self.saved = None  # if saved or not

        switchboard.requestCallbackMain("task finished", self.signalCB)
コード例 #13
0
ファイル: skeletonPage.py プロジェクト: anilkunwar/OOF2
    def __init__(self):
        self.postponed_update = False
        oofGUI.MainPage.__init__(self, name="Skeleton", ordering=120,
                                 tip='Construct and modify mesh skeletons')

        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'),
                                              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.skelwidget.gtk[0], expand=1, fill=1)
        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=1, fill=1)

        # Centered box of buttons
        align = gtk.Alignment(xalign=0.5)
        mainbox.pack_start(align, expand=0, fill=0)
        bbox = gtk.HBox(homogeneous=1, spacing=3)
        align.add(bbox)

        self.newbutton = gtkutils.StockButton(gtk.STOCK_NEW, 'New...')
        gtklogger.setWidgetName(self.newbutton, "New")
        gtklogger.connect(self.newbutton, 'clicked', self.new_skeleton_CB)
        tooltips.set_tooltip_text(self.newbutton,"Create a new skeleton from the current microstructure.")
        bbox.pack_start(self.newbutton, expand=1, fill=1)
        
        self.simplebutton = gtk.Button('Simple...')
        gtklogger.setWidgetName(self.simplebutton, "Simple")
        gtklogger.connect(self.simplebutton, 'clicked', self.simple_skeleton_CB)
        tooltips.set_tooltip_text(self.simplebutton,"Create a new skeleton from the current microstructure in a naive fashion, by creating one quadrilateral or two triangular elements per pixel.  Material boundaries will be inherently jagged, which may cause errors in finite element solutions.")
        bbox.pack_start(self.simplebutton, expand=1, fill=1)

        self.autobutton = gtk.Button('Auto...')
        gtklogger.setWidgetName(self.autobutton, 'Auto')
        gtklogger.connect(self.autobutton, 'clicked', self.autoCB)
        tooltips.set_tooltip_text(self.autobutton,"Create and automatically refine a Skeleton.")
        bbox.pack_start(self.autobutton, expand=1, fill=1)
        
        self.renamebutton = gtkutils.StockButton(gtk.STOCK_EDIT, 'Rename...')
        gtklogger.setWidgetName(self.renamebutton, "Rename")
        gtklogger.connect(self.renamebutton, 'clicked', self.rename_skeleton_CB)
        tooltips.set_tooltip_text(self.renamebutton,"Rename the current skeleton.")
        bbox.pack_start(self.renamebutton, expand=1, fill=1)

        self.copybutton = gtkutils.StockButton(gtk.STOCK_COPY, 'Copy...')
        gtklogger.setWidgetName(self.copybutton, 'Copy')
        gtklogger.connect(self.copybutton, 'clicked', self.copy_skeleton_CB)
        tooltips.set_tooltip_text(self.copybutton,"Copy the current skeleton.")
        bbox.pack_start(self.copybutton, expand=1, fill=1)

        self.deletebutton = gtkutils.StockButton(gtk.STOCK_DELETE, 'Delete')
        gtklogger.setWidgetName(self.deletebutton, 'Delete')
        gtklogger.connect(self.deletebutton, 'clicked', self.delete_skeletonCB)
        tooltips.set_tooltip_text(self.deletebutton,"Delete the current skeleton.")
        bbox.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.save_skeletonCB)
        tooltips.set_tooltip_text(self.savebutton,
                             "Save the current skeleton to a file.")
        bbox.pack_start(self.savebutton, expand=1, fill=1)
        
        mainpane = gtk.HPaned()
        gtklogger.setWidgetName(mainpane, 'Pane')
        mainbox.pack_start(mainpane, expand=1, fill=1)
        gtklogger.connect_passive(mainpane, 'notify::position')

        self.skelframe = gtk.Frame(label="Skeleton Status")
        self.skelframe.set_shadow_type(gtk.SHADOW_IN)
        mainpane.pack1(self.skelframe, resize=1, shrink=0)
        scroll = gtk.ScrolledWindow()
        gtklogger.logScrollBars(scroll, "StatusScroll")
        scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        scroll.set_shadow_type(gtk.SHADOW_IN)
        self.skelframe.add(scroll)
        self.skelinfo = fixedwidthtext.FixedWidthTextView()
        gtklogger.setWidgetName(self.skelinfo, "SkeletonText")
        self.skelinfo.set_wrap_mode(gtk.WRAP_WORD)
        self.skelinfo.set_editable(False)
        self.skelinfo.set_cursor_visible(False)
        self.boldTag = self.skelinfo.get_buffer().create_tag(
            "bold", weight=pango.WEIGHT_BOLD)
        scroll.add(self.skelinfo)

        # End of left-side of skeleton info frame.

        # Start of right-side

        skelmodframe = gtk.Frame(label="Skeleton Modification")
        gtklogger.setWidgetName(skelmodframe, 'Modification')
        skelmodframe.set_shadow_type(gtk.SHADOW_IN)
        skelmodbox = gtk.VBox(spacing=3)
        skelmodframe.add(skelmodbox)

        self.skelmod = regclassfactory.RegisteredClassFactory(
                       skeletonmodifier.SkeletonModifier.registry,
                       title="method: ",
                       callback=self.skelmodCB,
                       expand=0, fill=0, scope=self, name="Method")
        self.historian = historian.Historian(self.skelmod.set,
                                             self.sensitizeHistory,
                                             setCBkwargs={'interactive':1})

        skelmodbox.pack_start(self.skelmod.gtk,expand=1,fill=1)

        # Buttons for "Previous", "OK", and "Next"
        hbox = gtk.HBox()
        self.prevskelmodbutton = gtkutils.prevButton()
        gtklogger.connect(self.prevskelmodbutton, 'clicked', self.prevskelmod)
        tooltips.set_tooltip_text(self.prevskelmodbutton,
                      'Recall the previous skeleton modification operation.')
        hbox.pack_start(self.prevskelmodbutton, 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.okskelmod)
        tooltips.set_tooltip_text(self.okbutton,
                  'Perform the skeleton modification operation defined above.')
        hbox.pack_start(self.okbutton, expand=1, fill=1, padding=5)

        self.nextskelmodbutton = gtkutils.nextButton()
        gtklogger.connect(self.nextskelmodbutton, 'clicked', self.nextskelmod)
        tooltips.set_tooltip_text(self.nextskelmodbutton,
                             'Recall the next skeleton modification operation.')
        hbox.pack_start(self.nextskelmodbutton, expand=0, fill=0, padding=2)

        skelmodbox.pack_start(hbox, expand=0, fill=0, padding=2) 

        # Buttons for "Undo", "Redo"
        hbox = gtk.HBox()
        self.undobutton = gtk.Button(stock=gtk.STOCK_UNDO)
        gtklogger.setWidgetName(self.undobutton, 'Undo')
        gtklogger.connect(self.undobutton, 'clicked', self.undoskelmod)
        tooltips.set_tooltip_text(self.undobutton,
                             'Undo the latest skeleton 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.redoskelmod)
        tooltips.set_tooltip_text(self.redobutton,
                             'Redo the latest undone skeleton modification.')
        hbox.pack_start(self.redobutton, expand=1, fill=0, padding=10)

        skelmodbox.pack_start(hbox, expand=0, fill=0, padding=2)

        mainpane.pack2(skelmodframe, resize=0, shrink=0)
        # End of right-side

        self.sbcallbacks = [
            switchboard.requestCallback("made reservation",
                                        self.update_ok_button),
            switchboard.requestCallback("cancelled reservation",
                                        self.update_ok_button),
            switchboard.requestCallback("skeleton homogeneity changed",
                                        self.homogeneityChangeCB),
            switchboard.requestCallbackMain("Skeleton modified",
                                            self.recordModifier),
            switchboard.requestCallback(('who changed', 'Skeleton'),
                                        self.changeSkeleton),
            switchboard.requestCallbackMain(SkeletonModifier,
                                            self.updateskelmod),
            switchboard.requestCallbackMain(("new who", "Microstructure"),
                                            self.newMicrostructure),
            switchboard.requestCallbackMain(("new who", 'Skeleton'),
                                            self.newSkeleton),
            # Pages should catch the signal from updates to the widget
            # which don't originate on this page, e.g. deletions via
            # menu command.
            switchboard.requestCallback(self.skelwidget, self.skel_update),

            switchboard.requestCallback(('validity', self.skelmod),
                                        self.validityChangeCB),
            # Node movements can change the homogeneity of elements,
            # thus changing the state.
            switchboard.requestCallback("skeleton nodes moved", self.nodesMoved)
            ]
コード例 #14
0
    def __init__(self):
        self.built = False
        oofGUI.MainPage.__init__(self, name="Skeleton Boundaries",
                                 ordering = 150,
                                 tip = "Create and orient 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.skelwidget = whowidget.WhoWidget(whoville.getClass('Skeleton'),
                                              scope=self)
        switchboard.requestCallbackMain(self.skelwidget,
                                        self.widgetChanged)
        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')

        boundarylistframe = gtk.Frame("Boundaries")
        gtklogger.setWidgetName(boundarylistframe, 'Boundaries')
        boundarylistframe.set_shadow_type(gtk.SHADOW_IN)
        mainpane.pack1(boundarylistframe, resize=0, shrink=0)

        boundarylistbox = gtk.VBox()
        boundarylistframe.add(boundarylistbox)

        # List of all the boundaries.
        self.boundarylist = chooser.ScrolledChooserListWidget(
            callback=self.boundarylistCB,
            dbcallback=self.modifyBoundaryCB,
            autoselect=0,
            name="BoundaryList",
            separator_func=self.chooserSepFunc)
        boundarylistbox.pack_start(self.boundarylist.gtk, expand=1, fill=1)

        boundarybuttonbox = gtk.HBox(homogeneous=1, spacing=2)
        boundarylistbox.pack_start(boundarybuttonbox, expand=0, fill=0)

        # Buttons that actually do stuff.
        self.newbutton = gtk.Button("New...")
        gtklogger.setWidgetName(self.newbutton, 'New')
        gtklogger.connect(self.newbutton, "clicked", self.newBoundaryCB)
        tooltips.set_tooltip_text(self.newbutton,
                             "Construct a new boundary in the skeleton and associated meshes.")
        boundarybuttonbox.pack_start(self.newbutton, expand=1, fill=1)

        self.editbutton = gtk.Button("Modify...")
        gtklogger.setWidgetName(self.editbutton, 'Modify')
        gtklogger.connect(self.editbutton, "clicked", self.modifyBoundaryCB)
        tooltips.set_tooltip_text(self.editbutton,
                             "Modify the attributes of the selected boundary.")
        boundarybuttonbox.pack_start(self.editbutton, expand=1, fill=1)
        
        self.renamebutton = gtk.Button("Rename...")
        gtklogger.setWidgetName(self.renamebutton, 'Rename')
        gtklogger.connect(self.renamebutton, "clicked", self.renameBoundaryCB)
        tooltips.set_tooltip_text(self.renamebutton,
                             "Rename the selected boundary.")
        boundarybuttonbox.pack_start(self.renamebutton, expand=1, fill=1)

        self.deletebutton = gtk.Button("Delete")
        gtklogger.setWidgetName(self.deletebutton, 'Delete')
        gtklogger.connect(self.deletebutton, "clicked", self.deleteBoundaryCB)
        tooltips.set_tooltip_text(self.deletebutton,
                             "Delete the selected boundary from the skeleton and associated meshes.")
        boundarybuttonbox.pack_start(self.deletebutton, expand=1, fill=1)
        
        # TODO LATER: Copying could be added here -- the scenario is
        # that a user may want to make a copy of a boundary, and then
        # edit one of the copies.  Currently boundary editing is
        # primitive (one can only add/remove components), but when
        # visual pointy-clicky boundary editing is added, copying will
        # make sense.

        infoframe = gtk.Frame("Boundary data")
        infoframe.set_shadow_type(gtk.SHADOW_IN)
        mainpane.pack2(infoframe, resize=1, shrink=1)

        infowindow = gtk.ScrolledWindow()
        gtklogger.logScrollBars(infowindow, "InfoScroll")
        infowindow.set_shadow_type(gtk.SHADOW_IN)
        infoframe.add(infowindow)
        infowindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        
        self.infotext = fixedwidthtext.FixedWidthTextView()
        self.infotext.set_wrap_mode(gtk.WRAP_WORD)
        gtklogger.setWidgetName(self.infotext, 'status')
        self.infotext.set_editable(False)
        infowindow.add(self.infotext)

        self.built = True
        
        # Catches push events *after* the boundaries have been
        # propagated, and also undo/redo events.  "who changed" is
        # too early.
        switchboard.requestCallbackMain("new boundary configuration",
                                        self.newBdyConfigCB)
        switchboard.requestCallbackMain("new boundary created",
                                        self.newBdyCB)
        switchboard.requestCallbackMain("boundary removed",
                                        self.newBdyCB)
        switchboard.requestCallbackMain("boundary renamed",
                                        self.newBdyCB),
        switchboard.requestCallbackMain(("new who", "Microstructure"),
                                        self.newMicrostructureCB)
        self.selectsignals = [
            switchboard.requestCallbackMain("boundary selected",
                                            self.bdySelectedCB),
            switchboard.requestCallbackMain("boundary unselected",
                                            self.bdyUnselectedCB)
            ]
コード例 #15
0
ファイル: meshPage.py プロジェクト: anilkunwar/OOF2
    def __init__(self):
        self.built = False
        oofGUI.MainPage.__init__(self, name="FE Mesh", ordering=200,
                                 tip="Create a Finite Element Mesh from a Skeleton.")
        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)
        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)

        # Centered box of buttons
        align = gtk.Alignment(xalign=0.5)
        mainbox.pack_start(align, expand=0, fill=0)
        bbox = gtk.HBox(homogeneous=1, spacing=3)
        align.add(bbox)
        self.newbutton = gtkutils.StockButton(gtk.STOCK_NEW, "New...")
        gtklogger.setWidgetName(self.newbutton, 'New')
        gtklogger.connect(self.newbutton, 'clicked', self.newCB)
        tooltips.set_tooltip_text(self.newbutton,"Create a new mesh from the current skeleton.")
        bbox.pack_start(self.newbutton, expand=0, fill=1)
        
        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 mesh.")   
        bbox.pack_start(self.renamebutton, expand=0, fill=1)
        
        self.copybutton = gtkutils.StockButton(gtk.STOCK_COPY, "Copy...")
        gtklogger.setWidgetName(self.copybutton, 'Copy')
        gtklogger.connect(self.copybutton, 'clicked', self.copyCB)
        tooltips.set_tooltip_text(self.copybutton,"Copy the current mesh.")
        bbox.pack_start(self.copybutton, expand=0, 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 mesh.")
        bbox.pack_start(self.deletebutton, expand=0, 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 mesh to a file.")
        bbox.pack_start(self.savebutton, expand=0, fill=1)

        mainpane = gtk.HPaned()
        gtklogger.setWidgetName(mainpane, 'Pane')
        mainbox.pack_start(mainpane, expand=1, fill=1)
        gtklogger.connect_passive(mainpane, 'notify::position')
        leftbox = gtk.VPaned()
        mainpane.pack1(leftbox, resize=1, shrink=0)
        
        infoframe = gtk.Frame('Mesh Information')
        infoframe.set_shadow_type(gtk.SHADOW_IN)
        leftbox.pack1(infoframe, resize=1, shrink=1)
        scroll = gtk.ScrolledWindow()
        gtklogger.logScrollBars(scroll, "MeshInfo")
        scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        scroll.set_shadow_type(gtk.SHADOW_IN)
        infoframe.add(scroll)
        self.infoarea = fixedwidthtext.FixedWidthTextView()
        self.infoarea.set_cursor_visible(False)
        self.infoarea.set_editable(False)
        scroll.add(self.infoarea)

        # Subproblem creation, deletion, etc.
        subprobframe = gtk.Frame('Subproblems')
        gtklogger.setWidgetName(subprobframe, 'Subproblems')
        subprobframe.set_shadow_type(gtk.SHADOW_IN)
        leftbox.pack2(subprobframe, resize=1, shrink=1)
        subpbox = gtk.VBox()
        subprobframe.add(subpbox)
        self.subpchooser = chooser.ScrolledChooserListWidget(
            callback=self.subpchooserCB,
            dbcallback=self.subprobEditCB,
            name="subprobChooser")
        subpbox.pack_start(self.subpchooser.gtk, expand=1, fill=1)

        subpbuttons1 = gtk.HBox(homogeneous=True, spacing=2)
        subpbuttons2 = gtk.HBox(homogeneous=True, spacing=2)
        subpbox.pack_start(subpbuttons1, expand=0, fill=0)
        subpbox.pack_start(subpbuttons2, expand=0, fill=0)

        self.subprobNew = gtkutils.StockButton(gtk.STOCK_NEW, "New...")
        gtklogger.setWidgetName(self.subprobNew, "New")
        gtklogger.connect(self.subprobNew, "clicked", self.subprobNewCB)
        tooltips.set_tooltip_text(self.subprobNew,"Create a new subproblem.")
        subpbuttons1.pack_start(self.subprobNew, expand=1, fill=1)

        self.subprobRename = gtk.Button("Rename...")
        gtklogger.setWidgetName(self.subprobRename, "Rename")
        gtklogger.connect(self.subprobRename, "clicked", self.subprobRenameCB)
        tooltips.set_tooltip_text(self.subprobRename,
                             "Rename the selected subproblem")
        subpbuttons1.pack_start(self.subprobRename, expand=1, fill=1)

        self.subprobEdit = gtkutils.StockButton(gtk.STOCK_EDIT, "Edit...")
        gtklogger.setWidgetName(self.subprobEdit, "Edit")
        gtklogger.connect(self.subprobEdit, 'clicked', self.subprobEditCB)
        tooltips.set_tooltip_text(self.subprobEdit,"Edit the selected subproblem.")
        subpbuttons1.pack_start(self.subprobEdit, expand=1, fill=1)

        self.subprobCopy = gtkutils.StockButton(gtk.STOCK_COPY, "Copy...")
        gtklogger.setWidgetName(self.subprobCopy, "Copy")
        gtklogger.connect(self.subprobCopy, "clicked", self.subprobCopyCB)
        tooltips.set_tooltip_text(self.subprobCopy,"Copy the selected subproblem.")
        subpbuttons2.pack_start(self.subprobCopy, expand=1, fill=1)

##        subpbuttons2.pack_start(gtk.HBox(), expand=1, fill=1) # filler
        self.subprobInfo = gtk.Button("Info")
        gtklogger.setWidgetName(self.subprobInfo, "Info")
        gtklogger.connect(self.subprobInfo, 'clicked', self.subprobInfoCB)
        tooltips.set_tooltip_text(self.subprobInfo,
                             "Print information about the selected subproblem")
        subpbuttons2.pack_start(self.subprobInfo, expand=1, fill=1)
        
        self.subprobDelete = gtkutils.StockButton(gtk.STOCK_DELETE, "Delete")
        gtklogger.setWidgetName(self.subprobDelete, "Delete")
        gtklogger.connect(self.subprobDelete, "clicked", self.subprobDeleteCB)
        tooltips.set_tooltip_text(self.subprobDelete,
                             "Delete the selected subproblem.")
        subpbuttons2.pack_start(self.subprobDelete, expand=1, fill=1)
        
        # Right hand side for element operations
        
        elementopsframe = gtk.Frame(label="Mesh Operations")
        gtklogger.setWidgetName(elementopsframe, 'ElementOps')
        elementopsframe.set_shadow_type(gtk.SHADOW_IN)
        mainpane.pack2(elementopsframe, resize=0, shrink=0)
        elementopsbox = gtk.VBox(spacing=3)
        elementopsframe.add(elementopsbox)
        self.elementops = regclassfactory.RegisteredClassFactory(
            meshmod.MeshModification.registry,
            title="Method:",
            callback=self.elementopsCB,
            expand=0, fill=0, scope=self, name="Method")
        elementopsbox.pack_start(self.elementops.gtk, expand=1, fill=1)

        self.historian = historian.Historian(self.elementops.set,
                                             self.sensitizeHistory,
                                             setCBkwargs={'interactive':1})
        # Prev, OK, Next
        hbox = gtk.HBox()
        elementopsbox.pack_start(hbox, expand=0, fill=0, padding=2)
        self.prevbutton = gtkutils.prevButton()
        gtklogger.connect(self.prevbutton, 'clicked', self.prevCB)
        tooltips.set_tooltip_text(self.prevbutton,
                             "Recall the previous mesh element operation.")
        hbox.pack_start(self.prevbutton, 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,
                          'Perform the mesh operation defined above.')
        hbox.pack_start(self.okbutton, expand=1, fill=1, padding=5)

        self.nextbutton = gtkutils.nextButton()
        gtklogger.connect(self.nextbutton, 'clicked', self.nextCB)
        tooltips.set_tooltip_text(self.nextbutton,
                             'Recall the next mesh element operation.')
        hbox.pack_start(self.nextbutton, expand=0, fill=0, padding=2)

        self.built = True

        switchboard.requestCallbackMain("Mesh modified",
                                        self.recordModifier)
        switchboard.requestCallbackMain("mesh changed", self.meshchangeCB)
        switchboard.requestCallbackMain(("new who", "Microstructure"),
                                        self.newMSorSkeleton)
        switchboard.requestCallbackMain(("new who", "Skeleton"),
                                        self.newMSorSkeleton)
        switchboard.requestCallbackMain(("new who", "Mesh"),
                                        self.newMesh)
        switchboard.requestCallbackMain(("new who", "SubProblem"),
                                        self.newSubProblem)
        switchboard.requestCallbackMain(("rename who", "SubProblem"),
                                        self.renamedSubProblem)
        switchboard.requestCallbackMain(("remove who", "SubProblem"),
                                         self.removeSubProblem)
        switchboard.requestCallbackMain(self.meshwidget, self.meshwidgetCB)
        switchboard.requestCallbackMain("equation activated",
                                        self.equationCB)
        switchboard.requestCallbackMain("mesh status changed",
                                        self.statusChanged)
#         switchboard.requestCallbackMain("mesh boundaries changed",
#                                         self.newMeshBoundaries)

        switchboard.requestCallbackMain(('validity', self.elementops),
                                        self.validityChangeCB)
コード例 #16
0
ファイル: meshcstoolboxGUI.py プロジェクト: anilkunwar/OOF2
    def __init__(self, toolbox):
        toolboxGUI.GfxToolbox.__init__(
            self, utils.underscore2space(toolbox.name()), toolbox)

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

        sourceframe = gtk.Frame("Source")
        sourceframe.set_shadow_type(gtk.SHADOW_IN)
        mainbox.pack_start(sourceframe, fill=0, expand=0)
        sourcescroll = gtk.ScrolledWindow()
        gtklogger.logScrollBars(sourcescroll, "Source")
        sourceframe.add(sourcescroll)
        sourcescroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_NEVER)
        datatable = gtk.Table(rows=2,columns=2)
        sourcescroll.add_with_viewport(datatable)
        
        meshlabel = gtk.Label("mesh = ")
        meshlabel.set_alignment(1.0, 0.5)
        self.meshname = gtk.Label()
        gtklogger.setWidgetName(self.meshname,"meshname")
        self.meshname.set_alignment(0.0, 0.5)

        datatable.attach(meshlabel, 0, 1, 0, 1)
        datatable.attach(self.meshname, 1, 2, 0, 1)

        layerlabel = gtk.Label("output = ")
        layerlabel.set_alignment(1.0, 0.5)
        self.layername = gtk.Label()
        gtklogger.setWidgetName(self.layername,"layername")
        self.layername.set_alignment(0.0, 0.5)

        datatable.attach(layerlabel, 0, 1, 1, 2)
        datatable.attach(self.layername, 1, 2, 1, 2)


        csframe = gtk.Frame("Cross Section")
        csframe.set_shadow_type(gtk.SHADOW_IN)
        mainbox.pack_start(csframe, expand=0, fill=0)
        csbox = gtk.VBox()
        csframe.add(csbox)

        # Table contains the "current" and "points" widgets
        table = gtk.Table(rows=2, columns=2)
        csbox.pack_start(table, expand=0, fill=0)

        # Widget which shows the name of the current cross-section.
        label = gtk.Label("current: ")
        label.set_alignment(1.0, 0.5)
        table.attach(label, 0,1, 0,1, xoptions=0)
        self.csChooser = chooser.ChooserWidget([], callback=self.csChooserCB,
                                               name='csList')
        table.attach(self.csChooser.gtk, 1,2, 0,1,
                     xoptions=gtk.EXPAND|gtk.FILL, yoptions=0)

        # Widget for how to sample the cross-section.
        label = gtk.Label("points: ")
        label.set_alignment(1.0, 0.5)
        table.attach(label, 0,1, 1,2, xoptions=0)

        self.cs_sample_widget = sampleregclassfactory.SampleRCF(
            name="Sampling", 
            domainClass=analysisdomain.CrossSectionDomain,
            operationClass=analyze.DirectOutput)
        table.attach(self.cs_sample_widget.gtk, 1,2, 1,2,
                     xoptions=gtk.EXPAND|gtk.FILL, yoptions=0)
        self.cs_sample_widget.update(analysissample.SampleSet.registry)
        self.int_valid_swcb = switchboard.requestCallbackMain(
            ('validity', self.cs_sample_widget), self.validCB)

        hbox = gtk.HBox()
        csbox.pack_start(hbox, expand=0, fill=0, padding=1)
        # Rename button.
        self.renamebutton = gtk.Button("Rename")
        gtklogger.setWidgetName(self.renamebutton, 'Rename')
        gtklogger.connect(self.renamebutton, 'clicked', self.csrenameCB)
        tooltips.set_tooltip_text(self.renamebutton,
                             "Rename the current cross-section.")
        hbox.pack_start(self.renamebutton,fill=1,expand=1, padding=1)
        # Edit button
        self.editbutton = gtkutils.StockButton(gtk.STOCK_EDIT, "Edit...")
        gtklogger.setWidgetName(self.editbutton, 'Edit')
        gtklogger.connect(self.editbutton, 'clicked', self.cseditCB)
        tooltips.set_tooltip_text(self.editbutton,"Edit the current cross-section.")
        hbox.pack_start(self.editbutton, fill=1, expand=1, padding=1)
        # Copy button
        self.copybutton = gtkutils.StockButton(gtk.STOCK_COPY, "Copy...")
        gtklogger.setWidgetName(self.copybutton, 'Copy')
        gtklogger.connect(self.copybutton, 'clicked', self.cscopyCB)
        tooltips.set_tooltip_text(self.copybutton,"Copy the current cross-section.")
        hbox.pack_start(self.copybutton, fill=1, expand=1, padding=1)
        # Delete button.
        self.csdeletebutton = gtkutils.StockButton(gtk.STOCK_DELETE, "Remove")
        gtklogger.setWidgetName(self.csdeletebutton, 'Remove')
        gtklogger.connect(self.csdeletebutton, "clicked", self.csdeleteCB)
        tooltips.set_tooltip_text(self.csdeletebutton,
                             "Remove the current cross-section.")
        hbox.pack_start(self.csdeletebutton,fill=1,expand=1, padding=1)

        goframe = gtk.Frame("Output")
        goframe.set_shadow_type(gtk.SHADOW_IN)
        mainbox.pack_start(goframe,expand=0,fill=0)
        self.gobox = gtk.VBox()
        goframe.add(self.gobox)

        hbox = gtk.HBox()
        self.gobox.pack_start(hbox, expand=0, fill=0)
        label = gtk.Label("Destination: ")
        label.set_alignment(1.0, 0.5)
        hbox.pack_start(label, expand=0, fill=0)
        self.destwidget = outputdestinationwidget.TextDestinationWidget(
            name="Destination")
        self.dw_valid_swcb = switchboard.requestCallbackMain(
            ('validity', self.destwidget), self.validCB )
        hbox.pack_start(self.destwidget.gtk, expand=1, fill=1, padding=2)
        self.gobutton = gtkutils.StockButton(gtk.STOCK_EXECUTE, "Go!")
        gtklogger.setWidgetName(self.gobutton, 'Go')
        hbox.pack_start(self.gobutton,expand=1,fill=1, padding=2)
        tooltips.set_tooltip_text(self.gobutton,
            "Send the output to the destination.")
        gtklogger.connect(self.gobutton, "clicked", self.goCB)
        
        self.startpoint = None
        self.endpoint = None

        # Data needed by the "go" button.  Set in "show_data", when
        # the state of all the widgets is examined.
        self.meshobj = None
        self.current_cs_name = None
        
        # Shut off non-GUI toolbox's switchboard callbacks.  We will
        # take them over at activate-time.
        self.toolbox.stop_callbacks()
コード例 #17
0
ファイル: imagePage.py プロジェクト: anilkunwar/OOF2
    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.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)
            ]
コード例 #18
0
ファイル: layereditorGUI.py プロジェクト: anilkunwar/OOF2
    def __init__(self):
        debug.mainthreadTest()
        self.built = False
        layereditor.LayerEditor.__init__(self)
        gtklogger.checkpoint("layereditor layerset changed")

        self.suppressCallbacks = 0

        widgetscope.WidgetScope.__init__(self, None)

        self.setData("gfxwindow", None) # widgetscope data, that is
        
        self.sbcallbacks = [
            switchboard.requestCallbackMain('open graphics window',
                                            self.gfxwindowChanged),
            switchboard.requestCallbackMain('close graphics window',
                                            self.gfxwindowChanged)
            ]


        self.menu.File.Quit.gui_callback = quit.queryQuit

        subWindow.SubWindow.__init__(
            self, title="%s Graphics Layer Editor"%subWindow.oofname(),
            menu=self.menu)
##        self.gtk.set_policy(1, 1, 0)
        self.gtk.set_default_size(600, 250)
        self.gtk.connect('destroy', self.destroyCB)

        mainpane = gtk.HPaned()
        mainpane.set_border_width(3)
        mainpane.set_position(300)
        self.mainbox.pack_start(mainpane, expand=1, fill=1)

        # The left side of the layer editor is for choosing the object
        # being drawn.
        whoframe = gtk.Frame('Displayed Object')
        mainpane.pack1(whoframe, resize=1, shrink=0)
        wscroll = gtk.ScrolledWindow()
        gtklogger.logScrollBars(wscroll, "ObjectScroll")
        wscroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        whoframe.add(wscroll)
        vbox = gtk.VBox()
        wscroll.add_with_viewport(vbox)
        cmd = self.menu.LayerSet.DisplayedObject
        # This creates a table containing a WhoClassWidget and a WhoWidget:
        ptable = parameterwidgets.ParameterTable(
            [cmd.get_arg('category'), cmd.get_arg('object')],
            scope=self)
        vbox.pack_start(ptable.gtk, expand=0, fill=0)

        # The right side of the layer editor lists the display methods
        # for the object on the left side.
        methframe = gtk.Frame('Display Methods')
        gtklogger.setWidgetName(methframe, "DisplayMethods")
        mainpane.pack2(methframe, resize=1, shrink=0)
        mvbox = gtk.VBox()
        methframe.add(mvbox)
        mhbox = gtk.HBox()
        mvbox.pack_start(mhbox, expand=1, fill=1)
        self.methodList = chooser.ScrolledChooserListWidget(
            callback=self.singleClickMethodCB,
            dbcallback=self.doubleClickMethodCB,
            comparator=lambda x, y: (not x.inequivalent(y)),
            name="List")
        mhbox.pack_start(self.methodList.gtk, expand=1, fill=1, padding=3)

        # The who widget is replaced each time the who class widget is
        # activated, so its switchboard callback must be reset often,
        # and is done in findWidget().
        self.whowidgetsignal = None
        self.findWhoWidget()

        buttonbox = gtk.HBox()
        mvbox.pack_start(buttonbox, expand=0, fill=0, padding=3)

        self.newMethodButton = gtkutils.StockButton(gtk.STOCK_NEW, 'New...')
        buttonbox.pack_start(self.newMethodButton, expand=0, fill=0)
        gtklogger.setWidgetName(self.newMethodButton, "New")
        gtklogger.connect(self.newMethodButton, 'clicked',
                          self.newMethodButtonCB)
        self.editMethodButton = gtkutils.StockButton(gtk.STOCK_EDIT, 'Edit...')
        buttonbox.pack_start(self.editMethodButton, expand=0, fill=0)
        gtklogger.setWidgetName(self.editMethodButton, "Edit")
        gtklogger.connect(self.editMethodButton, 'clicked',
                          self.editMethodButtonCB)
        self.copyMethodButton = gtkutils.StockButton(gtk.STOCK_COPY, 'Copy')
        buttonbox.pack_start(self.copyMethodButton, expand=0, fill=0)
        gtklogger.setWidgetName(self.copyMethodButton, "Copy")
        gtklogger.connect(self.copyMethodButton, 'clicked',
                          self.copyMethodButtonCB)
        self.deleteMethodButton = gtkutils.StockButton(gtk.STOCK_DELETE,
                                                       'Delete')
        buttonbox.pack_start(self.deleteMethodButton, expand=0, fill=0)
        gtklogger.setWidgetName(self.deleteMethodButton, "Delete")
        gtklogger.connect(self.deleteMethodButton, 'clicked',
                          self.deleteMethodButtonCB)

        self.mainbox.pack_start(gtk.HSeparator(), expand=0, fill=0)

        # Buttons at the bottom governing LayerSet operations:
        # New LayerSet, Send to Gfx Window, etc.
        
        mainbuttonbox = gtk.HBox()
        self.mainbox.pack_start(mainbuttonbox, expand=0, fill=0, padding=3)

        newLayerButton = gtkutils.StockButton(gtk.STOCK_NEW, 'New Layer')
        mainbuttonbox.pack_start(newLayerButton, expand=0, fill=0, padding=3)
        gtklogger.setWidgetName(newLayerButton, "NewLayer")
        gtklogger.connect(newLayerButton, 'clicked', self.newLayerButtonCB)

        self.sendButton = gtkutils.StockButton(gtk.STOCK_GO_FORWARD, 'Send',
                                               reverse=1)
##        self.sendButton.set_usize(80, -1)
        mainbuttonbox.pack_end(self.sendButton, expand=0, fill=0, padding=3)
        gtklogger.setWidgetName(self.sendButton, "Send")
        gtklogger.connect(self.sendButton, 'clicked', self.sendCB)
        self.destinationMenu = chooser.ChooserWidget([], name="Destination")
        mainbuttonbox.pack_end(self.destinationMenu.gtk, expand=0, fill=0)
        self.updateDestinationMenu()
        label=gtk.Label('Destination=')
        tooltips.set_tooltip_text(label,
            'The graphics window(s) that will display the layer(s).')
        label.set_alignment(1.0, 0.5)
        mainbuttonbox.pack_end(label, expand=0, fill=0)

        self.mainbox.pack_start(gtk.HSeparator(), expand=0, fill=0, padding=3)

        # When the lhs widgets change state the rhs might have to
        # change too.  The widgets referred to here are inside the
        # ParameterTable constructed above.
        self.whoclasswidget = self.findWidget(
            lambda w: isinstance(w, whowidget.WhoClassParameterWidget))
        self.whoclasswidgetsignal = switchboard.requestCallbackMain(
            self.whoclasswidget, self.whoClassChangedCB)
        self.sbcallbacks.append(self.whoclasswidgetsignal)

        self.built = True
        self.sensitize()
        self.gtk.show_all()
コード例 #19
0
ファイル: solverPage.py プロジェクト: anilkunwar/OOF2
    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: 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...")
        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)

        # # Step size is set by the user and changed by the program.
        # label = gtk.Label('step size=')
        # label.set_alignment(1.0, 0.5)
        # table.attach(label, 0,1, 2,3, xpadding=3, xoptions=~gtk.EXPAND)
        # self.stepsizeEntry = gtk.Entry()
        # gtklogger.setWidgetName(self.stepsizeEntry, 'stepsize')
        # self.stepsizeSig = gtklogger.connect(self.stepsizeEntry, 'changed',
        #                                      self.timeChangeCB)
        # table.attach(self.stepsizeEntry, 1,2, 2,3, 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)
コード例 #20
0
ファイル: pinnodesPage.py プロジェクト: anilkunwar/OOF2
    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)
コード例 #21
0
ファイル: reporter_GUI.py プロジェクト: anilkunwar/OOF2
    def __init__(self, e_type, value, tbacklist):
        debug.mainthreadTest()
        
        errorstrings = []     # list of strings
        self.tracebacks = []  # list of lists of \n-terminated strings

        # If there are previous unprocessed exceptions, print them
        # too.  The oldest exception is the first in the
        # _savedExceptions list.
        global _savedExceptions
        _savedExceptions.append((e_type, value, tbacklist))
        for e_type, value, tbacklist in _savedExceptions:
            # format_exception_only returns a list of string, each
            # terminated whith a newline.  The list has length 1,
            # except for syntax errors.
            errorstrings.extend(
                [line.rstrip() for line in
                 traceback.format_exception_only(e_type, value)])

            if isinstance(value, ooferror.ErrErrorPtr):
                moreinfo = value.details()
                if moreinfo:
                    errorstrings.append(moreinfo)
            errorstrings.append("") # blank line
            if tbacklist:
                self.tracebacks.append(traceback.format_list(tbacklist))

        _savedExceptions = []

        self.answer = None
        
        self.datestampstring = time.strftime("%Y %b %d %H:%M:%S %Z")
        self.gtk = gtklogger.Dialog()
        self.gtk.set_keep_above(True)
        # self.gtk = gtk.Dialog()
        gtklogger.newTopLevelWidget(self.gtk, "Error")
        self.gtk.set_title("%s Error"%subWindow.oofname())

        self.gtk.vbox.set_spacing(3)
        classname = string.split(str(e_type),'.')[-1]
        self.gtk.vbox.pack_start(gtk.Label("ERROR"), expand=0, fill=0)

        self.errframe = gtk.Frame()
        self.errframe.set_border_width(6)
        self.errframe.set_shadow_type(gtk.SHADOW_IN)
        self.gtk.vbox.pack_start(self.errframe, expand=1, fill=1)

        fd = pango.FontDescription(mainmenuGUI.getFixedFont())

        errscroll = gtk.ScrolledWindow()
        gtklogger.logScrollBars(errscroll, "ErrorScroll")
        errscroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.errframe.add(errscroll)
        self.errbox = gtk.TextView()    # error text goes here
        gtklogger.setWidgetName(self.errbox, "ErrorText")
        errscroll.add(self.errbox)
        self.errbox.set_editable(0)
        self.errbox.set_wrap_mode(gtk.WRAP_WORD)
        self.errbox.get_buffer().set_text("\n".join(errorstrings))
        self.errbox.modify_font(fd)

        self.gtk.add_button(gtk.STOCK_OK, self.OK)
        self.gtk.add_button("Abort", self.ABORT)
        self.gtk.set_default_response(self.OK)

        self.tracebutton = gtk.Button("View Traceback")
        gtklogger.setWidgetName(self.tracebutton, "ViewTraceback")
        gtklogger.connect(self.tracebutton, "clicked", self.trace)
        self.gtk.action_area.add(self.tracebutton)

        self.savebutton = gtkutils.StockButton(gtk.STOCK_SAVE, "Save Traceback")
        gtklogger.setWidgetName(self.savebutton, "SaveTraceback")
        gtklogger.connect(self.savebutton, "clicked", self.savetrace)
        self.gtk.action_area.add(self.savebutton)

        self.scroll = gtk.ScrolledWindow()
        gtklogger.logScrollBars(self.scroll, "TraceScroll")
        self.scroll.set_border_width(3)
        self.scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.scroll.set_shadow_type(gtk.SHADOW_IN)
        
        self.tracepane = gtk.TextView()
        self.tracepane.set_editable(0)
        self.tracepane.set_wrap_mode(gtk.WRAP_WORD)
        self.tracepane.modify_font(fd)

        self.traceframe = gtk.Frame()
        self.traceframe.set_shadow_type(gtk.SHADOW_NONE)
        self.gtk.vbox.pack_start(self.traceframe, expand=0, fill=0)

        # Scroll is not added to the frame until the traceback button
        # is pressed.
        self.scroll.add(self.tracepane)

        if self.tracebacks:
            tbtext = ""
            for err, tb in zip(errorstrings, self.tracebacks):
                if tbtext:
                    tbtext += '\n----------\n\n'
                tbtext += err + '\n'
                tbtext += "".join(tb)
            self.tracepane.get_buffer().set_text(tbtext)
            
        else:
            self.savebutton.set_sensitive(0)
            self.tracebutton.set_sensitive(0)

        self.gtk.show_all()
コード例 #22
0
ファイル: pixelPage.py プロジェクト: anilkunwar/OOF2
    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)
            ]
コード例 #23
0
ファイル: analyzePage.py プロジェクト: anilkunwar/OOF2
    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)
            }

        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()
        output_type_selector_box = gtk.HBox()
        output_box.pack_start(output_type_selector_box, expand=0, fill=0)

        self.scalar_output_button = gtk.RadioButton(label="Scalar")
        gtklogger.setWidgetName(self.scalar_output_button, 'ScalarMode')
        self.aggregate_output_button = gtk.RadioButton(
            group=self.scalar_output_button, label="Aggregate")
        gtklogger.setWidgetName(self.aggregate_output_button, 'AggregateMode')
        output_type_selector_box.pack_start(self.scalar_output_button,
                                            expand=0, fill=0)
        output_type_selector_box.pack_start(self.aggregate_output_button,
                                            expand=0, fill=0)
        self.scalarSignal = gtklogger.connect(self.scalar_output_button,
                                              "clicked",
                                              self.scalar_button_CB)

        # Both aggregate and scalar widgets are built here, and they
        # are switched by show/hide.
        ## TODO: Use the ValueOutputWidget here.  In incorporates both
        ## the aggregate and scalar widgets.
        self.scalar_output_button.set_active(1)
        self.scalar_output_obj = outputwidget.ScalarOutputParameterWidget(
            None, scope=self, name="Scalar")
        self.aggregate_output_obj = \
                                  outputwidget.AggregateOutputParameterWidget(
            None, scope=self, name="Aggregate")
        
        self.output_obj = self.scalar_output_obj
        output_box.pack_start(self.scalar_output_obj.gtk, expand=0, fill=0)
        output_box.pack_start(self.aggregate_output_obj.gtk, expand=0, fill=0)
        self.aggregate_output_obj.gtk.hide()
        
        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 = DataOperationFactory(self,
            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(('validity', self.timeWidget),
                                        self.sensitize_widgets)
        switchboard.requestCallbackMain(('validity', self.domain_obj),
                                        self.sensitize_widgets)
        switchboard.requestCallbackMain(('validity', self.op_obj),
                                        self.sensitize_widgets)
        switchboard.requestCallbackMain(('validity', self.scalar_output_obj),
                                        self.sensitize_widgets)
        switchboard.requestCallbackMain(('validity', self.aggregate_output_obj),
                                        self.sensitize_widgets)
        switchboard.requestCallbackMain(('validity', self.destwidget),
                                        self.sensitize_widgets)
        switchboard.requestCallbackMain("named analyses changed",
                                        self.analysesChanged)
        switchboard.requestCallbackMain("retrieve analysis",
                                        self.retrieve_analysis)
        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.scalar_output_obj,
                                        self.setNamedAnalysisChooser)
        switchboard.requestCallbackMain(self.aggregate_output_obj,
                                        self.setNamedAnalysisChooser)
        switchboard.requestCallbackMain(self.sample_obj,
                                        self.setNamedAnalysisChooser)
コード例 #24
0
ファイル: fieldPage.py プロジェクト: anilkunwar/OOF2
    def __init__(self):
        oofGUI.MainPage.__init__(self, name="Fields & Equations", ordering=210,
                                 tip="Define fields on a finite element mesh.")
        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.subpwidget = whowidget.WhoWidget(
            ooflib.engine.subproblemcontext.subproblems, 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)

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

        ## Field Pane
        fieldframe = gtk.Frame("Fields")
        fieldframe.set_shadow_type(gtk.SHADOW_IN)
        hpane.pack1(fieldframe, resize=1, shrink=0)
        vbox = gtk.VBox(spacing=2)
        fieldframe.add(vbox)
        scroll = gtk.ScrolledWindow()
        gtklogger.logScrollBars(scroll, "Fields")
        scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        vbox.pack_start(scroll, expand=1, fill=1)
        bbox = gtk.VBox() # extra layer keeps table from expanding inside scroll
        scroll.add_with_viewport(bbox)
        self.fieldtable = gtk.Table()
        self.fieldtable.set_border_width(3)
        bbox.pack_start(self.fieldtable, expand=0, fill=0)
        self.build_fieldTable()
        align = gtk.Alignment(xalign=0.5)
        vbox.pack_start(align, expand=0, fill=0)
        self.copyfieldbutton = gtk.Button("Copy Field State...")
        gtklogger.setWidgetName(self.copyfieldbutton, 'CopyField')
        gtklogger.connect(self.copyfieldbutton, 'clicked', self.copyfstateCB)
        tooltips.set_tooltip_text(self.copyfieldbutton,
            "Copy all field status variables from the current subproblem to another subproblem.")
        align.add(self.copyfieldbutton)

        ## Equation Pane
        eqnframe = gtk.Frame("Equations")
        eqnframe.set_shadow_type(gtk.SHADOW_IN)
        hpane.pack2(eqnframe, resize=1, shrink=0)
        vbox = gtk.VBox(spacing=2)
        eqnframe.add(vbox)
        scroll = gtk.ScrolledWindow()
        gtklogger.logScrollBars(scroll, "Equations")
        scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        vbox.pack_start(scroll, expand=1, fill=1)
        bbox = gtk.VBox() # extra layer keeps table from expanding inside scroll
        scroll.add_with_viewport(bbox)
        self.eqntable = gtk.Table()
        self.eqntable.set_border_width(3)
        bbox.pack_start(self.eqntable, expand=0, fill=0)
        self.eqnbuttons = {}
        self.build_eqnTable()
        align = gtk.Alignment(xalign=0.5)
        vbox.pack_start(align, expand=0, fill=0)
        self.copyeqnbutton = gtk.Button("Copy Equation State...")
        gtklogger.setWidgetName(self.copyeqnbutton, "CopyEquation")
        gtklogger.connect(self.copyeqnbutton, "clicked", self.copyeqstateCB)
        align.add(self.copyeqnbutton)
        tooltips.set_tooltip_text(self.copyeqnbutton,
            "Copy the status of all equations from the current mesh to another mesh.")

        switchboard.requestCallbackMain(("new who", "Microstructure"),
                                         self.newMSorSkeletonOrMesh)
        switchboard.requestCallbackMain(("new who", "Skeleton"),
                                        self.newMSorSkeletonOrMesh)
        switchboard.requestCallbackMain(("new who", "Mesh"),
                                        self.newMSorSkeletonOrMesh)
        switchboard.requestCallbackMain("made reservation",
                                        self.reservationChanged)
        switchboard.requestCallbackMain("cancelled reservation",
                                        self.reservationChanged)
        switchboard.requestCallbackMain("new field", self.newFieldCB)
        switchboard.requestCallbackMain("field defined", self.defineFldCB)
        switchboard.requestCallbackMain("field activated", self.activateFldCB)
        if config.dimension() == 2:
            switchboard.requestCallbackMain("field inplane", self.inplaneFldCB)
        switchboard.requestCallbackMain("new equation",self.newEquationCB)
        switchboard.requestCallbackMain("equation activated",
                                        self.activateEqnCB)
        switchboard.requestCallbackMain("mesh status changed",
                                        self.meshStatusCB)