« lib/App/SeismicUnixGui/misc/grey_flow.pm
↑ Summary
lib/App/SeismicUnixGui/sunix/shapeNcut/susplit.pm »
| 1 | package App::SeismicUnixGui::misc::pink_flow; | ||
| 2 | |||
| 3 | =head1 DOCUMENTATION | ||
| 4 | |||
| 5 | |||
| 6 | =head2 SYNOPSIS | ||
| 7 | |||
| 8 | PERL PERL PROGRAM NAME: pink_flow.pm | ||
| 9 | AUTHOR: Juan Lorenzo | ||
| 10 | DATE: June 8 2018 | ||
| 11 | |||
| 12 | DESCRIPTION | ||
| 13 | |||
| 14 | |||
| 15 | BASED ON: | ||
| 16 | previous versions of the main userBuiltFlow.pl | ||
| 17 | |||
| 18 | |||
| 19 | =cut | ||
| 20 | |||
| 21 | =head2 USE | ||
| 22 | |||
| 23 | =head3 NOTES | ||
| 24 | |||
| 25 | Provides in-house macros/superflows | ||
| 26 | 1. Find widget you have selected | ||
| 27 | |||
| 28 | if widget_name= frame then we have flow | ||
| 29 | $var->{_flow} | ||
| 30 | |||
| 31 | if widget_name= menubutton we have superflow | ||
| 32 | $var->{_tool} | ||
| 33 | |||
| 34 | 2. Set the new program name | ||
| 35 | |||
| 36 | 3. Make widget states active for: | ||
| 37 | run_button | ||
| 38 | save_button | ||
| 39 | |||
| 40 | 4. Disable the following widgets: | ||
| 41 | delete_from_flow_button | ||
| 42 | (sunix) flow_listbox | ||
| 43 | |||
| 44 | sunix_listbox -choice of listed sunix modules in a listbox | ||
| 45 | gui_history records updates to GUI selections | ||
| 46 | but color_flow_href points to the changed has reference and senses | ||
| 47 | the change as well. | ||
| 48 | |||
| 49 | =head4 Examples | ||
| 50 | |||
| 51 | =head3 SEISMIC UNIX NOTES | ||
| 52 | |||
| 53 | =head2 CHANGES and their DATES | ||
| 54 | refactoring of 2017 version of L_SU.pl | ||
| 55 | V 0.0.2 removed unused methods in comments | ||
| 56 | |||
| 57 | V 0.0.3 2021 allows for better color listbox control | ||
| 58 | |||
| 59 | V 0.0.4 7.10.21 allows control to handle non-numeric | ||
| 60 | names for input files | ||
| 61 | |||
| 62 | =cut | ||
| 63 | |||
| 64 | =head2 Notes | ||
| 65 | |||
| 66 | sub sunix_select (subroutine is only active in neutral_flow.pm) | ||
| 67 | |||
| 68 | |||
| 69 | =cut | ||
| 70 | |||
| 71 | use Moose; | ||
| 72 | our $VERSION = '0.0.4'; | ||
| 73 | |||
| 74 | use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants'; | ||
| 75 | use aliased 'App::SeismicUnixGui::configs::big_streams::Project_config'; | ||
| 76 | |||
| 77 | extends 'App::SeismicUnixGui::misc::gui_history' => { -version => 0.0.2 }; | ||
| 78 | use aliased 'App::SeismicUnixGui::misc::gui_history'; | ||
| 79 | |||
| 80 | # use App::SeismicUnixGui::misc::param_widgets_pink '0.0.2'; | ||
| 81 | # use aliased 'App::SeismicUnixGui::misc::param_widgets_pink'; | ||
| 82 | |||
| 83 | use App::SeismicUnixGui::misc::param_widgets_color '0.0.3'; | ||
| 84 | use aliased 'App::SeismicUnixGui::misc::param_widgets_color'; | ||
| 85 | |||
| 86 | use App::SeismicUnixGui::misc::param_flow_pink '0.0.5'; | ||
| 87 | use aliased 'App::SeismicUnixGui::misc::param_flow_pink'; | ||
| 88 | |||
| 89 | use aliased 'App::SeismicUnixGui::misc::binding'; | ||
| 90 | |||
| 91 | use App::SeismicUnixGui::misc::control '0.0.3'; | ||
| 92 | use aliased 'App::SeismicUnixGui::misc::control'; | ||
| 93 | |||
| 94 | use App::SeismicUnixGui::misc::decisions '1.0.0'; | ||
| 95 | use aliased 'App::SeismicUnixGui::misc::decisions'; | ||
| 96 | |||
| 97 | use aliased 'App::SeismicUnixGui::misc::dirs'; | ||
| 98 | use aliased 'App::SeismicUnixGui::misc::file_dialog'; | ||
| 99 | use aliased 'App::SeismicUnixGui::misc::files_LSU'; | ||
| 100 | use aliased 'App::SeismicUnixGui::misc::flow_widgets'; | ||
| 101 | use aliased 'App::SeismicUnixGui::misc::help'; | ||
| 102 | use aliased 'App::SeismicUnixGui::misc::manage_files_by2'; | ||
| 103 | use aliased 'App::SeismicUnixGui::messages::message_director'; | ||
| 104 | use aliased 'App::SeismicUnixGui::misc::perl_flow'; | ||
| 105 | use aliased 'App::SeismicUnixGui::misc::param_sunix'; | ||
| 106 | |||
| 107 | use Carp; | ||
| 108 | use Clone 'clone'; | ||
| 109 | |||
| 110 | =head2 Instantiation | ||
| 111 | |||
| 112 | =cut | ||
| 113 | |||
| 114 | my $Project = Project_config->new(); | ||
| 115 | my $L_SU_global_constants = L_SU_global_constants->new(); | ||
| 116 | my $control = control->new(); | ||
| 117 | my $decisions = decisions->new(); | ||
| 118 | my $dirs = dirs->new(); | ||
| 119 | my $file_dialog = file_dialog->new(); | ||
| 120 | my $flow_widgets = flow_widgets->new(); | ||
| 121 | my $gui_history = gui_history->new(); | ||
| 122 | my $manage_files_by2 = manage_files_by2->new(); | ||
| 123 | my $message_director = message_director->new(); | ||
| 124 | |||
| 125 | my $param_flow_color_pkg = param_flow_pink->new(); | ||
| 126 | my $param_widgets = param_widgets_color->new(); | ||
| 127 | |||
| 128 | |||
| 129 | my $flow_type = $L_SU_global_constants->flow_type_href(); | ||
| 130 | my $var = $L_SU_global_constants->var(); | ||
| 131 | my $empty_string = $var->{_empty_string}; | ||
| 132 | my $this_color = 'pink'; | ||
| 133 | |||
| 134 | |||
| 135 | my $color_flow_href = $gui_history->get_defaults(); | ||
| 136 | my $neutral = $var->{_neutral}; | ||
| 137 | my $sunix_select = $var->{_sunix_select}; | ||
| 138 | my $number_from_color = $L_SU_global_constants->number_from_color_href(); | ||
| 139 | |||
| 140 | # set the flow color being used for the instance | ||
| 141 | $param_widgets->set_color_flow($this_color); | ||
| 142 | |||
| 143 | my $_is_last_parameter_index_touched_color = | ||
| 144 | '_is_last_parameter_index_touched_' . $this_color; | ||
| 145 | my $_flow_listbox_color_w = '_flow_listbox_' . $this_color . '_w'; | ||
| 146 | my $_flow_name_color_w = '_flow_name_' . $this_color . '_w'; | ||
| 147 | my $_number_from_color = $number_from_color->{ ( '_' . $this_color ) }; | ||
| 148 | my $_flow_name_in_color = '_flow_name_in_' . $this_color; | ||
| 149 | my $_flow_name_out_color = '_flow_name_out_' . $this_color; | ||
| 150 | |||
| 151 | =head2 | ||
| 152 | |||
| 153 | share the following parameters in same name | ||
| 154 | space | ||
| 155 | |||
| 156 | =cut | ||
| 157 | |||
| 158 | my $flow_color; | ||
| 159 | my $flow_name_color_w; | ||
| 160 | my $flowNsuperflow_name_w; | ||
| 161 | my $last_flow_color; | ||
| 162 | my $message_w; | ||
| 163 | my $occupied_listbox_aref; | ||
| 164 | my $vacant_listbox_aref; | ||
| 165 | my $parameter_values_button_frame; | ||
| 166 | my $parameter_values_frame; | ||
| 167 | |||
| 168 | my $user_built = $flow_type->{_user_built}; | ||
| 169 | my $true = $var->{_true}; | ||
| 170 | my $false = $var->{_false}; | ||
| 171 | |||
| 172 | #my @empty_array = (0); # length=1 | ||
| 173 | |||
| 174 | =head2 memory leak saviors | ||
| 175 | |||
| 176 | =cut | ||
| 177 | |||
| 178 | my $default = 0; | ||
| 179 | my @save_last_param_widget_values; | ||
| 180 | my $save_last_param_widget_value; | ||
| 181 | my $save_last_param_widget_index = $default; | ||
| 182 | my $memory_leak4save_button_fixed = $false; | ||
| 183 | my $memory_leak4flow_select_fixed = $false; | ||
| 184 | my $min_clicks4save_button = $var->{_min_clicks4save_button}; | ||
| 185 | my $min_clicks4flow_select = $var->{_min_clicks4flow_select}; | ||
| 186 | my $first_opening = $true; # don't touch, but commented out below | ||
| 187 | |||
| 188 | =head2 private anonymous hash | ||
| 189 | to share variable values easily | ||
| 190 | |||
| 191 | =cut | ||
| 192 | |||
| 193 | my $color_flow = { | ||
| 194 | |||
| 195 | _Flow_file_exists => $false, | ||
| 196 | _perl_flow_errors => $true, | ||
| 197 | |||
| 198 | }; | ||
| 199 | |||
| 200 | =head2 sub _add2flow | ||
| 201 | |||
| 202 | When automatically reading a user-built perl flow and not directed | ||
| 203 | to do so by a user's click of the mouse. | ||
| 204 | As when a file is opened | ||
| 205 | Incorporate new program parameter values and labels into the gui | ||
| 206 | and save the values, labels and checkbuttons setting in the param_flow | ||
| 207 | namespace | ||
| 208 | |||
| 209 | foreach my $key (sort keys %$color_flow_href) { | ||
| 210 | print (" color_flow _add2flow,key is $key, value is $color_flow_href->{$key}\n"); | ||
| 211 | } | ||
| 212 | |||
| 213 | _flow_select is run from _perl_flow | ||
| 214 | |||
| 215 | =cut | ||
| 216 | |||
| 217 | sub _add2flow { | ||
| 218 | |||
| 219 | my ( $self, $value ) = @_; | ||
| 220 | |||
| 221 | my $message = $message_director->null_button(0); | ||
| 222 | |||
| 223 | my $here; | ||
| 224 | my $flow_color = _get_flow_color(); | ||
| 225 | $gui_history->set_add2flow_color($flow_color); | ||
| 226 | $gui_history->set_button('add2flow_button'); | ||
| 227 | $gui_history->set_flow_type($user_built); | ||
| 228 | |||
| 229 | $gui_history->set_hash_ref($color_flow_href); | ||
| 230 | $gui_history->set4start_of_add2flow_button($flow_color); | ||
| 231 | $color_flow_href = $gui_history->get_hash_ref(); | ||
| 232 | |||
| 233 | $message_w->delete( "1.0", 'end' ); | ||
| 234 | $message_w->insert( 'end', $message ); | ||
| 235 | |||
| 236 | # add the most recently selected program | ||
| 237 | # name (scalar reference) to the | ||
| 238 | # end of the list inside flow_listbox | ||
| 239 | _local_set_flow_listbox_color_w($flow_color); # in "color"_flow namespace | ||
| 240 | |||
| 241 | # append new program names to the end of the list but this item is NOT selected | ||
| 242 | # selection occurs inside gui_history, conditions_gui | ||
| 243 | $color_flow_href->{_flow_listbox_color_w} | ||
| 244 | ->insert( "end", ${ $color_flow_href->{_prog_name_sref} }, ); | ||
| 245 | |||
| 246 | # display default paramters in the GUI | ||
| 247 | # same as for sunix_select | ||
| 248 | # can not get program name from the item selected in the sunix list box | ||
| 249 | # because focus is transferred to a flow list box ($this_color) | ||
| 250 | |||
| 251 | # widgets are initialized in a super class | ||
| 252 | # Assign program parameters in the GUI | ||
| 253 | # See: L_SU_global_constants.pl | ||
| 254 | |||
| 255 | $param_widgets->set_labels_w_aref( $color_flow_href->{_labels_w_aref} ); | ||
| 256 | $param_widgets->set_values_w_aref( $color_flow_href->{_values_w_aref} ); | ||
| 257 | $param_widgets->set_check_buttons_w_aref( | ||
| 258 | $color_flow_href->{_check_buttons_w_aref} ); | ||
| 259 | |||
| 260 | $param_widgets->range($color_flow_href); | ||
| 261 | $param_widgets->set_labels( $color_flow_href->{_names_aref} ); | ||
| 262 | $param_widgets->set_values( $color_flow_href->{_values_aref} ); | ||
| 263 | $param_widgets->set_check_buttons( | ||
| 264 | $color_flow_href->{_check_buttons_settings_aref} ); | ||
| 265 | |||
| 266 | # print(" 22. color_flow, _add2flow, color_flow_href->{_values_aref}=@{$color_flow_href->{_values_aref}}\n"); | ||
| 267 | |||
| 268 | # wipe out values labels and checkbuttons from the gui | ||
| 269 | # strange memory leak inside param_widgets | ||
| 270 | # TODO check it this is still true? | ||
| 271 | # my $save1 = clone( $color_flow_href->{_check_buttons_settings_aref} ); | ||
| 272 | # $param_widgets->gui_full_clear(); | ||
| 273 | # @{ $color_flow_href->{_check_buttons_settings_aref} } = @$save1; | ||
| 274 | # | ||
| 275 | # $param_widgets->redisplay_labels(); | ||
| 276 | # $param_widgets->redisplay_values(); | ||
| 277 | # $param_widgets->redisplay_check_buttons(); | ||
| 278 | |||
| 279 | # @{ $color_flow_href->{_names_aref} } = @$save2; | ||
| 280 | # @{ $color_flow_href->{_values_aref} } = @$save3; | ||
| 281 | |||
| 282 | # Collect and store prog versions changed in list box | ||
| 283 | _stack_versions(); | ||
| 284 | |||
| 285 | # Add a single_program to the growing stack | ||
| 286 | # store one program name, its associated parameters and their values | ||
| 287 | # as well as the checkbuttons settings (on or off) in another namespace | ||
| 288 | _stack_flow(); | ||
| 289 | |||
| 290 | $gui_history->set_hash_ref($color_flow_href); | ||
| 291 | $gui_history->set4end_of_add2flow($flow_color); | ||
| 292 | |||
| 293 | my $index = $flow_widgets->get_flow_selection( | ||
| 294 | $color_flow_href->{_flow_listbox_color_w} ); | ||
| 295 | |||
| 296 | $gui_history->set_flow_index_last_touched($index); # flow color is not reset | ||
| 297 | $color_flow_href = $gui_history->get_hash_ref(); | ||
| 298 | |||
| 299 | # switch between the correct index of the last parameter that was touched | ||
| 300 | # as a function of the flow's color | ||
| 301 | # These data are encapsulated | ||
| 302 | $color_flow_href->{_last_parameter_index_touched_color} = 0; # initialize | ||
| 303 | $color_flow_href->{$_is_last_parameter_index_touched_color} = $true; | ||
| 304 | |||
| 305 | $param_widgets->set_check_buttons( | ||
| 306 | $color_flow_href->{_check_buttons_settings_aref} ); | ||
| 307 | |||
| 308 | # print( | ||
| 309 | #" 2. color_flow, END _add2flow, color_flow_href->{_values_aref}=@{$color_flow_href->{_values_aref}}\n" | ||
| 310 | # ); | ||
| 311 | |||
| 312 | # print(" 2. color_flow, END _add2flow, widget values =@{$param_widgets->get_values_aref()} \n"); | ||
| 313 | |||
| 314 | _flow_select_director('_add2flow'); | ||
| 315 | |||
| 316 | $param_widgets->set_entry_change_status($false); | ||
| 317 | |||
| 318 | return (); | ||
| 319 | |||
| 320 | } | ||
| 321 | |||
| 322 | =head2 sub _clear_color_flow | ||
| 323 | |||
| 324 | wipe out color-flow list box with programs | ||
| 325 | wipe out param_widgets_color | ||
| 326 | wipe out parameters stored for color flow | ||
| 327 | |||
| 328 | =cut | ||
| 329 | |||
| 330 | sub _clear_color_flow { | ||
| 331 | my ($self) = @_; | ||
| 332 | |||
| 333 | # my $number = $param_flow_color_pkg->get_num_items(); | ||
| 334 | |||
| 335 | #clear all stored parameters and versions in the param_flow | ||
| 336 | $param_flow_color_pkg->clear(); | ||
| 337 | my $number = $param_flow_color_pkg->get_num_items(); | ||
| 338 | |||
| 339 | my $test = $color_flow_href->{_check_buttons_settings_aref}; | ||
| 340 | |||
| 341 | # clear the parameter values and labels belonging to the gui | ||
| 342 | # strange memory leak inside param_widgets | ||
| 343 | my $save = clone( $color_flow_href->{_check_buttons_settings_aref} ); | ||
| 344 | $param_widgets->gui_full_clear(); | ||
| 345 | |||
| 346 | # print("color_flow,_clear_color_flow: print gui_history.txt \n"); | ||
| 347 | # $gui_history->view(); | ||
| 348 | @{ $color_flow_href->{_check_buttons_settings_aref} } = @$save; | ||
| 349 | |||
| 350 | # remove all sunix program names from the flow listbox | ||
| 351 | # in "color"_flow namespace | ||
| 352 | my $_flow_listbox_color_w = _get_flow_listbox_color_w(); | ||
| 353 | $flow_widgets->clear($_flow_listbox_color_w); | ||
| 354 | |||
| 355 | } | ||
| 356 | |||
| 357 | =head2 sub _FileDialog_button | ||
| 358 | |||
| 359 | Only cases with MB binding use this private ('_') subroutine | ||
| 360 | e.g., sunix programs displayed in the parameter boxes during | ||
| 361 | flow construction. | ||
| 362 | sub binding is responsible | ||
| 363 | Other cases that select the GUI file buttons directly (user click) use: FileDialog_button instead. | ||
| 364 | Once the file name is selected the parameter value is updated in the GUI | ||
| 365 | |||
| 366 | foreach my $key (sort keys %$color_flow) { | ||
| 367 | print (" color_flowkey is $key, value is $color_flow->{$key}\n"); | ||
| 368 | } | ||
| 369 | print ("color_flow,_FileDialog_button(binding), _is_flow_listbox_color_w: $color_flow_href->{_is_flow_listbox_color_w} \n"); | ||
| 370 | |||
| 371 | =cut | ||
| 372 | |||
| 373 | sub _FileDialog_button { | ||
| 374 | |||
| 375 | my ( $self, $flow_dialog_type_sref ) = @_; | ||
| 376 | |||
| 377 | if ($flow_dialog_type_sref) { | ||
| 378 | |||
| 379 | # flow dialog type can be | ||
| 380 | # 'Open' or Data_PL_SEISMIC | ||
| 381 | |||
| 382 | # provide values in the current widget | ||
| 383 | $color_flow_href->{_values_aref} = $param_widgets->get_values_aref(); | ||
| 384 | |||
| 385 | my $most_recent_flow_index_touched = | ||
| 386 | ( $color_flow_href->{_flow_select_index_href} )->{_most_recent}; | ||
| 387 | |||
| 388 | # establish which program is active in the flow | ||
| 389 | $color_flow_href->{_prog_names_aref} = | ||
| 390 | $param_flow_color_pkg->get_flow_prog_names_aref(); | ||
| 391 | $control->set_flow_prog_names_aref( | ||
| 392 | $color_flow_href->{_prog_names_aref} ); | ||
| 393 | $control->set_flow_prog_name_index($most_recent_flow_index_touched); | ||
| 394 | |||
| 395 | # clean all quotes upon input | ||
| 396 | $color_flow_href->{_values_aref} = | ||
| 397 | $control->get_no_quotes4array( $color_flow_href->{_values_aref} ); | ||
| 398 | |||
| 399 | # restore string quotes to values that need them | ||
| 400 | # e.g., character strings as well as fnumeric file names | ||
| 401 | $color_flow_href->{_values_aref} = $control->get_string_or_number4aref( | ||
| 402 | $color_flow_href->{_values_aref} ); | ||
| 403 | |||
| 404 | # dereference scalar | ||
| 405 | $color_flow_href->{_dialog_type} = $$flow_dialog_type_sref; | ||
| 406 | |||
| 407 | $file_dialog->set_flow_color( $color_flow_href->{_flow_color} ); | ||
| 408 | $file_dialog->set_hash_ref($color_flow_href); | ||
| 409 | $file_dialog->set_dialog_type($$flow_dialog_type_sref); | ||
| 410 | $file_dialog->FileDialog_director(); | ||
| 411 | |||
| 412 | # updates to parameter values | ||
| 413 | # changed within file_dialog are retrieved | ||
| 414 | $color_flow_href->{_values_aref} = $file_dialog->get_values_aref(); | ||
| 415 | |||
| 416 | # print("color flow, _FileDialog_button: color_flow_href->{_values_aref}=@{$color_flow_href->{_values_aref}}\n"); | ||
| 417 | |||
| 418 | # assume that after selection to open of a data file, while using file-dialog button, the | ||
| 419 | # GUI has been updated | ||
| 420 | # Assume we are still dealing with the current flow item selected | ||
| 421 | # Update the value of the Entry widget (in GUI) with the selected file name | ||
| 422 | # Also update the parameter_widgets with the updated value | ||
| 423 | |||
| 424 | my $current_index = $file_dialog->get_current_index(); | ||
| 425 | my $selected_Entry_widget = $file_dialog->get_selected_Entry_widget(); | ||
| 426 | @{ $param_widgets->{_values_aref} }[$current_index] = | ||
| 427 | $file_dialog->get_selected_file_name(); | ||
| 428 | @{ $color_flow_href->{_values_aref} }[$current_index] = | ||
| 429 | $file_dialog->get_selected_file_name(); | ||
| 430 | |||
| 431 | $param_widgets->redisplay_values(); | ||
| 432 | |||
| 433 | # Make sure to place focus again on the updated widget so other modules can find the selection | ||
| 434 | |||
| 435 | $selected_Entry_widget->focus; # from above | ||
| 436 | |||
| 437 | #print("13 color_flow, _FileDialog_button,color_flow selected_file_name: @{ $param_widgets->{_values_aref} }[$current_index]\n"); | ||
| 438 | #print("13 color_flow, _FileDialog_button,color_flow values: @{ $color_flow_href->{_values_aref} }\n"); | ||
| 439 | # print("9. color_flow, _FileDialog_button, last_flow_color:$color_flow_href->{_last_flow_color}\n"); | ||
| 440 | # print("1. color_flow, _FileDialog_button, last_flow_index_touched $color_flow_href->{_last_flow_index_touched}\n"); | ||
| 441 | |||
| 442 | # set up this flow listbox item as the last item touched | ||
| 443 | # user-built_flow in current use | ||
| 444 | my $_flow_listbox_color_w = _get_flow_listbox_color_w(); | ||
| 445 | my $current_flow_listbox_index = | ||
| 446 | $flow_widgets->get_flow_selection($_flow_listbox_color_w); | ||
| 447 | |||
| 448 | # print("2. color_flow, _FileDialog_button, last_flow_index_touched $color_flow_href->{_last_flow_index_touched}\n"); | ||
| 449 | # print("10. color_flow, _FileDialog_button, last_flow_color:$color_flow_href->{_last_flow_color}\n"); | ||
| 450 | # Changes made with another instance of param_widgets (in file_dialog) will require | ||
| 451 | # that we update the namespace of the current param_flow | ||
| 452 | # We make this change inside _save_most_recent_param_flow | ||
| 453 | _save_most_recent_param_flow(); | ||
| 454 | |||
| 455 | } | ||
| 456 | else { | ||
| 457 | print("color_flow,_FileDialog_button (binding),option type missing "); | ||
| 458 | } | ||
| 459 | return (); | ||
| 460 | } | ||
| 461 | |||
| 462 | =head2 sub _clear_items_version_aref | ||
| 463 | |||
| 464 | clear items_versions_aref | ||
| 465 | used when last item is removed from the listbox | ||
| 466 | |||
| 467 | =cut | ||
| 468 | |||
| 469 | sub _clear_items_version_aref { | ||
| 470 | |||
| 471 | my ($self) = @_; | ||
| 472 | |||
| 473 | if ($color_flow_href) { | ||
| 474 | |||
| 475 | $color_flow_href->{_items_versions_aref} = ''; | ||
| 476 | return (); | ||
| 477 | |||
| 478 | } | ||
| 479 | else { | ||
| 480 | print("color_flow, _clear_items_version_aref, missing color_flow \n"); | ||
| 481 | return (); | ||
| 482 | } | ||
| 483 | |||
| 484 | } | ||
| 485 | |||
| 486 | =head2 sub _clear_stack_versions | ||
| 487 | |||
| 488 | clear items_versions_aref | ||
| 489 | when last flow item is deleted | ||
| 490 | in the listbox | ||
| 491 | |||
| 492 | =cut | ||
| 493 | |||
| 494 | sub _clear_stack_versions { | ||
| 495 | |||
| 496 | my $_flow_listbox_color_w = _get_flow_listbox_color_w(); | ||
| 497 | |||
| 498 | $flow_widgets->clear_flow_item($_flow_listbox_color_w); | ||
| 499 | $flow_widgets->clear_items_versions_aref(); | ||
| 500 | |||
| 501 | # with hash value = '' | ||
| 502 | _clear_items_version_aref(); | ||
| 503 | |||
| 504 | $param_flow_color_pkg->clear_flow_items_version_aref(); | ||
| 505 | |||
| 506 | } | ||
| 507 | |||
| 508 | =head2 sub _flow_select_director | ||
| 509 | |||
| 510 | Private alias for flow_select | ||
| 511 | both color and button are set as | ||
| 512 | per the flow_select called by an active click | ||
| 513 | from Main, in_L_SU_flow_bindings | ||
| 514 | |||
| 515 | =cut | ||
| 516 | |||
| 517 | sub _flow_select_director { | ||
| 518 | |||
| 519 | my ($type) = @_; | ||
| 520 | |||
| 521 | if ( defined $type ) { | ||
| 522 | $gui_history->set_flow_select_color($this_color); | ||
| 523 | |||
| 524 | if ( | ||
| 525 | $type eq '_add2flow' # when perl flow is read | ||
| 526 | or $type eq '_perl_flow' | ||
| 527 | or $type eq 'delete_from_flow_button' | ||
| 528 | or $type eq 'delete_whole_flow_button' | ||
| 529 | or $type eq 'flow_item_down_arrow_button' | ||
| 530 | or $type eq 'flow_item_up_arrow_button' | ||
| 531 | ) | ||
| 532 | { | ||
| 533 | # update most recent flow | ||
| 534 | # print( | ||
| 535 | #" 3. color_flow,_flow_select_director,END OF LOADING INTO GUI for type=$type\n" | ||
| 536 | # ); | ||
| 537 | # print( | ||
| 538 | #" 3. color_flow,_flow_select_director,color_flow_href->{_values_aref}=@{$color_flow_href->{_values_aref}}\n" | ||
| 539 | # ); | ||
| 540 | |||
| 541 | _flow_select2save_most_recent_param_flow(); | ||
| 542 | |||
| 543 | # print(" 3. color_flow,_flow_select_director, widget values=@{$param_widgets->get_values_aref()} \n"); | ||
| 544 | |||
| 545 | if ( $type eq '_add2flow' ) { | ||
| 546 | |||
| 547 | # CASE of opening a perl flow | ||
| 548 | # the last set of param_widgets opened | ||
| 549 | @save_last_param_widget_values = | ||
| 550 | @{ $param_widgets->get_values_aref() }; | ||
| 551 | $save_last_param_widget_value = $save_last_param_widget_values[-1]; | ||
| 552 | $save_last_param_widget_index = $#save_last_param_widget_values; | ||
| 553 | |||
| 554 | } | ||
| 555 | |||
| 556 | # flow loading and display is complete | ||
| 557 | # print("1. color_flow, _flow_select_director, print out gui_history\n"); | ||
| 558 | # $gui_history->view(); | ||
| 559 | |||
| 560 | } | ||
| 561 | elsif ( $type eq 'add2flow_button' ) { | ||
| 562 | |||
| 563 | _flow_select2save_most_recent_param_flow(); | ||
| 564 | |||
| 565 | # update prior flow | ||
| 566 | # flow_select(); | ||
| 567 | |||
| 568 | } | ||
| 569 | else { | ||
| 570 | print("color_flow,_flow_select_director, unexpected\n"); | ||
| 571 | } | ||
| 572 | return (); | ||
| 573 | |||
| 574 | } | ||
| 575 | } | ||
| 576 | |||
| 577 | =head2 sub flow_select2save_most_recent_param_flow | ||
| 578 | |||
| 579 | Select a program from the flow | ||
| 580 | Apply when add2flow_button is directly selected by the user | ||
| 581 | |||
| 582 | Archive the index | ||
| 583 | Update any changed parameter flows | ||
| 584 | Consider prior flow-color changes | ||
| 585 | Correct unticked strings from GUI a | ||
| 586 | Use _updateNsave_most_recent_param_flow(); | ||
| 587 | |||
| 588 | # print("color_flow, flow_select2save_most_recent_param_flow, view stored flow parameters BEFORE update\n"); | ||
| 589 | # $param_flow_color_pkg->view_data(); | ||
| 590 | # print("color_flow, flow_select2save_most_recent_param_flow, view stored flow parameters AFTER update\n"); | ||
| 591 | # $param_flow_color_pkg->view_data(); | ||
| 592 | |||
| 593 | # print("3. color_flow, flow_select2save_most_recent_param_flow: writing gui_history.txt\n"); | ||
| 594 | # $gui_history->view( | ||
| 595 | |||
| 596 | # print("10 flow_select2save_most_recent_param_flow,check_buttons_settings_aref: @{color_flow_href->{_check_buttons_settings_aref}}\n"); | ||
| 597 | |||
| 598 | |||
| 599 | =cut | ||
| 600 | |||
| 601 | sub flow_select2save_most_recent_param_flow { | ||
| 602 | my ($self) = @_; | ||
| 603 | |||
| 604 | $color_flow_href->{_flow_type} = $flow_type->{_user_built}; | ||
| 605 | |||
| 606 | _local_set_flow_listbox_color_w($flow_color); | ||
| 607 | |||
| 608 | my $message = $message_director->null_button(0); | ||
| 609 | $message_w->delete( "1.0", 'end' ); | ||
| 610 | $message_w->insert( 'end', $message ); | ||
| 611 | |||
| 612 | $gui_history->set_hash_ref($color_flow_href); | ||
| 613 | $gui_history->set_defaults_4start_of_flow_select($flow_color); | ||
| 614 | $color_flow_href = $gui_history->get_hash_ref(); | ||
| 615 | |||
| 616 | # update the flow color as per add2flow_select2save_most_recent_param_flow | ||
| 617 | my $_flow_listbox_color_w = _get_flow_listbox_color_w(); | ||
| 618 | |||
| 619 | $color_flow_href->{_prog_name_sref} = | ||
| 620 | $flow_widgets->get_current_program( \$_flow_listbox_color_w ); | ||
| 621 | |||
| 622 | $decisions->set_hash_ref($color_flow_href); | ||
| 623 | |||
| 624 | my $pre_req_ok = $decisions->get4flow_select(); | ||
| 625 | |||
| 626 | if ($pre_req_ok) { | ||
| 627 | |||
| 628 | my $binding = binding->new(); | ||
| 629 | my $here; | ||
| 630 | |||
| 631 | # consider previous flow-color changes | ||
| 632 | # unticked strings from GUI are corrected within | ||
| 633 | _updateNsave_most_recent_param_flow(); | ||
| 634 | |||
| 635 | # For just-selected program name | ||
| 636 | # Retrieve flow parameters from storage | ||
| 637 | # Redisplay the widgets with parameters | ||
| 638 | |||
| 639 | # Update the flow item index to the program that is currently being used, instead | ||
| 640 | # of prior program | ||
| 641 | # Warning: Flow selection gets reset if user double-clicks on a parameter value | ||
| 642 | # in another window | ||
| 643 | $gui_history->set_button('flow_select'); | ||
| 644 | my $index = $flow_widgets->get_flow_selection($_flow_listbox_color_w); | ||
| 645 | # print("635 color_flow, flow_select2save_most_recent_param_flow index=$index \n"); | ||
| 646 | |||
| 647 | # MOST COMMON CASE | ||
| 648 | if ( defined($index) | ||
| 649 | and $index >= 0 ) | ||
| 650 | { | ||
| 651 | |||
| 652 | $param_flow_color_pkg->set_flow_index($index); | ||
| 653 | $color_flow_href->{_names_aref} = | ||
| 654 | $param_flow_color_pkg->get_names_aref(); | ||
| 655 | $color_flow_href->{_values_aref} = | ||
| 656 | $param_flow_color_pkg->get_values_aref(); | ||
| 657 | |||
| 658 | $color_flow_href->{_check_buttons_settings_aref} = | ||
| 659 | $param_flow_color_pkg->get_check_buttons_settings(); | ||
| 660 | |||
| 661 | # get stored first index and num of items | ||
| 662 | $color_flow_href->{_param_flow_first_idx} = | ||
| 663 | $param_flow_color_pkg->first_idx(); | ||
| 664 | $color_flow_href->{_param_flow_length} = | ||
| 665 | $param_flow_color_pkg->length(); | ||
| 666 | |||
| 667 | $param_widgets->set_current_program( | ||
| 668 | $color_flow_href->{_prog_name_sref} ); | ||
| 669 | |||
| 670 | # widgets were initialized in super class | ||
| 671 | $param_widgets->set_labels_w_aref( | ||
| 672 | $color_flow_href->{_labels_w_aref} ); | ||
| 673 | $param_widgets->set_values_w_aref( | ||
| 674 | $color_flow_href->{_values_w_aref} ); | ||
| 675 | $param_widgets->set_check_buttons_w_aref( | ||
| 676 | $color_flow_href->{_check_buttons_w_aref} ); | ||
| 677 | |||
| 678 | $color_flow_href->{_prog_name_sref} = | ||
| 679 | $flow_widgets->get_current_program( \$_flow_listbox_color_w ); | ||
| 680 | |||
| 681 | $param_widgets->range($color_flow_href); | ||
| 682 | |||
| 683 | # strange memory leak inside param_widgets | ||
| 684 | my $save1 = | ||
| 685 | clone( $color_flow_href->{_check_buttons_settings_aref} ); | ||
| 686 | $param_widgets->gui_full_clear(); | ||
| 687 | @{ $color_flow_href->{_check_buttons_settings_aref} } = @$save1; | ||
| 688 | |||
| 689 | $param_widgets->set_labels( $color_flow_href->{_names_aref} ); | ||
| 690 | |||
| 691 | $param_widgets->set_check_buttons( | ||
| 692 | $color_flow_href->{_check_buttons_settings_aref} ); | ||
| 693 | |||
| 694 | $param_widgets->redisplay_labels(); | ||
| 695 | $param_widgets->redisplay_values(); | ||
| 696 | $param_widgets->redisplay_check_buttons(); | ||
| 697 | $param_widgets->set_entry_change_status($false); | ||
| 698 | |||
| 699 | # Unpectedly Entry focus is delayed until the end of this method before | ||
| 700 | # completion; | ||
| 701 | # that is we get to gui_history->view before we can update the focus | ||
| 702 | # mysterious!!!!! | ||
| 703 | $param_widgets->set_focus_on_Entry_w(0); # put focus on first entry widget, index=0 | ||
| 704 | |||
| 705 | # Rebind the different buttons depending on the | ||
| 706 | # program name that is selected (i.e., through spec.pm) | ||
| 707 | $binding->set_prog_name_sref( $color_flow_href->{_prog_name_sref} ); | ||
| 708 | $binding->set_values_w_aref( $param_widgets->get_values_w_aref ); | ||
| 709 | |||
| 710 | # reference to local subroutine that will be run when MB3 is pressed | ||
| 711 | $binding->setFileDialog_button_sub_ref( \&_FileDialog_button ); | ||
| 712 | $binding->set(); | ||
| 713 | |||
| 714 | $gui_history->set_hash_ref($color_flow_href); | ||
| 715 | $gui_history->set4end_of_flow_select($flow_color); | ||
| 716 | $gui_history->set_flow_index_last_touched($index); | ||
| 717 | $color_flow_href = $gui_history->get_hash_ref(); | ||
| 718 | |||
| 719 | # Use currently selected program name from the flow list | ||
| 720 | # e.g. data_in, suximage, suxgraph etc. to update the | ||
| 721 | # entry button value displaying the currently active | ||
| 722 | # flow or superflow name | ||
| 723 | ( $color_flow_href->{_flowNsuperflow_name_w} ) | ||
| 724 | ->configure( -text => ${ $color_flow_href->{_prog_name_sref} } ); | ||
| 725 | |||
| 726 | # For possible export via get_hash_ref to help | ||
| 727 | my $prog_name_sref = $color_flow_href->{_prog_name_sref}; | ||
| 728 | |||
| 729 | } | ||
| 730 | # LESS COMMON CASE | ||
| 731 | # index is defined but negative | ||
| 732 | elsif ( defined $index ) { | ||
| 733 | print("736 color_flow,flow_select2save_most_recent_param_flow, NADA probably deleted last of flow\n"); | ||
| 734 | } | ||
| 735 | # LESS COMMON CASE | ||
| 736 | # undefined but needed index | ||
| 737 | else { | ||
| 738 | |||
| 739 | # print("729 color_flow,flow_select2save_most_recent_param_flow, no index, - NADA\n"); | ||
| 740 | } | ||
| 741 | |||
| 742 | } # end pre_ok | ||
| 743 | # print("733. color_flow,flow_select2save_most_recent_param_flow, end\n"); | ||
| 744 | return (); | ||
| 745 | } # end sub | ||
| 746 | |||
| 747 | =head2 sub _flow_select2save_most_recent_param_flow | ||
| 748 | |||
| 749 | select a program from the flow | ||
| 750 | archive the index | ||
| 751 | and update any changed parameter flows | ||
| 752 | |||
| 753 | =cut | ||
| 754 | |||
| 755 | sub _flow_select2save_most_recent_param_flow { | ||
| 756 | my ($self) = @_; | ||
| 757 | |||
| 758 | $color_flow_href->{_flow_type} = $flow_type->{_user_built}; | ||
| 759 | |||
| 760 | # print("1. color_flow,_flow_select2save_most_recent_param_flow, last_flow_index_touched:$color_flow_href->{_last_flow_index_touched}\n"); | ||
| 761 | # print("color_flow,_flow_select2save_most_recent_param_flow, last_flow_color:$color_flow_href->{_last_flow_color}\n"); | ||
| 762 | |||
| 763 | # reset residual flow_listbox_color_w of another color | ||
| 764 | # flow_color exists in current (color_flow) namespace | ||
| 765 | _local_set_flow_listbox_color_w($flow_color); | ||
| 766 | $gui_history->set_flow_select_color($flow_color); | ||
| 767 | |||
| 768 | # print("1. color_flow, _flow_select2save_most_recent_param_flow, show stored flow parameters\n"); | ||
| 769 | # $param_flow_color_pkg->view_data(); | ||
| 770 | |||
| 771 | my $message = $message_director->null_button(0); | ||
| 772 | $message_w->delete( "1.0", 'end' ); | ||
| 773 | $message_w->insert( 'end', $message ); | ||
| 774 | |||
| 775 | $gui_history->set_hash_ref($color_flow_href); | ||
| 776 | $gui_history->set_defaults_4start_of_flow_select($flow_color); | ||
| 777 | $color_flow_href = $gui_history->get_hash_ref(); | ||
| 778 | |||
| 779 | # update the flow color as per add2_flow_select2save_most_recent_param_flow | ||
| 780 | my $_flow_listbox_color_w = _get_flow_listbox_color_w(); | ||
| 781 | |||
| 782 | $color_flow_href->{_prog_name_sref} = | ||
| 783 | $flow_widgets->get_current_program( \$_flow_listbox_color_w ); | ||
| 784 | |||
| 785 | $decisions->set_hash_ref($color_flow_href); | ||
| 786 | |||
| 787 | # print("3. color_flow, _flow_select2save_most_recent_param_flow: writing gui_history.txt\n"); | ||
| 788 | # $gui_history->view(); | ||
| 789 | |||
| 790 | # print("3. color_flow,_flow_select2save_most_recent_param_flow, last_flow_index_touched:$color_flow_href->{_last_flow_index_touched}\n"); | ||
| 791 | #$param_flow_color_pkg->view_data(); | ||
| 792 | |||
| 793 | my $pre_req_ok = $decisions->get4flow_select(); | ||
| 794 | |||
| 795 | if ($pre_req_ok) { | ||
| 796 | |||
| 797 | my $binding = binding->new(); | ||
| 798 | my $here; | ||
| 799 | |||
| 800 | $gui_history->set_button('flow_select'); | ||
| 801 | |||
| 802 | # consider prior flow-color changes | ||
| 803 | # unticked strings from GUI are corrected here | ||
| 804 | |||
| 805 | # print(" 8, color_flow, before _updatenNsave_most_recent_param_flow\n"); | ||
| 806 | |||
| 807 | # $param_flow_color_pkg->view_data(); | ||
| 808 | # print( | ||
| 809 | #"8B. color_flow, _flow_select2save_most_recent_param_flow, values@{$color_flow_href->{_values_aref}}\n" | ||
| 810 | # ); | ||
| 811 | |||
| 812 | _updateNsave_most_recent_param_flow(); | ||
| 813 | |||
| 814 | # print("after 117 _updateNsave_most_recent_param_flow\n"); | ||
| 815 | # print( | ||
| 816 | # "after 118 _color_flow, _flow_select2save_most_recent_param_flow, values@{$color_flow_href->{_values_aref}}\n" | ||
| 817 | # ); | ||
| 818 | |||
| 819 | # for just-selected program name | ||
| 820 | # get its flow parameters from storage | ||
| 821 | # and redisplay the widgets with parameters | ||
| 822 | |||
| 823 | # Update the flow item index to the program that is currently being used, instead | ||
| 824 | # of prior program | ||
| 825 | # Warning: Flow selection gets reset if user double-clicks on a parameter value | ||
| 826 | # in another window | ||
| 827 | my $index = $flow_widgets->get_flow_selection($_flow_listbox_color_w); | ||
| 828 | |||
| 829 | $param_flow_color_pkg->set_flow_index($index); | ||
| 830 | $color_flow_href->{_names_aref} = | ||
| 831 | $param_flow_color_pkg->get_names_aref(); | ||
| 832 | |||
| 833 | # print("9 _flow_select2save_most_recent_param_flow,index=$index\n"); | ||
| 834 | # $param_flow_color_pkg->view_data(); | ||
| 835 | # print("9B. color_flow, _flow_select2save_most_recent_param_flow, values@{$color_flow_href->{_values_aref}}\n"); | ||
| 836 | |||
| 837 | $color_flow_href->{_values_aref} = | ||
| 838 | $param_flow_color_pkg->get_values_aref(); | ||
| 839 | $color_flow_href->{_check_buttons_settings_aref} = | ||
| 840 | $param_flow_color_pkg->get_check_buttons_settings(); | ||
| 841 | |||
| 842 | # print("10 _flow_select2save_most_recent_param_flow,index=$index\n"); | ||
| 843 | # $param_flow_color_pkg->view_data(); | ||
| 844 | |||
| 845 | # print("10 _flow_select2save_most_recent_param_flow,check_buttons_settings_aref: @{color_flow_href->{_check_buttons_settings_aref}}\n"); | ||
| 846 | # get stored first index and num of items | ||
| 847 | $color_flow_href->{_param_flow_first_idx} = | ||
| 848 | $param_flow_color_pkg->first_idx(); | ||
| 849 | $color_flow_href->{_param_flow_length} = | ||
| 850 | $param_flow_color_pkg->length(); | ||
| 851 | |||
| 852 | $param_widgets->set_current_program( | ||
| 853 | $color_flow_href->{_prog_name_sref} ); | ||
| 854 | |||
| 855 | # print("4. color_flow, _flow_select2save_most_recent_param_flow: writing gui_history.txt\n"); | ||
| 856 | # $gui_history->view(); | ||
| 857 | |||
| 858 | # widgets were initialized in super class | ||
| 859 | $param_widgets->set_labels_w_aref( $color_flow_href->{_labels_w_aref} ); | ||
| 860 | $param_widgets->set_values_w_aref( $color_flow_href->{_values_w_aref} ); | ||
| 861 | $param_widgets->set_check_buttons_w_aref( | ||
| 862 | $color_flow_href->{_check_buttons_w_aref} ); | ||
| 863 | |||
| 864 | $color_flow_href->{_prog_name_sref} = | ||
| 865 | $flow_widgets->get_current_program( \$_flow_listbox_color_w ); | ||
| 866 | |||
| 867 | # wipes out values labels and checkbuttons from the gui | ||
| 868 | |||
| 869 | $param_widgets->range($color_flow_href); | ||
| 870 | |||
| 871 | # print( | ||
| 872 | #"119 color_flow, END _flow_select2save_most_recent_param_flow,color_flow_href->{_values_aref} =@{$color_flow_href->{_values_aref}}\n" | ||
| 873 | # ); | ||
| 874 | |||
| 875 | # strange memory leak inside param_widgets | ||
| 876 | # my @save1 = clone( @{$color_flow_href->{_check_buttons_settings_aref}} ); | ||
| 877 | # $color_flow_href->{_check_buttons_settings_aref} = \@save1; | ||
| 878 | # my @save2 = clone( @{$color_flow_href->{_values_aref}} ); | ||
| 879 | # $color_flow_href->{_values_aref} = \@save2; | ||
| 880 | # my @save3 = clone( @{$color_flow_href->{_names_aref}} ); | ||
| 881 | # $color_flow_href->{_names_aref} = \@save3; | ||
| 882 | # print("120 color_flow, END _flow_select2save_most_recent_param_flow,color_flow_href->{_values_aref} =@{$color_flow_href->{_values_aref}}\n"); | ||
| 883 | # | ||
| 884 | $param_widgets->gui_full_clear(); | ||
| 885 | $param_widgets->set_labels( $color_flow_href->{_names_aref} ); | ||
| 886 | $param_widgets->set_values( $color_flow_href->{_values_aref} ); | ||
| 887 | $param_widgets->set_check_buttons( | ||
| 888 | $color_flow_href->{_check_buttons_settings_aref} ); | ||
| 889 | |||
| 890 | # print( | ||
| 891 | #"121 color_flow, END _flow_select2save_most_recent_param_flow,color_flow_href->{_values_aref} =@{$color_flow_href->{_values_aref}}\n" | ||
| 892 | # ); | ||
| 893 | |||
| 894 | $param_widgets->redisplay_labels(); | ||
| 895 | $param_widgets->redisplay_values(); | ||
| 896 | $param_widgets->redisplay_check_buttons(); | ||
| 897 | $param_widgets->set_entry_change_status($false); | ||
| 898 | |||
| 899 | # mysterious!!!!! | ||
| 900 | # We need to get gui_istory->view before we can update the focus | ||
| 901 | # Unxpectedly, Entry focus is delayed until the end of this method before | ||
| 902 | # completion; | ||
| 903 | # put focus on first entry widget, index=0 | ||
| 904 | $param_widgets->set_focus_on_Entry_w(0); | ||
| 905 | |||
| 906 | # print( | ||
| 907 | #"122 color_flow, END _flow_select2save_most_recent_param_flow,color_flow_href->{_values_aref} =@{$color_flow_href->{_values_aref}}\n" | ||
| 908 | # ); | ||
| 909 | |||
| 910 | # $color_flow_href->{_last_parameter_index_touched_color} = 0; | ||
| 911 | # the changed parameter value in the Entry widget should force an update of stored values | ||
| 912 | # in the current flow item (not the last flow item touched) | ||
| 913 | # _save_most_recent_param_flow(); # is only active if | ||
| 914 | # $color_flow_href->{_last_parameter_index_touched_color} >= 0 | ||
| 915 | # Here is where you rebind the different buttons depending on the | ||
| 916 | # program name that is selected (i.e., through *_spec.pm) | ||
| 917 | $binding->set_prog_name_sref( $color_flow_href->{_prog_name_sref} ); | ||
| 918 | $binding->set_values_w_aref( $param_widgets->get_values_w_aref ); | ||
| 919 | |||
| 920 | # reference to local subroutine that will be run when MB3 is pressed | ||
| 921 | $binding->setFileDialog_button_sub_ref( \&_FileDialog_button ); | ||
| 922 | $binding->set(); | ||
| 923 | |||
| 924 | $gui_history->set_hash_ref($color_flow_href); | ||
| 925 | $gui_history->set4end_of_flow_select($flow_color); | ||
| 926 | $gui_history->set_flow_index_last_touched($index); | ||
| 927 | $color_flow_href = $gui_history->get_hash_ref(); | ||
| 928 | |||
| 929 | # Update the entry button value that displays the currently active | ||
| 930 | # flow or superflow name, by using the currently selected program name from the flow list | ||
| 931 | # e.g. data_in, suximage, suxgraph etc. | ||
| 932 | ( $color_flow_href->{_flowNsuperflow_name_w} ) | ||
| 933 | ->configure( -text => ${ $color_flow_href->{_prog_name_sref} } ); | ||
| 934 | |||
| 935 | # needed in possible export via get_hash_ref to help | ||
| 936 | my $prog_name_sref = $color_flow_href->{_prog_name_sref}; | ||
| 937 | |||
| 938 | # will not reflect the Entry focus change | ||
| 939 | # print("color_flow_href _flow_select2save_most_recent_param_flow, log view is on\n"); | ||
| 940 | # $gui_history->view(); | ||
| 941 | # print("11, color_flow, END of _flow_select2save_most_recent_param_flow \n"); | ||
| 942 | # $param_flow_color_pkg->view_data(); | ||
| 943 | # print("14.color_flow,_flow_select2save_most_recent_param_flow,widget values =@{$param_widgets->get_values_aref()} \n"); | ||
| 944 | |||
| 945 | } # end pre_ok | ||
| 946 | |||
| 947 | return (); | ||
| 948 | } | ||
| 949 | |||
| 950 | =head2 sub _get_flow_color | ||
| 951 | |||
| 952 | get a private hash value | ||
| 953 | |||
| 954 | =cut | ||
| 955 | |||
| 956 | sub _get_flow_color { | ||
| 957 | my ($self) = @_; | ||
| 958 | |||
| 959 | if ( $color_flow_href->{_flow_color} ) { | ||
| 960 | my $color; | ||
| 961 | |||
| 962 | $color = $color_flow_href->{_flow_color}; | ||
| 963 | return ($color); | ||
| 964 | |||
| 965 | } | ||
| 966 | else { | ||
| 967 | print("color_flow, missing flow color\n"); | ||
| 968 | } | ||
| 969 | |||
| 970 | } | ||
| 971 | |||
| 972 | =head2 sub _get_flow_listbox_color_w | ||
| 973 | |||
| 974 | |||
| 975 | =cut | ||
| 976 | |||
| 977 | sub _get_flow_listbox_color_w { | ||
| 978 | my ($self) = @_; | ||
| 979 | my $this_flow_listbox_color_w; | ||
| 980 | |||
| 981 | if ( defined $this_color | ||
| 982 | and $this_color ne $empty_string ) | ||
| 983 | { | ||
| 984 | my $flow_color = $this_color; | ||
| 985 | |||
| 986 | # print("color_flow, color=$flow_color; this_color=$this_color\n"); | ||
| 987 | |||
| 988 | $this_flow_listbox_color_w = $color_flow_href->{$_flow_listbox_color_w}; | ||
| 989 | |||
| 990 | } | ||
| 991 | else { | ||
| 992 | print("color_flow, _get_flow_listbox_color_w, missing color\n"); | ||
| 993 | } | ||
| 994 | |||
| 995 | return ($this_flow_listbox_color_w); | ||
| 996 | |||
| 997 | } | ||
| 998 | |||
| 999 | =head2 sub _move_in_stored_flows | ||
| 1000 | |||
| 1001 | move program names, | ||
| 1002 | parameter names, values and checkbutton setttings | ||
| 1003 | --- these are stored separately (via param_flows.pm) | ||
| 1004 | from GUI widgets (via flow_widgets.pm) | ||
| 1005 | The flow-widgets is a single copy of names and values | ||
| 1006 | that constantly changes as the uses interacts with the GUI | ||
| 1007 | The param-flows stores several program (items) and their | ||
| 1008 | names and values | ||
| 1009 | |||
| 1010 | =cut | ||
| 1011 | |||
| 1012 | sub _move_in_stored_flows { | ||
| 1013 | my ($self) = @_; | ||
| 1014 | |||
| 1015 | $color_flow_href->{_index2move} = $flow_widgets->index2move(); | ||
| 1016 | $color_flow_href->{_destination_index} = $flow_widgets->destination_index(); | ||
| 1017 | |||
| 1018 | my $start = $color_flow_href->{_index2move}; | ||
| 1019 | my $end = $color_flow_href->{_destination_index}; | ||
| 1020 | print("color_flow move_in_stored_flows,start index is the $start\n"); | ||
| 1021 | print("color_flow move_in_stored_flows, insertion index is $end \n"); | ||
| 1022 | |||
| 1023 | $param_flow_color_pkg->set_insert_start($start); | ||
| 1024 | $param_flow_color_pkg->set_insert_end($end); | ||
| 1025 | $param_flow_color_pkg->insert_selection(); | ||
| 1026 | |||
| 1027 | return (); | ||
| 1028 | } | ||
| 1029 | |||
| 1030 | =head2 sub _SaveAs_button | ||
| 1031 | |||
| 1032 | topic: only for 'SaveAs' | ||
| 1033 | for safety, place set_hash_ref first | ||
| 1034 | |||
| 1035 | CASE #1 considered: | ||
| 1036 | Flow_selection is forced during _add2flow | ||
| 1037 | |||
| 1038 | CASE #2 | ||
| 1039 | if the previous items have not been directly selected with sub flow_select | ||
| 1040 | they will not have been updated since loading into the GUI | ||
| 1041 | if user made changes to the paramters but the flow was not selected | ||
| 1042 | via flow_select (directly by the user) the flow parameters are not correct | ||
| 1043 | |||
| 1044 | =cut | ||
| 1045 | |||
| 1046 | sub _SaveAs_button { | ||
| 1047 | my ($topic) = @_; | ||
| 1048 | |||
| 1049 | if ( $topic eq 'SaveAs' ) { | ||
| 1050 | |||
| 1051 | my $files_LSU = files_LSU->new(); | ||
| 1052 | |||
| 1053 | # Start refocus index in flow, in case focus has been removed | ||
| 1054 | # e.g., by double-clicking in parameter values window | ||
| 1055 | my $most_recent_flow_index_touched = | ||
| 1056 | ( $color_flow_href->{_flow_select_index_href} )->{_most_recent}; | ||
| 1057 | my $prior_flow_index_touched = | ||
| 1058 | ( $color_flow_href->{_flow_select_index_href} )->{_prior}; | ||
| 1059 | my $most_recent_flow_color = | ||
| 1060 | ( $color_flow_href->{_flow_select_color_href} )->{_most_recent}; | ||
| 1061 | my $last_flow_index = $most_recent_flow_index_touched; | ||
| 1062 | |||
| 1063 | # print("1 OLD save, last_flow_color is: $color_flow_href->{_last_flow_color} \n"); | ||
| 1064 | # print("1 OLD save, last_flow_index is: $color_flow_href->{_last_flow_index} \n"); | ||
| 1065 | |||
| 1066 | # print("1 save_button, most_recent_flow_index is: $most_recent_flow_index_touched\n"); | ||
| 1067 | # print("1 save_button, pior_flow_index is: $prior_flow_index_touched\n"); | ||
| 1068 | |||
| 1069 | # print("1 color_flow, _SaveAs_button, new save, last_flow_color is: $most_recent_flow_color \n"); | ||
| 1070 | |||
| 1071 | # print("_SaveAs_button, view stored data in param flow3\n"); | ||
| 1072 | # $param_flow_color_pkg->view_data(); | ||
| 1073 | |||
| 1074 | $gui_history->set_hash_ref($color_flow_href); | ||
| 1075 | $gui_history->set4_start_of_SaveAs_button(); | ||
| 1076 | |||
| 1077 | my $num_items = $param_flow_color_pkg->get_num_items(); | ||
| 1078 | |||
| 1079 | $color_flow_href->{_names_aref} = | ||
| 1080 | $param_flow_color_pkg->get_names_aref(); | ||
| 1081 | |||
| 1082 | $param_flow_color_pkg->set_good_values(); | ||
| 1083 | $param_flow_color_pkg->set_good_labels(); | ||
| 1084 | |||
| 1085 | # collect information to be saved in a perl flow | ||
| 1086 | $color_flow_href->{_good_labels_aref2} = | ||
| 1087 | $param_flow_color_pkg->get_good_labels_aref2(); | ||
| 1088 | $color_flow_href->{_items_versions_aref} = | ||
| 1089 | $param_flow_color_pkg->get_flow_items_version_aref(); | ||
| 1090 | $color_flow_href->{_good_values_aref2} = | ||
| 1091 | $param_flow_color_pkg->get_good_values_aref2(); | ||
| 1092 | $color_flow_href->{_prog_names_aref} = | ||
| 1093 | $param_flow_color_pkg->get_flow_prog_names_aref(); | ||
| 1094 | |||
| 1095 | my $num_items4flow = scalar @{ $color_flow_href->{_good_labels_aref2} }; | ||
| 1096 | |||
| 1097 | # for (my $i=0; $i < $num_items4flow; $i++ ) { | ||
| 1098 | # @{@{$color_flow_href->{_good_labels_aref2}}[$i]}\n"); | ||
| 1099 | # } | ||
| 1100 | |||
| 1101 | # for (my $i=0; $i < $num_items4flow; $i++ ) { | ||
| 1102 | # print("color_flow,_SaveAs_button, _good_values_aref2, | ||
| 1103 | # @{@{$color_flow_href->{_good_values_aref2}}[$i]}\n"); | ||
| 1104 | # } | ||
| 1105 | # print("color_flow,_prog_versions_aref, | ||
| 1106 | # @{$color_flow_href->{_items_versions_aref}}\n"); | ||
| 1107 | |||
| 1108 | $files_LSU->set_prog_param_labels_aref2($color_flow_href); | ||
| 1109 | $files_LSU->set_prog_param_values_aref2($color_flow_href); | ||
| 1110 | $files_LSU->set_prog_names_aref($color_flow_href); | ||
| 1111 | $files_LSU->set_items_versions_aref($color_flow_href); | ||
| 1112 | $files_LSU->set_data(); | ||
| 1113 | $files_LSU->set_message($color_flow_href); | ||
| 1114 | |||
| 1115 | # listbox color assignment | ||
| 1116 | $files_LSU->set_flow_color($this_color); | ||
| 1117 | |||
| 1118 | # update PL_SEISMIC in case user has recently changed project area | ||
| 1119 | $files_LSU->set_PL_SEISMIC(); | ||
| 1120 | |||
| 1121 | # flows saved to PL_SEISMIC | ||
| 1122 | $files_LSU->set2pl($color_flow_href); | ||
| 1123 | $files_LSU->save(); | ||
| 1124 | |||
| 1125 | $gui_history->set4_end_of_SaveAs_button(); # sets: _has_used_SaveAs=true | ||
| 1126 | $color_flow_href = $gui_history->get_hash_ref(); | ||
| 1127 | |||
| 1128 | return (); | ||
| 1129 | |||
| 1130 | } | ||
| 1131 | else { | ||
| 1132 | print("color_flow,_SaveAs_button, missing topic\n"); | ||
| 1133 | } | ||
| 1134 | } | ||
| 1135 | |||
| 1136 | =head2 sub _perl_flow_errors | ||
| 1137 | Based on _perl_flow | ||
| 1138 | Parse (while reading) perl flows | ||
| 1139 | |||
| 1140 | =cut | ||
| 1141 | |||
| 1142 | sub _perl_flow_errors { | ||
| 1143 | |||
| 1144 | my ($self) = @_; | ||
| 1145 | |||
| 1146 | my $result; | ||
| 1147 | |||
| 1148 | # instantiate modules | ||
| 1149 | my $perl_flow = perl_flow->new(); | ||
| 1150 | my $param_sunix = param_sunix->new(); | ||
| 1151 | |||
| 1152 | # messages | ||
| 1153 | my $message = $message_director->null_button(0); | ||
| 1154 | $message_w->delete( "1.0", 'end' ); | ||
| 1155 | $message_w->insert( 'end', $message ); | ||
| 1156 | |||
| 1157 | # should be at start of color_flow | ||
| 1158 | $color_flow_href->{_flow_type} = $flow_type->{_user_built}; | ||
| 1159 | my $flow_name_in_color = $color_flow_href->{$_flow_name_in_color}; | ||
| 1160 | |||
| 1161 | my $flow_color = $color_flow_href->{_flow_color}; | ||
| 1162 | |||
| 1163 | # read in variables from the perl flow file | ||
| 1164 | $perl_flow->set_perl_file_in($flow_name_in_color); | ||
| 1165 | my $is_error = $perl_flow->get_parse_errors(); | ||
| 1166 | |||
| 1167 | $result = $is_error; | ||
| 1168 | |||
| 1169 | return ($result); | ||
| 1170 | } | ||
| 1171 | |||
| 1172 | =head2 sub _perl_flow | ||
| 1173 | Parse (while reading) perl flows | ||
| 1174 | |||
| 1175 | foreach my $key (sort keys %$color_flow_href) { | ||
| 1176 | print (" color_flowkey is $key, value is $color_flow_href->{$key}\n"); | ||
| 1177 | } | ||
| 1178 | my $length = scalar @{$all_values_aref}; | ||
| 1179 | print("color_flow,perl_flow, length = $length\n"); | ||
| 1180 | |||
| 1181 | for (my $j=0; $j <$length; $j++) { | ||
| 1182 | print("color_flow,perl_flow,name & value:@{$all_names_aref}[$j] = @{$all_values_aref}[$j]\n"); | ||
| 1183 | |||
| 1184 | } | ||
| 1185 | |||
| 1186 | =cut | ||
| 1187 | |||
| 1188 | sub _perl_flow { | ||
| 1189 | my ($self) = @_; | ||
| 1190 | |||
| 1191 | # instantiate modules | ||
| 1192 | my $perl_flow = perl_flow->new(); | ||
| 1193 | my $param_sunix = param_sunix->new(); | ||
| 1194 | |||
| 1195 | # messages | ||
| 1196 | my $message = $message_director->null_button(0); | ||
| 1197 | $message_w->delete( "1.0", 'end' ); | ||
| 1198 | $message_w->insert( 'end', $message ); | ||
| 1199 | |||
| 1200 | # should be at start of color_flow | ||
| 1201 | $color_flow_href->{_flow_type} = $flow_type->{_user_built}; | ||
| 1202 | my $flow_name_in_color = $color_flow_href->{$_flow_name_in_color}; | ||
| 1203 | |||
| 1204 | my $flow_color = $color_flow_href->{_flow_color}; | ||
| 1205 | |||
| 1206 | # read in variables from the perl flow file | ||
| 1207 | $perl_flow->set_perl_file_in($flow_name_in_color); | ||
| 1208 | $perl_flow->parse(); | ||
| 1209 | |||
| 1210 | # clear all signs in GUI and wipe all the memory spaces | ||
| 1211 | # associated with the contents in the flow listbox that is about to | ||
| 1212 | # be occupied | ||
| 1213 | _clear_color_flow(); | ||
| 1214 | |||
| 1215 | my $num_prog_names = $perl_flow->get_num_prog_names(); | ||
| 1216 | |||
| 1217 | if ( length $num_prog_names ) { | ||
| 1218 | |||
| 1219 | for ( my $prog_idx = 0 ; $prog_idx < $num_prog_names ; $prog_idx++ ) { | ||
| 1220 | |||
| 1221 | # collect info. from perl file | ||
| 1222 | $perl_flow->set_prog_index($prog_idx); | ||
| 1223 | $color_flow_href->{_prog_name_sref} = | ||
| 1224 | $perl_flow->get_prog_name_sref(); | ||
| 1225 | $color_flow_href->{_names_aref} = $perl_flow->get_all_names_aref(); | ||
| 1226 | $color_flow_href->{_values_aref} = | ||
| 1227 | $perl_flow->get_all_values_aref(); | ||
| 1228 | $color_flow_href->{_check_buttons_settings_aref} = | ||
| 1229 | $perl_flow->get_check_buttons_settings_aref(); | ||
| 1230 | |||
| 1231 | # establish which program is active in the flow 7.10.21 | ||
| 1232 | $control->set_flow_program_name_sref( | ||
| 1233 | $color_flow_href->{_prog_name_sref} ); | ||
| 1234 | $control->set_flow_prog_name_index(0); | ||
| 1235 | |||
| 1236 | # remove quotes upon input | ||
| 1237 | $color_flow_href->{_values_aref} = | ||
| 1238 | $control->get_no_quotes4array( $color_flow_href->{_values_aref} ); | ||
| 1239 | |||
| 1240 | # add single quotes upon input only to strings | ||
| 1241 | $color_flow_href->{_values_aref} = | ||
| 1242 | $control->get_string_or_number4aref( | ||
| 1243 | $color_flow_href->{_values_aref} ); | ||
| 1244 | |||
| 1245 | $perl_flow->set_prog_index($prog_idx); | ||
| 1246 | my $number_of_values = scalar @{ $color_flow_href->{_values_aref} }; | ||
| 1247 | |||
| 1248 | $color_flow_href->{_param_sunix_length} = | ||
| 1249 | $perl_flow->get_param_sunix_length(); | ||
| 1250 | |||
| 1251 | my $values_aref = $color_flow_href->{_values_aref}; | ||
| 1252 | |||
| 1253 | # print("2. color_flow,_perl_flow, values = @$values_aref \n"); | ||
| 1254 | |||
| 1255 | # Populate GUI with the parameter values and labels of the first item | ||
| 1256 | # _add2flow will call _flow_select to select the last flow item loaded | ||
| 1257 | # _flow select marks the gui history and calls | ||
| 1258 | # flow_select which will detect any parameter changes | ||
| 1259 | # and will store | ||
| 1260 | # upload variables into the param_flow for each program | ||
| 1261 | |||
| 1262 | _add2flow(); | ||
| 1263 | } | ||
| 1264 | |||
| 1265 | _flow_select_director('_perl_flow'); | ||
| 1266 | |||
| 1267 | # flow loading and display is complete | ||
| 1268 | # print("1. color_flow, _perl_flow, print out gui_history\n"); | ||
| 1269 | # $gui_history->view(); | ||
| 1270 | |||
| 1271 | return (); | ||
| 1272 | |||
| 1273 | } | ||
| 1274 | else { | ||
| 1275 | print("$this_color flow is missing the number of programs in a flow\n"); | ||
| 1276 | } | ||
| 1277 | |||
| 1278 | } | ||
| 1279 | |||
| 1280 | =head2 sub _set_flow_color | ||
| 1281 | |||
| 1282 | |||
| 1283 | =cut | ||
| 1284 | |||
| 1285 | sub _set_flow_color { | ||
| 1286 | my ($flow_color) = @_; | ||
| 1287 | |||
| 1288 | if ($flow_color) { | ||
| 1289 | |||
| 1290 | $color_flow_href->{_flow_color} = $flow_color; | ||
| 1291 | |||
| 1292 | } | ||
| 1293 | else { | ||
| 1294 | print("color_flow, set_flow_color, missing color\n"); | ||
| 1295 | } | ||
| 1296 | return (); | ||
| 1297 | } | ||
| 1298 | |||
| 1299 | =head2 sub _local_set_flow_listbox_color_w | ||
| 1300 | |||
| 1301 | |||
| 1302 | =cut | ||
| 1303 | |||
| 1304 | sub _local_set_flow_listbox_color_w { | ||
| 1305 | my ($flow_color) = @_; | ||
| 1306 | |||
| 1307 | if ( $flow_color eq $this_color ) { | ||
| 1308 | |||
| 1309 | $color_flow_href->{_flow_listbox_color_w} = | ||
| 1310 | $color_flow_href->{$_flow_listbox_color_w}; | ||
| 1311 | |||
| 1312 | } | ||
| 1313 | else { | ||
| 1314 | print( | ||
| 1315 | "color_flow,_local_set_flow_listbox_color_w, _local_set_flow_listbox_color_w, missing color\n" | ||
| 1316 | ); | ||
| 1317 | } | ||
| 1318 | |||
| 1319 | return (); | ||
| 1320 | } | ||
| 1321 | |||
| 1322 | =head2 sub _set_flow_name_color_w | ||
| 1323 | |||
| 1324 | =cut | ||
| 1325 | |||
| 1326 | sub _set_flow_name_color_w { | ||
| 1327 | my ($flow_color) = @_; | ||
| 1328 | |||
| 1329 | # print( | ||
| 1330 | # "color_flow,_set_flow_name_color_w, flow_color,this_color: $flow_color,$this_color \n" | ||
| 1331 | # ); | ||
| 1332 | if ( $flow_color eq $this_color ) { | ||
| 1333 | |||
| 1334 | $flow_name_color_w = $color_flow_href->{$_flow_name_color_w}; | ||
| 1335 | |||
| 1336 | # do not export | ||
| 1337 | $flow_name_color_w = $color_flow_href->{$_flow_name_color_w}; | ||
| 1338 | |||
| 1339 | } | ||
| 1340 | else { | ||
| 1341 | print( | ||
| 1342 | "color_flow,_set_flow_name_color_w, _set_flow_name_color_w, missing color \n" | ||
| 1343 | ); | ||
| 1344 | } | ||
| 1345 | |||
| 1346 | return (); | ||
| 1347 | } | ||
| 1348 | |||
| 1349 | =head2 sub _set_flowNsuperflow_name_w | ||
| 1350 | |||
| 1351 | displays superflow name at top of gui | ||
| 1352 | |||
| 1353 | =cut | ||
| 1354 | |||
| 1355 | sub _set_flowNsuperflow_name_w { | ||
| 1356 | my ($flowNsuperflow_name) = @_; | ||
| 1357 | |||
| 1358 | if ( $flowNsuperflow_name | ||
| 1359 | && $color_flow_href->{_flowNsuperflow_name_w} ) | ||
| 1360 | { | ||
| 1361 | |||
| 1362 | ( $color_flow_href->{_flowNsuperflow_name_w} ) | ||
| 1363 | ->configure( -text => $flowNsuperflow_name, ); | ||
| 1364 | } | ||
| 1365 | else { | ||
| 1366 | print( | ||
| 1367 | "color_flow, set_flowNsuperflow_name_w, missing widget or program name\n" | ||
| 1368 | ); | ||
| 1369 | } | ||
| 1370 | |||
| 1371 | return (); | ||
| 1372 | } | ||
| 1373 | |||
| 1374 | =head2 sub _set_user_built_flow_name_w | ||
| 1375 | |||
| 1376 | place and show the user-built flow name | ||
| 1377 | |||
| 1378 | =cut | ||
| 1379 | |||
| 1380 | sub _set_user_built_flow_name_w { | ||
| 1381 | my ($user_built_flow_name) = @_; | ||
| 1382 | |||
| 1383 | if ($user_built_flow_name) { | ||
| 1384 | |||
| 1385 | if ($flow_name_color_w) { | ||
| 1386 | |||
| 1387 | # do not export | ||
| 1388 | $flow_name_color_w = $flow_name_color_w; | ||
| 1389 | |||
| 1390 | # display name in widget | ||
| 1391 | $flow_name_color_w->configure( -text => $user_built_flow_name, ); | ||
| 1392 | |||
| 1393 | } | ||
| 1394 | elsif ( not $flow_name_color_w ) { | ||
| 1395 | |||
| 1396 | _set_flow_name_color_w($flow_color); | ||
| 1397 | |||
| 1398 | # do not export | ||
| 1399 | $flow_name_color_w = $flow_name_color_w; | ||
| 1400 | |||
| 1401 | # display name in widget | ||
| 1402 | $flow_name_color_w->configure( -text => $user_built_flow_name, ); | ||
| 1403 | |||
| 1404 | } | ||
| 1405 | else { | ||
| 1406 | print( | ||
| 1407 | "color_flow, set_user_built_flow_name_w, missing flow_name_color_w \n" | ||
| 1408 | ); | ||
| 1409 | } | ||
| 1410 | } | ||
| 1411 | else { | ||
| 1412 | print("color_flow, set_user_built_flow_name_w, missing program name\n"); | ||
| 1413 | } | ||
| 1414 | |||
| 1415 | return (); | ||
| 1416 | } | ||
| 1417 | |||
| 1418 | =head2 sub _stack_flow | ||
| 1419 | |||
| 1420 | store an initial version of the parameters in a | ||
| 1421 | namespace different to the one belonging to param_widgets | ||
| 1422 | |||
| 1423 | The initial version comes from default parameter files | ||
| 1424 | i.e., the same code as for sunix_select | ||
| 1425 | |||
| 1426 | print("color_flow,_stack_flow, color_flow_href->{_values_aref} =@{$color_flow_href->{_values_aref}} \n"); | ||
| 1427 | |||
| 1428 | =cut | ||
| 1429 | |||
| 1430 | sub _stack_flow { | ||
| 1431 | my ($self) = @_; | ||
| 1432 | |||
| 1433 | # my $num_items = $param_flow_color_pkg->get_num_items(); | ||
| 1434 | # print("color_flow,_stack_flow, data before stack num_items=$num_items\n"); | ||
| 1435 | # $param_flow_color_pkg->view_data(); | ||
| 1436 | |||
| 1437 | $param_flow_color_pkg->stack_flow_item( | ||
| 1438 | $color_flow_href->{_prog_name_sref} ); | ||
| 1439 | |||
| 1440 | $param_flow_color_pkg->stack_names_aref2( $color_flow_href->{_names_aref} ); | ||
| 1441 | |||
| 1442 | # print("color_flow,_stack_flow, color_flow_href->{_names_aref} =@{$color_flow_href->{_names_aref}} \n"); | ||
| 1443 | |||
| 1444 | # when used for very first time in a GUI the index can be < 0 | ||
| 1445 | # control->set_flow_prog_name_index takes care of this situation | ||
| 1446 | my $most_recent_flow_index_touched = | ||
| 1447 | ( $color_flow_href->{_flow_select_index_href} )->{_most_recent}; | ||
| 1448 | |||
| 1449 | # print("color_flow,_stack_flow, most_recent_flow_index_touched = $most_recent_flow_index_touched\n"); | ||
| 1450 | |||
| 1451 | $color_flow_href->{_prog_names_aref} = | ||
| 1452 | $param_flow_color_pkg->get_flow_prog_names_aref(); | ||
| 1453 | $control->set_flow_prog_names_aref( $color_flow_href->{_prog_names_aref} ); | ||
| 1454 | $control->set_flow_prog_name_index($most_recent_flow_index_touched); | ||
| 1455 | |||
| 1456 | # restore strings to have terminal strings | ||
| 1457 | # remove quotes upon input | ||
| 1458 | $color_flow_href->{_values_aref} = | ||
| 1459 | $control->get_no_quotes4array( $color_flow_href->{_values_aref} ); | ||
| 1460 | |||
| 1461 | # in case parameter values have been displayed stringless | ||
| 1462 | $color_flow_href->{_values_aref} = | ||
| 1463 | $control->get_string_or_number4aref( $color_flow_href->{_values_aref} ); | ||
| 1464 | |||
| 1465 | # print("color_flow,_stack_flow, color_flow_href->{_names_aref} =@{$color_flow_href->{_values_aref}} \n"); | ||
| 1466 | |||
| 1467 | $param_flow_color_pkg->stack_values_aref2( | ||
| 1468 | $color_flow_href->{_values_aref} ); | ||
| 1469 | |||
| 1470 | $param_flow_color_pkg->stack_checkbuttons_aref2( | ||
| 1471 | $color_flow_href->{_check_buttons_settings_aref} ); | ||
| 1472 | |||
| 1473 | # my $num_items = $param_flow_color_pkg->get_num_items(); | ||
| 1474 | # print("color_flow,_stack_flow, data after stack num_items=$num_items\n"); | ||
| 1475 | # $param_flow_color_pkg->view_data(); | ||
| 1476 | |||
| 1477 | return (); | ||
| 1478 | |||
| 1479 | } # end _stack_flow | ||
| 1480 | |||
| 1481 | =head2 sub _stack_versions | ||
| 1482 | |||
| 1483 | Collect and store latest program versions from changed list | ||
| 1484 | |||
| 1485 | Will update listbox variables inside flow_widgets.pm | ||
| 1486 | Therefore pop is not needed on the array | ||
| 1487 | Use after data have been stored, deleted, or | ||
| 1488 | suffered an insertion event | ||
| 1489 | |||
| 1490 | =cut | ||
| 1491 | |||
| 1492 | sub _stack_versions { | ||
| 1493 | |||
| 1494 | my $_flow_listbox_color_w = _get_flow_listbox_color_w(); | ||
| 1495 | |||
| 1496 | $flow_widgets->set_flow_items($_flow_listbox_color_w); | ||
| 1497 | $color_flow_href->{_items_versions_aref} = | ||
| 1498 | $flow_widgets->items_versions_aref; | ||
| 1499 | $param_flow_color_pkg->set_flow_items_version_aref( | ||
| 1500 | $color_flow_href->{_items_versions_aref} ); | ||
| 1501 | |||
| 1502 | } | ||
| 1503 | |||
| 1504 | =head2 _updateNsave_most_recent_param_flow | ||
| 1505 | |||
| 1506 | update parameter values of the most recently touched | ||
| 1507 | program in the flow | ||
| 1508 | |||
| 1509 | print( | ||
| 1510 | "1. START color_flow, _updateNsave_most_recent_param_flow, prior_flow_index=$prior, most_recent=$most_recent\n" | ||
| 1511 | ); | ||
| 1512 | print( | ||
| 1513 | "color_flow, START _updateNsave_most_recent_param_flow, view param flow stored data:\n" | ||
| 1514 | ); | ||
| 1515 | |||
| 1516 | |||
| 1517 | =cut | ||
| 1518 | |||
| 1519 | sub _updateNsave_most_recent_param_flow { | ||
| 1520 | |||
| 1521 | my ($self) = @_; | ||
| 1522 | |||
| 1523 | my $last_parameter_index_on_entry; | ||
| 1524 | my $last_parameter_index_touched_color; | ||
| 1525 | my $most_recent_flow_index_touched; | ||
| 1526 | my $prior_flow_index_touched; | ||
| 1527 | |||
| 1528 | $prior_flow_index_touched = | ||
| 1529 | ( $color_flow_href->{_flow_select_index_href} )->{_prior}; | ||
| 1530 | $most_recent_flow_index_touched = | ||
| 1531 | ( $color_flow_href->{_flow_select_index_href} )->{_most_recent}; | ||
| 1532 | my $_flow_listbox_color_w = _get_flow_listbox_color_w(); | ||
| 1533 | |||
| 1534 | =pod | ||
| 1535 | |||
| 1536 | hash remains partially undefined in gui_history.pm | ||
| 1537 | |||
| 1538 | =cut | ||
| 1539 | |||
| 1540 | if ( | ||
| 1541 | not( | ||
| 1542 | defined( | ||
| 1543 | ( | ||
| 1544 | $color_flow_href->{_parameter_index_on_entry_click_seq_href} | ||
| 1545 | )->{_most_recent} | ||
| 1546 | ) | ||
| 1547 | ) | ||
| 1548 | ) | ||
| 1549 | { | ||
| 1550 | ( $color_flow_href->{_parameter_index_on_entry_click_seq_href} ) | ||
| 1551 | ->{_most_recent} = -1; | ||
| 1552 | my $value = | ||
| 1553 | ( $color_flow_href->{_parameter_index_on_entry_click_seq_href} ) | ||
| 1554 | ->{_most_recent}; | ||
| 1555 | |||
| 1556 | } | ||
| 1557 | if ( | ||
| 1558 | not( | ||
| 1559 | defined( | ||
| 1560 | ( $color_flow_href->{_parameter_index_on_exit_click_seq_href} ) | ||
| 1561 | ->{_most_recent} | ||
| 1562 | ) | ||
| 1563 | ) | ||
| 1564 | ) | ||
| 1565 | |||
| 1566 | { | ||
| 1567 | ( $color_flow_href->{_parameter_index_on_exit_click_seq_href} ) | ||
| 1568 | ->{_most_recent} = -1; | ||
| 1569 | my $value = | ||
| 1570 | ( $color_flow_href->{_parameter_index_on_exit_click_seq_href} ) | ||
| 1571 | ->{_most_recent}; | ||
| 1572 | |||
| 1573 | # print("color_flow,_updateNsave_most_recent_param_flow, undefined 2 is: $value\n"); | ||
| 1574 | } | ||
| 1575 | |||
| 1576 | =pod | ||
| 1577 | |||
| 1578 | The following two values = -1 (default) until a | ||
| 1579 | second program is placed in the flow | ||
| 1580 | |||
| 1581 | =cut | ||
| 1582 | |||
| 1583 | $last_parameter_index_on_entry = | ||
| 1584 | ( $color_flow_href->{_parameter_index_on_entry_click_seq_href} ) | ||
| 1585 | ->{_most_recent}; | ||
| 1586 | $last_parameter_index_touched_color = | ||
| 1587 | ( $color_flow_href->{_parameter_index_on_exit_click_seq_href} ) | ||
| 1588 | ->{_most_recent}; | ||
| 1589 | |||
| 1590 | my $prior_flow_color = | ||
| 1591 | ( $color_flow_href->{_flow_select_color_href} )->{_prior}; | ||
| 1592 | my $most_recent_flow_color = | ||
| 1593 | ( $color_flow_href->{_flow_select_color_href} )->{_most_recent}; | ||
| 1594 | |||
| 1595 | my $storage_flow_index = $most_recent_flow_index_touched; | ||
| 1596 | |||
| 1597 | =pod To update parameters in the most recent flow | ||
| 1598 | at least one program item must exist | ||
| 1599 | =cut | ||
| 1600 | |||
| 1601 | my $num_flow_items = $flow_widgets->get_num_items($_flow_listbox_color_w); | ||
| 1602 | |||
| 1603 | # print("color_flow, _updateNsave_most_recent_param_flow, num flow items= $num_flow_items\n"); | ||
| 1604 | |||
| 1605 | if ( | ||
| 1606 | ( | ||
| 1607 | $most_recent_flow_index_touched >= 0 | ||
| 1608 | or $last_parameter_index_touched_color >= 0 | ||
| 1609 | ) | ||
| 1610 | and $num_flow_items > 0 | ||
| 1611 | ) | ||
| 1612 | { | ||
| 1613 | |||
| 1614 | # prior flow must have the same color as the current one or | ||
| 1615 | # we have just clicked an sunix program (neutral-flow case) | ||
| 1616 | if ( $prior_flow_color eq $neutral | ||
| 1617 | or $prior_flow_color eq $most_recent_flow_color ) | ||
| 1618 | { | ||
| 1619 | my $most_recent = | ||
| 1620 | ( ( $gui_history->get_defaults() )->{_flow_select_index_href} ) | ||
| 1621 | ->{_most_recent}; | ||
| 1622 | my $prior = | ||
| 1623 | ( ( $gui_history->get_defaults() )->{_flow_select_index_href} ) | ||
| 1624 | ->{_prior}; | ||
| 1625 | |||
| 1626 | # the checkbuttons, values and names of ONLY the last program used | ||
| 1627 | # are stored in param_widgets at any ONE time | ||
| 1628 | $color_flow_href->{_values_aref} = | ||
| 1629 | $param_widgets->get_values_aref(); | ||
| 1630 | |||
| 1631 | # establish which program is active in the flow-- for control | ||
| 1632 | $color_flow_href->{_prog_names_aref} = | ||
| 1633 | $param_flow_color_pkg->get_flow_prog_names_aref(); | ||
| 1634 | $control->set_flow_prog_names_aref( | ||
| 1635 | $color_flow_href->{_prog_names_aref} ); | ||
| 1636 | $control->set_flow_prog_name_index($most_recent); | ||
| 1637 | |||
| 1638 | # restore terminal ticks in strings after reading from the GUI | ||
| 1639 | # remove possible terminal strings | ||
| 1640 | $color_flow_href->{_values_aref} = | ||
| 1641 | $control->get_no_quotes4array( $color_flow_href->{_values_aref} ); | ||
| 1642 | |||
| 1643 | # in case parameter values have been displayed stringless | ||
| 1644 | $color_flow_href->{_values_aref} = | ||
| 1645 | $control->get_string_or_number4aref( | ||
| 1646 | $color_flow_href->{_values_aref} ); | ||
| 1647 | $color_flow_href->{_names_aref} = $param_widgets->get_labels_aref(); | ||
| 1648 | $color_flow_href->{_check_buttons_settings_aref} = | ||
| 1649 | $param_widgets->get_check_buttons_settings_aref(); | ||
| 1650 | |||
| 1651 | $param_flow_color_pkg->set_flow_index($storage_flow_index); | ||
| 1652 | |||
| 1653 | # The following 3 lines save old changed values and names but not the versions | ||
| 1654 | $param_flow_color_pkg->set_values_aref( | ||
| 1655 | $color_flow_href->{_values_aref} ); | ||
| 1656 | |||
| 1657 | # print( | ||
| 1658 | # "99. color flow,leaving _updateNsave_most_recent_param_flow \n" | ||
| 1659 | # ); | ||
| 1660 | # $param_flow_color_pkg->view_data(); | ||
| 1661 | |||
| 1662 | $param_flow_color_pkg->set_names_aref( | ||
| 1663 | $color_flow_href->{_names_aref} ); | ||
| 1664 | $param_flow_color_pkg->set_check_buttons_settings_aref( | ||
| 1665 | $color_flow_href->{_check_buttons_settings_aref} ); | ||
| 1666 | |||
| 1667 | $param_widgets->set_entry_change_status($false) | ||
| 1668 | ; # changes are now complete, needwd?? | ||
| 1669 | $color_flow_href->{_last_flow_color} = | ||
| 1670 | $color_flow_href->{_flow_color}; | ||
| 1671 | |||
| 1672 | $most_recent = | ||
| 1673 | ( ( $gui_history->get_defaults() )->{_flow_select_index_href} ) | ||
| 1674 | ->{_most_recent}; | ||
| 1675 | $prior = | ||
| 1676 | ( ( $gui_history->get_defaults() )->{_flow_select_index_href} ) | ||
| 1677 | ->{_prior}; | ||
| 1678 | |||
| 1679 | # print( | ||
| 1680 | # "1. END color_flow, _updateNsave_most_recent_param_flow, prior_flow_index=$prior, most_recent=$most_recent\n" | ||
| 1681 | # ); | ||
| 1682 | |||
| 1683 | } | ||
| 1684 | else { | ||
| 1685 | |||
| 1686 | #NADA | ||
| 1687 | } | ||
| 1688 | } | ||
| 1689 | else { | ||
| 1690 | } | ||
| 1691 | |||
| 1692 | return (); | ||
| 1693 | } | ||
| 1694 | |||
| 1695 | =head2 _update_prior_param_flow | ||
| 1696 | |||
| 1697 | Updates the values for parameters stored via param_flow | ||
| 1698 | param-flow takes uses parameters from param_widgets | ||
| 1699 | BUT param_widgets needs to have been updated by _update_most_recent_flow? or | ||
| 1700 | user changes on the screen will not have been updated | ||
| 1701 | |||
| 1702 | Apply every time that a flow item is selected | ||
| 1703 | 1. Assume that selection of a flow item implies pre-existing parameter values were changed/added | ||
| 1704 | |||
| 1705 | 2. Opening a file dialog assumes parameter values were also changed (Entry widget) | ||
| 1706 | -- this means that a prior program must have been touched and that the color must change | ||
| 1707 | from either neutral to the current color or be overwritten by the same color | ||
| 1708 | |||
| 1709 | Exceptions include the | ||
| 1710 | (1) case when you have just left a flow of a different color | ||
| 1711 | and are returning to previous settings. | ||
| 1712 | (2) case when you are using the first item in a flow for the first time, i.e. it has never been | ||
| 1713 | used before | ||
| 1714 | |||
| 1715 | Find out the previous color, then ... there are | ||
| 1716 | 2 possible CASES | ||
| 1717 | CASE 1 | ||
| 1718 | The current color is the same as the previously touched color | ||
| 1719 | i.e., if the last color-flow box touched was of the current flow color | ||
| 1720 | i.e., consider situation when we are still using the same colored list box | ||
| 1721 | |||
| 1722 | in which case... | ||
| 1723 | 1. Find out which index was touched in "color"-flow box | ||
| 1724 | 2. Find out which program was previously touched | ||
| 1725 | 3. Assume the touched program had its parameter values modified | ||
| 1726 | 4. Update all the previously touched program's values in storage via param_flow | ||
| 1727 | |||
| 1728 | CASE 2 | ||
| 1729 | If the current color is different to the previously touched color, then | ||
| 1730 | 2. ELIMINATE all the previous changes | ||
| 1731 | |||
| 1732 | Clicking Save will activate _update_prior_param_flow. | ||
| 1733 | Before Save is clicked: | ||
| 1734 | the | ||
| 1735 | _last_parameter_index_touched_color = 0 | ||
| 1736 | _last_flow_index_touched = -1 | ||
| 1737 | _last_flow_color = current flow color | ||
| 1738 | |||
| 1739 | |||
| 1740 | print("1. color_flow, _update_prior_param_flow, start\n"); | ||
| 1741 | $param_flow_color_pkg->view_data(); | ||
| 1742 | |||
| 1743 | # print("2. color_flow, _update_prior_param_flow, print gui_history.txt\n"); | ||
| 1744 | # $gui_history->view(); | ||
| 1745 | |||
| 1746 | deprecated 1.23.23 | ||
| 1747 | if ( $prior_flow_color eq $neutral | ||
| 1748 | or $prior_flow_color eq $most_recent_flow_color ) | ||
| 1749 | |||
| 1750 | |||
| 1751 | |||
| 1752 | print( | ||
| 1753 | "color_flow,_update_prior_param_flow,prior_color_flow = $prior_flow_color\n" | ||
| 1754 | ); | ||
| 1755 | print("2 color_flow, _update_prior_param_flow, start\n"); | ||
| 1756 | $param_flow_color_pkg->view_data(); | ||
| 1757 | |||
| 1758 | print( | ||
| 1759 | "3. color_flow,_update_prior_param_flow,names, color_flow: @{$color_flow_href->{_names_aref}}\n" | ||
| 1760 | ); | ||
| 1761 | print( | ||
| 1762 | "3.color_flow,_update_prior_param_flow,values, color_flow: @{$color_flow_href->{_values_aref}}\n" | ||
| 1763 | ); | ||
| 1764 | print( | ||
| 1765 | "3.color_flow,_update_prior_param_flow,n, param_widgets:@{$param_widgets->get_labels_aref()}\n" | ||
| 1766 | ); | ||
| 1767 | print( | ||
| 1768 | "3.color_flow,_update_prior_param_flow,values, param_widgets:@{$param_widgets->get_values_aref()}\n" | ||
| 1769 | ); | ||
| 1770 | print("1. color_flow,_update_prior_param_flow, prior_flow and storage index=$storage_flow_index\n"); | ||
| 1771 | print("color_flow,_update_prior_param_flow,most_recent_flow_index=$most_recent_flow_index_touched\n"); | ||
| 1772 | |||
| 1773 | print("4.color flow,_update_prior_param_flow \n"); | ||
| 1774 | $param_flow_color_pkg->view_data(); | ||
| 1775 | =cut | ||
| 1776 | |||
| 1777 | sub _update_prior_param_flow { | ||
| 1778 | |||
| 1779 | my ($self) = @_; | ||
| 1780 | |||
| 1781 | my $prior_item_exists = $false; | ||
| 1782 | my $_flow_listbox_color_w = | ||
| 1783 | _get_flow_listbox_color_w(); # user-built_flow in current use | ||
| 1784 | |||
| 1785 | my $prior_flow_index_touched = | ||
| 1786 | ( $color_flow_href->{_flow_select_index_href} )->{_prior}; | ||
| 1787 | my $most_recent_flow_index_touched = | ||
| 1788 | ( $color_flow_href->{_flow_select_index_href} )->{_most_recent}; | ||
| 1789 | |||
| 1790 | # following two values are empty until a second program is placed in the flow | ||
| 1791 | my $last_parameter_index_on_entry = | ||
| 1792 | ( $color_flow_href->{_parameter_index_on_entry_click_seq_href} ) | ||
| 1793 | ->{_most_recent}; | ||
| 1794 | my $last_parameter_index_touched_color = | ||
| 1795 | ( $color_flow_href->{_parameter_index_on_exit_click_seq_href} ) | ||
| 1796 | ->{_most_recent}; | ||
| 1797 | my $prior_flow_color = | ||
| 1798 | ( $color_flow_href->{_flow_select_color_href} )->{_prior}; | ||
| 1799 | my $most_recent_flow_color = | ||
| 1800 | ( $color_flow_href->{_flow_select_color_href} )->{_most_recent}; | ||
| 1801 | my $storage_flow_index = $prior_flow_index_touched; | ||
| 1802 | my $prior_flow_select = ( $color_flow_href->{_button_href} )->{_prior}; | ||
| 1803 | |||
| 1804 | # get number of items in the flow listbox | ||
| 1805 | # prior program must exist | ||
| 1806 | if ( $prior_flow_index_touched <= | ||
| 1807 | $flow_widgets->get_num_items($_flow_listbox_color_w) ) | ||
| 1808 | { | ||
| 1809 | |||
| 1810 | $prior_item_exists = $true; | ||
| 1811 | |||
| 1812 | } | ||
| 1813 | else { | ||
| 1814 | print("color_flow,_update_prior_param_flow, missing prior item\n"); | ||
| 1815 | } | ||
| 1816 | |||
| 1817 | if ( | ||
| 1818 | ( | ||
| 1819 | $most_recent_flow_index_touched >= 0 | ||
| 1820 | or $last_parameter_index_touched_color >= 0 | ||
| 1821 | ) | ||
| 1822 | and $prior_item_exists | ||
| 1823 | ) | ||
| 1824 | { | ||
| 1825 | |||
| 1826 | if ( $prior_flow_select eq $sunix_select | ||
| 1827 | and $prior_flow_color eq $most_recent_flow_color ) | ||
| 1828 | { | ||
| 1829 | |||
| 1830 | print( | ||
| 1831 | "4.color flow,_update_prior_param_flow, prior_flow_select=$prior_flow_select \n" | ||
| 1832 | ); | ||
| 1833 | |||
| 1834 | # CASE 1 prior flow must have been an sunix program | ||
| 1835 | # so ignore the param_widgets that were just displayed | ||
| 1836 | # NADA | ||
| 1837 | |||
| 1838 | } | ||
| 1839 | elsif ( $prior_flow_color eq $most_recent_flow_color ) { | ||
| 1840 | |||
| 1841 | # CASE 2 prior flow must have the same color as the current one | ||
| 1842 | # but sunix_select was not previously selected | ||
| 1843 | |||
| 1844 | # the checkbuttons, values and names of ONLY the last program used | ||
| 1845 | # are stored in param_widgets at any ONE time | ||
| 1846 | $color_flow_href->{_values_aref} = | ||
| 1847 | $param_widgets->get_values_aref(); | ||
| 1848 | |||
| 1849 | # establish which program is active in the flow--for control | ||
| 1850 | $color_flow_href->{_prog_names_aref} = | ||
| 1851 | $param_flow_color_pkg->get_flow_prog_names_aref(); | ||
| 1852 | $control->set_flow_prog_names_aref( | ||
| 1853 | $color_flow_href->{_prog_names_aref} ); | ||
| 1854 | $control->set_flow_prog_name_index($most_recent_flow_index_touched); | ||
| 1855 | |||
| 1856 | # restore terminal ticks in strings after reading from the GUI | ||
| 1857 | # remove possible terminal strings | ||
| 1858 | $color_flow_href->{_values_aref} = | ||
| 1859 | $control->get_no_quotes4array( $color_flow_href->{_values_aref} ); | ||
| 1860 | |||
| 1861 | # correct parameter values that have been displayed stringless | ||
| 1862 | $color_flow_href->{_values_aref} = | ||
| 1863 | $control->get_string_or_number4aref( | ||
| 1864 | $color_flow_href->{_values_aref} ); | ||
| 1865 | |||
| 1866 | # collect checkbuttons, names from what is currently in the gui | ||
| 1867 | $color_flow_href->{_names_aref} = $param_widgets->get_labels_aref(); | ||
| 1868 | $color_flow_href->{_check_buttons_settings_aref} = | ||
| 1869 | $param_widgets->get_check_buttons_settings_aref(); | ||
| 1870 | |||
| 1871 | # The following 3 lines save old changed values and names but not the versions | ||
| 1872 | $param_flow_color_pkg->set_values_aref( | ||
| 1873 | $color_flow_href->{_values_aref} ); | ||
| 1874 | $param_flow_color_pkg->set_names_aref( | ||
| 1875 | $color_flow_href->{_names_aref} ); | ||
| 1876 | $param_flow_color_pkg->set_check_buttons_settings_aref( | ||
| 1877 | $color_flow_href->{_check_buttons_settings_aref} ); | ||
| 1878 | $param_flow_color_pkg->set_flow_index($storage_flow_index); | ||
| 1879 | |||
| 1880 | $param_widgets->set_entry_change_status($false) | ||
| 1881 | ; # changes are now complete, needwd?? | ||
| 1882 | $color_flow_href->{_last_flow_color} = | ||
| 1883 | $color_flow_href->{_flow_color}; | ||
| 1884 | |||
| 1885 | } | ||
| 1886 | else { | ||
| 1887 | #NADA | ||
| 1888 | } | ||
| 1889 | } | ||
| 1890 | else { | ||
| 1891 | } | ||
| 1892 | |||
| 1893 | return (); | ||
| 1894 | } | ||
| 1895 | |||
| 1896 | =head2 _save_most_recent_param_flow | ||
| 1897 | |||
| 1898 | Force to save flow parameters to param_flow | ||
| 1899 | |||
| 1900 | We assume that the program of interest within an active flow stays the same. | ||
| 1901 | Nevertheless that a parameter within a fixed program has changed so that | ||
| 1902 | the stored parameters for that program need to be updated. (TODO??) | ||
| 1903 | That is, param_flow will update the stored parameters for a member of the flow | ||
| 1904 | without having to change the flow item/program with which we interact. | ||
| 1905 | |||
| 1906 | The checkbuttons, values and names of only the present program in use | ||
| 1907 | are stored in param_widgets at any one time | ||
| 1908 | |||
| 1909 | After selecting a data file name, the file name is automatically inserted | ||
| 1910 | into the GUI. Following, we update the data file name into the stored parameters via param_flow | ||
| 1911 | |||
| 1912 | $last_parameter_index_touched_color must =0 or > 0 | ||
| 1913 | but does exist and means the parameters are untouched | ||
| 1914 | |||
| 1915 | =cut | ||
| 1916 | |||
| 1917 | sub _save_most_recent_param_flow { | ||
| 1918 | |||
| 1919 | my ($self) = @_; | ||
| 1920 | |||
| 1921 | my $prior_flow_index_touched = | ||
| 1922 | ( $color_flow_href->{_flow_select_index_href} )->{_prior}; | ||
| 1923 | my $most_recent_flow_index_touched = | ||
| 1924 | ( $color_flow_href->{_flow_select_index_href} )->{_most_recent}; | ||
| 1925 | my $storage_flow_index = $most_recent_flow_index_touched; | ||
| 1926 | |||
| 1927 | # The following two values are empty until a second program is placed in the flow | ||
| 1928 | my $last_parameter_index_on_entry = | ||
| 1929 | ( $color_flow_href->{_parameter_index_on_entry_href} )->{_most_recent}; | ||
| 1930 | my $last_parameter_index_touched_color = | ||
| 1931 | ( $color_flow_href->{_parameter_index_on_exit_href} )->{_most_recent}; | ||
| 1932 | |||
| 1933 | # print("color_flow _save_most_recent_param_flow ,last changed entry index was $last_parameter_index_touched_color \n"); | ||
| 1934 | # print("2. color_flow, _save_most_recent_param_flow , print gui_history.txt\n"); | ||
| 1935 | # $gui_history->view(); | ||
| 1936 | |||
| 1937 | # my $prior_flow_color = ( $color_flow_href->{_flow_select_color_href} )->{_prior}; | ||
| 1938 | # my $most_recent_flow_color = ( $color_flow_href->{_flow_select_color_href} )->{_most_recent}; | ||
| 1939 | |||
| 1940 | if ( $last_parameter_index_touched_color >= 0 ) { | ||
| 1941 | |||
| 1942 | # Update names and check_buttons again, while reading in from the GUI ( via param_widgets) | ||
| 1943 | $color_flow_href->{_names_aref} = $param_widgets->get_labels_aref(); | ||
| 1944 | $color_flow_href->{_check_buttons_settings_aref} = | ||
| 1945 | $param_widgets->get_check_buttons_settings_aref(); | ||
| 1946 | $color_flow_href->{_values_aref} = $param_widgets->get_values_aref(); | ||
| 1947 | |||
| 1948 | # establish which program is active in the flow | ||
| 1949 | $color_flow_href->{_prog_names_aref} = | ||
| 1950 | $param_flow_color_pkg->get_flow_prog_names_aref(); | ||
| 1951 | $control->set_flow_prog_names_aref( | ||
| 1952 | $color_flow_href->{_prog_names_aref} ); | ||
| 1953 | $control->set_flow_prog_name_index($most_recent_flow_index_touched); | ||
| 1954 | |||
| 1955 | # restore terminal ticks in strings after reading from the GUI | ||
| 1956 | # remove possible terminal strings | ||
| 1957 | $color_flow_href->{_values_aref} = | ||
| 1958 | $control->get_no_quotes4array( $color_flow_href->{_values_aref} ); | ||
| 1959 | |||
| 1960 | # print( | ||
| 1961 | # "color_flow, _save_most_recent_param_flow, param_widgets->get_values_aref():@{$color_flow_href->{_values_aref}}\n" | ||
| 1962 | # ); | ||
| 1963 | # in case parameter values have been displayed stringless | ||
| 1964 | $color_flow_href->{_values_aref} = $control->get_string_or_number4aref( | ||
| 1965 | $color_flow_href->{_values_aref} ); | ||
| 1966 | |||
| 1967 | # print( | ||
| 1968 | # "3B. color_flow, _save_most_recent_param_flow,color_flow_href->{_values_aref}= | ||
| 1969 | # @{$color_flow_href->{_values_aref}}\n"); | ||
| 1970 | |||
| 1971 | # Use flow item index of the program in the color-flow listbox that is currently being used, | ||
| 1972 | # i.e., not the index of the last-used program ut the current | ||
| 1973 | # user-built_flow. | ||
| 1974 | my $_flow_listbox_color_w = _get_flow_listbox_color_w(); | ||
| 1975 | |||
| 1976 | if ( $storage_flow_index >= 0 ) { | ||
| 1977 | |||
| 1978 | # select an item from which to extract data | ||
| 1979 | $param_flow_color_pkg->set_flow_index($storage_flow_index); | ||
| 1980 | |||
| 1981 | # save current values, names and check buttons BUT not the versions | ||
| 1982 | $param_flow_color_pkg->set_values_aref( | ||
| 1983 | $color_flow_href->{_values_aref} ); | ||
| 1984 | $param_flow_color_pkg->set_names_aref( | ||
| 1985 | $color_flow_href->{_names_aref} ); | ||
| 1986 | $param_flow_color_pkg->set_check_buttons_settings_aref( | ||
| 1987 | $color_flow_href->{_check_buttons_settings_aref} ); | ||
| 1988 | $param_widgets->set_entry_change_status($false) | ||
| 1989 | ; # changes are now complete | ||
| 1990 | |||
| 1991 | # print( | ||
| 1992 | # "1912 End of $this_color _save_most_recent_param_flow: _last_parameter_index_touched reset: | ||
| 1993 | # $color_flow_href->{_last_parameter_index_touched_color}\n" | ||
| 1994 | # ); | ||
| 1995 | |||
| 1996 | } | ||
| 1997 | else { | ||
| 1998 | |||
| 1999 | # Look for the last flow index that was touched | ||
| 2000 | my $last_idx_chng = $storage_flow_index; | ||
| 2001 | $param_flow_color_pkg->set_flow_index($last_idx_chng); | ||
| 2002 | |||
| 2003 | # save current values, names and check buttons BUT not the versions | ||
| 2004 | $param_flow_color_pkg->set_values_aref( | ||
| 2005 | $color_flow_href->{_values_aref} ); | ||
| 2006 | $param_flow_color_pkg->set_names_aref( | ||
| 2007 | $color_flow_href->{_names_aref} ); | ||
| 2008 | $param_flow_color_pkg->set_check_buttons_settings_aref( | ||
| 2009 | $color_flow_href->{_check_buttons_settings_aref} ); | ||
| 2010 | $param_widgets->set_entry_change_status($false) | ||
| 2011 | ; # changes are now complete | ||
| 2012 | |||
| 2013 | # print( | ||
| 2014 | # "1656 End of $this_color _save_most_recent_param_flow: _last_parameter_index_touched reset: $color_flow_href->{_last_parameter_index_touched_color}\n" | ||
| 2015 | # ); | ||
| 2016 | |||
| 2017 | } | ||
| 2018 | |||
| 2019 | } | ||
| 2020 | else { | ||
| 2021 | |||
| 2022 | # print("color_flow,_save_most_recent_param-flow,NADA \n"); | ||
| 2023 | } | ||
| 2024 | |||
| 2025 | return (); | ||
| 2026 | } | ||
| 2027 | |||
| 2028 | =head2 sub FileDialog_button | ||
| 2029 | |||
| 2030 | Handles Data, SaveAs and (perl) Open (in) or Delete | ||
| 2031 | May provide values from the current widget if it is used. | ||
| 2032 | Can also be (1) a previous pre-built superflow that is already in the GUI | ||
| 2033 | or 2) empty if program is just starting | ||
| 2034 | |||
| 2035 | dialog type (option_sref) can be: | ||
| 2036 | Data, | ||
| 2037 | Open (open an exisiting user-built flow, but not a pre-built | ||
| 2038 | superflow), or | ||
| 2039 | SaveAs | ||
| 2040 | |||
| 2041 | Delete ( a file or any type, default $PL_SEISMIC) | ||
| 2042 | |||
| 2043 | my $uBF = $file_dialog->get_hash_ref(); | ||
| 2044 | foreach my $key (sort keys %$uBF) { | ||
| 2045 | print (" color_flowkey is $key, value is $uBF->{$key}\n"); | ||
| 2046 | } | ||
| 2047 | |||
| 2048 | =cut | ||
| 2049 | |||
| 2050 | sub FileDialog_button { | ||
| 2051 | |||
| 2052 | my ( $self, $dialog_type_sref ) = @_; | ||
| 2053 | |||
| 2054 | my $file_dialog_type = $L_SU_global_constants->file_dialog_type_href(); | ||
| 2055 | my $PL_SEISMIC = $Project->PL_SEISMIC(); | ||
| 2056 | |||
| 2057 | if ($dialog_type_sref) { | ||
| 2058 | |||
| 2059 | $color_flow_href->{_dialog_type} = | ||
| 2060 | $$dialog_type_sref; # dereference scalar | ||
| 2061 | my $topic = $color_flow_href->{_dialog_type}; | ||
| 2062 | |||
| 2063 | if ( $topic eq $file_dialog_type->{_SaveAs} ) { | ||
| 2064 | |||
| 2065 | # print("color_flow, L_SU,FileDialog_button, ONLY for SaveAs\n"); | ||
| 2066 | # i.e., in this module, dialog_type_sref can only be SaveAs | ||
| 2067 | # Save for 'user-built flows' is accessible via L_SU.pm | ||
| 2068 | |||
| 2069 | my $most_recent_flow_index_touched = | ||
| 2070 | ( $color_flow_href->{_flow_select_index_href} )->{_most_recent}; | ||
| 2071 | |||
| 2072 | $color_flow_href->{_values_aref} = | ||
| 2073 | $param_widgets->get_values_aref(); | ||
| 2074 | |||
| 2075 | # establish which program is active in the flow | ||
| 2076 | $color_flow_href->{_prog_names_aref} = | ||
| 2077 | $param_flow_color_pkg->get_flow_prog_names_aref(); | ||
| 2078 | $control->set_flow_prog_names_aref( | ||
| 2079 | $color_flow_href->{_prog_names_aref} ); | ||
| 2080 | $control->set_flow_prog_name_index($most_recent_flow_index_touched); | ||
| 2081 | |||
| 2082 | # restore strings to have terminal strings | ||
| 2083 | # remove quotes upon input | ||
| 2084 | $color_flow_href->{_values_aref} = | ||
| 2085 | $control->get_no_quotes4array( $color_flow_href->{_values_aref} ); | ||
| 2086 | |||
| 2087 | # in case parameter values have been displayed stringless | ||
| 2088 | $color_flow_href->{_values_aref} = | ||
| 2089 | $control->get_string_or_number4aref( | ||
| 2090 | $color_flow_href->{_values_aref} ); | ||
| 2091 | |||
| 2092 | $color_flow_href->{_dialog_type} = | ||
| 2093 | $$dialog_type_sref; # dereference scalar | ||
| 2094 | |||
| 2095 | $file_dialog->set_flow_color( $color_flow_href->{_flow_color} ); | ||
| 2096 | $file_dialog->set_hash_ref($color_flow_href); | ||
| 2097 | $file_dialog->FileDialog_director(); | ||
| 2098 | |||
| 2099 | $color_flow_href->{_has_used_SaveAs_button} = $true; | ||
| 2100 | |||
| 2101 | # new file name will generate a case that an index has been touched | ||
| 2102 | $color_flow_href->{_last_parameter_index_touched_color} = | ||
| 2103 | $file_dialog->get_last_parameter_index_touched_color(); | ||
| 2104 | |||
| 2105 | # print ("1. color_flow,FileDialog_button,_last_parameter_index_touched_color:$color_flow_href->{_last_parameter_index_touched_color} \n"); | ||
| 2106 | # print ("1. color_flow,FileDialog_button, color: $flow_color \n"); | ||
| 2107 | $color_flow_href->{$_is_last_parameter_index_touched_color} = $true; | ||
| 2108 | |||
| 2109 | _save_most_recent_param_flow(); | ||
| 2110 | |||
| 2111 | $color_flow_href->{$_flow_name_out_color} = | ||
| 2112 | file_dialog->get_perl_flow_name_out(); | ||
| 2113 | $color_flow_href->{_path} = file_dialog->get_file_path(); | ||
| 2114 | |||
| 2115 | # consider empty case, for which saving is not possible | ||
| 2116 | if ( !( $color_flow_href->{$_flow_name_out_color} ) | ||
| 2117 | || $color_flow_href->{$_flow_name_out_color} eq '' | ||
| 2118 | || !( $color_flow_href->{_path} ) | ||
| 2119 | || $color_flow_href->{_path} eq '' ) | ||
| 2120 | { | ||
| 2121 | |||
| 2122 | my $message = $message_director->save_button(1); | ||
| 2123 | $message_w->delete( "1.0", 'end' ); | ||
| 2124 | $message_w->insert( 'end', $message ); | ||
| 2125 | |||
| 2126 | } | ||
| 2127 | else { | ||
| 2128 | |||
| 2129 | # CASE: NON-EMPTY and good | ||
| 2130 | |||
| 2131 | # displays user-built flow name at top of color-flow gui | ||
| 2132 | _set_flowNsuperflow_name_w( | ||
| 2133 | $color_flow_href->{$_flow_name_out_color} ); | ||
| 2134 | _set_user_built_flow_name_w( | ||
| 2135 | $color_flow_href->{$_flow_name_out_color} ); | ||
| 2136 | |||
| 2137 | # go save perl flow file | ||
| 2138 | _SaveAs_button($topic); | ||
| 2139 | |||
| 2140 | # print("color_flow,FileDialog_button, saving the perl file\n"); | ||
| 2141 | |||
| 2142 | # restore message at the bottom of the string to blank if not already so | ||
| 2143 | # messages | ||
| 2144 | my $message = $message_director->null_button(0); | ||
| 2145 | $message_w->delete( "1.0", 'end' ); | ||
| 2146 | $message_w->insert( 'end', $message ); | ||
| 2147 | |||
| 2148 | } # Ends SaveAs option | ||
| 2149 | |||
| 2150 | } | ||
| 2151 | elsif ( $topic eq $file_dialog_type->{_Open} ) { | ||
| 2152 | |||
| 2153 | # 1. Read perl flow file | ||
| 2154 | # 2. Write name to the file name in the appropriate flow | ||
| 2155 | # 3. populate GUI | ||
| 2156 | # 4. populate hashes (color_flow)and memory spaces (param_flow) | ||
| 2157 | # 5. Make sure to clean prior information from the FileDialog Button such as file names. | ||
| 2158 | # 6. save moment all this is done in gui_history | ||
| 2159 | |||
| 2160 | $file_dialog->set_flow_color( $color_flow_href->{_flow_color} ); | ||
| 2161 | $file_dialog->set_hash_ref($color_flow_href); # uses values_aref | ||
| 2162 | $file_dialog->set_flow_type('user_built'); | ||
| 2163 | |||
| 2164 | $file_dialog->FileDialog_director(); | ||
| 2165 | |||
| 2166 | $color_flow_href->{$_flow_name_in_color} = | ||
| 2167 | $file_dialog->get_perl_flow_name_in(); | ||
| 2168 | |||
| 2169 | # print("color_flow, flow_name_in = $color_flow_href->{$_flow_name_in_color}\n"); | ||
| 2170 | $color_flow_href->{$_flow_name_out_color} = | ||
| 2171 | $color_flow_href->{$_flow_name_in_color}; | ||
| 2172 | |||
| 2173 | # print("color_flow,color_flow_href->{_has_used_open_perl_file_button}=$color_flow_href->{_has_used_open_perl_file_button}\n"); | ||
| 2174 | |||
| 2175 | # Is $flow_name_in empty? | ||
| 2176 | my $file2query = | ||
| 2177 | $PL_SEISMIC . '/' . $color_flow_href->{$_flow_name_in_color}; | ||
| 2178 | $color_flow->{_Flow_file_exists} = | ||
| 2179 | $manage_files_by2->does_file_exist_sref( \$file2query ); | ||
| 2180 | |||
| 2181 | # Are there any errors when reading the perl flow file | ||
| 2182 | $color_flow->{_perl_flow_errors} = _perl_flow_errors(); | ||
| 2183 | |||
| 2184 | if ( $color_flow->{_Flow_file_exists} | ||
| 2185 | && $color_flow->{_perl_flow_errors} eq $false ) | ||
| 2186 | { | ||
| 2187 | |||
| 2188 | _set_flow_name_color_w($flow_color); | ||
| 2189 | |||
| 2190 | # Place names of the programs at the top of the color listbox | ||
| 2191 | $flow_name_color_w->configure( | ||
| 2192 | -text => $color_flow_href->{$_flow_name_in_color} ); | ||
| 2193 | |||
| 2194 | # Place names of the programs at the head of the GUI | ||
| 2195 | $color_flow_href->{_flowNsuperflow_name_w}->configure( | ||
| 2196 | -text => $color_flow_href->{_big_stream_name_in} ); | ||
| 2197 | |||
| 2198 | # populate gui, and bot param_flow and param_widgets namespaces | ||
| 2199 | _perl_flow(); | ||
| 2200 | |||
| 2201 | } | ||
| 2202 | else { | ||
| 2203 | # print(" color_flow,FileDialog_button, perl flow parse errors\n"); | ||
| 2204 | # print("3 color_flow,FileDialog_button, Warning: missing file. \"Cancel\" clicked by user? NADA\n"); | ||
| 2205 | } | ||
| 2206 | |||
| 2207 | } | ||
| 2208 | elsif ( $topic eq $file_dialog_type->{_Data} ) { | ||
| 2209 | |||
| 2210 | # print("color_flow, FileDialog_button,option_sref $topic\n"); | ||
| 2211 | # assume that after selection to open of a data file in file-dialog the | ||
| 2212 | # GUI has been updated | ||
| 2213 | # See if the last parameter index has been touched (>= 0) | ||
| 2214 | # Assume we are still dealing with the current flow item selected | ||
| 2215 | $color_flow_href->{_last_parameter_index_touched_color} = | ||
| 2216 | $file_dialog->get_last_parameter_index_touched_color(); | ||
| 2217 | $color_flow_href->{$_is_last_parameter_index_touched_color} = $true; | ||
| 2218 | |||
| 2219 | # set the current listbox as the last color listbox | ||
| 2220 | $color_flow_href->{_last_flow_listbox_color_w} = | ||
| 2221 | $color_flow_href->{_flow_listbox_color_w}; | ||
| 2222 | |||
| 2223 | # provide values in the current widget | ||
| 2224 | $color_flow_href->{_values_aref} = | ||
| 2225 | $param_widgets->get_values_aref(); | ||
| 2226 | |||
| 2227 | my $most_recent_flow_index_touched = | ||
| 2228 | ( $color_flow_href->{_flow_select_index_href} )->{_most_recent}; | ||
| 2229 | |||
| 2230 | # restore terminal ticks to strings | ||
| 2231 | |||
| 2232 | # establish which program is active in the flow | ||
| 2233 | $color_flow_href->{_prog_names_aref} = | ||
| 2234 | $param_flow_color_pkg->get_flow_prog_names_aref(); | ||
| 2235 | $control->set_flow_prog_names_aref( | ||
| 2236 | $color_flow_href->{_prog_names_aref} ); | ||
| 2237 | $control->set_flow_prog_name_index($most_recent_flow_index_touched); | ||
| 2238 | |||
| 2239 | # restore strings to have terminal strings | ||
| 2240 | # remove quotes upon input | ||
| 2241 | $color_flow_href->{_values_aref} = | ||
| 2242 | $control->get_no_quotes4array( $color_flow_href->{_values_aref} ); | ||
| 2243 | |||
| 2244 | # in case parameter values have been displayed stringless | ||
| 2245 | $color_flow_href->{_values_aref} = | ||
| 2246 | $control->get_string_or_number4aref( | ||
| 2247 | $color_flow_href->{_values_aref} ); | ||
| 2248 | |||
| 2249 | # print( | ||
| 2250 | # "color_flow,FileDialog_button(binding), flow_listbox_color_w: $color_flow_href->{_flow_listbox_color_w} \n" | ||
| 2251 | # ); | ||
| 2252 | $file_dialog->set_flow_color( $color_flow_href->{_flow_color} ); | ||
| 2253 | $file_dialog->set_hash_ref($color_flow_href); | ||
| 2254 | $file_dialog->FileDialog_director(); | ||
| 2255 | |||
| 2256 | # print( | ||
| 2257 | # "color_flow,FileDialog_button(binding), last_parameter_index_touched_color: $color_flow_href->{_last_parameter_index_touched_color} \n" | ||
| 2258 | # ); | ||
| 2259 | |||
| 2260 | # update to parameter values occurs in file_dialog | ||
| 2261 | $color_flow_href->{_values_aref} = $file_dialog->get_values_aref(); | ||
| 2262 | |||
| 2263 | # set up this flow listbox item as the last item touched | ||
| 2264 | my $_flow_listbox_color_w = | ||
| 2265 | _get_flow_listbox_color_w(); # user-built_flow in current use | ||
| 2266 | my $current_flow_listbox_index = | ||
| 2267 | $flow_widgets->get_flow_selection($_flow_listbox_color_w); | ||
| 2268 | |||
| 2269 | # $color_flow_href->{_last_flow_index_touched} = | ||
| 2270 | # $current_flow_listbox_index; # for next time | ||
| 2271 | # $color_flow_href->{$_is_last_flow_index_touched_color} = $true; | ||
| 2272 | |||
| 2273 | # print("color_flow,FileDialog_button(binding), last_flow_index_touched:$color_flow_href->{_last_flow_index_touched} \n"); | ||
| 2274 | |||
| 2275 | # Changes made with another instance of param_widgets (in file_dialog) will require | ||
| 2276 | # that we also update the namespace of the current param_flow | ||
| 2277 | # We make this change inside _save_most_recent_param_flow | ||
| 2278 | _save_most_recent_param_flow(); | ||
| 2279 | |||
| 2280 | } | ||
| 2281 | else { | ||
| 2282 | print("1. color_flow, FileDialog_button, missing topic \n"); | ||
| 2283 | |||
| 2284 | # Ends opt_ref | ||
| 2285 | } | ||
| 2286 | } | ||
| 2287 | else { | ||
| 2288 | print("color_flow,FileDialog_button ,option type missing\n"); | ||
| 2289 | } | ||
| 2290 | |||
| 2291 | return (); | ||
| 2292 | } | ||
| 2293 | |||
| 2294 | =head2 sub add2flow_button | ||
| 2295 | |||
| 2296 | When build a first-time perl flow | ||
| 2297 | Incorporate new prorgam parameter values and labels into the gui | ||
| 2298 | and save the values, labels and checkbuttons setting in the param_flow | ||
| 2299 | namespace | ||
| 2300 | |||
| 2301 | foreach my $key (sort keys %$color_flow_href) { | ||
| 2302 | print (" color_flow key is $key, value is $color_flow_href->{$key}\n"); | ||
| 2303 | } | ||
| 2304 | |||
| 2305 | $ans= $color_flow_href->{_param_sunix_length}; | ||
| 2306 | print("1b. color_flow, add2flow_button, _param_sunix_length= $ans\n"); | ||
| 2307 | |||
| 2308 | =cut | ||
| 2309 | |||
| 2310 | sub add2flow_button { | ||
| 2311 | |||
| 2312 | my ( $self, $value ) = @_; | ||
| 2313 | |||
| 2314 | # $color_flow_href->{_names_aref} = $param_widgets->get_labels_aref(); | ||
| 2315 | # print("start add2flow_button all label0 = @{$color_flow_href->{_names_aref}}[0]\n"); | ||
| 2316 | # print("start add2flow_buttonall label1 = @{$color_flow_href->{_names_aref}}[1]\n"); | ||
| 2317 | # $color_flow_href->{_values_aref} = $param_widgets->get_values_aref(); | ||
| 2318 | # print("start add2flow_buttonall value0 = @{$color_flow_href->{_values_aref}}[0]\n"); | ||
| 2319 | # print("start add2flow_buttonall value1 = @{$color_flow_href->{_values_aref}}[1]\n"); | ||
| 2320 | |||
| 2321 | # There is a case when a flow is used for the first time, when | ||
| 2322 | # a parameter value has been added or | ||
| 2323 | # modified and the flow item | ||
| 2324 | # is not selected manually after a change (using select_flow_button) | ||
| 2325 | # If a previous flow item has not been updated | ||
| 2326 | # we must force an update to save these first-time, new, parameter values | ||
| 2327 | # by using _flow_select (which calls flow_select). | ||
| 2328 | # When we are coming from selecting an sunix program | ||
| 2329 | # the flow listbox has been cleared of selections | ||
| 2330 | # The last flow listbox selection was stored in the gui history | ||
| 2331 | # We can not set flow_select button index | ||
| 2332 | # We will increment the number of clicks | ||
| 2333 | # (TODO) and that you have not changed color | ||
| 2334 | my $_flow_listbox_color_w = _get_flow_listbox_color_w(); | ||
| 2335 | my $flow_num_items = $_flow_listbox_color_w->size(); | ||
| 2336 | |||
| 2337 | $color_flow_href->{_flow_type} = $flow_type->{_user_built}; | ||
| 2338 | |||
| 2339 | my $param_sunix = param_sunix->new(); | ||
| 2340 | my $message = $message_director->null_button(0); | ||
| 2341 | |||
| 2342 | $gui_history->set_hash_ref($color_flow_href); | ||
| 2343 | $gui_history->set4start_of_add2flow_button($flow_color); | ||
| 2344 | $color_flow_href = $gui_history->get_hash_ref(); | ||
| 2345 | |||
| 2346 | $message_w->delete( "1.0", 'end' ); | ||
| 2347 | $message_w->insert( 'end', $message ); | ||
| 2348 | |||
| 2349 | # add the most recently selected program | ||
| 2350 | # name (scalar reference) to the | ||
| 2351 | # end of the list inside flow_listbox | ||
| 2352 | _local_set_flow_listbox_color_w($flow_color); # in "color"_flow namespace | ||
| 2353 | |||
| 2354 | # append new program names to the end of the list but this item is NOT selected | ||
| 2355 | # selection occurs inside conditions4flow (inheritance by gui_history) | ||
| 2356 | $color_flow_href->{_flow_listbox_color_w} | ||
| 2357 | ->insert( "end", ${ $color_flow_href->{_prog_name_sref} }, ); | ||
| 2358 | |||
| 2359 | # Display default paramters in the GUI, | ||
| 2360 | # as for sunix_select | ||
| 2361 | # Can not get program name from the item selected in the sunix list box | ||
| 2362 | # because focus is transferred to another list box | ||
| 2363 | |||
| 2364 | my $most_recent = | ||
| 2365 | ( ( $gui_history->get_defaults() )->{_flow_select_index_href} ) | ||
| 2366 | ->{_most_recent}; | ||
| 2367 | my $prior = | ||
| 2368 | ( ( $gui_history->get_defaults() )->{_flow_select_index_href} )->{_prior}; | ||
| 2369 | |||
| 2370 | # print("1. color_flow, add2flow_button, NO CHANGES within: prior_flow_index=$prior, most_recent=$most_recent\n"); | ||
| 2371 | |||
| 2372 | # print("1. color_flow, add2flow_button, print out gui_history\n"); | ||
| 2373 | # $gui_history->view(); | ||
| 2374 | |||
| 2375 | # TBD | ||
| 2376 | # if there is a deletion immediately before, the | ||
| 2377 | # indices for recent and prior should be reduced by -1 | ||
| 2378 | # the most recent value will be correct but | ||
| 2379 | # the prior and earliest will not | ||
| 2380 | # so always check that the prior value exists before using it | ||
| 2381 | |||
| 2382 | $param_sunix->set_program_name( $color_flow_href->{_prog_name_sref} ); | ||
| 2383 | $color_flow_href->{_names_aref} = $param_sunix->get_names(); | ||
| 2384 | $color_flow_href->{_values_aref} = $param_sunix->get_values(); | ||
| 2385 | $color_flow_href->{_check_buttons_settings_aref} = | ||
| 2386 | $param_sunix->get_check_buttons_settings(); | ||
| 2387 | $color_flow_href->{_param_sunix_first_idx} = | ||
| 2388 | $param_sunix->first_idx(); # first index = 0 | ||
| 2389 | $color_flow_href->{_first_idx} = | ||
| 2390 | $param_sunix->first_idx(); # first index = 0 | ||
| 2391 | |||
| 2392 | # print("color_flow,add2flow_button, check_buttons_settings_aref: @{$color_flow_href->{_check_buttons_settings_aref}}\n"); | ||
| 2393 | |||
| 2394 | $param_sunix->set_half_length(); | ||
| 2395 | |||
| 2396 | # values -- not #(values+labels) | ||
| 2397 | $color_flow_href->{_param_sunix_length} = $param_sunix->get_length(); | ||
| 2398 | |||
| 2399 | # widgets are initialized in a super class | ||
| 2400 | # Assign program parameters in the GUI | ||
| 2401 | $param_widgets->set_labels_w_aref( $color_flow_href->{_labels_w_aref} ); | ||
| 2402 | $param_widgets->set_values_w_aref( $color_flow_href->{_values_w_aref} ); | ||
| 2403 | $param_widgets->set_check_buttons_w_aref( | ||
| 2404 | $color_flow_href->{_check_buttons_w_aref} ); | ||
| 2405 | |||
| 2406 | # print(" 1. color_flow, add2flow_button, \n"); | ||
| 2407 | $param_widgets->range($color_flow_href); | ||
| 2408 | $param_widgets->set_labels( $color_flow_href->{_names_aref} ); | ||
| 2409 | $param_widgets->set_values( $color_flow_href->{_values_aref} ); | ||
| 2410 | $param_widgets->set_check_buttons( | ||
| 2411 | $color_flow_href->{_check_buttons_settings_aref} ); | ||
| 2412 | |||
| 2413 | $param_widgets->redisplay_labels(); | ||
| 2414 | $param_widgets->redisplay_values(); | ||
| 2415 | $param_widgets->redisplay_check_buttons(); | ||
| 2416 | |||
| 2417 | # Collect and store prog versions changed in list box | ||
| 2418 | _stack_versions(); | ||
| 2419 | |||
| 2420 | # Add a single_program to the growing stack | ||
| 2421 | # store one program name, its associated parameters and their values | ||
| 2422 | # as well as the checkbuttons settings (on or off) in another namespace | ||
| 2423 | _stack_flow(); | ||
| 2424 | |||
| 2425 | # print("color_flow,add2flow_button, after stack flow but before update\n"); | ||
| 2426 | # $param_flow_color_pkg->view_data(); | ||
| 2427 | |||
| 2428 | $gui_history->set_hash_ref($color_flow_href); | ||
| 2429 | |||
| 2430 | # last item added is highlighted and selected conditions4flows are inherited by gui_hsitory | ||
| 2431 | $gui_history->set4end_of_add2flow_button($flow_color); | ||
| 2432 | |||
| 2433 | my $flow_index = $flow_widgets->get_flow_selection( | ||
| 2434 | $color_flow_href->{_flow_listbox_color_w} ); | ||
| 2435 | |||
| 2436 | # done in conditions4flow, flow color is not reset | ||
| 2437 | $gui_history->set_flow_index_last_touched($flow_index); | ||
| 2438 | $color_flow_href = $gui_history->get_hash_ref(); | ||
| 2439 | |||
| 2440 | # switch between the correct index of the last parameter that was touched | ||
| 2441 | # as a function of the flow's color | ||
| 2442 | # These data are encapsulated | ||
| 2443 | $color_flow_href->{_last_parameter_index_touched_color} = 0; # initialize | ||
| 2444 | $color_flow_href->{$_is_last_parameter_index_touched_color} = $true; | ||
| 2445 | |||
| 2446 | # print("10 color_flow,add2flow_button, after stack flow AND after update, view param_flow data:\n"); | ||
| 2447 | # $param_flow_color_pkg->view_data(); | ||
| 2448 | |||
| 2449 | _flow_select_director('add2flow_button'); | ||
| 2450 | |||
| 2451 | # the following is also carried out in flow_select when pre_ok=true | ||
| 2452 | # $color_flow_href->{_last_flow_color} = $flow_color; | ||
| 2453 | return (); | ||
| 2454 | } | ||
| 2455 | |||
| 2456 | =head2 sub delete_from_flow_button | ||
| 2457 | |||
| 2458 | if flow_select was last clicked then | ||
| 2459 | $gui_history has already recorded the chosen flow color | ||
| 2460 | |||
| 2461 | my $flow_color = $gui_history->get_flow_color(); | ||
| 2462 | |||
| 2463 | =cut | ||
| 2464 | |||
| 2465 | sub delete_from_flow_button { | ||
| 2466 | |||
| 2467 | my ($self) = @_; | ||
| 2468 | |||
| 2469 | my $flow_color = | ||
| 2470 | ( $color_flow_href->{_flow_select_color_href} )->{_most_recent}; | ||
| 2471 | |||
| 2472 | if ($flow_color) { | ||
| 2473 | |||
| 2474 | _set_flow_color($flow_color); | ||
| 2475 | |||
| 2476 | my $message = $message_director->null_button(0); | ||
| 2477 | $message_w->delete( "1.0", 'end' ); | ||
| 2478 | $message_w->insert( 'end', $message ); | ||
| 2479 | |||
| 2480 | my $_flow_listbox_color_w = _get_flow_listbox_color_w(); | ||
| 2481 | |||
| 2482 | $gui_history->set_hash_ref($color_flow_href); | ||
| 2483 | $gui_history->set_defaults4start_of_delete_from_flow_button( | ||
| 2484 | $flow_color); | ||
| 2485 | $color_flow_href = $gui_history->get_hash_ref(); | ||
| 2486 | |||
| 2487 | $decisions->set4delete_from_flow_button($color_flow_href); | ||
| 2488 | my $pre_req_ok = $decisions->get4delete_from_flow_button(); | ||
| 2489 | |||
| 2490 | # confirm listboxes are active | ||
| 2491 | if ($pre_req_ok) { | ||
| 2492 | |||
| 2493 | # location within GUI on first clicking delete button | ||
| 2494 | # $gui_history->set_hash_ref($color_flow_href); | ||
| 2495 | |||
| 2496 | # flow_color is in 'color'_flow namespace | ||
| 2497 | my $index = | ||
| 2498 | $flow_widgets->get_flow_selection($_flow_listbox_color_w); | ||
| 2499 | |||
| 2500 | if ( $index == 0 | ||
| 2501 | and $param_flow_color_pkg->get_num_items() == 1 ) | ||
| 2502 | { | ||
| 2503 | |||
| 2504 | # CASE: LAST ITEM in listbox is deleted | ||
| 2505 | # extra checking includes verifying number of items | ||
| 2506 | |||
| 2507 | # For Run and Save button | ||
| 2508 | $flow_widgets->delete_selection($_flow_listbox_color_w); | ||
| 2509 | |||
| 2510 | # Blank out the names of the programs in the GUI | ||
| 2511 | _set_flow_name_color_w($flow_color); | ||
| 2512 | $flow_name_color_w->configure( -text => $var->{_clear_text} ); | ||
| 2513 | $color_flow_href->{_flowNsuperflow_name_w} | ||
| 2514 | ->configure( -text => $var->{_clear_text} ); | ||
| 2515 | |||
| 2516 | # delete stored programs and their parameters | ||
| 2517 | my $index2delete = $flow_widgets->get_index2delete(); | ||
| 2518 | |||
| 2519 | # delete_from_stored_flows(); | ||
| 2520 | $param_flow_color_pkg->delete_selection($index2delete); | ||
| 2521 | |||
| 2522 | # collect and store latest program versions from changed list | ||
| 2523 | # clear all the versions from the changed list | ||
| 2524 | _clear_stack_versions(); | ||
| 2525 | |||
| 2526 | $gui_history->set_hash_ref($color_flow_href); | ||
| 2527 | $gui_history->set_defaults4last_delete_from_flow_button(); | ||
| 2528 | $color_flow_href = $gui_history->get_hash_ref(); | ||
| 2529 | |||
| 2530 | # Blank out all the stored parameter values and names within param_flow | ||
| 2531 | $param_flow_color_pkg->clear(); | ||
| 2532 | |||
| 2533 | # clear the parameter values and labels from the gui | ||
| 2534 | # strange memory leak inside param_widgets | ||
| 2535 | my $save = | ||
| 2536 | clone( $color_flow_href->{_check_buttons_settings_aref} ); | ||
| 2537 | $param_widgets->gui_full_clear(); | ||
| 2538 | @{ $color_flow_href->{_check_buttons_settings_aref} } = @$save; | ||
| 2539 | |||
| 2540 | # reinitialize flow_select_count | ||
| 2541 | $gui_history->set_clear('delete_from_flow_button'); | ||
| 2542 | @{ $color_flow_href->{_occupied_listbox_aref} } | ||
| 2543 | [$_number_from_color] = $false; | ||
| 2544 | @{ $color_flow_href->{_vacant_listbox_aref} } | ||
| 2545 | [$_number_from_color] = $true; | ||
| 2546 | |||
| 2547 | # print("1.color_flow, delete_from_flow_button, \n | ||
| 2548 | # color_flow_href->{_occupied_listbox_aref}[_number_from_color]= $color_flow_href->{_occupied_listbox_aref}[$_number_from_color] | ||
| 2549 | # \n"); | ||
| 2550 | # print("1.color_flow, delete_from_flow_button, \n | ||
| 2551 | # color_flow_href->{_vacant_listbox_aref}[_number_from_color]= $color_flow_href->{_vacant_listbox_aref}[$_number_from_color] | ||
| 2552 | # \n"); | ||
| 2553 | # print("1. last item deleted Shut down delete button\n"); | ||
| 2554 | |||
| 2555 | } | ||
| 2556 | elsif ( $index > 0 ) { | ||
| 2557 | |||
| 2558 | # CASE more more than one item remains in a listbox (implied) | ||
| 2559 | # but selected index is not the first | ||
| 2560 | $flow_widgets->delete_selection($_flow_listbox_color_w); | ||
| 2561 | |||
| 2562 | # delete stored programs and their parameters | ||
| 2563 | # delete_from_stored_flows(); | ||
| 2564 | my $index2delete = $flow_widgets->get_index2delete(); | ||
| 2565 | |||
| 2566 | # print("2. color_flow deletefrom a stored flow,index2delete:$index2delete\n"); | ||
| 2567 | $param_flow_color_pkg->delete_selection($index2delete); | ||
| 2568 | |||
| 2569 | # keep track of flow selection clicks and colors | ||
| 2570 | $_flow_listbox_color_w->selectionSet( ( $index2delete - 1 ) ); | ||
| 2571 | $gui_history->set_flow_select_color($this_color); | ||
| 2572 | $gui_history->set_button('flow_select'); | ||
| 2573 | |||
| 2574 | # Update the widget parameter names and values | ||
| 2575 | # to those of new selection after deletion | ||
| 2576 | # Only the chkbuttons, values and names of the last program used | ||
| 2577 | # are stored in param_widgets at any one time | ||
| 2578 | # Get parameters from storage | ||
| 2579 | my $next_idx_selected_after_deletion = $index2delete - 1; | ||
| 2580 | if ( $next_idx_selected_after_deletion == -1 ) { | ||
| 2581 | $next_idx_selected_after_deletion = 0; | ||
| 2582 | } # NOT < 0 | ||
| 2583 | # $next_idx_selected_after_deletion\n"); | ||
| 2584 | |||
| 2585 | $param_flow_color_pkg->set_flow_index( | ||
| 2586 | $next_idx_selected_after_deletion); | ||
| 2587 | $color_flow_href->{_names_aref} = | ||
| 2588 | $param_flow_color_pkg->get_names_aref(); | ||
| 2589 | |||
| 2590 | $color_flow_href->{_values_aref} = | ||
| 2591 | $param_flow_color_pkg->get_values_aref(); | ||
| 2592 | |||
| 2593 | $color_flow_href->{_check_buttons_settings_aref} = | ||
| 2594 | $param_flow_color_pkg->get_check_buttons_settings(); | ||
| 2595 | |||
| 2596 | # get stored first index and num of items | ||
| 2597 | $color_flow_href->{_param_flow_first_idx} = | ||
| 2598 | $param_flow_color_pkg->first_idx(); | ||
| 2599 | $color_flow_href->{_param_flow_length} = | ||
| 2600 | $param_flow_color_pkg->length(); | ||
| 2601 | $color_flow_href->{_prog_name_sref} = | ||
| 2602 | $param_widgets->get_current_program( | ||
| 2603 | \$_flow_listbox_color_w ); | ||
| 2604 | $param_widgets->set_current_program( | ||
| 2605 | $color_flow_href->{_prog_name_sref} ); | ||
| 2606 | |||
| 2607 | $param_widgets->gui_full_clear(); # formerly gui_clean | ||
| 2608 | $param_widgets->range($color_flow_href); | ||
| 2609 | $param_widgets->set_labels( $color_flow_href->{_names_aref} ); | ||
| 2610 | $param_widgets->set_values( $color_flow_href->{_values_aref} ); | ||
| 2611 | $param_widgets->set_check_buttons( | ||
| 2612 | $color_flow_href->{_check_buttons_settings_aref} ); | ||
| 2613 | |||
| 2614 | $param_widgets->redisplay_labels(); | ||
| 2615 | $param_widgets->redisplay_values(); | ||
| 2616 | $param_widgets->redisplay_check_buttons(); | ||
| 2617 | |||
| 2618 | # collect and store latest program versions from changed list | ||
| 2619 | _stack_versions(); | ||
| 2620 | |||
| 2621 | } | ||
| 2622 | elsif ( $index == 0 | ||
| 2623 | and $param_flow_color_pkg->get_num_items() > 1 ) | ||
| 2624 | { | ||
| 2625 | |||
| 2626 | # CASE more than 1 item exists and selected index is first | ||
| 2627 | $flow_widgets->delete_selection($_flow_listbox_color_w); | ||
| 2628 | |||
| 2629 | # delete stored programs and their parameters | ||
| 2630 | # delete_from_stored_flows(); | ||
| 2631 | my $index2delete = $flow_widgets->get_index2delete(); | ||
| 2632 | |||
| 2633 | # print("2. color_flow delete_from_stored,index2delete:$index2delete\n"); | ||
| 2634 | $param_flow_color_pkg->delete_selection($index2delete); | ||
| 2635 | |||
| 2636 | # keep track of flow selection clicks and colors | ||
| 2637 | $_flow_listbox_color_w->selectionSet( ( $index2delete - 1 ) ); | ||
| 2638 | $gui_history->set_flow_select_color($this_color); | ||
| 2639 | $gui_history->set_button('flow_select'); | ||
| 2640 | |||
| 2641 | # Update the widget parameter names and values | ||
| 2642 | # to those of new selection after deletion | ||
| 2643 | # Only the chekbuttons, values and names of the last program used | ||
| 2644 | # are stored in param_widgets at any one time | ||
| 2645 | # Get parameters from storage | ||
| 2646 | my $next_idx_selected_after_deletion = $index2delete - 1; | ||
| 2647 | |||
| 2648 | # NOT < 0 | ||
| 2649 | # $next_idx_selected_after_deletion\n"); | ||
| 2650 | if ( $next_idx_selected_after_deletion == -1 ) { | ||
| 2651 | |||
| 2652 | $next_idx_selected_after_deletion = 0; | ||
| 2653 | } | ||
| 2654 | |||
| 2655 | $param_flow_color_pkg->set_flow_index( | ||
| 2656 | $next_idx_selected_after_deletion); | ||
| 2657 | $color_flow_href->{_names_aref} = | ||
| 2658 | $param_flow_color_pkg->get_names_aref(); | ||
| 2659 | |||
| 2660 | $color_flow_href->{_values_aref} = | ||
| 2661 | $param_flow_color_pkg->get_values_aref(); | ||
| 2662 | |||
| 2663 | $color_flow_href->{_check_buttons_settings_aref} = | ||
| 2664 | $param_flow_color_pkg->get_check_buttons_settings(); | ||
| 2665 | |||
| 2666 | # get stored first index and num of items | ||
| 2667 | $color_flow_href->{_param_flow_first_idx} = | ||
| 2668 | $param_flow_color_pkg->first_idx(); | ||
| 2669 | $color_flow_href->{_param_flow_length} = | ||
| 2670 | $param_flow_color_pkg->length(); | ||
| 2671 | $color_flow_href->{_prog_name_sref} = | ||
| 2672 | $param_widgets->get_current_program( | ||
| 2673 | \$_flow_listbox_color_w ); | ||
| 2674 | $param_widgets->set_current_program( | ||
| 2675 | $color_flow_href->{_prog_name_sref} ); | ||
| 2676 | |||
| 2677 | #print(" 2. color_flow, delete_from-flow_button \n"); | ||
| 2678 | $param_widgets->gui_full_clear(); # formerly gui_clean | ||
| 2679 | $param_widgets->range($color_flow_href); | ||
| 2680 | $param_widgets->set_labels( $color_flow_href->{_names_aref} ); | ||
| 2681 | $param_widgets->set_values( $color_flow_href->{_values_aref} ); | ||
| 2682 | $param_widgets->set_check_buttons( | ||
| 2683 | $color_flow_href->{_check_buttons_settings_aref} ); | ||
| 2684 | |||
| 2685 | $param_widgets->redisplay_labels(); | ||
| 2686 | $param_widgets->redisplay_values(); | ||
| 2687 | $param_widgets->redisplay_check_buttons(); | ||
| 2688 | |||
| 2689 | # collect and store latest program versions from changed list | ||
| 2690 | _stack_versions(); | ||
| 2691 | |||
| 2692 | } | ||
| 2693 | else { | ||
| 2694 | print("color_flow, delete_fro_flow_button unexpected result\n"); | ||
| 2695 | } | ||
| 2696 | } # if pre_req_ok | ||
| 2697 | |||
| 2698 | } | ||
| 2699 | else { # if flow_color | ||
| 2700 | print("color_flow, delete_from_flow_button, flow color missing: \n"); | ||
| 2701 | } | ||
| 2702 | |||
| 2703 | # print("color_flow, END delete_from_flow_button, print gui_history.txt\n"); | ||
| 2704 | # $gui_history->view(); | ||
| 2705 | } | ||
| 2706 | |||
| 2707 | =head2 sub delete_whole_flow_button | ||
| 2708 | |||
| 2709 | If flow_select was last clicked then | ||
| 2710 | $gui_history has already recorded the chosen flow color | ||
| 2711 | |||
| 2712 | =cut | ||
| 2713 | |||
| 2714 | sub delete_whole_flow_button { | ||
| 2715 | |||
| 2716 | my ($self) = @_; | ||
| 2717 | |||
| 2718 | my $flow_color = | ||
| 2719 | ( $color_flow_href->{_flow_select_color_href} )->{_most_recent}; | ||
| 2720 | |||
| 2721 | # print(" START color_flow, delete_whole_flow_button, \n"); | ||
| 2722 | # print("color_flow, delete_whole_flow_button, print gui_history.txt\n"); | ||
| 2723 | # $gui_history->view(); | ||
| 2724 | |||
| 2725 | if ($flow_color) { | ||
| 2726 | |||
| 2727 | _set_flow_color($flow_color); | ||
| 2728 | |||
| 2729 | my $message = $message_director->null_button(0); | ||
| 2730 | $message_w->delete( "1.0", 'end' ); | ||
| 2731 | $message_w->insert( 'end', $message ); | ||
| 2732 | |||
| 2733 | my $_flow_listbox_color_w = _get_flow_listbox_color_w(); | ||
| 2734 | |||
| 2735 | $gui_history->set_hash_ref($color_flow_href); | ||
| 2736 | $gui_history->set_defaults4start_of_delete_whole_flow_button( | ||
| 2737 | $flow_color); | ||
| 2738 | $color_flow_href = $gui_history->get_hash_ref(); | ||
| 2739 | $decisions->set4delete_whole_flow_button($color_flow_href); | ||
| 2740 | my $pre_req_ok = $decisions->get4delete_whole_flow_button(); | ||
| 2741 | |||
| 2742 | # confirm listboxes are active | ||
| 2743 | if ($pre_req_ok) { | ||
| 2744 | |||
| 2745 | # flow_color is in 'color'_flow namespace | ||
| 2746 | # index is the currently selected | ||
| 2747 | my $index = | ||
| 2748 | $flow_widgets->get_flow_selection($_flow_listbox_color_w); | ||
| 2749 | |||
| 2750 | # print("color_flow, delete_whole_flow_button index=$index\n"); | ||
| 2751 | |||
| 2752 | if ( $index >= 0 | ||
| 2753 | and $param_flow_color_pkg->get_num_items() >= 1 ) | ||
| 2754 | { | ||
| 2755 | |||
| 2756 | # CASE: DELETE ALL ITEMS in listbox | ||
| 2757 | # extra checking includes verifying number of items | ||
| 2758 | # For Run and Save button | ||
| 2759 | $flow_widgets->clear($_flow_listbox_color_w); | ||
| 2760 | |||
| 2761 | # Blank out the names of the programs in the GUI | ||
| 2762 | _set_flow_name_color_w($flow_color); | ||
| 2763 | $flow_name_color_w->configure( -text => $var->{_clear_text} ); | ||
| 2764 | $color_flow_href->{_flowNsuperflow_name_w} | ||
| 2765 | ->configure( -text => $var->{_clear_text} ); | ||
| 2766 | |||
| 2767 | # delete stored programs and all the stored flow parameters | ||
| 2768 | my $index2delete = 'all'; | ||
| 2769 | $param_flow_color_pkg->delete_selection($index2delete); | ||
| 2770 | |||
| 2771 | # Blank out all the stored parameter values and names within param_flow | ||
| 2772 | $param_flow_color_pkg->clear(); | ||
| 2773 | |||
| 2774 | $gui_history->set_hash_ref($color_flow_href); | ||
| 2775 | $gui_history->set_defaults4end_of_delete_whole_flow_button(); | ||
| 2776 | $color_flow_href = $gui_history->get_hash_ref(); | ||
| 2777 | |||
| 2778 | # Blank out all the stored parameter values and names within param_flow | ||
| 2779 | $param_flow_color_pkg->clear(); | ||
| 2780 | |||
| 2781 | # print("5. whole flow deleted Shut down delete button\n"); | ||
| 2782 | # clear the parameter values and labels from the gui | ||
| 2783 | # strange memory leak inside param_widgets | ||
| 2784 | my $save = | ||
| 2785 | clone( $color_flow_href->{_check_buttons_settings_aref} ); | ||
| 2786 | $param_widgets->gui_full_clear(); | ||
| 2787 | @{ $color_flow_href->{_check_buttons_settings_aref} } = @$save; | ||
| 2788 | |||
| 2789 | # reinitialize flow_select_count | ||
| 2790 | $gui_history->set_clear('delete_whole_flow_button'); | ||
| 2791 | |||
| 2792 | } | ||
| 2793 | else { | ||
| 2794 | print( | ||
| 2795 | "color_flow, delete_whole_flow_button unexpected result\n"); | ||
| 2796 | } # index is >= 0 | ||
| 2797 | |||
| 2798 | } # if pre_req_ok | ||
| 2799 | |||
| 2800 | } | ||
| 2801 | else { # if flow_color | ||
| 2802 | print("color_flow, delete_whole_flow_button, flow color missing: \n"); | ||
| 2803 | } | ||
| 2804 | |||
| 2805 | } | ||
| 2806 | |||
| 2807 | =head2 sub flow_item_down_arrow_button | ||
| 2808 | |||
| 2809 | move items down in a flow listbox | ||
| 2810 | |||
| 2811 | =cut | ||
| 2812 | |||
| 2813 | sub flow_item_down_arrow_button { | ||
| 2814 | |||
| 2815 | my ($self) = @_; | ||
| 2816 | my $prog_name; | ||
| 2817 | |||
| 2818 | if ($flow_color) { | ||
| 2819 | |||
| 2820 | _set_flow_color($flow_color); | ||
| 2821 | |||
| 2822 | # $conditions_gui->set4start_of_flow_item_down_arrow_button($color_flow_href); | ||
| 2823 | |||
| 2824 | my $message = $message_director->null_button(0); | ||
| 2825 | $message_w->delete( "1.0", 'end' ); | ||
| 2826 | $message_w->insert( 'end', $message ); | ||
| 2827 | |||
| 2828 | $prog_name = ${ $color_flow_href->{_prog_name_sref} }; | ||
| 2829 | |||
| 2830 | # get number of items in the flow listbox | ||
| 2831 | my $_flow_listbox_color_w = | ||
| 2832 | _get_flow_listbox_color_w(); # user-built_flow in current use | ||
| 2833 | my $num_items = $flow_widgets->get_num_items($_flow_listbox_color_w); | ||
| 2834 | |||
| 2835 | # get the current index | ||
| 2836 | my $current_flow_listbox_index = | ||
| 2837 | $flow_widgets->get_flow_selection($_flow_listbox_color_w); | ||
| 2838 | |||
| 2839 | # the destination index will be one more | ||
| 2840 | my $destination_index = $current_flow_listbox_index + 1; | ||
| 2841 | |||
| 2842 | # limit max index | ||
| 2843 | if ( $destination_index >= $num_items ) { | ||
| 2844 | $destination_index = $num_items - 1; | ||
| 2845 | } | ||
| 2846 | |||
| 2847 | # MEET THESE conditions, OR do NOTHING | ||
| 2848 | if ( $prog_name | ||
| 2849 | && ( $current_flow_listbox_index >= 0 ) | ||
| 2850 | && $destination_index < $num_items ) | ||
| 2851 | { | ||
| 2852 | |||
| 2853 | $color_flow_href->{_index2move} = $current_flow_listbox_index; | ||
| 2854 | $color_flow_href->{_destination_index} = $destination_index; | ||
| 2855 | |||
| 2856 | # get all the elements from inside the listbox | ||
| 2857 | my @elements = $_flow_listbox_color_w->get( 0, 'end' ); | ||
| 2858 | |||
| 2859 | # rearrange elements | ||
| 2860 | my $saved_item = $elements[ $color_flow_href->{_index2move} ]; | ||
| 2861 | |||
| 2862 | $color_flow_href->{_flow_listbox_color_w} | ||
| 2863 | ->delete( $color_flow_href->{_index2move} ); | ||
| 2864 | $color_flow_href->{_flow_listbox_color_w} | ||
| 2865 | ->insert( $color_flow_href->{_destination_index}, $saved_item ); | ||
| 2866 | $color_flow_href->{_flow_listbox_color_w} | ||
| 2867 | ->selectionSet( $color_flow_href->{_destination_index} ); | ||
| 2868 | |||
| 2869 | # note the last program that was touched | ||
| 2870 | # $color_flow_href->{_last_flow_index_touched} = | ||
| 2871 | # $color_flow_href->{_destination_index}; | ||
| 2872 | # $color_flow_href->{$_is_last_flow_index_touched_color} = $true; | ||
| 2873 | |||
| 2874 | # move stored data within arrays | ||
| 2875 | my $start = $color_flow_href->{_index2move}; | ||
| 2876 | my $end = $color_flow_href->{_destination_index}; | ||
| 2877 | |||
| 2878 | $param_flow_color_pkg->set_insert_start($start); | ||
| 2879 | $param_flow_color_pkg->set_insert_end($end); | ||
| 2880 | $param_flow_color_pkg->insert_selection(); | ||
| 2881 | |||
| 2882 | # update program versions if listbox changes | ||
| 2883 | # stored in param_flows | ||
| 2884 | _stack_versions(); | ||
| 2885 | |||
| 2886 | # update the parameter widget labels and their values | ||
| 2887 | |||
| 2888 | # highlight new index | ||
| 2889 | _local_set_flow_listbox_color_w($flow_color) | ||
| 2890 | ; # in "color"_flow namespace | ||
| 2891 | $_flow_listbox_color_w->selectionSet( | ||
| 2892 | $color_flow_href->{_destination_index}, ); | ||
| 2893 | |||
| 2894 | # carry out all gui updates needed | ||
| 2895 | # keep track of flow_selection clicks | ||
| 2896 | _flow_select_director('flow_item_down_arrow_button'); | ||
| 2897 | |||
| 2898 | } | ||
| 2899 | else { | ||
| 2900 | print( | ||
| 2901 | "color_flow, flow_item_down_arrow_button missing program or bad index\n" | ||
| 2902 | ); | ||
| 2903 | } | ||
| 2904 | |||
| 2905 | } | ||
| 2906 | else { | ||
| 2907 | print("color_flow, flow_item_down_arrow_button missing color \n"); | ||
| 2908 | } | ||
| 2909 | |||
| 2910 | } | ||
| 2911 | |||
| 2912 | =head2 sub flow_item_up_arrow_button | ||
| 2913 | |||
| 2914 | move items up in a flow listbox | ||
| 2915 | |||
| 2916 | =cut | ||
| 2917 | |||
| 2918 | sub flow_item_up_arrow_button { | ||
| 2919 | |||
| 2920 | my ($self) = @_; | ||
| 2921 | my $prog_name; | ||
| 2922 | |||
| 2923 | if ($flow_color) { | ||
| 2924 | |||
| 2925 | _set_flow_color($flow_color); | ||
| 2926 | |||
| 2927 | # $conditions_gui->set4start_of_flow_item_up_arrow_button($color_flow_href); | ||
| 2928 | |||
| 2929 | my $message = $message_director->null_button(0); | ||
| 2930 | $message_w->delete( "1.0", 'end' ); | ||
| 2931 | $message_w->insert( 'end', $message ); | ||
| 2932 | |||
| 2933 | $prog_name = ${ $color_flow_href->{_prog_name_sref} }; | ||
| 2934 | |||
| 2935 | # get number of items in the flow listbox | ||
| 2936 | my $_flow_listbox_color_w = | ||
| 2937 | _get_flow_listbox_color_w(); # user-built_flow in current use | ||
| 2938 | my $num_items = $flow_widgets->get_num_items($_flow_listbox_color_w); | ||
| 2939 | |||
| 2940 | # get the current index | ||
| 2941 | my $current_flow_listbox_index = | ||
| 2942 | $flow_widgets->get_flow_selection($_flow_listbox_color_w); | ||
| 2943 | |||
| 2944 | # the destination index will be one less | ||
| 2945 | my $destination_index = $current_flow_listbox_index - 1; | ||
| 2946 | if ( $destination_index <= 0 ) { | ||
| 2947 | $destination_index = 0; | ||
| 2948 | } # limit min index | ||
| 2949 | |||
| 2950 | # MEET THESE conditions, OR do NOTHING | ||
| 2951 | if ( $prog_name | ||
| 2952 | && ( $current_flow_listbox_index > 0 ) | ||
| 2953 | && $destination_index >= 0 ) | ||
| 2954 | { | ||
| 2955 | |||
| 2956 | $color_flow_href->{_index2move} = $current_flow_listbox_index; | ||
| 2957 | $color_flow_href->{_destination_index} = $destination_index; | ||
| 2958 | |||
| 2959 | # note the last program that was touched | ||
| 2960 | # $color_flow_href->{_last_flow_index_touched} = | ||
| 2961 | # $color_flow_href->{_destination_index}; | ||
| 2962 | # $color_flow_href->{$_is_last_flow_index_touched_color} = $true; | ||
| 2963 | |||
| 2964 | # get all the elements from inside the listbox | ||
| 2965 | my @elements = $_flow_listbox_color_w->get( 0, 'end' ); | ||
| 2966 | |||
| 2967 | # rearrange elements | ||
| 2968 | my $saved_item = $elements[ $color_flow_href->{_index2move} ]; | ||
| 2969 | |||
| 2970 | $color_flow_href->{_flow_listbox_color_w} | ||
| 2971 | ->delete( $color_flow_href->{_index2move} ); | ||
| 2972 | $color_flow_href->{_flow_listbox_color_w} | ||
| 2973 | ->insert( $color_flow_href->{_destination_index}, $saved_item ); | ||
| 2974 | $color_flow_href->{_flow_listbox_color_w} | ||
| 2975 | ->selectionSet( $color_flow_href->{_destination_index} ); | ||
| 2976 | |||
| 2977 | # note the last program that was touched | ||
| 2978 | # $color_flow_href->{_last_flow_index_touched} = | ||
| 2979 | # $color_flow_href->{_destination_index}; | ||
| 2980 | # $color_flow_href->{$_is_last_flow_index_touched_color} = $true; | ||
| 2981 | |||
| 2982 | # move stored data within arrays | ||
| 2983 | my $start = $color_flow_href->{_index2move}; | ||
| 2984 | my $end = $color_flow_href->{_destination_index}; | ||
| 2985 | |||
| 2986 | $param_flow_color_pkg->set_insert_start($start); | ||
| 2987 | $param_flow_color_pkg->set_insert_end($end); | ||
| 2988 | $param_flow_color_pkg->insert_selection(); | ||
| 2989 | |||
| 2990 | # update program versions if listbox changes | ||
| 2991 | # stored in param_flows | ||
| 2992 | _stack_versions(); | ||
| 2993 | |||
| 2994 | # highlight new index | ||
| 2995 | $_flow_listbox_color_w->selectionSet( | ||
| 2996 | $color_flow_href->{_destination_index}, ); | ||
| 2997 | |||
| 2998 | # carry out all gui updates needed | ||
| 2999 | # keep track of flow_selection clicks | ||
| 3000 | _flow_select_director('flow_item_up_arrow_button'); | ||
| 3001 | |||
| 3002 | } | ||
| 3003 | else { | ||
| 3004 | } | ||
| 3005 | |||
| 3006 | } | ||
| 3007 | else { | ||
| 3008 | print("color_flow, flow_item_up_arrow_button missing color \n"); | ||
| 3009 | } | ||
| 3010 | |||
| 3011 | } | ||
| 3012 | |||
| 3013 | =head2 sub flow_select | ||
| 3014 | |||
| 3015 | Pick a Seismic Unix module | ||
| 3016 | from within a (colored) flow listbox | ||
| 3017 | |||
| 3018 | Always takes focus on first entry ; index = 0 | ||
| 3019 | If focus is on first entry then also make the | ||
| 3020 | $color_flow_href->{_last_parameter_index_touched_color} =0 | ||
| 3021 | |||
| 3022 | print(" flow_select, view stored param flow data before update of prior\n"); | ||
| 3023 | $param_flow_color_pkg->view_data(); | ||
| 3024 | my $ans = @{$color_flow_href->{_values_w_aref}}[0]->get; | ||
| 3025 | |||
| 3026 | print("color_flow,flow_select, print gui_history\n"); | ||
| 3027 | $gui_history->view(); | ||
| 3028 | |||
| 3029 | print("12color_flow, flow_select, extract saved values\n"); | ||
| 3030 | $param_flow_color_pkg->view_data(); | ||
| 3031 | |||
| 3032 | print( | ||
| 3033 | "1 color_flow, flow_select, num_items_in_flow =$num_items_in_flow\n" | ||
| 3034 | ); | ||
| 3035 | print( | ||
| 3036 | "1 color_flow, flow_select, max_index_in_flow =$max_index_in_flow\n" | ||
| 3037 | ); | ||
| 3038 | print( | ||
| 3039 | "1 color_flow, flow_select, most_recent_flow_index =$most_recent_flow_index\n" | ||
| 3040 | ); | ||
| 3041 | print( | ||
| 3042 | "1 color_flow, flow_select, last_flow_color=$last_flow_color\n"); | ||
| 3043 | |||
| 3044 | print( | ||
| 3045 | "2 color_flow, flow_select, num_items_in_flow =$num_items_in_flow\n" | ||
| 3046 | ); | ||
| 3047 | print( | ||
| 3048 | "2 color_flow, flow_select, max_index_in_flow =$max_index_in_flow\n" | ||
| 3049 | ); | ||
| 3050 | print( | ||
| 3051 | "2 color_flow, flow_select, most_recent_flow_index =$most_recent_flow_index\n" | ||
| 3052 | ); | ||
| 3053 | # $gui_history->set_file_status($num_items_in_flow); | ||
| 3054 | # gets click count? | ||
| 3055 | my $file_status = $gui_history->get_file_status(); | ||
| 3056 | print( "3131 color_flow,flow_select,file_status,num_items_in_flow, last flow color:\n"); | ||
| 3057 | print( "$file_status,$num_items_in_flow,$last_flow_color \n"); | ||
| 3058 | |||
| 3059 | $aref = $param_flow_color_pkg->get_values_aref(); | ||
| 3060 | print("11a.color_flow,flow_select, values:@{$aref}\n"); | ||
| 3061 | |||
| 3062 | |||
| 3063 | =cut | ||
| 3064 | |||
| 3065 | sub flow_select { | ||
| 3066 | my ($self) = @_; | ||
| 3067 | |||
| 3068 | # --- Phase 0: Initialize state and UI --- | ||
| 3069 | # Set flow type to user-built and sync current color into history | ||
| 3070 | $color_flow_href->{_flow_type} = $flow_type->{_user_built}; | ||
| 3071 | |||
| 3072 | # reset residual flow_listbox_color_w of another color | ||
| 3073 | # flow_color exists in current (color_flow) namespace | ||
| 3074 | _local_set_flow_listbox_color_w($flow_color); | ||
| 3075 | $gui_history->set_flow_select_color($flow_color); | ||
| 3076 | |||
| 3077 | # Reset message panel | ||
| 3078 | my $message = $message_director->null_button(0); | ||
| 3079 | $message_w->delete( "1.0", 'end' ); | ||
| 3080 | $message_w->insert( 'end', $message ); | ||
| 3081 | |||
| 3082 | # Share current hash state with gui_history and apply defaults | ||
| 3083 | $gui_history->set_hash_ref($color_flow_href); | ||
| 3084 | $gui_history->set_defaults_4start_of_flow_select($flow_color); | ||
| 3085 | $color_flow_href = $gui_history->get_hash_ref(); | ||
| 3086 | |||
| 3087 | # Determine the selected program from current color listbox | ||
| 3088 | my $_flow_listbox_color_w = _get_flow_listbox_color_w(); | ||
| 3089 | $color_flow_href->{_prog_name_sref} = | ||
| 3090 | $flow_widgets->get_current_program( \$_flow_listbox_color_w ); | ||
| 3091 | |||
| 3092 | # Guard: prerequisites must pass before continuing | ||
| 3093 | $decisions->set_hash_ref($color_flow_href); | ||
| 3094 | my $pre_req_ok = $decisions->get4flow_select(); | ||
| 3095 | return () unless $pre_req_ok; | ||
| 3096 | |||
| 3097 | # --- Phase 1: Snapshot defaults / history once --- | ||
| 3098 | my $binding = binding->new(); | ||
| 3099 | $gui_history->set_button('flow_select'); | ||
| 3100 | |||
| 3101 | my $defaults = $gui_history->get_defaults; | ||
| 3102 | my $prior_flow_type = $defaults->{_flow_type_href}->{_prior}; | ||
| 3103 | |||
| 3104 | my $prior_flow_select_color = $defaults->{_flow_select_color_href}->{_prior}; | ||
| 3105 | my $most_recent_flow_select_color = $defaults->{_flow_select_color_href}->{_most_recent}; | ||
| 3106 | |||
| 3107 | my $most_recent_flow_index_touched = $color_flow_href->{_flow_select_index_href}->{_most_recent}; | ||
| 3108 | my $max_saved_widget_index = scalar @save_last_param_widget_values; | ||
| 3109 | |||
| 3110 | # print("3100. color_flow, flow_select, print out gui_history\n"); | ||
| 3111 | # $gui_history->view(); | ||
| 3112 | |||
| 3113 | # --- Phase 2: Handle prior-state cases (1–4) --- | ||
| 3114 | # ========================================================== | ||
| 3115 | # CASE 1 Last click inside same-colored, user-built flow | ||
| 3116 | # Consider prior flow-color changes | ||
| 3117 | # that have been made to param_widgets but not updated | ||
| 3118 | # Unticked strings from GUI are corrected here | ||
| 3119 | # ========================================================== | ||
| 3120 | |||
| 3121 | if ( $prior_flow_type eq $flow_type->{_user_built} | ||
| 3122 | and $most_recent_flow_select_color eq $prior_flow_select_color ) { | ||
| 3123 | |||
| 3124 | # CASE 1: Last click inside same-colored, user-built flow | ||
| 3125 | _update_prior_param_flow(); | ||
| 3126 | |||
| 3127 | # find which flow index is selected | ||
| 3128 | my $num_items_in_flow = $param_flow_color_pkg->get_num_items(); | ||
| 3129 | my $max_index_in_flow = $num_items_in_flow - 1; | ||
| 3130 | $last_flow_color = $color_flow_href->{_last_flow_color}; | ||
| 3131 | |||
| 3132 | # Memory-correction logic only if not already fixed | ||
| 3133 | if ( not $memory_leak4flow_select_fixed ) { | ||
| 3134 | |||
| 3135 | if ( ( $this_color eq $last_flow_color ) | ||
| 3136 | && $most_recent_flow_index_touched == $max_index_in_flow ) | ||
| 3137 | { | ||
| 3138 | # CASE 1A- NO memory correction needed | ||
| 3139 | # Last selected index was last in program | ||
| 3140 | # List and last color flow is the same as this color flow | ||
| 3141 | # e.g., just loaded a new flow and user clicks on last program | ||
| 3142 | # in flow | ||
| 3143 | $param_widgets->set_values(\@save_last_param_widget_values ); | ||
| 3144 | $param_flow_color_pkg->set_flow_index($most_recent_flow_index_touched); | ||
| 3145 | $param_flow_color_pkg->set_values_aref(\@save_last_param_widget_values ); | ||
| 3146 | |||
| 3147 | } elsif ( ( $this_color eq $last_flow_color ) | ||
| 3148 | && $most_recent_flow_index_touched < $max_index_in_flow | ||
| 3149 | ) | ||
| 3150 | |||
| 3151 | { | ||
| 3152 | # CASE 1B Fix memory loss when reselecting earlier index | ||
| 3153 | # When last selected index was last in program | ||
| 3154 | # list, last color flow is the same as this color flow | ||
| 3155 | # but index of current program is less than the last index | ||
| 3156 | # of the last program in the flow | ||
| 3157 | |||
| 3158 | $param_flow_color_pkg->set_flow_index($max_index_in_flow); | ||
| 3159 | my $last_param_flow_values_w_strings_aref = $control->get_string_or_number4aref( | ||
| 3160 | \@save_last_param_widget_values ); | ||
| 3161 | |||
| 3162 | $param_flow_color_pkg->set_values_aref($last_param_flow_values_w_strings_aref); | ||
| 3163 | |||
| 3164 | } # end of memory leak solution for flow_select | ||
| 3165 | |||
| 3166 | $memory_leak4flow_select_fixed = $false; | ||
| 3167 | # print("3157 color_flow, flow_select, last click in same colored flow\n"); | ||
| 3168 | } | ||
| 3169 | } | ||
| 3170 | elsif ( $prior_flow_type eq $flow_type->{_user_built} | ||
| 3171 | and $most_recent_flow_select_color ne $prior_flow_select_color ) { | ||
| 3172 | |||
| 3173 | # CASE 2: User-built, different colored flow | ||
| 3174 | print("3164 color_flow, flow_select, last click in different color flow; NADA\n");} | ||
| 3175 | |||
| 3176 | elsif ( $prior_flow_type eq $flow_type->{_pre_built_superflow} | ||
| 3177 | and $most_recent_flow_select_color ne $prior_flow_select_color ){ | ||
| 3178 | |||
| 3179 | # CASE 3: Pre-built superflow, and a different colored flow | ||
| 3180 | print("3170 color_flow, flow_select, last click in different color flow; NADA\n"); | ||
| 3181 | print("3171 color_flow, flow_select, last click was a superflow\n"); | ||
| 3182 | |||
| 3183 | } elsif ( $prior_flow_type eq $flow_type->{_pre_built_superflow} | ||
| 3184 | and $most_recent_flow_select_color eq $prior_flow_select_color ) { | ||
| 3185 | |||
| 3186 | # CASE 4: Pre-built superflow, and SAME colored flow | ||
| 3187 | # Highlight last index | ||
| 3188 | $gui_history->set4superflow2user_flow_transition($flow_color); | ||
| 3189 | } | ||
| 3190 | else { | ||
| 3191 | # CASE 5: Undetermined | ||
| 3192 | print("3184 color_flow, flow_select, undetermined NADA\n"); | ||
| 3193 | } | ||
| 3194 | |||
| 3195 | # --- Phase 3: Update widget & GUI states | ||
| 3196 | |||
| 3197 | # Current selection index in color flow listbox | ||
| 3198 | my $index = $flow_widgets->get_flow_selection($_flow_listbox_color_w); | ||
| 3199 | |||
| 3200 | # Extract saved values and labels for the current selection | ||
| 3201 | $param_flow_color_pkg->set_flow_index($most_recent_flow_index_touched); | ||
| 3202 | $color_flow_href->{_names_aref} = $param_flow_color_pkg->get_names_aref(); | ||
| 3203 | $color_flow_href->{_values_aref} = $param_flow_color_pkg->get_values_aref(); | ||
| 3204 | |||
| 3205 | $color_flow_href->{_check_buttons_settings_aref} = $param_flow_color_pkg->get_check_buttons_settings(); | ||
| 3206 | |||
| 3207 | # Get stored first index and num of items | ||
| 3208 | $color_flow_href->{_param_flow_first_idx} = $param_flow_color_pkg->first_idx(); | ||
| 3209 | $color_flow_href->{_param_flow_length} = | ||
| 3210 | $param_flow_color_pkg->length(); | ||
| 3211 | |||
| 3212 | $param_widgets->set_current_program($color_flow_href->{_prog_name_sref} ); | ||
| 3213 | |||
| 3214 | # Widgets were initialized in super class | ||
| 3215 | # Prepare to update gui by assigning widgets | ||
| 3216 | # TODO are the next 3 lines needed now that we share gui_history? | ||
| 3217 | $param_widgets->set_labels_w_aref( $color_flow_href->{_labels_w_aref} ); | ||
| 3218 | $param_widgets->set_values_w_aref( $color_flow_href->{_values_w_aref} ); | ||
| 3219 | $param_widgets->set_check_buttons_w_aref($color_flow_href->{_check_buttons_w_aref} ); | ||
| 3220 | |||
| 3221 | $color_flow_href->{_prog_name_sref} = | ||
| 3222 | $flow_widgets->get_current_program( \$_flow_listbox_color_w ); | ||
| 3223 | |||
| 3224 | # Wipe out values labels and checkbuttons from GUI for a fresh redraw | ||
| 3225 | $param_widgets->range($color_flow_href); | ||
| 3226 | |||
| 3227 | # Workaround for "strange memory leak" in param_widgets | ||
| 3228 | my $save = clone( $color_flow_href->{_check_buttons_settings_aref} ); | ||
| 3229 | $param_widgets->gui_full_clear(); | ||
| 3230 | @{ $color_flow_href->{_check_buttons_settings_aref} } = @$save; | ||
| 3231 | |||
| 3232 | # Push data back into widgets and redraw | ||
| 3233 | $param_widgets->set_labels( $color_flow_href->{_names_aref} ); | ||
| 3234 | $param_widgets->set_values( $color_flow_href->{_values_aref} ); | ||
| 3235 | $param_widgets->set_check_buttons( | ||
| 3236 | $color_flow_href->{_check_buttons_settings_aref} ); | ||
| 3237 | $param_widgets->redisplay_labels(); | ||
| 3238 | $param_widgets->redisplay_values(); | ||
| 3239 | $param_widgets->redisplay_check_buttons(); | ||
| 3240 | $param_widgets->set_entry_change_status($false); | ||
| 3241 | |||
| 3242 | # unxpectedly Entry focus is delayed until the end of this method before | ||
| 3243 | # completion; | ||
| 3244 | # that is we get to gui_history->view before we can update the focus | ||
| 3245 | # mysterious!!!!! | ||
| 3246 | |||
| 3247 | # Focus first entry widget (index 0) | ||
| 3248 | $param_widgets->set_focus_on_Entry_w(0); | ||
| 3249 | |||
| 3250 | # Here is where you rebind the different buttons depending on the | ||
| 3251 | # program name that is selected (i.e., through spec.pm) | ||
| 3252 | $binding->set_prog_name_sref( $color_flow_href->{_prog_name_sref} ); | ||
| 3253 | $binding->set_values_w_aref( $param_widgets->get_values_w_aref ); | ||
| 3254 | |||
| 3255 | # Bind MB3 click to reference to a local subroutine | ||
| 3256 | $binding->setFileDialog_button_sub_ref( \&_FileDialog_button ); | ||
| 3257 | $binding->set(); | ||
| 3258 | $gui_history->set_hash_ref($color_flow_href); | ||
| 3259 | $gui_history->set4end_of_flow_select($flow_color); | ||
| 3260 | $gui_history->set_flow_index_last_touched($index); | ||
| 3261 | $color_flow_href = $gui_history->get_hash_ref(); | ||
| 3262 | |||
| 3263 | # Update thre entry button value displaying currently active | ||
| 3264 | # flow or superflow name. Use currently selected program name from the flow list | ||
| 3265 | # e.g. data_in, suximage, suxgraph etc. | ||
| 3266 | ( $color_flow_href->{_flowNsuperflow_name_w} ) | ||
| 3267 | ->configure( -text => ${ $color_flow_href->{_prog_name_sref} } ); | ||
| 3268 | |||
| 3269 | # needed in possible export via get_hash_ref to help | ||
| 3270 | my $prog_name_sref = $color_flow_href->{_prog_name_sref}; | ||
| 3271 | |||
| 3272 | return (); | ||
| 3273 | } | ||
| 3274 | |||
| 3275 | =head2 sub get_Flow_file_exists | ||
| 3276 | |||
| 3277 | =cut | ||
| 3278 | |||
| 3279 | sub get_Flow_file_exists { | ||
| 3280 | my ($self) = @_; | ||
| 3281 | my $result = $empty_string; | ||
| 3282 | |||
| 3283 | if ( length $color_flow->{_Flow_file_exists} ) { | ||
| 3284 | |||
| 3285 | $result = $color_flow->{_Flow_file_exists}; | ||
| 3286 | return ($result); | ||
| 3287 | |||
| 3288 | } | ||
| 3289 | else { | ||
| 3290 | print(" color_flow, get_Flow_file_exists, missing variable value\n"); | ||
| 3291 | return ($result); | ||
| 3292 | } | ||
| 3293 | |||
| 3294 | } | ||
| 3295 | |||
| 3296 | =head2 sub get_hash_ref | ||
| 3297 | exports private hash | ||
| 3298 | |||
| 3299 | =cut | ||
| 3300 | |||
| 3301 | sub get_hash_ref { | ||
| 3302 | my ($self) = @_; | ||
| 3303 | |||
| 3304 | return ($color_flow_href); | ||
| 3305 | |||
| 3306 | } | ||
| 3307 | |||
| 3308 | =head2 sub get_flow_color | ||
| 3309 | exports private hash value | ||
| 3310 | |||
| 3311 | =cut | ||
| 3312 | |||
| 3313 | sub get_flow_color { | ||
| 3314 | my ($self) = @_; | ||
| 3315 | |||
| 3316 | if ( $color_flow_href->{_flow_color} ) { | ||
| 3317 | my $color; | ||
| 3318 | |||
| 3319 | $color = $color_flow_href->{_flow_color}; | ||
| 3320 | return ($color); | ||
| 3321 | |||
| 3322 | } | ||
| 3323 | else { | ||
| 3324 | print("color_flow, missing flow color\n"); | ||
| 3325 | } | ||
| 3326 | |||
| 3327 | } | ||
| 3328 | |||
| 3329 | =head2 sub get_flow_type | ||
| 3330 | |||
| 3331 | exports private hash value | ||
| 3332 | |||
| 3333 | =cut | ||
| 3334 | |||
| 3335 | sub get_flow_type { | ||
| 3336 | my ($self) = @_; | ||
| 3337 | |||
| 3338 | if ( $color_flow_href->{_flow_type} ) { | ||
| 3339 | my $flow_type; | ||
| 3340 | |||
| 3341 | $flow_type = $color_flow_href->{_flow_type}; | ||
| 3342 | return ($flow_type); | ||
| 3343 | |||
| 3344 | } | ||
| 3345 | else { | ||
| 3346 | print("color_flow, missing flow type\n"); | ||
| 3347 | } | ||
| 3348 | |||
| 3349 | } | ||
| 3350 | |||
| 3351 | =head2 sub get_perl_flow_errors | ||
| 3352 | |||
| 3353 | =cut | ||
| 3354 | |||
| 3355 | sub get_perl_flow_errors { | ||
| 3356 | my ($self) = @_; | ||
| 3357 | my $result = $empty_string; | ||
| 3358 | |||
| 3359 | if ( length $color_flow->{_perl_flow_errors} ) { | ||
| 3360 | |||
| 3361 | $result = $color_flow->{_perl_flow_errors}; | ||
| 3362 | return ($result); | ||
| 3363 | |||
| 3364 | } | ||
| 3365 | else { | ||
| 3366 | print(" color_flow, get_perl_flow_errors, missing variable value\n"); | ||
| 3367 | return ($result); | ||
| 3368 | } | ||
| 3369 | } | ||
| 3370 | |||
| 3371 | =head2 sub get_prog_name_sref | ||
| 3372 | |||
| 3373 | exports private hash value | ||
| 3374 | |||
| 3375 | =cut | ||
| 3376 | |||
| 3377 | sub get_prog_name_sref { | ||
| 3378 | my ($self) = @_; | ||
| 3379 | |||
| 3380 | if ( $color_flow_href->{_prog_name_sref} ) { | ||
| 3381 | my $name; | ||
| 3382 | |||
| 3383 | $name = $color_flow_href->{_prog_name_sref}; | ||
| 3384 | return ($name); | ||
| 3385 | |||
| 3386 | } | ||
| 3387 | else { | ||
| 3388 | print("color_flow, missing \n"); | ||
| 3389 | } | ||
| 3390 | |||
| 3391 | } | ||
| 3392 | |||
| 3393 | =head2 sub increase_vigil_on_delete_counter | ||
| 3394 | |||
| 3395 | Helps keep check of whether an item | ||
| 3396 | is deleted from the listbox | ||
| 3397 | during dragging and dropping | ||
| 3398 | |||
| 3399 | =cut | ||
| 3400 | |||
| 3401 | sub increase_vigil_on_delete_counter { | ||
| 3402 | my ($self) = @_; | ||
| 3403 | $flow_widgets->inc_vigil_on_delete_counter; | ||
| 3404 | |||
| 3405 | return (); | ||
| 3406 | } | ||
| 3407 | |||
| 3408 | =head2 sub get_help | ||
| 3409 | |||
| 3410 | Callback sequence following MB3 click | ||
| 3411 | activation of a sunix (Listbox) item | ||
| 3412 | program name is a scalar reference | ||
| 3413 | |||
| 3414 | Let help decide whether it is a superflow | ||
| 3415 | or a user-created flow | ||
| 3416 | |||
| 3417 | Show a window with the perldoc to the user | ||
| 3418 | |||
| 3419 | and length $color_flow_href->{_sunix_prog_group} | ||
| 3420 | |||
| 3421 | =cut | ||
| 3422 | |||
| 3423 | sub get_help { | ||
| 3424 | |||
| 3425 | my ($self) = @_; | ||
| 3426 | |||
| 3427 | my $help = help->new(); | ||
| 3428 | my $pre_req_ok; | ||
| 3429 | |||
| 3430 | $decisions->set4help($color_flow_href); | ||
| 3431 | $pre_req_ok = $decisions->get4help(); | ||
| 3432 | |||
| 3433 | if ( | ||
| 3434 | $pre_req_ok | ||
| 3435 | and length $color_flow_href->{_prog_name_sref} | ||
| 3436 | and length $color_flow_href->{_current_program_name} | ||
| 3437 | and ( $color_flow_href->{_current_program_name} eq | ||
| 3438 | ${ $color_flow_href->{_prog_name_sref} } ) | ||
| 3439 | ) | ||
| 3440 | { | ||
| 3441 | |||
| 3442 | # it is a sunix program | ||
| 3443 | # the program category is defined | ||
| 3444 | |||
| 3445 | my $current_program_name = $color_flow_href->{_current_program_name}; | ||
| 3446 | my $SeismicUnixGui = $dirs->get_path4SeismicUnixGui(); | ||
| 3447 | my $module_name = ${ $color_flow_href->{_prog_name_sref} }; | ||
| 3448 | my $program_category_h = | ||
| 3449 | $L_SU_global_constants->get_developer_sunix_category_h(); | ||
| 3450 | my $key = '_' . $current_program_name; | ||
| 3451 | my $program_category = $program_category_h->{$key}; | ||
| 3452 | my $sunix_program_group = $program_category; | ||
| 3453 | |||
| 3454 | my $PATH = $SeismicUnixGui . '/sunix' . '/' . $program_category; | ||
| 3455 | |||
| 3456 | my $help = help->new(); | ||
| 3457 | my $inbound = $PATH . '/' . $module_name . $var->{_suffix_pm}; | ||
| 3458 | |||
| 3459 | $help->set_name( \$inbound ); | ||
| 3460 | $help->tkpod(); | ||
| 3461 | |||
| 3462 | } | ||
| 3463 | else { | ||
| 3464 | print("color_flow, missing variable\n"); | ||
| 3465 | } | ||
| 3466 | return (); | ||
| 3467 | } | ||
| 3468 | |||
| 3469 | =head2 sub save_button | ||
| 3470 | |||
| 3471 | topic: only 'Save' | ||
| 3472 | for safety, place set_hash_ref first | ||
| 3473 | run from L_SU.pm | ||
| 3474 | |||
| 3475 | Also save new parameter values (redisplay_values) | ||
| 3476 | for changes occurred | ||
| 3477 | immediately before the current saving | ||
| 3478 | |||
| 3479 | param_flow_color memory leak workaround | ||
| 3480 | |||
| 3481 | # print("color_flow, save_button writing gui_history.txt\n"); | ||
| 3482 | # $gui_history->view(); | ||
| 3483 | |||
| 3484 | # print("3. color_flow, save_button, param_flow view data\n" | ||
| 3485 | # ); | ||
| 3486 | # $param_flow_color_pkg->view_data(); | ||
| 3487 | |||
| 3488 | print( | ||
| 3489 | "5. color_flow, save_button, memory fix, click count=$click_count\n" | ||
| 3490 | ); # =7 < 19 default OK | ||
| 3491 | print( | ||
| 3492 | "5. color_flow, save_button, most_recent_flow_index_touched=$last_flow_index\n" | ||
| 3493 | ); #=2 OK | ||
| 3494 | print( | ||
| 3495 | "5. color_flow, save_button, max_saved_widget_index=$max_saved_widget_index\n" | ||
| 3496 | ); # =1 TODO | ||
| 3497 | print("5 color_flow,save_last_param_widget_values=@save_last_param_widget_values\n"); | ||
| 3498 | |||
| 3499 | # print("5. color_flow, save_button, Can not fix memory leak\n"); | ||
| 3500 | # print( | ||
| 3501 | print( | ||
| 3502 | "5. color_flow, save_button, this_color,last_flow_color are:$this_color,$last_flow_color\n" | ||
| 3503 | ); | ||
| 3504 | print( | ||
| 3505 | "5. color_flow, save_button, most recent flow index touched is $most_recent_flow_index_touched\n" | ||
| 3506 | ); | ||
| 3507 | print( | ||
| 3508 | "5. color_flow, save_button, max index in flow: $max_index_in_flow\n" | ||
| 3509 | ); | ||
| 3510 | |||
| 3511 | # print( | ||
| 3512 | #"5. color_flow, save_button, last flow index: $last_flow_index\n" | ||
| 3513 | # ); | ||
| 3514 | # print( | ||
| 3515 | #"5. color_flow, save_button, max_saved_widget_index was $max_saved_widget_index\n" | ||
| 3516 | # ); | ||
| 3517 | # print( | ||
| 3518 | #"5. color_flow, save_button, click_count:$click_count min_clicks4save_button:$min_clicks4save_button\n" | ||
| 3519 | # ); | ||
| 3520 | |||
| 3521 | |||
| 3522 | =cut | ||
| 3523 | |||
| 3524 | sub save_button { | ||
| 3525 | my ( $self, $topic ) = @_; | ||
| 3526 | |||
| 3527 | my $num_items_in_flow = $param_flow_color_pkg->get_num_items(); | ||
| 3528 | my $max_index_in_flow = $num_items_in_flow - 1; | ||
| 3529 | |||
| 3530 | $gui_history->set_file_status($num_items_in_flow); | ||
| 3531 | my $file_prob_just_opened = $gui_history->get_file_status(); | ||
| 3532 | # print("file_prob_just_opened=$true\n"); | ||
| 3533 | |||
| 3534 | $param_widgets->redisplay_values(); | ||
| 3535 | |||
| 3536 | # Double-check we are in the correct place: | ||
| 3537 | if ( $topic eq 'Save' ) { | ||
| 3538 | |||
| 3539 | my $files_LSU = files_LSU->new(); | ||
| 3540 | |||
| 3541 | # user-built_flow in current use | ||
| 3542 | my $flow_listbox_color_w = _get_flow_listbox_color_w(); | ||
| 3543 | |||
| 3544 | # Start refocus index in flow, in case focus has been removed | ||
| 3545 | # e.g., by double-clicking in parameter values window | ||
| 3546 | my $most_recent_flow_index_touched = | ||
| 3547 | ( $color_flow_href->{_flow_select_index_href} )->{_most_recent}; | ||
| 3548 | my $prior_flow_index_touched = | ||
| 3549 | ( $color_flow_href->{_flow_select_index_href} )->{_prior}; | ||
| 3550 | my $most_recent_flow_color = | ||
| 3551 | ( $color_flow_href->{_flow_select_color_href} )->{_most_recent}; | ||
| 3552 | my $last_flow_index = $most_recent_flow_index_touched; | ||
| 3553 | |||
| 3554 | $last_flow_color = $color_flow_href->{_last_flow_color}; | ||
| 3555 | my $max_saved_widget_index = | ||
| 3556 | ( scalar @save_last_param_widget_values ) - 1; | ||
| 3557 | |||
| 3558 | # restore terminal ticks in strings after reading from the GUI | ||
| 3559 | # remove possible terminal strings | ||
| 3560 | $color_flow_href->{_values_aref} = | ||
| 3561 | $control->get_no_quotes4array( $color_flow_href->{_values_aref} ); | ||
| 3562 | |||
| 3563 | if ( length $last_flow_color | ||
| 3564 | && $last_flow_index >= 1 | ||
| 3565 | && $flow_listbox_color_w ) | ||
| 3566 | { | ||
| 3567 | |||
| 3568 | # print("CASE 1A color_flow, save_button, last_flow_index=$last_flow_index\n"); | ||
| 3569 | # One parameter index was previously selected | ||
| 3570 | # Assume that recent selection is valid for this current save | ||
| 3571 | |||
| 3572 | # keep track of flow_selection clicks | ||
| 3573 | $flow_listbox_color_w->selectionSet($last_flow_index); | ||
| 3574 | $gui_history->set_flow_select_color($this_color); | ||
| 3575 | $gui_history->set_button('flow_select'); | ||
| 3576 | |||
| 3577 | } | ||
| 3578 | else { | ||
| 3579 | # print("color_flow, save_button , unexpected missing variables NADA\n"); | ||
| 3580 | } | ||
| 3581 | |||
| 3582 | =pod | ||
| 3583 | |||
| 3584 | CASE common : When save_button is being used for the first time | ||
| 3585 | BUT when no flow has been selected previously (_last_flow_index_touched=-1) | ||
| 3586 | In other words: when a flow in the GUI is used | ||
| 3587 | for first time but no listboxes have been occupied previously | ||
| 3588 | |||
| 3589 | =cut | ||
| 3590 | |||
| 3591 | _save_most_recent_param_flow(); | ||
| 3592 | |||
| 3593 | # find which flow index is selected | ||
| 3594 | my $num_items_in_flow = $param_flow_color_pkg->get_num_items(); | ||
| 3595 | my $max_index_in_flow = $num_items_in_flow - 1; | ||
| 3596 | $last_flow_color = $color_flow_href->{_last_flow_color}; | ||
| 3597 | |||
| 3598 | # $gui_history->set_file_status($num_items_in_flow); | ||
| 3599 | # my $file_status = $gui_history->get_file_status(); | ||
| 3600 | |||
| 3601 | # print("color_flow, save_button: writing gui_history.txt\n"); | ||
| 3602 | # $gui_history->view(); | ||
| 3603 | |||
| 3604 | if ( not $memory_leak4save_button_fixed ) { | ||
| 3605 | |||
| 3606 | # Strange memory leak from param_flow_color_pkg | ||
| 3607 | # when first file is just opened. | ||
| 3608 | # Last element of last program disappears-- | ||
| 3609 | # if either user clicks on an element different from | ||
| 3610 | # the last, or the Save button. | ||
| 3611 | # Conditions to detect the circumstance are: | ||
| 3612 | #--just having opened a file, | ||
| 3613 | # -- no changes have yet been made to the flow | ||
| 3614 | # -- $total_click_value < $very_low_click_value | ||
| 3615 | # if file has just been opened and is immediately saved | ||
| 3616 | # the set flow index is assumed = 0 | ||
| 3617 | # just in total_click_value is still slow | ||
| 3618 | # and there was a change to the last parameter | ||
| 3619 | # in the last item of the flow, we detect this | ||
| 3620 | # by assuming that when the updated_parameter_index_on_exit | ||
| 3621 | # indicates the last parameter box was engaged then | ||
| 3622 | # we will not | ||
| 3623 | |||
| 3624 | if ( | ||
| 3625 | $this_color eq $last_flow_color | ||
| 3626 | && ( $most_recent_flow_index_touched == $max_index_in_flow | ||
| 3627 | && $file_prob_just_opened == $true) | ||
| 3628 | ) | ||
| 3629 | { | ||
| 3630 | |||
| 3631 | # CASE 1 FIX MEMORY LEAK | ||
| 3632 | # When last color=this_color | ||
| 3633 | # and we are still over the last index in GUI | ||
| 3634 | # e.g., when a recently opened file is | ||
| 3635 | # saved without any changes | ||
| 3636 | # (a strange but possible case) | ||
| 3637 | # Fix param_widget memory leak that deletes the | ||
| 3638 | # last element in the last flow | ||
| 3639 | |||
| 3640 | # print( | ||
| 3641 | #"6 color_flow,most_recent_flow_index_touched=$most_recent_flow_index_touched\n" | ||
| 3642 | # ); | ||
| 3643 | |||
| 3644 | # # print("6. color_flow,@save_last_param_widget_values=$@save_last_param_widget_values\n"); | ||
| 3645 | $param_flow_color_pkg->set_flow_index($max_index_in_flow); | ||
| 3646 | $param_flow_color_pkg->set_param_index($save_last_param_widget_index); | ||
| 3647 | $param_flow_color_pkg->set_param_value($save_last_param_widget_value); | ||
| 3648 | |||
| 3649 | $param_widgets->redisplay_values(); | ||
| 3650 | |||
| 3651 | } | ||
| 3652 | else { | ||
| 3653 | #NADA | ||
| 3654 | } | ||
| 3655 | |||
| 3656 | # needs to be fixed each time Save is used on unchanged perl flow | ||
| 3657 | $memory_leak4save_button_fixed = $true; | ||
| 3658 | |||
| 3659 | # leak is now fixed going forward for the flow_select button as well. | ||
| 3660 | $memory_leak4flow_select_fixed = $true; | ||
| 3661 | |||
| 3662 | } # end of memory leak solution | ||
| 3663 | |||
| 3664 | $param_flow_color_pkg->set_flow_index($last_flow_index); | ||
| 3665 | |||
| 3666 | # collect the values from those stored data in param_flow | ||
| 3667 | # because the values from the widgets have not been updated | ||
| 3668 | $color_flow_href->{_values_aref} = | ||
| 3669 | $param_flow_color_pkg->get_values_aref(); | ||
| 3670 | |||
| 3671 | # establish which program is active in the flow | ||
| 3672 | $color_flow_href->{_prog_names_aref} = | ||
| 3673 | $param_flow_color_pkg->get_flow_prog_names_aref(); | ||
| 3674 | $control->set_flow_prog_names_aref( | ||
| 3675 | $color_flow_href->{_prog_names_aref} ); | ||
| 3676 | $control->set_flow_prog_name_index($most_recent_flow_index_touched); | ||
| 3677 | |||
| 3678 | # remove all quotes | ||
| 3679 | $color_flow_href->{_values_aref} = | ||
| 3680 | $control->get_no_quotes4array( $color_flow_href->{_values_aref} ); | ||
| 3681 | |||
| 3682 | # restore so that only strings have quotes | ||
| 3683 | # for the last program name that was used | ||
| 3684 | $color_flow_href->{_values_aref} = $control->get_string_or_number4aref( | ||
| 3685 | $color_flow_href->{_values_aref} ); | ||
| 3686 | |||
| 3687 | $color_flow_href->{_last_parameter_index_touched_color} = 0; | ||
| 3688 | $color_flow_href->{$_is_last_parameter_index_touched_color} = $true; | ||
| 3689 | |||
| 3690 | # update changes to parameter values between 'SaveAs' and 'Save'-2 | ||
| 3691 | # assume a parameter index has been changed so that | ||
| 3692 | # _save_most_recent_param_flow is forced to update previous changes before | ||
| 3693 | # the current "updating"" | ||
| 3694 | # these changes occur via param_flow | ||
| 3695 | # _update_prior_param_flow(); | ||
| 3696 | |||
| 3697 | $color_flow_href->{_names_aref} = | ||
| 3698 | $param_flow_color_pkg->get_names_aref(); | ||
| 3699 | |||
| 3700 | $param_flow_color_pkg->set_good_values(); | ||
| 3701 | $param_flow_color_pkg->set_good_labels(); | ||
| 3702 | |||
| 3703 | $color_flow_href->{_good_labels_aref2} = | ||
| 3704 | $param_flow_color_pkg->get_good_labels_aref2(); | ||
| 3705 | $color_flow_href->{_items_versions_aref} = | ||
| 3706 | $param_flow_color_pkg->get_flow_items_version_aref(); | ||
| 3707 | $color_flow_href->{_good_values_aref2} = | ||
| 3708 | $param_flow_color_pkg->get_good_values_aref2(); | ||
| 3709 | $color_flow_href->{_prog_names_aref} = | ||
| 3710 | $param_flow_color_pkg->get_flow_prog_names_aref(); | ||
| 3711 | |||
| 3712 | $color_flow_href->{_prog_names_aref} = | ||
| 3713 | $param_flow_color_pkg->get_flow_prog_names_aref(); | ||
| 3714 | $control->set_flow_prog_names_aref( | ||
| 3715 | $color_flow_href->{_prog_names_aref} ); | ||
| 3716 | |||
| 3717 | # One last check on quotes for strings | ||
| 3718 | # Program names help discern strings from numbers: | ||
| 3719 | # after memory leak correction -- one time only | ||
| 3720 | # and for case where file name are numeric e.g., '1000.txt' | ||
| 3721 | |||
| 3722 | $color_flow_href->{_good_values_aref2} = | ||
| 3723 | $control->get_string_or_number_aref2( | ||
| 3724 | $color_flow_href->{_good_values_aref2} ); | ||
| 3725 | |||
| 3726 | $files_LSU->set_prog_param_labels_aref2($color_flow_href); | ||
| 3727 | $files_LSU->set_prog_param_values_aref2($color_flow_href); | ||
| 3728 | $files_LSU->set_prog_names_aref($color_flow_href); | ||
| 3729 | $files_LSU->set_items_versions_aref($color_flow_href); | ||
| 3730 | $files_LSU->set_data(); | ||
| 3731 | $files_LSU->set_message($color_flow_href); | ||
| 3732 | |||
| 3733 | # listbox color assignment | ||
| 3734 | $files_LSU->set_flow_color($this_color); | ||
| 3735 | |||
| 3736 | # update PL_SEISMIC in case user has recently changed project area | ||
| 3737 | $files_LSU->set_PL_SEISMIC(); | ||
| 3738 | |||
| 3739 | # flows saved to PL_SEISMIC | ||
| 3740 | $files_LSU->set2pl($color_flow_href); | ||
| 3741 | $files_LSU->save(); | ||
| 3742 | |||
| 3743 | } | ||
| 3744 | else { | ||
| 3745 | print("color_flow, missing topic Save\n"); | ||
| 3746 | } | ||
| 3747 | return (); | ||
| 3748 | |||
| 3749 | } # ends save_button | ||
| 3750 | |||
| 3751 | =head2 sub set_hash_ref | ||
| 3752 | Import external hash into private settings via gui_history | ||
| 3753 | hash | ||
| 3754 | |||
| 3755 | Keys that used simplified names are also kept so later | ||
| 3756 | the hash can be returned to a calling module | ||
| 3757 | |||
| 3758 | print("color_flow, END of flow_select: writing gui_history.txt\n"); | ||
| 3759 | $gui_history->view(); | ||
| 3760 | |||
| 3761 | =cut | ||
| 3762 | |||
| 3763 | sub set_hash_ref { | ||
| 3764 | my ( $self, $hash_ref ) = @_; | ||
| 3765 | |||
| 3766 | $gui_history->set_defaults($hash_ref); | ||
| 3767 | $color_flow_href = $gui_history->get_defaults(); | ||
| 3768 | |||
| 3769 | # REALLY? | ||
| 3770 | # set up param_widgets for later use | ||
| 3771 | # give param_widgets the needed values | ||
| 3772 | $param_widgets->set_hash_ref($color_flow_href); | ||
| 3773 | |||
| 3774 | $flow_color = $color_flow_href->{_flow_color}; | ||
| 3775 | |||
| 3776 | # $gui_history_aref = $color_flow_href->{_gui_history_aref}; | ||
| 3777 | |||
| 3778 | # for local use | ||
| 3779 | $last_flow_color = | ||
| 3780 | $color_flow_href->{_last_flow_color}; # used in flow_select | ||
| 3781 | $message_w = $color_flow_href->{_message_w}; | ||
| 3782 | $parameter_values_frame = $color_flow_href->{_parameter_values_frame}; | ||
| 3783 | $parameter_values_button_frame = | ||
| 3784 | $color_flow_href->{_parameter_values_button_frame}; | ||
| 3785 | |||
| 3786 | # $sunix_listbox = $color_flow_href->{_sunix_listbox}; | ||
| 3787 | |||
| 3788 | # print("color_flow, set_hash_ref _check_buttons_settings_aref: @{$color_flow_href->{_check_buttons_settings_aref}}\n"); | ||
| 3789 | |||
| 3790 | # print("color_flow,set_hash_ref: print gui_history->view\n"); | ||
| 3791 | # $gui_history->view(); | ||
| 3792 | |||
| 3793 | return (); | ||
| 3794 | } | ||
| 3795 | |||
| 3796 | =head2 sub set_occupied_listbox_aref | ||
| 3797 | |||
| 3798 | |||
| 3799 | =cut | ||
| 3800 | |||
| 3801 | sub set_occupied_listbox_aref { | ||
| 3802 | |||
| 3803 | my ( $self, $occupied_listbox_aref ) = @_; | ||
| 3804 | |||
| 3805 | if ($occupied_listbox_aref) { | ||
| 3806 | |||
| 3807 | $color_flow_href->{_occupied_listbox_aref} = $occupied_listbox_aref; | ||
| 3808 | |||
| 3809 | } | ||
| 3810 | else { | ||
| 3811 | print( | ||
| 3812 | "color_flow,_set_occupied_listbox_aref, missing occupied_listbox_aref \n" | ||
| 3813 | ); | ||
| 3814 | } | ||
| 3815 | |||
| 3816 | } | ||
| 3817 | |||
| 3818 | =head2 sub set_vacant_listbox_aref | ||
| 3819 | |||
| 3820 | |||
| 3821 | =cut | ||
| 3822 | |||
| 3823 | sub set_vacant_listbox_aref { | ||
| 3824 | |||
| 3825 | my ( $self, $vacant_listbox_aref ) = @_; | ||
| 3826 | |||
| 3827 | if ($vacant_listbox_aref) { | ||
| 3828 | |||
| 3829 | $color_flow_href->{_vacant_listbox_aref} = $vacant_listbox_aref; | ||
| 3830 | |||
| 3831 | } | ||
| 3832 | else { | ||
| 3833 | print( | ||
| 3834 | "color_flow,_set_vacant_listbox_aref, missing vacant_listbox_aref \n" | ||
| 3835 | ); | ||
| 3836 | } | ||
| 3837 | |||
| 3838 | } | ||
| 3839 | |||
| 3840 | __PACKAGE__->meta->make_immutable; | ||
| 3841 | 1; |