示例#1
0
  def draw(self, context):
    Thing.draw(self, context)

    # draw a bounding box
    #Primitives.bounding_box(context, -0.5, -0.5, 1.0, 1.0)
    
    # set origin to top left
    #context.translate(-0.5 + (self.root_node.width / 2.0), -0.5 + (self.root_node.height / 2.0)) 
    context.translate(-0.5, -0.5) 
    
    if self.cache_drawing_operations:
      # check if rendering cache needs to be refreshed
      if (self.cached_render is None) or (self.cached_scale is not TheWorld.scale):
        self.cached_render = self.__render_cache(context)
        self.cached_scale = TheWorld.scale
  
      # blast cached rendering to screen
      context.save()
      pixel_width, pixel_height = context.user_to_device_distance(self.width, self.height)
      context.scale(1.0 / pixel_width, 1.0 / pixel_height)
      context.set_source_surface(self.cached_render)
      context.paint()
      context.restore()
    
    else:
      # draw connectors first for z-order 
      context.save()
      self.x_offset = 0
      self.y_offset = 0
      self.draw_connectors(context, self.root_node)
      self.x_offset = 0
      self.y_offset = 0
      self.draw_nodes(context, self.root_node)
      context.restore()
示例#2
0
 def draw(self, context):
   Thing.draw(self, context)
   context.select_font_face("Sans", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL)
   context.set_font_size(0.1)
   context.set_source_rgb(0.0, 0.0, 0.0)
   context.move_to(-0.3, 0.02)
   context.show_text(self.target.__name__)
示例#3
0
  def draw(self, context):
    Thing.draw(self, context)

    # draw a bounding box
    context.set_line_width(0.005)
    context.set_source_rgba(0.8, 0.8, 0.8, 1.0)
    context.rectangle(-0.5, -0.5, 1.0, 1.0)
    context.fill()
    
    # render label
    context.save()
    context.move_to(-0.5, -0.5)
    context.scale(self.scale_x, self.scale_y)
    context.set_source_rgb(0.0, 0.0, 0.0)
    context.show_layout(self.layout)    
    context.restore()
示例#4
0
  def draw(self, context):
    Thing.draw(self, context)
    
    self.text = self.target.__class__.__name__ # + "\n" + self.target.code
    
    # figure out scale factor to fit text to thing size
    scale = min(1.0 / self.pixel_width, 1.0 / self.pixel_height) / 2.0
    
    # draw connectors
    self.draw_inputs(context)
    #self.draw_outputs(context)

    # render the text
    context.save()
    context.move_to(-0.3, -0.5)
    context.scale(scale, scale)
    context.set_source_rgba(0.0, 0.0, 0.0, 1.0)
    context.show_layout(self.layout)        
    context.restore()
 
    # render box
    Primitives.panel(context, -0.5, -0.5, 1.0, 1.0, 0.05)