示例#1
0
    def __init__(self):
        self.built = False
        oofGUI.MainPage.__init__(self, name="Materials", ordering=100,
                                 tip='Define Materials')
        pane = gtk.HPaned()              # Properties on left, Materials on R.
        gtklogger.setWidgetName(pane, 'Pane')
        self.gtk.add(pane)

        self.propertypane = PropertyPane(self)
        self.materialpane = MaterialPane(self)
        pane.pack1(self.propertypane.gtk, resize=0, shrink=0)
        pane.pack2(self.materialpane.gtk, resize=1, shrink=0)
        gtklogger.connect_passive(pane, 'notify::position')

        self.built = True
示例#2
0
    def __init__(self, tree, expand=1, callback=None, name=None,
                 *callbackargs, **callbackkwargs):
        debug.mainthreadTest()
        self.tree = tree                # associated LabelTree
        self.callback = callback
        self.callbackargs = callbackargs
        self.callbackkwargs = callbackkwargs

        self.rccb = None

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

        self.current_selection = None   # a LabelTreeNode

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

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

        self.sbcallbacks = [
            switchboard.requestCallbackMain((tree, "insert"), self.insertCB),
            switchboard.requestCallbackMain((tree, "delete"), self.deleteCB),
            switchboard.requestCallbackMain((tree, "rename"), self.renameCB)
            ]
示例#3
0
def gtkOOFPopUpMenu(menu, basewidget):
    # Create a pop-up menu for an OOFMenu. The basewidget argument
    # can be any existing gtk Widget on the same screen as the pop-up.
    # The pop-up is returned. 

    # Example:
    #  popup = gtkOOFPopUpMenu(oofmenu, basewidget)
    #  gtklogger.connect(basewidget, 'button-press-event', callback)
    #
    #  def callback(gtkobj, event):
    #     if event.button == 3:  # right-click
    #         popup.popup(None, None, None, event.button, event.time)
    #         ## The Nones are some vestigial gtk cruft, apparently.
    debug.mainthreadTest()
    popupmenu = gtk.Menu()
    gtklogger.newTopLevelWidget(popupmenu, 'PopUp-'+menu.name)
    popupmenu.set_screen(basewidget.get_screen())
    gtklogger.connect_passive(popupmenu, 'deactivate')
    for item in menu:
        item.construct_gui(menu, popupmenu, None)
    popupmenu.show_all()
    return popupmenu
示例#4
0
    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)
示例#5
0
    def __init__(self, title, menu=None, callback=None, guiloggable=True):
        debug.mainthreadTest()
        self.gtk = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.gtk.set_title(title)
        if guiloggable:
            gtklogger.newTopLevelWidget(self.gtk, title)
            gtklogger.connect_passive(self.gtk, 'delete-event')
            gtklogger.connect_passive(self.gtk, 'configure-event')
        self.mainbox = gtk.VBox()
        self.gtk.add(self.mainbox)

        # Checking the type is clumsy; the idea is that the caller
        # must provide either the name for the auto-generated menu, or
        # a menu to use instead.  TODO 3.1: It would be cleaner for
        # the Activity Viewer if the SubWindow class could provide the
        # window-specific (i.e "Close" and "Quit") menu items under
        # "File" (creating it, if necessary, and prepending it to the
        # passed-in menu) even when a menu is passed in.  This would
        # prevent duplication of effort by separate subclasses of
        # subwindow.
        if type(menu) == types.StringType:
            # If no menu is provided, then build a non-logging local
            # one with 'Close' and 'Quit'.
            self.subwindow_menu = oofmenu.OOFMenuItem(menu,
                                                      secret=1,
                                                      gui_only=1,
                                                      no_log=1)

            file_item = oofmenu.OOFMenuItem('File', gui_only=1, no_log=1)
            self.subwindow_menu.addItem(file_item)

            file_item.addItem(
                oofmenu.OOFMenuItem('Close',
                                    help="Close this window.",
                                    callback=self.menu_close,
                                    no_log=1,
                                    gui_only=1,
                                    accel='w'))

            file_item.addItem(
                oofmenu.OOFMenuItem('Quit',
                                    gui_callback=quit.queryQuit,
                                    no_log=1,
                                    gui_only=1,
                                    help="Quit the OOF application.",
                                    accel='q',
                                    threadable=oofmenu.UNTHREADABLE))

            mainmenu.OOF.addItem(self.subwindow_menu)
            self._local_menu = menu
        elif isinstance(menu, oofmenu.OOFMenuItem):
            self.subwindow_menu = menu
            self._local_menu = None  # Flag indicating menu was passed in.
        else:
            raise TypeError("Incorrect type passed as menu to SubWindow.")

        # Build the menu bar and add it to the window.
##        self.menu_bar = None
        self.accel_group = gtk.AccelGroup()
        self.gtk.add_accel_group(self.accel_group)
        self.menu_bar = gfxmenu.gtkOOFMenuBar(self.subwindow_menu,
                                              accelgroup=self.accel_group)
        if guiloggable:
            gtklogger.setWidgetName(self.menu_bar, "MenuBar")

        self.mainbox.pack_start(self.menu_bar, fill=0, expand=0)

        # Add the "Windows" menu to the bar.
        self.windows_gtk_menu_item = gfxmenu.gtkOOFMenu(
            mainmenu.OOF.Windows, self.accel_group)
        self.menu_bar.append(self.windows_gtk_menu_item)

        self.menu_bar.connect("destroy", self.menu_bar_destroyed)

        if callback is None:
            callback = self.destroySubWindow
        guitop.top().gtk.connect("destroy", callback)
示例#6
0
    def __init__thread(self, gfxwindow, time, position, output):
        debug.mainthreadTest()
        allMeshDataWindows.append(self)
        widgetscope.WidgetScope.__init__(self, None)

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

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

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

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

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

        expander = gtk.Expander("Source")
        gtklogger.setWidgetName(expander, 'ViewSource')
        gtklogger.connect_passive_after(expander, 'activate')
        self.mainbox.pack_start(expander, expand=0, fill=0)
        expander.set_expanded(1)

        self.table = gtk.Table(rows=config.dimension() + 4, columns=2)
        expander.add(self.table)

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

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

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

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

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

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

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

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

        # Output selection
        label = gtk.Label("Output:")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label,
                          0,
                          1,
                          timerow + 2,
                          timerow + 3,
                          xpadding=3,
                          xoptions=gtk.FILL,
                          yoptions=0)
        tooltips.set_tooltip_text(label, "Choose which data is displayed.")

        self.outputwidget = self.outputparam.makeWidget(scope=self)
        self.table.attach(self.outputwidget.gtk,
                          1,
                          2,
                          timerow + 2,
                          timerow + 3,
                          xpadding=3,
                          xoptions=gtk.EXPAND | gtk.FILL,
                          yoptions=0)
        switchboard.requestCallback(self.outputwidget, self.outputwidgetCB)

        # Data display panel
        hbox = gtk.HBox()
        self.mainbox.pack_start(hbox, expand=1, fill=1, padding=5)
        frame = gtk.Frame("Data")
        gtklogger.setWidgetName(frame, 'Data')
        frame.set_shadow_type(gtk.SHADOW_IN)
        hbox.pack_start(frame, expand=1, fill=1, padding=5)
        # valign keeps the data widget at the top of the frame
        valign = gtk.Alignment(yalign=0.0)
        frame.add(valign)
        # dhbox just provides space between the data widget and the frame
        dhbox = gtk.HBox(spacing=5)
        valign.add(dhbox)
        # databox is where the data widget goes
        self.databox = gtk.VBox()
        dhbox.pack_start(self.databox, expand=1, fill=1, padding=5)
        self.datawidget = None  # set by updateData

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

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

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

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

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

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

        self.gtk.show_all()
示例#7
0
    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()
        gtklogger.setWidgetName(self.infoarea, 'info')
        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)

        # 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)
        innerframe = gtk.Frame()
        innerframe.set_shadow_type(gtk.SHADOW_IN)
        subpbox.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.subprobEditCB)

        # Subproblem name in the column 1
        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)

        # Subproblem consistency in the column 2
        consistencycell = gtk.CellRendererText()
        consistencycol = gtk.TreeViewColumn("Consistent?")
        consistencycol.set_resizable(True)
        consistencycol.pack_start(consistencycell, expand=True)
        consistencycol.set_cell_data_func(consistencycell,
                                          self.renderSubproblemConsistency)
        self.subpListView.append_column(consistencycol)

        # Subproblem type in the column 3
        typecell = gtk.CellRendererText()
        typecol = gtk.TreeViewColumn("Type")
        typecol.set_resizable(True)
        typecol.pack_start(typecell, expand=True)
        typecol.set_cell_data_func(typecell, self.renderSubproblemType)
        self.subpListView.append_column(typecol)

        # Buttons at the bottom of the subproblem pane
        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

        # lastStatus is used to prevent update_info() from being
        # called when a nominal status change hasn't really changed
        # anything.
        self.lastStatus = None

        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)
示例#8
0
    def __init__(self):
        self.built = False
        oofGUI.MainPage.__init__(
            self, name="Skeleton Selection",
            ordering = 135,
            tip = "Manipulate selectable skeleton objects.")

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

        self.skelwidgetbox = gtk.Alignment(xalign=0.5)
        self.mainbox.pack_start(self.skelwidgetbox, expand=0, fill=0)
        centerbox = gtk.HBox(spacing=3)
        self.skelwidgetbox.add(centerbox)
        self.skelwidget = whowidget.WhoWidget(skeletoncontext.skeletonContexts,
                                              scope=self)
        self.skelwidget.verbose = True
        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)

        self.modebox = gtk.Alignment(xalign=0.5)
        gtklogger.setWidgetName(self.modebox, 'Mode')
        self.mainbox.pack_start(self.modebox, expand=0, fill=0)
        centerbox = gtk.HBox(spacing=3)
        self.modebox.add(centerbox)
        label = gtk.Label("Selection Mode:")
        label.set_alignment(1.0, 0.5)
        centerbox.pack_start(label, expand=0, fill=0)

        # Construct buttons for switching between selection modes, and
        # the ModeData objects that contain the mode-specific data and
        # widgets.
        self.modedict = {}
        firstbutton = None
        for mode in skeletonselmodebase.SkeletonSelectionMode.modes:
            name = mode.name
            modedata = self.modedict[name] = ModeData(self, mode)
            if firstbutton:
                button = gtk.RadioButton(label=name+'s', group=firstbutton)
            else:
                button = gtk.RadioButton(label=name+'s')
                firstbutton = button
                self.activemode = modedata
            gtklogger.setWidgetName(button, name)
            modedata.button = button
            tooltips.set_tooltip_text(button,"Select " + name + "s")
            centerbox.pack_start(button, expand=0, fill=0)
            gtklogger.connect(button, 'clicked', self.pickerCB, modedata)
            switchboard.requestCallbackMain(
                modedata.mode.changedselectionsignal,
                self.newSelection, mode=modedata)
            switchboard.requestCallbackMain(
                modedata.mode.modifierappliedsignal,
                self.modifiedSelection, mode=modedata)
        firstbutton.set_active(1)

        self.mainpane = gtk.HPaned()
        gtklogger.setWidgetName(self.mainpane, 'Pane')
        self.mainbox.pack_start(self.mainpane, expand=1, fill=1)
        gtklogger.connect_passive(self.mainpane, 'notify::position')
        
        # Status and Group are on the left side of the page.
        self.leftbox = gtk.VBox(spacing=3)
        self.mainpane.pack1(self.leftbox, resize=1, shrink=0)

        # Status box.
        self.statusframe = gtk.Frame()
        self.leftbox.pack_start(self.statusframe, expand=0, fill=0)
        self.statusframe.set_shadow_type(gtk.SHADOW_IN)
        self.status = gtk.Label()
        gtklogger.setWidgetName(self.status, 'status')
        self.status.set_alignment(0.0, 0.5)
        self.statusframe.add(self.status)

        # Group operations.
        self.groupgui = GroupGUI(self)
        self.leftbox.pack_start(self.groupgui.gtk, expand=1, fill=1)

        # Selection operations on the right side of the page.
        self.selectiongui = SelectionGUI(self)
        self.mainpane.pack2(self.selectiongui.gtk, resize=0, shrink=0)

        switchboard.requestCallbackMain(("new who", "Microstructure"),
                                        self.new_microstructure)
        switchboard.requestCallbackMain(self.skelwidget, self.skelwidgetCB)
        switchboard.requestCallbackMain("materials changed in skeleton",
                                        self.matchangedCB)

        switchboard.requestCallbackMain("made reservation",
                                        self.reservationChanged)
        switchboard.requestCallbackMain("cancelled reservation",
                                        self.reservationChanged)
示例#9
0
    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)
            ]
示例#10
0
    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)
            ]
示例#11
0
    def __init__(self):
        oofGUI.MainPage.__init__(
            self,
            name="Solver",
            ordering=240,
            tip="Find solutions for static and time-dependent problems.")
        mainbox = gtk.VBox(spacing=2)
        self.gtk.add(mainbox)

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

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

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

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

        # Subproblem pane

        ## TODO: 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)
