6 module subroutine p3d_clean_up(this)
7 type(plot_3d),
intent(inout) :: this
8 call this%free_resources()
9 if (
associated(this%m_xAxis))
then
10 deallocate(this%m_xAxis)
13 if (
associated(this%m_yAxis))
then
14 deallocate(this%m_yAxis)
17 if (
associated(this%m_zAxis))
then
18 deallocate(this%m_zAxis)
24 module subroutine p3d_init(this, term, fname, err)
26 class(plot_3d),
intent(inout) :: this
27 integer(int32),
intent(in),
optional :: term
28 character(len = *),
intent(in),
optional :: fname
29 class(errors),
intent(inout),
optional,
target :: err
32 integer(int32) :: flag
33 class(errors),
pointer :: errmgr
34 type(errors),
target :: deferr
37 if (
present(err))
then
44 call plt_init(this, term, fname, errmgr)
45 if (errmgr%has_error_occurred())
return
49 if (.not.
associated(this%m_xAxis))
then
50 allocate(this%m_xAxis, stat = flag)
52 if (flag == 0 .and. .not.
associated(this%m_yAxis))
then
53 allocate(this%m_yAxis, stat = flag)
55 if (flag == 0 .and. .not.
associated(this%m_zAxis))
then
56 allocate(this%m_zAxis, stat = flag)
61 call errmgr%report_error(
"p3d_init", &
62 "Insufficient memory available.", plot_out_of_memory_error)
68 module function p3d_get_cmd(this) result(x)
70 class(plot_3d),
intent(in) :: this
71 character(len = :),
allocatable :: x
74 type(string_builder) :: str
75 integer(int32) :: i, n
76 class(plot_data),
pointer :: ptr
77 class(plot_axis),
pointer :: xAxis, yAxis, zAxis
78 type(legend),
pointer :: leg
85 call str%append(this%plot%get_command_string())
88 if (this%get_show_gridlines())
then
89 call str%append(new_line(
'a'))
90 call str%append(
"set grid")
94 n = len_trim(this%get_title())
96 call str%append(new_line(
'a'))
97 call str%append(
'set title "')
98 call str%append(this%get_title())
103 call str%append(new_line(
'a'))
104 xaxis => this%get_x_axis()
105 if (
associated(xaxis))
call str%append(xaxis%get_command_string())
107 call str%append(new_line(
'a'))
108 yaxis => this%get_y_axis()
109 if (
associated(yaxis))
call str%append(yaxis%get_command_string())
111 call str%append(new_line(
'a'))
112 zaxis => this%get_z_axis()
113 if (
associated(zaxis))
call str%append(zaxis%get_command_string())
116 if (.not.this%get_tics_inward())
then
117 call str%append(new_line(
'a'))
118 call str%append(
"set tics out")
120 if (xaxis%get_zero_axis() .or. yaxis%get_zero_axis() .or. &
121 zaxis%get_zero_axis())
then
122 call str%append(new_line(
'a'))
123 call str%append(
"set tics axis")
127 if (this%get_draw_border())
then
131 if (.not.xaxis%get_zero_axis()) n = n + 1
132 if (.not.yaxis%get_zero_axis()) n = n + 4
133 if (.not.zaxis%get_zero_axis()) n = n + 16
135 call str%append(new_line(
'a'))
136 call str%append(
"set xtics nomirror")
137 call str%append(new_line(
'a'))
138 call str%append(
"set ytics nomirror")
139 call str%append(new_line(
'a'))
140 call str%append(
"set ztics nomirror")
142 call str%append(new_line(
'a'))
144 call str%append(
"set border ")
145 call str%append(to_string(n))
147 call str%append(
"unset border")
151 if (this%get_z_intersect_xy())
then
152 call str%append(new_line(
'a'))
153 call str%append(
"set ticslevel 0")
157 if (this%get_axis_equal())
then
158 call str%append(new_line(
'a'))
159 call str%append(
"set view equal xyz")
163 call str%append(new_line(
'a'))
164 leg => this%get_legend()
165 if (
associated(leg))
call str%append(leg%get_command_string())
176 call str%append(new_line(
'a'))
177 call str%append(
"set view ")
178 if (this%get_use_map_view())
then
179 call str%append(
"map")
181 call str%append(to_string(this%get_elevation()))
183 call str%append(to_string(this%get_azimuth()))
187 if (this%get_coordinate_system() == coordinates_cylindrical)
then
188 call str%append(new_line(
'a'))
189 call str%append(
"set mapping cylindrical")
190 else if (this%get_coordinate_system() == coordinates_spherical)
then
191 call str%append(new_line(
'a'))
192 call str%append(
"set mapping spherical")
197 call str%append(new_line(
'a'))
198 call str%append(
"splot ")
201 if (.not.
associated(ptr)) cycle
202 call str%append(ptr%get_command_string())
203 if (i /= n)
call str%append(
", ")
209 if (.not.
associated(ptr)) cycle
210 call str%append(new_line(
'a'))
211 call str%append(ptr%get_data_string())
219 x = char(str%to_string())
223 module function p3d_get_x_axis(this) result(ptr)
224 class(plot_3d),
intent(in) :: this
225 class(plot_axis),
pointer :: ptr
230 module function p3d_get_y_axis(this) result(ptr)
231 class(plot_3d),
intent(in) :: this
232 class(plot_axis),
pointer :: ptr
237 module function p3d_get_z_axis(this) result(ptr)
238 class(plot_3d),
intent(in) :: this
239 class(plot_axis),
pointer :: ptr
244 pure module function p3d_get_elevation(this) result(x)
245 class(plot_3d),
intent(in) :: this
251 module subroutine p3d_set_elevation(this, x)
252 class(plot_3d),
intent(inout) :: this
253 real(real64),
intent(in) :: x
258 pure module function p3d_get_azimuth(this) result(x)
259 class(plot_3d),
intent(in) :: this
265 module subroutine p3d_set_azimuth(this, x)
266 class(plot_3d),
intent(inout) :: this
267 real(real64),
intent(in) :: x
272 pure module function p3d_get_z_axis_intersect(this) result(x)
273 class(plot_3d),
intent(in) :: this
275 x = this%m_zIntersect
279 module subroutine p3d_set_z_axis_intersect(this, x)
280 class(plot_3d),
intent(inout) :: this
281 logical,
intent(in) :: x
282 this%m_zIntersect = x
287 pure module function p3d_get_use_map_view(this) result(rst)
288 class(plot_3d),
intent(in) :: this
294 module subroutine p3d_set_use_map_view(this, x)
295 class(plot_3d),
intent(inout) :: this
296 logical,
intent(in) :: x
302 pure module function p3d_get_csys(this) result(rst)
303 class(plot_3d),
intent(in) :: this
304 integer(int32) :: rst
309 module subroutine p3d_set_csys(this, x)
310 class(plot_3d),
intent(inout) :: this
311 integer(int32),
intent(in) :: x
312 if (x /= coordinates_cartesian .and. &
313 x /= coordinates_cylindrical .and. &
314 x /= coordinates_spherical) &
317 this%m_csys = coordinates_cartesian