fplot 1.7.1
A Fortran library providing a convenient interface for plotting with Gnuplot.
Loading...
Searching...
No Matches
fplot_surface_plot.f90
1! fplot_surface_plot.f90
2
3submodule(fplot_core) fplot_surface_plot
4contains
5! ------------------------------------------------------------------------------
6 ! module subroutine surf_clean_up(this)
7 ! type(surface_plot), intent(inout) :: this
8 ! if (associated(this%m_colormap)) then
9 ! deallocate(this%m_colormap)
10 ! nullify(this%m_colormap)
11 ! end if
12
13 ! ! No need to call the base class finalization routine as the compiler
14 ! ! takes care of that for us.
15 ! end subroutine
16
17! ------------------------------------------------------------------------------
18 module subroutine surf_init(this, term, fname, err)
19 ! Arguments
20 class(surface_plot), intent(inout) :: this
21 integer(int32), intent(in), optional :: term
22 character(len = *), intent(in), optional :: fname
23 class(errors), intent(inout), optional, target :: err
24
25 ! Local Variables
26 type(legend), pointer :: lgnd
27
28 ! Initialize the base class
29 call this%plot_3d%initialize(term, fname, err)
30
31 ! Do not display the legend
32 lgnd => this%get_legend()
33 call lgnd%set_is_visible(.false.)
34
35 ! Nullify the colormap
36 ! nullify(this%m_colormap)
37 end subroutine
38
39! ------------------------------------------------------------------------------
40 pure module function surf_get_show_hidden(this) result(x)
41 class(surface_plot), intent(in) :: this
42 logical :: x
43 x = this%m_showHidden
44 end function
45
46! ------------------------------------------------------------------------------
47 module subroutine surf_set_show_hidden(this, x)
48 class(surface_plot), intent(inout) :: this
49 logical, intent(in) :: x
50 this%m_showHidden = x
51 end subroutine
52
53! ------------------------------------------------------------------------------
54 module function surf_get_cmd(this) result(x)
55 ! Arguments
56 class(surface_plot), intent(in) :: this
57 character(len = :), allocatable :: x
58
59 ! Local Variables
60 type(string_builder) :: str
61 ! class(colormap), pointer :: clr
62
63 ! Initialization
64 call str%initialize()
65
66 ! Call the base routine
67 call str%append(this%plot%get_command_string())
68
69 ! Hidden Stuff
70 call str%append(new_line('a'))
71 if (this%get_show_hidden()) then
72 call str%append("unset hidden3d")
73 else
74 call str%append("set hidden3d")
75 end if
76
77 ! Define the colormap
78 ! clr => this%get_colormap()
79 ! if (associated(clr)) then
80 ! call str%append(new_line('a'))
81 ! call str%append(clr%get_command_string())
82 ! end if
83
84 ! Allow for smoothing interpolation
85 if (this%get_allow_smoothing()) then
86 call str%append(new_line('a'))
87 call str%append("set pm3d interpolate 0,0")
88 end if
89
90 ! Draw a contour plot as well?
91 if (this%get_show_contours()) then
92 call str%append(new_line('a'))
93 call str%append("set contour")
94 end if
95
96 ! Show colorbar
97 ! if (.not.this%get_show_colorbar()) then
98 ! call str%append(new_line('a'))
99 ! call str%append("unset colorbox")
100 ! end if
101
102 ! Lighting
103 if (this%get_use_lighting()) then
104 call str%append(new_line('a'))
105 call str%append("set pm3d lighting primary ")
106 call str%append(to_string(this%get_light_intensity()))
107 call str%append(" specular ")
108 call str%append(to_string(this%get_specular_intensity()))
109 end if
110
111 ! Translucent
112 if (this%get_transparency() < 1.0 .and. this%get_transparency() > 0.0) then
113 call str%append(new_line('a'))
114 call str%append("set style fill transparent solid ")
115 call str%append(to_string(this%get_transparency()))
116 end if
117
118 ! Call the base class to define the rest of the plot commands
119 call str%append(new_line('a'))
120 call str%append(this%plot_3d%get_command_string())
121
122 ! Output
123 x = char(str%to_string())
124 end function
125
126! ------------------------------------------------------------------------------
127! module function surf_get_colormap(this) result(x)
128! class(surface_plot), intent(in) :: this
129! class(colormap), pointer :: x
130! x => this%m_colormap
131! end function
132
133! ! --------------------
134! module subroutine surf_set_colormap(this, x, err)
135! ! Arguments
136! class(surface_plot), intent(inout) :: this
137! class(colormap), intent(in) :: x
138! class(errors), intent(inout), optional, target :: err
139
140! ! Local Variables
141! integer(int32) :: flag
142! class(errors), pointer :: errmgr
143! type(errors), target :: deferr
144
145! ! Initialization
146! if (present(err)) then
147! errmgr => err
148! else
149! errmgr => deferr
150! end if
151
152! ! Process
153! if (associated(this%m_colormap)) deallocate(this%m_colormap)
154! allocate(this%m_colormap, stat = flag, source = x)
155! if (flag /= 0) then
156! call errmgr%report_error("surf_set_colormap", &
157! "Insufficient memory available.", PLOT_OUT_OF_MEMORY_ERROR)
158! return
159! end if
160! end subroutine
161
162! ------------------------------------------------------------------------------
163 pure module function surf_get_smooth(this) result(x)
164 class(surface_plot), intent(in) :: this
165 logical :: x
166 x = this%m_smooth
167 end function
168
169! --------------------
170 module subroutine surf_set_smooth(this, x)
171 class(surface_plot), intent(inout) :: this
172 logical, intent(in) :: x
173 this%m_smooth = x
174 end subroutine
175
176! ------------------------------------------------------------------------------
177 pure module function surf_get_show_contours(this) result(x)
178 class(surface_plot), intent(in) :: this
179 logical :: x
180 x = this%m_contour
181 end function
182
183! --------------------
184 module subroutine surf_set_show_contours(this, x)
185 class(surface_plot), intent(inout) :: this
186 logical, intent(in) :: x
187 this%m_contour = x
188 end subroutine
189
190! ------------------------------------------------------------------------------
191! pure module function surf_get_show_colorbar(this) result(x)
192! class(surface_plot), intent(in) :: this
193! logical :: x
194! x = this%m_showColorbar
195! end function
196
197! ! --------------------
198! module subroutine surf_set_show_colorbar(this, x)
199! class(surface_plot), intent(inout) :: this
200! logical, intent(in) :: x
201! this%m_showColorbar = x
202! end subroutine
203
204! ------------------------------------------------------------------------------
205 pure module function surf_get_use_lighting(this) result(x)
206 class(surface_plot), intent(in) :: this
207 logical :: x
208 x = this%m_useLighting
209 end function
210
211! --------------------
212 module subroutine surf_set_use_lighting(this, x)
213 class(surface_plot), intent(inout) :: this
214 logical, intent(in) :: x
215 this%m_useLighting = x
216 end subroutine
217
218! ------------------------------------------------------------------------------
219 pure module function surf_get_light_intensity(this) result(x)
220 class(surface_plot), intent(in) :: this
221 real(real32) :: x
222 x = this%m_lightIntensity
223 end function
224
225! --------------------
226 module subroutine surf_set_light_intensity(this, x)
227 class(surface_plot), intent(inout) :: this
228 real(real32), intent(in) :: x
229 if (x < 0.0) then
230 this%m_lightIntensity = 0.0
231 else if (x > 1.0) then
232 this%m_lightIntensity = 1.0
233 else
234 this%m_lightIntensity = x
235 end if
236 end subroutine
237
238! ------------------------------------------------------------------------------
239 pure module function surf_get_specular_intensity(this) result(x)
240 class(surface_plot), intent(in) :: this
241 real(real32) :: x
242 x = this%m_specular
243 end function
244
245! --------------------
246 module subroutine surf_set_specular_intensity(this, x)
247 class(surface_plot), intent(inout) :: this
248 real(real32), intent(in) :: x
249 if (x < 0.0) then
250 this%m_specular = 0.0
251 else if (x > 1.0) then
252 this%m_specular = 1.0
253 else
254 this%m_specular = x
255 end if
256 end subroutine
257
258! ------------------------------------------------------------------------------
259 pure module function surf_get_transparency(this) result(x)
260 class(surface_plot), intent(in) :: this
261 real(real32) :: x
262 x = this%m_transparency
263 end function
264
265! --------------------
266 module subroutine surf_set_transparency(this, x)
267 class(surface_plot), intent(inout) :: this
268 real(real32), intent(in) :: x
269 if (x > 1.0) then
270 this%m_transparency = 1.0
271 else if (x <= 0.0) then
272 this%m_transparency = 0.1
273 else
274 this%m_transparency = x
275 end if
276 end subroutine
277
278end submodule
fplot_core