def restore(self): print "restore to is %s " % self.restoreTo if (len(self.restoreTo)>0): getSelf().lines.clear() pp = self.restoreTo.pop() print "popped %s " % pp getSelf().lines.addAll(pp) print "lines are %s" % getSelf().lines
def Initially(inside, text, glob): """Execute this block once per Field session (or until a menu item is selected)""" hasExecuted = getattr(getSelf(), inside.name + "_") if (not hasExecuted): exec text in glob else: pass setattr(getSelf(), inside.name + "_", 1)
def Initially(inside,text,glob): """Execute this block once per Field session (or until a menu item is selected)""" hasExecuted = getattr(getSelf(), inside.name+"_") if (not hasExecuted): exec text in glob else: pass setattr(getSelf(), inside.name+"_", 1)
def Once(inside,text,glob): """Execute this block once (or until a menu item is selected)""" #print "exec: about to look up %s inside %s " % (inside.name, getSelf()) hasExecuted = getattr(getSelf(), inside.name) if (not hasExecuted): exec text in glob else: pass setattr(getSelf(), inside.name, 1)
def Once(inside, text, glob): """Execute this block once (or until a menu item is selected)""" #print "exec: about to look up %s inside %s " % (inside.name, getSelf()) hasExecuted = getattr(getSelf(), inside.name) if (not hasExecuted): exec text in glob else: pass setattr(getSelf(), inside.name, 1)
def makeEmbeddedCanvas(name, x=None, y=None, w=500, h=500, background=Vector4()): """Makes a self-enclosed drawing window and places it inside the main Field canvas. Like makeFullscreenCanvas and makeWindowedCanvas, but in this case the window is embedded inside Field""" if (x==None): x = getSelf().frame.x if (y==None): y = getSelf().frame.y+getSelf().frame.h+25 print x,y,w,h a,b,c = VisualElement.createWithToken(name, getSelf(), Rect(x,y,w,h), VisualElement, PlainDraggableComponent, ThreedComputingOverride) a.name = "canvas: "+name if (a.where.python_source_v==getSelf()): a.python_source_v="" return a.canvas
def __Once_paint(inside, g, bounds): print "paint: about to look up %s inside %s " % (inside.name, getSelf()) if (not getattr(getSelf(), inside.name)): return g = g.create() g.setPaint(GradientPaint(bounds.x, bounds.y, Color(0.4, 0.4, 0.4, 0.8), bounds.x, bounds.y+bounds.h, Color(0.3, 0.3, 0.3, 0.5))) g.fillRect(int(bounds.x), int(bounds.y), int(bounds.w-15), int(bounds.h)) g.setColor(Color(1,1,1,0.1)) g.setStroke(BasicStroke()) g.clipRect(int(bounds.x),int(bounds.y), int(bounds.w-15), int(bounds.h)) for n in range(-20, bounds.w, 10): g.drawLine(int(bounds.x+n), int(bounds.y+1), int(bounds.x+20+n), int(bounds.y+bounds.h-3))
def __Once_paint(inside, g, bounds): print "paint: about to look up %s inside %s " % (inside.name, getSelf()) if (not getattr(getSelf(), inside.name)): return g = g.create() g.setPaint( GradientPaint(bounds.x, bounds.y, Color(0.4, 0.4, 0.4, 0.8), bounds.x, bounds.y + bounds.h, Color(0.3, 0.3, 0.3, 0.5))) g.fillRect(int(bounds.x), int(bounds.y), int(bounds.w - 15), int(bounds.h)) g.setColor(Color(1, 1, 1, 0.1)) g.setStroke(BasicStroke()) g.clipRect(int(bounds.x), int(bounds.y), int(bounds.w - 15), int(bounds.h)) for n in range(-20, bounds.w, 10): g.drawLine(int(bounds.x + n), int(bounds.y + 1), int(bounds.x + 20 + n), int(bounds.y + bounds.h - 3))
def begin(self): self.restoreTo = [ArrayList(getSelf().lines or [])] self.begun = 1
def save(self): self.restoreTo.append(ArrayList(getSelf().lines or [] )) print "restore to is now %s " % self.restoreTo
def dont(): setattr(getSelf(), inside.name,1)
def rearm(): setattr(getSelf(), inside.name,0)
def rearm(): setattr(getSelf(), inside.name, 0)
def dont(): setattr(getSelf(), inside.name + "_", 1)