示例#12
0
    def __init__(self, movenodetoolbox):
        debug.mainthreadTest()
        self.downed = 0  # is the mouse button down?
        self.moving = 0  # in the middle of a move
        self.movingnode = None  # node being moved
        # writable should only be set by self.set_writable, which
        # issues a checkpoint.
        self.writable = True  # is the top most Skeleton writable?
        self.mode = "Mouse"
        self.mouselock = lock.Lock()

        toolboxGUI.GfxToolbox.__init__(self, "Move Nodes", movenodetoolbox)
        mainbox = gtk.VBox()
        self.gtk.add(mainbox)

        hbox = gtk.HBox()
        mainbox.pack_start(hbox, expand=0, fill=0)
        gtklogger.setWidgetName(hbox, "MoveWith")
        hbox.pack_start(gtk.Label("Move with: "), expand=0, fill=0)

        modes = [("Mouse", "Click and drag a node to move it."),
                 ("Keyboard",
                  "Select a node, type a position, and click the Move button")]
        self.modebuttons = []
        for mode, tip in modes:
            if self.modebuttons:
                button = gtk.RadioButton(label=mode, group=self.modebuttons[0])
            else:
                button = gtk.RadioButton(label=mode)
            gtklogger.setWidgetName(button, mode)
            self.modebuttons.append(button)
            tooltips.set_tooltip_text(button, tip)
            hbox.pack_start(button, expand=0, fill=0)
            button.set_active(self.mode is mode)
            gtklogger.connect(button, 'clicked', self.changeMode, mode)

        # allow illegal move?
        self.allow_illegal = gtk.CheckButton("Allow illegal moves")
        gtklogger.setWidgetName(self.allow_illegal, "AllowIllegal")
        mainbox.pack_start(self.allow_illegal, expand=0, fill=0, padding=1)
        mainbox.pack_start(gtk.HSeparator(), expand=0, fill=0, padding=3)
        gtklogger.connect(self.allow_illegal, "clicked", self.illegal_status)
        if movenodetoolbox.allow_illegal:
            self.allow_illegal.set_active(1)
        else:
            self.allow_illegal.set_active(0)

        if config.dimension() == 2:
            self.table = gtk.Table(columns=2, rows=6)
            r = 2
        elif config.dimension() == 3:
            self.table = gtk.Table(columns=2, rows=8)
            r = 3
        mainbox.pack_start(self.table, expand=0, fill=0)

        label = gtk.Label('x=')
        label.set_alignment(1.0, 0.5)
        self.table.attach(label, 0, 1, 0, 1, xpadding=5, xoptions=gtk.FILL)
        self.xtext = gtk.Entry()
        gtklogger.setWidgetName(self.xtext, "x")
        self.xsignal = gtklogger.connect_passive(self.xtext, 'changed')
        self.xtext.set_size_request(12 * guitop.top().digitsize, -1)
        self.xtext.set_editable(1)
        self.table.attach(self.xtext,
                          1,
                          2,
                          0,
                          1,
                          xpadding=5,
                          xoptions=gtk.EXPAND | gtk.FILL)
        tooltips.set_tooltip_text(self.xtext, "x position of the mouse")

        label = gtk.Label('y=')
        label.set_alignment(1.0, 0.5)
        self.table.attach(label, 0, 1, 1, 2, xpadding=5, xoptions=gtk.FILL)
        self.ytext = gtk.Entry()
        gtklogger.setWidgetName(self.ytext, 'y')
        self.ysignal = gtklogger.connect_passive(self.ytext, 'changed')
        self.ytext.set_size_request(12 * guitop.top().digitsize, -1)
        self.ytext.set_editable(1)
        self.table.attach(self.ytext,
                          1,
                          2,
                          1,
                          2,
                          xpadding=5,
                          xoptions=gtk.EXPAND | gtk.FILL)
        tooltips.set_tooltip_text(self.ytext, "y position of the mouse")

        if config.dimension() == 3:
            label = gtk.Label('z=')
            label.set_alignment(1.0, 0.5)
            self.table.attach(label, 0, 1, 2, 3, xpadding=5, xoptions=gtk.FILL)
            self.ztext = gtk.Entry()
            gtklogger.setWidgetName(self.ztext, 'z')
            self.zsignal = gtklogger.connect_passive(self.ztext, 'changed')
            self.ztext.set_size_request(12 * guitop.top().digitsize, -1)
            self.ztext.set_editable(1)
            self.table.attach(self.ztext,
                              1,
                              2,
                              2,
                              3,
                              xpadding=5,
                              xoptions=gtk.EXPAND | gtk.FILL)
            tooltips.set_tooltip_text(self.ztext, "z position of the mouse")

        label = gtk.Label("Change in... ")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label,
                          0,
                          1,
                          r,
                          r + 1,
                          xpadding=4,
                          xoptions=gtk.EXPAND | gtk.FILL)

        label = gtk.Label("shape energy=")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label,
                          0,
                          1,
                          r + 1,
                          r + 2,
                          xpadding=5,
                          xoptions=gtk.FILL)
        self.shapetext = gtk.Entry()
        self.shapetext.set_editable(0)
        gtklogger.setWidgetName(self.shapetext, "shape")
        self.shapetext.set_size_request(12 * guitop.top().digitsize, -1)
        self.table.attach(self.shapetext,
                          1,
                          2,
                          r + 1,
                          r + 2,
                          xpadding=5,
                          xoptions=gtk.EXPAND | gtk.FILL)
        tooltips.set_tooltip_text(self.shapetext,
                                  "total change in shape energy")

        label = gtk.Label("homogeneity=")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label,
                          0,
                          1,
                          r + 2,
                          r + 3,
                          xpadding=5,
                          xoptions=gtk.FILL)
        self.homogtext = gtk.Entry()
        self.homogtext.set_editable(0)
        gtklogger.setWidgetName(self.homogtext, "homog")
        self.homogtext.set_size_request(12 * guitop.top().digitsize, -1)
        self.table.attach(self.homogtext,
                          1,
                          2,
                          r + 2,
                          r + 3,
                          xpadding=5,
                          xoptions=gtk.EXPAND | gtk.FILL)
        tooltips.set_tooltip_text(self.homogtext,
                                  "total change in homogeneity")

        mainbox.pack_start(gtk.HSeparator(), expand=0, fill=0, padding=3)
        self.statusText = gtk.Label()
        gtklogger.setWidgetName(self.statusText, "Status")
        mainbox.pack_start(self.statusText, expand=0, fill=0, padding=3)

        bbox = gtk.HBox(homogeneous=1, spacing=2)
        mainbox.pack_end(bbox, expand=0, fill=0, padding=3)
        self.undobutton = gtk.Button(stock=gtk.STOCK_UNDO)
        tooltips.set_tooltip_text(self.undobutton,
                                  "Undo the latest node move.")
        self.movebutton = gtk.Button('Move')
        tooltips.set_tooltip_text(
            self.movebutton,
            "Move the selected node to the specified position.")
        self.redobutton = gtk.Button(stock=gtk.STOCK_REDO)
        tooltips.set_tooltip_text(self.redobutton, "Redo the latest UNDO.")

        gtklogger.setWidgetName(self.undobutton, 'Undo')
        gtklogger.setWidgetName(self.redobutton, 'Redo')
        gtklogger.setWidgetName(self.movebutton, 'Move')
        bbox.pack_start(self.undobutton, expand=1, fill=1)
        bbox.pack_start(self.movebutton, expand=1, fill=1)
        bbox.pack_start(self.redobutton, expand=1, fill=1)
        gtklogger.connect(self.undobutton, 'clicked', self.undoCB)
        gtklogger.connect(self.movebutton, 'clicked', self.moveCB)
        gtklogger.connect(self.redobutton, 'clicked', self.redoCB)

        self.sbcallbacks = [
            switchboard.requestCallbackMain(('who changed', 'Skeleton'),
                                            self.skelChanged),
            switchboard.requestCallbackMain("made reservation",
                                            self.rsrvChanged, 1),
            switchboard.requestCallbackMain("cancelled reservation",
                                            self.rsrvChanged, 0),
            switchboard.requestCallbackMain(("node selected", movenodetoolbox),
                                            self.nodeSelected),
            switchboard.requestCallbackMain(
                ("illegal-move status changed", movenodetoolbox),
                self.illegal_status_changed),
            switchboard.requestCallbackMain(
                ("skeleton changed", movenodetoolbox), self.layersChanged)
        ]
        self.move_info(None, '---', '---', '')
示例#13
0
    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)
示例#14
0
    def buildBottomRow(self, mainbox):
        # Build the bottom row of widgets, containing the named
        # analysis buttons, the Destination chooser, and the Go
        # button.
        # Box along the bottom of the page, containing Named Analyses,
        # Destination, and Go.
        hbox = gtk.HBox()
        hbox.set_homogeneous(True)
        mainbox.pack_start(hbox, expand=0, fill=0, padding=3)

        # Named Analyses
        nameframe = gtk.Frame("Named Analyses")
        gtklogger.setWidgetName(nameframe, 'Name')
        nameframe.set_shadow_type(gtk.SHADOW_IN)
        hbox.pack_start(nameframe, expand=1, fill=1, padding=3)
        namebox = gtk.VBox(spacing=2)
        namebox.set_border_width(1)
        nameframe.add(namebox)

        # The namedOps_button isn't used as a button, really.  It's
        # just a place to click to bring up the menu of named analysis
        # operations.  There isn't room in the frame to make separate
        # buttons for all the operations and still display the name of
        # the current analysis, if any.
        self.namedOps_button = gtk.Button("Create/Delete/etc...")
        gtklogger.setWidgetName(self.namedOps_button, "Operations")
        namebox.pack_start(self.namedOps_button, expand=1, fill=1)
        gtklogger.connect(self.namedOps_button, 'button-press-event',
                          self.namedOpsCB)
        # Construct the menu of operations.
        self.namedOpsPopUp = gtk.Menu()
        gtklogger.newTopLevelWidget(self.namedOpsPopUp, self.menuWidgetName)
        self.namedOpsPopUp.set_screen(self.namedOps_button.get_screen())
        gtklogger.connect_passive(self.namedOpsPopUp, 'deactivate')
        self.namedOpsMenuItems = {}
        for position, (name, callback, tip) in enumerate([
            ('Create', self.createCB, "Create a new named analysis."),
            ('Save', self.savenamedCB, "Save named analysis definitions."),
            ('Delete', self.deleteCB, "Delete a named analysis.")
        ]):
            menuitem = gtk.MenuItem()
            self.namedOpsMenuItems[name] = menuitem
            gtklogger.setWidgetName(menuitem, name)
            label = gtk.Label(name + "...")
            tooltips.set_tooltip_text(label, tip)
            menuitem.add(label)
            self.namedOpsPopUp.insert(menuitem, position)
            gtklogger.connect(menuitem, 'activate', callback)
        self.namedOpsPopUp.show_all()
        # Display the name of the current analysis, if it has one.
        hbox4 = gtk.HBox()
        namebox.pack_start(hbox4, expand=0, fill=0)
        hbox4.pack_start(gtk.Label("Current:"), expand=0, fill=0)
        self.namedAnalysisChooser = chooser.ChooserWidget(
            [], callback=self.retrieveCB, name="Retrieve")
        hbox4.pack_start(self.namedAnalysisChooser.gtk, expand=1, fill=1)

        # reduce no. of calls to setNamedAnalysisChooser
        self.suppressRetrievalLoop = False

        # Destination
        destinationframe = gtk.Frame("Destination")
        destinationframe.set_shadow_type(gtk.SHADOW_IN)
        hbox.pack_start(destinationframe, expand=1, fill=1, padding=3)
        destbox = gtk.HBox()
        destbox.set_border_width(1)
        destinationframe.add(destbox)

        self.destwidget = outputdestinationwidget.TextDestinationWidget(
            name="Destination", framed=False)
        destbox.pack_start(self.destwidget.gtk, expand=1, fill=1, padding=2)

        # Go button
        self.go_button = gtkutils.StockButton(gtk.STOCK_EXECUTE, "Go")
        self.go_button.set_border_width(2)
        gtklogger.setWidgetName(self.go_button, 'Go')
        gtklogger.connect(self.go_button, "clicked", self.go_buttonCB)
        tooltips.set_tooltip_text(self.go_button,
                                  "Send the output to the destination.")
        hbox.pack_start(self.go_button, fill=1, expand=1, padding=2)
示例#15
0
    def __init__(self, title, menu=None, callback=None, guiloggable=True):
        debug.mainthreadTest()
        self.gtk = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.gtk.set_title(title)
        if guiloggable:
            gtklogger.newTopLevelWidget(self.gtk, title)
            gtklogger.connect_passive(self.gtk, 'delete-event')
            gtklogger.connect_passive(self.gtk, 'configure-event')
        self.mainbox = gtk.VBox()
        self.gtk.add(self.mainbox)

        # Checking the type is clumsy; the idea is that the caller
        # must provide either the name for the auto-generated menu, or
        # a menu to use instead.  TODO LATER: It would be cleaner for
        # the Layer Editor and the Activity Viewer if the SubWindow
        # class could provide the window-specific (i.e "Close" and
        # "Quit") menu items under "File" (creating it, if necessary,
        # and prepending it to the passed-in menu) even when a menu is
        # passed in.  This would prevent duplication of effort by
        # separate subclasses of subwindow.
        if type(menu)==types.StringType:
            # If no menu is provided, then build a non-logging local
            # one with 'Close' and 'Quit'.
            self.subwindow_menu = oofmenu.OOFMenuItem(
                menu, secret=1, gui_only=1, no_log=1)

            file_item = oofmenu.OOFMenuItem('File', gui_only=1, no_log=1)
            self.subwindow_menu.addItem(file_item)

            file_item.addItem(oofmenu.OOFMenuItem(
                'Close', help="Close this window.",
                callback=self.menu_close,
                no_log=1, gui_only=1, accel='w'))
            
            file_item.addItem(oofmenu.OOFMenuItem(
                'Quit', gui_callback=quit.queryQuit,
                no_log=1, gui_only=1,
                help="Quit the OOF application.",
                accel='q', threadable = oofmenu.UNTHREADABLE))
                              
            mainmenu.OOF.addItem(self.subwindow_menu)
            self._local_menu = menu
        elif isinstance(menu, oofmenu.OOFMenuItem):
            self.subwindow_menu = menu
            self._local_menu = None # Flag indicating menu was passed in.
        else:
            raise TypeError("Incorrect type passed as menu to SubWindow.")

        # Build the menu bar and add it to the window.
##        self.menu_bar = None
        self.accel_group = gtk.AccelGroup()
        self.gtk.add_accel_group(self.accel_group)
        self.menu_bar = gfxmenu.gtkOOFMenuBar(
            self.subwindow_menu, accelgroup=self.accel_group)
        if guiloggable:
            gtklogger.setWidgetName(self.menu_bar, "MenuBar")

        self.mainbox.pack_start(self.menu_bar, fill=0, expand=0)

        # Add the "Windows" menu to the bar.
        self.windows_gtk_menu_item = gfxmenu.gtkOOFMenu(mainmenu.OOF.Windows,
                                                        self.accel_group)
        self.menu_bar.append(self.windows_gtk_menu_item)

        self.menu_bar.connect("destroy", self.menu_bar_destroyed)
        
        if callback is None:
            callback = self.destroySubWindow
        top().gtk.connect("destroy", callback)
示例#16
0
    def __init__thread(self, gfxwindow, time, position, output):
        debug.mainthreadTest()
        allMeshDataWindows.append(self)
        widgetscope.WidgetScope.__init__(self, None)

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

        
        self.gtk.show_all()
示例#17
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)
        ]
示例#18
0
    def __init__(self):
        oofGUI.MainPage.__init__(self, name="Image", ordering=50,
                                 tip='Manipulate Images')

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        self.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)
            ]
