예제 #1
0
    def __init__(self, set_callback, ok_callback):
        debug.mainthreadTest()
        self.gtk = gtk.HBox()
        self.set_callback = set_callback
        self.historian = historian.Historian(self.setCB,
                                             self.sensitize)

        # Buttons:  Previous, OK, and next.
        self.prevbutton = gtkutils.prevButton()
        gtklogger.connect(self.prevbutton, "clicked", self.historian.prevCB)
        tooltips.set_tooltip_text(self.prevbutton,
            "Recall the previous selection modification operation.")
        self.gtk.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", ok_callback)
        self.gtk.pack_start(self.okbutton, expand=1, fill=1, padding=2)
        tooltips.set_tooltip_text(self.okbutton,
            "Perform the selection modification operation.")
        self.okbutton.set_sensitive(0)
        
        self.nextbutton = gtkutils.nextButton()
        gtklogger.connect(self.nextbutton, "clicked", self.historian.nextCB)
        tooltips.set_tooltip_text(self.nextbutton,
            "Recall the next selection modification operation.")
        self.gtk.pack_start(self.nextbutton, expand=0, fill=0, padding=2)
예제 #2
0
파일: meshPage.py 프로젝트: santiama/OOF3D
    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)
예제 #3
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)
            ]
예제 #4
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)
            ]
예제 #5
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)
        ]
예제 #6
0
    def __init__(self, name, infotb):
        toolboxGUI.GfxToolbox.__init__(self, name, infotb)
        self.mainbox = gtk.VBox()
        self.gtk.add(self.mainbox)

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

        self.clickIDs = {}

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

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

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

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

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

        firstbutton.set_active(True)

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

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

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

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

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

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

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

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

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

        self.sbcallbacks = [
            switchboard.requestCallback((self.toolbox, "query"), self.queryCB),
            switchboard.requestCallbackMain((self.toolbox, "peek"),
                                            self.peekCB),
            switchboard.requestCallback((self.toolbox, "clear"), self.clearCB)
        ]
예제 #7
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)
            ]
예제 #8
0
파일: meshPage.py 프로젝트: anilkunwar/OOF2
    def __init__(self):
        self.built = False
        oofGUI.MainPage.__init__(self, name="FE Mesh", ordering=200,
                                 tip="Create a Finite Element Mesh from a Skeleton.")
        mainbox = gtk.VBox(spacing=2)
        self.gtk.add(mainbox)

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

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

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

        # Centered box of buttons
        align = gtk.Alignment(xalign=0.5)
        mainbox.pack_start(align, expand=0, fill=0)
        bbox = gtk.HBox(homogeneous=1, spacing=3)
        align.add(bbox)
        self.newbutton = gtkutils.StockButton(gtk.STOCK_NEW, "New...")
        gtklogger.setWidgetName(self.newbutton, 'New')
        gtklogger.connect(self.newbutton, 'clicked', self.newCB)
        tooltips.set_tooltip_text(self.newbutton,"Create a new mesh from the current skeleton.")
        bbox.pack_start(self.newbutton, expand=0, fill=1)
        
        self.renamebutton = gtkutils.StockButton(gtk.STOCK_EDIT, "Rename...")
        gtklogger.setWidgetName(self.renamebutton, 'Rename')
        gtklogger.connect(self.renamebutton, 'clicked', self.renameCB)
        tooltips.set_tooltip_text(self.renamebutton,"Rename the current mesh.")   
        bbox.pack_start(self.renamebutton, expand=0, fill=1)
        
        self.copybutton = gtkutils.StockButton(gtk.STOCK_COPY, "Copy...")
        gtklogger.setWidgetName(self.copybutton, 'Copy')
        gtklogger.connect(self.copybutton, 'clicked', self.copyCB)
        tooltips.set_tooltip_text(self.copybutton,"Copy the current mesh.")
        bbox.pack_start(self.copybutton, expand=0, fill=1)
        
        self.deletebutton = gtkutils.StockButton(gtk.STOCK_DELETE, "Delete")
        gtklogger.setWidgetName(self.deletebutton, 'Delete')
        gtklogger.connect(self.deletebutton, 'clicked', self.deleteCB)
        tooltips.set_tooltip_text(self.deletebutton,"Delete the current mesh.")
        bbox.pack_start(self.deletebutton, expand=0, fill=1)
        
        self.savebutton = gtkutils.StockButton(gtk.STOCK_SAVE, "Save...")
        gtklogger.setWidgetName(self.savebutton, 'Save')
        gtklogger.connect(self.savebutton, 'clicked', self.saveCB)
        tooltips.set_tooltip_text(self.savebutton,
                             "Save the current mesh to a file.")
        bbox.pack_start(self.savebutton, expand=0, fill=1)

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

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

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

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

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

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

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

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

        self.historian = historian.Historian(self.elementops.set,
                                             self.sensitizeHistory,
                                             setCBkwargs={'interactive':1})
        # Prev, OK, Next
        hbox = gtk.HBox()
        elementopsbox.pack_start(hbox, expand=0, fill=0, padding=2)
        self.prevbutton = gtkutils.prevButton()
        gtklogger.connect(self.prevbutton, 'clicked', self.prevCB)
        tooltips.set_tooltip_text(self.prevbutton,
                             "Recall the previous mesh element operation.")
        hbox.pack_start(self.prevbutton, expand=0, fill=0, padding=2)

        self.okbutton = gtk.Button(stock=gtk.STOCK_OK)
        gtklogger.setWidgetName(self.okbutton, 'OK')
        gtklogger.connect(self.okbutton, 'clicked', self.okCB)
        tooltips.set_tooltip_text(self.okbutton,
                          'Perform the mesh operation defined above.')
        hbox.pack_start(self.okbutton, expand=1, fill=1, padding=5)

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

        self.built = True

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

        switchboard.requestCallbackMain(('validity', self.elementops),
                                        self.validityChangeCB)
