def __init__(self, progress): debug.mainthreadTest() self.lock = lock.Lock() progressbar.ProgressBar.__init__(self, progress) self.dismissable = False progress.setProgressBar(self) self.gtk = gtk.Frame() self.gtk.set_shadow_type(gtk.SHADOW_IN) vbox = gtk.VBox(spacing=2) self.gtk.add(vbox) hbox = gtk.HBox(spacing=2) vbox.pack_start(hbox, expand=0, fill=0, padding=2) self.gtkprogressbar = gtk.ProgressBar() self.gtkprogressbar.set_orientation(gtk.PROGRESS_LEFT_TO_RIGHT) hbox.pack_start(self.gtkprogressbar, expand=1, fill=1) self.stopbutton = gtkutils.StockButton(gtk.STOCK_STOP, "Stop") gtklogger.setWidgetName(self.stopbutton, "Stop%d" % self.idcounter) self.idcounter += 1 gtklogger.connect(self.stopbutton, 'clicked', self.stopButtonCB) hbox.pack_start(self.stopbutton, expand=0, fill=0) self.timeout_id = None
def __init__(self, name, gfxmgr, clone=0): debug.subthreadTest() self.gfxlock = lock.Lock() mainthread.runBlock(self.preinitialize, (name, gfxmgr, clone)) self.newCanvas() ghostgfxwindow.GhostGfxWindow.__init__(self, name, gfxmgr, clone=clone) mainthread.runBlock(self.postinitialize, (name, gfxmgr, clone))
def __init__(self, name, classname, obj, parent, secretFlag=0): self._name = name self._obj = obj self.classname = classname # not necessarily the Python class name, # but just a name to be listed in GUI. self.parent = parent self.switchboardCallbacks = [] # self.timestamp = timestamp.TimeStamp() ## Locking variables self.have_reservation = 0 ## Locking methods. self.reservation_lock = lock.Lock( ) ## holds the Who writing privileges # Create an rwlock. Subclasses may share this lock with their # contained objects. self.rwLock = lock.RWLock() ## secret flag for hiding it from the user ## TODO 3.1: For some situation where this who object need to ## be secret for some kind of display and not for another the ## boolean type would not be enough. We will have to think of ## another structure to handle different kind of display and ## different kind of secrecy for those displays. self.secretFlag = secretFlag
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, alpha, min, max, colormap): self.alpha = alpha self.colormap = colormap self.max = max self.min = min self.vmax = None self.vmin = None self.contourmaphidden = False self.lock = lock.Lock() SkeletonDisplayMethod.__init__(self)
def __init__(self, alpha, min, max, colormap, filter): self.alpha = alpha self.colormap = colormap self.max = max # parameter value self.min = min # parameter value self.vmax = None self.vmin = None self.contourmaphidden = False self.lock = lock.Lock() SolidFillMeshDisplay.__init__(self) SkeletonDisplayMethod.__init__(self, filter)
def __init__(self): global menu self.menu = menu # The state of the editor is kept in a LayerSet, which is the # layer currently being edited. Because it's possible to set # the WhoClass in the editor without specifying a Who, and # because a LayerSet only contains a Who, it's necessary to # keep a separate currentWhoClass variable. self.currentLayerSet = display.LayerSet(whoville.nobody) self.currentWhoClass = whoville.noclass self.lock = lock.Lock()
def __init__(self, name, classname, obj, parent, secretFlag=0): self._name = name self._obj = obj self.classname = classname # not necessarily the Python class name, # but just a name to be listed in GUI. self.parent = parent self.switchboardCallbacks = [] self.timestamp = timestamp.TimeStamp() ## Locking variables self.have_reservation = 0 ## Locking methods. self.reservation_lock = lock.Lock( ) ## holds the Who writing privileges # Create an rwlock. Subclasses may share this lock with their # contained objects. self.rwLock = lock.RWLock() ## secret flag for hiding it from the user self.secretFlag = secretFlag
time.sleep(naptime) naptime *= napfactor if naptime > maxnap: naptime = maxnap # end while not worker.finished except KeyboardInterrupt: self.worker.threadstate.impedeProgress() # Wait for thread to finish before OOF-ing some more. Text # mode doesn't support concurrent operations. self.join() ############################### mpiLock = lock.Lock() ## this lock is necessary because MPI does not ## support more than one subthread at a ## time, without running the risk of dead-locking. In order ## to avoid this potential deadlocking ## problem, every parallel worker ## acquires a lock and releases it upon ## completion of the assigned task. ## the MPI lock will not be necessary ## anymore when a fully threadable ## implementation of MPI becomes ## available (MPI-2?). ##################################
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()
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) self.renamebutton.set_sensitive(0) 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) self.copybutton.set_sensitive(0) 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) self.deletebutton.set_sensitive(0) 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) self.savebutton.set_sensitive(0) 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) self.newgroupbutton.set_sensitive(0) 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) self.renamegroupbutton.set_sensitive(0) 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) self.copygroupbutton.set_sensitive(0) 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) self.delgroupbutton.set_sensitive(0) tooltips.set_tooltip_text( self.delgroupbutton, "Delete the selected %s group from the microstructure." % pixstring) 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) self.meshablebutton.set_sensitive(0) 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) self.addbutton.set_sensitive(0) 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) self.removebutton.set_sensitive(0) 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) self.clearbutton.set_sensitive(0) 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) self.infobutton.set_sensitive(0) 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) ]
# available (in PDF form, of course) from # <http://partners.adobe.com/public/developer/pdf/index_reference.html>. # # PDF data structures and operators are copyright by Adobe Systems # Incorporated, used with permission granted by section 1.5 of the # PDF reference manual. unitscale = {} unitscale['points'] = 1 unitscale['inches'] = 72.00 unitscale['cm'] = 28.346456693 # Line width is always in points -- the factor expresses the width # provided in points in the current user-coordinate-system units. linewidth_factor = 1.0 linewidth_lock = lock.Lock() def set_linewidth_factor(value): global linewidth_factor linewidth_lock.acquire() linewidth_factor = value linewidth_lock.release() def get_linewidth_factor(): global linewidth_factor linewidth_lock.acquire() res = linewidth_factor linewidth_lock.release() return res
def __init__(self, movenodetoolbox): debug.mainthreadTest() self.downed = 0 # is the mouse button down? self.moving = 0 # in the middle of a move self.movingnode = None # node being moved # writable should only be set by self.set_writable, which # issues a checkpoint. self.writable = True # is the top most Skeleton writable? self.mode = "Mouse" self.mouselock = lock.Lock() toolboxGUI.GfxToolbox.__init__(self, "Move Nodes", movenodetoolbox) mainbox = gtk.VBox() self.gtk.add(mainbox) hbox = gtk.HBox() mainbox.pack_start(hbox, expand=0, fill=0) gtklogger.setWidgetName(hbox, "MoveWith") hbox.pack_start(gtk.Label("Move with: "), expand=0, fill=0) modes = [("Mouse", "Click and drag a node to move it."), ("Keyboard", "Select a node, type a position, and click the Move button")] self.modebuttons = [] for mode, tip in modes: if self.modebuttons: button = gtk.RadioButton(label=mode, group=self.modebuttons[0]) else: button = gtk.RadioButton(label=mode) gtklogger.setWidgetName(button, mode) self.modebuttons.append(button) tooltips.set_tooltip_text(button, tip) hbox.pack_start(button, expand=0, fill=0) button.set_active(self.mode is mode) gtklogger.connect(button, 'clicked', self.changeMode, mode) # allow illegal move? self.allow_illegal = gtk.CheckButton("Allow illegal moves") gtklogger.setWidgetName(self.allow_illegal, "AllowIllegal") mainbox.pack_start(self.allow_illegal, expand=0, fill=0, padding=1) mainbox.pack_start(gtk.HSeparator(), expand=0, fill=0, padding=3) gtklogger.connect(self.allow_illegal, "clicked", self.illegal_status) if movenodetoolbox.allow_illegal: self.allow_illegal.set_active(1) else: self.allow_illegal.set_active(0) if config.dimension() == 2: self.table = gtk.Table(columns=2, rows=6) r = 2 elif config.dimension() == 3: self.table = gtk.Table(columns=2, rows=8) r = 3 mainbox.pack_start(self.table, expand=0, fill=0) label = gtk.Label('x=') label.set_alignment(1.0, 0.5) self.table.attach(label, 0, 1, 0, 1, xpadding=5, xoptions=gtk.FILL) self.xtext = gtk.Entry() gtklogger.setWidgetName(self.xtext, "x") self.xsignal = gtklogger.connect_passive(self.xtext, 'changed') self.xtext.set_size_request(12 * guitop.top().digitsize, -1) self.xtext.set_editable(1) self.table.attach(self.xtext, 1, 2, 0, 1, xpadding=5, xoptions=gtk.EXPAND | gtk.FILL) tooltips.set_tooltip_text(self.xtext, "x position of the mouse") label = gtk.Label('y=') label.set_alignment(1.0, 0.5) self.table.attach(label, 0, 1, 1, 2, xpadding=5, xoptions=gtk.FILL) self.ytext = gtk.Entry() gtklogger.setWidgetName(self.ytext, 'y') self.ysignal = gtklogger.connect_passive(self.ytext, 'changed') self.ytext.set_size_request(12 * guitop.top().digitsize, -1) self.ytext.set_editable(1) self.table.attach(self.ytext, 1, 2, 1, 2, xpadding=5, xoptions=gtk.EXPAND | gtk.FILL) tooltips.set_tooltip_text(self.ytext, "y position of the mouse") if config.dimension() == 3: label = gtk.Label('z=') label.set_alignment(1.0, 0.5) self.table.attach(label, 0, 1, 2, 3, xpadding=5, xoptions=gtk.FILL) self.ztext = gtk.Entry() gtklogger.setWidgetName(self.ztext, 'z') self.zsignal = gtklogger.connect_passive(self.ztext, 'changed') self.ztext.set_size_request(12 * guitop.top().digitsize, -1) self.ztext.set_editable(1) self.table.attach(self.ztext, 1, 2, 2, 3, xpadding=5, xoptions=gtk.EXPAND | gtk.FILL) tooltips.set_tooltip_text(self.ztext, "z position of the mouse") label = gtk.Label("Change in... ") label.set_alignment(1.0, 0.5) self.table.attach(label, 0, 1, r, r + 1, xpadding=4, xoptions=gtk.EXPAND | gtk.FILL) label = gtk.Label("shape energy=") label.set_alignment(1.0, 0.5) self.table.attach(label, 0, 1, r + 1, r + 2, xpadding=5, xoptions=gtk.FILL) self.shapetext = gtk.Entry() self.shapetext.set_editable(0) gtklogger.setWidgetName(self.shapetext, "shape") self.shapetext.set_size_request(12 * guitop.top().digitsize, -1) self.table.attach(self.shapetext, 1, 2, r + 1, r + 2, xpadding=5, xoptions=gtk.EXPAND | gtk.FILL) tooltips.set_tooltip_text(self.shapetext, "total change in shape energy") label = gtk.Label("homogeneity=") label.set_alignment(1.0, 0.5) self.table.attach(label, 0, 1, r + 2, r + 3, xpadding=5, xoptions=gtk.FILL) self.homogtext = gtk.Entry() self.homogtext.set_editable(0) gtklogger.setWidgetName(self.homogtext, "homog") self.homogtext.set_size_request(12 * guitop.top().digitsize, -1) self.table.attach(self.homogtext, 1, 2, r + 2, r + 3, xpadding=5, xoptions=gtk.EXPAND | gtk.FILL) tooltips.set_tooltip_text(self.homogtext, "total change in homogeneity") mainbox.pack_start(gtk.HSeparator(), expand=0, fill=0, padding=3) self.statusText = gtk.Label() gtklogger.setWidgetName(self.statusText, "Status") mainbox.pack_start(self.statusText, expand=0, fill=0, padding=3) bbox = gtk.HBox(homogeneous=1, spacing=2) mainbox.pack_end(bbox, expand=0, fill=0, padding=3) self.undobutton = gtk.Button(stock=gtk.STOCK_UNDO) tooltips.set_tooltip_text(self.undobutton, "Undo the latest node move.") self.movebutton = gtk.Button('Move') tooltips.set_tooltip_text( self.movebutton, "Move the selected node to the specified position.") self.redobutton = gtk.Button(stock=gtk.STOCK_REDO) tooltips.set_tooltip_text(self.redobutton, "Redo the latest UNDO.") gtklogger.setWidgetName(self.undobutton, 'Undo') gtklogger.setWidgetName(self.redobutton, 'Redo') gtklogger.setWidgetName(self.movebutton, 'Move') bbox.pack_start(self.undobutton, expand=1, fill=1) bbox.pack_start(self.movebutton, expand=1, fill=1) bbox.pack_start(self.redobutton, expand=1, fill=1) gtklogger.connect(self.undobutton, 'clicked', self.undoCB) gtklogger.connect(self.movebutton, 'clicked', self.moveCB) gtklogger.connect(self.redobutton, 'clicked', self.redoCB) self.sbcallbacks = [ switchboard.requestCallbackMain(('who changed', 'Skeleton'), self.skelChanged), switchboard.requestCallbackMain("made reservation", self.rsrvChanged, 1), switchboard.requestCallbackMain("cancelled reservation", self.rsrvChanged, 0), switchboard.requestCallbackMain(("node selected", movenodetoolbox), self.nodeSelected), switchboard.requestCallbackMain( ("illegal-move status changed", movenodetoolbox), self.illegal_status_changed), switchboard.requestCallbackMain( ("skeleton changed", movenodetoolbox), self.layersChanged) ] self.move_info(None, '---', '---', '')
def __init__(self, pinnodestoolbox): debug.mainthreadTest() toolboxGUI.GfxToolbox.__init__(self, pinnodestoolbox) mainbox = gtk.VBox() self.gtk.add(mainbox) infoframe = gtk.Frame() mainbox.pack_start(infoframe, expand=0, fill=0) info = gtk.Label("""Click a node to pin it. Shift-click to pin additional nodes. Ctrl-click to toggle a node. Shift-ctrl-click to unpin a node.""") infoframe.add(info) self.updateLock = lock.Lock() self.table = gtk.Table(columns=3, rows=4) r = 0 mainbox.pack_start(self.table, expand=0, fill=0) label = gtk.Label("Node") label.set_alignment(1.0, 0.5) self.table.attach(label, 0, 1, r, r + config.dimension(), xpadding=2, xoptions=0) label = gtk.Label('x=') label.set_alignment(1.0, 0.5) self.table.attach(label, 1, 2, r, r + 1, xpadding=2, xoptions=gtk.FILL) self.nodextext = gtk.Entry() gtklogger.setWidgetName(self.nodextext, "Node X") self.nodextext.set_size_request(12 * guitop.top().digitsize, -1) self.nodextext.set_editable(0) self.table.attach(self.nodextext, 2, 3, r, r + 1, xpadding=2, xoptions=gtk.EXPAND | gtk.FILL) r += 1 label = gtk.Label('y=') label.set_alignment(1.0, 0.5) self.table.attach(label, 1, 2, r, r + 1, xpadding=2, xoptions=gtk.FILL) self.nodeytext = gtk.Entry() gtklogger.setWidgetName(self.nodeytext, "Node Y") self.nodeytext.set_size_request(12 * guitop.top().digitsize, -1) self.nodeytext.set_editable(0) self.table.attach(self.nodeytext, 2, 3, r, r + 1, xpadding=2, xoptions=gtk.EXPAND | gtk.FILL) r += 1 label = gtk.Label('z=') label.set_alignment(1.0, 0.5) self.table.attach(label, 1, 2, r, r + 1, xpadding=2, xoptions=gtk.FILL) self.nodeztext = gtk.Entry() gtklogger.setWidgetName(self.nodeztext, "Node Z") self.nodeztext.set_size_request(12 * guitop.top().digitsize, -1) self.nodeztext.set_editable(0) self.table.attach(self.nodeztext, 2, 3, r, r + 1, xpadding=2, xoptions=gtk.EXPAND | gtk.FILL) r += 1 self.pintext = gtk.Label() gtklogger.setWidgetName(self.pintext, "Pin Label") self.pintext.set_alignment(0.0, 0.5) self.table.attach(self.pintext, 2, 3, r, r + 1, xpadding=5, xoptions=gtk.EXPAND | gtk.FILL) modbox = gtk.VBox() mainbox.pack_end(modbox, expand=0, fill=0) bbox1 = gtk.HBox(homogeneous=True, spacing=2) modbox.pack_end(bbox1, 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 action.") bbox1.pack_start(self.undobutton, expand=1, fill=1) self.redobutton = gtk.Button(stock=gtk.STOCK_REDO) gtklogger.setWidgetName(self.redobutton, 'Redo') gtklogger.connect(self.redobutton, "clicked", self.redoCB) tooltips.set_tooltip_text(self.redobutton, "Redo the latest undone action.") bbox1.pack_start(self.redobutton, expand=1, fill=1) bbox2 = gtk.HBox(homogeneous=True, spacing=2) modbox.pack_end(bbox2, expand=0, fill=0, padding=2) self.unpinallbutton = gtk.Button("Unpin All") gtklogger.setWidgetName(self.unpinallbutton, 'UnPinAll') gtklogger.connect(self.unpinallbutton, "clicked", self.unpinallCB) tooltips.set_tooltip_text(self.unpinallbutton, "Unpin all the pinned nodes.") bbox2.pack_start(self.unpinallbutton, expand=1, fill=1) self.invertbutton = gtk.Button("Invert") gtklogger.setWidgetName(self.invertbutton, 'Invert') gtklogger.connect(self.invertbutton, "clicked", self.invertCB) tooltips.set_tooltip_text( self.invertbutton, "Invert - pin the unpinned and unpin the pinned.") bbox2.pack_start(self.invertbutton, expand=1, fill=1) self.status = gtk.Label() gtklogger.setWidgetName(self.status, "Status") self.status.set_alignment(0.0, 0.5) mainbox.pack_end(self.status, expand=0, fill=0, padding=5) self.sbcallbacks = [ switchboard.requestCallbackMain(('who changed', 'Skeleton'), self.skelChanged), switchboard.requestCallbackMain( (self.gfxwindow(), 'layers changed'), self.update), switchboard.requestCallbackMain("new pinned nodes", self.newPinState) ]