示例#19
0
    def __init__(self):
        oofGUI.MainPage.__init__(
            self, name="Scheduled Output", ordering=235,
            tip="Set output quantities to be computed during time evolution.")
        mainbox = gtk.VBox(spacing=2)
        self.gtk.add(mainbox)

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

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

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

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

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

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

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

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

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

        # The "Enable" column has a check box for each output
        self.enableFrame = gtk.Frame()
        self.enableFrame.set_shadow_type(gtk.SHADOW_IN)
        hpaneL.pack1(self.enableFrame, resize=False, shrink=False)
        vbox = gtk.VBox()
        self.enableFrame.add(vbox)
        self.enableView = gtk.TreeView(self.outputList)
        gtklogger.setWidgetName(self.enableView, "enable")
        vbox.pack_start(self.enableView, expand=True, fill=True)
        self.enablecell = gtk.CellRendererToggle()
        enablecol = gtk.TreeViewColumn("")
        enablecol.set_resizable(False)
        enablecol.pack_start(self.enablecell, expand=False)
        enablecol.set_cell_data_func(self.enablecell, self.renderEnableCell)
        self.enableView.append_column(enablecol)
        gtklogger.adoptGObject(self.enablecell, self.enableView,
                               access_function=gtklogger.findCellRenderer,
                               access_kwargs={'col':0, 'rend':0})
        gtklogger.connect(self.enablecell, 'toggled', self.enableCellCB)
        # Extra space at the bottom of the column.  The other columns
        # have button boxes at the bottom, so this one needs a strut
        # to keep its rows aligned with the others.
        self.enableStrut = gtk.VBox()
        vbox.pack_start(self.enableStrut, expand=False, fill=False)
        
        # The "Output" pane lists the name of each output
        self.outputFrame = gtk.Frame()
        self.outputFrame.set_shadow_type(gtk.SHADOW_IN)
        gtklogger.setWidgetName(self.outputFrame, "Output")
        hpaneL.pack2(self.outputFrame, resize=True, shrink=False)
        outputVBox = gtk.VBox()
        self.outputFrame.add(outputVBox)
        self.outputView = gtk.TreeView(self.outputList)
        gtklogger.setWidgetName(self.outputView, "list")
        outputVBox.pack_start(self.outputView, expand=True, fill=True)
        self.outputHScroll = gtk.HScrollbar()
        outputVBox.pack_start(self.outputHScroll, expand=False, fill=False)
        self.outputView.set_hadjustment(self.outputHScroll.get_adjustment())
        self.outputcell = gtk.CellRendererText()
        outputcol = gtk.TreeViewColumn("Output")
        outputcol.pack_start(self.outputcell, expand=True)
        outputcol.set_cell_data_func(self.outputcell, self.renderOutputCell)
        self.outputView.append_column(outputcol)
        gtklogger.connect(self.outputView, 'row-activated',
                          self.outputDoubleClickCB)
        # Buttons for the Output pane.  The extra VBox is used so that
        # the sizes of the button boxes can be synchronized.
        self.outputBBox = gtk.VBox(homogeneous=True)
        outputVBox.pack_start(self.outputBBox, expand=False, fill=False)
        bbox = gtk.HBox(homogeneous=False)
        self.outputBBox.pack_start(bbox, expand=True, fill=True)
        # New Output
        self.newOutputButton = gtkutils.StockButton(gtk.STOCK_NEW, "New")
        gtklogger.setWidgetName(self.newOutputButton, "New")
        gtklogger.connect(self.newOutputButton, 'clicked', self.newOutputCB)
        bbox.pack_start(self.newOutputButton, expand=True, fill=True)
        tooltips.set_tooltip_text(self.newOutputButton,
                             "Define a new output operation.")
        # Edit Output
        self.editOutputButton = gtkutils.StockButton(gtk.STOCK_EDIT, "Edit")
        gtklogger.setWidgetName(self.editOutputButton, "Edit")
        gtklogger.connect(self.editOutputButton, 'clicked', self.editOutputCB)
        bbox.pack_start(self.editOutputButton, expand=True, fill=True)
        tooltips.set_tooltip_text(self.editOutputButton,
                             "Redefine the selected output operation.")
        # Copy Output
        self.copyOutputButton = gtkutils.StockButton(gtk.STOCK_COPY, "Copy")
        gtklogger.setWidgetName(self.copyOutputButton, "Copy")
        gtklogger.connect(self.copyOutputButton, 'clicked', self.copyOutputCB)
        bbox.pack_start(self.copyOutputButton, expand=True, fill=True)
        tooltips.set_tooltip_text(self.copyOutputButton,
            "Copy the selected output and its schedule and destination.")
        # Second row of buttons
        bbox = gtk.HBox(homogeneous=False)
        self.outputBBox.pack_start(bbox, expand=True, fill=True)
        # Rename Output
        self.renameOutputButton = gtkutils.StockButton(gtk.STOCK_EDIT, "Rename")
        gtklogger.setWidgetName(self.renameOutputButton, "Rename")
        gtklogger.connect(self.renameOutputButton, 'clicked', self.renameCB)
        bbox.pack_start(self.renameOutputButton, expand=True, fill=True)
        tooltips.set_tooltip_text(self.renameOutputButton,
                             "Rename the selected output operation.")
        # Delete Output
        self.deleteOutputButton = gtkutils.StockButton(gtk.STOCK_DELETE, 
                                                       "Delete")
        gtklogger.setWidgetName(self.deleteOutputButton, "Delete")
        gtklogger.connect(self.deleteOutputButton, 'clicked',
                          self.deleteOutputCB)
        tooltips.set_tooltip_text(self.deleteOutputButton,
                             "Delete the selected output operation.")
        bbox.pack_start(self.deleteOutputButton, expand=True, fill=True)
        # Delete all outputs
        self.deleteAllButton = gtkutils.StockButton(gtk.STOCK_DELETE,
                                                    "Delete All")
        gtklogger.setWidgetName(self.deleteAllButton, "DeleteAll")
        gtklogger.connect(self.deleteAllButton, 'clicked', self.deleteAllCB)
        bbox.pack_start(self.deleteAllButton, expand=True, fill=True)
        tooltips.set_tooltip_text(self.deleteAllButton,
                             "Delete all output operations")
        

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

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

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


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

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

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

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

        switchboard.requestCallbackMain("gtk font changed", self.setSizes)
示例#20
0
    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)
示例#21
0
    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)
示例#22
0
    def __init__(self):
        debug.mainthreadTest()
        widgetscope.WidgetScope.__init__(self, None)
        self.gtk = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.gtk.set_title(oofname)
        initial_width, initial_height = map(int, runtimeflags.geometry.split("x"))
        self.gtk.set_default_size(initial_width, initial_height)
        gtklogger.newTopLevelWidget(self.gtk, oofname)
        gtklogger.connect(self.gtk, "delete-event", self.deleteEventCB)
        gtklogger.connect_passive(self.gtk, "configure-event")
        self.gtk.connect("destroy", self.destroyCB)
        guitop.setTop(self)

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

        self.menubar = gtk.MenuBar()
        self.mainbox.pack_start(self.menubar, expand=0, fill=0)
        accelgrp = gtk.AccelGroup()
        self.gtk.add_accel_group(accelgrp)

        self.mainmenu = mainmenu.OOF
        self.oofmenu = gfxmenu.gtkOOFMenuBar(self.mainmenu, bar=self.menubar, accelgroup=accelgrp)
        gtklogger.setWidgetName(self.oofmenu, "MenuBar")
        self.pageChooserFrame = gtk.Frame()
        self.pageChooserFrame.set_shadow_type(gtk.SHADOW_IN)
        self.mainbox.pack_start(self.pageChooserFrame, expand=0, fill=0, padding=2)

        align = gtk.Alignment(xalign=0.5)
        self.pageChooserFrame.add(align)
        chooserBox = gtk.HBox()
        chooserBox.set_border_width(2)
        gtklogger.setWidgetName(chooserBox, "Navigation")
        align.add(chooserBox)

        self.historian = historian.Historian(self.historianCB, self.sensitizeHistory)

        label = gtk.Label("Task: ")
        label.set_alignment(1.0, 0.5)
        chooserBox.pack_start(label, expand=0, fill=0)

        self.prevHistoryButton = gtkutils.StockButton(gtk.STOCK_GOTO_FIRST)
        chooserBox.pack_start(self.prevHistoryButton, expand=0, fill=0, padding=3)
        gtklogger.setWidgetName(self.prevHistoryButton, "PrevHist")
        gtklogger.connect(self.prevHistoryButton, "clicked", self.historian.prevCB)
        tooltips.set_tooltip_text(self.prevHistoryButton, "Go to the chronologically previously page.")

        self.prevPageButton = gtkutils.StockButton(gtk.STOCK_GO_BACK)
        chooserBox.pack_start(self.prevPageButton, expand=0, fill=0, padding=3)
        gtklogger.setWidgetName(self.prevPageButton, "Prev")
        gtklogger.connect(self.prevPageButton, "clicked", self.prevPageCB)
        self.pageChooser = chooser.ChooserWidget([], callback=self.pageChooserCB, name="PageMenu")
        chooserBox.pack_start(self.pageChooser.gtk, expand=0, fill=0)
        self.currentPageName = None

        self.nextPageButton = gtkutils.StockButton(gtk.STOCK_GO_FORWARD)
        chooserBox.pack_start(self.nextPageButton, expand=0, fill=0, padding=3)
        gtklogger.setWidgetName(self.nextPageButton, "Next")
        gtklogger.connect(self.nextPageButton, "clicked", self.nextPageCB)

        self.nextHistoryButton = gtkutils.StockButton(gtk.STOCK_GOTO_LAST)
        chooserBox.pack_start(self.nextHistoryButton, expand=0, fill=0, padding=3)
        gtklogger.setWidgetName(self.nextHistoryButton, "NextHist")
        gtklogger.connect(self.nextHistoryButton, "clicked", self.historian.nextCB)
        tooltips.set_tooltip_text(self.nextHistoryButton, "Go to the chronologically next page.")

        # Find the font size, so widgets can be sized appropriately.
        #  digitsize and charsize are in pixels.

        self.digitsize, self.charsize = gtkutils.widgetFontSizes(self.gtk)

        # Add a GUI callback to the "OOF2" windows item.
        oof2_item = self.mainmenu.Windows.OOF2
        oof2_item.add_gui_callback(self.menu_raise)

        # Frame around main pages.  GUI pages are added and removed
        # from it by installPage().
        self.pageframe = gtk.Frame()
        self.pageframe.set_shadow_type(gtk.SHADOW_IN)
        self.mainbox.pack_start(self.pageframe, expand=1, fill=1)

        # Add pages that may have been created before the main GUI was built.
        for pagename, i in zip(pagenames, range(len(allPages))):
            self.addPage(allPages[pagename], i)
示例#23
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)
            ]
示例#24
0
    def __init__(self):
        self.built = False
        oofGUI.MainPage.__init__(self, name="Active %s"%Spacestring, ordering=71.1,
                                     tip="Modify active %s."%spacestring)

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

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

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

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

        naaframe = gtk.Frame("Named Active %ss"%Spacestring)
        naaframe.set_shadow_type(gtk.SHADOW_IN)
        vbox.pack_start(naaframe, expand=1, fill=1)
        naabox = gtk.VBox()
        naaframe.add(naabox)
        self.aalist = chooser.ScrolledChooserListWidget(
            callback=self.aalistCB, dbcallback=self.aalistCB2,
            name="NamedAreas")
        naabox.pack_start(self.aalist.gtk, expand=1, fill=1, padding=2)
        bbox = gtk.HBox()
        naabox.pack_start(bbox, expand=0, fill=0, padding=2)
        self.storebutton = gtk.Button("Store...")
        bbox.pack_start(self.storebutton, expand=1, fill=0)
        gtklogger.setWidgetName(self.storebutton, "Store")
        gtklogger.connect(self.storebutton, 'clicked', self.storeCB)
        tooltips.set_tooltip_text(self.storebutton,
            "Save the current active %s for future use."%spacestring)
        self.renamebutton = gtk.Button("Rename...")
        bbox.pack_start(self.renamebutton, expand=1, fill=0)
        gtklogger.setWidgetName(self.renamebutton, "Rename")
        gtklogger.connect(self.renamebutton, 'clicked', self.renameCB)
        tooltips.set_tooltip_text(self.renamebutton,
            "Rename the selected saved active %s."%spacestring)
        self.deletebutton = gtk.Button("Delete")
        bbox.pack_start(self.deletebutton, expand=1, fill=0)
        gtklogger.setWidgetName(self.deletebutton, "Delete")
        gtklogger.connect(self.deletebutton, 'clicked', self.deleteCB)
        tooltips.set_tooltip_text(self.deletebutton,
            "Delete the selected saved active %s."%spacestring)
        self.restorebutton = gtk.Button("Restore")
        bbox.pack_start(self.restorebutton, expand=1, fill=0)
        gtklogger.setWidgetName(self.restorebutton, "Restore")
        gtklogger.connect(self.restorebutton, 'clicked', self.restoreCB)
        tooltips.set_tooltip_text(self.restorebutton,
            "Use the selected saved active %s."%spacestring)
        
        # Active area modification methods in the right half of the main pane
        modframe = gtk.Frame("Active %s Modification"%Spacestring)
        gtklogger.setWidgetName(modframe, "Modify")
        modframe.set_shadow_type(gtk.SHADOW_IN)
        mainpane.pack2(modframe, resize=0, shrink=0)
        modbox = gtk.VBox()
        modframe.add(modbox)
##        scroll = gtk.ScrolledWindow()
##        scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
##        modbox.pack_start(scroll, expand=1, fill=1)
        self.activeareaModFactory = regclassfactory.RegisteredClassFactory(
            activeareamod.ActiveAreaModifier.registry, title="Method:",
            scope=self, name="Method")
##        scroll.add_with_viewport(self.activeareaModFactory.gtk)
        modbox.pack_start(self.activeareaModFactory.gtk, expand=1, fill=1)
        self.historian = historian.Historian(self.activeareaModFactory.set,
                                             self.sensitizeHistory,
                                             setCBkwargs={'interactive':1})
        self.activeareaModFactory.set_callback(self.historian.stateChangeCB)

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

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

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

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

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

        self.built = True
