submodule(fortplot_figure_core) fortplot_figure_core_wrappers_state implicit none contains module subroutine grid(self, enabled, which, axis, alpha, linestyle) !! Enable/disable and configure grid lines class(figure_t), intent(inout) :: self logical, intent(in), optional :: enabled character(len=*), intent(in), optional :: which, axis, linestyle real(wp), intent(in), optional :: alpha call core_grid(self%state, enabled, which, axis, alpha, linestyle) end subroutine grid module subroutine set_xlabel(self, label) class(figure_t), intent(inout) :: self character(len=*), intent(in) :: label call core_set_xlabel(self%state, self%xlabel, label) end subroutine set_xlabel module subroutine set_ylabel(self, label) class(figure_t), intent(inout) :: self character(len=*), intent(in) :: label call core_set_ylabel(self%state, self%ylabel, label) end subroutine set_ylabel module subroutine set_title(self, title) class(figure_t), intent(inout) :: self character(len=*), intent(in) :: title call core_set_title(self%state, self%title, title) end subroutine set_title module subroutine set_xscale(self, scale, threshold) class(figure_t), intent(inout) :: self character(len=*), intent(in) :: scale real(wp), intent(in), optional :: threshold call core_set_xscale(self%state, scale, threshold) end subroutine set_xscale module subroutine set_yscale(self, scale, threshold) class(figure_t), intent(inout) :: self character(len=*), intent(in) :: scale real(wp), intent(in), optional :: threshold call core_set_yscale(self%state, scale, threshold) end subroutine set_yscale module subroutine set_xlim(self, x_min, x_max) class(figure_t), intent(inout) :: self real(wp), intent(in) :: x_min, x_max call core_set_xlim(self%state, x_min, x_max) end subroutine set_xlim module subroutine set_ylim(self, y_min, y_max) class(figure_t), intent(inout) :: self real(wp), intent(in) :: y_min, y_max call core_set_ylim(self%state, y_min, y_max) end subroutine set_ylim module subroutine set_line_width(self, width) class(figure_t), intent(inout) :: self real(wp), intent(in) :: width call core_set_line_width(self%state, width) end subroutine set_line_width module subroutine set_ydata(self, plot_index, y_new) class(figure_t), intent(inout) :: self integer, intent(in) :: plot_index real(wp), intent(in) :: y_new(:) call core_set_ydata(self%plots, self%state%plot_count, plot_index, y_new) end subroutine set_ydata module subroutine figure_legend(self, location) class(figure_t), intent(inout) :: self character(len=*), intent(in), optional :: location call core_figure_legend(self%state, self%plots, self%state%plot_count, & location) end subroutine figure_legend module subroutine clear(self) !! Clear the figure for reuse, preserving backend settings class(figure_t), intent(inout) :: self call core_clear(self%state, self%streamlines, & self%subplots_array, self%subplot_rows, self%subplot_cols, & self%current_subplot, self%title, self%xlabel, self%ylabel, & self%plot_count, self%annotation_count) end subroutine clear module subroutine clear_streamlines(self) class(figure_t), intent(inout) :: self call core_clear_streamlines(self%streamlines) end subroutine clear_streamlines module subroutine destroy(self) type(figure_t), intent(inout) :: self call core_destroy(self%state, self%plots, self%streamlines, & self%title, self%xlabel, self%ylabel) end subroutine destroy module function get_width(self) result(width) class(figure_t), intent(in) :: self integer :: width width = core_get_width(self%state) end function get_width module function get_height(self) result(height) class(figure_t), intent(in) :: self integer :: height height = core_get_height(self%state) end function get_height module function get_rendered(self) result(rendered) class(figure_t), intent(in) :: self logical :: rendered rendered = core_get_rendered(self%state) end function get_rendered module subroutine set_rendered(self, rendered) class(figure_t), intent(inout) :: self logical, intent(in) :: rendered call core_set_rendered(self%state, rendered) end subroutine set_rendered module function get_plot_count(self) result(plot_count) class(figure_t), intent(in) :: self integer :: plot_count plot_count = core_get_plot_count(self%state) end function get_plot_count module function get_plots(self) result(plots_ptr) class(figure_t), intent(in), target :: self type(plot_data_t), pointer :: plots_ptr(:) plots_ptr => core_get_plots(self%plots) end function get_plots module function get_dpi(self) result(dpi) !! Get the current DPI setting class(figure_t), intent(in) :: self real(wp) :: dpi dpi = self%state%dpi end function get_dpi module subroutine set_dpi(self, dpi) !! Set the DPI and update backend if needed class(figure_t), intent(inout) :: self real(wp), intent(in) :: dpi ! Validate DPI value if (dpi <= 0.0_wp) then call log_error('set_dpi: DPI must be positive') return end if ! Update DPI in state self%state%dpi = dpi ! Mark as needing re-rendering for consistent output self%state%rendered = .false. end subroutine set_dpi end submodule fortplot_figure_core_wrappers_state