def removeAll(self): self.outputs = [] # list, so GUI can present them in creation order ## Use OrderedSets and OrderedDicts instead of sets and dicts ## so that the order of outputs is repeatable, which makes ## testing much easier. self.nexttimes = utils.OrderedDict() # next time to perform each output self.nextoutputs = utils.OrderedSet() # outputs to perform at next time self.conditionalOutputs = utils.OrderedSet() self.nexttime = None self.finished = set()
def reset(self, time0, continuing): # Reset all output schedules, and advance them to the first # time after time0 (which is the earliest time in the current # evolution). self.finished.clear() self.nexttimes = utils.OrderedDict() self.nexttime = None self.nextoutputs.clear() self.conditionalOutputs.clear() for output in self.outputs: if (output.active and output.fullyDefined()): output.schedule.reset(continuing) output.start(self.meshcontext, time0, continuing) if output.schedule.conditional: self.conditionalOutputs.add(output) else: try: t = roundOffCheck(output.schedule.next(), time0) if continuing: while t <= time0: t = output.schedule.next() else: while t < time0: t = output.schedule.next() except StopIteration: # The schedule has no times in it later than time0. # Just ignore it. pass else: self.nexttimes[output] = t if self.nexttime is None or t < self.nexttime: self.nexttime = t self.nextoutputs = utils.OrderedSet( [o for (o,t) in self.nexttimes.items() if t == self.nexttime])
def __init__(self, groups=[], defaults=utils.OrderedSet(), scope=None, name=None): self.defaults = defaults self.widget = chooser.ChooserWidget(groups, self.selectCB, name=name) parameterwidgets.ParameterWidget.__init__(self, self.widget.gtk, scope) self.skelmeshwidget = scope.findWidget( lambda w: (isinstance(w, whowidget.WhoWidget) and (w.whoclass is skeletoncontext.skeletonContexts or w. whoclass is mesh.meshes))) assert self.skelmeshwidget is not None self.sbcallbacks = [ switchboard.requestCallbackMain(self.skelmeshwidget, self.skelwidgetCB) ] self.update() self.sbcallbacks += [ switchboard.requestCallbackMain("groupset member added", self.grpCB), switchboard.requestCallbackMain("groupset member renamed", self.grpCB), switchboard.requestCallbackMain("groupset changed", self.grpCB) ] self.widgetChanged(self.widget.nChoices() > 0, interactive=0)
def __init__(self, param, groups=[], scope=None, name=None): SkeletonGroupWidget.__init__(self, groups, defaults=utils.OrderedSet( [placeholder.selection.IDstring]), scope=scope, name=name)
def __init__(self, param, groups=[], scope=None, name=None): SkeletonGroupWidget.__init__(self, param, groups, defaults=utils.OrderedSet(), scope=scope, name=name)
def exteriorSegmentsOfFaceSet(self, faces): # Used in boundarybuilder.py # A segment is on the exterior of the face set if only one of # the segment's faces is in the set. skel = self.getObject() segcounts = utils.OrderedDict() for face in faces: for seg in skel.getFaceSegments(face): segcounts[seg] = segcounts.get(seg, 0) + 1 return utils.OrderedSet(seg for seg, count in segcounts.items() if count == 1)
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, param, groups=[], scope=None, name=None): SkeletonGroupWidget.__init__(self, groups, defaults=utils.OrderedSet( [placeholder.selection.IDstring]), scope=scope, name=name) # self.skelwidget has been set by the parent. The modifier # widget will not change during our lifetime, since changing # it causes a new aggregate widget to be created. self.modifierwidget = scope.findWidget( lambda w: isinstance(w, bdymodparamwidget.BoundaryModParamWidget)) # The modifierwidget's scope's parent is the ParameterDialog # box, which has the boundary name. self.bdy_name = self.modifierwidget.scope.parent.boundaryname self.widgetChanged(self.local_validity(), interactive=0)
def times(self, endtime): if not self.nexttimes: self.nexttime = endtime yield endtime while self.nexttimes: self.nexttime = min(self.nexttimes.values()) # min over all Outputs self.nextoutputs = utils.OrderedSet( [o for (o,t) in self.nexttimes.items() if t == self.nexttime]) yield self.nexttime # Update next times for the outputs that have just been # performed. If output.schedule.next() raises # StopIteration, it's finished. for output in self.nextoutputs: try: self.nexttimes[output] = roundOffCheck( output.schedule.next(), endtime) except StopIteration: del self.nexttimes[output] self.finished.add(output) # end while self.nexttimes if endtime != self.nexttime: self.nextoutputs.clear() yield endtime
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) ]