示例#25
0
    def __init__(self, viewertoolbox):
        debug.mainthreadTest()

        toolboxGUI.GfxToolbox.__init__(self, "Viewer", viewertoolbox)
        mainbox = gtk.VBox()
        self.gtk.add(mainbox)

        infoframe = gtk.Frame("Position Information")
        infoframe.set_shadow_type(gtk.SHADOW_IN)
        mainbox.pack_start(infoframe, fill=0, expand=0)

        infotable = gtk.Table(columns=3, rows=2)
        infoframe.add(infotable)
        pixellabel = gtk.Label("Pixel: ")
        pixellabel.set_alignment(1.0, 0.5)
        self.pixel_x = gtk.Entry()
        gtklogger.setWidgetName(self.pixel_x, "PixelX")
        self.pixel_x.set_size_request(ndigits * guitop.top().digitsize, -1)
        self.pixel_x.set_editable(0)
        self.pixel_y = gtk.Entry()
        gtklogger.setWidgetName(self.pixel_y, "PixelY")
        self.pixel_y.set_size_request(ndigits * guitop.top().digitsize, -1)
        self.pixel_y.set_editable(0)
        physicallabel = gtk.Label("Physical: ")
        physicallabel.set_alignment(1.0, 0.5)
        self.physical_x = gtk.Entry()
        gtklogger.setWidgetName(self.physical_x, "PhysicalX")
        self.physical_x.set_size_request(ndigits * guitop.top().digitsize, -1)
        self.physical_x.set_editable(0)
        self.physical_y = gtk.Entry()
        gtklogger.setWidgetName(self.physical_y, "PhysicalY")
        self.physical_y.set_size_request(ndigits * guitop.top().digitsize, -1)
        self.physical_y.set_editable(0)
        infotable.attach(pixellabel,
                         0,
                         1,
                         0,
                         1,
                         xpadding=5,
                         ypadding=2,
                         xoptions=0)
        infotable.attach(self.pixel_x,
                         1,
                         2,
                         0,
                         1,
                         xpadding=1,
                         ypadding=2,
                         xoptions=gtk.FILL | gtk.EXPAND)
        infotable.attach(self.pixel_y,
                         2,
                         3,
                         0,
                         1,
                         xpadding=1,
                         ypadding=2,
                         xoptions=gtk.FILL | gtk.EXPAND)
        infotable.attach(physicallabel,
                         0,
                         1,
                         1,
                         2,
                         xpadding=5,
                         ypadding=2,
                         xoptions=0)
        infotable.attach(self.physical_x,
                         1,
                         2,
                         1,
                         2,
                         xpadding=1,
                         ypadding=2,
                         xoptions=gtk.FILL | gtk.EXPAND)
        infotable.attach(self.physical_y,
                         2,
                         3,
                         1,
                         2,
                         xpadding=1,
                         ypadding=2,
                         xoptions=gtk.FILL | gtk.EXPAND)

        zoomframe = gtk.Frame("Zoom")
        gtklogger.setWidgetName(zoomframe, "Zoom")
        zoomframe.set_shadow_type(gtk.SHADOW_IN)
        mainbox.pack_start(zoomframe, fill=0, expand=0)
        zoombox = gtk.VBox()
        zoomframe.add(zoombox)

        buttonrow = gtk.HBox(homogeneous=1, spacing=2)
        zoombox.pack_start(buttonrow, expand=0, fill=1, padding=2)
        inbutton = gtkutils.StockButton(gtk.STOCK_ZOOM_IN, 'In')
        buttonrow.pack_start(inbutton, expand=0, fill=1)
        gtklogger.setWidgetName(inbutton, "In")
        gtklogger.connect(inbutton, 'clicked', self.inCB)
        outbutton = gtkutils.StockButton(gtk.STOCK_ZOOM_OUT, 'Out')
        buttonrow.pack_start(outbutton, expand=0, fill=1)
        gtklogger.setWidgetName(outbutton, "Out")
        gtklogger.connect(outbutton, 'clicked', self.outCB)
        fillbutton = gtkutils.StockButton(gtk.STOCK_ZOOM_FIT, 'Fill')
        buttonrow.pack_start(fillbutton, expand=0, fill=1)
        gtklogger.setWidgetName(fillbutton, "Fill")
        gtklogger.connect(fillbutton, 'clicked', self.fillCB)

        factorrow = gtk.HBox()
        zoombox.pack_start(factorrow, expand=0, fill=0, padding=2)
        factorrow.pack_start(gtk.Label("Zoom Factor: "), expand=0, fill=0)
        self.zoomfactor = gtk.Entry()
        self.zoomfactor.set_editable(1)
        self.zoomfactor.set_size_request(ndigits * guitop.top().digitsize, -1)
        gtklogger.setWidgetName(self.zoomfactor, "Factor")
        self.zfactorsignal = gtklogger.connect_passive(self.zoomfactor,
                                                       "changed")
        factorrow.pack_start(self.zoomfactor, expand=1, fill=1)

        zoombox.pack_start(gtk.HSeparator(), fill=0, expand=0, padding=2)

        label0 = gtk.Label("Shift+Click: Zoom in\nCtrl+Click: Zoom out")
        label0.set_pattern("             _______\n            ________\n")
        label0.set_justify(gtk.JUSTIFY_LEFT)
        zoombox.pack_start(label0, fill=0, expand=0, padding=2)

        align = gtk.Alignment(xalign=0.5)
        mainbox.pack_end(align, expand=0, fill=0, padding=2)
        canvas_info = gtkutils.StockButton(gtk.STOCK_DIALOG_INFO,
                                           "Canvas Info")
        gtklogger.setWidgetName(canvas_info, "Info")
        gtklogger.connect(canvas_info, "clicked", self.canvas_infoCB)
        tooltips.set_tooltip_text(
            canvas_info, "Display canvas information in the message window.")
        align.add(canvas_info)

        self.currentZFactor = self.gfxwindow().zoomFactor()

        switchboard.requestCallbackMain("zoom factor changed", self.zfactorCB)

        # Make sure that the Zoom commands in the graphics windows
        # Settings menu use an up-to-date zoom factor.
        self.gfxwindow().menu.Settings.Zoom.In.add_gui_callback(
            self.wrapMenuZoom)
        self.gfxwindow().menu.Settings.Zoom.Out.add_gui_callback(
            self.wrapMenuZoom)
示例#26
0
    def __init__(self):
        self.built = False
        oofGUI.MainPage.__init__(self,
                                 name="Boundary Analysis",
                                 ordering=271,
                                 tip="Examine the boundaries of the system.")

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        self.built = True

        switchboard.requestCallbackMain(("new who", "Mesh"), self.newmeshCB)
        switchboard.requestCallbackMain(("new who", "Skeleton"),
                                        self.newskelCB)
        switchboard.requestCallbackMain(self.meshwidget, self.meshwidgetCB)
        switchboard.requestCallbackMain("mesh changed", self.meshchangedCB)
        switchboard.requestCallbackMain(self.analysisWidget,
                                        self.analysisWidgetCB)
        switchboard.requestCallbackMain("new boundary created", self.newbdyCB)
        switchboard.requestCallbackMain("boundary removed", self.newbdyCB)
        switchboard.requestCallbackMain("boundary renamed", self.newbdyCB)
        switchboard.requestCallbackMain("named boundary analyses changed",
                                        self.analysesChangedCB)
        switchboard.requestCallbackMain("retrieve boundary analysis",
                                        self.retrieve_analysis)
        switchboard.requestCallbackMain(('validity', self.timeWidget),
                                        self.validityChangeCB)
        switchboard.requestCallbackMain("mesh status changed",
                                        self.meshchangedCB)
示例#27
0
    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)
            ]
示例#28
0
    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)
        ]
示例#29
0
    def __init__(self, parent, mesh=None):
        debug.mainthreadTest()
        self.parent = parent  # Reference to the enclosing BoundaryCondPage.
        self.current_mesh = mesh
        debug.mainthreadTest()
        self.bcliststore = gtk.ListStore(gobject.TYPE_STRING,
                                         gobject.TYPE_PYOBJECT)
        self.sortedlist = gtk.TreeModelSort(self.bcliststore)
        self.gtk = gtk.TreeView(self.sortedlist)
        gtklogger.setWidgetName(self.gtk, "BCList")

        # Enable/disable column
        enablecell = gtk.CellRendererToggle()
        enablecol = gtk.TreeViewColumn("Enable")
        enablecol.pack_start(enablecell, expand=False)
        enablecol.set_cell_data_func(enablecell, self.renderEnableCell)
        self.gtk.append_column(enablecol)
        gtklogger.adoptGObject(enablecell,
                               self.gtk,
                               access_function=gtklogger.findCellRenderer,
                               access_kwargs={
                                   'col': 0,
                                   'rend': 0
                               })
        gtklogger.connect(enablecell, 'toggled', self.enableCellCB)
        ## Click on the column header to sort by Enabled status.
        ## Currently commented out because clicking on a toggle cell
        ## when sorting by Enable may trigger an instant re-sort,
        ## which moves the clicked cell.
        #         gtklogger.adoptGObject(enablecol, self.gtk,
        #                                access_method=gtk.TreeView.get_column,
        #                                access_args=(0,))
        #         gtklogger.connect_passive(enablecol, 'clicked')
        #         enablecol.set_sort_column_id(self.sortByEnableID)
        #         self.sortedlist.set_sort_func(self.sortByEnableID, self.sortByEnableFn)

        # Boundary condition name column
        bcnamecell = gtk.CellRendererText()
        bcnamecol = gtk.TreeViewColumn('Name')
        bcnamecol.pack_start(bcnamecell, expand=False)
        bcnamecol.set_attributes(bcnamecell, text=0)
        self.gtk.append_column(bcnamecol)
        gtklogger.adoptGObject(bcnamecol,
                               self.gtk,
                               access_method=gtk.TreeView.get_column,
                               access_args=(1, ))
        gtklogger.connect_passive(bcnamecol, 'clicked')
        bcnamecol.set_sort_column_id(self.sortByNameID)
        self.sortedlist.set_sort_func(self.sortByNameID, self.sortByNameFn)

        # Boundary name column
        bdycell = gtk.CellRendererText()
        bdycol = gtk.TreeViewColumn('Boundary')
        bdycol.pack_start(bdycell, expand=True)
        bdycol.set_cell_data_func(bdycell, self.renderBdy)
        self.gtk.append_column(bdycol)
        gtklogger.adoptGObject(bdycol,
                               self.gtk,
                               access_method=gtk.TreeView.get_column,
                               access_args=(2, ))
        gtklogger.connect_passive(bdycol, 'clicked')
        bdycol.set_sort_column_id(self.sortByBdyID)
        self.sortedlist.set_sort_func(self.sortByBdyID, self.sortByBdyFn)

        # Boundary condition column
        bccell = gtk.CellRendererText()
        bccol = gtk.TreeViewColumn('Condition')
        bccol.pack_start(bccell, expand=True)
        bccol.set_cell_data_func(bccell, self.renderBC)
        self.gtk.append_column(bccol)

        selection = self.gtk.get_selection()
        gtklogger.adoptGObject(selection,
                               self.gtk,
                               access_method=self.gtk.get_selection)

        self.signals = (gtklogger.connect(selection, 'changed', self.selectCB),
                        gtklogger.connect(self.gtk, 'row-activated',
                                          self.doubleClickCB))

        # Set initial sorting method
        self.lastsortcol = bcnamecol
        self.sortedlist.set_sort_column_id(self.sortByNameID,
                                           gtk.SORT_ASCENDING)
示例#30
0
    def __init__(self):
        oofGUI.MainPage.__init__(self, name="Pin Nodes", ordering=120.1,
                                 tip='Pin and unpin nodes')

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

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

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

        # Pinned nodes status in the left half of the main pane
        pnsframe = gtk.Frame("Pinned Nodes Status")
        pnsframe.set_shadow_type(gtk.SHADOW_IN)
        self.datascroll = gtk.ScrolledWindow()
        gtklogger.logScrollBars(self.datascroll, "StatusScroll")
        pnsframe.add(self.datascroll)
        self.datascroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.psdata = fixedwidthtext.FixedWidthTextView()
        self.psdata.set_editable(False)
        self.psdata.set_wrap_mode(gtk.WRAP_WORD)
        self.psdata.set_cursor_visible(False)
        self.datascroll.add_with_viewport(self.psdata)
        mainpane.pack1(pnsframe, resize=1, shrink=0)
        
        # Pin nodes method
        modframe = gtk.Frame("Pin Nodes Methods")
        gtklogger.setWidgetName(modframe, 'Modify')
        modframe.set_shadow_type(gtk.SHADOW_IN)
        modbox = gtk.VBox()  # will have "methods" and "buttons"
        modframe.add(modbox)
        self.pinModFactory = regclassfactory.RegisteredClassFactory(
            pinnodesmodifier.PinNodesModifier.registry,
            title="Method:", scope=self, name="Method")
        modbox.pack_start(self.pinModFactory.gtk, expand=1, fill=1, padding=2)

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

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

        # Switchboard callbacks
        switchboard.requestCallbackMain(('who changed', 'Skeleton'),
                                        self.changeSkeleton)
        switchboard.requestCallbackMain(('new who', 'Microstructure'),
                                        self.newMS)
        switchboard.requestCallbackMain("new pinned nodes",
                                        self.newNodesPinned)
        switchboard.requestCallbackMain(self.skelwidget,
                                        self.skel_update)
        switchboard.requestCallbackMain("made reservation",
                                        self.reservationChanged)
        switchboard.requestCallbackMain("cancelled reservation",
                                        self.reservationChanged)
示例#31
0
    def __init__(self):
        self.built = False
        oofGUI.MainPage.__init__(self,
                                 name="Active %s" % Spacestring,
                                 ordering=71.1,
                                 tip="Modify active %s." % spacestring)

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

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

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

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

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

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

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

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

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

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

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

        self.built = True
示例#32
0
    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)
            ]
示例#33
0
    def preinitialize(self, name, gfxmanager, clone):
        # preinitialize is called by GfxWindowBase.__init__ on the
        # main thread *before* GhostGfxWindow.__init__ is called.
        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

        # 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')

        # Pane dividing upper pane horizontally into 2 parts.
        self.paned1 = gtk.HPaned()
        gtklogger.setWidgetName(self.paned1, "Pane2")

        # "resize=True" here means that when the window is resized
        # vertically, the canvas and toolboxes will resize, but the
        # layer list won't.  It also makes the layer list compact when
        # the window is first opened.  This is what we want. However,
        # on some systems (those using Unity WM, maybe) the layer list
        # is completely collapsed in the initial window, which is
        # unfriendly but not fatal.  Ubuntu 17.10 doesn't have the
        # problem so it's not going to be fixed.
        self.mainpane.pack1(self.paned1, resize=True)
        gtklogger.connect_passive(self.paned1, 'size-allocate')

        # The toolbox is in the left half of paned1 (ie the left frame of 3)
        toolboxframe = gtk.Frame()
        toolboxframe.set_shadow_type(gtk.SHADOW_IN)
        self.paned1.pack1(toolboxframe, resize=True)
        ## TODO OPT: Does the frame size really need to be logged?  It
        ## should just follow from the pane size.
        gtklogger.setWidgetName(toolboxframe, "ToolboxFrame")
        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 paned1.  The toolbar goes
        # on top of the canvas.
        self.canvasBox = gtk.VBox()
        toolbarFrame = gtk.Frame()
        toolbarFrame.set_shadow_type(gtk.SHADOW_IN)
        self.canvasBox.pack_start(toolbarFrame, expand=0, fill=0, padding=0)
        self.toolbarBox = gtk.VBox()
        toolbarFrame.add(self.toolbarBox)

        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.paned1.pack2(self.canvasBox, resize=True)

        # 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)

        # Handle right-clicks on the layer list.  They pop up the
        # Layer menu.
        gtklogger.connect(self.layerListView, 'button-press-event',
                          self.layerListButtonCB)

        # 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)
