def insert(self, morph): ''' Insert morph into this group. If self is a primitive morph, insert new group morph in hierarchy, i.e. branch. Because, if self is a primitive morph, it has a transform that shapes its glyphs but we want a distinct transform for the new group [self,morph]. For debugging, return either new branch or self. ''' if self.is_primitive(): # Standard insert branch into tree. parent = self.parent branch = Morph() # new branch, parented soon, on append # Assert branch.transform is identity, branch.retained_transform is None # Rearrange parent of self parent.remove(self) # break self, former child from parent # !!! But self.parent still points to parent branch.append(self) # self, former child of parent, now child of branch # !!! Note the above changed self.parent branch.append(morph) # new child of new branch parent.append(branch) # parent has new child, a branch # !!! Sets branch.parent = parent branch.retained_transform = transform.copy(parent.retained_transform) # Assert branch.transform is identity, branch.retained_transform equals parents # Assert parent.transform and parent.retained_transform are untouched # print "branch retained", branch.retained_transform return branch else: print "...............Grouping with ", self self.append(morph) return self
def insert(self, morph): ''' Insert morph into this group. If self is a primitive morph, insert new group morph in hierarchy, i.e. branch. Because, if self is a primitive morph, it has a transform that shapes its glyphs but we want a distinct transform for the new group [self,morph]. For debugging, return either new branch or self. ''' if self.is_primitive(): # Standard insert branch into tree. parent = self.parent branch = Morph() # new branch, parented soon, on append # Assert branch.transform is identity, branch.retained_transform is None # Rearrange parent of self parent.remove(self) # break self, former child from parent # !!! But self.parent still points to parent branch.append( self) # self, former child of parent, now child of branch # !!! Note the above changed self.parent branch.append(morph) # new child of new branch parent.append(branch) # parent has new child, a branch # !!! Sets branch.parent = parent branch.retained_transform = transform.copy( parent.retained_transform) # Assert branch.transform is identity, branch.retained_transform equals parents # Assert parent.transform and parent.retained_transform are untouched # print "branch retained", branch.retained_transform return branch else: print "...............Grouping with ", self self.append(morph) return self
def picking_func(self, point): # Fresh context since can be called outside a walk of model hierarchy context = config.viewport.user_context() if self.parent: # None if in background ctl context.set_matrix(transform.copy(self.parent.retained_transform)) # !!! No style put to context, but insure black ink? TODO self.put_path_to(context) # recursive, with transforms # Transform point from DCS to UCS since Cairo in_foo() functions want UCS pointUCS = vector.Vector(*context.device_to_user(point.x, point.y)) # print self, pointUCS value = func(self, context, pointUCS) print "picking_func returning", value return value
def _prepare_for_picking(self, point): ''' Prepare a context for picking. Fresh context since can be called outside a walk of model hierarchy. Assert parent is ??? ''' # context = config.viewport.user_context() if self.parent: # None if in background ctl context.set_matrix(transform.copy(self.parent.retained_transform)) # !!! No style put to context, but insure black ink? TODO self.put_path_to(context) # recursive, with transforms # Transform point from DCS to UCS since Cairo in_foo() functions want UCS pointUCS = vector.Vector(*context.device_to_user(point.x, point.y)) return context, pointUCS