6 module subroutine plr_clean_up(this)
7 type(plot_polar),
intent(inout) :: this
8 call this%free_resources()
12 module subroutine plr_init(this, term, fname, err)
14 class(plot_polar),
intent(inout) :: this
15 integer(int32),
intent(in),
optional :: term
16 character(len = *),
intent(in),
optional :: fname
17 class(errors),
intent(inout),
optional,
target :: err
20 class(errors),
pointer :: errmgr
21 type(errors),
target :: deferr
24 if (
present(err))
then
31 call plt_init(this, term, fname, errmgr)
32 if (errmgr%has_error_occurred())
return
35 this%m_thetaStart = polar_theta_right
36 this%m_thetaDirection = polar_theta_ccw
40 module function plr_get_cmd(this) result(x)
42 class(plot_polar),
intent(in) :: this
43 character(len = :),
allocatable :: x
46 integer(int32) :: i, n
47 type(string_builder) :: str
48 type(legend),
pointer :: leg
49 real(real64) :: lim(2)
51 class(plot_data),
pointer :: ptr
57 call str%append(this%plot%get_command_string())
60 call str%append(new_line(
'a'))
61 call str%append(
"unset border")
63 call str%append(new_line(
'a'))
64 call str%append(
"set polar")
66 call str%append(new_line(
'a'))
67 call str%append(
"set size square")
69 call str%append(new_line(
'a'))
70 call str%append(
"unset xtics")
71 call str%append(new_line(
'a'))
72 call str%append(
"unset ytics")
74 call str%append(new_line(
'a'))
75 call str%append(
'set ttics 0, 30 format "%g".GPVAL_DEGREE_SIGN')
77 call str%append(new_line(
'a'))
78 call str%append(
"set mttics 3")
80 call str%append(new_line(
'a'))
81 call str%append(
"set theta ")
82 call str%append(this%get_theta_start_position())
84 call str%append(this%get_theta_direction())
87 if (.not.this%get_autoscale())
then
88 lim = this%get_radial_limits()
89 call str%append(new_line(
'a'))
90 call str%append(
"set rrange [")
91 call str%append(to_string(lim(1)))
93 call str%append(to_string(lim(2)))
98 if (this%get_show_gridlines())
then
99 call str%append(new_line(
'a'))
100 call str%append(
"set grid r polar")
104 n = len_trim(this%get_title())
106 call str%append(new_line(
'a'))
107 call str%append(
'set title "')
108 call str%append(this%get_title())
113 call str%append(new_line(
'a'))
114 if (this%get_draw_border())
then
115 call str%append(
"set border polar")
117 call str%append(
"set border 0")
121 call str%append(new_line(
'a'))
122 leg => this%get_legend()
123 if (
associated(leg))
call str%append(leg%get_command_string())
135 call str%append(new_line(
'a'))
136 call str%append(
"plot ")
139 if (.not.
associated(ptr)) cycle
140 call str%append(ptr%get_command_string())
141 if (i /= n)
call str%append(
", ")
147 if (.not.
associated(ptr)) cycle
148 call str%append(new_line(
'a'))
149 call str%append(ptr%get_data_string())
154 x = char(str%to_string())
158 pure module function plr_get_autoscale(this) result(rst)
159 class(plot_polar),
intent(in) :: this
161 rst = this%m_autoscale
165 module subroutine plr_set_autoscale(this, x)
166 class(plot_polar),
intent(inout) :: this
167 logical,
intent(in) :: x
172 pure module function plr_get_limits(this) result(rst)
173 class(plot_polar),
intent(in) :: this
174 real(real64) :: rst(2)
175 rst = [this%m_minrad, this%m_maxrad]
179 module subroutine plr_set_limits(this, x)
180 class(plot_polar),
intent(inout) :: this
181 real(real64),
intent(in) :: x(2)
182 this%m_minrad = minval(x)
183 this%m_maxrad = maxval(x)
187 pure module function plr_get_theta_start(this) result(rst)
188 class(plot_polar),
intent(in) :: this
189 character(len = :),
allocatable :: rst
190 rst = this%m_thetaStart
194 module subroutine plr_set_theta_start(this, x)
195 class(plot_polar),
intent(inout) :: this
196 character(len = *),
intent(in) :: x
197 if (x /= polar_theta_bottom .and. &
198 x /= polar_theta_top .and. &
199 x /= polar_theta_left .and. &
200 x /= polar_theta_right) &
203 this%m_thetaStart = polar_theta_right
205 this%m_thetaStart = x
210 pure module function plr_get_theta_direction(this) result(rst)
211 class(plot_polar),
intent(in) :: this
212 character(len = :),
allocatable :: rst
213 rst = this%m_thetaDirection
217 module subroutine plr_set_theta_direction(this, x)
218 class(plot_polar),
intent(inout) :: this
219 character(len = *),
intent(in) :: x
220 if (x /= polar_theta_ccw .and. x /= polar_theta_cw)
then
222 this%m_thetaDirection = polar_theta_ccw
224 this%m_thetaDirection = x