Пример #1
0
 def tailToNode( self, arrow_anno, circle_anno ):
     "return true if the tail of the arrow comes from the circle"
     lineDist = max(len(arrow_anno.tailstroke.Points) / 10, 1) #Check the last 10th of the stroke points the right way
     if arrow_anno.direction == "tail2head":
         lineSeg = ( arrow_anno.tailstroke.Points[lineDist], arrow_anno.tailstroke.Points[0] )
     else: #direction == 'head2tail'
         lineSeg = ( arrow_anno.tailstroke.Points[-lineDist], arrow_anno.tailstroke.Points[-1] )
         
     if GeomUtils.pointDist( arrow_anno.tail,  circle_anno.center ) < circle_anno.radius* DiGraphAnnotation.MATCHING_DISTANCE:
         if GeomUtils.linePointsTowards( lineSeg[0], lineSeg[1], circle_anno.center, circle_anno.radius * DiGraphAnnotation.POINTSTO_DISTANCE):
             return True
     return False
Пример #2
0
 def collectionFromItem( self, strokes, annotation ):
     text_anno = None # text_anno will be the return value
     if annotation.isType( CircleObserver.CircleAnnotation ):
         circle = annotation
         text_anno = TextAnnotation("0",circle.radius*2)
     if annotation.isType( LineObserver.LineAnnotation ):
         line = annotation
         # if the line is up/down then it is a one
         if GeomUtils.angleParallel( line.angle, 90 ) > 0.6:
             line_length = GeomUtils.pointDist( line.start_point, line.end_point )
             text_anno = TextAnnotation("1",line_length)
     return text_anno
Пример #3
0
 def tipToNode( self, arrow_anno, circle_anno ):
     "return true if the tip of the arrow points to the circle"
     lineDist = min(10, max(len(arrow_anno.tailstroke.Points) / 10, 1)) #Check the last 10th of the stroke points the right way
     #lineseg: two points from arrow "neck" to arrowhead tip 
     #lineseg2: two points from arrow "neck" to last point in tail stroke
     if arrow_anno.direction == "tail2head":
         lineSeg = ( arrow_anno.tailstroke.Points[-lineDist], arrow_anno.tip )
         lineSeg2 = ( arrow_anno.tailstroke.Points[-lineDist], arrow_anno.tailstroke.Points[-1] )
     else: #direction == 'head2tail'
         lineSeg = ( arrow_anno.tailstroke.Points[lineDist], arrow_anno.tip )
         lineSeg2 = ( arrow_anno.tailstroke.Points[lineDist], arrow_anno.tailstroke.Points[0] )
         
     if GeomUtils.pointDist( arrow_anno.tip,  circle_anno.center ) < circle_anno.radius* DiGraphAnnotation.MATCHING_DISTANCE:
         if GeomUtils.linePointsTowards( lineSeg[0], lineSeg[1], circle_anno.center, circle_anno.radius * DiGraphAnnotation.POINTSTO_DISTANCE):
             return True
         if GeomUtils.linePointsTowards( lineSeg2[0], lineSeg2[1], circle_anno.center, circle_anno.radius * DiGraphAnnotation.POINTSTO_DISTANCE):
             return True
     return False
Пример #4
0
 def distance(self, point2):
      "Returns the distance from this point to the point in argument 1"
      from Utils import GeomUtils
      return GeomUtils.pointDist(self, point2)
Пример #5
0
 def tailToNode( self, arrow_anno, circle_anno ):
     "return true if the tail of the arrow comes from the circle"
     return GeomUtils.pointDist( arrow_anno.tail, circle_anno.center ) < circle_anno.radius*1.5
Пример #6
0
 def tipToNode( self, arrow_anno, circle_anno ):
     "return true if the tip of the arrow points to the circle"
     return GeomUtils.pointDist( arrow_anno.tip,  circle_anno.center ) < circle_anno.radius*1.5