From 4ffe71fb3057fd0e48cafb67661c04dcd916a8cf Mon Sep 17 00:00:00 2001 From: David Sagan Date: Mon, 2 Dec 2024 05:14:06 -0500 Subject: [PATCH] Fixed Tao curve legend plotting. (#1337) --- sim_utils/plot/quick_plot.f90 | 8 +++----- tao/code/tao_init_plotting.f90 | 3 ++- tao/code/tao_input_struct.f90 | 18 +++++++----------- tao/code/tao_plot_mod.f90 | 2 +- tao/code/tao_show_this.f90 | 14 +++++++------- tao/code/tao_struct.f90 | 2 +- tao/doc/cover-page.tex | 2 +- tao/doc/plotting.tex | 4 ++-- 8 files changed, 24 insertions(+), 29 deletions(-) diff --git a/sim_utils/plot/quick_plot.f90 b/sim_utils/plot/quick_plot.f90 index 537ddba76..a0057fb81 100644 --- a/sim_utils/plot/quick_plot.f90 +++ b/sim_utils/plot/quick_plot.f90 @@ -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)) @@ -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 diff --git a/tao/code/tao_init_plotting.f90 b/tao/code/tao_init_plotting.f90 index 6226e6732..1afdd1f80 100644 --- a/tao/code/tao_init_plotting.f90 +++ b/tao/code/tao_init_plotting.f90 @@ -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. diff --git a/tao/code/tao_input_struct.f90 b/tao/code/tao_input_struct.f90 index a357ed3c5..4ef63d936 100644 --- a/tao/code/tao_input_struct.f90 +++ b/tao/code/tao_input_struct.f90 @@ -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 @@ -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. @@ -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 ! @@ -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? diff --git a/tao/code/tao_plot_mod.f90 b/tao/code/tao_plot_mod.f90 index ef52601d7..5fc894ba2 100644 --- a/tao/code/tao_plot_mod.f90 +++ b/tao/code/tao_plot_mod.f90 @@ -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 diff --git a/tao/code/tao_show_this.f90 b/tao/code/tao_show_this.f90 index b94328e61..5c9a1a2dc 100644 --- a/tao/code/tao_show_this.f90 +++ b/tao/code/tao_show_this.f90 @@ -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) @@ -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' diff --git a/tao/code/tao_struct.f90 b/tao/code/tao_struct.f90 index e67a77e1c..2ad3832af 100644 --- a/tao/code/tao_struct.f90 +++ b/tao/code/tao_struct.f90 @@ -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). @@ -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' diff --git a/tao/doc/cover-page.tex b/tao/doc/cover-page.tex index 2eec7a022..2106c5a21 100644 --- a/tao/doc/cover-page.tex +++ b/tao/doc/cover-page.tex @@ -2,7 +2,7 @@ \begin{flushright} \large -Revision: November 25, 2024 \\ +Revision: December 2, 2024 \\ \end{flushright} \vfill diff --git a/tao/doc/plotting.tex b/tao/doc/plotting.tex index ee1333f95..6d4a58722 100644 --- a/tao/doc/plotting.tex +++ b/tao/doc/plotting.tex @@ -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}).