Esempio n. 1
0
    def get_handle_guides(self, hit_point):
        index = self.edit_points.index(hit_point)
        opp_handle_index = (index + 2) % 4;
        opp_handle = self.edit_points[opp_handle_index]

        guide_1_handle = self.edit_points[(opp_handle_index - 1) % 4]
        guide_2_handle = self.edit_points[(opp_handle_index + 1) % 4]

        guide_1 = viewgeom.get_vec_for_points(opp_handle.get_pos(), guide_1_handle.get_pos())
        guide_2 = viewgeom.get_vec_for_points(opp_handle.get_pos(), guide_2_handle.get_pos())
        guide_1.point_index = (opp_handle_index - 1) % 4
        guide_2.point_index = (opp_handle_index + 1) % 4

        return (guide_1, guide_2)
Esempio n. 2
0
    def get_handle_guides(self, hit_point):
        index = self.edit_points.index(hit_point)
        opp_handle_index = (index + 2) % 4;
        opp_handle = self.edit_points[opp_handle_index]

        guide_1_handle = self.edit_points[(opp_handle_index - 1) % 4]
        guide_2_handle = self.edit_points[(opp_handle_index + 1) % 4]

        guide_1 = viewgeom.get_vec_for_points(opp_handle.get_pos(), guide_1_handle.get_pos())
        guide_2 = viewgeom.get_vec_for_points(opp_handle.get_pos(), guide_2_handle.get_pos())
        guide_1.point_index = (opp_handle_index - 1) % 4
        guide_2.point_index = (opp_handle_index + 1) % 4

        return (guide_1, guide_2)
Esempio n. 3
0
    def _shape_press_event(self):
        self.start_edit_points = copy.deepcopy(self.edit_points)

        if self.current_mouse_hit == X_SCALE_HANDLE:
            self.guide = viewgeom.get_vec_for_points((self.shape_x,self.shape_y), self.edit_points[X_SCALE_HANDLE])
        elif self.current_mouse_hit == Y_SCALE_HANDLE:
            self.guide = viewgeom.get_vec_for_points((self.shape_x,self.shape_y), self.edit_points[Y_SCALE_HANDLE])
        elif self.current_mouse_hit == ROTATION_HANDLE:
            ax, ay = self.edit_points[POS_HANDLE]
            zero_deg_point = (ax, ay + 10)
            m_end_point = (self.get_screen_x(self.mouse_start_x), self.get_screen_y(self.mouse_start_y))
            self.mouse_start_rotation = viewgeom.get_angle_in_deg(zero_deg_point, self.edit_points[POS_HANDLE], m_end_point)
            self.mouse_rotation_last = 0.0
            self.rotation_value_start = self.rotation
        elif self.current_mouse_hit == POS_HANDLE or self.current_mouse_hit == AREA_HIT:
            self.start_shape_x = self.shape_x 
            self.start_shape_y = self.shape_y
Esempio n. 4
0
    def _get_legal_point(self, x, y):
        vec = viewgeom.get_vec_for_points((self.CENTER_X, self.CENTER_Y), (x, y))
        dist = vec.get_length()
        if dist < self.MAX_DIST:
            return (x, y)

        new_vec = vec.get_multiplied_vec(self.MAX_DIST / dist )
        return new_vec.end_point
Esempio n. 5
0
    def get_side_for_index(self, side_index):
        start = self.curve_points[side_index].get_pos()

        if side_index < len(self.curve_points) - 1:
            end = self.curve_points[side_index + 1].get_pos()
        else:
            end = self.curve_points[0].get_pos()

        return viewgeom.get_vec_for_points(start, end)
Esempio n. 6
0
 def get_straight_line_handle_places(self, cp_index):
     prev_i = cp_index - 1
     next_i = cp_index + 1
     if next_i == len(self.curve_points):
         next_i = 0
     if prev_i < 0:
         prev_i = len(self.curve_points) - 1
     
     prev_p = self.curve_points[prev_i].get_pos()
     next_p = self.curve_points[next_i].get_pos()
     p = self.curve_points[cp_index].get_pos()
     
     forward = viewgeom.get_vec_for_points(p, next_p)
     back =  viewgeom.get_vec_for_points(p, prev_p)
     
     forward = forward.get_multiplied_vec(0.3)
     back = back.get_multiplied_vec(0.3)
     
     return (back.end_point, forward.end_point)
Esempio n. 7
0
    def _shape_press_event(self):
        self.start_edit_points = copy.deepcopy(self.edit_points)

        if self.current_mouse_hit == X_SCALE_HANDLE:
            self.guide = viewgeom.get_vec_for_points(
                (self.shape_x, self.shape_y), self.edit_points[X_SCALE_HANDLE])
        elif self.current_mouse_hit == Y_SCALE_HANDLE:
            self.guide = viewgeom.get_vec_for_points(
                (self.shape_x, self.shape_y), self.edit_points[Y_SCALE_HANDLE])
        elif self.current_mouse_hit == ROTATION_HANDLE:
            ax, ay = self.edit_points[POS_HANDLE]
            zero_deg_point = (ax, ay + 10)
            m_end_point = (self.get_screen_x(self.mouse_start_x),
                           self.get_screen_y(self.mouse_start_y))
            self.mouse_start_rotation = viewgeom.get_angle_in_deg(
                zero_deg_point, self.edit_points[POS_HANDLE], m_end_point)
            self.mouse_rotation_last = 0.0
            self.rotation_value_start = self.rotation
        elif self.current_mouse_hit == POS_HANDLE or self.current_mouse_hit == AREA_HIT:
            self.start_shape_x = self.shape_x
            self.start_shape_y = self.shape_y
Esempio n. 8
0
    def get_point_dist_from_seq(self, p, seq_index):
        start = self.curve_points[seq_index].get_pos()

        if seq_index < len(self.curve_points) - 1:
            end = self.curve_points[seq_index + 1].get_pos()
        else:
            end = self.curve_points[0].get_pos()
        
        seq = viewgeom.get_vec_for_points(start, end)

        if seq.point_is_between(p) == True:
            dist = seq.get_distance_vec(p)
            return abs(dist.get_length())
        else:
            return -1
Esempio n. 9
0
 def get_distance(self, p):
     vec = viewgeom.get_vec_for_points((self.CENTER_X, self.CENTER_Y), p)
     dist = vec.get_length()
     return dist/self.MAX_DIST