@@ -404,7 +404,7 @@ function find_icon(system::ODESystem, design_path::String)
404404end
405405
406406
407- function is_tuple_approx (a:: Tuple{Float64,Float64 } , b:: Tuple{Float64,Float64 } ; atol)
407+ function is_tuple_approx (a:: Tuple{<:Number,<:Number } , b:: Tuple{<:Number,<:Number } ; atol)
408408
409409 r1 = isapprox (a[1 ], b[1 ]; atol)
410410 r2 = isapprox (a[2 ], b[2 ]; atol)
@@ -549,9 +549,6 @@ function view(design::ODESystemDesign, interactive = true)
549549 end
550550
551551
552-
553- elseif plt isa Lines
554-
555552 elseif plt isa Scatter
556553
557554 point = plt
@@ -580,6 +577,18 @@ function view(design::ODESystemDesign, interactive = true)
580577
581578 elseif plt isa Mesh
582579
580+ triangles = plt[1 ][]
581+ points = map (x-> sum (x. points)/ length (x. points), triangles)
582+ x,y = sum (points)/ length (points)
583+
584+ selected_component = filtersingle (
585+ c -> is_tuple_approx (c. xy[], (x, y); atol = 1e-3 ),
586+ design. components,
587+ )
588+ if ! isnothing (selected_component)
589+ selected_component. color[] = :pink
590+ dragging[] = true
591+ end
583592
584593
585594 end
@@ -949,6 +958,8 @@ function draw_box!(ax::Axis, design::ODESystemDesign)
949958 xo = Observable (zeros (5 ))
950959 yo = Observable (zeros (5 ))
951960
961+ points = Observable ([(0. , 0. ), (1. , 0. ), (1. , 1. ), (0. , 1. )])
962+
952963
953964 Δh_, linewidth = if ModelingToolkit. isconnector (design. system)
954965 0.6 * Δh, 2
@@ -961,9 +972,16 @@ function draw_box!(ax::Axis, design::ODESystemDesign)
961972 y = val[2 ]
962973
963974 xo[], yo[] = box (x, y, Δh_)
975+
976+ new_points = Tuple{Float64, Float64}[]
977+ for i= 1 : 4
978+ push! (new_points, (xo[][i], yo[][i]))
979+ end
980+ points[] = new_points
964981 end
965982
966983
984+ poly! (ax, points, color= :white )
967985 lines! (ax, xo, yo; color = design. color, linewidth)
968986
969987
0 commit comments