示例#34
0
    def __init__(self):
        self.built = False
        oofGUI.MainPage.__init__(self, name="Boundary Analysis",
                                 ordering=271,
                                 tip="Examine the boundaries of the system.")

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        # self.savenamed_button = gtkutils.StockButton(gtk.STOCK_SAVE_AS,
        #                                              'Save...')
        # hbox3.pack_start(self.savenamed_button, expand=1, fill=1)
        # gtklogger.setWidgetName(self.savenamed_button, 'Save')
        # gtklogger.connect(self.savenamed_button, 'clicked', self.savenamedCB)
        # tooltips.set_tooltip_text(self.savenamed_button,
        #                      'Save definitions of named analyses to a file.')
        
        # self.delete_button = gtkutils.StockButton(gtk.STOCK_DELETE, 'Delete...')
        # hbox3.pack_start(self.delete_button, expand=1, fill=1)
        # gtklogger.setWidgetName(self.delete_button, 'Delete')
        # gtklogger.connect(self.delete_button, 'clicked', self.deleteCB)
        # tooltips.set_tooltip_text(self.delete_button,
        #                      "Delete a named analysis operation")
        
        # # Destination
        # destframe = gtk.Frame("Destination")
        # destframe.set_shadow_type(gtk.SHADOW_IN)
        # hbox.pack_start(destframe, expand=1, fill=1, padding=3)
        # destbox = gtk.HBox()
        # destframe.add(destbox)
        # self.destwidget = outputdestinationwidget.TextDestinationWidget(
        #     name="Destination", framed=False)
        # destbox.pack_start(self.destwidget.gtk, expand=1, fill=1, padding=2)
        
        # # Go button
        # self.gobutton = gtkutils.StockButton(gtk.STOCK_EXECUTE, "Go!")
        # gtklogger.setWidgetName(self.gobutton, 'Go')
        # gtklogger.connect(self.gobutton, "clicked", self.goCB)
        # tooltips.set_tooltip_text(self.gobutton,
        #                           "Send the output to the destination.")
        # hbox.pack_end(self.gobutton, expand=1, fill=1, padding=2)

        self.built = True

        switchboard.requestCallbackMain(("new who", "Mesh"), self.newmeshCB)
        switchboard.requestCallbackMain(("new who", "Skeleton"), self.newskelCB)
        switchboard.requestCallbackMain(self.meshwidget, self.meshwidgetCB)
        switchboard.requestCallbackMain("mesh changed", self.meshchangedCB)
        switchboard.requestCallbackMain(self.analysisWidget,
                                        self.analysisWidgetCB)
        switchboard.requestCallbackMain("new boundary created", self.newbdyCB)
        switchboard.requestCallbackMain("boundary removed", self.newbdyCB)
        switchboard.requestCallbackMain("boundary renamed", self.newbdyCB)
        switchboard.requestCallbackMain("named boundary analyses changed",
                                        self.analysesChangedCB)
        switchboard.requestCallbackMain("retrieve boundary analysis",
                                        self.retrieve_analysis)
        switchboard.requestCallbackMain(('validity', self.timeWidget), 
                                        self.validityChangeCB)
        switchboard.requestCallbackMain("mesh status changed",
                                        self.meshchangedCB)
