fplot 1.7.1
A Fortran library providing a convenient interface for plotting with Gnuplot.
Loading...
Searching...
No Matches
fplot_terminal.f90
1! fplot_terminal.f90
2
3submodule(fplot_core) fplot_terminal
4contains
5! ------------------------------------------------------------------------------
6 pure module function term_get_window_width(this) result(x)
7 class(terminal), intent(in) :: this
8 integer :: x
9 x = this%m_windowWidth
10 end function
11
12! --------------------
13 module subroutine term_set_window_width(this, x)
14 class(terminal), intent(inout) :: this
15 integer, intent(in) :: x
16 if (x == 0) then
17 this%m_windowWidth = gnuplot_default_window_width
18 else
19 this%m_windowWidth = abs(x)
20 end if
21 end subroutine
22
23! ------------------------------------------------------------------------------
24 pure module function term_get_window_height(this) result(x)
25 class(terminal), intent(in) :: this
26 integer :: x
27 x = this%m_windowHeight
28 end function
29
30! --------------------
31 module subroutine term_set_window_height(this, x)
32 class(terminal), intent(inout) :: this
33 integer, intent(in) :: x
34 if (x == 0) then
35 this%m_windowHeight = gnuplot_default_window_height
36 else
37 this%m_windowHeight = abs(x)
38 end if
39 end subroutine
40
41! ------------------------------------------------------------------------------
42 pure module function term_get_plot_window_number(this) result(x)
43 class(terminal), intent(in) :: this
44 integer(int32) :: x
45 x = this%m_termID
46 end function
47
48! --------------------
49 module subroutine term_set_plot_window_number(this, x)
50 class(terminal), intent(inout) :: this
51 integer(int32), intent(in) :: x
52 this%m_termID = x
53 end subroutine
54
55! ------------------------------------------------------------------------------
56 module function term_get_title(this) result(str)
57 class(terminal), intent(in) :: this
58 character(len = :), allocatable :: str
59 integer(int32) :: n
60 n = len_trim(str)
61 allocate(character(len = n) :: str)
62 str = trim(this%m_title)
63 end function
64
65! --------------------
66 module subroutine term_set_title(this, txt)
67 class(terminal), intent(inout) :: this
68 character(len = *), intent(in) :: txt
69 integer(int32) :: n
70 n = min(len_trim(txt), gnuplot_max_label_length)
71 this%m_title = ""
72 if (n /= 0) then
73 this%m_title(1:n) = txt(1:n)
74 this%m_hasTitle = .true.
75 else
76 this%m_hasTitle = .false.
77 end if
78 end subroutine
79
80! ------------------------------------------------------------------------------
81 module function term_get_font_name(this) result(name)
82 class(terminal), intent(in) :: this
83 character(len = :), allocatable :: name
84 integer(int32) :: n
85 n = len_trim(this%m_fontName)
86 allocate(character(len = n) :: name)
87 name = trim(this%m_fontName)
88 end function
89
90! --------------------
91 module subroutine term_set_font_name(this, name)
92 class(terminal), intent(inout) :: this
93 character(len = *), intent(in) :: name
94 integer(int32) :: n
95 n = min(len_trim(name), gnuplot_max_label_length)
96 this%m_fontName = ""
97 if (n == 0) then
98 this%m_fontName = gnuplot_default_fontname
99 else
100 this%m_fontName(1:n) = name(1:n)
101 end if
102 end subroutine
103
104! ------------------------------------------------------------------------------
105 pure module function term_get_font_size(this) result(sz)
106 class(terminal), intent(in) :: this
107 integer(int32) :: sz
108 sz = this%m_fontSize
109 end function
110
111! --------------------
112 module subroutine term_set_font_size(this, sz)
113 class(terminal), intent(inout) :: this
114 integer(int32), intent(in) :: sz
115 if (sz == 0) then
116 this%m_fontSize = gnuplot_default_font_size
117 else
118 this%m_fontSize = abs(sz)
119 end if
120 end subroutine
121
122! ------------------------------------------------------------------------------
123 module function term_get_command_string(this) result(x)
124 ! Arguments
125 class(terminal), intent(in) :: this
126 character(len = :), allocatable :: x
127
128 ! Local Variables
129 type(string_builder) :: str
130
131 ! Process
132 call str%initialize()
133 call str%append("set term ")
134 call str%append(this%get_id_string())
135 call str%append(" enhanced ")
136 call str%append(to_string(this%get_plot_window_number()))
137 call str%append(" font ")
138 call str%append('"')
139 call str%append(this%get_font_name())
140 call str%append(',')
141 call str%append(to_string(this%get_font_size()))
142 call str%append('"')
143 call str%append(" size ")
144 call str%append(to_string(this%get_window_width()))
145 call str%append(",")
146 call str%append(to_string(this%get_window_height()))
147 if (this%m_hasTitle) then
148 call str%append(' title "')
149 call str%append(this%get_title())
150 call str%append('"')
151 end if
152 x = char(str%to_string())
153 end function
154
155! ------------------------------------------------------------------------------
156end submodule
fplot_core