def _C_displist(self): # compute method for self.displist ### WARNING: this doesn't recycle displists when instances are remade at same ipath (but it probably should), # and it never frees them. To recycle them, just change it to use transient_state. # When we start using more than one GL Context which share display lists, we'll have to revise this somehow. # ### NOTE: usage tracking should turn up nothing -- we use nothing """ allocate a new display list name (a 32-bit int) in our GL context """ if self.displist_disabled( ): # revised this cond (true more often), 070215 printfyi( "bug: why does .displist get requested in a disabled DisplayListChunk??" ) # (i never saw this) return 0 self.glpane.makeCurrent( ) # not sure when this compute method might get called, so make sure our GL context is current displist = self.glpane.glGenLists( 1 ) # allocate the display list name [#k does this do makeCurrent??] # make sure it's a nonzero int or long assert type(displist) in (type(1), type(1L)) assert displist, "error: allocated displist was zero" if self._debug_print_name: print "%s: allocated display list name %r" % ( self._debug_print_name, displist) return displist
def draw(self): guy = self.delegate print "guy = %r" % (guy, ) ## attrs = self.args[1:] attrs = self.attrs if type(attrs) == type("kluge"): attrs = [attrs] printnim("need to unstub ArgList in DebugPrintAttrs") else: printfyi("seems like ArgList may have worked in DebugPrintAttrs") if 'ipath' not in attrs: attrs.append('ipath') #070118; not sure it's good for name in attrs: print "guy.%s is" % name, getattr(guy, name, "<unassigned>") return self.drawkid(guy) ## return guy.draw()
def draw(self): guy = self.delegate print "guy = %r" % (guy, ) ## attrs = self.args[1:] attrs = self.attrs if type(attrs) == type("kluge"): attrs = [attrs] printnim("need to unstub ArgList in DebugPrintAttrs") else: printfyi("seems like ArgList may have worked in DebugPrintAttrs") if 'ipath' not in attrs: attrs.append('ipath')#070118; not sure it's good for name in attrs: print "guy.%s is" % name, getattr(guy,name,"<unassigned>") return self.drawkid( guy) ## return guy.draw()
def _C_displist(self): # compute method for self.displist ### WARNING: this doesn't recycle displists when instances are remade at same ipath (but it probably should), # and it never frees them. To recycle them, just change it to use transient_state. # When we start using more than one GL Context which share display lists, we'll have to revise this somehow. # ### NOTE: usage tracking should turn up nothing -- we use nothing "allocate a new display list name (a 32-bit int) in our GL context" if self.displist_disabled(): # revised this cond (true more often), 070215 printfyi("bug: why does .displist get requested in a disabled DisplayListChunk??") # (i never saw this) return 0 self.glpane.makeCurrent() # not sure when this compute method might get called, so make sure our GL context is current displist = self.glpane.glGenLists(1) # allocate the display list name [#k does this do makeCurrent??] # make sure it's a nonzero int or long assert type(displist) in (type(1), type(1L)) assert displist, "error: allocated displist was zero" if self._debug_print_name: print "%s: allocated display list name %r" % (self._debug_print_name, displist) return displist
class Rect(Widget2D): # finally working as of 061106 """ Rect(width, height, color) renders as a filled x/y-aligned rectangle of the given dimensions and color, with the origin on bottomleft, and a layout box equal to its size (no margin). If color is not given, it will be gray [#e should be a default attrval from env]. If height is not given, it will be a square (even if width is a formula and/or random). See also: RectFrame, ... """ # args width = Arg(Width, 5) # changed 10 to 5 late on 061109 # Note: Widget2D defines width & height, making this seem circular, but it's ok (see comment in RectFrame) height = Arg(Width, width) color = ArgOrOption(Color, gray) # formulas if 0: # use this to test whatever scheme we use to detect this error, once we put one in [disabled 061105 until other things work] bright = width ######@@@@@ PROBLEM: in ns, width and bright will have same value, no ordering possible -- how can it tell # which one should be used to name the arg? It can't, so it'll need to detect this error and make you use _self. prefix. # (in theory, if it could scan source code, or turn on debugging during class imports, it could figure this out... # or you could put the argname in Arg or have an _args decl... but I think just using _self.attr in these cases is simpler.) printnim("make sure it complains about bright and width here") btop = height else: if debug_flags.atom_debug: printfyi( "not yet trying to trigger the error warning for 'bright = width'" ) # (since it's nim, even as of 061114 i think) bright = _self.width btop = _self.height # bbottom and bleft are not needed (same as the defaults in Widget2D), except that we use them in the formula for center; # it would be more correct to say bleft = _self.bleft, but less efficient I think (not much), and hasn't been tested (should be #e). bbottom = 0 bleft = 0 ## center = V_expr( (bright - bleft) / 2.0, (btop - bbottom) / 2.0, 0.0) #070211 #e someday this could be deduced from lbox, generally ###e should move this def into Spacer, RectFrame, etc -- or arrange to deduce it from lbox on any Widget2D, somehow... # [070227] hmm, can't it just be moved from here into Widget2D itself? Yes, that works! def draw(self): glDisable(GL_CULL_FACE) draw_filled_rect( ORIGIN, DX * self.bright, DY * self.btop, self.fix_color( self.color)) #e move fix_color into draw_filled_rect? glEnable(GL_CULL_FACE) pass
def viewerfunc(x): printfyi("viewerfunc is being used but is a stub") return x