From 2512a36fe89433aeb9eb858edee2727dc0e194ef Mon Sep 17 00:00:00 2001 From: David Sagan Date: Sun, 14 Jul 2024 22:02:40 -0400 Subject: [PATCH] Fix Tao `python floor_plan` command. --- tao/code/tao_plot_mod.f90 | 31 +++++++++++-- tao/code/tao_python_cmd.f90 | 90 ++++++++++++++++--------------------- tao/code/tao_struct.f90 | 6 +++ 3 files changed, 73 insertions(+), 54 deletions(-) diff --git a/tao/code/tao_plot_mod.f90 b/tao/code/tao_plot_mod.f90 index 8bef5387ef..586b507ad6 100644 --- a/tao/code/tao_plot_mod.f90 +++ b/tao/code/tao_plot_mod.f90 @@ -434,13 +434,15 @@ subroutine tao_draw_floor_plan (plot, graph) ! Draw for a particular universe +if (allocated(graph%floor_list)) deallocate(graph%floor_list) + if (graph%ix_universe == -2) then do isu = 1, size(s%u) - call draw_this_floor_plan(isu) + call draw_this_floor_plan(isu, plot, graph) enddo else isu = tao_universe_index(graph%ix_universe) - call draw_this_floor_plan(isu) + call draw_this_floor_plan(isu, plot, graph) endif ! Hook routine for more plotting if desired... @@ -452,8 +454,10 @@ subroutine tao_draw_floor_plan (plot, graph) !------------------------------------------------------------- contains -subroutine draw_this_floor_plan(isu) +subroutine draw_this_floor_plan(isu, plot, graph) +type (tao_plot_struct) :: plot +type (tao_graph_struct) :: graph type (tao_ele_shape_struct), pointer :: ele_shape, ele_shape2 type (tao_lattice_struct), pointer :: tao_lat type (tao_building_wall_point_struct) pt0, pt1 @@ -661,6 +665,7 @@ recursive subroutine tao_draw_ele_for_floor_plan (plot, graph, tao_lat, ele, ele type (coord_struct), pointer :: orbit(:) type (coord_struct) orb_here, orb_start, orb_end type (tao_shape_pattern_struct), pointer :: pat +type (tao_floor_plan_ele), allocatable :: floor_ele(:) integer, parameter :: n_bend_extra = 40, l1 = -n_bend_extra, l2 = 200 + n_bend_extra integer i, j, k, n_bend, n, ix, ic, n_mid, min1_bend, min2_bend, max1_bend, max2_bend @@ -693,6 +698,26 @@ recursive subroutine tao_draw_ele_for_floor_plan (plot, graph, tao_lat, ele, ele call find_element_ends (ele, ele1, ele2) if (.not. associated(ele1)) return +if (.not. allocated(graph%floor_list)) then + allocate(graph%floor_list(1)) + n = 1 +else + n = size(graph%floor_list) + 1 + call move_alloc(graph%floor_list, floor_ele) + allocate(graph%floor_list(n)) + graph%floor_list(:n-1) = floor_ele +endif + +graph%floor_list(n)%ele_loc = ele_loc(ele) + +if (associated(ele_shape)) then + graph%floor_list(n)%shape = ele_shape +else + graph%floor_list(n)%shape%shape = null_name$ +endif + +! + orbit => tao_lat%tao_branch(ele1%ix_branch)%orbit orb_start = orbit(ele1%ix_ele) diff --git a/tao/code/tao_python_cmd.f90 b/tao/code/tao_python_cmd.f90 index 87b1280fb3..b565590f50 100644 --- a/tao/code/tao_python_cmd.f90 +++ b/tao/code/tao_python_cmd.f90 @@ -139,6 +139,7 @@ subroutine tao_python_cmd (input_str) type (tao_ele_shape_struct), pointer :: shapes(:) type (tao_ele_shape_struct), allocatable :: shapes_temp(:) type (tao_ele_shape_struct), pointer :: shape +type (tao_ele_shape_struct) :: ashape type (tao_ele_shape_input) shape_input type (photon_element_struct), pointer :: ph type (qp_axis_struct) x_ax, y_ax @@ -4267,57 +4268,44 @@ subroutine tao_python_cmd (input_str) u => tao_pointer_to_universe(g%ix_universe, .true.) lat => u%model%lat - do ib = 0, ubound(lat%branch, 1) - branch => lat%branch(ib) - do i = 1, branch%n_ele_max - ele => branch%ele(i) - if (ele%slave_status == super_slave$) cycle - if (ele%lord_status == multipass_lord$) cycle - if (ele%key == overlay$) cycle - if (ele%key == group$) cycle - if (ele%key == girder$) cycle - - ix_shape_min = 1 - first_time = .true. - do - call tao_ele_shape_info (g%ix_universe, ele, s%plot_page%lat_layout%ele_shape, shape, label_name, y1, y2, ix_shape_min) - if (associated(shape)) then - color = shape%color - shape_shape = shape%shape - line_width = shape%line_width - else - if (.not. first_time) exit - y1 = 0 - y2 = 0 - color = '' - label_name = '' - shape_shape = '' - line_width = 0 - endif - first_time = .false. - - call find_element_ends(ele, ele1, ele2) - floor%r = [0.0_rp, 0.0_rp, 0.0_rp] - floor1 = coords_local_curvilinear_to_floor (floor, ele, .true.) - - floor%r = [0.0_rp, 0.0_rp, ele%value(l$)] - floor2 = coords_local_curvilinear_to_floor (floor, ele, .true.) - call tao_floor_to_screen_coords (g, floor1, end1) - call tao_floor_to_screen_coords (g, floor2, end2) - if (ele%key == sbend$) then - nl=incr(nl); write (li(nl), '(2(i0, a), 2a, 6(es14.7, a), (i0, a), 2a, 2(es10.2, a), 4a, 4(es14.7, a))') ib, ';', i, ';', & - trim(key_name(ele%key)), ';', end1%r(1), ';', end1%r(2), ';', end1%theta, ';', & - end2%r(1), ';', end2%r(2), ';', end2%theta, ';', & - line_width, ';', trim(shape_shape), ';', y1, ';', y2, ';', trim(color), ';', trim(label_name), ';', & - ele%value(l$), ';', ele%value(angle$), ';', ele%value(e1$), ';', ele%value(e2$) - else - nl=incr(nl); write (li(nl), '(2(i0, a), 2a, 6(es14.7, a), (i0, a), 2a, 2(es10.2, a), 4a)') ib, ';', i, ';', & - trim(key_name(ele%key)), ';', end1%r(1), ';', end1%r(2), ';', end1%theta, ';', & - end2%r(1), ';', end2%r(2), ';', end2%theta, ';', & - line_width, ';', trim(shape_shape), ';', y1, ';', y2, ';', trim(color), ';', trim(label_name) - endif - enddo - enddo + do i = 1, size(g%floor_list) + ele => pointer_to_ele(lat, g%floor_list(i)%ele_loc) + ashape = g%floor_list(i)%shape + if (ashape%shape == null_name$) then + y1 = 0 + y2 = 0 + color = '' + label_name = '' + shape_shape = '' + line_width = 0 + else + color = ashape%color + shape_shape = ashape%shape + line_width = ashape%line_width + endif + + call find_element_ends(ele, ele1, ele2) + floor%r = [0.0_rp, 0.0_rp, 0.0_rp] + floor1 = coords_local_curvilinear_to_floor (floor, ele, .true.) + + floor%r = [0.0_rp, 0.0_rp, ele%value(l$)] + floor2 = coords_local_curvilinear_to_floor (floor, ele, .true.) + call tao_floor_to_screen_coords (g, floor1, end1) + call tao_floor_to_screen_coords (g, floor2, end2) + if (ele%key == sbend$) then + nl=incr(nl); write (li(nl), '(2(i0, a), 2a, 6(es14.7, a), (i0, a), 2a, 2(es10.2, a), 4a, 4(es14.7, a))') & + ele%ix_branch, ';', ele%ix_ele, ';', & + trim(key_name(ele%key)), ';', end1%r(1), ';', end1%r(2), ';', end1%theta, ';', & + end2%r(1), ';', end2%r(2), ';', end2%theta, ';', & + line_width, ';', trim(shape_shape), ';', y1, ';', y2, ';', trim(color), ';', trim(label_name), ';', & + ele%value(l$), ';', ele%value(angle$), ';', ele%value(e1$), ';', ele%value(e2$) + else + nl=incr(nl); write (li(nl), '(2(i0, a), 2a, 6(es14.7, a), (i0, a), 2a, 2(es10.2, a), 4a)') & + ele%ix_branch, ';', ele%ix_ele, ';', & + trim(key_name(ele%key)), ';', end1%r(1), ';', end1%r(2), ';', end1%theta, ';', & + end2%r(1), ';', end2%r(2), ';', end2%theta, ';', & + line_width, ';', trim(shape_shape), ';', y1, ';', y2, ';', trim(color), ';', trim(label_name) + endif enddo !------------------------------------------------------------------------------------------------ diff --git a/tao/code/tao_struct.f90 b/tao/code/tao_struct.f90 index 44850fcca6..11ae4a083c 100644 --- a/tao/code/tao_struct.f90 +++ b/tao/code/tao_struct.f90 @@ -230,6 +230,11 @@ module tao_struct ! This is used with floor_plan drawings. +type tao_floor_plan_ele + type (lat_ele_loc_struct) :: ele_loc + type (tao_ele_shape_struct) :: shape +end type + type tao_floor_plan_struct character(2) :: view = 'zx' ! or 'xz'. real(rp) :: rotation = 0 ! Rotation of floor plan plot: 1.0 -> 360^deg @@ -260,6 +265,7 @@ module tao_struct type (tao_curve_struct), allocatable :: curve(:) type (tao_plot_struct), pointer :: p => null() ! pointer to parent plot type (tao_floor_plan_struct) :: floor_plan = tao_floor_plan_struct() + type (tao_floor_plan_ele), allocatable :: floor_list(:) ! Store what is drawn. Used by "python floor_plan" command. type (qp_point_struct) :: text_legend_origin = qp_point_struct() type (qp_point_struct) :: curve_legend_origin = qp_point_struct() type (qp_axis_struct) :: x = qp_axis_struct() ! X-axis parameters.