예제 #9
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
예제 #10
0
    def __init__(self, skeletoninfo):
        toolboxGUI.GfxToolbox.__init__(self, "Skeleton Info", skeletoninfo)
        self.mainbox = gtk.VBox()
        self.gtk.add(self.mainbox)

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

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

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

        self.modebuttons = []
        self.modebuttondict = {}
        for mode in modes:
            if self.modebuttons:
                button = gtk.RadioButton(label=mode.targetname,
                                         group=self.modebuttons[0])
            else:
                button = gtk.RadioButton(label=mode.targetname)
            gtklogger.setWidgetName(button, mode.targetname)
            self.modebuttons.append(button)
            tooltips.set_tooltip_text(
                button, "Show " + mode.targetname + " Information")
            hbox.pack_start(button, expand=0, fill=0)
            button.set_active(self.modeclass is mode)
            gtklogger.connect(button, 'clicked', self.changeModeCB, mode)
            self.modebuttondict[mode.targetname] = button

        # Display mouse click coordinates
        if config.dimension() == 2:
            table = gtk.Table(columns=2, rows=2)
        elif config.dimension() == 3:
            table = gtk.Table(columns=2, rows=3)
        clickbox.pack_start(table, expand=0, fill=0)

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

        self.infoframe = gtk.Frame()
        self.infoframe.set_shadow_type(gtk.SHADOW_NONE)
        self.mainbox.pack_start(self.infoframe, expand=1, fill=1)

        self.buildInfoGUI(self.modeclass)

        # Buttons at the bottom: Prev, Clear, Next
        buttonbox = gtk.HBox()
        self.prev = gtkutils.prevButton()
        gtklogger.connect(self.prev, 'clicked', self.prevQuery)
        tooltips.set_tooltip_text(self.prev, "Go back to the previous object")
        buttonbox.pack_start(self.prev, expand=0, fill=0, padding=2)

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

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

        self.mainbox.pack_start(buttonbox, expand=0, fill=0, padding=2)

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

        self.xposition = None
        self.yposition = None
        if config.dimension() == 3:
            self.zposition = None

        self.sbcallbacks = [
            switchboard.requestCallback(
                (self.toolbox.gfxwindow(), "query skeleton"),
                self.updateQuery),
            switchboard.requestCallback('changed pixel group',
                                        self.grpchanged),
            switchboard.requestCallback('changed pixel groups',
                                        self.grpschngd),
            switchboard.requestCallback('destroy pixel group',
                                        self.grpdestroy),
            switchboard.requestCallback('renamed pixel group',
                                        self.grprenamed),
            switchboard.requestCallback('materials changed in microstructure',
                                        self.matchanged),
            switchboard.requestCallback('materials changed in skeleton',
                                        self.matchangedSkel),
            switchboard.requestCallbackMain((self.toolbox, "new skeleton"),
                                            self.newSkeleton)
        ]