示例#35
0
    def __init__(self, vwrtoolbox):
        debug.mainthreadTest()

        toolboxGUI.GfxToolbox.__init__(self, "Viewer", vwrtoolbox)
        mainbox = gtk.VBox(spacing=3)
        self.gtk.add(mainbox)

        self.historian = historian.Historian(
            setCB=self.restoreHistoricalView,
            sensitizeCB=self.sensitize,
            compareCB=lambda v1, v2: v1.equiv(v2))

        # camera position
        infoExpander = gtk.Expander("Camera Info")
        gtklogger.setWidgetName(infoExpander, "CameraInfo")
        infoFrame = gtk.Frame()
        infoFrame.set_shadow_type(gtk.SHADOW_IN)
        mainbox.pack_start(infoExpander, fill=0, expand=0)
        infoExpander.add(infoFrame)
        infoBox = gtk.VBox(spacing=3)
        infoFrame.add(infoBox)
        positionlabel = gtk.Label("Camera Position:")
        infoBox.pack_start(positionlabel, fill=0, expand=0)
        positiontable = gtk.Table(columns=3, rows=1)
        infoBox.pack_start(positiontable, fill=0, expand=0)
        self.camera_x = gtk.Entry()
        gtklogger.setWidgetName(self.camera_x, "CameraX")
        self.camera_x.set_size_request(ndigits * guitop.top().digitsize, -1)
        self.camera_x.set_editable(0)
        positiontable.attach(self.camera_x, 0, 1, 0, 1)
        self.camera_y = gtk.Entry()
        gtklogger.setWidgetName(self.camera_y, "CameraY")
        self.camera_y.set_size_request(ndigits * guitop.top().digitsize, -1)
        self.camera_y.set_editable(0)
        positiontable.attach(self.camera_y, 1, 2, 0, 1)
        self.camera_z = gtk.Entry()
        gtklogger.setWidgetName(self.camera_z, "CameraZ")
        self.camera_z.set_size_request(ndigits * guitop.top().digitsize, -1)
        self.camera_z.set_editable(0)
        positiontable.attach(self.camera_z, 2, 3, 0, 1)
        focalpointlabel = gtk.Label("Focal Point:")
        infoBox.pack_start(focalpointlabel, fill=0, expand=0)
        focalpointtable = gtk.Table(columns=3, rows=1)
        infoBox.pack_start(focalpointtable, fill=0, expand=0)
        self.fp_x = gtk.Entry()
        gtklogger.setWidgetName(self.fp_x, "FocalX")
        self.fp_x.set_size_request(ndigits * guitop.top().digitsize, -1)
        self.fp_x.set_editable(0)
        focalpointtable.attach(self.fp_x, 0, 1, 0, 1)
        self.fp_y = gtk.Entry()
        gtklogger.setWidgetName(self.fp_y, "FocalY")
        self.fp_y.set_size_request(ndigits * guitop.top().digitsize, -1)
        self.fp_y.set_editable(0)
        focalpointtable.attach(self.fp_y, 1, 2, 0, 1)
        self.fp_z = gtk.Entry()
        gtklogger.setWidgetName(self.fp_z, "FocalZ")
        self.fp_z.set_size_request(ndigits * guitop.top().digitsize, -1)
        self.fp_z.set_editable(0)
        focalpointtable.attach(self.fp_z, 2, 3, 0, 1)
        viewuplabel = gtk.Label("View Up Vector:")
        infoBox.pack_start(viewuplabel, fill=0, expand=0)
        viewuptable = gtk.Table(columns=3, rows=1)
        infoBox.pack_start(viewuptable, fill=0, expand=0)
        self.viewup_x = gtk.Entry()
        gtklogger.setWidgetName(self.viewup_x, "ViewUpX")
        self.viewup_x.set_size_request(ndigits * guitop.top().digitsize, -1)
        self.viewup_x.set_editable(0)
        viewuptable.attach(self.viewup_x, 0, 1, 0, 1)
        self.viewup_y = gtk.Entry()
        gtklogger.setWidgetName(self.viewup_y, "ViewUpY")
        self.viewup_y.set_size_request(ndigits * guitop.top().digitsize, -1)
        self.viewup_y.set_editable(0)
        viewuptable.attach(self.viewup_y, 1, 2, 0, 1)
        self.viewup_z = gtk.Entry()
        gtklogger.setWidgetName(self.viewup_z, "ViewUpZ")
        self.viewup_z.set_size_request(ndigits * guitop.top().digitsize, -1)
        self.viewup_z.set_editable(0)
        viewuptable.attach(self.viewup_z, 2, 3, 0, 1)
        distancetable = gtk.Table(columns=2, rows=1)
        infoBox.pack_start(distancetable, fill=0, expand=0)
        distancelabel = gtk.Label("Distance:")
        distancetable.attach(distancelabel, 0, 1, 0, 1)
        self.distance = gtk.Entry()
        gtklogger.setWidgetName(self.distance, "Distance")
        self.distance.set_size_request(ndigits * guitop.top().digitsize, -1)
        self.distance.set_editable(0)
        distancetable.attach(self.distance, 1, 2, 0, 1)
        angletable = gtk.Table(columns=2, rows=1)
        infoBox.pack_start(angletable, fill=0, expand=0)
        anglelabel = gtk.Label("View Angle:")
        angletable.attach(anglelabel, 0, 1, 0, 1)
        self.viewangle = gtk.Entry()
        gtklogger.setWidgetName(self.viewangle, "ViewAngle")
        self.viewangle.set_size_request(ndigits * guitop.top().digitsize, -1)
        self.viewangle.set_editable(0)
        angletable.attach(self.viewangle, 1, 2, 0, 1)

        # Translation
        transExpander = gtk.Expander("Translate")
        gtklogger.setWidgetName(transExpander, "Translation")
        mainbox.pack_start(transExpander, fill=0, expand=0)
        transFrame = gtk.Frame()
        transFrame.set_shadow_type(gtk.SHADOW_IN)
        transExpander.add(transFrame)
        transBox = gtk.VBox()
        transFrame.add(transBox)
        # dolly
        dollyrow = gtk.HBox(homogeneous=1, spacing=2)
        transBox.pack_start(dollyrow, expand=0, fill=1, padding=2)
        inbutton = gtk.Button('Dolly In')
        gtklogger.setWidgetName(inbutton, 'DollyIn')
        tooltips.set_tooltip_text(
            inbutton, "Translate camera towards focal point by given factor.")
        dollyrow.pack_start(inbutton, expand=0, fill=1)
        gtklogger.connect(inbutton, 'clicked', self.dollyin)
        outbutton = gtk.Button('Dolly Out')
        gtklogger.setWidgetName(outbutton, 'DollyOut')
        tooltips.set_tooltip_text(
            outbutton,
            "Translate camera away from focal point by given factor.")
        dollyrow.pack_start(outbutton, expand=0, fill=1)
        gtklogger.connect(outbutton, 'clicked', self.dollyout)
        fillbutton = gtk.Button('Fill')
        gtklogger.setWidgetName(fillbutton, 'Fill')
        tooltips.set_tooltip_text(
            fillbutton, "Set the camera position so that the image"
            " approximately fills the window.")
        dollyrow.pack_start(fillbutton, expand=0, fill=1)
        gtklogger.connect(fillbutton, 'clicked', self.dollyfill)
        factorrow = gtk.HBox()
        transBox.pack_start(factorrow, expand=0, fill=0, padding=2)
        factorrow.pack_start(gtk.Label("Factor: "), expand=0, fill=0)
        self.dollyfactor = gtk.Entry()
        self.dollyfactor.set_editable(1)
        self.dollyfactor.set_size_request(ndigits * guitop.top().digitsize, -1)
        gtklogger.setWidgetName(self.dollyfactor, "DollyFactor")
        self.dollyfactor.set_text("1.5")
        tooltips.set_tooltip_text(
            self.dollyfactor,
            "Factor by which to multiply distance from camera to focal point.")
        factorrow.pack_start(self.dollyfactor, expand=1, fill=1)

        # track
        trackrow = gtk.HBox(homogeneous=1, spacing=2)
        transBox.pack_start(trackrow, expand=0, fill=1, padding=2)
        horizbutton = gtk.Button('Horizontal')
        tooltips.set_tooltip_text(horizbutton,
                                  "Shift camera and focal point horizontally")
        trackrow.pack_start(horizbutton, expand=0, fill=1)
        gtklogger.connect(horizbutton, 'clicked', self.trackh)
        vertbutton = gtk.Button('Vertical')
        tooltips.set_tooltip_text(vertbutton,
                                  "Shift camera and focal point vertically")
        trackrow.pack_start(vertbutton, expand=0, fill=1)
        gtklogger.connect(vertbutton, 'clicked', self.trackv)
        recenterbutton = gtk.Button('Recenter')
        tooltips.set_tooltip_text(
            recenterbutton, "Recenter the microstructure in the viewport.")
        trackrow.pack_start(recenterbutton, expand=0, fill=1)
        gtklogger.connect(recenterbutton, 'clicked', self.recenter)
        distrow = gtk.HBox()
        transBox.pack_start(distrow, expand=0, fill=0, padding=2)
        distrow.pack_start(gtk.Label("Distance: "), expand=0, fill=0)
        self.trackdist = gtk.Entry()
        self.trackdist.set_editable(1)
        self.trackdist.set_size_request(ndigits * guitop.top().digitsize, -1)
        self.trackdist.set_text("10.0")
        tooltips.set_tooltip_text(
            self.trackdist,
            "Distance by which to track camera, in pixel units.")
        distrow.pack_start(self.trackdist, expand=1, fill=1)

        #rotate
        rotateExpander = gtk.Expander("Rotate")
        rotateFrame = gtk.Frame()
        rotateFrame.set_shadow_type(gtk.SHADOW_IN)
        mainbox.pack_start(rotateExpander, fill=0, expand=0)
        rotateBox = gtk.VBox()
        rotateExpander.add(rotateFrame)
        rotateFrame.add(rotateBox)
        rotrow1 = gtk.HBox(homogeneous=1, spacing=2)
        rotateBox.pack_start(rotrow1, expand=0, fill=1, padding=2)
        rollbutton = gtk.Button('Roll')
        tooltips.set_tooltip_text(rollbutton,
                                  "Rotate about direction of projection.")
        rotrow1.pack_start(rollbutton, expand=0, fill=1)
        gtklogger.connect(rollbutton, 'clicked', self.roll)
        pitchbutton = gtk.Button('Pitch')
        tooltips.set_tooltip_text(
            pitchbutton,
            "Rotate about cross product of direction of projection and"
            " view up vector centered at camera position.")
        rotrow1.pack_start(pitchbutton, expand=0, fill=1)
        gtklogger.connect(pitchbutton, 'clicked', self.pitch)
        yawbutton = gtk.Button('Yaw')
        tooltips.set_tooltip_text(
            yawbutton,
            "Rotate about view up vector centered at camera position.")
        rotrow1.pack_start(yawbutton, expand=0, fill=1)
        gtklogger.connect(yawbutton, 'clicked', self.yaw)
        rotrow2 = gtk.HBox(homogeneous=1, spacing=2)
        rotateBox.pack_start(rotrow2, expand=0, fill=1, padding=2)
        azbutton = gtk.Button('Azimuth')
        tooltips.set_tooltip_text(
            azbutton, "Rotate about view up vector centered at focal point.")
        rotrow2.pack_start(azbutton, expand=0, fill=1)
        gtklogger.connect(azbutton, 'clicked', self.azimuth)
        elbutton = gtk.Button('Elevation')
        tooltips.set_tooltip_text(
            elbutton,
            "Rotate about cross product of direction of projection and"
            " view up vector centered at focal point")
        rotrow2.pack_start(elbutton, expand=0, fill=1)
        gtklogger.connect(elbutton, 'clicked', self.elevation)
        anglerow = gtk.HBox()
        rotateBox.pack_start(anglerow, expand=0, fill=0, padding=2)
        anglerow.pack_start(gtk.Label("Angle: "), expand=0, fill=0)
        self.angle = gtk.Entry()
        self.angle.set_editable(1)
        self.angle.set_size_request(ndigits * guitop.top().digitsize, -1)
        self.angle.set_text("10.0")
        tooltips.set_tooltip_text(self.angle,
                                  "Angle by which to rotate, in degrees.")
        anglerow.pack_start(self.angle, expand=1, fill=1)

        # Zoom
        zoomExpander = gtk.Expander('Zoom')
        gtklogger.setWidgetName(zoomExpander, 'Zoom')
        mainbox.pack_start(zoomExpander, fill=0, expand=0)
        zoomFrame = gtk.Frame()
        zoomFrame.set_shadow_type(gtk.SHADOW_IN)
        zoomExpander.add(zoomFrame)
        zoomBox = gtk.VBox()
        zoomFrame.add(zoomBox)
        buttonbox = gtk.HBox(homogeneous=1, spacing=2)
        zoomBox.pack_start(buttonbox, expand=0, fill=0)
        zoominbutton = gtk.Button('In')
        gtklogger.setWidgetName(zoominbutton, 'In')
        gtklogger.connect(zoominbutton, 'clicked', self.zoomInCB)
        buttonbox.pack_start(zoominbutton, expand=1, fill=1)
        tooltips.set_tooltip_text(
            zoominbutton,
            "Zoom in (decrease the viewing angle) by the given factor.")
        zoomoutbutton = gtk.Button('Out')
        gtklogger.setWidgetName(zoomoutbutton, 'Out')
        gtklogger.connect(zoomoutbutton, 'clicked', self.zoomOutCB)
        buttonbox.pack_start(zoomoutbutton, expand=1, fill=1)
        tooltips.set_tooltip_text(
            zoomoutbutton,
            "Zoom out (increase the viewing angle) by the given factor.")
        zoomfillbutton = gtk.Button('Fill')
        gtklogger.setWidgetName(zoomfillbutton, 'Fill')
        gtklogger.connect(zoomfillbutton, 'clicked', self.zoomFillCB)
        buttonbox.pack_start(zoomfillbutton, expand=1, fill=1)
        tooltips.set_tooltip_text(
            zoomfillbutton,
            "Set the viewing angle so that the image fills the window.")
        zoomrow = gtk.HBox()
        zoomBox.pack_start(zoomrow, expand=0, fill=0)
        zoomrow.pack_start(gtk.Label("Factor: "), expand=0, fill=0)
        self.zoomfactor = gtk.Entry()
        self.zoomfactor.set_text("1.1")
        self.zoomfactor.set_editable(1)
        gtklogger.setWidgetName(self.zoomfactor, "Factor")
        gtklogger.connect_passive(self.zoomfactor, "changed")
        tooltips.set_tooltip_text(
            self.zoomfactor, "Factor by which to multiply the camera angle.")
        zoomrow.pack_start(self.zoomfactor, expand=1, fill=1)

        # Clipping planes
        clippingExpander = gtk.Expander("Clip")
        clippingFrame = gtk.Frame()
        gtklogger.setWidgetName(clippingExpander, "Clipping")
        clippingFrame.set_shadow_type(gtk.SHADOW_IN)
        mainbox.pack_start(clippingExpander, fill=1, expand=1)
        clippingExpander.add(clippingFrame)
        clippingBox = gtk.VBox()
        clippingFrame.add(clippingBox)
        clippingScroll = gtk.ScrolledWindow()
        gtklogger.logScrollBars(clippingScroll, "Scroll")
        clippingScroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        clippingBox.pack_start(clippingScroll, expand=1, fill=1)
        self.clippingList = gtk.ListStore(gobject.TYPE_PYOBJECT,
                                          gobject.TYPE_INT)
        self.clippingListView = gtk.TreeView(self.clippingList)
        gtklogger.setWidgetName(self.clippingListView, "ClippingList")
        clippingScroll.add(self.clippingListView)
        gtklogger.adoptGObject(self.clippingList,
                               self.clippingListView,
                               access_method=self.clippingListView.get_model)
        gtklogger.adoptGObject(
            self.clippingListView.get_selection(),
            self.clippingListView,
            access_method=self.clippingListView.get_selection)
        self.clipSelectSignal = gtklogger.connect(
            self.clippingListView.get_selection(), 'changed',
            self.clipSelectionChangedCB)
        gtklogger.connect(self.clippingListView, 'row-activated',
                          self.editClipCB)
        # A check button that enables or disables a clipping plane
        enablecell = gtk.CellRendererToggle()
        enablecol = gtk.TreeViewColumn("On")
        enablecol.pack_start(enablecell, expand=False)
        enablecol.set_cell_data_func(enablecell, self.renderEnableCell)
        self.clippingListView.append_column(enablecol)
        gtklogger.adoptGObject(enablecell,
                               self.clippingListView,
                               access_function=gtklogger.findCellRenderer,
                               access_kwargs={
                                   'col': 0,
                                   'rend': 0
                               })
        gtklogger.connect(enablecell, 'toggled', self.enableCellCB)
        # A check button for inverting the plane
        flipcell = gtk.CellRendererToggle()
        flipcol = gtk.TreeViewColumn("Flip")
        flipcol.pack_start(flipcell, expand=False)
        flipcol.set_cell_data_func(flipcell, self.renderFlipCell)
        self.clippingListView.append_column(flipcol)
        gtklogger.adoptGObject(flipcell,
                               self.clippingListView,
                               access_function=gtklogger.findCellRenderer,
                               access_kwargs={
                                   'col': 1,
                                   'rend': 0
                               })
        gtklogger.connect(flipcell, 'toggled', self.flipCellCB)
        # The normal to the clipping plane
        normalcell = gtk.CellRendererText()
        normalcol = gtk.TreeViewColumn("Normal")
        normalcol.set_resizable(True)
        normalcol.pack_start(normalcell, expand=True)
        normalcol.set_cell_data_func(normalcell, self.renderNormalCol)
        self.clippingListView.append_column(normalcol)
        # The offset
        offsetcell = gtk.CellRendererText()
        offsetcol = gtk.TreeViewColumn("Offset")
        offsetcol.set_resizable(True)
        offsetcol.pack_start(offsetcell, expand=True)
        offsetcol.set_cell_data_func(offsetcell, self.renderOffsetCol)
        self.clippingListView.append_column(offsetcol)

        # Buttons for operating on clipping planes
        bbox = gtk.HBox()
        bbox.set_homogeneous(True)
        clippingBox.pack_start(bbox, expand=0, fill=0)

        newclipbutton = gtk.Button("New")
        gtklogger.setWidgetName(newclipbutton, "New")
        gtklogger.connect(newclipbutton, 'clicked', self.newClipCB)
        tooltips.set_tooltip_text(newclipbutton, "Add a clipping plane.")
        bbox.pack_start(newclipbutton)

        self.editclipbutton = gtk.Button("Edit")
        gtklogger.setWidgetName(self.editclipbutton, "Edit")
        gtklogger.connect(self.editclipbutton, 'clicked', self.editClipCB)
        tooltips.set_tooltip_text(self.editclipbutton,
                                  "Edit a clipping plane.")
        bbox.pack_start(self.editclipbutton)

        self.delclipbutton = gtk.Button("Delete")
        gtklogger.setWidgetName(self.delclipbutton, "Delete")
        gtklogger.connect(self.delclipbutton, 'clicked', self.delClipCB)
        tooltips.set_tooltip_text(self.delclipbutton,
                                  "Delete a clipping plane.")
        bbox.pack_start(self.delclipbutton)

        # Second row of buttons for clipping plane operations
        bbox = gtk.HBox()
        bbox.set_homogeneous(True)
        clippingBox.pack_start(bbox, expand=0, fill=0)

        self.invclipButton = gtk.CheckButton("Invert All")
        gtklogger.setWidgetName(self.invclipButton, "Invert")
        gtklogger.connect(self.invclipButton, 'clicked', self.invClipCB)
        tooltips.set_tooltip_text(self.invclipButton,
                                  "Invert clipping sense globally")
        bbox.pack_start(self.invclipButton)

        self.suppressButton = gtk.CheckButton("Suppress All")
        gtklogger.setWidgetName(self.suppressButton, "Suppress")
        gtklogger.connect(self.suppressButton, 'clicked', self.suppressCB)
        tooltips.set_tooltip_text(self.suppressButton,
                                  "Suppress all clipping planes.")
        bbox.pack_start(self.suppressButton)

        ## TODO 3.1: Clipping plane operations
        ##   Delete all
        ##   Save/Load?
        ##   Copy to/from other window
        ##   Click & drag editing

        # save and restore
        historyFrame = gtk.Frame("Save and Restore Views")
        historyFrame.set_shadow_type(gtk.SHADOW_IN)
        mainbox.pack_start(historyFrame, fill=0, expand=0)
        viewTable = gtk.Table(columns=2, rows=3)
        historyFrame.add(viewTable)
        align = gtk.Alignment(xalign=0.9, yalign=0.5)
        align.add(gtk.Label("Restore:"))
        viewTable.attach(align, 0, 1, 0, 1)
        self.viewChooser = chooser.ChooserWidget(viewertoolbox.viewNames(),
                                                 callback=self.setViewCB,
                                                 name="viewChooser")
        viewTable.attach(self.viewChooser.gtk, 1, 2, 0, 1)

        saveViewButton = gtk.Button("Save...")
        tooltips.set_tooltip_text(saveViewButton,
                                  "Save the current view settings.")
        gtklogger.setWidgetName(saveViewButton, "Save")
        gtklogger.connect(saveViewButton, 'clicked', self.saveViewCB)
        viewTable.attach(saveViewButton, 0, 1, 1, 2)
        deleteViewButton = gtk.Button("Delete...")
        tooltips.set_tooltip_text(deleteViewButton, "Delete a saved view.")
        gtklogger.setWidgetName(deleteViewButton, "Delete")
        gtklogger.connect(deleteViewButton, 'clicked', self.deleteViewCB)
        viewTable.attach(deleteViewButton, 1, 2, 1, 2)

        self.prevViewButton = gtkutils.prevButton()
        gtklogger.setWidgetName(self.prevViewButton, "Prev")
        gtklogger.connect(self.prevViewButton, 'clicked',
                          self.historian.prevCB)
        tooltips.set_tooltip_text(self.prevViewButton,
                                  "Reinstate the previous view.")
        viewTable.attach(self.prevViewButton, 0, 1, 2, 3)

        self.nextViewButton = gtkutils.nextButton()
        gtklogger.setWidgetName(self.nextViewButton, "Next")
        gtklogger.connect(self.nextViewButton, 'clicked',
                          self.historian.nextCB)
        tooltips.set_tooltip_text(self.nextViewButton,
                                  "Reinstate the next view.")
        viewTable.attach(self.nextViewButton, 1, 2, 2, 3)

        # # position information
        # voxelinfoFrame = gtk.Frame("Voxel Info")
        # voxelinfoFrame.set_shadow_type(gtk.SHADOW_IN)
        # mainbox.pack_start(voxelinfoFrame)
        # voxelinfoBox = gtk.VBox()
        # voxelinfoFrame.add(voxelinfoBox)
        # voxelinfotable = gtk.Table(rows=3,columns=2)
        # voxelinfoBox.pack_start(voxelinfotable, expand=False, fill=False)
        # label = gtk.Label('x=')
        # label.set_alignment(1.0, 0.5)
        # voxelinfotable.attach(label, 0,1, 0,1, xpadding=5, xoptions=gtk.FILL)
        # self.xtext = gtk.Entry()
        # self.xtext.set_size_request(ndigits*guitop.top().digitsize, -1)
        # voxelinfotable.attach(self.xtext, 1,2, 0,1,
        #                   xpadding=5, xoptions=gtk.EXPAND|gtk.FILL)
        # label = gtk.Label('y=')
        # label.set_alignment(1.0, 0.5)
        # voxelinfotable.attach(label, 0,1, 1,2, xpadding=5, xoptions=gtk.FILL)
        # self.ytext = gtk.Entry()
        # self.ytext.set_size_request(ndigits*guitop.top().digitsize, -1)
        # voxelinfotable.attach(self.ytext, 1,2, 1,2,
        #                   xpadding=5, xoptions=gtk.EXPAND|gtk.FILL)
        # label = gtk.Label('z=')
        # label.set_alignment(1.0, 0.5)
        # voxelinfotable.attach(label, 0,1, 2,3, xpadding=5, xoptions=gtk.FILL)
        # self.ztext = gtk.Entry()
        # self.ztext.set_size_request(ndigits*guitop.top().digitsize, -1)
        # voxelinfotable.attach(self.ztext, 1,2, 2,3,
        #                   xpadding=5, xoptions=gtk.EXPAND|gtk.FILL)

        self.sbcallbacks = [
            switchboard.requestCallbackMain("view changed",
                                            self.viewChangedCB),
            switchboard.requestCallbackMain("view restored",
                                            self.viewRestoredCB),
            switchboard.requestCallbackMain("new view", self.newViewCB),
            switchboard.requestCallbackMain("view deleted",
                                            self.viewDeletedCB),
            switchboard.requestCallbackMain("clip planes changed",
                                            self.updateClipList)
        ]

        self.sensitize()
