« lib/App/SeismicUnixGui/developer/code/sunix/prog_doc2pm.pm
↑ Summary
lib/App/SeismicUnixGui/misc/param_flow_neutral.pm »
| 1 | package App::SeismicUnixGui::big_streams::pre_built_big_stream; | ||
| 2 | |||
| 3 | =head1 DOCUMENTATION | ||
| 4 | |||
| 5 | =head2 SYNOPSIS | ||
| 6 | |||
| 7 | PERL PROGRAM NAME: pre_built_big_stream | ||
| 8 | AUTHOR: Juan Lorenzo | ||
| 9 | DATE: May 19, 2018 | ||
| 10 | |||
| 11 | DESCRIPTION: | ||
| 12 | Handles setup and selection of predefined “big streams” in SeismicUnixGui. | ||
| 13 | |||
| 14 | BASED ON: | ||
| 15 | Previous versions of the main L_SU.pm (V0.1.1) | ||
| 16 | |||
| 17 | =cut | ||
| 18 | |||
| 19 | use Moose; | ||
| 20 | our $VERSION = '0.1.0'; | ||
| 21 | |||
| 22 | extends 'App::SeismicUnixGui::misc::gui_history' => { -version => 0.0.2 }; | ||
| 23 | |||
| 24 | use aliased 'App::SeismicUnixGui::misc::gui_history'; | ||
| 25 | use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants'; | ||
| 26 | use aliased 'App::SeismicUnixGui::misc::L_SU_local_user_constants'; | ||
| 27 | use aliased 'App::SeismicUnixGui::messages::message_director'; | ||
| 28 | use aliased 'App::SeismicUnixGui::misc::whereami'; | ||
| 29 | use aliased 'App::SeismicUnixGui::misc::param_widgets4pre_built_streams'; | ||
| 30 | use aliased 'App::SeismicUnixGui::misc::binding'; | ||
| 31 | use aliased 'App::SeismicUnixGui::misc::program_name'; | ||
| 32 | use aliased 'App::SeismicUnixGui::misc::config_superflows'; | ||
| 33 | |||
| 34 | #--------------------------------------------------------- | ||
| 35 | # Instantiation | ||
| 36 | #--------------------------------------------------------- | ||
| 37 | |||
| 38 | my $get = L_SU_global_constants->new(); | ||
| 39 | my $param_widgets = param_widgets4pre_built_streams->new(); | ||
| 40 | my $whereami = whereami->new(); | ||
| 41 | my $gui_history = gui_history->new(); | ||
| 42 | my $pre_built_big_stream_href = $gui_history->get_defaults(); | ||
| 43 | my $program_name = program_name->new(); | ||
| 44 | my $pre_built_big_stream_href_sub_ref; | ||
| 45 | |||
| 46 | #--------------------------------------------------------- | ||
| 47 | # Shared parameters | ||
| 48 | #--------------------------------------------------------- | ||
| 49 | |||
| 50 | my $message_w; | ||
| 51 | my ( $values_aref, $names_aref, $check_buttons_settings_aref ); | ||
| 52 | |||
| 53 | #========================================================= | ||
| 54 | # Subroutines | ||
| 55 | #========================================================= | ||
| 56 | |||
| 57 | =head2 sub get_hash_ref | ||
| 58 | |||
| 59 | Return all values of the private hash reference. | ||
| 60 | |||
| 61 | =cut | ||
| 62 | |||
| 63 | sub get_hash_ref { | ||
| 64 | my ($self) = @_; | ||
| 65 | |||
| 66 | if ($pre_built_big_stream_href) { | ||
| 67 | return $pre_built_big_stream_href; | ||
| 68 | } | ||
| 69 | else { | ||
| 70 | print("superflow, get_hash_ref: missing superflow hash_ref\n"); | ||
| 71 | } | ||
| 72 | } | ||
| 73 | |||
| 74 | |||
| 75 | =head2 sub set_flowNsuperflow_name_w | ||
| 76 | |||
| 77 | Assigns a widget name for the current flow or superflow. | ||
| 78 | |||
| 79 | =cut | ||
| 80 | |||
| 81 | sub set_flowNsuperflow_name_w { | ||
| 82 | my ( $self, $flowNsuperflow_name_w ) = @_; | ||
| 83 | |||
| 84 | if ($flowNsuperflow_name_w) { | ||
| 85 | $pre_built_big_stream_href->{_flowNsuperflow_name_w} = $flowNsuperflow_name_w; | ||
| 86 | |||
| 87 | if ( $pre_built_big_stream_href->{_prog_name_sref} ) { | ||
| 88 | my $flowNsuperflow_name = ${ $pre_built_big_stream_href->{_prog_name_sref} }; | ||
| 89 | $flowNsuperflow_name_w->configure( -text => $flowNsuperflow_name ); | ||
| 90 | } | ||
| 91 | else { | ||
| 92 | print("pre_built_big_stream: missing widget name\n"); | ||
| 93 | } | ||
| 94 | } | ||
| 95 | else { | ||
| 96 | print("pre_built_big_stream: missing program name\n"); | ||
| 97 | } | ||
| 98 | |||
| 99 | return (); | ||
| 100 | } | ||
| 101 | |||
| 102 | |||
| 103 | =head2 sub select | ||
| 104 | |||
| 105 | Choose and display a big stream configuration, including parameters and widgets. | ||
| 106 | |||
| 107 | =cut | ||
| 108 | |||
| 109 | sub select { | ||
| 110 | my ($self) = @_; | ||
| 111 | |||
| 112 | my $binding = binding->new(); | ||
| 113 | my $program_name = program_name->new(); | ||
| 114 | my $msg_director = message_director->new(); | ||
| 115 | my $config_superflows = config_superflows->new(); | ||
| 116 | my $Project = 'Project'; | ||
| 117 | |||
| 118 | my $prog_name_sref = $pre_built_big_stream_href->{_prog_name_sref}; | ||
| 119 | my $external_name = $$prog_name_sref; | ||
| 120 | |||
| 121 | # Convert GUI name into internal program name | ||
| 122 | $program_name->set($external_name); | ||
| 123 | my $internal_name = $program_name->get(); | ||
| 124 | $prog_name_sref = \$internal_name; | ||
| 125 | |||
| 126 | my $message = $msg_director->null_button(0); | ||
| 127 | $message_w->delete( "1.0", 'end' ); | ||
| 128 | $message_w->insert( 'end', $message ); | ||
| 129 | |||
| 130 | # Prepare GUI history | ||
| 131 | gui_history->set_hash_ref($pre_built_big_stream_href); | ||
| 132 | gui_history->set4start_of_superflow_select(); | ||
| 133 | $pre_built_big_stream_href = gui_history->get_hash_ref(); | ||
| 134 | |||
| 135 | # Update GUI position and configuration | ||
| 136 | $whereami->set4superflow_select_button(); | ||
| 137 | $config_superflows->set_program_name($prog_name_sref); | ||
| 138 | $config_superflows->set_prog_name_config($prog_name_sref); | ||
| 139 | my $prog_name_config = $config_superflows->get_prog_name_config(); | ||
| 140 | |||
| 141 | # Handle Project.config or other streams | ||
| 142 | if ( $prog_name_config eq $Project . '.config' ) { | ||
| 143 | my $user_constants = L_SU_local_user_constants->new(); | ||
| 144 | |||
| 145 | if ( $user_constants->user_configuration_Project_config_exists() ) { | ||
| 146 | # Valid configuration exists | ||
| 147 | } | ||
| 148 | elsif ( not $user_constants->user_configuration_Project_config_exists ) { | ||
| 149 | my $message = $msg_director->superflow(0); | ||
| 150 | $pre_built_big_stream_href->{_message_w}->delete( "1.0", 'end' ); | ||
| 151 | $pre_built_big_stream_href->{_message_w}->insert( 'end', $message ); | ||
| 152 | } | ||
| 153 | else { | ||
| 154 | print("pre_built_big_stream: invalid Project.config file name\n"); | ||
| 155 | } | ||
| 156 | } | ||
| 157 | else { | ||
| 158 | $config_superflows->inbound(); | ||
| 159 | $config_superflows->check2read(); | ||
| 160 | } | ||
| 161 | |||
| 162 | # Get parameter data | ||
| 163 | $pre_built_big_stream_href->{_names_aref} = $config_superflows->get_names(); | ||
| 164 | $pre_built_big_stream_href->{_values_aref} = $config_superflows->get_values(); | ||
| 165 | $pre_built_big_stream_href->{_check_buttons_settings_aref} = $config_superflows->get_check_buttons_settings(); | ||
| 166 | $pre_built_big_stream_href->{_superflow_first_idx} = $config_superflows->first_idx(); | ||
| 167 | $pre_built_big_stream_href->{_superflow_length} = $config_superflows->length(); | ||
| 168 | |||
| 169 | # GUI refresh | ||
| 170 | $param_widgets->gui_full_clear(); | ||
| 171 | $param_widgets->range($pre_built_big_stream_href); | ||
| 172 | $param_widgets->set_labels( $pre_built_big_stream_href->{_names_aref} ); | ||
| 173 | $param_widgets->set_values( $pre_built_big_stream_href->{_values_aref} ); | ||
| 174 | $param_widgets->set_check_buttons( $pre_built_big_stream_href->{_check_buttons_settings_aref} ); | ||
| 175 | $param_widgets->set_current_program($prog_name_sref); | ||
| 176 | |||
| 177 | $param_widgets->redisplay_labels(); | ||
| 178 | $param_widgets->redisplay_values(); | ||
| 179 | $param_widgets->redisplay_check_buttons(); | ||
| 180 | |||
| 181 | # Focus on first entry field (no highlighting) | ||
| 182 | my @Entry_widget = @{ $param_widgets->get_values_w_aref() }; | ||
| 183 | $Entry_widget[0]->focus; | ||
| 184 | |||
| 185 | # Bind callbacks and actions | ||
| 186 | my $run_name = $internal_name; | ||
| 187 | $binding->set_prog_name_sref( \$run_name ); | ||
| 188 | $binding->set_values_w_aref( $param_widgets->get_values_w_aref ); | ||
| 189 | $binding->setFileDialog_button_sub_ref($pre_built_big_stream_href_sub_ref); | ||
| 190 | $binding->set(); | ||
| 191 | |||
| 192 | # Update reference data for export | ||
| 193 | $values_aref = $pre_built_big_stream_href->{_values_aref}; | ||
| 194 | gui_history->set_hash_ref($pre_built_big_stream_href); | ||
| 195 | gui_history->set4end_of_superflow_select(); | ||
| 196 | $pre_built_big_stream_href = gui_history->get_hash_ref(); | ||
| 197 | |||
| 198 | $names_aref = $pre_built_big_stream_href->{_names_aref}; | ||
| 199 | $values_aref = $pre_built_big_stream_href->{_values_aref}; | ||
| 200 | $check_buttons_settings_aref = $pre_built_big_stream_href->{_check_buttons_settings_aref}; | ||
| 201 | |||
| 202 | return (); | ||
| 203 | } | ||
| 204 | |||
| 205 | |||
| 206 | =head2 sub set_hash_ref | ||
| 207 | |||
| 208 | Imports an external hash reference into local scope and updates widget references. | ||
| 209 | |||
| 210 | =cut | ||
| 211 | |||
| 212 | sub set_hash_ref { | ||
| 213 | my ( $self, $hash_ref ) = @_; | ||
| 214 | |||
| 215 | $gui_history->set_defaults($hash_ref); | ||
| 216 | $pre_built_big_stream_href = $gui_history->get_defaults(); | ||
| 217 | |||
| 218 | $param_widgets->set_hash_ref($pre_built_big_stream_href); | ||
| 219 | $message_w = $pre_built_big_stream_href->{_message_w}; | ||
| 220 | |||
| 221 | return (); | ||
| 222 | } | ||
| 223 | |||
| 224 | |||
| 225 | =head2 sub set_name_sref | ||
| 226 | |||
| 227 | Optionally assigns a program name reference. | ||
| 228 | |||
| 229 | =cut | ||
| 230 | |||
| 231 | sub set_name_sref { | ||
| 232 | my ( $self, $prog_name_sref ) = @_; | ||
| 233 | |||
| 234 | if ($prog_name_sref) { | ||
| 235 | $pre_built_big_stream_href->{_prog_name_sref} = $prog_name_sref; | ||
| 236 | } | ||
| 237 | else { | ||
| 238 | print("pre_built_big_stream: missing program name\n"); | ||
| 239 | } | ||
| 240 | |||
| 241 | return (); | ||
| 242 | } | ||
| 243 | |||
| 244 | |||
| 245 | =head2 sub set_sub_ref | ||
| 246 | |||
| 247 | Stores a subroutine reference for later binding within the namespace. | ||
| 248 | |||
| 249 | =cut | ||
| 250 | |||
| 251 | sub set_sub_ref { | ||
| 252 | my ( $self, $sub_ref ) = @_; | ||
| 253 | |||
| 254 | if ( length $sub_ref ) { | ||
| 255 | $pre_built_big_stream_href_sub_ref = $sub_ref; | ||
| 256 | } | ||
| 257 | else { | ||
| 258 | print("pre_built_big_stream: missing subroutine reference\n"); | ||
| 259 | } | ||
| 260 | |||
| 261 | return (); | ||
| 262 | } | ||
| 263 | |||
| 264 | 1; |