def _createView(self): """Set up a view for the traits.""" items = [] if self.showProgressBar: items.append(Item('progress', show_label=False, editor=ProgressEditor(callback=self._seek))) # Controls items.append( alignCenter( Item('backwardButton', style='custom', enabled_when='not object.running and object.mainloopRunning ' +'and object.sensors and object.iteration > 1'), Item('runButton', style='custom', enabled_when='object.pause and not object.done'), Item('pauseButton', style='custom', enabled_when='not (object.pause or object.done)'), Item('stepButton', style='custom', enabled_when='object.pause and not object.done'), show_labels=False, orientation='horizontal' )) # Repeat button and pause target buttons items.append( alignCenter( Item('repeatButton', show_label=False, enabled_when='not object.running and object.mainloopRunning ' 'and object.iteration > 0'), Item('nextTargetButton', show_label=False, editor=ButtonEditor(label_value='targetButtonLabel'), enabled_when='not object.running and object.mainloopRunning ' 'and object.pauseTarget'), Item('customTargetButton', show_label=False, enabled_when='not object.running and object.mainloopRunning') )) # Speed control items.append(Item('speed', style='custom', show_label=False, editor=EnumEditor(cols=1, values={ 1 : '1: Slow (update on every iteration)', 10 : '2: Medium (update every 10 iterations)', 100 : '3: Fast (update every 100 iterations)' }) )) items.extend([ Group( Item('pauseAtNextStep'), show_left=False ), alignLeft( Item('stopButton', show_label=False, enabled_when='object.iteration') ) ]) self.traits_view = View(*items)
def createView(self, displayWidth=None, displayHeight=None): """ Set up a view for the traits. """ if displayWidth is None: displayWidth = self._stdDisplayWidth if displayHeight is None: displayHeight = self._stdDisplayHeight # Build category dict catValues = {} for k, catName in enumerate(self.catNames): catValues["cat%04d" % k] = "%d: %s" % (k, catName) self.catIndex = 0 # Gabor related traits if self._hasGabor: # Get response properties phaseMode = self._gaborProxy._phaseMode if phaseMode == 'dual': numPhases = 2 else: assert phaseMode == 'single' numPhases = 1 centerSurround = self._gaborP_centerSurround numOrientations = self._gaborP._numOrientations # Build orientation dict numGaborOrients = self._gaborProxy.getNumPlanes() orientValues = {"all": "00: Composite"} for k in xrange(numOrientations): orientValues["orient%04d" % k] = "%02d: %d Degrees" % (k+1, k * 180.0/numOrientations) if centerSurround: orientValues["centerSurround"] = "%02d: Center Surround" % (numOrientations + 1) self._gaborOrient = 'all' # Build phase dict phaseValues = {} for k, phaseName in enumerate(['Positive', 'Negative'][:numPhases]): phaseValues[phaseName] = "%d: Phase %s" % (k+1, phaseName) self._gaborPhase = 0 self._numGaborPhases = numPhases # Build scale dict scaleValues = {} for k, scale in enumerate(self.scales): scaleValues["scale%04d" % k] = "%d: Scale %.2f%%" % (k+1, 100.0 * scale) #self._gaborScale = scaleValues["scale0000"] self._gaborScale = 0 self._numGaborScales = len(scaleValues) # @todo -- much of this can/should be commonized loadLogGroupPixel = Group( alignLeft( Item('mode', style='custom', show_label=False, editor=EnumEditor(cols=1, values={ 'filteredByCat': '1: Single-category matches', 'singleProtoPerCat': '2: Single best match per category', 'unfiltered': '3: Raw best matches', })) ), alignLeft( Item('category', show_label=False, editor=EnumEditor(values=catValues)) ), alignLeft( Item('loadLogFile', show_label=False, editor=FileOrDirectoryEditor(buttonLabel="Load log directory...", directory=True)) ), Item('numPrototypes', style='readonly'), label='Display Settings', show_border=True, show_labels=False, orientation='horizontal', ) if self._hasGabor: if self._numGaborPhases > 1: if self._numGaborScales > 1: # Multi-phase/Multi-scale gaborItems = Group(Item('orientation', show_label=False, editor=EnumEditor(values=orientValues)), Item('phase', show_label=False, editor=EnumEditor(values=phaseValues)), Item('scale', show_label=False, editor=EnumEditor(values=scaleValues)), ) else: # Multi-phase/single-scale gaborItems = Group(Item('orientation', show_label=False, editor=EnumEditor(values=orientValues)), Item('phase', show_label=False, editor=EnumEditor(values=phaseValues)), ) else: if self._numGaborScales > 1: # Single-phase/Multi-scale gaborItems = Group(Item('orientation', show_label=False, editor=EnumEditor(values=orientValues)), Item('scale', show_label=False, editor=EnumEditor(values=scaleValues)), ) else: # Single-phase/Single-scale gaborItems = Item('orientation', show_label=False, editor=EnumEditor(values=orientValues)) loadLogGroupGabor = Group( alignLeft( Item('mode', style='custom', show_label=False, editor=EnumEditor(cols=1, values={ 'filteredByCat': '1: Single-category matches', 'singleProtoPerCat': '2: Single best match per category', 'unfiltered': '3: Raw best matches', })) ), alignLeft( Item('category', show_label=False, editor=EnumEditor(values=catValues)) ), alignLeft( Item('loadLogFile', show_label=False, editor=FileOrDirectoryEditor(buttonLabel="Load log directory...", directory=True)) ), Item('numPrototypes', style='readonly'), alignLeft( gaborItems #Item('orientation', show_label=False, # editor=EnumEditor(values=orientValues)) ), label='Display Settings', show_border=True, show_labels=False, orientation='horizontal', ) # Create image panes pixelItems = self._createImagePane('pixel', displayWidth, displayHeight) if self._hasGabor: gaborItems = self._createImagePane('gabor', displayWidth, displayHeight) neighborsPixelGroup = Group(pixelItems[0], pixelItems[1], pixelItems[2], pixelItems[3], pixelItems[4], label="Neighbors in Pixel Space", show_border=True, orientation='horizontal') if self._hasGabor: neighborsGaborGroup = Group(gaborItems[0], gaborItems[1], gaborItems[2], gaborItems[3], gaborItems[4], label="Neighbors in Gabor Space", show_border=True, orientation='horizontal') tabPixel = Group(loadLogGroupPixel, neighborsPixelGroup, label='Pixel Space') if self._hasGabor: tabGabor = Group(loadLogGroupGabor, neighborsGaborGroup, label='Gabor Space') self.traits_view = View( tabPixel, tabGabor, handler=NearestNeighborHandler, ) else: self.traits_view = View( tabPixel, handler=NearestNeighborHandler, )
def createView(self, displayWidth=None, displayHeight=None): """ Set up a view for the traits. """ if displayWidth is None: displayWidth = self._stdDisplayWidth if displayHeight is None: displayHeight = self._stdDisplayHeight # Build category dict catValues = {} for k, catName in enumerate(self.catNames): catValues["cat%04d" % k] = "%d: %s" % (k, catName) self.catIndex = 0 # Gabor related traits if self._hasGabor: # Get response properties phaseMode = self._gaborProxy._phaseMode if phaseMode == 'dual': numPhases = 2 else: assert phaseMode == 'single' numPhases = 1 centerSurround = self._gaborP_centerSurround numOrientations = self._gaborP._numOrientations # Build orientation dict numGaborOrients = self._gaborProxy.getNumPlanes() orientValues = {"all": "00: Composite"} for k in xrange(numOrientations): orientValues["orient%04d" % k] = "%02d: %d Degrees" % (k + 1, k * 180.0 / numOrientations) if centerSurround: orientValues["centerSurround"] = "%02d: Center Surround" % ( numOrientations + 1) self._gaborOrient = 'all' # Build phase dict phaseValues = {} for k, phaseName in enumerate(['Positive', 'Negative'][:numPhases]): phaseValues[phaseName] = "%d: Phase %s" % (k + 1, phaseName) self._gaborPhase = 0 self._numGaborPhases = numPhases # Build scale dict scaleValues = {} for k, scale in enumerate(self.scales): scaleValues["scale%04d" % k] = "%d: Scale %.2f%%" % (k + 1, 100.0 * scale) #self._gaborScale = scaleValues["scale0000"] self._gaborScale = 0 self._numGaborScales = len(scaleValues) # @todo -- much of this can/should be commonized loadLogGroupPixel = Group( alignLeft( Item('mode', style='custom', show_label=False, editor=EnumEditor(cols=1, values={ 'filteredByCat': '1: Single-category matches', 'singleProtoPerCat': '2: Single best match per category', 'unfiltered': '3: Raw best matches', }))), alignLeft( Item('category', show_label=False, editor=EnumEditor(values=catValues))), alignLeft( Item('loadLogFile', show_label=False, editor=FileOrDirectoryEditor( buttonLabel="Load log directory...", directory=True))), Item('numPrototypes', style='readonly'), label='Display Settings', show_border=True, show_labels=False, orientation='horizontal', ) if self._hasGabor: if self._numGaborPhases > 1: if self._numGaborScales > 1: # Multi-phase/Multi-scale gaborItems = Group( Item('orientation', show_label=False, editor=EnumEditor(values=orientValues)), Item('phase', show_label=False, editor=EnumEditor(values=phaseValues)), Item('scale', show_label=False, editor=EnumEditor(values=scaleValues)), ) else: # Multi-phase/single-scale gaborItems = Group( Item('orientation', show_label=False, editor=EnumEditor(values=orientValues)), Item('phase', show_label=False, editor=EnumEditor(values=phaseValues)), ) else: if self._numGaborScales > 1: # Single-phase/Multi-scale gaborItems = Group( Item('orientation', show_label=False, editor=EnumEditor(values=orientValues)), Item('scale', show_label=False, editor=EnumEditor(values=scaleValues)), ) else: # Single-phase/Single-scale gaborItems = Item('orientation', show_label=False, editor=EnumEditor(values=orientValues)) loadLogGroupGabor = Group( alignLeft( Item('mode', style='custom', show_label=False, editor=EnumEditor( cols=1, values={ 'filteredByCat': '1: Single-category matches', 'singleProtoPerCat': '2: Single best match per category', 'unfiltered': '3: Raw best matches', }))), alignLeft( Item('category', show_label=False, editor=EnumEditor(values=catValues))), alignLeft( Item('loadLogFile', show_label=False, editor=FileOrDirectoryEditor( buttonLabel="Load log directory...", directory=True))), Item('numPrototypes', style='readonly'), alignLeft( gaborItems #Item('orientation', show_label=False, # editor=EnumEditor(values=orientValues)) ), label='Display Settings', show_border=True, show_labels=False, orientation='horizontal', ) # Create image panes pixelItems = self._createImagePane('pixel', displayWidth, displayHeight) if self._hasGabor: gaborItems = self._createImagePane('gabor', displayWidth, displayHeight) neighborsPixelGroup = Group(pixelItems[0], pixelItems[1], pixelItems[2], pixelItems[3], pixelItems[4], label="Neighbors in Pixel Space", show_border=True, orientation='horizontal') if self._hasGabor: neighborsGaborGroup = Group(gaborItems[0], gaborItems[1], gaborItems[2], gaborItems[3], gaborItems[4], label="Neighbors in Gabor Space", show_border=True, orientation='horizontal') tabPixel = Group(loadLogGroupPixel, neighborsPixelGroup, label='Pixel Space') if self._hasGabor: tabGabor = Group(loadLogGroupGabor, neighborsGaborGroup, label='Gabor Space') self.traits_view = View( tabPixel, tabGabor, handler=NearestNeighborHandler, ) else: self.traits_view = View( tabPixel, handler=NearestNeighborHandler, )
def _createView(self): """Set up a view for the traits.""" items = [] if self.showProgressBar: items.append( Item('progress', show_label=False, editor=ProgressEditor(callback=self._seek))) # Controls items.append( alignCenter(Item( 'backwardButton', style='custom', enabled_when='not object.running and object.mainloopRunning ' + 'and object.sensors and object.iteration > 1'), Item('runButton', style='custom', enabled_when='object.pause and not object.done'), Item('pauseButton', style='custom', enabled_when='not (object.pause or object.done)'), Item('stepButton', style='custom', enabled_when='object.pause and not object.done'), show_labels=False, orientation='horizontal')) # Repeat button and pause target buttons items.append( alignCenter( Item( 'repeatButton', show_label=False, enabled_when='not object.running and object.mainloopRunning ' 'and object.iteration > 0'), Item( 'nextTargetButton', show_label=False, editor=ButtonEditor(label_value='targetButtonLabel'), enabled_when='not object.running and object.mainloopRunning ' 'and object.pauseTarget'), Item( 'customTargetButton', show_label=False, enabled_when='not object.running and object.mainloopRunning' ))) # Speed control items.append( Item('speed', style='custom', show_label=False, editor=EnumEditor( cols=1, values={ 1: '1: Slow (update on every iteration)', 10: '2: Medium (update every 10 iterations)', 100: '3: Fast (update every 100 iterations)' }))) items.extend([ Group(Item('pauseAtNextStep'), show_left=False), alignLeft( Item('stopButton', show_label=False, enabled_when='object.iteration')) ]) self.traits_view = View(*items)