예제 #11
0
    def __init__(self, name, toolbox, method):
        debug.mainthreadTest()
        toolboxGUI.GfxToolbox.__init__(self, name, toolbox)
        self.method = method            # RegisteredClass of selection methods
        self.points = []                # locations of mouse events
        # Was a modifier key pressed during the last button event?
        self.shift = 0                 
        self.ctrl = 0

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

##        scroll = gtk.ScrolledWindow()
##        scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
##        outerbox.pack_start(scroll, expand=1, fill=1)

        # Retrieve the registered class factory from the subclass.
        self.selectionMethodFactory = self.methodFactory()
        # self.selectionMethodFactory = regclassfactory.RegisteredClassFactory(
        #     method.registry, title="Method:", name="Method")
##        scroll.add_with_viewport(self.selectionMethodFactory.gtk)
        outerbox.pack_start(self.selectionMethodFactory.gtk, expand=1, fill=1)
        self.historian = historian.Historian(self.setHistory,
                                             self.sensitizeHistory)
        self.selectionMethodFactory.set_callback(self.historian.stateChangeCB)

        # Undo, Redo, Clear, and Invert buttons.  The callbacks for
        # these have to be defined in the derived classes.
        hbox = gtk.HBox(homogeneous=True, spacing=2)
        outerbox.pack_start(hbox, expand=0, fill=0)
        self.undobutton = gtk.Button(stock=gtk.STOCK_UNDO)
        self.redobutton = gtk.Button(stock=gtk.STOCK_REDO)
        hbox.pack_start(self.undobutton, expand=1, fill=1)
        hbox.pack_start(self.redobutton, expand=1, fill=1)
        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 selection operation.")
        tooltips.set_tooltip_text(self.redobutton,
            "Redo an undone selection operation.")

        self.clearbutton = gtk.Button(stock=gtk.STOCK_CLEAR)
        gtklogger.setWidgetName(self.clearbutton, "Clear")
        hbox.pack_start(self.clearbutton, expand=1, fill=1)
        gtklogger.connect(self.clearbutton, 'clicked', self.clearCB)
        tooltips.set_tooltip_text(self.clearbutton,"Unselect all objects.")

        self.invertbutton = gtk.Button('Invert')
        gtklogger.setWidgetName(self.invertbutton, "Invert")
        hbox.pack_start(self.invertbutton, expand=1, fill=1)
        gtklogger.connect(self.invertbutton, 'clicked', self.invertCB)
        tooltips.set_tooltip_text(self.invertbutton,
            "Select all unselected objects, and deselect all selected objects.")

        # Selection history
        frame = gtk.Frame('History')
        frame.set_shadow_type(gtk.SHADOW_IN)
        outerbox.pack_start(frame, expand=0, fill=0)
        vbox = gtk.VBox()

        frame.add(vbox)
        
        table = gtk.Table(rows=2, columns=3)
        vbox.pack_start(table, expand=0, fill=0)
        table.attach(gtk.Label('down'), 0,1, 0,1, xoptions=0, yoptions=0)
        table.attach(gtk.Label('up'), 0,1, 1,2, xoptions=0, yoptions=0)

        self.xdownentry = gtk.Entry()
        self.ydownentry = gtk.Entry()
        self.xupentry = gtk.Entry()
        self.yupentry = gtk.Entry()
        gtklogger.setWidgetName(self.xdownentry, 'xdown')
        gtklogger.setWidgetName(self.ydownentry, 'ydown')
        gtklogger.setWidgetName(self.xupentry, 'xup')
        gtklogger.setWidgetName(self.yupentry, 'yup') # yessirree, Bob!
        entries = [self.xdownentry, self.ydownentry, self.xupentry, self.yupentry]
        if config.dimension() == 3:
            self.zdownentry = gtk.Entry()  
            self.zupentry = gtk.Entry()
            gtklogger.setWidgetName(self.zdownentry, 'zdown')  
            gtklogger.setWidgetName(self.zdownentry, 'zup')
            entries.append(self.zdownentry)
            entries.append(self.zupentry)
        self.entrychangedsignals = []
        for entry in entries:
            entry.set_size_request(12*guitop.top().digitsize, -1)
            self.entrychangedsignals.append(
                gtklogger.connect(entry, "changed", self.poschanged))
        table.attach(self.xdownentry, 1,2, 0,1)
        table.attach(self.ydownentry, 2,3, 0,1)
        table.attach(self.xupentry, 1,2, 1,2)
        table.attach(self.yupentry, 2,3, 1,2)
        if config.dimension() == 3:
            table.attach(self.zdownentry, 3,4, 0,1)
            table.attach(self.zupentry, 3,4, 1,2)
        hbox = gtk.HBox(spacing=2)
        vbox.pack_start(hbox, expand=0, fill=0)
        self.prevmethodbutton = gtkutils.prevButton()
        self.repeatbutton = gtkutils.StockButton(gtk.STOCK_REFRESH, 'Repeat')
        gtklogger.setWidgetName(self.repeatbutton, 'Repeat')
        self.nextmethodbutton = gtkutils.nextButton()
        hbox.pack_start(self.prevmethodbutton, expand=0, fill=0)
        hbox.pack_start(self.repeatbutton, expand=1, fill=0)
        hbox.pack_start(self.nextmethodbutton, expand=0, fill=0)
        gtklogger.connect(self.repeatbutton, 'clicked', self.repeatCB)
        gtklogger.connect(self.repeatbutton, 'button-release-event',
                          self.repeateventCB)
        gtklogger.connect(self.prevmethodbutton, 'clicked',
                          self.historian.prevCB)
        gtklogger.connect(self.nextmethodbutton, 'clicked',
                         self.historian.nextCB)
        tooltips.set_tooltip_text(self.prevmethodbutton,
            "Recall the settings and mouse coordinates for the previous selection method.")
        tooltips.set_tooltip_text(self.nextmethodbutton,
            "Recall the settings and mouse coordinates for the next selection method.")
        tooltips.set_tooltip_text(self.repeatbutton,
            "Execute the selection method as if the mouse had been clicked at the above coordinates.  Hold the shift key to retain the previous selection.  Hold the control key to toggle the selection state of the selected pixels.")
        

        # Selection information
        hbox = gtk.HBox()
        outerbox.pack_start(hbox, expand=0, fill=0)
        hbox.pack_start(gtk.Label('Selection size: '), expand=0, fill=0)
        self.sizetext = gtk.Entry();
        gtklogger.setWidgetName(self.sizetext, 'size')
        hbox.pack_start(self.sizetext, expand=1, fill=1)
        self.sizetext.set_editable(False)
        self.sizetext.set_size_request(12*guitop.top().digitsize, -1)
        self.setInfo()

        # switchboard callbacks
        self.sbcallbacks = [
            switchboard.requestCallbackMain(method,
                                            self.updateSelectionMethods),
            switchboard.requestCallback((self.toolbox.gfxwindow(),
                                         'layers changed'),
                                        self.setInfo_subthread)
        ]
