!+ ! Subroutine tao_hook_draw_floor_plan (plot, graph) ! ! Subroutine to customize the plotting of the floor_plan. ! Also see: tao_hook_draw_graph. ! ! Input: ! plot -- Tao_plot_struct: Plot structure containing the graph. ! graph -- Tao_graph_struct: The graph to calculate the data for. !- subroutine tao_hook_draw_floor_plan (plot, graph) use tao_interface, dummy => tao_hook_draw_floor_plan use synrad3d_parse_wall use synrad3d_plot_mod use quick_plot implicit none type (tao_plot_struct) plot type (tao_graph_struct) graph type (lat_struct), pointer :: lat type (branch_struct), pointer :: branch type (ele_struct), pointer :: ele type (floor_position_struct) :: screen real(rp) s_min, s_max, chamber_width_scale real(rp) x_min, x_max, y_min, y_max, r_max integer iu, icol, isu, ib, ie, ios, ix_branch logical no_wall_here, inside_plot character(16) wall_color, draw_units character(200) synrad3d_wall_file character(*), parameter :: r_name = 'tao_hook_draw_floor_plan' namelist / hook_params / synrad3d_wall_file, chamber_width_scale, wall_color, ix_branch ! Read parameter file iu = lunget() open (iu, file = s%com%hook_init_file, iostat = ios) if (ios /= 0) then call out_io (s_warn$, r_name, 'File not found: ' // s%com%hook_init_file) return endif read (iu, nml = hook_params, iostat = ios) close(iu) if (ios /= 0) then call out_io (s_error$, r_name, 'CANNOT READ HOOK_PARAMS NAMELIST IN FILE: ' // s%com%hook_init_file) return endif if (graph%floor_plan_size_is_absolute) then draw_units = 'DATA' else draw_units = 'POINTS' endif ! Read wall file isu = tao_universe_number(graph%ix_universe) lat => s%u(isu)%model%lat ! Find sections of the lattice that are within the plot boundary and plot the associated wall. r_max = 100 call qp_get_axis_attrib ('X', x_min, x_max) call qp_get_axis_attrib ('Y', y_min, y_max) call sr3d_read_wall_file (synrad3d_wall_file, lat) do ib = ix_branch, ix_branch branch => lat%branch(ib) s_min = -1 do ie = 1, branch%n_ele_track ele => branch%ele(ie) call tao_floor_to_screen_coords (graph, ele%floor, screen) inside_plot = (x_min < screen%r(1) .and. screen%r(1) < x_max .and. & y_min < screen%r(2) .and. screen%r(2) < y_max) if (inside_plot) then if (s_min == -1) s_min = ele%s else if (s_min > -1) then call plot_this_wall (s_min, ele%s) s_min = -1 endif endif enddo if (s_min /= -1) call plot_this_wall (s_min, branch%ele(branch%n_ele_track)%s) enddo !------------------------------------------------------------ contains subroutine plot_this_wall (s_min, s_max) integer, parameter :: n_pts = 401 type (sr3d_photon_track_struct), target :: photon type (floor_position_struct) :: local, floor, screen, local0, floor0 type (floor_position_struct) :: wall_minus(n_pts), wall_plus(n_pts), w, w0 real(rp) s_min, s_max, s_here, x_minus, x_plus, x_wall, y_wall integer ip, iw ! do ip = 1, n_pts ! Look over s positions s_here = s_min + (ip - 1) * (s_max - s_min) / (n_pts - 1) x_minus = 0 x_plus = 0 do iw = 1, size(branch%wall3d) photon%now%orb%vec = 0 photon%now%orb%s = s_here photon%now%ix_wall3d = iw photon%now%orb%vec(1) = -r_max call sr3d_find_wall_point (photon, branch, x_wall, y_wall, no_wall_here) x_minus = min(x_minus, x_wall) photon%now%orb%vec(1) = r_max call sr3d_find_wall_point (photon, branch, x_wall, y_wall, no_wall_here) x_plus = max(x_plus, x_wall) enddo ele => pointer_to_element_at_s (branch, s_here, .false.) if (draw_units == 'DATA') then local%r = [chamber_width_scale * x_minus, 0.0_rp, s_here - (ele%s - ele%value(l$))] floor = coords_local_curvilinear_to_floor (local, ele) call tao_floor_to_screen_coords (graph, floor, wall_minus(ip)) local%r = [chamber_width_scale * x_plus, 0.0_rp, s_here - (ele%s - ele%value(l$))] floor = coords_local_curvilinear_to_floor (local, ele) call tao_floor_to_screen_coords (graph, floor, wall_plus(ip)) else local0%r = [0.0_rp, 0.0_rp, s_here - (ele%s - ele%value(l$))] floor0 = coords_local_curvilinear_to_floor (local0, ele) call tao_floor_to_screen_coords (graph, floor0, w0) local%r = [1.0_rp, 0.0_rp, s_here - (ele%s - ele%value(l$))] floor = coords_local_curvilinear_to_floor (local, ele) call tao_floor_to_screen_coords (graph, floor, w) wall_minus(ip)%r = w0%r + x_minus * chamber_width_scale * (w%r - w0%r) wall_plus(ip)%r = w0%r + x_plus * chamber_width_scale * (w%r - w0%r) endif enddo icol = qp_string_to_enum(wall_color, 'color', -1) if (icol == -1) then call out_io (s_error$, r_name, 'BAD WALL_COLOR NAME: ' // wall_color) wall_color = 'red' endif call qp_draw_polyline (wall_minus%r(1), wall_minus%r(2), units = 'DATA', color = wall_color, clip = .true.) call qp_draw_polyline (wall_plus%r(1), wall_plus%r(2), units = 'DATA', color = wall_color, clip = .true.) end subroutine plot_this_wall end subroutine tao_hook_draw_floor_plan