Example #1
0
 def on_mouse_left_down(self, event):
     self.previous_window_position = event.GetPosition()
     self.previous_scene_position = self.convert_window_to_scene(
         self.previous_window_position)
     self.corner_drag = None
     for i, p in enumerate(self.perspective):
         half = CORNER_SIZE / 2
         if Point.distance(self.previous_scene_position, p) < half:
             self.corner_drag = i
             break
Example #2
0
    def on_mouse_left_down(self, event):
        """
        Handle mouse left down event.

        Used for adjusting perspective items.

        :param event:
        :return:
        """
        self.previous_window_position = event.GetPosition()
        self.previous_scene_position = self.convert_window_to_scene(
            self.previous_window_position)
        self.corner_drag = None
        if self.perspective is not None:
            for i, p in enumerate(self.perspective):
                half = CORNER_SIZE / 2
                if Point.distance(self.previous_scene_position, p) < half:
                    self.corner_drag = i
                    break
Example #3
0
    def on_button_align_trace_hull(
            self, event):  # wxGlade: Navigation.<event_handler>
        pts = []
        for obj in self.elements:
            if isinstance(obj, Path):
                epath = abs(obj)
                pts += [q for q in epath.as_points()]
            elif isinstance(obj, SVGImage):
                bounds = obj.bbox()
                pts += [(bounds[0], bounds[1]), (bounds[0], bounds[3]),
                        (bounds[2], bounds[1]), (bounds[2], bounds[3])]
        hull = [p for p in Point.convex_hull(pts)]
        if len(hull) == 0:
            return

        def trace_hull():
            yield COMMAND_WAIT_BUFFER_EMPTY
            yield COMMAND_LASER_OFF
            for p in hull:
                yield COMMAND_RAPID_MOVE, p

        self.device.send_job(trace_hull)
Example #4
0
 def find_hit_chain(self, position):
     self.hit_chain.clear()
     for current_widget, current_matrix in self.hittable_elements:
         hit_point = Point(current_matrix.point_in_inverse_space(position))
         if current_widget.contains(hit_point.x, hit_point.y):
             self.hit_chain.append((current_widget, current_matrix))
Example #5
0
 def __init__(self, x, y=None):
     Point.__init__(self, x, y)
     self.connections = []
     self.visited = 0