def __init__(self, color, linewidth, glyphsize, resolution): SkeletonBdyDisplayBase.__init__(self, color, linewidth, glyphsize, resolution) self.sbcallbacks.extend([ switchboard.requestCallback("boundary selected", self.bdySelectedCB), switchboard.requestCallback("boundary unselected", self.bdyUnselectedCB)])
def __init__(self, no_material, no_color, opacity, filter): self.no_material = no_material # color if Material isn't assigned self.no_color = no_color # color if Material has no ColorProperty bitmapdisplay.BitmapDisplayMethod.__init__(self, filter, opacity) self.matChangedSignals = [ switchboard.requestCallback("materials changed in microstructure", self.matMSChangedCB), switchboard.requestCallback("material changed", self.matChangedCB) ]
def __init__(self, filter, opacity): self.filter = filter self.autoOpacityFactor = 1.0 self.opacity = opacity self.sbcallbacks = [ switchboard.requestCallback("voxel filter changed", self.filterChanged), switchboard.requestCallback("autoopacity", self.autoOpacityCB) ] display.DisplayMethod.__init__(self)
def __init__(self, no_material=defaultNoMaterial, no_color=defaultNoColor): SolidFillMeshDisplay.__init__(self) self.no_color = no_color self.no_material = no_material self.matchangeSignals = [ switchboard.requestCallback("material changed", self.matlChangedCB), switchboard.requestCallback("materials changed in microstructure", self.matlAssignmentsChangedCB) ]
def __init__(self, name, ordering, parentClass=None, instanceClass=Who, proxyClasses=[], secret=0): self._name = name # names must be unique! self.ordering = ordering self.parentClass = parentClass self.instanceClass = instanceClass # list of names of proxies that should be created for this class: self.proxyClasses = proxyClasses self.members = labeltree.LabelTree() self.nmembers = 0 self.nproxies = 0 ## TODO 3.1: For situations in which this whoclass object ## needs to be secret for some kinds of display and not for ## others the boolean type would not be enough. We will have ## to think of another structure to handle different kinds of ## secrecy for those displays. self.secret = secret # does not appear in GUI if secret==1 # Insert the new WhoClass in the list of all WhoClasses, # updating each class's index. global whoClasses nwho = len(whoClasses) for i in range(nwho): if whoClasses[i].ordering > ordering: whoClasses.insert(i, self) for j in range(i, nwho + 1): whoClasses[j]._index = j break else: whoClasses.append(self) self._index = nwho # Create proxy objects if requested. The proxy class may not # have been loaded yet. That's ok: when the class is created # it will create the proxy for this WhoClass. for whoproxyclassname in proxyClasses: try: whoproxyclass = WhoProxyClass.allProxyClasses[ whoproxyclassname] except KeyError: pass else: self.addProxy(whoproxyclass.makeProxy(self)) switchboard.notify('new who class', name) # Be notified when a who object changes its name, in case that # object's WhoClass is a parent class of this class. If it # is, objects in this class need to update their paths. switchboard.requestCallback('rename who', self.renameWho)
def __init__(self, color, opacity): self.color = color self.opacity = opacity self.filter = None self.sbcallbacks = [ switchboard.requestCallback("voxel filter changed", self.filterChanged), switchboard.requestCallback("pixel selection changed", self.selectionChanged) ] display.DisplayMethod.__init__(self)
def __init__(self, meshinfotb): genericinfoGUI.GenericInfoToolboxGUI.__init__(self, "Mesh Info", meshinfotb) self.sbcallbacks.extend([ switchboard.requestCallback("mesh changed", self.meshChanged), switchboard.requestCallback("mesh data changed", self.meshDataChanged), switchboard.requestCallback("subproblem changed", self.subproblemChanged), switchboard.requestCallback("field defined", self.fieldDefsChanged) ])
def __init__(self, gfxtoolbox): genericinfoGUI.GenericInfoModeGUI.__init__(self, gfxtoolbox) self.sbcallbacks.extend([ switchboard.requestCallback("groupset member resized", self.groupsChangedCB), switchboard.requestCallback("groupset member added", self.groupsChangedCB), switchboard.requestCallback("groupset member renamed", self.groupsChangedCB), switchboard.requestCallback("groupset changed", self.groupsChangedCB) ])
def __init__(self, gfxwindow): toolbox.Toolbox.__init__(self, "Mesh_Cross_Section", gfxwindow) self.current_mesh = None # Topmost mesh. self.current_output = None # Topmost contourable layer. self.whoset = ('Mesh', ) # Cross-sections live on meshes. self.sb_callbacks = [ switchboard.requestCallback((self.gfxwindow(), "layers changed"), self.newLayers), switchboard.requestCallback( (self.gfxwindow(), "new contourmap layer"), self.newLayers) ]
def __init__(self, gfxwindow): toolbox.Toolbox.__init__(self, 'Move_Nodes', gfxwindow) self.whoset = ('Skeleton',) self.selectednode = SelectedNode() self.allow_illegal = False self.skeleton = None self.sbcallbacks = [ switchboard.requestCallback((self.gfxwindow(), "layers changed"), self.layersChangedCB), switchboard.requestCallback(("who changed", "Skeleton"), self.whoChangedCB) ]
def __init__(self, gfxwindow): toolbox.Toolbox.__init__(self, "Mesh_Cross_Section", gfxwindow) self.current_mesh = None # Topmost mesh. self.current_output = None # Topmost contourable layer. self.whoset = ('Mesh',) # Cross-sections live on meshes. self.sb_callbacks = [ switchboard.requestCallback( (self.gfxwindow(), "layers changed"), self.newLayers), switchboard.requestCallback( (self.gfxwindow(), "new contourmap layer"), self.newLayers) ]
def __init__(self, gfxwindow): toolbox.Toolbox.__init__(self, "Skeleton_Info", gfxwindow) self.whoset = ("Skeleton",) self.querier = None self.peeker = None self.records = ringbuffer.RingBuffer(49) self.timestamp = timestamp.TimeStamp() self.timestamp.backdate() self.sbcallbacks = [ # Looks for a skeleton on the gfx window. switchboard.requestCallback((self.gfxwindow(), "layers changed"), self.newLayers), # Looks for a skeleton modification. switchboard.requestCallback(("who changed", "Skeleton"), self.skelChanged), ]
def __init__(self, name, gfxmgr, clone=0): debug.subthreadTest() # self.name is also assigned by GhostGfxWindow, but it's # helpful for debugging for it to be assigned as soon as # possible in all execution paths. self.name = name self.gfxlock = lock.Lock() self.acquireGfxLock() # This whole initialization sequence is complicated. The # reason is that the order of operations is important -- the # ghostgfxwindow makes function calls which need to be # redefined in the GUI before they occur -- and there is a # requirement that the main thread never be locked. # Furthermore, the ghostgfxwindow has to create the menu # before the SubWindow init gets called. It could probably be # rationalized, but it's not urgent. # preinitialize and postinitialize are defined in gfxwindow.py # for 2D and gfxwindow3d.py for 3D. mainthread.runBlock(self.preinitialize, (name, gfxmgr, clone)) # GhostGfxWindow.__init__ creates the canvas, among other things. ghostgfxwindow.GhostGfxWindow.__init__(self, name, gfxmgr, clone=clone) mainthread.runBlock(self.postinitialize, (name, gfxmgr, clone)) self.releaseGfxLock() self.switchboardCallbacks.append( switchboard.requestCallback("shutdown", self.shutdownCB))
def __init__(self, skeletoncontext): skeletonselectable.SelectionBase.__init__(self, skeletoncontext) self.stack = ringbuffer.RingBuffer(stacksize) self.stack.push(PinnedNodeSet(self.skeletoncontext)) self.sbcallbacks.append( switchboard.requestCallback('pinnednode ringbuffer resize', self.setUndoBufferSizeCB))
def __init__(self, skeletoncontext): self.skeletoncontext = skeletoncontext self.rwLock = lock.RWLock() self.sbcallbacks = [ switchboard.requestCallback(('whodoundo push', 'Skeleton'), self.whoChanged0) ]
def __init__(self, gfxwindow): toolbox.Toolbox.__init__(self, 'Skeleton_Info', gfxwindow) self.whoset = ('Skeleton', ) self.querier = None self.peeker = None self.records = ringbuffer.RingBuffer(49) self.timestamp = timestamp.TimeStamp() self.timestamp.backdate() self.sbcallbacks = [ # Looks for a skeleton on the gfx window. switchboard.requestCallback((self.gfxwindow(), "layers changed"), self.newLayers), # Looks for a skeleton modification. switchboard.requestCallback(('who changed', 'Skeleton'), self.skelChanged) ]
def __init__(self, skeletoncontext): SelectionBase.__init__(self, skeletoncontext) # Ringbuffer of SelectionSet objects -- these contain # selections for undo/redo. self.stack = ringbuffer.RingBuffer(self.mode().stacksize) self.stack.push(SelectionSet(self.skeletoncontext)) self.sbcallbacks.append(switchboard.requestCallback( ('skelselection ringbuffer resize', self.mode().name), self.setUndoBufferSizeCB))
def __init__(self, name, isize, size): cmicrostructure.CMicrostructure.__init__(self, name, isize, size) self._isize = isize # iPoint(width, height) in pixels # Make sure that the physical size isn't stored as ints, which # could cause problems later (specifically when computing the # aspect ratio of the microstructure, as in # Skeleton.hashNodes). This *isn't* done in the Point # constructor, since it might be slow. if config.dimension() == 2: self._size = primitives.Point(float(size.x), float(size.y)) elif config.dimension() == 3: self._size = primitives.Point(float(size.x), float(size.y), float(size.z)) # Also store increments. if config.dimension() == 2: self._delta = (self._size[0] / self._isize[0], self._size[1] / self._isize[1]) elif config.dimension() == 3: self._delta = (self._size[0] / self._isize[0], self._size[1] / self._isize[1], self._size[2] / self._isize[2]) # The 'parent' arg to pixelselectionWhoClass.add and # activeareaWhoClass.add should be set to the Who object for # this MS, which hasn't been created yet. So it's set to None # here, and fixed later. pixsel = pixelselection.PixelSelection(isize, size, self) pixelselection.pixelselectionWhoClass.add(name, pixsel, parent=None) self.pixelselection = pixelselection.pixelselectionWhoClass[name] self.activearea = activearea.activeareaWhoClass.add( name, activearea.ActiveArea(isize, size, self), parent=None) self.namedActiveAreas = [] self.setCurrentActiveArea(self.activearea.getObject()) # Plug-ins have to be created before the Microstructure # context Who object is created, because Who object creation # might trigger switchboard calls that use the plug-ins. self.plugins = {} for pluginname, pluginclass in plugInClasses.items(): self.plugins[pluginname] = pluginclass(self) # Create the Who object for this Microstructure, and add it to # list of all Microstructures. Do this last, because it calls # switchboard callbacks that may assume that the MS is fully # constructed. mswho = microStructures.add(name, self, parent=None) # Fix the 'parent' for the pixelselection and activearea. See # comment above. self.pixelselection.setParent(mswho) self.activearea.setParent(mswho) self.sbcallbacks = [ switchboard.requestCallback(('who changed', 'Active Area'), self.aaChangedCB) ]
def __init__(self, gfxwindow): toolbox.Toolbox.__init__(self, 'Move_Nodes', gfxwindow) self.whoset = ('Skeleton',) self.selectednode = SelectedNode() self.allow_illegal=0 self.skeleton = None self.sbcallbacks = [ switchboard.requestCallback((self.gfxwindow(), "layers changed"), self.layersChangedCB)]
def __init__(self, name, isize, size): cmicrostructure.CMicrostructure.__init__(self, name, isize, size) self._isize = isize # iPoint(width, height) in pixels # Make sure that the physical size isn't stored as ints, which # could cause problems later (specifically when computing the # aspect ratio of the microstructure, as in # Skeleton.hashNodes). This *isn't* done in the Point # constructor, since it might be slow. if config.dimension() == 2: self._size = primitives.Point(float(size.x), float(size.y)) elif config.dimension() == 3: self._size = primitives.Point(float(size.x), float(size.y), float(size.z)) # Also store increments. if config.dimension() == 2: self._delta = (self._size[0]/self._isize[0], self._size[1]/self._isize[1]) elif config.dimension() == 3: self._delta = (self._size[0]/self._isize[0], self._size[1]/self._isize[1], self._size[2]/self._isize[2]) # The 'parent' arg to pixelselectionWhoClass.add and # activeareaWhoClass.add should be set to the Who object for # this MS, which hasn't been created yet. So it's set to None # here, and fixed later. pixsel = pixelselection.PixelSelection(isize, size, self) pixelselection.pixelselectionWhoClass.add(name, pixsel, parent=None) self.pixelselection = pixelselection.pixelselectionWhoClass[name] self.activearea = activearea.activeareaWhoClass.add( name, activearea.ActiveArea(isize, size, self), parent=None) self.namedActiveAreas = [] self.setCurrentActiveArea(self.activearea.getObject()) # Plug-ins have to be created before the Microstructure # context Who object is created, because Who object creation # might trigger switchboard calls that use the plug-ins. self.plugins = {} for pluginname, pluginclass in plugInClasses.items(): self.plugins[pluginname] = pluginclass(self) # Create the Who object for this Microstructure, and add it to # list of all Microstructures. Do this last, because it calls # switchboard callbacks that may assume that the MS is fully # constructed. mswho = microStructures.add(name, self, parent=None) # Fix the 'parent' for the pixelselection and activearea. See # comment above. self.pixelselection.setParent(mswho) self.activearea.setParent(mswho) self.sbcallbacks = [ switchboard.requestCallback(('who changed', 'Active Area'), self.aaChangedCB) ]
def __init__(self, name, ordering, parentClass=None, instanceClass=Who, proxyClasses=[], secret=0): self._name = name # names must be unique! self.ordering = ordering self.parentClass = parentClass self.instanceClass = instanceClass # list of names of proxies that should be created for this class: self.proxyClasses = proxyClasses self.members = labeltree.LabelTree() self.nmembers = 0 self.nproxies = 0 self.secret = secret # does not appear in GUI if secret==1 # Insert the new WhoClass in the list of all WhoClasses, # updating each class's index. global whoClasses nwho = len(whoClasses) for i in range(nwho): if whoClasses[i].ordering > ordering: whoClasses.insert(i, self) for j in range(i, nwho+1): whoClasses[j]._index = j break else: whoClasses.append(self) self._index = nwho # Create proxy objects if requested. The proxy class may not # have been loaded yet. That's ok: when the class is created # it will create the proxy for this WhoClass. for whoproxyclassname in proxyClasses: try: whoproxyclass = WhoProxyClass.allProxyClasses[whoproxyclassname] except KeyError: pass else: self.addProxy(whoproxyclass.makeProxy(self)) switchboard.notify('new who class', name) # Be notified when a who object changes its name, in case that # object's WhoClass is a parent class of this class. If it # is, objects in this class need to update their paths. switchboard.requestCallback('rename who', self.renameWho)
def __init__(self, gfxwindow): self.point = None # location of last query # self.timestamp = timestamp.TimeStamp() toolbox.Toolbox.__init__(self, toolboxName(), gfxwindow) self.lastMS = None self.sbcallbacks = [ switchboard.requestCallback((self.gfxwindow(), "layers changed"), self.newLayers), ]
def __init__(self, gfxwindow): self.point = None # location of last query self.timestamp = timestamp.TimeStamp() toolbox.Toolbox.__init__(self, "Pixel_Info", gfxwindow) self.plugIns = [plugInClass(self) for plugInClass in plugInClasses] self.sbcallbacks = [ switchboard.requestCallback("new pixelinfo plugin", self.newPlugIn) ]
def __init__(self, color, linewidth, glyphsize, resolution): self.color = color self.linewidth = linewidth self.glyphsize = glyphsize self.resolution = resolution display.DisplayMethod.__init__(self) self.sbcallbacks = [ switchboard.requestCallback("new boundary configuration", self.newBdyConfigCB) ]
def __init__(self, skeletoncontext): self.timestamp = timestamp.TimeStamp() self.skeletoncontext = skeletoncontext self.rwLock = lock.RWLock() self.sbcallbacks = [ # switchboard.requestCallback(('who changed', 'Skeleton'), # self.newSkeleton), switchboard.requestCallback(('whodoundo push', 'Skeleton'), self.whoChanged0) ]
def setWho(self, hoo): if hoo is self._who: return True self._who = hoo if self.whoChangedSignal: switchboard.removeCallback(self.whoChangedSignal) switchboard.removeCallback(self.whoRenamedSignal) self.whoChangedSignal = None if hoo is not None: # whoChanged should return True if it did *not* do # everything that setParams does. Some subclasses can't # separate the jobs of whoChanged and setParams. They # should define both functions and have them do the same # thing, but return False from whoChanged(). status = self.whoChanged() self.whoChangedSignal = switchboard.requestCallback( ("who changed", hoo.classname), self._whoChangedCB) self.whoRenamedSignal = switchboard.requestCallback( ("rename who", hoo.classname), self._whoRenamedCB) return status
def setupSwitchboard(self): map(switchboard.removeCallback, self.gsbcallbacks) window = self.currentGfxWindow() if window is not None: self.gsbcallbacks = [ switchboard.requestCallback((window, "layers changed"), self.layersChangedCB), switchboard.requestCallbackMain((window, "meshinfo click"), self.updatePosition) ] else: self.gsbcallbacks = []
def __init__(self, gfxwindow): toolbox.Toolbox.__init__(self, 'Mesh_Info', gfxwindow) self.whoset = ('Mesh',) self.querier = None self.peeker = None self.records = ringbuffer.RingBuffer(49) self.meshlayer = None self.last_position = None # Most recent mouse-click position. self.sbcallbacks = [ switchboard.requestCallback((self.gfxwindow(), "layers changed"), self.newLayers)]
def __init__(self, name, method, gfxwindow, **extrakwargs): toolbox.Toolbox.__init__(self, name, gfxwindow) self.method = method self.lastclick = None # position of last mouse click self.menu = None ## extrakwargs are passed to the getSelectionContext() ## function to retrieve the Who object of the current ## selection. self.extrakwargs = extrakwargs self.sb_callbacks = [ switchboard.requestCallback(method, self.rebuildMenus) ]
def __init__(self, gfxwindow, name, modes): toolbox.Toolbox.__init__(self, name, gfxwindow) self.modeobjdict = {} for mode in modes: self.modeobjdict[mode.targetName] = mode # Previous queries are stored as (mode, index) pairs. self.queries = ringbuffer.RingBuffer(49) self.queries.push((modes[0], None)) # The current peek state is stored as a dictionary of indices, # keyed by mode. No history is maintained. self.peek = {} self.context = None # MeshContext or SkeletonContext or ... self.sbcallbacks = [ switchboard.requestCallback((self.gfxwindow(), "layers changed"), self.newLayers), switchboard.requestCallback(("who changed", self.whoClassName), self.whoChangedCB)]
def __init__(self, skeletoncontext, groupset=[]): self.skeletoncontext = skeletoncontext self.groups = utils.OrderedSet(groupset) # The "tracker" maintains data about group membership on a # skeleton-by-skeleton basis, eliminating (some) searches. # Keys are skeletons in the context, values are CGroupTracker # objects. self.tracker = weakref.WeakKeyDictionary() self.sbcallbacks = [ switchboard.requestCallback(('whodoundo push', 'Skeleton'), self.new_skeleton) ]
def __init__(self, toolbox): debug.mainthreadTest() self.toolbox = toolbox # SkeletonInfoToolboxGUI self.menu = self.toolbox.toolbox.menu # ie, gfxtoolbox.toolbox.menu self.gtk = gtk.Frame(self.targetname + " Information") self.gtk.set_shadow_type(gtk.SHADOW_IN) scroll = gtk.ScrolledWindow() gtklogger.logScrollBars(scroll, self.targetname+"Information") scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.gtk.add(scroll) # This vbox just keeps the table from expanding inside the # scrolledwindow. vbox = gtk.VBox() scroll.add_with_viewport(vbox) self.table = gtk.Table() vbox.pack_start(self.table, expand=0, fill=0) self.sbcallbacks = [ switchboard.requestCallback("groupset member resized", self.grpsChanged)]
def __init__(self, toolbox): debug.mainthreadTest() self.toolbox = toolbox # SkeletonInfoToolboxGUI self.menu = self.toolbox.toolbox.menu # ie, gfxtoolbox.toolbox.menu self.gtk = gtk.Frame(self.targetname + " Information") self.gtk.set_shadow_type(gtk.SHADOW_IN) scroll = gtk.ScrolledWindow() gtklogger.logScrollBars(scroll, self.targetname + "Information") scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.gtk.add(scroll) # This vbox just keeps the table from expanding inside the # scrolledwindow. vbox = gtk.VBox() scroll.add_with_viewport(vbox) self.table = gtk.Table() vbox.pack_start(self.table, expand=0, fill=0) self.sbcallbacks = [ switchboard.requestCallback("groupset member resized", self.grpsChanged) ]
def __init__(self, skelinfotb): genericinfoGUI.GenericInfoToolboxGUI.__init__(self, "Skeleton Info", skelinfotb) self.sbcallbacks.extend([ switchboard.requestCallback('changed pixel group', self.grpChangedCB), switchboard.requestCallback('changed pixel groups', self.grpsChangedCB), switchboard.requestCallback('destroy pixel group', self.grpChangedCB), switchboard.requestCallback('renamed pixel group', self.grpRenamedCB), switchboard.requestCallback('materials changed in microstructure', self.matChangedCB), switchboard.requestCallback('materials changed in skeleton', self.matChangedSkelCB) ])
def __init__(self, skeletoncontext, objects=None, groupset=[]): self.skeletoncontext = skeletoncontext self.groups = utils.OrderedSet(groupset) # self.objects is a reference to the list of objects in the # Skeleton from which the members of the group are chosen. It # is updated in the new_objects() function in the derived # classes, which is called directly from the skeleton context # at push-time. The "who changed" signal should not be used # for this, the subthread activity introduces a race condition # with the "new who" signal, which confuses some of the pages. self.objects = objects or [] # The "tracker" maintains data about group membership on a # skeleton-by-skeleton basis, eliminating (some) searches. # Keys are skeletons in the context, values are GroupTracker # objects. self.tracker = weakref.WeakKeyDictionary() self.sbcallbacks = [ switchboard.requestCallback(('whodoundo push', 'Skeleton'), self.new_skeleton) ]
except AttributeError: discussion = None menuitem = pinnodesmenu.addItem( oofmenu.OOFMenuItem( utils.space2underscore(registration.name()), callback=pinnodesmodifier.pinnodesmod, params=[whoville.WhoParameter('skeleton', skeletoncontext.skeletonContexts, tip=parameter.emptyTipString)] +registration.params, help=help, discussion=discussion)) menuitem.data = registration # Make menu when a new entry has been made to the registration. switchboard.requestCallback(pinnodesmodifier.PinNodesModifier, makeMenu) makeMenu() ###################### def _setPinnedNode_UndoBufferSize(menuitem, size): skeletonnode.stacksize = size switchboard.notify('pinnednode ringbuffer resize', size+1) mainmenu.OOF.Settings.UndoBuffer_Size.addItem(oofmenu.OOFMenuItem( 'Pinned_Nodes', ordering=2, callback=_setPinnedNode_UndoBufferSize, params=[parameter.IntParameter('size', skeletonnode.stacksize, tip='number of previous pinned node configurations to retain')],
## Create toolbox subclasses for each SkeletonSelectionMode tbordering=2.5 def _newSelectionMode(mode): class SkelSelectToolbox(SkeletonSelectionToolbox): def __init__(self, gfxwindow): SkeletonSelectionToolbox.__init__(self, mode=mode, gfxwindow=gfxwindow) global tbordering tbordering += 0.01 tip="Select " + mode.name + "s in a Skeleton." discussion="""<para> Commands for selecting %ss in a &skel;, based on mouse input. </para>""" % mode.name ## The mode keeps a reference to the associated class so that GUI ## extensions can be applied to the class. If the mode didn't ## keep a reference, then the only way to find the class would be ## to look through the registry in toolbox.py. mode.tbclass = SkelSelectToolbox toolbox.registerToolboxClass(SkelSelectToolbox, ordering=tbordering) for mode in skeletonselmodebase.SkeletonSelectionMode.modes: _newSelectionMode(mode) switchboard.requestCallback(skeletonselmodebase.SkeletonSelectionMode, _newSelectionMode)
def requestCallback(self, *args): self.switchboardCallbacks.append(switchboard.requestCallback(*args))
def __init__(self, parent): debug.mainthreadTest() self.parent = parent self.gtk = gtk.Frame() gtklogger.setWidgetName(self.gtk, 'Groups') self.gtk.set_shadow_type(gtk.SHADOW_IN) box = gtk.HBox(spacing=2) self.gtk.add(box) # Set in chooserCB, the widget callback for the chooser list. self.current_group_name = None # List of buttons which are sensitive only when a group is selected. self.groupbuttons = [] # List of buttons which are sensitive when there is a group # and a selection. self.groupandselectionbuttons = [] # Left-hand button box. New/Auto/Rename/Copy/Delete/DeleteAll lbuttons = gtk.VBox(spacing=2) box.pack_start(lbuttons, fill=0, expand=0) self.new_button = gtk.Button("New...") gtklogger.setWidgetName(self.new_button, 'New') lbuttons.pack_start(self.new_button, fill=0, expand=0) gtklogger.connect(self.new_button, "clicked", self.newGroupCB) tooltips.set_tooltip_text(self.new_button,"Create a new empty group.") self.auto_button = gtk.Button("Auto") gtklogger.setWidgetName(self.auto_button, 'Auto') lbuttons.pack_start(self.auto_button, fill=0, expand=0) gtklogger.connect(self.auto_button, 'clicked', self.autoGroupCB) tooltips.set_tooltip_text(self.auto_button, "Automatically create groups from the current pixel groups.") self.rename_button = gtk.Button("Rename...") gtklogger.setWidgetName(self.rename_button, 'Rename') lbuttons.pack_start(self.rename_button, fill=0, expand=0) self.groupbuttons.append(self.rename_button) gtklogger.connect(self.rename_button, "clicked", self.renameGroupCB) tooltips.set_tooltip_text(self.rename_button,"Rename the selected group.") self.copy_button = gtk.Button("Copy...") gtklogger.setWidgetName(self.copy_button, 'Copy') lbuttons.pack_start(self.copy_button, fill=0, expand=0) self.groupbuttons.append(self.copy_button) gtklogger.connect(self.copy_button, "clicked", self.copyGroupCB) tooltips.set_tooltip_text(self.copy_button,"Copy the selected group.") self.delete_button = gtk.Button("Delete") gtklogger.setWidgetName(self.delete_button, 'Delete') lbuttons.pack_start(self.delete_button, fill=0, expand=0) self.groupbuttons.append(self.delete_button) gtklogger.connect(self.delete_button, "clicked", self.deleteGroupCB) tooltips.set_tooltip_text(self.delete_button,"Deleted the selected group.") self.deleteAll_button = gtk.Button("Delete All") gtklogger.setWidgetName(self.deleteAll_button, 'DeleteAll') lbuttons.pack_start(self.deleteAll_button, fill=0, expand=0) gtklogger.connect(self.deleteAll_button, 'clicked', self.deleteAllCB) tooltips.set_tooltip_text(self.deleteAll_button,"Delete all groups.") # Groups list. self.grouplist = chooser.ScrolledChooserListWidget( callback=self.chooserCB, name="GroupList") box.pack_start(self.grouplist.gtk, fill=1, expand=1) # Right-hand button box. Add/Remove/Clear/ClearAll/Info rbuttons = gtk.VBox(spacing=2) box.pack_start(rbuttons, fill=0, expand=0) self.add_button = gtk.Button("Add") gtklogger.setWidgetName(self.add_button, 'Add') rbuttons.pack_start(self.add_button, fill=0, expand=0) self.groupandselectionbuttons.append(self.add_button) gtklogger.connect(self.add_button, "clicked", self.addToGroupCB) tooltips.set_tooltip_text(self.add_button, "Add the currently selected pixels to the selected group.") self.remove_button = gtk.Button("Remove") gtklogger.setWidgetName(self.remove_button, 'Remove') rbuttons.pack_start(self.remove_button, fill=0, expand=0) self.groupandselectionbuttons.append(self.remove_button) gtklogger.connect(self.remove_button, "clicked", self.removeFromGroupCB) tooltips.set_tooltip_text(self.remove_button, "Remove the currently selected pixels from the selected group.") self.clear_button = gtk.Button("Clear") gtklogger.setWidgetName(self.clear_button, 'Clear') rbuttons.pack_start(self.clear_button, fill=0, expand=0) gtklogger.connect(self.clear_button, "clicked", self.clearGroupCB) tooltips.set_tooltip_text(self.clear_button, "Remove all pixels from the selected group.") self.clearAll_button = gtk.Button("Clear All") gtklogger.setWidgetName(self.clearAll_button, 'ClearAll') rbuttons.pack_start(self.clearAll_button, fill=0, expand=0) gtklogger.connect(self.clearAll_button, "clicked", self.clearAllCB) tooltips.set_tooltip_text(self.clearAll_button, "Remove all pixels from all groups.") self.info_button = gtk.Button("Info") gtklogger.setWidgetName(self.info_button, 'Info') rbuttons.pack_start(self.info_button, fill=0, expand=0) self.groupbuttons.append(self.info_button) gtklogger.connect(self.info_button, "clicked", self.queryGroupCB) tooltips.set_tooltip_text(self.info_button, "Display information about the selected group in the OOF Messages window.") ## TODO: Hide this frame when mode.materialsallowed is False. matframe = gtk.Frame("Material") # matframe.set_shadow_type(gtk.SHADOW_IN) rbuttons.pack_start(matframe, expand=0, fill=0, padding=3) matbox = gtk.VBox(spacing=2) matframe.add(matbox) self.addmaterial_button = gtk.Button("Assign") gtklogger.setWidgetName(self.addmaterial_button, 'AddMaterial') matbox.pack_start(self.addmaterial_button, fill=0, expand=0) gtklogger.connect(self.addmaterial_button, "clicked", self.addMaterialCB) tooltips.set_tooltip_text(self.addmaterial_button, "Assign a material to the members of the selected group.") self.removematerial_button = gtk.Button("Remove") matbox.pack_start(self.removematerial_button, fill=0, expand=0) gtklogger.connect(self.removematerial_button, "clicked", self.removeMaterialCB) tooltips.set_tooltip_text(self.removematerial_button, "Remove an explicitly assigned material from the members of the selected group.") # Need to be notified when groupset memberships change. switchboard.requestCallback("groupset member added", self.group_added), switchboard.requestCallback("groupset member renamed", self.group_added), switchboard.requestCallback("groupset changed", self.groupset_changed), switchboard.requestCallback("groupset member resized", self.group_resized) switchboard.requestCallback("new pixel group", self.pxlgroup_added) switchboard.requestCallback("destroy pixel group", self.pxlgroup_added)
help = registration.tip except AttributeError: help = None # Discussion try: discussion = registration.discussion except AttributeError: discussion = None menuitem = selmodmenu.addItem( oofmenu.OOFMenuItem(utils.space2underscore(registration.name()), callback=pixelselectionmod.doSelectionMod, threadable=oofmenu.THREADABLE, params=[ whoville.WhoParameter('microstructure', microstructure.microStructures, tip=parameter.emptyTipString) ]+registration.params, help=help, discussion=discussion)) menuitem.data = registration # Rebuild the selection modification menu whenever a new # SelectionModifier Registration is created. Hopefully this won't be # too often. switchboard.requestCallback(pixelselectionmod.SelectionModifier, buildSelectionModMenu) buildSelectionModMenu()
# inconsistent the equation mapping must not be attempted. if listofconjugatepairs.sanity_check(relevant_pairs): subpctxt.matrix_symmetry_K.set_symmetric() subpctxt.matrix_symmetry_C.set_symmetric() subpctxt.matrix_symmetry_M.set_symmetric() else: subpctxt.matrix_symmetry_K.set_inconsistent() subpctxt.matrix_symmetry_C.set_inconsistent() subpctxt.matrix_symmetry_M.set_inconsistent() # Direct callback for the "mesh changed" signal. def _meshChangedCB(mesh): meshpath = mesh.path() from ooflib.engine import subproblemcontext subppaths = subproblemcontext.subproblems.keys(base=meshpath) # subppaths is a list of paths. Each path is a list containing a # single name, which is the path to the subproblem relative to the # mesh. for subppath in subppaths: check_symmetry(meshpath+":"+subppath[0]) switchboard.requestCallback("mesh changed", _meshChangedCB) switchboard.requestCallback("equation activated", check_symmetry) switchboard.requestCallback("equation deactivated", check_symmetry) switchboard.requestCallback("field activated", check_symmetry) switchboard.requestCallback("field deactivated", check_symmetry)
def __init__thread(self, gfxwindow, time, position, output): debug.mainthreadTest() allMeshDataWindows.append(self) widgetscope.WidgetScope.__init__(self, None) current_count = MeshDataGUI.count MeshDataGUI.count += 1 self._name = "Mesh_Data_%d" % current_count self.output = output self.time = time self.position = position self.sbcallbacks = [] self.gsbcallbacks = [] # callbacks from a specific gfx window self.updateLock = lock.Lock() self.outputparam = \ ooflib.engine.IO.output.AggregateOutputParameter('output') # Although it's not displayed, we need a mesh widget in the # widgetscope, or the OutputParameterWidget won't work. # TODO LATER: Is this ugly, or what? self.meshWidget = whowidget.WhoWidget(mesh.meshes, scope=self, name="Godot") self.gtk = gtk.Window(gtk.WINDOW_TOPLEVEL) title = utils.underscore2space(self._name) self.gtk.set_title(title) gtklogger.newTopLevelWidget(self.gtk, title) gtklogger.connect_passive(self.gtk, 'delete-event') gtklogger.connect_passive(self.gtk, 'configure-event') self.mainbox = gtk.VBox() self.gtk.add(self.mainbox) # Put this window into the Windows menu. The menu item can't # be logged, since the creation and operation of the window # aren't logged, so scripts shouldn't refer to it at all. mainmenu.OOF.Windows.Mesh_Data.addItem(oofmenu.OOFMenuItem( self._name, no_log=1, help="Raise Mesh Data window %d." % current_count, threadable=oofmenu.UNTHREADABLE, callback=self.raiseWindow)) expander = gtk.Expander("Source") gtklogger.setWidgetName(expander, 'ViewSource') gtklogger.connect_passive_after(expander, 'activate') self.mainbox.pack_start(expander) expander.set_expanded(1) self.table = gtk.Table(rows=config.dimension()+4, columns=2) expander.add(self.table) label = gtk.Label("Source Window:") label.set_alignment(1.0, 0.5) self.table.attach(label, 0,1, 0,1, xpadding=3, xoptions=gtk.FILL) tooltips.set_tooltip_text(label, "Display data for mouse clicks in this Graphics window.") self.gfxWindowChooser = chooser.ChooserWidget([], callback=self.chooserCB, name='GfxWindow') self.table.attach(self.gfxWindowChooser.gtk, 1,2, 0,1, xpadding=3, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0) label = gtk.Label("Mesh:") label.set_alignment(1.0, 0.5) self.table.attach(label, 0,1, 1,2, xpadding=3, xoptions=gtk.FILL, yoptions=0) tooltips.set_tooltip_text(label,"Data is displayed for values on this mesh.") self.meshText = gtk.Entry() gtklogger.setWidgetName(self.meshText, "meshname") self.meshText.set_editable(False) self.meshText.set_size_request(12*guitop.top().charsize, -1) self.table.attach(self.meshText, 1,2, 1,2, xpadding=3, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0) # Position controls label = gtk.Label("position x:") label.set_alignment(1.0, 0.5) self.table.attach(label, 0,1, 2,3, xpadding=3, xoptions=gtk.FILL, yoptions=0) self.xText = gtk.Entry() gtklogger.setWidgetName(self.xText, 'x') self.xText.set_size_request(12*guitop.top().digitsize, -1) self.table.attach(self.xText, 1,2, 2,3, xpadding=3, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0) self.xsignal = gtklogger.connect(self.xText, 'changed', self.posChangedCB) label = gtk.Label("position y:") label.set_alignment(1.0, 0.5) self.table.attach(label, 0,1, 3,4, xpadding=3, xoptions=gtk.FILL, yoptions=0) self.yText = gtk.Entry() gtklogger.setWidgetName(self.yText, 'y') self.yText.set_size_request(12*guitop.top().digitsize, -1) self.table.attach(self.yText, 1,2, 3,4, xpadding=3, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0) self.ysignal = gtklogger.connect(self.yText, 'changed', self.posChangedCB) if config.dimension() == 3: label = gtk.Label("position z:") label.set_alignment(1.0, 0.5) self.table.attach(label, 0,1, 4,5, xpadding=3, xoptions=gtk.FILL, yoptions=0) self.zText = gtk.Entry() gtklogger.setWidgetName(self.zText, 'z') self.zText.set_size_request(12*guitop.top().digitsize, -1) self.table.attach(self.zText, 1,2, 4,5, xpadding=3, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0) self.zsignal = gtklogger.connect(self.zText, 'changed', self.posChangedCB) timerow = 5 else: timerow = 6 # Time controls. Typing in the time widget does not # immediately update the displayed data, because interpolating # to a new time is an expensive computation, and shouldn't be # done while the user is in the middle of typing. Instead, # the time widget is normally desensitized and uneditable. # When the user clicks the "Edit" button, the widget becomes # editable, the rest of the window is desensitized, and the # "Edit" button changes do a "Done" button. When the user # clicks "Done" the data is updated and the time widget # becomes uneditable again. label = gtk.Label("time:") label.set_alignment(1.0, 0.5) self.table.attach(label, 0,1, timerow,timerow+1, xpadding=3, xoptions=gtk.FILL, yoptions=0) tBox = gtk.HBox(spacing=3) self.table.attach(tBox, 1,2, timerow,timerow+1, xpadding=3, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0) self.tText = gtk.Entry() self.tText.set_editable(False) self.tText.set_sensitive(False) tBox.pack_start(self.tText, expand=1, fill=1) gtklogger.setWidgetName(self.tText, 't') self.tText.set_size_request(12*guitop.top().digitsize, -1) self.tEditButton = gtk.Button("Edit") tBox.pack_start(self.tEditButton, expand=0, fill=0) gtklogger.setWidgetName(self.tEditButton, "tEdit") gtklogger.connect(self.tEditButton, 'clicked', self.tEditCB) self.tEditMode = False # Output selection label = gtk.Label("Output:") label.set_alignment(1.0, 0.5) self.table.attach(label, 0,1, timerow+2,timerow+3, xpadding=3, xoptions=gtk.FILL, yoptions=0) tooltips.set_tooltip_text(label,"Choose which data is displayed.") self.outputwidget = self.outputparam.makeWidget(scope=self) self.table.attach(self.outputwidget.gtk, 1,2, timerow+2,timerow+3, xpadding=3, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0) switchboard.requestCallback(self.outputwidget, self.outputwidgetCB) # Data display panel hbox = gtk.HBox() self.mainbox.pack_start(hbox, expand=1, fill=1, padding=5) frame = gtk.Frame("Data") gtklogger.setWidgetName(frame, 'Data') frame.set_shadow_type(gtk.SHADOW_IN) hbox.pack_start(frame, expand=1, fill=1, padding=5) vbox = gtk.VBox() frame.add(vbox) self.databox = gtk.HBox() vbox.pack_start(self.databox, expand=1, fill=1, padding=3) self.datawidget = None # set by updateData # Buttons at the bottom of the window buttonbox = gtk.HBox() self.mainbox.pack_start(buttonbox, expand=0, fill=0, padding=3) # Freeze buttons freezeframe = gtk.Frame("Freeze") gtklogger.setWidgetName(freezeframe, "Freeze") buttonbox.pack_start(freezeframe, expand=1, fill=1, padding=3) hbox = gtk.HBox() freezeframe.add(hbox) # Freeze Space button self.freezeSpaceFlag = False self.freezeSpaceButton = gtk.CheckButton('Space') gtklogger.setWidgetName(self.freezeSpaceButton, 'Space') hbox.pack_start(self.freezeSpaceButton, expand=1, fill=0, padding=0) self.freezeSpaceButton.set_active(self.freezeSpaceFlag) gtklogger.connect(self.freezeSpaceButton, 'clicked', self.freezeSpaceButtonCB) tooltips.set_tooltip_text(self.freezeSpaceButton, "Prevent the data in this window from being updated when the sample position changes.") # Freeze Time button self.freezeTimeFlag = False self.freezeTimeButton = gtk.CheckButton('Time') gtklogger.setWidgetName(self.freezeTimeButton, "Time") hbox.pack_start(self.freezeTimeButton, expand=1, fill=0, padding=0) self.freezeTimeButton.set_active(self.freezeTimeFlag) gtklogger.connect(self.freezeTimeButton,'clicked', self.freezeTimeButtonCB) tooltips.set_tooltip_text(self.freezeTimeButton, "Prevent the data in this window from being updated when the Mesh's time changes.") # Clone button self.cloneButton = gtkutils.StockButton(gtk.STOCK_COPY, 'Clone') gtklogger.setWidgetName(self.cloneButton, 'Clone') gtklogger.connect(self.cloneButton, 'clicked', self.cloneButtonCB) buttonbox.pack_start(self.cloneButton, expand=0, fill=0, padding=3) tooltips.set_tooltip_text(self.cloneButton, "Make a copy of this window with its current settings.") # Close button self.closeButton = gtk.Button(stock=gtk.STOCK_CLOSE) gtklogger.setWidgetName(self.closeButton, 'Close') gtklogger.connect(self.closeButton, 'clicked', self.closeButtonCB) buttonbox.pack_end(self.closeButton, expand=0, fill=0, padding=3) self.gtk.connect('destroy', self.destroyCB) self.updateGfxWindowChooser() if gfxwindow: self.gfxWindowChooser.set_state(gfxwindow.name) if position is not None: self.updatePosition(position) self.currentMesh = None self.updateMesh() self.setupSwitchboard() # gfx window dependent callbacks self.sbcallbacks += [ switchboard.requestCallbackMain('open graphics window', self.gfxwindowChanged), switchboard.requestCallbackMain('close graphics window', self.gfxwindowChanged), switchboard.requestCallbackMain('mesh data changed', self.meshDataChanged), switchboard.requestCallbackMain((gfxwindow, "time changed"), self.timeChanged) ] self.gtk.show_all()
# with its operation, modification and maintenance. However, to # facilitate maintenance we ask that before distributing modified # versions of this software, you first contact the authors at # [email protected]. from ooflib.SWIG.common import switchboard from ooflib.tutorials import tutorial TutoringItem = tutorial.TutoringItem TutorialClass = tutorial.TutorialClass def new_boundaries(*args): switchboard.notify("new boundaries for tutorial") switchboard.requestCallback("new boundary created", new_boundaries) TutorialClass( subject = "Skeleton Boundaries", ordering=3, lessons = [ TutoringItem( subject="Introduction", comments= """This tutorial is a simple interactive walkthrough explaining how to construct boundaries in skeletons. Skeleton boundaries are the places to which boundary conditions are applied. Boundaries created in a skeleton are automatically propagated to previous and later BOLD(modifications) of the skeleton,
secret=0, ordering=90, callback=saveprofile, threadable=oofmenu.THREADABLE, params = [ filenameparam.WriteFileNameParameter('filename', tip="File name."), filenameparam.WriteModeParameter( 'mode', tip="'w' to (over)write and 'a' to append."), enum.EnumParameter('format', datafile.DataFileFormat, datafile.ASCII, tip="File format."), profile.ProfileNameParameter('profile', tip="Profile to save.")], help="Save a named profile to a file.", discussion="""<para> Save a <link linkend='Section-Concepts-Mesh-BoundaryCondition-NamedProfile'>named <classname>Profile</classname></link> to a data file. The available file <varname>formats</varname> are discussed in <xref linkend='Section-Concepts-FileFormats'/>. </para>""")) def enable_profile_save(*args): if AllProfiles: savemenu.Profile.enable() else: savemenu.Profile.disable() switchboard.requestCallback("profiles changed", enable_profile_save) enable_profile_save()
params=[ filenameparam.WriteFileNameParameter("filename", tip="Name of the file."), filenameparam.WriteModeParameter("mode", tip="'w' for (over)write and 'a' to append."), enum.EnumParameter("format", datafile.DataFileFormatExt, datafile.ASCII, tip="Format of the file."), whoville.WhoParameter("skeleton", skeletoncontext.skeletonContexts, tip=parameter.emptyTipString), ], help="Save a Skeleton to a file.", discussion=""" <para>Store a &skel; in a file in one of several <link linkend='Section-Concepts-FileFormats'><varname>formats</varname></link>. The file can be reloaded by <xref linkend='MenuItem-OOF.File.Load.Script'/> or <xref linkend='MenuItem-OOF.File.Load.Data'/>, depending on the file format.</para> """, ) ) def _fixmenu(*args): if skeletoncontext.skeletonContexts.nActual() == 0: OOF.File.Save.Skeleton.disable() else: OOF.File.Save.Skeleton.enable() _fixmenu() switchboard.requestCallback(("new who", "Skeleton"), _fixmenu) switchboard.requestCallback(("remove who", "Skeleton"), _fixmenu)
ordering=30, params=[ filenameparam.WriteFileNameParameter('filename', tip="Name of the file."), filenameparam.WriteModeParameter('mode', tip="write or append?"), enum.EnumParameter('format', datafile.DataFileFormat, datafile.ASCII, tip="File format."), whoville.WhoParameter('microstructure', ooflib.common.microstructure.microStructures, tip=parameter.emptyTipString)], help="Save a Microstructure in a file.", discussion=""" <para>Store a µ in a file in one of several <link linkend='Section-Concepts-FileFormats'><varname>formats</varname></link>. The file can be reloaded by <xref linkend='MenuItem-OOF.File.Load.Script'/> or <xref linkend='MenuItem-OOF.File.Load.Data'/>, depending on the file format.</para> """ )) def _fixmenu(*args): import sys if ooflib.common.microstructure.microStructures.nActual() == 0: mainmenu.OOF.File.Save.Microstructure.disable() else: mainmenu.OOF.File.Save.Microstructure.enable() _fixmenu() switchboard.requestCallback(('new who', 'Microstructure'), _fixmenu) switchboard.requestCallback(('remove who', 'Microstructure'), _fixmenu)
## up by default with all of the methods enabled, the "methods" ## parameter needs to be set to a list containing an instance of each ## RationalizeMethod. This list is constructed here, and it's updated ## each time a new RationalizeMethod is created. The update is done ## carefully, so that the id of the list doesn't change, so that the ## RegisteredListParameter still refers to the correct list. def _updateDefaults(): # rebuild list in place. Don't just do "defaults = [...]" ! global defaults del defaults[:] defaults += [reg() for reg in Rationalizer.registry] defaults = [] _updateDefaults() switchboard.requestCallback(Rationalizer, _updateDefaults) ################################################################ class RationalizeMethod(registeredclass.RegisteredClass): registry = [] tip = "Strategies for removing bad elements from a Skeleton" discussion = xmlmenudump.loadFile('DISCUSSIONS/engine/reg/rationalizemethod.xml') ## The Automatic RationalizeMethod applies the rationalizers to *all* ## elements in the target set and picks the best rationalization, or ## reverts to the original element. It has no criteria (minimum ## angles, etc), unlike the Specified RationalizeMethod. class AutomaticRationalization(RationalizeMethod): def rationalize(self, skel, context, targets, criterion):
def __init__(self): debug.mainthreadTest() self.built = False oofGUI.MainPage.__init__( self, name="Microstructure", ordering=10, tip="Define Microstructure and %s Group objects."%Pixstring) vbox = gtk.VBox(spacing=2) self.gtk.add(vbox) align = gtk.Alignment(xalign=0.5) vbox.pack_start(align, expand=0, fill=0) centerbox = gtk.HBox() align.add(centerbox) label=gtk.Label('Microstructure=') label.set_alignment(1.0, 0.5) centerbox.pack_start(label, expand=0, fill=0) self.mswidget = whowidget.WhoWidget(microstructure.microStructures, callback=self.msCB) centerbox.pack_start(self.mswidget.gtk[0], expand=0, fill=0) align = gtk.Alignment(xalign=0.5) # first row of ms buttons vbox.pack_start(align, expand=0, fill=0) self.newbuttonbox = gtk.HBox(homogeneous=0, spacing=3) align.add(self.newbuttonbox) self.newbutton = gtkutils.StockButton(gtk.STOCK_NEW, 'New...') gtklogger.setWidgetName(self.newbutton, "New") gtklogger.connect(self.newbutton,'clicked', self.newEmptyCB) tooltips.set_tooltip_text(self.newbutton, "Create a new microstructure that is NOT associated with images.") self.newbuttonbox.pack_start(self.newbutton, expand=1, fill=1) # Other buttons can be added to the row of "New" buttons by # other modules. When they're added, by addNewButton(), a # function can be specified for sensitizing the button. This # is the list of those functions: self.sensitizeFns = [] # Other modules can contribute strings to be displayed on the # info page. This is the list of # MicrostructurePageInfoPlugIns that retrieve those strings. self.infoplugins = [] align = gtk.Alignment(xalign=0.5) # second row of ms buttons vbox.pack_start(align, expand=0, fill=0) centerbox = gtk.HBox(homogeneous=1, spacing=3) align.add(centerbox) self.renamebutton = gtkutils.StockButton(gtk.STOCK_EDIT, 'Rename...') gtklogger.setWidgetName(self.renamebutton, "Rename") gtklogger.connect(self.renamebutton, 'clicked', self.renameMSCB) tooltips.set_tooltip_text(self.renamebutton, "Rename the current microstructure.") centerbox.pack_start(self.renamebutton, expand=1, fill=1) self.copybutton = gtkutils.StockButton(gtk.STOCK_COPY, 'Copy...') gtklogger.setWidgetName(self.copybutton, "Copy") gtklogger.connect(self.copybutton, 'clicked', self.copyMSCB) tooltips.set_tooltip_text(self.copybutton, "Copy the current microstructure.") centerbox.pack_start(self.copybutton, expand=1, fill=1) self.deletebutton = gtkutils.StockButton(gtk.STOCK_DELETE, 'Delete') gtklogger.setWidgetName(self.deletebutton, "Delete") gtklogger.connect(self.deletebutton, 'clicked', self.deleteMSCB) tooltips.set_tooltip_text(self.deletebutton, "Delete the current microstructure.") centerbox.pack_start(self.deletebutton, expand=1, fill=1) self.savebutton = gtkutils.StockButton(gtk.STOCK_SAVE, 'Save...') gtklogger.setWidgetName(self.savebutton, "Save") gtklogger.connect(self.savebutton, 'clicked', self.saveMSCB) tooltips.set_tooltip_text(self.savebutton, "Save the current microstructure to a file.") centerbox.pack_start(self.savebutton, expand=1, fill=1) pane = gtk.HPaned() gtklogger.setWidgetName(pane, "Pane") vbox.pack_start(pane, expand=1, fill=1, padding=2) gtklogger.connect_passive(pane, 'notify::position') ####### infoframe = gtk.Frame('Microstructure Info') infoframe.set_shadow_type(gtk.SHADOW_IN) pane.pack1(infoframe, resize=True, shrink=False) scroll = gtk.ScrolledWindow() gtklogger.logScrollBars(scroll, "InfoFrameScroll") scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scroll.set_shadow_type(gtk.SHADOW_IN) infoframe.add(scroll) self.infoarea = fixedwidthtext.FixedWidthTextView() self.infoarea.set_editable(0) self.infoarea.set_cursor_visible(False) self.infoarea.set_wrap_mode(gtk.WRAP_WORD) scroll.add(self.infoarea) ######## self.grouplock = lock.Lock() groupframe = gtk.Frame('%s Groups'%Pixstring) gtklogger.setWidgetName(groupframe, "%sGroups"%Pixstring) groupframe.set_shadow_type(gtk.SHADOW_IN) pane.pack2(groupframe, resize=True, shrink=False) hbox = gtk.HBox() groupframe.add(hbox) vbox = gtk.VBox(spacing=2) # buttons on L side of pixel group list hbox.pack_start(vbox, expand=0, fill=0, padding=2) frame = gtk.Frame() # frame for the list of groups frame.set_shadow_type(gtk.SHADOW_IN) hbox.pack_start(frame) grparea = gtk.VBox() frame.add(grparea) # only one of grplist and grpmsg is visible at a time self.grplist = chooser.ScrolledChooserListWidget( # list of pixel groups callback=self.listItemChosen, name="GroupList") grparea.add(self.grplist.gtk) self.grpmsg = gtk.Label() # helpful message when there are no grps grparea.add(self.grpmsg) self.newgroupbutton = gtk.Button('New...') gtklogger.setWidgetName(self.newgroupbutton, "New") vbox.pack_start(self.newgroupbutton, expand=0, fill=0) gtklogger.connect(self.newgroupbutton, 'clicked', self.newGroupButtonCB) tooltips.set_tooltip_text(self.newgroupbutton, "Create a new empty %s group in the current microstructure." % pixstring) self.renamegroupbutton = gtk.Button('Rename...') gtklogger.setWidgetName(self.renamegroupbutton, "Rename") vbox.pack_start(self.renamegroupbutton, expand=0, fill=0) gtklogger.connect(self.renamegroupbutton, 'clicked', self.renameGroupButtonCB) tooltips.set_tooltip_text(self.renamegroupbutton, "Rename the selected %s group." % pixstring) self.copygroupbutton = gtk.Button('Copy...') gtklogger.setWidgetName(self.copygroupbutton, "Copy") vbox.pack_start(self.copygroupbutton, expand=0, fill=0) gtklogger.connect(self.copygroupbutton, 'clicked', self.copyGroupButtonCB) tooltips.set_tooltip_text(self.copygroupbutton, "Create a new group containing the same %ss as the selected group." % pixstring) self.delgroupbutton = gtk.Button('Delete') gtklogger.setWidgetName(self.delgroupbutton, "Delete") vbox.pack_start(self.delgroupbutton, expand=0, fill=0) gtklogger.connect(self.delgroupbutton, 'clicked', self.deleteGroupButtonCB) tooltips.set_tooltip_text(self.delgroupbutton, "Delete the selected %s group from the microstructure." % pixstring) self.delallgroupsbutton = gtk.Button('Delete All') gtklogger.setWidgetName(self.delallgroupsbutton, 'DeleteAll') vbox.pack_start(self.delallgroupsbutton, expand=0, fill=0) gtklogger.connect(self.delallgroupsbutton, 'clicked', self.deleteAllGroupsButtonCB) tooltips.set_tooltip_text(self.delallgroupsbutton, "Delete all pixel groups from the microstructure.") self.meshablebutton = gtk.CheckButton('Meshable') gtklogger.setWidgetName(self.meshablebutton, "Meshable") vbox.pack_start(self.meshablebutton, expand=0, fill=0) self.meshablesignal = gtklogger.connect(self.meshablebutton, 'clicked', self.meshableGroupCB) tooltips.set_tooltip_text(self.meshablebutton, "Should adaptive meshes follow the boundaries of the selected %s group?" % pixstring) # buttons on rhs of pixelgroup list vbox = gtk.VBox(spacing=2) hbox.pack_start(vbox, expand=0, fill=0, padding=2) self.addbutton = gtk.Button('Add') gtklogger.setWidgetName(self.addbutton, "Add") vbox.pack_start(self.addbutton, expand=0, fill=0) gtklogger.connect(self.addbutton, 'clicked', self.addPixelsCB) tooltips.set_tooltip_text(self.addbutton, "Add the currently selected %ss to the selected group." % pixstring) self.removebutton = gtk.Button('Remove') gtklogger.setWidgetName(self.removebutton, "Remove") vbox.pack_start(self.removebutton, expand=0, fill=0) gtklogger.connect(self.removebutton, 'clicked', self.removePixelsCB) tooltips.set_tooltip_text(self.removebutton, "Remove the currently selected %ss from the selected group." % pixstring) self.clearbutton = gtk.Button('Clear') gtklogger.setWidgetName(self.clearbutton, "Clear") vbox.pack_start(self.clearbutton, expand=0, fill=0) gtklogger.connect(self.clearbutton, 'clicked', self.clearPixelsCB) tooltips.set_tooltip_text(self.clearbutton, "Reset the selected group by removing all the %ss from the group." % pixstring) self.infobutton = gtk.Button('Info') gtklogger.setWidgetName(self.infobutton, "Info") vbox.pack_start(self.infobutton, expand=0, fill=0) gtklogger.connect(self.infobutton, 'clicked', self.queryPixelsCB) tooltips.set_tooltip_text(self.infobutton, "Display information about the selected group in the Messages window.") self.built = True self.sbcallbacks = [ switchboard.requestCallback('new pixel group', self.newpixgrp), switchboard.requestCallback('destroy pixel group', self.destpixgrp), # switchboard.requestCallback('changed pixel group', self.destpixgrp), switchboard.requestCallback('changed pixel groups', self.chngdgrps), switchboard.requestCallback(('new who', 'Microstructure'), self.newwhoMS), switchboard.requestCallback(('new who', 'Image'), self.newwhoImage), switchboard.requestCallback(('rename who', 'Image'), self.displayMSInfo), switchboard.requestCallback('remove who', self.removewho), switchboard.requestCallback('renamed pixel group', self.renamepixgrp), switchboard.requestCallback('pixel selection changed', self.selectionchanged), switchboard.requestCallback( 'images changed in microstructure', self.displayMSInfo) ]
def buildImageModMenu_Parallel(): modmenu.clearMenu() for registration in imagemodifier.ImageModifier.registry: params = [parameter.StringParameter('image')] \ + registration.params menuitem = modmenu.addItem( oofmenu.OOFMenuItem(registration.name(), callback=doImageMod_Parallel, secret = 1, no_log = 1, threadable = oofmenu.PARALLEL_THREADABLE, params=params) ) menuitem.data = registration switchboard.requestCallback(imagemodifier.ImageModifier, buildImageModMenu_Parallel) buildImageModMenu_Parallel() ##################################### ## createPixelGroups_Parallel is currently broken, because the ## non-parallel version was modified to have a name_template argument. ## Group names can no longer be inferred simply from the pixel color. ## There will have to be some way of resolving conflicts when two ## processors both want to create 'group6' using different pixel ## colors. def createPixelGroups_Parallel(menuitem, image, name_template): # For the back-end processes global _rank if _rank == 0:
def __init__(self, skeletoncontext): skeletonselectable.SelectionBase.__init__(self, skeletoncontext) self.stack = ringbuffer.RingBuffer(stacksize) self.stack.push(PinnedNodeSet(self.skeletoncontext)) self.sbcallbacks.append(switchboard.requestCallback( 'pinnednode ringbuffer resize', self.setUndoBufferSizeCB))
def __init__(self, *args, **kwargs): GenericGroupSet.__init__(self, *args, **kwargs) self.materials = {} switchboard.requestCallback("remove_material", self.removeMatlCB)
try: help = registration.tip except AttributeError: help = None params = [whoville.WhoParameter('image', whoville.getClass('Image'), tip=parameter.emptyTipString)] \ + registration.params menuitem = imagemodmenu.addItem( oofmenu.OOFMenuItem(registration.name(), callback=imagemodifier.doImageMod, params=params, help=help, discussion=registration.discussion)) menuitem.data = registration switchboard.requestCallback(imagemodifier.ImageModifier, buildImageModMenu) buildImageModMenu() ################################### # Size params are reused several times sizeparams = parameter.ParameterGroup( parameter.AutoNumericParameter('height', automatic.automatic, tip= \ "Physical height of image, or 'automatic'."), parameter.AutoNumericParameter('width', automatic.automatic, tip= \ "Physical width of image, or 'automatic'."))
gfxwindow.draw() def addToGfxSettings(gfxwindow): item = gfxwindow.menu.Settings.addItem( oofmenu.CheckOOFMenuItem( 'Hide_Empty_Mesh_Elements', callback=toggleEmptyDrawing, value=gfxwindow.settings.hideEmptyElements, help="Toggle the display of elements with no Material.", discussion=xmlmenudump.loadFile( 'DISCUSSIONS/common/menu/hideempty.xml'))) item.data = gfxwindow switchboard.requestCallback('open graphics window', addToGfxSettings) ghostgfxwindow.defineGfxSetting('hideEmptyElements', True) ################## # Common mesh display parameters. meshdispparams = [ placeholder.TimeParameter('when', value=placeholder.latest, tip='Time at which to plot'), output.PositionOutputParameter( 'where', outputDefs.originalPosition, tip="Plot at displaced or original position?") ]
def toggleEmptyDrawing(menuitem, hideEmpty): gfxwindow = menuitem.data gfxwindow.settings.hideEmptyElements = hideEmpty gfxwindow.draw() def addToGfxSettings(gfxwindow): item = gfxwindow.menu.Settings.addItem(oofmenu.CheckOOFMenuItem( 'Hide_Empty_Mesh_Elements', callback=toggleEmptyDrawing, value=gfxwindow.settings.hideEmptyElements, help="Toggle the display of elements with no Material.", discussion=xmlmenudump.loadFile('DISCUSSIONS/common/menu/hideempty.xml'))) item.data = gfxwindow switchboard.requestCallback('open graphics window', addToGfxSettings) ghostgfxwindow.defineGfxSetting('hideEmptyElements', True) ################## # Common mesh display parameters. meshdispparams = [ placeholder.TimeParameter( 'when', value=placeholder.latest, tip='Time at which to plot'), output.PositionOutputParameter( 'where', outputDefs.originalPosition, tip="Plot at displaced or original position?") ]