fplot 1.7.1
A Fortran library providing a convenient interface for plotting with Gnuplot.
Loading...
Searching...
No Matches
fplot_png_terminal.f90
1! fplot_png_terminal.f90
2
3submodule(fplot_core) fplot_png_terminal
4contains
5! ------------------------------------------------------------------------------
10 module function png_get_term_string(this) result(x)
11 class(png_terminal), intent(in) :: this
12 character(len = :), allocatable :: x
13 integer(int32) :: n
14 n = len_trim(this%m_id)
15 allocate(character(len = n) :: x)
16 x = this%m_id
17 end function
18
19! ------------------------------------------------------------------------------
24 module function png_get_filename(this) result(txt)
25 class(png_terminal), intent(in) :: this
26 character(len = :), allocatable :: txt
27 integer(int32) :: n
28 n = len_trim(this%m_fname)
29 allocate(character(len = n) :: txt)
30 txt = trim(this%m_fname)
31 end function
32
33! --------------------
38 module subroutine png_set_filename(this, txt)
39 class(png_terminal), intent(inout) :: this
40 character(len = *), intent(in) :: txt
41 integer(int32) :: n
42 n = min(len_trim(txt), gnuplot_max_path_length)
43 this%m_fname = ""
44 if (n /= 0) then
45 this%m_fname(1:n) = txt(1:n)
46 else
47 this%m_fname = "default.png"
48 end if
49 end subroutine
50
51! ------------------------------------------------------------------------------
57 module function png_get_command_string(this) result(x)
58 ! Arguments
59 class(png_terminal), intent(in) :: this
60 character(len = :), allocatable :: x
61
62 ! Local Variables
63 type(string_builder) :: str
64
65 ! Process
66 call str%initialize()
67 call str%append("set term pngcairo enhanced ")
68 call str%append(" font ")
69 call str%append('"')
70 call str%append(this%get_font_name())
71 call str%append(',')
72 call str%append(to_string(this%get_font_size()))
73 call str%append('"')
74 call str%append(" size ")
75 call str%append(to_string(this%get_window_width()))
76 call str%append(",")
77 call str%append(to_string(this%get_window_height()))
78 call str%append(new_line('a'))
79 call str%append("set output ")
80 call str%append('"')
81 call str%append(this%get_filename())
82 call str%append('"')
83 x = char(str%to_string())
84 end function
85
86end submodule
fplot_core