lib/App/SeismicUnixGui/misc/grey_flow.pm untested

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