fplot 1.7.1
A Fortran library providing a convenient interface for plotting with Gnuplot.
Loading...
Searching...
No Matches
fplot_arrow.f90
1submodule(fplot_core) fplot_arrow
2 implicit none
3contains
4! ------------------------------------------------------------------------------
5pure module function par_get_is_visible(this) result(rst)
6 class(plot_arrow), intent(in) :: this
7 logical :: rst
8 rst = this%m_visible
9end function
10
11! --------------------
12module subroutine par_set_is_visible(this, x)
13 class(plot_arrow), intent(inout) :: this
14 logical, intent(in) :: x
15 this%m_visible = x
16end subroutine
17
18! ------------------------------------------------------------------------------
19pure module function par_get_tail(this) result(rst)
20 class(plot_arrow), intent(in) :: this
21 real(real32), dimension(3) :: rst
22 rst = this%m_tail
23end function
24
25! --------------------
26module subroutine par_set_tail_1(this, x)
27 class(plot_arrow), intent(inout) :: this
28 real(real32), intent(in) :: x(3)
29 this%m_tail = x
30end subroutine
31
32! --------------------
33module subroutine par_set_tail_2(this, x, y)
34 class(plot_arrow), intent(inout) :: this
35 real(real32), intent(in) :: x, y
36 this%m_tail = [x, y, 0.0]
37end subroutine
38
39! --------------------
40module subroutine par_set_tail_3(this, x, y, z)
41 class(plot_arrow), intent(inout) :: this
42 real(real32), intent(in) :: x, y, z
43 this%m_tail = [x, y, z]
44end subroutine
45
46! ------------------------------------------------------------------------------
47pure module function par_get_head(this) result(rst)
48 class(plot_arrow), intent(in) :: this
49 real(real32), dimension(3) :: rst
50 rst = this%m_head
51end function
52
53! --------------------
54module subroutine par_set_head_1(this, x)
55 class(plot_arrow), intent(inout) :: this
56 real(real32), intent(in) :: x(3)
57 this%m_head = x
58end subroutine
59
60! --------------------
61module subroutine par_set_head_2(this, x, y)
62 class(plot_arrow), intent(inout) :: this
63 real(real32), intent(in) :: x, y
64 this%m_head = [x, y, 0.0]
65end subroutine
66
67! --------------------
68module subroutine par_set_head_3(this, x, y, z)
69 class(plot_arrow), intent(inout) :: this
70 real(real32), intent(in) :: x, y, z
71 this%m_head = [x, y, z]
72end subroutine
73
74! ------------------------------------------------------------------------------
75pure module function par_get_color(this) result(rst)
76 class(plot_arrow), intent(in) :: this
77 type(color) :: rst
78 rst = this%m_color
79end function
80
81! --------------------
82module subroutine par_set_color(this, x)
83 class(plot_arrow), intent(inout) :: this
84 type(color), intent(in) :: x
85 this%m_color = x
86end subroutine
87
88! ------------------------------------------------------------------------------
89pure module function par_get_line_style(this) result(rst)
90 class(plot_arrow), intent(in) :: this
91 integer(int32) :: rst
92 rst = this%m_linestyle
93end function
94
95! --------------------
96module subroutine par_set_line_style(this, x)
97 class(plot_arrow), intent(inout) :: this
98 integer(int32), intent(in) :: x
99 if (x == line_dashed .or. &
100 x == line_dash_dotted .or. &
101 x == line_dash_dot_dot .or. &
102 x == line_dotted .or. &
103 x == line_solid) then
104 ! Only reset the line style if it is a valid type.
105 this%m_linestyle = x
106 end if
107end subroutine
108
109! ------------------------------------------------------------------------------
110pure module function par_get_line_width(this) result(rst)
111 class(plot_arrow), intent(in) :: this
112 real(real32) :: rst
113 rst = this%m_linewidth
114end function
115
116! --------------------
117module subroutine par_set_line_width(this, x)
118 class(plot_arrow), intent(inout) :: this
119 real(real32), intent(in) :: x
120 this%m_linewidth = x
121end subroutine
122
123! ------------------------------------------------------------------------------
124pure module function par_get_head_type(this) result(rst)
125 class(plot_arrow), intent(in) :: this
126 integer(int32) :: rst
127 rst = this%m_head_type
128end function
129
130! --------------------
131module subroutine par_set_head_type(this, x)
132 class(plot_arrow), intent(inout) :: this
133 integer(int32), intent(in) :: x
134 if (x == arrow_backhead .or. &
135 x == arrow_head .or. &
136 x == arrow_heads .or. &
137 x == arrow_no_head &
138 ) then
139 this%m_head_type = x
140 end if
141end subroutine
142
143! ------------------------------------------------------------------------------
144pure module function par_get_fill(this) result(rst)
145 class(plot_arrow), intent(in) :: this
146 integer(int32) :: rst
147 rst = this%m_filling
148end function
149
150! --------------------
151module subroutine par_set_fill(this, x)
152 class(plot_arrow), intent(inout) :: this
153 integer(int32), intent(in) :: x
154 if (x == arrow_filled .or. &
155 x == arrow_empty .or. &
156 x == arrow_no_border .or. &
157 x == arrow_no_fill &
158 ) then
159 this%m_filling = x
160 end if
161end subroutine
162
163! ------------------------------------------------------------------------------
164pure module function par_get_move_to_front(this) result(rst)
165 class(plot_arrow), intent(in) :: this
166 logical :: rst
167 rst = this%m_front
168end function
169
170! --------------------
171module subroutine par_set_move_to_front(this, x)
172 class(plot_arrow), intent(inout) :: this
173 logical, intent(in) :: x
174 this%m_front = x
175end subroutine
176
177! ------------------------------------------------------------------------------
178pure module function par_get_head_size(this) result(rst)
179 class(plot_arrow), intent(in) :: this
180 real(real32) :: rst
181 rst = this%m_size
182end function
183
184! --------------------
185module subroutine par_set_head_size(this, x)
186 class(plot_arrow), intent(inout) :: this
187 real(real32), intent(in) :: x
188 this%m_size = x
189end subroutine
190
191! ------------------------------------------------------------------------------
192pure module function par_get_head_angle(this) result(rst)
193 class(plot_arrow), intent(in) :: this
194 real(real32) :: rst
195 rst = this%m_angle
196end function
197
198! --------------------
199module subroutine par_set_head_angle(this, x)
200 class(plot_arrow), intent(inout) :: this
201 real(real32), intent(in) :: x
202 this%m_angle = x
203end subroutine
204
205! ------------------------------------------------------------------------------
206pure module function par_get_head_back_angle(this) result(rst)
207 class(plot_arrow), intent(in) :: this
208 real(real32) :: rst
209 rst = this%m_backangle
210end function
211
212! --------------------
213module subroutine par_set_head_back_angle(this, x)
214 class(plot_arrow), intent(inout) :: this
215 real(real32), intent(in) :: x
216 this%m_backangle = x
217end subroutine
218
219! ------------------------------------------------------------------------------
220pure module function par_get_use_default_size(this) result(rst)
221 class(plot_arrow), intent(in) :: this
222 logical :: rst
223 rst = this%m_use_default_size
224end function
225
226! --------------------
227module subroutine par_set_use_default_size(this, x)
228 class(plot_arrow), intent(inout) :: this
229 logical, intent(in) :: x
230 this%m_use_default_size = x
231end subroutine
232
233! ------------------------------------------------------------------------------
234module function par_get_cmd(this) result(rst)
235 ! Arguments
236 class(plot_arrow), intent(in) :: this
237 character(len = :), allocatable :: rst
238
239 ! Local Variables
240 type(string_builder) :: str
241 type(color) :: clr
242 real(real32) :: tail(3), head(3)
243
244 ! Quick Return
245 if (.not.this%get_is_visible()) then
246 rst = ""
247 return
248 end if
249
250 ! Command
251 call str%append("set arrow")
252
253 ! Position Info
254 tail = this%get_tail_location()
255 head = this%get_head_location()
256 call str%append(" from ")
257 call str%append(to_string(tail(1)))
258 call str%append(",")
259 call str%append(to_string(tail(2)))
260 call str%append(",")
261 call str%append(to_string(tail(3)))
262
263 call str%append(" to ")
264 call str%append(to_string(head(1)))
265 call str%append(",")
266 call str%append(to_string(head(2)))
267 call str%append(",")
268 call str%append(to_string(head(3)))
269
270 ! Head Type
271 select case (this%get_head_type())
272 case (arrow_backhead)
273 call str%append(" backhead")
274 case (arrow_head)
275 call str%append(" head")
276 case (arrow_heads)
277 call str%append(" heads")
278 case (arrow_no_head)
279 call str%append(" nohead")
280 end select
281
282 if (this%get_head_type() /= arrow_no_head) then
283 ! Fill Info
284 select case (this%get_head_fill())
285 case (arrow_filled)
286 call str%append(" filled")
287 case (arrow_empty)
288 call str%append(" empty")
289 case (arrow_no_border)
290 call str%append(" noborder")
291 case (arrow_no_fill)
292 call str%append(" nofilled")
293 end select
294
295 ! Size
296 if (.not.this%get_use_default_size()) then
297 call str%append(" size ")
298 call str%append(to_string(this%get_head_size()))
299 call str%append(",")
300 call str%append(to_string(this%get_head_angle()))
301 call str%append(",")
302 call str%append(to_string(this%get_head_back_angle()))
303 end if
304 end if
305
306 ! Front/Back
307 if (this%get_move_to_front()) then
308 call str%append(" front")
309 else
310 call str%append(" back")
311 end if
312
313 ! Line Color
314 clr = this%get_color()
315 call str%append(' lc rgb "#')
316 call str%append(clr%to_hex_string())
317 call str%append('"')
318
319 ! Line Width
320 call str%append(" lw ")
321 call str%append(to_string(this%get_line_width()))
322
323 ! Line Style
324 call str%append(" lt ")
325 call str%append(to_string(this%get_line_style()))
326 if (this%get_line_style() /= line_solid) then
327 call str%append(" dashtype ")
328 call str%append(to_string(this%get_line_style()))
329 end if
330
331 ! End
332 rst = char(str%to_string())
333end function
334
335! ------------------------------------------------------------------------------
336pure module subroutine par_assign(x, y)
337 type(plot_arrow), intent(out) :: x
338 class(plot_arrow), intent(in) :: y
339 x%m_visible = y%m_visible
340 x%m_tail = y%m_tail
341 x%m_head = y%m_head
342 x%m_color = y%m_color
343 x%m_linestyle = y%m_linestyle
344 x%m_linewidth = y%m_linewidth
345 x%m_head_type = y%m_head_type
346 x%m_filling = y%m_filling
347 x%m_front = y%m_front
348 x%m_size = y%m_size
349 x%m_angle = y%m_angle
350 x%m_backangle = y%m_backangle
351 x%m_use_default_size = y%m_use_default_size
352end subroutine
353
354! ------------------------------------------------------------------------------
355end submodule
fplot_core