Example #1
0
 def draw (self):
     """Draw the robot."""
     self.reset ()
     if self.pos is not None:
         self.trans_translate (self.pos)
         self.trans_rotate (self.angle)
         # Draw slots.
         for slot in self.clamp_model.slots:
             if slot.pawn is not None:
                 self.trans_push ()
                 self.trans_scale (1 - slot.z / 1000.0)
                 self.trans_translate ((slot.x, slot.y))
                 draw_pawn (self, slot.pawn)
                 self.trans_pop ()
         # Draw clamp.
         if self.clamp_model.rotation is not None:
             self.trans_push ()
             # Fixed side.
             self.trans_rotate (self.clamp_model.rotation)
             self.draw_arc ((150, 0), 103, start = pi / 2, extent = pi / 2,
                     style = 'arc', outline = COLOR_CLAMP)
             # Draw load.
             load = self.clamp_model.load
             if load:
                 self.trans_push ()
                 self.trans_translate ((150, 0))
                 draw_pawn (self, load)
                 self.trans_pop ()
             # Mobile side.
             self.trans_rotate (- self.clamp_model.clamping / 47)
             self.draw_arc ((150, 0), 103, start = pi, extent = pi / 2,
                     style = 'arc', outline = COLOR_CLAMP)
             # Done.
             self.trans_pop ()
         # Draw robot body.
         self.draw_polygon ((0, 190), (150, 110), (95, 95), (55, 55),
                 (40, -0), (55, -55), (95, -95), (150, -110), (0, -190),
                 (-150, -110), (-95, -95), (-55, -55), (-40, -0),
                 (-55, 55), (-95, 95), (-150, 110), (0, 190),
                 fill = COLOR_ROBOT)
         self.draw_arc ((0, 0), 190, start = pi * 35 / 180,
                 extent = pi * 110 / 180, style = 'chord',
                 outline = COLOR_ROBOT, fill = COLOR_ROBOT)
         self.draw_arc ((0, 0), 190, start = pi + pi * 35 / 180,
                 extent = pi * 110 / 180, style = 'chord',
                 outline = COLOR_ROBOT, fill = COLOR_ROBOT)
         # Draw Robot axis.
         self.draw_line ((-50, 0), (50, 0), fill = COLOR_AXES,
                 arrow = 'last')
         # Draw Robot wheels.
         f = 221 # Wheel spacing
         wr = 60 / 2 # Wheel radius
         self.draw_line ((0, +f / 2), (0, -f / 2), fill = COLOR_AXES)
         self.draw_line ((-wr, f / 2), (+wr, f / 2), fill = COLOR_AXES)
         self.draw_line ((-wr, -f / 2), (+wr, -f / 2), fill = COLOR_AXES)
         # Extends.
         simu.inter.drawable.Drawable.draw (self)
Example #2
0
 def draw (self):
     self.reset ()
     # Draw base from top.
     self.trans_rotate (pi)
     self.draw_arc ((0, 0), 190, start = pi * 35 / 180,
             extent = pi * 110 / 180, style = 'arc',
             outline = GREY)
     self.draw_arc ((0, 0), 190, start = pi + pi * 35 / 180,
             extent = pi * 110 / 180, style = 'arc',
             outline = GREY)
     self.draw_arc ((150, 0), 110, start = pi / 2,
             extent = pi, style = 'arc', outline = GREY)
     self.draw_arc ((-150, 0), 110, start = 3 * pi / 2,
             extent = pi, style = 'arc', outline = GREY)
     self.draw_arc ((0, 150), 100, start = pi,
             extent = pi, style = 'arc', outline = GREY, dash = (2, 3))
     self.draw_line ((-40, 0), (40, 0), fill = GREY, arrow = 'last')
     # Draw slots.
     for slot in self.model.slots:
         if slot.pawn is not None:
             self.trans_push ()
             self.trans_scale (1 - slot.z / 1000.0)
             self.trans_translate ((slot.x, slot.y))
             draw_pawn (self, slot.pawn)
             self.trans_pop ()
     # Draw clamp.
     if self.model.rotation is not None:
         self.trans_rotate (self.model.rotation)
         # Fixed side.
         self.draw_line ((0, 3), (47, 3))
         self.draw_arc ((150, 0), 103, start = pi / 2, extent = pi / 2,
                 style = 'arc')
         # Pawn.
         load = self.model.load
         if load is not None:
             self.trans_push ()
             self.trans_translate ((150, 0))
             draw_pawn (self, load)
             self.trans_pop ()
         # Mobile side.
         self.trans_rotate (-self.model.clamping / 43)
         self.draw_line ((0, -3), (47, -3))
         self.draw_arc ((150, 0), 103, start = pi, extent = pi / 2,
                 style = 'arc')