Example #1
0
 def _draw_equilibrium(self):
     width = 3
     orig_coords = [p.get_xy() for p in self.points]
     items = []
     for sig in (-1, 1):
         coords = geometry.find_parallel_polyline(orig_coords, sig * width)
         if sig == -1:
             x1, y1 = coords[1]
             x2, y2 = coords[0]
             coords[0] = geometry.elongate_line(
                 x1, y1, x2, y2, -8)  # shorten the line - looks better
         else:
             x1, y1 = coords[-2]
             x2, y2 = coords[-1]
             coords[-1] = geometry.elongate_line(
                 x1, y1, x2, y2, -8)  # shorten the line - looks better
         # the line
         ps = tuple(j for i in coords for j in i)
         item1 = self.paper.create_line(ps,
                                        tags='arrow',
                                        width=self.line_width,
                                        smooth=self.spline,
                                        fill=self.line_color)
         items.append(item1)
         # the pin
         cs = single_sided_arrow_head(x1, y1, x2, y2, 8, 10, 3,
                                      self.line_width)
         items.append(
             self.paper.create_polygon(cs,
                                       fill=self.line_color,
                                       outline=self.line_color,
                                       width=1,
                                       tags="arrow_no_focus",
                                       joinstyle="miter"))
     return items
Example #2
0
 def _draw_retro(self):
     width = 3
     coords = [p.get_xy() for p in self.points]
     items = []
     # the pins
     if self.pin in (2, 3):
         head = retro_arrow_head(coords[1][0], coords[1][1], coords[0][0],
                                 coords[0][1], 8, 8, width)
         head_item = self.paper.create_line(head,
                                            width=self.line_width,
                                            fill=self.line_color,
                                            joinstyle="miter")
         items.append(head_item)
     if self.pin in (1, 3):
         head = retro_arrow_head(coords[-2][0], coords[-2][1],
                                 coords[-1][0], coords[-1][1], 8, 8, width)
         head_item = self.paper.create_line(head,
                                            width=self.line_width,
                                            fill=self.line_color,
                                            joinstyle="miter")
         items.append(head_item)
     # the lines
     for sig in (-1, 1):
         cs = geometry.find_parallel_polyline(coords, sig * width)
         ps = tuple(j for i in cs for j in i)
         item1 = self.paper.create_line(ps,
                                        tags='arrow',
                                        width=self.line_width,
                                        smooth=self.spline,
                                        fill=self.line_color)
         items.append(item1)
     return items
Example #3
0
 def _draw_equilibrium2(self):
     width = 3
     orig_coords = [p.get_xy() for p in self.points]
     items = []
     for sig in (-1, 1):
         coords = geometry.find_parallel_polyline(orig_coords, sig * width)
         if not self.spline:
             # if its not a spline, we can draw it all in one go
             if sig == -1:
                 x1, y1 = coords[1]
                 x2, y2 = coords[0]
                 xp, yp = geometry.elongate_line(x1, y1, x2, y2, -8)
                 xp, yp = geometry.point_at_distance_from_line(
                     x1, y1, xp, yp, 5)
                 coords.insert(0, (xp, yp))
             else:
                 x1, y1 = coords[-2]
                 x2, y2 = coords[-1]
                 xp, yp = geometry.elongate_line(x1, y1, x2, y2, -8)
                 xp, yp = geometry.point_at_distance_from_line(
                     x1, y1, xp, yp, 5)
                 coords.append((xp, yp))
         else:
             # splines must have a sharp point at the end - the must have a separate head
             if sig == -1:
                 x1, y1 = coords[1]
                 x2, y2 = coords[0]
             else:
                 x1, y1 = coords[-2]
                 x2, y2 = coords[-1]
             xp, yp = geometry.elongate_line(x1, y1, x2, y2, -8)
             xp, yp = geometry.point_at_distance_from_line(
                 x1, y1, xp, yp, 5)
             items.append(
                 self.paper.create_line((x2, y2, xp, yp),
                                        tags='arrow',
                                        width=self.line_width,
                                        smooth=self.spline,
                                        fill=self.line_color,
                                        joinstyle="miter"))
         # the line (with optional pin)
         ps = tuple(j for i in coords for j in i)
         item1 = self.paper.create_line(ps,
                                        tags='arrow',
                                        width=self.line_width,
                                        smooth=self.spline,
                                        fill=self.line_color,
                                        joinstyle="miter")
         items.append(item1)
     return items
