fplot 1.7.1
A Fortran library providing a convenient interface for plotting with Gnuplot.
Loading...
Searching...
No Matches
fplot_legend.f90
1! fplot_legend.f90
2
3submodule(fplot_core) fplot_legend
4contains
5! ------------------------------------------------------------------------------
6 pure module function leg_get_inside(this) result(x)
7 class(legend), intent(in) :: this
8 logical :: x
9 x = this%m_inside
10 end function
11
12! ---------------------
13 module subroutine leg_set_inside(this, x)
14 class(legend), intent(inout) :: this
15 logical, intent(in) :: x
16 this%m_inside = x
17 end subroutine
18
19! ------------------------------------------------------------------------------
20 pure module function leg_get_box(this) result(x)
21 class(legend), intent(in) :: this
22 logical :: x
23 x = this%m_box
24 end function
25
26! ---------------------
27 module subroutine leg_set_box(this, x)
28 class(legend), intent(inout) :: this
29 logical, intent(in) :: x
30 this%m_box = x
31 end subroutine
32
33! ------------------------------------------------------------------------------
34 module function leg_get_horz_pos(this) result(x)
35 class(legend), intent(in) :: this
36 character(len = :), allocatable :: x
37 integer(int32) :: n
38 n = len_trim(this%m_horzPosition)
39 allocate(character(len = n) :: x)
40 x = trim(this%m_horzPosition)
41 end function
42
43! ---------------------
44 module subroutine leg_set_horz_pos(this, x)
45 class(legend), intent(inout) :: this
46 character(len = *), intent(in) :: x
47 this%m_horzPosition = x
48 if (x /= legend_left .and. x /= legend_right .and. x /= legend_center) &
49 this%m_horzPosition = legend_right
50 end subroutine
51
52! ------------------------------------------------------------------------------
53 module function leg_get_vert_pos(this) result(x)
54 class(legend), intent(in) :: this
55 character(len = :), allocatable :: x
56 integer(int32) :: n
57 n = len_trim(this%m_vertPosition)
58 allocate(character(len = n) :: x)
59 x = trim(this%m_vertPosition)
60 end function
61
62! ---------------------
63 module subroutine leg_set_vert_pos(this, x)
64 class(legend), intent(inout) :: this
65 character(len = *), intent(in) :: x
66 this%m_vertPosition = x
67 if (x /= legend_top .and. x /= legend_center .and. x /= legend_bottom) &
68 this%m_vertPosition = legend_top
69 end subroutine
70
71! ------------------------------------------------------------------------------
72 pure module function leg_get_visible(this) result(x)
73 class(legend), intent(in) :: this
74 logical :: x
75 x = this%m_show
76 end function
77
78! ---------------------
79 module subroutine leg_set_visible(this, x)
80 class(legend), intent(inout) :: this
81 logical, intent(in) :: x
82 this%m_show = x
83 end subroutine
84
85! ------------------------------------------------------------------------------
86 module function leg_get_command_txt(this) result(txt)
87 ! Arguments
88 class(legend), intent(in) :: this
89 character(len = :), allocatable :: txt
90
91 ! Local Variables
92 type(string_builder) :: str
93
94 ! Process
95 call str%initialize()
96
97 ! Visible?
98 if (.not.this%get_is_visible()) then
99 txt = "set key off"
100 return
101 end if
102
103 ! Inside vs Outside & Position
104 if (this%get_draw_inside_axes()) then
105 call str%append("set key inside")
106 else
107 call str%append("set key outside")
108 end if
109 call str%append(" ")
110 call str%append(this%get_vertical_position())
111 call str%append(" ")
112 call str%append(this%get_horizontal_position())
113
114 ! Border
115 call str%append(new_line('a'))
116 if (this%get_draw_border()) then
117 ! call str%append("set key box opaque")
118 call str%append("set key box")
119 else
120 call str%append("set key nobox")
121 end if
122
123 ! Layout
124 call str%append(new_line('a'))
125 call str%append("set key ")
126 call str%append(this%get_layout())
127
128 ! Opaque
129 call str%append(new_line('a'))
130 call str%append("set key ")
131 if (this%get_is_opaque()) then
132 call str%append("opaque")
133 else
134 call str%append("noopaque")
135 end if
136
137 ! End
138 txt = char(str%to_string())
139 end function
140
141! ------------------------------------------------------------------------------
142 pure module function leg_get_layout(this) result(rst)
143 class(legend), intent(in) :: this
144 character(len = :), allocatable :: rst
145 rst = trim(this%m_layout)
146 end function
147
148! ---------------------
149 module subroutine leg_set_layout(this, x)
150 class(legend), intent(inout) :: this
151 character(len = *), intent(in) :: x
152 if (x == legend_arrange_horizontally .or. &
153 x == legend_arrange_vertically) &
154 then
155 this%m_layout = x
156 end if
157 end subroutine
158
159! ------------------------------------------------------------------------------
160 pure module function leg_get_opaque(this) result(rst)
161 class(legend), intent(in) :: this
162 logical :: rst
163 rst = this%m_opaque
164 end function
165
166! ---------------------
167 module subroutine leg_set_opaque(this, x)
168 class(legend), intent(inout) :: this
169 logical :: x
170 this%m_opaque = x
171 end subroutine
172
173! ------------------------------------------------------------------------------
174end submodule
fplot_core