コード例 #1
0
ファイル: arrow.py プロジェクト: yassineMrabet/bkchem
def double_sided_arrow_head (x1,y1,x2,y2,a,b,c):
  '''last two points of arrow 1->2
  a,b,c like tkinter
  a = leght from point 2 where the head touches the line (out point A)
  b = total lenght of the head (defines also help point P on the line)
  c = width 
  Point B will be the outer Point of the head
  rl = "r" the head is on the right , = "l" left'''
  xa,ya = x2,y2
  xp,yp = geometry.elongate_line (x1,y1,x2,y2,-b)
  xb,yb = geometry.point_at_distance_from_line (x1,y1,xp,yp,c)
  xd,yd = geometry.point_at_distance_from_line (x1,y1,xp,yp,-c)
  xc,yc = geometry.elongate_line (x1,y1,x2,y2,-a)
  return xa,ya, xb,yb, xc,yc, xd,yd
コード例 #2
0
ファイル: arrow.py プロジェクト: insilichem/bkchem
 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
コード例 #3
0
ファイル: arrow.py プロジェクト: yassineMrabet/bkchem
def single_sided_arrow_head (x1,y1,x2,y2,a,b,c,lw):
  '''last two points of arrow 1->2
  a,b,c like tkinter
  a = leght from point 2 where the head touches the line (out point A)
  b = total lenght of the head (defines also help point P on the line)
  c = width 
  Point B will be the outer Point of the head
  rl = "r" the head is on the right , = "l" left,
  lw is the line_width of the line the arrow will be attached to'''

  xa,ya = geometry.elongate_line (x1,y1,x2,y2,-a)
  xa,ya = geometry.point_at_distance_from_line (x1,y1,xa,ya,-misc.signum(c)*(lw-1.0)/2.0)
  xp,yp = geometry.elongate_line (x1,y1,x2,y2,-b)
  xb,yb = geometry.point_at_distance_from_line (x1,y1,xp,yp,c)
  xc,yc = geometry.point_at_distance_from_line (x1,y1,x2,y2,-misc.signum(c)*(lw-1.0)/2.0)
  return xa,ya, xc,yc, xb,yb
コード例 #4
0
ファイル: arrow.py プロジェクト: bartlebee/bkchem
 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
コード例 #5
0
ファイル: arrow.py プロジェクト: yassineMrabet/bkchem
def retro_arrow_head (x1,y1,x2,y2,length,width,d):
  """arrow head at 2
#                    length
#                   |---|  _
#                  C\      |
#                    \     | width
#   A----------------B\-P  |
#   1       d |  __R___\|2 -
#                      /|
#   D----------------E/-Q
#                    /
#                  F/
#   P,Q,R are not drawn
"""
  w_ratio = 1.0*d / width
  dl = w_ratio * length
  xh ,yh = geometry.elongate_line( x1,y1,x2,y2,dl)
  xr, yr = geometry.elongate_line( x1,y1,x2,y2,dl-length)
  xc, yc = geometry.point_at_distance_from_line (x1,y1,xr,yr,width)
  xf, yf = geometry.point_at_distance_from_line (x1,y1,xr,yr,-width)

  return (xc,yc, xh,yh, xf,yf)