Skip to content

Commit

Permalink
Fixed Tao curve legend plotting. (bmad-sim#1337)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidSagan authored Dec 2, 2024
1 parent dff6770 commit 4ffe71f
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 29 deletions.
8 changes: 3 additions & 5 deletions sim_utils/plot/quick_plot.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2973,11 +2973,9 @@ subroutine qp_draw_curve_legend (origin, legend, line, symbol, text)

! Draw the rows

yc = yc - 1.1 * height
yc2 = yc - 0.6 * height

do i = 1, n_rows
yc2 = yc + 0.5 * height * legend%row_spacing

if (has_line) then
if (line(i)%width > -1) then
call qp_set_line ('STD', line(i))
Expand All @@ -2994,10 +2992,10 @@ subroutine qp_draw_curve_legend (origin, legend, line, symbol, text)

if (has_text) then
call qp_set_text_attrib ('LEGEND')
call qp_draw_text_no_set (text(i), xc + line_len + text_off, yc, 'INCH/PAGE/LB')
call qp_draw_text_no_set (text(i), xc + line_len + text_off, yc2-0.5*height, 'INCH/PAGE/LB')
endif

yc = yc - 1.5 * height * legend%row_spacing
yc2 = yc2 - 1.0 * height * legend%row_spacing
enddo

call qp_restore_state
Expand Down
3 changes: 2 additions & 1 deletion tao/code/tao_init_plotting.f90
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,8 @@ subroutine tao_init_plotting (plot_file_in)
grph%draw_grid = graph%draw_grid
grph%draw_only_good_user_data_or_vars = graph%draw_only_good_user_data_or_vars
grph%draw_curve_legend = graph%draw_curve_legend
grph%floor_plan = graph%floor_plan
grph%floor_plan = graph%floor_plan
grph%curve_legend = graph%curve_legend
grph%title_suffix = ''
grph%text_legend = ''
grph%y2_mirrors_y = .true.
Expand Down
18 changes: 7 additions & 11 deletions tao/code/tao_input_struct.f90
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ module tao_input_struct
type (qp_axis_struct) :: y = qp_axis_struct()
type (qp_axis_struct) :: x2 = qp_axis_struct()
type (qp_axis_struct) :: y2 = qp_axis_struct()
type (qp_legend_struct) :: curve_legend = qp_legend_struct(1.0_rp, 30.0_rp, 6.0_rp, .true., .true., .true.)
end type

type tao_plot_input
Expand Down Expand Up @@ -192,7 +193,6 @@ module tao_input_struct
type tao_plot_page_input
type (tao_title_struct) :: title = tao_title_struct() ! Title at top of page.
type (tao_title_struct) :: subtitle = tao_title_struct() ! Subtitle at top of page.
type (qp_legend_struct) :: curve_legend = qp_legend_struct()
type (qp_rect_struct) :: border = qp_rect_struct() ! Border around plots edge of page.
character(8) :: plot_display_type = ''
real(rp) :: size(2) = 0.0 ! width and height of window in pixels.
Expand Down Expand Up @@ -267,8 +267,6 @@ subroutine tao_set_plotting (plot_input, plot_page, use_cmd_line_geom, reverse)
plot_input%border = plot_page%border
plot_input%delete_overlapping_plots = plot_page%delete_overlapping_plots
plot_input%draw_graph_title_suffix = plot_page%draw_graph_title_suffix
plot_input%curve_legend_line_len = plot_page%curve_legend%line_length
plot_input%curve_legend_text_offset = plot_page%curve_legend%text_offset
endif

!
Expand All @@ -293,16 +291,14 @@ subroutine tao_set_plotting (plot_input, plot_page, use_cmd_line_geom, reverse)
plot_page%delete_overlapping_plots = plot_input%delete_overlapping_plots
plot_page%draw_graph_title_suffix = plot_input%draw_graph_title_suffix

if (plot_input%curve_legend_line_len == real_garbage$) then
plot_page%curve_legend%line_length = 30 ! Points
else
plot_page%curve_legend%line_length = plot_input%curve_legend_line_len
if (plot_input%curve_legend_line_len /= real_garbage$) then
call out_io(s_error$, r_name, '"plot_page%curve_legend_line_len" has been replaced by "default_graph%curve_legend%line_len".', &
'Please modify the input file. This setting will be ignored.')
endif

if (plot_input%curve_legend_text_offset == real_garbage$) then
plot_page%curve_legend%text_offset = 6 ! Points
else
plot_page%curve_legend%text_offset = plot_input%curve_legend_text_offset
if (plot_input%curve_legend_text_offset /= real_garbage$) then
call out_io(s_error$, r_name, '"plot_page%curve_legend_text_offset" has been replaced by "default_graph%curve_legend%text_offset".', &
'Please modify the input file. This setting will be ignored.')
endif

! Plot window geometry specified on cmd line?
Expand Down
2 changes: 1 addition & 1 deletion tao/code/tao_plot_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1961,7 +1961,7 @@ subroutine tao_draw_graph_axes (plot, graph)
enddo

if (graph%draw_curve_legend .and. (nc > 1 .or. .not. graph%x%draw_label)) then
call qp_draw_curve_legend (graph%curve_legend_origin, s%plot_page%curve_legend, line, symbol, text)
call qp_draw_curve_legend (graph%curve_legend_origin, graph%curve_legend, line, symbol, text)
endif


Expand Down
14 changes: 7 additions & 7 deletions tao/code/tao_show_this.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2407,8 +2407,14 @@ subroutine tao_show_this (what, result_id, lines, nl)
nl=nl+1; write(lines(nl), rmt) 'symbol_size_scale = ', g%symbol_size_scale
nl=nl+1; write(lines(nl), amt) 'text_legend_origin%x,y,units = ', real_str(g%text_legend_origin%x, 3), ', ', &
real_str(g%text_legend_origin%y, 3), ', ', quote(g%text_legend_origin%units)
nl=nl+1; write(lines(nl), amt) 'curve_legend_origin%x,y,units = ', real_str(g%curve_legend_origin%x, 3), ', ', &
nl=nl+1; write(lines(nl), amt) 'curve_legend_origin%x,y,units = ', real_str(g%curve_legend_origin%x, 3), ', ', &
real_str(g%curve_legend_origin%y, 3), ', ', quote(g%curve_legend_origin%units)
nl=nl+1; write(lines(nl), f3mt) 'curve_legend%line_length = ', g%curve_legend%line_length
nl=nl+1; write(lines(nl), f3mt) 'curve_legend%text_offset = ', g%curve_legend%text_offset
nl=nl+1; write(lines(nl), f3mt) 'curve_legend%row_spacing = ', g%curve_legend%row_spacing
nl=nl+1; write(lines(nl), lmt) 'curve_legend%draw_line = ', g%curve_legend%draw_line
nl=nl+1; write(lines(nl), lmt) 'curve_legend%draw_symbol = ', g%curve_legend%draw_symbol
nl=nl+1; write(lines(nl), lmt) 'curve_legend%draw_text = ', g%curve_legend%draw_text

if (g%type == 'floor_plan') then
nl=nl+1; write(lines(nl), amt) 'floor_plan%view = ', quote(g%floor_plan%view)
Expand Down Expand Up @@ -4130,12 +4136,6 @@ subroutine tao_show_this (what, result_id, lines, nl)
nl=nl+1; write(lines(nl), f3mt) ' %lat_layout_text_scale = ', s%plot_page%lat_layout_text_scale
nl=nl+1; write(lines(nl), lmt) ' %delete_overlapping_plots = ', s%plot_page%delete_overlapping_plots
nl=nl+1; write(lines(nl), lmt) ' %draw_graph_title_suffix = ', s%plot_page%draw_graph_title_suffix
nl=nl+1; write(lines(nl), f3mt) ' %curve_legend%line_length = ', s%plot_page%curve_legend%line_length
nl=nl+1; write(lines(nl), f3mt) ' %curve_legend%text_offset = ', s%plot_page%curve_legend%text_offset
nl=nl+1; write(lines(nl), f3mt) ' %curve_legend%row_spacing = ', s%plot_page%curve_legend%row_spacing
nl=nl+1; write(lines(nl), lmt) ' %curve_legend%draw_line = ', s%plot_page%curve_legend%draw_line
nl=nl+1; write(lines(nl), lmt) ' %curve_legend%draw_symbol = ', s%plot_page%curve_legend%draw_symbol
nl=nl+1; write(lines(nl), lmt) ' %curve_legend%draw_text = ', s%plot_page%curve_legend%draw_text


result_id = 'plot:global'
Expand Down
2 changes: 1 addition & 1 deletion tao/code/tao_struct.f90
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ module tao_struct
type (tao_floor_plan_struct) :: floor_plan = tao_floor_plan_struct()
type (qp_point_struct) :: text_legend_origin = qp_point_struct()
type (qp_point_struct) :: curve_legend_origin = qp_point_struct()
type (qp_legend_struct) :: curve_legend = qp_legend_struct()
type (qp_axis_struct) :: x = qp_axis_struct() ! X-axis parameters.
type (qp_axis_struct) :: y = qp_axis_struct() ! Y-axis attributes.
type (qp_axis_struct) :: x2 = qp_axis_struct() ! X2-axis attributes (Not currently used).
Expand Down Expand Up @@ -337,7 +338,6 @@ module tao_struct
type (tao_drawing_struct) :: floor_plan = tao_drawing_struct(null())
type (tao_drawing_struct) :: lat_layout = tao_drawing_struct(null())
type (tao_shape_pattern_struct), allocatable :: pattern(:)
type (qp_legend_struct) :: curve_legend = qp_legend_struct()
type (tao_plot_struct), allocatable :: template(:) ! Templates for the plots.
type (tao_plot_region_struct), allocatable :: region(:)
character(8) :: plot_display_type = 'X' ! 'X' or 'TK'
Expand Down
2 changes: 1 addition & 1 deletion tao/doc/cover-page.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

\begin{flushright}
\large
Revision: November 25, 2024 \\
Revision: December 2, 2024 \\
\end{flushright}

\vfill
Expand Down
4 changes: 2 additions & 2 deletions tao/doc/plotting.tex
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,11 @@ \subsection{Curve Legend of a Graph}
Parameters that affect the curve legend are:
\begin{example}
plot_page%legend_text_scale ! Also affects lat_layout and floor_plan text size.
plot_page%curve_legend_line_len ! tao_plot_page namelist (\sref{s:plot.page})
plot_page%curve_legend_text_offset ! tao_plot_page namelist (\sref{s:plot.page})
curve(N)%legend_text !
graph%curve_legend_origin
graph%draw_curve_legend
graph%curve_legend%line_len ! curve_legend is a qp_legend_struct (\sref{s:qp.legend.str}).
graph%curve_legend%text_offset !
\end{example}
The curve legend is distinct from the \vn{text legend} (\sref{s:text.legend}).
Expand Down

0 comments on commit 4ffe71f

Please sign in to comment.