From 9c1416292b87f96caa6f5e96496adf9488595526 Mon Sep 17 00:00:00 2001 From: mattsignorelli Date: Thu, 14 Nov 2024 15:55:46 -0500 Subject: [PATCH] Added row gap scale factor for curve legends --- bmad/doc/subroutines.tex | 2 +- sim_utils/plot/quick_plot.f90 | 43 +++++++++++++++++----------------- tao/code/tao_init_plotting.f90 | 1 + tao/code/tao_input_struct.f90 | 1 + tao/code/tao_pipe_cmd.f90 | 1 + tao/code/tao_plot_mod.f90 | 2 +- tao/code/tao_set_mod.f90 | 2 ++ tao/code/tao_show_this.f90 | 1 + tao/code/tao_struct.f90 | 1 + tao/doc/initialization.tex | 2 ++ 10 files changed, 33 insertions(+), 23 deletions(-) diff --git a/bmad/doc/subroutines.tex b/bmad/doc/subroutines.tex index a4c6cfc7bf..52b4593422 100644 --- a/bmad/doc/subroutines.tex +++ b/bmad/doc/subroutines.tex @@ -2605,7 +2605,7 @@ \subsection{Quick Plot Drawing Routines} \index[routine]{qp_draw_curve_legend} \label{r:qp.draw.curve.legend} \item[\protect\parbox{6in}{qp_draw_curve_legend (x_origin, y_origin, units, line, line_length, \\ -\hspace*{1in} symbol, text, text_offset, draw_line, draw_symbol, draw_text) }] \Newline +\hspace*{1in} symbol, text, text_offset, row_gap_scale, draw_line, draw_symbol, draw_text) }] \Newline Routine to draw a legend with each line in the legend having a line, a symbol, some text. diff --git a/sim_utils/plot/quick_plot.f90 b/sim_utils/plot/quick_plot.f90 index 73ad47bcf9..459a6b8f7f 100644 --- a/sim_utils/plot/quick_plot.f90 +++ b/sim_utils/plot/quick_plot.f90 @@ -2897,33 +2897,34 @@ end subroutine qp_draw_text_legend !----------------------------------------------------------------------- !+ ! Subroutine qp_draw_curve_legend (x_origin, y_origin, units, line, line_length, -! symbol, text, text_offset, draw_line, draw_symbol, draw_text) +! symbol, text, text_offset, row_gap_scale, draw_line, draw_symbol, draw_text) ! ! Subroutine to draw a legend with each line in the legend having ! a line, a symbol, some text. ! ! Input: -! x_origin -- Real(rp), optional: x-postion of start of the first line. -! y_origin -- Real(rp), optional: y-postion of start of the first line. -! units -- Character(*), optional: Units of x_origin, y_origin. -! Default is: 'DATA/GRAPH/LB' -! See quick_plot writeup for more details. -! line(:) -- qp_line_struct, optional: Array of lines. -! Set line(i)%width < 0 to suppress drawing of the i^th line -! line_length -- Real(rp), optional: Length of the line in points. Default is 72 pts (~ 1 inch). -! symbol(:) -- qp_symbol_struct, optional: Array of symbols. -! Set symbol(i)%type < 0 to suppress drawing of the i^th symbol. -! text(:) -- Character(*), optional: Array of text lines. -! text_offset -- Real(rp), optional: Horizontal offset in points between the line and the text. -! Default is 10 pt. -! draw_line -- Logical, optional: Draw lines? Default is True if line arg is present. -! Line style set by the LEGEND line style. See qp_set_line_attrib. -! draw_symbol -- Logical, optional: Draw symbols? Default is True if symbol arg is present. -! draw_text -- Logical, optional: Draw text? Default is True if text arg is present. +! x_origin -- Real(rp), optional: x-postion of start of the first line. +! y_origin -- Real(rp), optional: y-postion of start of the first line. +! units -- Character(*), optional: Units of x_origin, y_origin. +! Default is: 'DATA/GRAPH/LB' +! See quick_plot writeup for more details. +! line(:) -- qp_line_struct, optional: Array of lines. +! Set line(i)%width < 0 to suppress drawing of the i^th line +! line_length -- Real(rp), optional: Length of the line in points. Default is 72 pts (~ 1 inch). +! symbol(:) -- qp_symbol_struct, optional: Array of symbols. +! Set symbol(i)%type < 0 to suppress drawing of the i^th symbol. +! text(:) -- Character(*), optional: Array of text lines. +! text_offset -- Real(rp), optional: Horizontal offset in points between the line and the text. +! Default is 10 pt. +! row_gap_scale -- Real(rp), optional: Scale factor for gap size between entries in a legend. Default is 1. +! draw_line -- Logical, optional: Draw lines? Default is True if line arg is present. +! Line style set by the LEGEND line style. See qp_set_line_attrib. +! draw_symbol -- Logical, optional: Draw symbols? Default is True if symbol arg is present. +! draw_text -- Logical, optional: Draw text? Default is True if text arg is present. !- subroutine qp_draw_curve_legend (x_origin, y_origin, units, line, line_length, & - symbol, text, text_offset, draw_line, draw_symbol, draw_text) + symbol, text, text_offset, row_gap_scale, draw_line, draw_symbol, draw_text) implicit none @@ -2931,7 +2932,7 @@ subroutine qp_draw_curve_legend (x_origin, y_origin, units, line, line_length, & type (qp_symbol_struct), optional :: symbol(:) real(rp) x_origin, y_origin -real(rp), optional :: line_length, text_offset +real(rp), optional :: line_length, text_offset, row_gap_scale real(rp) height, xc, yc, yc2, line_len, dummy, text_off integer i, n_rows @@ -2948,7 +2949,7 @@ subroutine qp_draw_curve_legend (x_origin, y_origin, units, line, line_length, & call qp_set_text_attrib ('LEGEND') call qp_set_line_attrib ('LEGEND') -height = qp_text_height_to_inches(qp_com%this_text%height) +height = real_option(1.0_rp, row_gap_scale)*qp_text_height_to_inches(qp_com%this_text%height) call qp_to_inch_abs (x_origin, y_origin, xc, yc, units) diff --git a/tao/code/tao_init_plotting.f90 b/tao/code/tao_init_plotting.f90 index 7e5dfd1510..0b647e6c82 100644 --- a/tao/code/tao_init_plotting.f90 +++ b/tao/code/tao_init_plotting.f90 @@ -505,6 +505,7 @@ function old_style_title_syntax(iu) result (is_old_style) grph%type = graph%type grph%x_axis_scale_factor = graph%x_axis_scale_factor grph%symbol_size_scale = graph%symbol_size_scale + grph%curve_legend_row_gap_scale = graph%curve_legend_row_gap_scale grph%text_legend_origin = graph%text_legend_origin grph%curve_legend_origin = graph%curve_legend_origin grph%box = graph%box diff --git a/tao/code/tao_input_struct.f90 b/tao/code/tao_input_struct.f90 index 1078a3f846..8289d2f446 100644 --- a/tao/code/tao_input_struct.f90 +++ b/tao/code/tao_input_struct.f90 @@ -123,6 +123,7 @@ module tao_input_struct integer :: n_curve = -1 real(rp) :: x_axis_scale_factor = 1 real(rp) :: symbol_size_scale = 0 + real(rp) :: curve_legend_row_gap_scale = 1 real(rp) :: floor_plan_rotation = real_garbage$ ! deprecated. Use g%floor_plan%... real(rp) :: floor_plan_orbit_scale = -1 ! deprecated. Use g%floor_plan%... logical :: floor_plan_flip_label_side = .false. ! deprecated. Use g%floor_plan%... diff --git a/tao/code/tao_pipe_cmd.f90 b/tao/code/tao_pipe_cmd.f90 index 9919ea67e5..d403269798 100644 --- a/tao/code/tao_pipe_cmd.f90 +++ b/tao/code/tao_pipe_cmd.f90 @@ -5413,6 +5413,7 @@ subroutine tao_pipe_cmd (input_str) nl=incr(nl); write (li(nl), amt) 'why_invalid;STR;F;', trim(g%why_invalid) nl=incr(nl); write (li(nl), rmt) 'x_axis_scale_factor;REAL;T;', g%x_axis_scale_factor nl=incr(nl); write (li(nl), rmt) 'symbol_size_scale;REAL;T;', g%symbol_size_scale + nl=incr(nl); write (li(nl), rmt) 'curve_legend_row_gap_scale;REAL;T;', g%curve_legend_row_gap_scale nl=incr(nl); write (li(nl), jmt) g%ix_universe, '^ix_branch;INUM;T;', g%ix_branch nl=incr(nl); write (li(nl), imt) 'ix_universe;INUM;T;', g%ix_universe nl=incr(nl); write (li(nl), lmt) 'clip;LOGIC;T;', g%clip diff --git a/tao/code/tao_plot_mod.f90 b/tao/code/tao_plot_mod.f90 index 1ea72e6d0f..2062992271 100644 --- a/tao/code/tao_plot_mod.f90 +++ b/tao/code/tao_plot_mod.f90 @@ -1963,7 +1963,7 @@ subroutine tao_draw_graph_axes (plot, graph) if (graph%draw_curve_legend .and. nc > 1) then call qp_draw_curve_legend (graph%curve_legend_origin%x, graph%curve_legend_origin%y, & graph%curve_legend_origin%units, line, s%plot_page%curve_legend_line_len, & - symbol, text, s%plot_page%curve_legend_text_offset) + symbol, text, s%plot_page%curve_legend_text_offset, graph%curve_legend_row_gap_scale) endif diff --git a/tao/code/tao_set_mod.f90 b/tao/code/tao_set_mod.f90 index d6f6b49967..0dd2df3e03 100644 --- a/tao/code/tao_set_mod.f90 +++ b/tao/code/tao_set_mod.f90 @@ -2041,6 +2041,8 @@ subroutine set_this_graph (this_graph) call tao_set_qp_rect_struct (comp, sub_comp, this_graph%margin, value, error, u%ix_uni) case ('name') this_graph%name = value_str +case ('curve_legend_row_gap_scale') + call tao_set_real_value(this_graph%curve_legend_row_gap_scale, component, value, error, dflt_uni = u%ix_uni) case ('scale_margin') call tao_set_qp_rect_struct (comp, sub_comp, this_graph%scale_margin, value, error, u%ix_uni) case ('symbol_size_scale') diff --git a/tao/code/tao_show_this.f90 b/tao/code/tao_show_this.f90 index 6d3aa3bbd4..6c31895b40 100644 --- a/tao/code/tao_show_this.f90 +++ b/tao/code/tao_show_this.f90 @@ -2400,6 +2400,7 @@ subroutine tao_show_this (what, result_id, lines, nl) nl=nl+1; write(lines(nl), rmt) 'x_axis_scale_factor = ', g%x_axis_scale_factor nl=nl+1; write(lines(nl), rmt) 'symbol_size_scale = ', g%symbol_size_scale + nl=nl+1; write(lines(nl), rmt) 'curve_legend_row_gap_scale = ', g%curve_legend_row_gap_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), ', ', & diff --git a/tao/code/tao_struct.f90 b/tao/code/tao_struct.f90 index 86c9c89410..9b0c9d2b2d 100644 --- a/tao/code/tao_struct.f90 +++ b/tao/code/tao_struct.f90 @@ -274,6 +274,7 @@ module tao_struct type (qp_rect_struct) :: scale_margin = qp_rect_struct() ! Margin for scaling real(rp) :: x_axis_scale_factor = 1 ! x-axis conversion from internal to plotting units. real(rp) :: symbol_size_scale = 0 ! Symbol size scale factor for phase_space plots. + real(rp) :: curve_legend_row_gap_scale = 1 ! Row gap scale factor for each entry in the curve legend. integer :: box(4) = 0 ! Defines which box the plot is put in. integer :: ix_branch = -1 ! Branch in lattice. Used when there are no associated curves. integer :: ix_universe = -1 ! Used for lat_layout plots. diff --git a/tao/doc/initialization.tex b/tao/doc/initialization.tex index bbf0e6e14b..296b2adc85 100644 --- a/tao/doc/initialization.tex +++ b/tao/doc/initialization.tex @@ -2470,6 +2470,7 @@ \subsection{Plot Templates} \index{graph_index}\index{graph}\index{graph!name}\index{curve} \index{graph!type}\index{graph!box}\index{graph!title}\index{graph!margin} \index{graph!y2}\index{graph!n_curve}\index{graph!clip}\index{graph!component} +\index{graph!curve_legend_row_gap_scale} \index{graph!symbol_size_scale} \index{curve!data_type}\index{curve!data_source} \index{curve!x_axis_units_factor}\index{curve!y_axis_units_factor} @@ -2507,6 +2508,7 @@ \subsection{Plot Templates} = ! Default = T. graph%x_axis_scale_factor = ! Scale the x-axis by this. graph%n_curve = ! Limit number of curves. + graph%curve_legend_row_gap_scale = ! Scales the row gap width between entries in the legend. curve(N)%name = "" ! Default is "c", = curve num. curve(N)%data_type = "" ! EG: "orbit.x" curve(N)%data_source = "" ! Source for the data curve points