예제 #12
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()
예제 #13
0
    def __init__(self, skeletoninfo):
        toolboxGUI.GfxToolbox.__init__(self, "Skeleton Info", skeletoninfo)
        self.mainbox = gtk.VBox()
        self.gtk.add(self.mainbox)

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

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

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

        self.modebuttons = []
        self.modebuttondict = {}
        for mode in modes:
            if self.modebuttons:
                button = gtk.RadioButton(label=mode.targetname,
                                        group=self.modebuttons[0])
            else:
                button = gtk.RadioButton(label=mode.targetname)
            gtklogger.setWidgetName(button, mode.targetname)
            self.modebuttons.append(button)
            tooltips.set_tooltip_text(button,
                               "Show " + mode.targetname + " Information")
            hbox.pack_start(button, expand=0, fill=0)
            button.set_active(self.modeclass is mode)
            gtklogger.connect(button, 'clicked', self.changeModeCB, mode)
            self.modebuttondict[mode.targetname] = button

        # Display mouse click coordinates
        if config.dimension() == 2:
            table = gtk.Table(columns=2, rows=2) 
        elif config.dimension() == 3:
            table = gtk.Table(columns=2, rows=3) 
        clickbox.pack_start(table, expand=0, fill=0)

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

        self.infoframe = gtk.Frame()
        self.infoframe.set_shadow_type(gtk.SHADOW_NONE)
        self.mainbox.pack_start(self.infoframe, expand=1, fill=1)
        
        self.buildInfoGUI(self.modeclass)

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

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

        self.mainbox.pack_start(buttonbox, expand=0, fill=0, padding=2)

        self.mainbox.show_all()
        self.sensitize()
        
        self.xposition = None
        self.yposition = None
        if config.dimension() == 3:
            self.zposition = None

        self.sbcallbacks = [
            switchboard.requestCallback((self.toolbox.gfxwindow(),
                                         "query skeleton"),
                                        self.updateQuery),
            switchboard.requestCallback('changed pixel group', self.grpchanged),
            switchboard.requestCallback('changed pixel groups', self.grpschngd),
            switchboard.requestCallback('destroy pixel group', self.grpdestroy),
            switchboard.requestCallback('renamed pixel group', self.grprenamed),
            switchboard.requestCallback('materials changed in microstructure',
                                        self.matchanged),
            switchboard.requestCallback('materials changed in skeleton',
                                        self.matchangedSkel),
            switchboard.requestCallbackMain( (self.toolbox, "new skeleton"),
                                             self.newSkeleton)
            ]