示例#36
0
    def __init__(self, parent, mesh=None):
        debug.mainthreadTest()
        self.parent = parent # Reference to the enclosing BoundaryCondPage.
        self.current_mesh = mesh
        debug.mainthreadTest()
        self.bcliststore = gtk.ListStore(gobject.TYPE_STRING,
                                         gobject.TYPE_PYOBJECT)
        self.sortedlist = gtk.TreeModelSort(self.bcliststore)
        self.gtk = gtk.TreeView(self.sortedlist)
        gtklogger.setWidgetName(self.gtk, "BCList")

        # Enable/disable column
        enablecell = gtk.CellRendererToggle()
        enablecol = gtk.TreeViewColumn("Enable")
        enablecol.pack_start(enablecell, expand=False)
        enablecol.set_cell_data_func(enablecell, self.renderEnableCell)
        self.gtk.append_column(enablecol)
        gtklogger.adoptGObject(enablecell, self.gtk,
                               access_function=gtklogger.findCellRenderer,
                               access_kwargs={'col':0, 'rend':0})
        gtklogger.connect(enablecell, 'toggled', self.enableCellCB)
        ## Click on the column header to sort by Enabled status.
        ## Currently commented out because clicking on a toggle cell
        ## when sorting by Enable may trigger an instant re-sort,
        ## which moves the clicked cell.
#         gtklogger.adoptGObject(enablecol, self.gtk,
#                                access_method=gtk.TreeView.get_column,
#                                access_args=(0,))
#         gtklogger.connect_passive(enablecol, 'clicked')
#         enablecol.set_sort_column_id(self.sortByEnableID)
#         self.sortedlist.set_sort_func(self.sortByEnableID, self.sortByEnableFn)

        # Boundary condition name column
        bcnamecell = gtk.CellRendererText()
        bcnamecol = gtk.TreeViewColumn('Name')
        bcnamecol.pack_start(bcnamecell, expand=False)
        bcnamecol.set_attributes(bcnamecell, text=0)
        self.gtk.append_column(bcnamecol)
        gtklogger.adoptGObject(bcnamecol, self.gtk,
                               access_method=gtk.TreeView.get_column,
                               access_args=(1,))
        gtklogger.connect_passive(bcnamecol, 'clicked')
        bcnamecol.set_sort_column_id(self.sortByNameID)
        self.sortedlist.set_sort_func(self.sortByNameID, self.sortByNameFn)
        
        # Boundary name column
        bdycell = gtk.CellRendererText()
        bdycol = gtk.TreeViewColumn('Boundary')
        bdycol.pack_start(bdycell, expand=True)
        bdycol.set_cell_data_func(bdycell, self.renderBdy)
        self.gtk.append_column(bdycol)
        gtklogger.adoptGObject(bdycol, self.gtk,
                               access_method=gtk.TreeView.get_column,
                               access_args=(2,))
        gtklogger.connect_passive(bdycol, 'clicked')
        bdycol.set_sort_column_id(self.sortByBdyID)
        self.sortedlist.set_sort_func(self.sortByBdyID, self.sortByBdyFn)

        # Boundary condition column
        bccell = gtk.CellRendererText()
        bccol = gtk.TreeViewColumn('Condition')
        bccol.pack_start(bccell, expand=True)
        bccol.set_cell_data_func(bccell, self.renderBC)
        self.gtk.append_column(bccol)

        selection = self.gtk.get_selection()
        gtklogger.adoptGObject(selection, self.gtk,
                               access_method=self.gtk.get_selection)

        self.signals = (
            gtklogger.connect(selection, 'changed', self.selectCB),
            gtklogger.connect(self.gtk, 'row-activated', self.doubleClickCB)
            )

        # Set initial sorting method
        self.lastsortcol = bcnamecol
        self.sortedlist.set_sort_column_id(self.sortByNameID, 
                                           gtk.SORT_ASCENDING)
示例#37
0
    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 3.1: 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)
        ]
示例#38
0
    def __init__(self, viewertoolbox):
        debug.mainthreadTest()

        toolboxGUI.GfxToolbox.__init__(self, "Viewer", viewertoolbox)
        mainbox = gtk.VBox()
        self.gtk.add(mainbox)

        infoframe = gtk.Frame("Position Information")
        infoframe.set_shadow_type(gtk.SHADOW_IN)
        mainbox.pack_start(infoframe, fill=0, expand=0)

        infotable = gtk.Table(columns=3, rows=2)
        infoframe.add(infotable)
        pixellabel = gtk.Label("Pixel: ")
        pixellabel.set_alignment(1.0, 0.5)
        self.pixel_x = gtk.Entry()
        gtklogger.setWidgetName(self.pixel_x, "PixelX")
        self.pixel_x.set_size_request(ndigits*guitop.top().digitsize, -1)
        self.pixel_x.set_editable(0)
        self.pixel_y = gtk.Entry()
        gtklogger.setWidgetName(self.pixel_y, "PixelY")
        self.pixel_y.set_size_request(ndigits*guitop.top().digitsize, -1)
        self.pixel_y.set_editable(0)
        physicallabel = gtk.Label("Physical: ")
        physicallabel.set_alignment(1.0, 0.5)
        self.physical_x = gtk.Entry()
        gtklogger.setWidgetName(self.physical_x, "PhysicalX")
        self.physical_x.set_size_request(ndigits*guitop.top().digitsize, -1)
        self.physical_x.set_editable(0)
        self.physical_y = gtk.Entry()
        gtklogger.setWidgetName(self.physical_y, "PhysicalY")
        self.physical_y.set_size_request(ndigits*guitop.top().digitsize, -1)
        self.physical_y.set_editable(0)
        infotable.attach(pixellabel, 0,1, 0,1, xpadding=5, ypadding=2,
                         xoptions=0)
        infotable.attach(self.pixel_x, 1,2, 0,1, xpadding=1, ypadding=2,
                         xoptions=gtk.FILL|gtk.EXPAND)
        infotable.attach(self.pixel_y, 2,3, 0,1, xpadding=1, ypadding=2,
                         xoptions=gtk.FILL|gtk.EXPAND)
        infotable.attach(physicallabel, 0,1, 1,2, xpadding=5, ypadding=2,
                         xoptions=0)
        infotable.attach(self.physical_x, 1,2, 1,2, xpadding=1, ypadding=2,
                         xoptions=gtk.FILL|gtk.EXPAND)
        infotable.attach(self.physical_y, 2,3, 1,2, xpadding=1, ypadding=2,
                         xoptions=gtk.FILL|gtk.EXPAND)

        zoomframe = gtk.Frame("Zoom")
        gtklogger.setWidgetName(zoomframe, "Zoom")
        zoomframe.set_shadow_type(gtk.SHADOW_IN)
        mainbox.pack_start(zoomframe, fill=0, expand=0)
        zoombox = gtk.VBox()
        zoomframe.add(zoombox)

        buttonrow = gtk.HBox(homogeneous=1, spacing=2)
        zoombox.pack_start(buttonrow, expand=0, fill=1, padding=2)
        inbutton = gtkutils.StockButton(gtk.STOCK_ZOOM_IN, 'In')
        buttonrow.pack_start(inbutton, expand=0, fill=1)
        gtklogger.setWidgetName(inbutton, "In")
        gtklogger.connect(inbutton, 'clicked', self.inCB)
        outbutton = gtkutils.StockButton(gtk.STOCK_ZOOM_OUT, 'Out')
        buttonrow.pack_start(outbutton, expand=0, fill=1)
        gtklogger.setWidgetName(outbutton, "Out")
        gtklogger.connect(outbutton, 'clicked', self.outCB)
        fillbutton = gtkutils.StockButton(gtk.STOCK_ZOOM_FIT, 'Fill')
        buttonrow.pack_start(fillbutton, expand=0, fill=1)
        gtklogger.setWidgetName(fillbutton, "Fill")
        gtklogger.connect(fillbutton, 'clicked', self.fillCB)

        factorrow = gtk.HBox()
        zoombox.pack_start(factorrow, expand=0, fill=0, padding=2)
        factorrow.pack_start(gtk.Label("Zoom Factor: "), expand=0, fill=0)
        self.zoomfactor = gtk.Entry()
        self.zoomfactor.set_editable(1)
        self.zoomfactor.set_size_request(ndigits*guitop.top().digitsize, -1)
        gtklogger.setWidgetName(self.zoomfactor, "Factor")
        self.zfactorsignal = gtklogger.connect_passive(self.zoomfactor,"changed")
        factorrow.pack_start(self.zoomfactor, expand=1, fill=1)

        zoombox.pack_start(gtk.HSeparator(), fill=0, expand=0, padding=2)

        label0 = gtk.Label("Shift+Click: Zoom in\nCtrl+Click: Zoom out")
        label0.set_pattern("             _______\n            ________\n")
        label0.set_justify(gtk.JUSTIFY_LEFT)
        zoombox.pack_start(label0, fill=0, expand=0, padding=2)

        align = gtk.Alignment(xalign=0.5)
        mainbox.pack_end(align, expand=0, fill=0, padding=2)
        canvas_info = gtkutils.StockButton(gtk.STOCK_DIALOG_INFO, "Canvas Info")
        gtklogger.setWidgetName(canvas_info, "Info")
        gtklogger.connect(canvas_info, "clicked", self.canvas_infoCB)
        tooltips.set_tooltip_text(canvas_info,
            "Display canvas information in the message window.")
        align.add(canvas_info)

        self.currentZFactor = self.gfxwindow().zoomFactor()

        switchboard.requestCallbackMain("zoom factor changed",
                                        self.zfactorCB)

        # Make sure that the Zoom commands in the graphics windows
        # Settings menu use an up-to-date zoom factor.
        self.gfxwindow().menu.Settings.Zoom.In.add_gui_callback(
            self.wrapMenuZoom)
        self.gfxwindow().menu.Settings.Zoom.Out.add_gui_callback(
            self.wrapMenuZoom)
示例#39
0
文件: oofGUI.py 项目: creuzige/OOF2
    def __init__(self):
        debug.mainthreadTest()
        widgetscope.WidgetScope.__init__(self, None)
        self.gtk = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.gtk.set_title(oofname)
        initial_width, initial_height = map(int,
                                            runtimeflags.geometry.split('x'))
        self.gtk.set_default_size(initial_width, initial_height)
        gtklogger.newTopLevelWidget(self.gtk, oofname)
        gtklogger.connect(self.gtk, "delete-event", self.deleteEventCB)
        gtklogger.connect_passive(self.gtk, "configure-event")
        self.gtk.connect("destroy", self.destroyCB)
        guitop.setTop(self)

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

        self.menubar = gtk.MenuBar()
        self.mainbox.pack_start(self.menubar, expand=0, fill=0)
        accelgrp = gtk.AccelGroup()
        self.gtk.add_accel_group(accelgrp)

        self.mainmenu = mainmenu.OOF
        self.oofmenu = gfxmenu.gtkOOFMenuBar(self.mainmenu,
                                             bar=self.menubar,
                                             accelgroup=accelgrp)
        gtklogger.setWidgetName(self.oofmenu, "MenuBar")
        self.pageChooserFrame = gtk.Frame()
        self.pageChooserFrame.set_shadow_type(gtk.SHADOW_IN)
        self.mainbox.pack_start(self.pageChooserFrame,
                                expand=0,
                                fill=0,
                                padding=2)

        align = gtk.Alignment(xalign=0.5)
        self.pageChooserFrame.add(align)
        chooserBox = gtk.HBox()
        chooserBox.set_border_width(2)
        gtklogger.setWidgetName(chooserBox, 'Navigation')
        align.add(chooserBox)

        self.historian = historian.Historian(self.historianCB,
                                             self.sensitizeHistory)

        label = gtk.Label('Task: ')
        label.set_alignment(1.0, 0.5)
        chooserBox.pack_start(label, expand=0, fill=0)

        self.prevHistoryButton = gtkutils.StockButton(gtk.STOCK_GOTO_FIRST)
        chooserBox.pack_start(self.prevHistoryButton,
                              expand=0,
                              fill=0,
                              padding=3)
        gtklogger.setWidgetName(self.prevHistoryButton, 'PrevHist')
        gtklogger.connect(self.prevHistoryButton, 'clicked',
                          self.historian.prevCB)
        tooltips.set_tooltip_text(
            self.prevHistoryButton,
            "Go to the chronologically previously page.")

        self.prevPageButton = gtkutils.StockButton(gtk.STOCK_GO_BACK)
        chooserBox.pack_start(self.prevPageButton, expand=0, fill=0, padding=3)
        gtklogger.setWidgetName(self.prevPageButton, 'Prev')
        gtklogger.connect(self.prevPageButton, 'clicked', self.prevPageCB)
        self.pageChooser = chooser.ChooserWidget([],
                                                 callback=self.pageChooserCB,
                                                 name="PageMenu")
        chooserBox.pack_start(self.pageChooser.gtk, expand=0, fill=0)
        self.currentPageName = None

        self.nextPageButton = gtkutils.StockButton(gtk.STOCK_GO_FORWARD)
        chooserBox.pack_start(self.nextPageButton, expand=0, fill=0, padding=3)
        gtklogger.setWidgetName(self.nextPageButton, 'Next')
        gtklogger.connect(self.nextPageButton, 'clicked', self.nextPageCB)

        self.nextHistoryButton = gtkutils.StockButton(gtk.STOCK_GOTO_LAST)
        chooserBox.pack_start(self.nextHistoryButton,
                              expand=0,
                              fill=0,
                              padding=3)
        gtklogger.setWidgetName(self.nextHistoryButton, 'NextHist')
        gtklogger.connect(self.nextHistoryButton, 'clicked',
                          self.historian.nextCB)
        tooltips.set_tooltip_text(self.nextHistoryButton,
                                  "Go to the chronologically next page.")

        # Find the font size, so widgets can be sized appropriately.
        #  digitsize and charsize are in pixels.

        self.digitsize, self.charsize = gtkutils.widgetFontSizes(self.gtk)

        # Add a GUI callback to the "OOF2" windows item.
        oof2_item = self.mainmenu.Windows.OOF2
        oof2_item.add_gui_callback(self.menu_raise)

        # Frame around main pages.  GUI pages are added and removed
        # from it by installPage().
        self.pageframe = gtk.Frame()
        self.pageframe.set_shadow_type(gtk.SHADOW_IN)
        self.mainbox.pack_start(self.pageframe, expand=1, fill=1)

        # Add pages that may have been created before the main GUI was built.
        for pagename, i in zip(pagenames, range(len(allPages))):
            self.addPage(allPages[pagename], i)
示例#40
0
    def __init__(self):
        oofGUI.MainPage.__init__(
            self, name="Solver",
            ordering=240,
            tip="Find solutions for static and time-dependent problems.")
        mainbox = gtk.VBox(spacing=2)
        self.gtk.add(mainbox)

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

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

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

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

        # Subproblem pane

        ## TODO: 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)