Example #4
0
 def _draw_equilibrium2( self):
   width = 3
   orig_coords = [p.get_xy() for p in self.points]
   items = []
   for sig in (-1,1):
     coords = geometry.find_parallel_polyline( orig_coords, sig*width)
     if not self.spline:
       # if its not a spline, we can draw it all in one go
       if sig == -1:
         x1, y1 = coords[1]
         x2, y2 = coords[0]
         xp, yp = geometry.elongate_line( x1,y1,x2,y2,-8)
         xp, yp = geometry.point_at_distance_from_line( x1,y1,xp,yp,5)
         coords.insert(0,(xp,yp))
       else:
         x1, y1 = coords[-2]
         x2, y2 = coords[-1]
         xp, yp = geometry.elongate_line( x1,y1,x2,y2,-8)
         xp, yp = geometry.point_at_distance_from_line( x1,y1,xp,yp,5)
         coords.append((xp,yp))
     else:
       # splines must have a sharp point at the end - the must have a separate head
       if sig == -1:
         x1, y1 = coords[1]
         x2, y2 = coords[0]
       else:
         x1, y1 = coords[-2]
         x2, y2 = coords[-1]
       xp, yp = geometry.elongate_line( x1,y1,x2,y2,-8)
       xp, yp = geometry.point_at_distance_from_line( x1,y1,xp,yp,5)
       items.append( self.paper.create_line( (x2,y2,xp,yp),
                                             tags='arrow', width=self.line_width,
                                             smooth=self.spline, fill=self.line_color,
                                             joinstyle="miter"))
     # the line (with optional pin)
     ps = reduce( operator.add, coords)
     item1 = self.paper.create_line( ps, tags='arrow', width=self.line_width,
                                     smooth=self.spline, fill=self.line_color,
                                     joinstyle="miter")
     items.append( item1)
   return items
Example #5
0
 def _draw_retro( self):
   width = 3
   coords = [p.get_xy() for p in self.points]
   items = []
   # the pins
   if self.pin in (2,3):
     head = retro_arrow_head(coords[1][0],coords[1][1],coords[0][0],coords[0][1],8,8,width)
     head_item = self.paper.create_line( head, width=self.line_width,fill=self.line_color,joinstyle="miter")
     items.append( head_item)
   if self.pin in (1,3):
     head = retro_arrow_head(coords[-2][0],coords[-2][1],coords[-1][0],coords[-1][1],8,8,width)
     head_item = self.paper.create_line( head, width=self.line_width,fill=self.line_color,joinstyle="miter")
     items.append( head_item)
   # the lines
   for sig in (-1,1):
     cs = geometry.find_parallel_polyline( coords, sig*width)
     ps = reduce( operator.add, cs)
     item1 = self.paper.create_line( ps, tags='arrow', width=self.line_width,
                                     smooth=self.spline, fill=self.line_color)
     items.append( item1)
   return items
Example #6
0
 def _draw_equilibrium( self):
   width = 3
   orig_coords = [p.get_xy() for p in self.points]
   items = []
   for sig in (-1,1):
     coords = geometry.find_parallel_polyline( orig_coords, sig*width)
     if sig == -1:
       x1, y1 = coords[1]
       x2, y2 = coords[0]
       coords[0] = geometry.elongate_line( x1,y1,x2,y2,-8) # shorten the line - looks better
     else:
       x1, y1 = coords[-2]
       x2, y2 = coords[-1]
       coords[-1] = geometry.elongate_line( x1,y1,x2,y2,-8) # shorten the line - looks better
     # the line
     ps = reduce( operator.add, coords)
     item1 = self.paper.create_line( ps, tags='arrow', width=self.line_width,
                                     smooth=self.spline, fill=self.line_color)
     items.append( item1)
     # the pin
     cs = single_sided_arrow_head(x1, y1, x2, y2, 8, 10, 3, self.line_width)
     items.append( self.paper.create_polygon( cs, fill=self.line_color, outline=self.line_color,
                                              width=1, tags="arrow_no_focus", joinstyle="miter"))
   return items