Class: Wx::SF::RoundOrthoLineShape
- Inherits:
-
OrthoLineShape
- Object
- Shape
- LineShape
- OrthoLineShape
- Wx::SF::RoundOrthoLineShape
- Defined in:
- lib/wx/shapes/shapes/round_ortho_shape.rb
Overview
Rounded orthogonal line shape. The class extends OrthoLineShape class and allows user to create connection line orthogonal to base axis with round corners.
Constant Summary collapse
- MAX_RADIUS =
7
Instance Attribute Summary collapse
-
#max_radius ⇒ Object
Access (set/get) maximum radius.
Instance Method Summary collapse
-
#draw_line_segment(dc, src, trg, cps) ⇒ Object
protected
Draw one orthogonal line segment.
-
#initialize(src = nil, trg = nil, path: nil, diagram: nil) ⇒ RoundOrthoLineShape
constructor
Constructor.
Methods inherited from OrthoLineShape
#draw_complete_line, #get_first_subsegment, #get_hit_linesegment, #get_last_subsegment, #get_middle_subsegment, #get_segment_direction, #get_used_connection_points, #is_two_segment
Methods inherited from LineShape
#contains?, #create_handles, #draw_complete_line, #draw_highlighted, #draw_hover, #draw_normal, #get_absolute_position, #get_border_point, #get_bounding_box, #get_control_points, #get_direct_line, #get_dock_point, #get_dock_point_position, #get_hit_linesegment, #get_line_mode, #get_line_pen, #get_line_segment, #get_line_segment_count, #get_mod_src_point, #get_mod_trg_point, #get_src_arrow, #get_src_point, #get_src_shape, #get_stand_alone, #get_trg_arrow, #get_trg_point, #get_trg_shape, #move_by, #move_to, #on_begin_drag, #on_end_handle, #on_handle, #on_left_double_click, #scale, #set_dock_point, #set_ending_connection_point, #set_line_mode, #set_line_pen, #set_src_arrow, #set_src_point, #set_src_shape, #set_stand_alone, #set_starting_connection_point, #set_trg_arrow, #set_trg_point, #set_trg_shape, #set_unfinished_point
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?, #contains_style, #create_handles, #descendant?, #do_alignment, #does_not_accept_children?, #draw, #draw_highlighted, #draw_hover, #draw_normal, #draw_selected, #draw_shadow, #fit_to_children, #get_absolute_position, #get_accepted_children, #get_accepted_connections, #get_accepted_src_neighbours, #get_accepted_trg_neighbours, #get_assigned_connections, #get_border_point, #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
#initialize(src = nil, trg = nil, path: nil, diagram: nil) ⇒ RoundOrthoLineShape
Constructor
21 22 23 24 |
# File 'lib/wx/shapes/shapes/round_ortho_shape.rb', line 21 def initialize(src = nil, trg = nil, path: nil, diagram: nil) super @max_radius = MAX_RADIUS end |
Instance Attribute Details
#max_radius ⇒ Object
Access (set/get) maximum radius.
27 28 29 |
# File 'lib/wx/shapes/shapes/round_ortho_shape.rb', line 27 def max_radius @max_radius end |
Instance Method Details
#draw_line_segment(dc, src, trg, cps) ⇒ Object (protected)
Draw one orthogonal line segment.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/wx/shapes/shapes/round_ortho_shape.rb', line 36 def draw_line_segment(dc, src, trg, cps) if (trg.x == src.x) || (trg.y == src.y) dc.draw_line(src.to_point, trg.to_point) return end direction = get_segment_direction(src, trg, cps) src_pt = src.to_point trg_pt = trg.to_point dx = trg.x - src.x dy = trg.y - src.y kx = dx < 0 ? -1 : 1 ky = dy < 0 ? 1 : -1 pt_center = Wx::RealPoint.new((src.x + trg.x)/2, (src.y + trg.y)/2) dc.with_brush(Wx::TRANSPARENT_BRUSH) do if is_two_segment(cps) if direction < 1.0 r = (dy * @max_radius/100).abs r = @max_radius if r > @max_radius dc.draw_line(src_pt.x, src_pt.y, (trg.x - r * kx).to_i, src_pt.y) dc.draw_line(trg_pt.x, (src.y - r * ky).to_i, trg_pt.x, trg_pt.y) if r > 0 if (ky > 0 && kx > 0) || (ky < 0 && kx < 0) dc.draw_arc((trg.x - r * kx).to_i, src_pt.y, trg_pt.x, (src.y - r * ky).to_i, (trg.x - r * kx).to_i, (src.y - r * ky).to_i) else dc.draw_arc(trg_pt.x, (src.y - r * ky).to_i, (trg.x - r * kx).to_i, src_pt.y, (trg.x - r * kx).to_i, (src.y - r * ky).to_i) end end else r = (dx * @max_radius/100).abs r = @max_radius if r > @max_radius dc.draw_line(src_pt.x, src_pt.y, src_pt.x, (trg.y + r * ky).to_i) dc.draw_line((src.x + r * kx).to_i, trg_pt.y, trg_pt.x, trg_pt.y) if r > 0 if (ky > 0 && kx > 0) || (ky < 0 && kx < 0) dc.draw_arc((src.x + r * kx).to_i, trg_pt.y, src_pt.x, (trg.y + r * ky).to_i, (src.x + r * kx).to_i, (trg.y + r * ky).to_i) else dc.draw_arc(src_pt.x, (trg.y + r * ky).to_i, (src.x + r * kx).to_i, trg_pt.y, (src.x + r * kx).to_i, (trg.y + r * ky).to_i) end end end else if direction < 1 r = (dy * @max_radius/100).abs r = @max_radius if r > @max_radius dc.draw_line(src_pt.x, src_pt.y, (pt_center.x - r * kx).to_i, src_pt.y) dc.draw_line(pt_center.x.to_i, (src.y - r * ky).to_i, pt_center.x.to_i, (trg.y + r * ky).to_i) dc.draw_line((pt_center.x + r * kx).to_i, trg_pt.y, trg_pt.x, trg_pt.y) if r > 0 if (ky > 0 && kx > 0) || (ky < 0 && kx < 0) dc.draw_arc((pt_center.x - r * kx).to_i, src_pt.y, pt_center.x.to_i, (src.y - r * ky).to_i, (pt_center.x - r * kx).to_i, (src.y - r * ky).to_i) dc.draw_arc((pt_center.x + r * kx).to_i, trg_pt.y, pt_center.x.to_i, (trg.y + r * ky).to_i, (pt_center.x + r * kx).to_i, (trg.y + r * ky).to_i) else dc.draw_arc(pt_center.x.to_i, (src.y - r * ky).to_i, (pt_center.x - r * kx).to_i, src_pt.y, (pt_center.x - r * kx).to_i, (src.y - r * ky).to_i) dc.draw_arc(pt_center.x.to_i, (trg.y + r * ky).to_i, (pt_center.x + r * kx).to_i, trg_pt.y, (pt_center.x + r * kx).to_i, (trg.y + r * ky).to_i) end end else r = (dx * @max_radius/100).abs r = @max_radius if r > @max_radius dc.draw_line(src_pt.x, src_pt.y, src_pt.x, (pt_center.y + r * ky).to_i) dc.draw_line((src.x + r * kx).to_i, pt_center.y.to_i, (trg.x - r * kx).to_i, pt_center.y.to_i) dc.draw_line(trg_pt.x, (pt_center.y - r * ky).to_i, trg_pt.x, trg_pt.y) if r > 0 if (ky > 0 && kx > 0) || (ky < 0 && kx < 0) dc.draw_arc((src.x + r * kx).to_i, pt_center.y.to_i, src_pt.x, (pt_center.y + r * ky).to_i, (src.x + r * kx).to_i, (pt_center.y + r * ky).to_i) dc.draw_arc((trg.x - r * kx).to_i, pt_center.y.to_i, trg_pt.x, (pt_center.y - r * ky).to_i, (trg.x - r * kx).to_i, (pt_center.y - r * ky).to_i) else dc.draw_arc(src_pt.x, (pt_center.y + r * ky).to_i, (src.x + r * kx).to_i, pt_center.y.to_i, (src.x + r * kx).to_i, (pt_center.y + r * ky).to_i) dc.draw_arc(trg_pt.x, (pt_center.y - r * ky).to_i, (trg.x - r * kx).to_i, pt_center.y.to_i, (trg.x - r * kx).to_i, (pt_center.y - r * ky).to_i) end end end end end end |