Class: Wx::SF::CurveShape
- Defined in:
- lib/wx/shapes/shapes/curve_shape.rb
Overview
Interpolation line shape. The class extends LineShape class and allows user to create curved connection line.
Instance Method Summary collapse
-
#draw_complete_line(dc) ⇒ Object
protected
Internal function used for drawing of completed line shape.
-
#get_bounding_box ⇒ Wx::Rect
Get line’s bounding box.
-
#get_point(segment, offset) ⇒ Wx::RealPoint
Get a line point laying on the given line segment and shifted from the beginning of the segment by given offset.
-
#initialize(*args, **kwargs) ⇒ CurveShape
constructor
A new instance of CurveShape.
Methods inherited from LineShape
#contains?, #create_handles, #draw_highlighted, #draw_hover, #draw_normal, #get_absolute_position, #get_border_point, #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_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 = DEFAULT::POINT, trg = DEFAULT::POINT, path: nil, manager: nil) ⇒ CurveShape #initialize(src, trg, path: nil, manager: nil) ⇒ CurveShape
Returns a new instance of CurveShape.
24 25 26 |
# File 'lib/wx/shapes/shapes/curve_shape.rb', line 24 def initialize(*args, **kwargs) super end |
Instance Method Details
#draw_complete_line(dc) ⇒ Object (protected)
Internal function used for drawing of completed line shape.
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 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/wx/shapes/shapes/curve_shape.rb', line 53 def draw_complete_line(dc) case @mode when LINEMODE::READY # draw line segments b = c = nil if !@lst_points.empty? (0..@lst_points.size).each do |i| a,b,c,d = get_segment_quaternion(i) if i == 0 && @src_arrow src, trg = get_line_segment(i) src = @src_arrow.draw(trg, src, dc) a = b = src.to_real end if i == @lst_points.size && @trg_arrow src, trg = get_line_segment(i) trg = @trg_arrow.draw(src, trg, dc) c = d = trg.to_real end catmul_rom_kubika(a, b, c, d, dc, at_end: i == @lst_points.size) end else src, trg = get_direct_line.collect(&:to_point) src = @src_arrow.draw(trg, src, dc) if @src_arrow trg = @trg_arrow.draw(src, trg, dc) if @trg_arrow dc.draw_line(src, trg) end when LINEMODE::UNDERCONSTRUCTION # draw basic line parts c = nil unless @lst_points.empty? @lst_points.size.times do |i| a,b,c,d = get_segment_quaternion(i) catmul_rom_kubika(a, b, c, d, dc) end end # draw unfinished line segment if any (for interactive line creation) dc.with_pen(Wx::Pen.new(Wx::BLACK, 1, Wx::PenStyle::PENSTYLE_DOT)) do if @lst_points.size > 1 dc.draw_line(c.to_point, @unfinished_point) elsif @src_shape # draw unfinished line segment if any (for interactive line creation) dc.with_pen(Wx::Pen.new(Wx::BLACK, 1, Wx::PenStyle::PENSTYLE_DOT)) do if @src_shape.get_connection_points.empty? dc.draw_line((@src_shape.get_border_point(@src_shape.get_center, @unfinished_point.to_real)).to_point, @unfinished_point) else dc.draw_line(get_mod_src_point.to_point, @unfinished_point) end end end end when LINEMODE::SRCCHANGE # draw basic line parts c = nil @lst_points.size.times do |i| a,b,c,d = get_segment_quaternion(i+1) catmul_rom_kubika(a, b, c, d, dc) end # draw linesegment being updated dc.with_pen(Wx::Pen.new(Wx::BLACK, 1, Wx::PenStyle::PENSTYLE_DOT)) do if !@lst_points.empty? _,_,c,_ = get_segment_quaternion(0) else _,c = get_direct_line end dc.draw_line(@unfinished_point, c.to_point) end when LINEMODE::TRGCHANGE # draw basic line parts c = nil if !@lst_points.empty? @lst_points.size.times do |i| a,b,c,d = get_segment_quaternion(i) catmul_rom_kubika(a, b, c, d, dc) end else c = get_src_point end # draw linesegment being updated dc.with_pen(Wx::Pen.new(Wx::BLACK, 1, Wx::PenStyle::PENSTYLE_DOT)) do dc.draw_line(@unfinished_point, c.to_point) end end end |
#get_bounding_box ⇒ Wx::Rect
Get line’s bounding box. The function can be overridden if necessary.
30 31 32 |
# File 'lib/wx/shapes/shapes/curve_shape.rb', line 30 def get_bounding_box super.inflate(35, 35) end |
#get_point(segment, offset) ⇒ Wx::RealPoint
Get a line point laying on the given line segment and shifted from the beginning of the segment by given offset. the line-point offset inside the line segment
40 41 42 43 44 45 46 47 |
# File 'lib/wx/shapes/shapes/curve_shape.rb', line 40 def get_point(segment, offset) if segment <= @lst_points.size a,b,c,d = get_segment_quaternion(segment) coord_catmul_rom_kubika(a, b, c, d, offset) else Wx::RealPoint.new end end |