Figure lifecycle management module for fortplot_figure_core
This module handles figure lifecycle, initialization, I/O operations, animation support, and cleanup. Extracted from fortplot_figure_core.f90 for better organization following Single Responsibility Principle.
Responsibilities: - Figure initialization and destruction - File I/O operations (savefig, show) - Animation support (PNG backend setup, data extraction) - Streamline data management - Subplot management
============================================================================= CORE MODULE DELEGATION WRAPPERS Simple wrapper procedures for core module delegation pattern =============================================================================
Get the number of plots in a specific subplot
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(subplot_data_t), | intent(in) | :: | subplots_array(:,:) | |||
| integer, | intent(in) | :: | subplot_rows | |||
| integer, | intent(in) | :: | subplot_cols | |||
| integer, | intent(in) | :: | row | |||
| integer, | intent(in) | :: | col | 
Get the title for a specific subplot
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(subplot_data_t), | intent(in) | :: | subplots_array(:,:) | |||
| integer, | intent(in) | :: | subplot_rows | |||
| integer, | intent(in) | :: | subplot_cols | |||
| integer, | intent(in) | :: | row | |||
| integer, | intent(in) | :: | col | 
Initialize the figure with specified dimensions and backend
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(figure_state_t), | intent(inout) | :: | state | |||
| type(plot_data_t), | intent(inout), | allocatable | :: | plots(:) | ||
| type(plot_data_t), | intent(inout), | allocatable | :: | streamlines(:) | ||
| type(subplot_data_t), | intent(inout), | allocatable | :: | subplots_array(:,:) | ||
| integer, | intent(inout) | :: | subplot_rows | |||
| integer, | intent(inout) | :: | subplot_cols | |||
| integer, | intent(inout) | :: | current_subplot | |||
| character(len=:), | intent(inout), | allocatable | :: | title_target | ||
| character(len=:), | intent(inout), | allocatable | :: | xlabel_target | ||
| character(len=:), | intent(inout), | allocatable | :: | ylabel_target | ||
| integer, | intent(inout) | :: | plot_count | |||
| integer, | intent(in), | optional | :: | width | ||
| integer, | intent(in), | optional | :: | height | ||
| character(len=*), | intent(in), | optional | :: | backend | 
Finalize and clean up figure
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(figure_state_t), | intent(inout) | :: | state | |||
| type(plot_data_t), | intent(inout), | allocatable | :: | plots(:) | ||
| type(plot_data_t), | intent(inout), | allocatable | :: | streamlines(:) | ||
| character(len=:), | intent(inout), | allocatable | :: | title_target | ||
| character(len=:), | intent(inout), | allocatable | :: | xlabel_target | ||
| character(len=:), | intent(inout), | allocatable | :: | ylabel_target | 
Save figure to file (backward compatibility version)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(figure_state_t), | intent(inout) | :: | state | |||
| type(plot_data_t), | intent(inout) | :: | plots(:) | |||
| integer, | intent(in) | :: | plot_count | |||
| character(len=*), | intent(in) | :: | filename | |||
| logical, | intent(in), | optional | :: | blocking | ||
| type(text_annotation_t), | intent(in), | optional | :: | annotations(:) | ||
| integer, | intent(in), | optional | :: | annotation_count | ||
| type(subplot_data_t), | intent(in), | optional | :: | subplots_array(:,:) | ||
| integer, | intent(in), | optional | :: | subplot_rows | ||
| integer, | intent(in), | optional | :: | subplot_cols | 
Save figure to file with error status reporting
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(figure_state_t), | intent(inout) | :: | state | |||
| type(plot_data_t), | intent(inout) | :: | plots(:) | |||
| integer, | intent(in) | :: | plot_count | |||
| character(len=*), | intent(in) | :: | filename | |||
| integer, | intent(out) | :: | status | |||
| logical, | intent(in), | optional | :: | blocking | ||
| type(text_annotation_t), | intent(in), | optional | :: | annotations(:) | ||
| integer, | intent(in), | optional | :: | annotation_count | ||
| type(subplot_data_t), | intent(in), | optional | :: | subplots_array(:,:) | ||
| integer, | intent(in), | optional | :: | subplot_rows | ||
| integer, | intent(in), | optional | :: | subplot_cols | 
Display the figure
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(figure_state_t), | intent(inout) | :: | state | |||
| type(plot_data_t), | intent(inout) | :: | plots(:) | |||
| integer, | intent(in) | :: | plot_count | |||
| logical, | intent(in), | optional | :: | blocking | ||
| type(text_annotation_t), | intent(in), | optional | :: | annotations(:) | ||
| integer, | intent(in), | optional | :: | annotation_count | ||
| type(subplot_data_t), | intent(in), | optional | :: | subplots_array(:,:) | ||
| integer, | intent(in), | optional | :: | subplot_rows | ||
| integer, | intent(in), | optional | :: | subplot_cols | 
Clear the figure to prepare for reuse (preserving backend settings)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(figure_state_t), | intent(inout) | :: | state | |||
| type(plot_data_t), | intent(inout), | allocatable | :: | streamlines(:) | ||
| type(subplot_data_t), | intent(inout), | allocatable | :: | subplots_array(:,:) | ||
| integer, | intent(inout) | :: | subplot_rows | |||
| integer, | intent(inout) | :: | subplot_cols | |||
| integer, | intent(inout) | :: | current_subplot | |||
| character(len=:), | intent(inout), | allocatable | :: | title_target | ||
| character(len=:), | intent(inout), | allocatable | :: | xlabel_target | ||
| character(len=:), | intent(inout), | allocatable | :: | ylabel_target | ||
| integer, | intent(inout) | :: | plot_count | |||
| integer, | intent(inout) | :: | annotation_count | 
Clear streamline data
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(plot_data_t), | intent(inout), | allocatable | :: | streamlines(:) | 
Setup PNG backend for animation
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(figure_state_t), | intent(inout) | :: | state | 
Extract RGB data for animation
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(figure_state_t), | intent(inout) | :: | state | |||
| real(kind=wp), | intent(out) | :: | rgb_data(:,:,:) | |||
| logical, | intent(in) | :: | rendered | 
Extract PNG data for animation
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(figure_state_t), | intent(inout) | :: | state | |||
| integer(kind=1), | intent(out), | allocatable | :: | png_data(:) | ||
| integer, | intent(out) | :: | status | |||
| logical, | intent(in) | :: | rendered | 
Create a grid of subplots
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(subplot_data_t), | intent(inout), | allocatable | :: | subplots_array(:,:) | ||
| integer, | intent(inout) | :: | subplot_rows | |||
| integer, | intent(inout) | :: | subplot_cols | |||
| integer, | intent(inout) | :: | current_subplot | |||
| integer, | intent(in) | :: | nrows | |||
| integer, | intent(in) | :: | ncols | 
Add a plot to a specific subplot
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(subplot_data_t), | intent(inout) | :: | subplots_array(:,:) | |||
| integer, | intent(in) | :: | subplot_rows | |||
| integer, | intent(in) | :: | subplot_cols | |||
| integer, | intent(in) | :: | row | |||
| integer, | intent(in) | :: | col | |||
| real(kind=wp), | intent(in) | :: | x(:) | |||
| real(kind=wp), | intent(in) | :: | y(:) | |||
| character(len=*), | intent(in), | optional | :: | label | ||
| character(len=*), | intent(in), | optional | :: | linestyle | ||
| real(kind=wp), | intent(in), | optional | :: | color(3) | ||
| real(kind=wp), | intent(in) | :: | colors(:,:) | |||
| integer, | intent(in) | :: | num_colors | 
Set the title for a specific subplot
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(subplot_data_t), | intent(inout) | :: | subplots_array(:,:) | |||
| integer, | intent(in) | :: | subplot_rows | |||
| integer, | intent(in) | :: | subplot_cols | |||
| integer, | intent(in) | :: | row | |||
| integer, | intent(in) | :: | col | |||
| character(len=*), | intent(in) | :: | title | 
Set the x-axis label for a specific subplot
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(subplot_data_t), | intent(inout) | :: | subplots_array(:,:) | |||
| integer, | intent(in) | :: | subplot_rows | |||
| integer, | intent(in) | :: | subplot_cols | |||
| integer, | intent(in) | :: | row | |||
| integer, | intent(in) | :: | col | |||
| character(len=*), | intent(in) | :: | xlabel | 
Set the y-axis label for a specific subplot
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(subplot_data_t), | intent(inout) | :: | subplots_array(:,:) | |||
| integer, | intent(in) | :: | subplot_rows | |||
| integer, | intent(in) | :: | subplot_cols | |||
| integer, | intent(in) | :: | row | |||
| integer, | intent(in) | :: | col | |||
| character(len=*), | intent(in) | :: | ylabel | 
Clear the figure for reuse, preserving backend settings
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(figure_state_t), | intent(inout) | :: | state | |||
| type(plot_data_t), | intent(inout), | allocatable | :: | streamlines(:) | ||
| type(subplot_data_t), | intent(inout), | allocatable | :: | subplots_array(:,:) | ||
| integer, | intent(inout) | :: | subplot_rows | |||
| integer, | intent(inout) | :: | subplot_cols | |||
| integer, | intent(inout) | :: | current_subplot | |||
| character(len=:), | intent(inout), | allocatable | :: | title_target | ||
| character(len=:), | intent(inout), | allocatable | :: | xlabel_target | ||
| character(len=:), | intent(inout), | allocatable | :: | ylabel_target | ||
| integer, | intent(inout) | :: | plot_count | |||
| integer, | intent(inout) | :: | annotation_count | 
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(plot_data_t), | intent(inout), | allocatable | :: | streamlines(:) | 
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(figure_state_t), | intent(inout) | :: | state | |||
| type(plot_data_t), | intent(inout), | allocatable | :: | plots(:) | ||
| type(plot_data_t), | intent(inout), | allocatable | :: | streamlines(:) | ||
| character(len=:), | intent(inout), | allocatable | :: | title_target | ||
| character(len=:), | intent(inout), | allocatable | :: | xlabel_target | ||
| character(len=:), | intent(inout), | allocatable | :: | ylabel_target |