Class: Wx::SF::EllipseShape
- Defined in:
- lib/wx/shapes/shapes/ellipse_shape.rb
Overview
Class encapsulating the ellipse shape. It extends the basic rectangular shape.
Instance Method Summary collapse
-
#contains?(pos) ⇒ Boolean
Test whether the given point is inside the shape.
-
#draw_highlighted(dc) ⇒ Object
protected
Draw the shape in the highlighted mode (another shape is dragged over this shape and this shape will accept the dragged one if it will be dropped on it).
-
#draw_hover(dc) ⇒ Object
protected
Draw the shape in the hover mode (the mouse cursor is above the shape).
-
#draw_normal(dc) ⇒ Object
protected
Draw the shape in the normal way.
-
#draw_shadow(dc) ⇒ Object
protected
Draw shadow under the shape.
-
#get_border_point(start, end_pt) ⇒ Wx::RealPoint
Get intersection point of the shape border and a line leading from ‘start’ point to ‘end_pt’ point.
-
#initialize(pos = Shape::DEFAULT::POSITION, size = RectShape::DEFAULT::SIZE, diagram: nil) ⇒ EllipseShape
constructor
Constructor.
Methods inherited from RectShape
#create_handles, #do_begin_handle, #do_on_handle, #fit_to_children, #get_border, #get_bounding_box, #get_fill, #get_rect_size, #on_begin_handle, #on_bottom_handle, #on_handle, #on_left_handle, #on_right_handle, #on_top_handle, #scale, #scale_rectangle, #set_border, #set_fill, #set_rect_size
Methods inherited from Shape
#accept_child, #accept_connection, #accept_currently_dragged_shapes, #accept_src_neighbour, #accept_trg_neighbour, #activate, #active?, #add_child_shape, #add_connection_point, #add_handle, #add_style, #ancestor?, #clear_accepted_childs, #clear_accepted_connections, #clear_accepted_src_neighbours, #clear_accepted_trg_neighbours, component, component_shapes, #contains_style, #create_handles, #descendant?, #do_alignment, #does_not_accept_children?, #draw, #draw_selected, #fit_to_children, #get_absolute_position, #get_accepted_children, #get_accepted_connections, #get_accepted_src_neighbours, #get_accepted_trg_neighbours, #get_assigned_connections, #get_bounding_box, #get_center, #get_child_shapes, #get_children, #get_children_recursively, #get_complete_bounding_box, #get_connection_point, #get_connection_points, #get_custom_dock_point, #get_diagram, #get_grand_parent_shape, #get_h_align, #get_h_border, #get_handle, #get_handles, #get_hover_colour, #get_nearest_connection_point, #get_neighbours, #get_parent_absolute_position, #get_parent_canvas, #get_parent_shape, #get_relative_position, #get_shape_canvas, #get_style, #get_user_data, #get_v_align, #get_v_border, #has_children, #has_selected_parent?, #include_child_shape?, #inside?, #inspect, #intersects?, #is_child_accepted, #is_connection_accepted, #is_managed, #is_manager, #is_src_neighbour_accepted, #is_trg_neighbour_accepted, lines_intersection, #lines_intersection, #move_by, #move_to, #on_begin_drag, #on_begin_handle, #on_child_dropped, #on_dragging, #on_end_drag, #on_end_handle, #on_handle, #on_import, #on_key, #on_left_click, #on_left_double_click, #on_mouse_enter, #on_mouse_leave, #on_mouse_over, #on_right_click, #on_right_double_click, #refresh, #refresh_rect, #remove_connection_point, #remove_handle, #remove_style, #scale, #scale_children, #select, #selected?, #set_custom_dock_point, #set_diagram, #set_h_align, #set_h_border, #set_hover_colour, #set_parent_shape, #set_relative_position, #set_style, #set_user_data, #set_v_align, #set_v_border, #show, #show_handles, #to_s, #update, #visible?
Constructor Details
Instance Method Details
#contains?(pos) ⇒ Boolean
Test whether the given point is inside the shape. The function can be overridden if necessary.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/wx/shapes/shapes/ellipse_shape.rb', line 21 def contains?(pos) a = get_rect_size.x/2 b = get_rect_size.y/2 apos = get_absolute_position m = apos.x + a n = apos.y + b pos = pos.to_point (((pos.x - m)*(pos.x - m))/(a*a) + ((pos.y - n)*(pos.y - n))/(b*b)) < 1 end |
#draw_highlighted(dc) ⇒ Object (protected)
Draw the shape in the highlighted mode (another shape is dragged over this shape and this shape will accept the dragged one if it will be dropped on it). The function can be overridden if necessary.
80 81 82 83 84 85 86 |
# File 'lib/wx/shapes/shapes/ellipse_shape.rb', line 80 def draw_highlighted(dc) dc.with_pen(Wx::Pen.new(hover_colour, 2)) do dc.with_brush(fill) do dc.draw_ellipse(get_absolute_position.to_point, @rect_size.to_size) end end end |
#draw_hover(dc) ⇒ Object (protected)
Draw the shape in the hover mode (the mouse cursor is above the shape). The function can be overridden if necessary.
68 69 70 71 72 73 74 |
# File 'lib/wx/shapes/shapes/ellipse_shape.rb', line 68 def draw_hover(dc) dc.with_pen(Wx::Pen.new(hover_colour, 1)) do dc.with_brush(fill) do dc.draw_ellipse(get_absolute_position.to_point, @rect_size.to_size) end end end |
#draw_normal(dc) ⇒ Object (protected)
Draw the shape in the normal way. The function can be overridden if necessary.
57 58 59 60 61 62 63 |
# File 'lib/wx/shapes/shapes/ellipse_shape.rb', line 57 def draw_normal(dc) dc.with_pen(border) do dc.with_brush(fill) do dc.draw_ellipse(get_absolute_position.to_point, @rect_size.to_size) end end end |
#draw_shadow(dc) ⇒ Object (protected)
Draw shadow under the shape. The function can be overridden if necessary.
90 91 92 93 94 95 96 97 98 99 |
# File 'lib/wx/shapes/shapes/ellipse_shape.rb', line 90 def draw_shadow(dc) if fill.style != Wx::BrushStyle::BRUSHSTYLE_TRANSPARENT dc.with_pen(Wx::TRANSPARENT_PEN) do dc.with_brush(get_parent_canvas.get_shadow_fill) do dc.draw_ellipse((get_absolute_position + get_parent_canvas.get_shadow_offset).to_point, @rect_size.to_size) end end end end |
#get_border_point(start, end_pt) ⇒ Wx::RealPoint
Get intersection point of the shape border and a line leading from ‘start’ point to ‘end_pt’ point. The function can be overridden if necessary.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/wx/shapes/shapes/ellipse_shape.rb', line 38 def get_border_point(start, end_pt) start = start.to_real_point; end_pt.to_real_point dist = start.distance_to(end_pt) center = get_absolute_position + [@rect_size.x/2, @rect_size.y/2] if dist != 0.0 src_dx = @rect_size.x/2*(end_pt.x-start.x)/dist - (start.x-center.x) src_dy = @rect_size.y/2*(end_pt.y-start.y)/dist - (start.y-center.y) Wx::RealPoint.new(start.x + src_dx, start.y + src_dy) else center end end |