fplot 1.7.1
A Fortran library providing a convenient interface for plotting with Gnuplot.
Loading...
Searching...
No Matches
fplot_label.f90
1! fplot_label.f90
2
3submodule(fplot_core) fplot_label
4contains
5! ------------------------------------------------------------------------------
6 module function lbl_get_cmd(this) result(x)
7 ! Arguments
8 class(plot_label), intent(in) :: this
9 character(len = :), allocatable :: x
10
11 ! Local Variables
12 type(string_builder) :: str
13 real(real32) :: pt(3)
14
15 ! Initialization
16 call str%initialize()
17 pt = this%get_position()
18
19 ! If visible, draw the label
20 if (this%get_is_visible()) then
21 call str%append('set label "')
22 call str%append(this%get_text())
23 call str%append('"')
24
25 call str%append(" at ")
26 call str%append(to_string(pt(1)))
27 call str%append(",")
28 call str%append(to_string(pt(2)))
29 call str%append(",")
30 call str%append(to_string(pt(3)))
31
32 call str%append(" rotate by ")
33 call str%append(to_string(this%get_angle()))
34
35 x = char(str%to_string())
36 end if
37 end function
38
39! ------------------------------------------------------------------------------
40 pure module function lbl_get_is_visible(this) result(x)
41 class(plot_label), intent(in) :: this
42 logical :: x
43 x = this%m_visible
44 end function
45
46! --------------------
47 module subroutine lbl_set_is_visible(this, x)
48 class(plot_label), intent(inout) :: this
49 logical, intent(in) :: x
50 this%m_visible = x
51 end subroutine
52
53! ------------------------------------------------------------------------------
54 pure module function lbl_get_position(this) result(x)
55 class(plot_label), intent(in) :: this
56 real(real32), dimension(3) :: x
57 x = this%m_position
58 end function
59
60! --------------------
61 module subroutine lbl_set_position(this, x)
62 class(plot_label), intent(inout) :: this
63 real(real32), intent(in), dimension(3) :: x
64 this%m_position = x
65 end subroutine
66
67! ------------------------------------------------------------------------------
68 pure module function lbl_get_angle(this) result(x)
69 class(plot_label), intent(in) :: this
70 real(real32) :: x
71 x = this%m_angle
72 end function
73
74! --------------------
75 module subroutine lbl_set_angle(this, x)
76 class(plot_label), intent(inout) :: this
77 real(real32), intent(in) :: x
78 this%m_angle = x
79 end subroutine
80
81! ------------------------------------------------------------------------------
82 module function lbl_get_txt(this) result(x)
83 class(plot_label), intent(in) :: this
84 character(len = :), allocatable :: x
85 x = trim(this%m_text)
86 end function
87
88! --------------------
89 module subroutine lbl_set_txt(this, x)
90 class(plot_label), intent(inout) :: this
91 character(len = *), intent(in) :: x
92 integer(int32) :: n
93 n = min(len(x), plotdata_max_name_length)
94 this%m_text = ""
95 this%m_text(1:n) = x(1:n)
96 end subroutine
97
98! ******************************************************************************
99! ADDED: JAN. 09, 2024 - JAC
100! ------------------------------------------------------------------------------
101 pure module subroutine lbl_assign(x, y)
102 type(plot_label), intent(out) :: x
103 class(plot_label), intent(in) :: y
104 x%m_visible = y%m_visible
105 x%m_position = y%m_position
106 x%m_angle = y%m_angle
107 x%m_text = y%m_text
108 end subroutine
109
110! ------------------------------------------------------------------------------
111end submodule
fplot_core