示例#41
0
    def __init__(self):
        oofGUI.MainPage.__init__(self,
                                 name="Pin Nodes",
                                 ordering=120.1,
                                 tip='Pin and unpin nodes')

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

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

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

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

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

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

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

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

        # Switchboard callbacks
        switchboard.requestCallbackMain(('who changed', 'Skeleton'),
                                        self.changeSkeleton)
        switchboard.requestCallbackMain(('new who', 'Microstructure'),
                                        self.newMS)
        switchboard.requestCallbackMain("new pinned nodes",
                                        self.newNodesPinned)
        switchboard.requestCallbackMain(self.skelwidget, self.skel_update)
        switchboard.requestCallbackMain("made reservation",
                                        self.reservationChanged)
        switchboard.requestCallbackMain("cancelled reservation",
                                        self.reservationChanged)
示例#42
0
    def __init__(self, movenodetoolbox):
        debug.mainthreadTest()
        self.downed = 0                 # is the mouse button down?
        self.moving = 0                 # in the middle of a move
        self.movingnode = None          # node being moved
        # writable should only be set by self.set_writable, which
        # issues a checkpoint.
        self.writable = True            # is the top most Skeleton writable?
        self.mode = "Mouse"
        self.mouselock = lock.Lock()
        
        toolboxGUI.GfxToolbox.__init__(self, "Move Nodes", movenodetoolbox)
        mainbox = gtk.VBox()
        self.gtk.add(mainbox)

        hbox = gtk.HBox()
        mainbox.pack_start(hbox, expand=0, fill=0)
        gtklogger.setWidgetName(hbox, "MoveWith")
        hbox.pack_start(gtk.Label("Move with: "), expand=0, fill=0)

        modes = [("Mouse", "Click and drag a node to move it."),
                 ("Keyboard",
                  "Select a node, type a position, and click the Move button")
                 ]
        self.modebuttons = []
        for mode, tip in modes:
            if self.modebuttons:
                button = gtk.RadioButton(label=mode,
                                         group=self.modebuttons[0])
            else:
                button = gtk.RadioButton(label=mode)
            gtklogger.setWidgetName(button, mode)
            self.modebuttons.append(button)
            tooltips.set_tooltip_text(button,tip)
            hbox.pack_start(button, expand=0, fill=0)
            button.set_active(self.mode is mode)
            gtklogger.connect(button, 'clicked', self.changeMode, mode)

        # allow illegal move?
        self.allow_illegal = gtk.CheckButton("Allow illegal moves")
        gtklogger.setWidgetName(self.allow_illegal, "AllowIllegal")
        mainbox.pack_start(self.allow_illegal, expand=0, fill=0, padding=1)
        mainbox.pack_start(gtk.HSeparator(), expand=0, fill=0, padding=3)
        gtklogger.connect(self.allow_illegal, "clicked", self.illegal_status)
        if movenodetoolbox.allow_illegal:
            self.allow_illegal.set_active(1)
        else:
            self.allow_illegal.set_active(0)

        if config.dimension() == 2:
            self.table = gtk.Table(columns=2, rows=6)
            r = 2
        elif config.dimension() == 3:
            self.table = gtk.Table(columns=2, rows=8)
            r = 3
        mainbox.pack_start(self.table, expand=0, fill=0)

        label = gtk.Label('x=')
        label.set_alignment(1.0, 0.5)
        self.table.attach(label, 0,1, 0,1, xpadding=5, xoptions=gtk.FILL)
        self.xtext = gtk.Entry()
        gtklogger.setWidgetName(self.xtext, "x")
        self.xsignal = gtklogger.connect_passive(self.xtext, 'changed')
        self.xtext.set_size_request(12*guitop.top().digitsize, -1)
        self.xtext.set_editable(1)
        self.table.attach(self.xtext, 1,2, 0,1,
                          xpadding=5, xoptions=gtk.EXPAND|gtk.FILL)
        tooltips.set_tooltip_text(self.xtext,"x position of the mouse")

        label = gtk.Label('y=')
        label.set_alignment(1.0, 0.5)
        self.table.attach(label, 0,1, 1,2, xpadding=5, xoptions=gtk.FILL)
        self.ytext = gtk.Entry()
        gtklogger.setWidgetName(self.ytext, 'y')
        self.ysignal = gtklogger.connect_passive(self.ytext, 'changed')
        self.ytext.set_size_request(12*guitop.top().digitsize, -1)        
        self.ytext.set_editable(1)
        self.table.attach(self.ytext, 1,2, 1,2,
                          xpadding=5, xoptions=gtk.EXPAND|gtk.FILL)
        tooltips.set_tooltip_text(self.ytext,"y position of the mouse")

        if config.dimension() == 3:
            label = gtk.Label('z=')
            label.set_alignment(1.0, 0.5)
            self.table.attach(label, 0,1, 2,3, xpadding=5, xoptions=gtk.FILL)
            self.ztext = gtk.Entry()
            gtklogger.setWidgetName(self.ztext, 'z')
            self.zsignal = gtklogger.connect_passive(self.ztext, 'changed')
            self.ztext.set_size_request(12*guitop.top().digitsize, -1)        
            self.ztext.set_editable(1)
            self.table.attach(self.ztext, 1,2, 2,3,
                              xpadding=5, xoptions=gtk.EXPAND|gtk.FILL)
            tooltips.set_tooltip_text(self.ztext,"z position of the mouse")
        
        label = gtk.Label("Change in... ")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label, 0,1, r,r+1, xpadding=4,
                          xoptions=gtk.EXPAND|gtk.FILL)

        label = gtk.Label("shape energy=")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label, 0,1, r+1,r+2, xpadding=5, xoptions=gtk.FILL)
        self.shapetext = gtk.Entry()
        self.shapetext.set_editable(0)
        gtklogger.setWidgetName(self.shapetext,"shape")
        self.shapetext.set_size_request(12*guitop.top().digitsize, -1)        
        self.table.attach(self.shapetext, 1,2, r+1,r+2,
                          xpadding=5, xoptions=gtk.EXPAND|gtk.FILL)
        tooltips.set_tooltip_text(self.shapetext,"total change in shape energy")

        label = gtk.Label("homogeneity=")
        label.set_alignment(1.0, 0.5)
        self.table.attach(label, 0,1, r+2,r+3, xpadding=5, xoptions=gtk.FILL)
        self.homogtext = gtk.Entry()
        self.homogtext.set_editable(0)
        gtklogger.setWidgetName(self.homogtext,"homog")
        self.homogtext.set_size_request(12*guitop.top().digitsize, -1)        
        self.table.attach(self.homogtext, 1,2, r+2,r+3,
                          xpadding=5, xoptions=gtk.EXPAND|gtk.FILL)
        tooltips.set_tooltip_text(self.homogtext,"total change in homogeneity")

        mainbox.pack_start(gtk.HSeparator(), expand=0, fill=0, padding=3)
        self.statusText = gtk.Label()
        gtklogger.setWidgetName(self.statusText, "Status")
        mainbox.pack_start(self.statusText, expand=0, fill=0, padding=3)
        
        bbox = gtk.HBox(homogeneous=1, spacing=2)
        mainbox.pack_end(bbox, expand=0, fill=0, padding=3)
        self.undobutton = gtk.Button(stock=gtk.STOCK_UNDO)
        tooltips.set_tooltip_text(self.undobutton,"Undo the latest node move.")
        self.movebutton = gtk.Button('Move')
        tooltips.set_tooltip_text(self.movebutton,
                             "Move the selected node to the specified position.")
        self.redobutton = gtk.Button(stock=gtk.STOCK_REDO)
        tooltips.set_tooltip_text(self.redobutton,"Redo the latest UNDO.")

        gtklogger.setWidgetName(self.undobutton, 'Undo')
        gtklogger.setWidgetName(self.redobutton, 'Redo')
        gtklogger.setWidgetName(self.movebutton, 'Move')
        bbox.pack_start(self.undobutton, expand=1, fill=1)
        bbox.pack_start(self.movebutton, expand=1, fill=1)
        bbox.pack_start(self.redobutton, expand=1, fill=1)
        gtklogger.connect(self.undobutton, 'clicked', self.undoCB)
        gtklogger.connect(self.movebutton, 'clicked', self.moveCB)
        gtklogger.connect(self.redobutton, 'clicked', self.redoCB)

        self.sbcallbacks = [
            switchboard.requestCallbackMain(('who changed', 'Skeleton'),
                                            self.skelChanged),
            switchboard.requestCallbackMain("made reservation",
                                            self.rsrvChanged,
                                            1),
            switchboard.requestCallbackMain("cancelled reservation",
                                            self.rsrvChanged, 0),
            switchboard.requestCallbackMain(("node selected",
                                             movenodetoolbox),
                                            self.nodeSelected),
            switchboard.requestCallbackMain(("illegal-move status changed",
                                             movenodetoolbox),
                                            self.illegal_status_changed),
            switchboard.requestCallbackMain(("skeleton changed", 
                                             movenodetoolbox),
                                            self.layersChanged)
            ]
        self.move_info(None, '---', '---', '')
示例#43
0
    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)
        self.selectionModFactory = regclassfactory.RegisteredClassFactory(
            pixelselection.VoxelSelectionModifier.registry,
            title="Method:",
            scope=self,
            name="Method")
        vbox.pack_start(self.selectionModFactory.gtk, expand=1, fill=1)
        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, Clear, and Invert 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.invertbutton = gtk.Button('Invert')
        hbox.pack_start(self.invertbutton, expand=1, fill=0)
        gtklogger.setWidgetName(self.invertbutton, "Invert")
        gtklogger.connect(self.invertbutton, 'clicked', self.invertCB)
        tooltips.set_tooltip_text(self.invertbutton,
                                  "Toggle the current selection.")

        self.sbcallbacks = [
            switchboard.requestCallbackMain(self.mswidget, self.mswidgetCB),
            switchboard.requestCallbackMain('pixel selection changed',
                                            self.selectionChanged),
            switchboard.requestCallbackMain(
                pixelselection.VoxelSelectionModifier,
                self.updateSelectionModifiers),
            switchboard.requestCallbackMain("voxel selection modifier applied",
                                            self.recordModifier),
            switchboard.requestCallbackMain(
                ('validity', self.selectionModFactory), self.validityChangeCB),
            switchboard.requestCallbackMain("made reservation",
                                            self.reservationCB),
            switchboard.requestCallbackMain("cancelled reservation",
                                            self.reservationCB)
        ]

        self.updatePSInfo()
        self.sensitize()
        self.sensitizeHistory()
示例#44
0
    def buildBottomRow(self, mainbox):
        # Build the bottom row of widgets, containing the named
        # analysis buttons, the Destination chooser, and the Go
        # button.
        # Box along the bottom of the page, containing Named Analyses,
        # Destination, and Go.
        hbox = gtk.HBox()
        hbox.set_homogeneous(True)
        mainbox.pack_start(hbox, expand=0, fill=0, padding=3)

        # Named Analyses
        nameframe = gtk.Frame("Named Analyses")
        gtklogger.setWidgetName(nameframe, 'Name')
        nameframe.set_shadow_type(gtk.SHADOW_IN)
        hbox.pack_start(nameframe, expand=1, fill=1, padding=3)
        namebox = gtk.VBox(spacing=2)
        namebox.set_border_width(1)
        nameframe.add(namebox)
        
        # The namedOps_button isn't used as a button, really.  It's
        # just a place to click to bring up the menu of named analysis
        # operations.  There isn't room in the frame to make separate
        # buttons for all the operations and still display the name of
        # the current analysis, if any.
        self.namedOps_button = gtk.Button("Create/Delete/etc...")
        gtklogger.setWidgetName(self.namedOps_button, "Operations")
        namebox.pack_start(self.namedOps_button, expand=1, fill=1)
        gtklogger.connect(self.namedOps_button, 'button-press-event', 
                          self.namedOpsCB)
        # Construct the menu of operations.
        self.namedOpsPopUp = gtk.Menu()
        gtklogger.newTopLevelWidget(self.namedOpsPopUp, self.menuWidgetName)
        self.namedOpsPopUp.set_screen(self.namedOps_button.get_screen())
        gtklogger.connect_passive(self.namedOpsPopUp, 'deactivate')
        self.namedOpsMenuItems = {}
        for position, (name, callback, tip) in enumerate([
                ('Create', self.createCB, "Create a new named analysis."),
                ('Save', self.savenamedCB, "Save named analysis definitions."),
                ('Delete', self.deleteCB, "Delete a named analysis.")]):
            menuitem = gtk.MenuItem()
            self.namedOpsMenuItems[name] = menuitem
            gtklogger.setWidgetName(menuitem, name)
            label = gtk.Label(name + "...")
            tooltips.set_tooltip_text(label, tip)
            menuitem.add(label)
            self.namedOpsPopUp.insert(menuitem, position)
            gtklogger.connect(menuitem, 'activate', callback)
        self.namedOpsPopUp.show_all()
        # Display the name of the current analysis, if it has one.
        hbox4 = gtk.HBox()
        namebox.pack_start(hbox4, expand=0, fill=0)
        hbox4.pack_start(gtk.Label("Current:"), expand=0, fill=0)
        self.namedAnalysisChooser = chooser.ChooserWidget(
            [], callback=self.retrieveCB, name="Retrieve")
        hbox4.pack_start(self.namedAnalysisChooser.gtk, expand=1, fill=1)

        # reduce no. of calls to setNamedAnalysisChooser
        self.suppressRetrievalLoop = False

        # Destination
        destinationframe = gtk.Frame("Destination")
        destinationframe.set_shadow_type(gtk.SHADOW_IN)
        hbox.pack_start(destinationframe, expand=1, fill=1, padding=3)
        destbox = gtk.HBox()
        destbox.set_border_width(1)
        destinationframe.add(destbox)

        self.destwidget = outputdestinationwidget.TextDestinationWidget(
            name="Destination", framed=False)
        destbox.pack_start(self.destwidget.gtk, expand=1, fill=1, padding=2)
        
        # Go button
        self.go_button = gtkutils.StockButton(gtk.STOCK_EXECUTE, "Go")
        self.go_button.set_border_width(2)
        gtklogger.setWidgetName(self.go_button, 'Go')
        gtklogger.connect(self.go_button, "clicked", self.go_buttonCB)
        tooltips.set_tooltip_text(self.go_button,
                             "Send the output to the destination.")
        hbox.pack_start(self.go_button, fill=1, expand=1, padding=2)
示例#45
0
    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)