예제 #14
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)
            ]
예제 #15
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)
예제 #16
0
    def __init__(self, meshinfo):
        toolboxGUI.GfxToolbox.__init__(self, "Mesh Info", meshinfo)
        self.mainbox = gtk.VBox()
        self.gtk.add(self.mainbox)

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

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

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

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

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

        # End of clicked point display

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

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

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

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

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

        self.mouse_xposition = None
        self.mouse_yposition = None
        self.mesh_xposition = None
        self.mesh_yposition = None
        if config.dimension() == 3:
            self.mouse_zposition = None
            self.mesh_zposition = None
        
        self.sbcallbacks = [
            switchboard.requestCallbackMain((self.toolbox.gfxwindow(),
                                             "query mesh"),
                                            self.updateQuery),
            switchboard.requestCallbackMain("mesh changed",
                                            self.meshChanged),
            switchboard.requestCallbackMain("mesh data changed",
                                            self.meshDataChanged),
            switchboard.requestCallbackMain("subproblem changed",
                                            self.subproblemChanged),
            switchboard.requestCallbackMain( (self.toolbox, "new layers"),
                                             self.newLayers),
            switchboard.requestCallbackMain( (self.toolbox, "clear"),
                                             self.toolboxClear),
            switchboard.requestCallbackMain((self.toolbox.gfxwindow(),
                                             "time changed"),
                                            self.updateQuery)
            ]
예제 #17
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
예제 #18
0
    def __init__(self, meshinfo):
        toolboxGUI.GfxToolbox.__init__(self, "Mesh Info", meshinfo)
        self.mainbox = gtk.VBox()
        self.gtk.add(self.mainbox)

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

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

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

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

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

        # End of clicked point display

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

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

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

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

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

        self.mouse_xposition = None
        self.mouse_yposition = None
        self.mesh_xposition = None
        self.mesh_yposition = None
        if config.dimension() == 3:
            self.mouse_zposition = None
            self.mesh_zposition = None
        
        self.sbcallbacks = [
            switchboard.requestCallbackMain((self.toolbox.gfxwindow(),
                                             "query mesh"),
                                            self.updateQuery),
            switchboard.requestCallbackMain("mesh changed",
                                            self.meshChanged),
            switchboard.requestCallbackMain("mesh data changed",
                                            self.meshDataChanged),
            switchboard.requestCallbackMain("subproblem changed",
                                            self.subproblemChanged),
            switchboard.requestCallbackMain( (self.toolbox, "new layers"),
                                             self.newLayers),
            switchboard.requestCallbackMain( (self.toolbox, "clear"),
                                             self.toolboxClear),
            switchboard.requestCallbackMain((self.toolbox.gfxwindow(),
                                             "time changed"),
                                            self.updateQuery)
            ]