Пример #1
0
 def mousePressEvent(self, event):
     if event.button() == Qt.LeftButton and self.draggedLine == None:
         for i in (0, 1):
             if imagefuncs.eucldistance(self.noteCorners[i], (event.pos().x(), event.pos().y())) < 10:
                 self.draggedPoint = i
                 return
         for i, p in enumerate(self.linePositions):
             if abs(event.pos().x() - p) < 10:
                 self.draggedLine = i
                 return
Пример #2
0
 def mousePressEvent(self, event):
     if event.button() == Qt.LeftButton and self.draggedPoint == None:
         for i, p in enumerate(self.draggablePoints):
             if imagefuncs.eucldistance(p, (event.pos().x(), event.pos().y())) < 10:
                 self.draggedPoint = i
Пример #3
0
    vertically_sorted_corners_with_index = sorted(enumerate(calibrationdata['corners']), key=lambda t: t[1][1])
    topindex, toppoint = vertically_sorted_corners_with_index[0]

    rightindex = (topindex + 1) % 4
    rightpoint = calibrationdata['corners'][rightindex]
    leftindex = (topindex + 4 - 1) % 4
    leftpoint = calibrationdata['corners'][leftindex]

    def abs_distance_per_axis(p1, p2):
        return abs(p1[0] - p2[0]), abs(p1[1] - p2[1])

    xdiff_right, ydiff_right = abs_distance_per_axis(toppoint, rightpoint)
    xdiff_left, ydiff_left = abs_distance_per_axis(toppoint, leftpoint)

    acos_left = math.acos(abs(xdiff_left) / imagefuncs.eucldistance(leftpoint, toppoint))
    acos_right = math.acos(abs(xdiff_right) / imagefuncs.eucldistance(rightpoint, toppoint))

    if acos_left < acos_right:
        othertopindex = leftindex
        othertoppoint = leftpoint
    else:
        othertopindex = rightindex
        othertoppoint = rightpoint

    if toppoint[0] < othertoppoint[0]:
        startingpointindex = topindex
        direction = othertopindex - topindex
    else:
        startingpointindex = othertopindex
        direction = topindex - othertopindex