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

filter: Statementstmt 0.0% 0 / 565 Branchbran 0.0% 0 / 128 Conditioncond 0.0% 0 / 39 MC/DCmcdc 0.0% 0 / 22 Subroutinesub 0.0% 0 / 64 Podpod 0.0% 0 / 55 totaltotal 0.0% 0 / 873 CC 67 SCAR 40.6
CC
67
Cov
0%
_update_check_button_setting
272.0
set_location_in_gui
182.0
_changes
30.0
CRAP 57.7
1 package App::SeismicUnixGui::misc::param_widgets;
2  
3 =head1 DOCUMENTATION
4  
5 =head2 SYNOPSIS
6  
7 PERL PROGRAM NAME: param_widgets
8 AUTHOR: Juan Lorenzo
9  
10 =head2 CHANGES and their DATES
11  
12 DATE: V 1.0.1 May 6 2018
13  
14  
15 =head2 DESCRIPTION
16  
17 manages the parameter labels, values and their
18 checkboxes in the mguis
19  
20 =head2 USE
21  
22 =head2 Examples
23  
24 =head2
25  
26 =head2 STEPS
27  
28  
29 =head2 NOTES
30  
31 =cut
32  
33 use Moose;
34 our $VERSION = '1.0.1';
35 use Tk;
36 use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants';
37 use aliased 'App::SeismicUnixGui::misc::check_buttons';
38 use App::SeismicUnixGui::misc::control '0.0.3';
39 use aliased 'App::SeismicUnixGui::misc::control'; #note
40 use aliased 'App::SeismicUnixGui::misc::wipe';
41  
42 my $check_buttons = check_buttons->new();
43 my $get = L_SU_global_constants->new();
44 my $default_param_specs = $get->param();
45 my $var = $get->var();
46 my $on = $var->{_on};
47 my $off = $var->{_off};
48 my $nu = $var->{_nu};
49 my $no = $var->{_no};
50 my $empty_string = $var->{_empty_string};
51  
52 =head2 Declare
53 local variables
54  
55 =cut
56  
57 my $default_entry_in_switch = 'default_entry_in_switch';
58 my $default_parameter_index_on_entry = 0;
59 my $default_parameter_index_on_exit = 0;
60  
61 # print("param_widgets, default_param_specs,first entry num=$default_param_specs->{_first_entry_num}\n");
62  
63 =head2 private hash references
64  
65 32 off
66  
67 =cut
68  
69 my $param_widgets = {
70  
71 _changed_entry => 0,
72 _check_buttons_settings_aref => '',
73 _check_buttons_frame_href => '',
74 _check_buttons_w_aref => '',
75 _current_program_name => '',
76 _entry_in_switch => $default_entry_in_switch,
77 _entry_button_chosen_index => '',
78 _entry_button_chosen_widget => '',
79 _location_in_gui => '',
80 _first_idx => $default_param_specs->{_first_entry_idx},
81 _index => '',
82 _index_on_entry => '',
83 _labels_aref => '',
84 _labels_w_aref => '',
85 _last => '',
86 _length => $default_param_specs->{_length},
87 _parameter_index_on_entry => $default_parameter_index_on_entry,
88 _parameter_index_on_exit => $default_parameter_index_on_exit,
89 _prog_name => '',
90 _prog_name_sref => '',
91 _values_aref => '',
92 _values_frame_href => '',
93 _values_w_aref => '',
94  
95 };
96  
97 my $true = 1;
98 my $false = 0;
99  
100 =head2 sub _max_length_in_gui
101  
102  
103 =cut
104  
105 sub _max_length_in_gui {
106 my ($self) = @_;
107 my $max_length_in_gui = $default_param_specs->{_length};
108  
109 $param_widgets->{_length} = $max_length_in_gui;
110  
111 return ();
112  
113 }
114  
115 =head2 sub _set_length_in_gui
116  
117  
118 =cut
119  
120 sub _set_length_in_gui {
121 my ($new_length_in_gui) = @_;
122  
123 if ( $new_length_in_gui >= 0 ) {
124 $param_widgets->{_length} = $new_length_in_gui;
125  
126 }
127 else {
128 print("wipe,_set_length_in_gui, unexpected result\n");
129 }
130 return ();
131  
132 }
133  
134 =head2 sub _reset
135  
136 private reset of "condition" variables
137 do not reset incoming widgets
138
139 =cut
140  
141 sub _reset {
142 my ($self) = @_;
143  
144 $param_widgets->{_is_flow_listbox_grey_w} = $false;
145 $param_widgets->{_is_flow_listbox_pink_w} = $false;
146 $param_widgets->{_is_flow_listbox_green_w} = $false;
147 $param_widgets->{_is_flow_listbox_blue_w} = $false;
148 $param_widgets->{_is_flow_listbox_color_w} = $false;
149 $param_widgets->{_is_add2flow} = $false; # needed? double confirmation?
150 $param_widgets->{_is_add2flow_button} =
151 $false; # needed? double confirmation?
152 $param_widgets->{_is_delete_from_flow_button} = $false;
153 $param_widgets->{_is_new_listbox_selection} = $false;
154 $param_widgets->{_is_superflow_select_button} = $false;
155 $param_widgets->{_is_delete_from_flow_button} = $false;
156 $param_widgets->{_is_moveNdrop_in_flow} = $false;
157 $param_widgets->{_is_sunix_listbox} = $false;
158  
159 return ();
160 }
161  
162 =head2 _changes
163  
164 to only one parameter
165 some changes will be false and should be rejected
166  
167 If you are at this subroutine it means that
168 a possible change has been detected in
169 the Entry Widget TODO: yet to be ratified
170  
171 Currently if we reach this subroutine we assume that changes always occur to
172 all parameters and so we
173 forcibly check for changes always
174
175 changes are only allowed for those sunix programs whose spec files
176 have a max_index defined
177
178 currently changes in param_widgets package only works with regular flows
179 and not with pre-built superflows
180
181  
182 =cut
183  
184 sub _changes {
185 my ( $self, $index ) = @_;
186  
187 my $idx = $index; # individual parameter line
188 my $control = control->new();
189  
190 # two cases possible
191 # in general L_SU
192 if ( $idx >= 0
193 and length( $param_widgets->{_current_program_name} ) )
194 {
195  
196 my $prog_name = $param_widgets->{_current_program_name};
197  
198 # print(" param_widgets, _changes, prog_name: $prog_name \n");
199 # print(" param_widgets, _changes, index: $idx \n");
200  
201 my $max_idx = $control->get_max_index($prog_name);
202  
203 # print(" param_widgets,max_index, $max_idx \n");
204 if ( $idx <= $control->get_max_index($prog_name) ) {
205  
206 # cautious, index must be reasonable
207  
208 _set_index_on_entry($idx);
209 _check_value_changes();
210 _update_value_changes();
211  
212 # my $changed_entry = $param_widgets->{_changed_entry}; #always
213 # print("param_widgets,_changes,changed 1-yes 0 -no? $changed_entry\n");
214 # always = 1 (yes)
215 _set_entry_change_status($true);
216 _update_check_button_setting($idx);
217  
218 # _set_last_changed_entry_index($idx);
219 }
220 else {
221 print(" param_widgets, _changes, bad index \n");
222 }
223 }
224 else {
225 print("param_widgets, _changes,missing prog_name\n");
226 }
227  
228 =head2 sub _check_value_changes
229
230 locate change index for Entry widget
231 off = 0
232 on = 1
233  
234 Second case applies when we are using project_selector
235 project_selector does not yet have a max_index defined in a separate module
236  
237 =cut
238  
239 sub _check_value_changes {
240  
241 my ($self) = @_;
242  
243 # print(" 1. sub _check_value_changes\n");
244  
245 if ( $param_widgets->{_entry_in_switch} eq $off
246 or $param_widgets->{_entry_in_switch} eq $default_entry_in_switch )
247 {
248  
249 $param_widgets->{_entry_in_switch} = $on;
250  
251 # my $ans = $self->get_index_on_exit();
252 my $ans = $param_widgets->{_parameter_index_on_entry};
253  
254 # print(" 2. param_widgets, _check_value_changes, ENTERED INDEX=$ans\n");
255  
256 $ans = $param_widgets->{_entry_in_switch};
257  
258 # print(" 2. param_widgets, _check_value_changes, entry_in_switch=$ans\n");
259  
260 }
261 elsif ( $param_widgets->{_entry_in_switch} eq $on ) {
262  
263 # i.e., on and set =0
264  
265 $param_widgets->{_entry_in_switch} = $off;
266  
267 my $idx = $param_widgets->{_parameter_index_on_entry};
268  
269 # print(" 2. param_widgets, _check_value_changes, ENTERED INDEX=$ans\n");
270  
271 # my $ans = $param_widgets->{_entry_in_switch};
272 # print(" 2. param_widgets, _check_value_changes, entry_in_switch=$ans\n");
273  
274 $param_widgets->{_parameter_index_on_exit} = $idx;
275  
276 # print(" 3. param_widgets, _check_value_changes, Leaving INDEX=$param_widgets->{_parameter_index_on_exit}\n");
277  
278 }
279 else {
280 print(" param_widgets, changes, bad switch \n");
281 }
282  
283 return (); # for Entry widget to learn there is no error
284  
285 }
286  
287 # my @array = @{ $param_widgets_color_href->{_values_w_aref} };
288 # my $ans = $array[0]->get();
289 # print(" 1. param_widgets, _update_value_changes, array of widget Entry values:$ans \n");
290 # $ans = $array[1]->get();
291 # print(" 1. param_widgets, _update_value_changes, array of widget Entry values:$ans \n");
292  
293 return (1); # marks success for Entry widget
294 }
295  
296 =head2 sub _update_value_changes
297
298 locate change index for Entry widget
299  
300 =cut
301  
302 sub _update_value_changes {
303  
304 my ($self) = @_;
305  
306 # print(" start param_widgets, _update_value_changes\n");
307  
308 if ( $param_widgets->{_entry_in_switch} eq $off ) {
309  
310 # CASE 1 just left a widget after having entered it
311 # save the value of the prior widget
312 my $index_on_entry = $param_widgets->{_parameter_index_on_entry};
313  
314 # print(" param_widgets, _update_value_changes,index_on_entry =$index_on_entry\n");
315 my $prior_value =
316 @{ $param_widgets->{_values_w_aref} }[$index_on_entry]->get();
317 @{ $param_widgets->{_values_aref} }[$index_on_entry] = $prior_value;
318  
319 }
320 elsif ( $param_widgets->{_entry_in_switch} eq $on ) {
321  
322 # CASE 2 just entering a widget after having left another
323 # save the value in the prior widget
324 my $index_on_exit = $param_widgets->{_parameter_index_on_exit};
325  
326 # print(" param_widgets, _update_value_changes,index_on_entry =$index_on_exit \n");
327 my $prior_value =
328 @{ $param_widgets->{_values_w_aref} }[$index_on_exit]->get();
329 @{ $param_widgets->{_values_aref} }[$index_on_exit] = $prior_value;
330  
331 }
332 else {
333 print(" 1. param_widgets, _update_value_changes, missing value\n");
334 }
335  
336 return ();
337  
338 }
339  
340 =head2 sub error_check
341  
342 When entry values are in error
343  
344 =cut
345  
346 sub error_check {
347  
348 my ($self) = @_;
349 print("param_widgets,error_check return is $true\n");
350 return ($true);
351 }
352  
353 =head2 sub get_check_buttons_w_aref
354  
355  
356 =cut
357  
358 sub get_check_buttons_w_aref {
359 my ($self) = @_;
360  
361 if ( $param_widgets->{_check_buttons_w_aref} ) {
362  
363 my $check_buttons_w_aref = $param_widgets->{_check_buttons_w_aref};
364 return ($check_buttons_w_aref);
365  
366 }
367 else {
368 print(
369 "param_widgets, get_check_buttons_w_aref, missing check_buttons_w_aref \n"
370 );
371 return ();
372 }
373 }
374  
375 =head2 sub
376  
377 =cut
378  
379 sub get_current_program {
380  
381 my ( $self, $widget_ref ) = @_;
382 my @selection_index = $$widget_ref->curselection();
383 my $prog_name = $$widget_ref->get( $selection_index[0] );
384  
385 # print("param_widgets get_current_program: $prog_name,index:$selection_index[0] \n");
386 return ( \$prog_name );
387 }
388  
389 =head2 sub get_entry_change_status
390  
391 =cut
392  
393 sub get_entry_change_status {
394 my @self = @_;
395 my $status = $param_widgets->{_changed_entry};
396  
397 # print("param_widgets, get_entry_change_status,changed_entry: $param_widgets->{_changed_entry}\n");
398 return ($status);
399 }
400  
401 =head2 sub get_labels_w_aref
402  
403 =cut
404  
405 sub get_labels_w_aref {
406 my ($self) = @_;
407  
408 if ( $param_widgets->{_labels_w_aref} ) {
409  
410 my $labels_w_aref = $param_widgets->{_labels_w_aref};
411 return ($labels_w_aref);
412  
413 }
414 else {
415 print("param_widgets,get_labels_w_aref, missing labels_w_aref \n");
416 return ();
417 }
418 }
419  
420 =head2 sub get_length_check_buttons_on
421  
422 =cut
423  
424 sub get_length_check_buttons_on {
425 my ($self) = @_;
426 my ( $length, $count );
427 my $check_buttons_aref = _get_check_buttons_settings_aref();
428  
429 # print("param_widgets,get_length_check_buttons_on, @$check_buttons_aref)\n");
430 my @button_settings = @$check_buttons_aref;
431 $length = scalar @button_settings;
432  
433 for ( my $i = 0, $count = 0 ; $i < $length ; $i++ ) {
434 if ( $button_settings[$i] ) {
435 if ( $button_settings[$i] eq 'on' ) {
436 $count++;
437 }
438 }
439 }
440  
441 $length = $count;
442 return ($length);
443 }
444  
445 =head2 sub get_index_check_buttons_on
446  
447 =cut
448  
449 sub get_index_check_buttons_on {
450 my ($self) = @_;
451 my ( $length, $count );
452 my $check_buttons_aref = _get_check_buttons_settings_aref();
453  
454 # print("param_widgets,get_length_check_buttons_on, @$check_buttons_aref)\n");
455 my @button_settings = @$check_buttons_aref;
456 $length = scalar @button_settings;
457 my @saved_index_on;
458 my $j = 0;
459 for ( my $i = 0, $count = 0 ; $i < $length ; $i++ ) {
460 if ( $button_settings[$i] ) {
461 if ( $button_settings[$i] eq 'on' ) {
462 $saved_index_on[$j] = $i;
463 $j++;
464 }
465 }
466 }
467  
468 return ( \@saved_index_on );
469 }
470  
471 =head2 get_values_w_aref
472  
473 return an array widget references
474  
475 =cut
476  
477 sub get_values_w_aref {
478 my ($self) = @_;
479  
480 if ( $param_widgets->{_values_w_aref} ) {
481  
482 my $values_w_aref = $param_widgets->{_values_w_aref};
483 return ($values_w_aref);
484  
485 }
486 else {
487 print("param_widgets,get_values_w_aref, missing values_w_aref \n");
488 return ();
489 }
490 }
491  
492 #sub gui_clean {
493 # my ($self) = @_;
494 #
495 # my $wipe = wipe->new();
496 #
497 ## print("param_widgets, gui_clean, _values_w_aref, $param_widgets->{_values_w_aref} \n");
498 ## print("param_widgets, gui_clean, _labels_w_aref, $param_widgets->{_labels_w_aref} \n");
499 # $wipe->range($param_widgets);
500 # $wipe->values();
501 # $wipe->labels();
502 # $wipe->check_buttons();
503 #
504 # return ();
505 #}
506  
507 =head2 sub gui_full_clear
508  
509 clear the gui completely of 61 parameter values
510 61 = current defaulted maximum number of variables in a list box
511  
512 =cut
513  
514 sub gui_full_clear {
515 my ($self) = @_;
516 # print("param_widgets,guifull_clear, start\n");
517  
518 # use aliased 'App::SeismicUnixGui::misc::wipe';
519 my $wipe = wipe->new();
520  
521 my $safe = $param_widgets->{_length};
522 _max_length_in_gui();
523  
524 # print(
525 #"param_widgets, gui_full_clear, length used for cleaning $param_widgets->{_length} \n"
526 # );
527 # print(
528 #"param_widgets, gui_full_clear, _values_aref, $param_widgets->{_values_aref} \n"
529 # );
530 # print(
531 #"param_widgets, gui_full_clear, _labels_aref, $param_widgets>{_labels_aref} \n"
532 # );
533  
534 $wipe->range($param_widgets);
535 $wipe->values();
536 $wipe->labels();
537 $wipe->check_buttons();
538  
539 # return to original length value
540 _set_length_in_gui($safe);
541  
542 # print(
543 #"param_widgets, gui_full_clear, restored length $param_widgets->{_length} \n"
544 # );
545  
546 return ();
547 }
548  
549 =head2 sub _set_entry_change_status
550  
551 =cut
552  
553 sub _set_entry_change_status {
554 my ($ans) = @_;
555 $param_widgets->{_changed_entry} = $ans;
556  
557 # print("param_widgets,_set_entry_change_status,changed_entry,is: success \n");
558  
559 return ();
560 }
561  
562 =head2 sub _set_index_on_entry
563  
564 =cut
565  
566 sub _set_index_on_entry {
567 my ($parameter_index_on_entry) = @_;
568  
569 $param_widgets->{_parameter_index_on_entry} = $parameter_index_on_entry;
570  
571 # print("1. param_widgets,_set_index_on_entry: $param_widgets->{_parameter_index_on_entry} \n");
572 return ();
573 }
574  
575 =head2 sub _update_check_button_setting
576  
577 update for one parameter index
578 in currently active program
579
580 Entry widget uses textvariables
581  
582 =cut
583  
584 sub _update_check_button_setting {
585 my ($index) = @_;
586 my $idx = $index;
587 my @values = @{ $param_widgets->{_values_aref} };
588 my (@on_off);
589  
590 # apparently empty cases
591 # equal to 0 or 0.0 or empty or undefined
592 if ( !( $values[$idx] ) ) {
593  
594 # if value is defined and initialized
595 if ( defined( $values[$idx] ) ) {
596  
597 if ( $values[$idx] eq '0' ) {
598  
599 $on_off[$idx] = $on;
600  
601 # print("1.20 param_widgets,,_update_check_button_setting index: $idx , value:$values[$idx] or '0' \n");
602  
603 }
604 elsif ( $values[$idx] eq '0.0' ) {
605  
606 $on_off[$idx] = $on;
607  
608 # print("1.21 param_widgets,_update_check_button_setting, ndex: $idx , value:$values[$idx] or 0.0 \n");
609  
610 }
611 elsif ( $values[$idx] eq '0' ) {
612  
613 $on_off[$idx] = $on;
614  
615 # print("1.22 param_widgets,,_update_check_button_setting index: $idx , value:$values[$idx] or '0' \n");
616  
617 }
618 elsif ( $values[$idx] eq '0.0' ) {
619  
620 $on_off[$idx] = $on;
621  
622 # print("1.23 param_widgets,_update_check_button_setting, ndex: $idx , value:$values[$idx] or 0.0 \n");
623  
624 }
625 else {
626  
627 # print("1.24 param_widgets,_update_check_button_setting; empty value, :index $idx value: $values[$idx]\n");
628 $on_off[$idx] = $off;
629 }
630  
631 }
632 else {
633  
634 # print("param_widgets,_update_check_button_setting; unexpected cases\n");
635 $on_off[$idx] = $off;
636 }
637  
638 # apparently non-empty cases
639 }
640 elsif ( $values[$idx] ) {
641  
642 if ( $values[$idx] eq "0" ) {
643  
644 $on_off[$idx] = $on;
645  
646 # print("1.11.23 1 param_widgets,_update_check_button_setting, index: $idx value: $values[$idx]\n");
647  
648 }
649 elsif ( $values[$idx] eq '0.0' ) {
650  
651 $on_off[$idx] = $on;
652  
653 # print("1.12 param_widgets,_update_check_button_setting, ndex: $idx , value:$values[$idx] or 0.0 \n");
654  
655 }
656 elsif ( $values[$idx] eq "" ) {
657  
658 $on_off[$idx] = $off;
659  
660 # print("1.13 param_widgets,_update_check_button_setting, \"\" \n");
661  
662 }
663 elsif ( $values[$idx] eq '' ) {
664  
665 # print("1.14 param_widgets,_update_check_button_setting, \'\' \n");
666 $on_off[$idx] = $off;
667  
668 }
669 elsif ( $values[$idx] eq "'nu'" ) {
670  
671 $on_off[$idx] = $off;
672  
673 # print("1. param_widgets,_update_check_button_setting, \"\'nu\'\" \n");
674  
675 }
676 elsif ( $values[$idx] eq $nu ) {
677 $on_off[$idx] = $off;
678  
679 # print("1.15 param_widgets,_update_check_button_setting, \$nu \n");
680  
681 }
682 elsif ( $values[$idx] eq $no ) {
683 $on_off[$idx] = $off;
684  
685 # print("2. param_widgets,_update_check_button_setting, \$no \n");
686  
687 }
688 elsif ( $values[$idx] eq "'0'" ) {
689 $on_off[$idx] = $on;
690  
691 # print("2.1 param_widgets,_update_check_button_setting, \"\'0\'\" \n");
692  
693 }
694 else {
695  
696 # print("3.1 param_widgets,_update_check_button_setting, all else\n");
697 $on_off[$idx] = $on;
698 }
699  
700 }
701 else {
702 print(
703 "param-widgets,_update_check_button_setting, apparently unconsidered case\n"
704 ); # weird TODO
705 }
706  
707 $check_buttons->set_index($idx);
708 $check_buttons->set_switch( \@on_off );
709  
710 # update a single change in private hash
711 @{ $param_widgets->{_check_buttons_settings_aref} }[$idx] = $on_off[$idx];
712  
713 # print("param_widgets: _update_check_button_setting :index $idx setting is: $on_off[$idx]\n");
714  
715 # print("param_widgets: update_check_buttons_settings_aref @{$param_widgets->{_check_buttons_settings_aref}}\n");
716  
717 return ();
718 }
719  
720 =head2 sub set_check_buttons
721 a widget reference
722  
723 =cut
724  
725 sub set_check_buttons {
726 my ( $self, $check_buttons_settings_aref ) = @_;
727 if ($check_buttons_settings_aref) {
728 $param_widgets->{_check_buttons_settings_aref} =
729 $check_buttons_settings_aref;
730  
731 # print("param_widgets,set_check_buttons, settings are @{$param_widgets->{_check_buttons_settings_aref}}\n");
732 }
733 return ();
734 }
735  
736 =head2 sub get_current_widget_name
737  
738 screen location by using part of the widget name
739 print(" self:$self widget: $widget\n");
740 print(" currently focus lies in: $screen_location\n");
741 print(" reference: $reference\n");
742 foreach my $i (@fields) {
743 print(" 2. widget is $i\n");
744 my $screen_location = $widget->focusCurrent;
745 my $reference = ref $screen_location;
746 print(" 1. widget is $a\n");
747 print ( "widget is $fields[-1]\n");
748 name is in the last element of the split array
749  
750 if widget_name= frame then we have flow
751 $var->{_flow}
752 if widget_name= menubutton we have superflow
753 $var->{_tool}
754 =cut
755  
756 sub get_current_widget_name {
757 my ( $self, $widget_ref ) = @_;
758 my @fields = split( /\./, $widget_ref->PathName() );
759 my $widget_name = $fields[-1];
760 return ($widget_name);
761 }
762  
763 =head2 sub get_check_buttons_settings_aref
764  
765 =cut
766  
767 sub get_check_buttons_settings_aref {
768 my ($self) = @_;
769  
770 if ( defined $param_widgets->{_check_buttons_settings_aref}
771 && $param_widgets->{_check_buttons_settings_aref} ne $empty_string )
772 {
773  
774 my $check_buttons_settings_aref =
775 \@{ $param_widgets->{_check_buttons_settings_aref} };
776 my $check_buttons_aref = $check_buttons_settings_aref;
777  
778 return ($check_buttons_aref);
779 }
780 else {
781 my @check_buttons_aref = ();
782  
783 # print("param_widgets,get_check_buttons_settings_aref is empty NADA\n");
784 return ( \@check_buttons_aref );
785 }
786  
787 }
788  
789 sub set_entry_button_chosen_index {
790  
791 my ( $self, $index ) = @_;
792 $param_widgets->{_entry_button_chosen_index} = $index;
793  
794 # print (" param_widgets,set_entry_button_chosen_index, #$index \n");
795  
796 }
797  
798 =head2 sub _get_check_buttons_settings_aref
799  
800 =cut
801  
802 sub _get_check_buttons_settings_aref {
803 my ($self) = @_;
804 my $check_buttons_settings_aref =
805 \@{ $param_widgets->{_check_buttons_settings_aref} };
806 my $check_buttons_aref = $check_buttons_settings_aref;
807  
808 #print("param_widgets,get_check_buttons_settings_aref: @{$param_widgets->{_check_buttons_settings_aref}}\n");
809 return ($check_buttons_aref);
810 }
811  
812 sub set_entry_button_chosen_widget {
813  
814 my ( $self, $widget_h ) = @_;
815 $param_widgets->{_entry_button_chosen_widget} = $widget_h;
816  
817 # print (" param_widgets,set_entry_button_chosen_widget, #$widget_h \n");
818  
819 }
820  
821 =head2 sub get_entry_button_chosen_index
822  
823  
824 =cut
825  
826 sub get_entry_button_chosen_index {
827  
828 my ($self) = @_;
829 my $index;
830  
831 # first and last indices
832 my $first = $param_widgets->{_first_idx};
833 my $length = $param_widgets->{_length};
834  
835 # print("param_widget,get_entry_button_chosen_index,first_index=$param_widgets->{_first_idx}\n");
836 # print("param_widget,get_entry_button_chosen_index,length_=$param_widgets->{_length} \n");
837  
838 my $widget = $param_widgets->{_entry_button_chosen_widget};
839  
840 # print("param_widget,get_entry_button_chosen_index,widget,=$widget\n");
841  
842 for ( my $choice = $first ; $choice < $length ; $choice++ ) {
843 if ( $widget eq @{ $param_widgets->{_values_w_aref} }[$choice] ) {
844  
845 $param_widgets->{_entry_button_chosen_index} = $choice;
846  
847 # print (" param_widgets,get_entry_button_chosen_index, #$choice \n");
848 $index = $choice;
849 }
850 }
851  
852 return ($index);
853 }
854  
855 =head2 sub get_label4entry_button_chosen
856  
857 determine which Entry Button is chosen
858  
859 print("param is $entry_param;\n");
860 print ("selected widget is # $LSU->{_parameter_value_index}\");
861 print ("label is $out\n");
862  
863 =cut
864  
865 sub get_label4entry_button_chosen {
866 my ($self) = @_;
867 my $label;
868  
869 # first and last indices
870 my $first = $param_widgets->{_first_idx};
871 my $length = $param_widgets->{_length};
872  
873 # print("param_widget,get_entry_button_chosen,first_index=$param_widgets->{_first_idx}\n");
874 # print("param_widget,get_entry_button_chosen,length_=$param_widgets->{_length} \n");
875  
876 my $widget = $param_widgets->{_entry_button_chosen_widget};
877  
878 # print("param_widget,get_entry_button_chosen,widget,=$widget\n");
879  
880 for ( my $choice = $first ; $choice < $length ; $choice++ ) {
881 if ( $widget eq @{ $param_widgets->{_values_w_aref} }[$choice] ) {
882 my $parameter_value_index = $choice;
883 my $parameter_name_index = $choice;
884
885 $label =
886 @{ $param_widgets->{_labels_w_aref} }[$choice]->cget('-text');
887 my $value = @{ $param_widgets->{_values_w_aref} }[$choice]->get;
888  
889 # print("param_widget,get_entry_button_chosen,label,=$label\n");
890 # print("param_widget,get_entry_button_chosen,value,=$value\n");
891 # print("param_widget,get_entry_button_chosen,index,=$choice\n");
892 }
893 }
894 return ($label);
895 }
896  
897 =head2 sub get_value4entry_button_chosen
898  
899 determine which Entry Button is chosen
900  
901 print("param is $entry_param;\n");
902 print ("selected widget is # $LSU->{_parameter_value_index}\");
903 print ("label is $out\n");
904  
905 =cut
906  
907 sub get_value4entry_button_chosen {
908 my ($self) = @_;
909 my $value;
910  
911 # first and last indices
912 my $first = $param_widgets->{_first_idx};
913 my $length = $param_widgets->{_length};
914  
915 # print("param_widgets,get_entry_button_chosen,first_index=$param_widgets->{_first_idx}\n");
916 # print("param_widgets,get_entry_button_chosen,length_=$param_widgets->{_length} \n");
917  
918 my $widget = $param_widgets->{_entry_button_chosen_widget};
919  
920 # print("param_widgets,get_entry_button_chosen,widget,=$widget\n");
921  
922 for ( my $choice = $first ; $choice < $length ; $choice++ ) {
923 if ( $widget eq @{ $param_widgets->{_values_w_aref} }[$choice] ) {
924 my $parameter_value_index = $choice;
925 my $parameter_name_index = $choice;
926  
927 $value = @{ $param_widgets->{_values_w_aref} }[$choice]->get();
928  
929 # print("param_widgets,get_entry_button_chosen,value,=$value\n");
930  
931 #print("param_widgets,get_entry_button_chosen,index,=$choice\n");
932 }
933 }
934 return ($value);
935 }
936  
937 =head2 sub get_values_aref
938  
939 all the values for one program at a time
940  
941 =cut
942  
943 sub get_values_aref {
944 my ($self) = @_;
945  
946 if ( $param_widgets->{_values_aref} ne $empty_string ) {
947  
948 my $values_aref = \@{ $param_widgets->{_values_aref} };
949  
950 # print("param_widgets,get_values_aref,value[0]= @{$param_widgets->{_values_aref}}[0]\n");
951 return ($values_aref);
952  
953 }
954 else {
955 print("param_widgets, get_values_aref, missing values_aref\n");
956 return ();
957 }
958  
959 }
960  
961 =head2 sub get_labels_aref
962  
963 equivalent to get_naems_aref
964  
965 =cut
966  
967 sub get_labels_aref {
968  
969 my ($self) = @_;
970 my $labels_aref = \@{ $param_widgets->{_labels_aref} };
971  
972 # print("param_widgets,get_labels_aref: @{$param_widgets->{_labels_aref}}\n"); # all labels in array may not be there
973 return ( $param_widgets->{_labels_aref} );
974 }
975  
976 =head2 sub get_names_aref
977  
978 equivalent to get_labels_aref
979  
980 =cut
981  
982 sub get_names_aref {
983  
984 my ($self) = @_;
985 my $labels_aref = \@{ $param_widgets->{_labels_aref} };
986  
987 print("param_widgets,get_labels_aref: @{$param_widgets->{_labels_aref}}\n")
988 ; # all labels in array may not be there
989 return ( $param_widgets->{_labels_aref} );
990 }
991  
992 =head2 sub initialize_check_buttons
993  
994 same set of check buttons for all programs
995  
996 =cut
997  
998 sub initialize_check_buttons {
999 my ($self) = @_;
1000 my ( $first, $length );
1001 my (@off);
1002  
1003 $first = $param_widgets->{_first_idx};
1004 $length = $param_widgets->{_length};
1005  
1006 for ( my $i = $first ; $i < $length ; $i++ ) {
1007 $off[$i] = 'off';
1008 }
1009  
1010 $check_buttons->specs($default_param_specs);
1011 $check_buttons->frame( $param_widgets->{_check_buttons_frame_href} );
1012 $check_buttons->make( \@off );
1013  
1014 $param_widgets->{_check_buttons_w_aref} = $check_buttons->get_w_aref();
1015  
1016 # print("param_widgets, initialize_check_buttons check_buttons_w_aref: $param_widgets->{_check_buttons_w_aref}\n");
1017  
1018 }
1019  
1020 =head2 sub initialize_labels
1021  
1022  
1023 =cut
1024  
1025 sub initialize_labels {
1026  
1027 my ($self) = @_;
1028 my ( $labels, $first, $length );
1029 my (@blank_labels);
1030  
1031 use aliased 'App::SeismicUnixGui::misc::label_boxes';
1032  
1033 $labels = label_boxes->new();
1034 $first = $param_widgets->{_first_idx};
1035 $length = $param_widgets->{_length};
1036  
1037 # print("param_widgets,initialize_labels,first:$first\n");
1038 # print("param_widgets,initialize_labels,length:$length\n");
1039  
1040 for ( my $i = $first ; $i < $length ; $i++ ) {
1041 $blank_labels[$i] = '';
1042 }
1043  
1044 $labels->specs($default_param_specs);
1045 $labels->frame( $param_widgets->{_labels_frame_href} );
1046 $labels->texts( \@blank_labels );
1047  
1048 $param_widgets->{_labels_w_aref} = $labels->get_w_aref();
1049 }
1050  
1051 =head2 sub initialize_values
1052  
1053  
1054 =cut
1055  
1056 sub initialize_values {
1057 my ($self) = @_;
1058 my ( $values, $first, $length );
1059 my @blank_values = ();
1060 use aliased 'App::SeismicUnixGui::misc::value_boxes';
1061 $values = value_boxes->new();
1062  
1063 $first = $param_widgets->{_first_idx};
1064 $length = $param_widgets->{_length};
1065  
1066 for ( my $i = $first ; $i < $length ; $i++ ) {
1067 $blank_values[$i] = '';
1068 }
1069  
1070 $values->specs($default_param_specs);
1071 $values->frame( $param_widgets->{_values_frame_href} );
1072 $values->texts( \@blank_values );
1073  
1074 $param_widgets->{_values_w_aref} = $values->get_w_aref();
1075  
1076 }
1077  
1078 =head2 sub range
1079  
1080 establish the first and last
1081 indices of the array
1082 foreach my $key (sort keys %$ref_hash) {
1083 print (" param_widgets,range, key is $key, value is $ref_hash->{$key}\n");
1084 }
1085  
1086 =cut
1087  
1088 sub range {
1089 my ( $self, $ref_hash ) = @_;
1090  
1091 # for adding to flows as a user-built flow
1092 if ( $param_widgets->{_is_add2flow_button}
1093 || $param_widgets->{_is_add2flow} )
1094 {
1095  
1096 $param_widgets->{_first_idx} = $ref_hash->{_param_sunix_first_idx};
1097 $param_widgets->{_length} = $ref_hash->{_param_sunix_length};
1098  
1099 # print("1.param_widgets,range, (add2flow_button and add2flow) first idx:$param_widgets->{_first_idx}, and length:$param_widgets->{_length}\n");
1100 }
1101  
1102 # for sunix selections
1103 elsif ( $param_widgets->{_is_sunix_listbox} ) {
1104  
1105 $param_widgets->{_first_idx} = $ref_hash->{_param_sunix_first_idx};
1106 $param_widgets->{_length} = $ref_hash->{_param_sunix_length};
1107  
1108 # print("2. param_widgets,range, (sunix_listbox) first idx:$param_widgets->{_first_idx}, and length:$param_widgets->{_length}\n");
1109 }
1110  
1111 # for user-built flows
1112 elsif ($param_widgets->{_is_flow_listbox_grey_w}
1113 || $param_widgets->{_is_flow_listbox_pink_w}
1114 || $param_widgets->{_is_flow_listbox_green_w}
1115 || $param_widgets->{_is_flow_listbox_blue_w}
1116 || $param_widgets->{_is_flow_listbox_color_w}
1117 || $param_widgets->{_is_user_built_flow} )
1118 {
1119  
1120 $param_widgets->{_first_idx} = $ref_hash->{_param_flow_first_idx};
1121 $param_widgets->{_length} = $ref_hash->{_param_flow_length};
1122  
1123 # print("3. param_widgets,range, (user-built-flow) first idx:$param_widgets->{_first_idx}, and length:$param_widgets->{_length}\n");
1124 }
1125  
1126 # button for L_SU and no button for project selector
1127 elsif ($ref_hash->{_is_superflow_select_button}
1128 || $ref_hash->{_is_superflow} )
1129 {
1130  
1131 $param_widgets->{_first_idx} = $ref_hash->{_superflow_first_idx};
1132 $param_widgets->{_length} = $ref_hash->{_superflow_length};
1133  
1134 # print("4. param_widgets,range, (superflows) first idx:$param_widgets->{_first_idx}, and length:$param_widgets->{_length}\n");
1135  
1136 # # case of now pre-existing color (not even neutral) and the perl flow is selected
1137 # this case actually does not need range because the following subroutines estimate
1138 # the length fromt he scalar of the array and all correctly assume that the first index=0
1139 # elsif ($ref_hash->{_is_user_built_flow} && $ref_hash->{_is_new_listbox_selection} ) {
1140 #
1141 # $param_widgets->{_first_idx} = $ref_hash->{_param_flow_first_idx};
1142 # $param_widgets->{_length} = $ref_hash->{_param_flow_length};
1143 # print("5. param_widgets,range, (user-built-flow) first idx:$param_widgets->{_first_idx}, and length:$param_widgets->{_length}\n");
1144 #
1145 # }
1146  
1147 # case of now pre-existing color (not even neutral) and the perl flow is selected
1148 # this case actually does not need range because the following subroutines estimate
1149 # the length fromt he scalar of the array and all correctly assume that the first index=0
1150 }
1151 else {
1152  
1153 #NADA print ("6. param_widgets,range, _missing ref_hash\n");
1154 }
1155  
1156 # print ("6. param_widgets,range, _values_w_aref: $param_widgets->{_values_w_aref}\n");
1157 return ();
1158 }
1159  
1160 =head2 sub redisplay_check_buttons
1161  
1162 update colors in check button boxes
1163  
1164 =cut
1165  
1166 sub redisplay_check_buttons {
1167 my ($self) = @_;
1168 my $button_w_aref = $param_widgets->{_check_buttons_w_aref};
1169 my $first = $param_widgets->{_first_idx};
1170 my $length = scalar @{ $param_widgets->{_check_buttons_settings_aref} };
1171  
1172 # my $length = $param_widgets->{_length};
1173 my $settings_aref = $param_widgets->{_check_buttons_settings_aref};
1174  
1175 # print("1. param_widgets,redisplay_check_buttons,settings @{$settings_aref}\n");
1176 # print("2. param_widgets,redisplay_check_buttons,settings @{$param_widgets->{_check_buttons_settings_aref}}[0]\n");
1177 # print("2. param_widgets,redisplay_check_buttons,length: $length\n");
1178  
1179 if ( $button_w_aref && $settings_aref ) {
1180  
1181 for ( my $i = $first ; $i < $length ; $i++ ) {
1182  
1183 @$button_w_aref[$i]->configure(
1184 -onvalue => 'on',
1185 -offvalue => 'off',
1186 -selectcolor => 'green',
1187 -activebackground => 'red',
1188 -background => 'red',
1189 -variable => \@$settings_aref[$i],
1190 );
1191 }
1192 }
1193 else {
1194 print("param_widgets, redisplay_check_buttons missing parameters\n");
1195 }
1196 return ();
1197 }
1198  
1199 =head2 sub redisplay_labels
1200  
1201 print("1. redisplay, resdisplay_labels, text is @{$label_array_ref}[$i]\n");
1202 print("redisplay, resdisplay_labels, i is $i\n");
1203 print("2. redisplay, resdisplay_labels, text is @{$LSU->{_label_array_ref}}[$i]\n");
1204  
1205 =cut
1206  
1207 sub redisplay_labels {
1208 my ($self) = @_;
1209 my $labels_w_aref = $param_widgets->{_labels_w_aref};
1210 my $labels_aref = $param_widgets->{_labels_aref};
1211 my $first = $param_widgets->{_first_idx};
1212 my $length = scalar @{ $param_widgets->{_labels_aref} };
1213  
1214 # my $length = $param_widgets->{_length};
1215  
1216 if ($labels_w_aref) {
1217 for ( my $i = $first ; $i < $length ; $i++ ) {
1218  
1219 # print("i:$i param_widgets,redisplay_labels length:$length\n");
1220 # print(" text is @{$labels_aref}\n");
1221 @$labels_w_aref[$i]->configure( -text => @$labels_aref[$i], );
1222 }
1223 }
1224 else {
1225 print(
1226 "param_widgets,redisplay labels, Warning parameters or labels_w_aref missing \n"
1227 );
1228 }
1229  
1230 return ();
1231 }
1232  
1233 =head2 sub redisplay_values
1234  
1235 display parameter values without quotes
1236 although internally we always have quotes for strings
1237 and no quotes if the value looks like a number
1238  
1239 i/p: 2 array references
1240 o/p: array reference
1241  
1242 N.B. This is an ENTRY widget
1243 textvariables must be a reference in order
1244 for -validatecommand to work. BEWARE!
1245  
1246 For the Entry widget do not alter the
1247 textvariable directly while using
1248 validatecommand but instead
1249 indirectly delete the textvarible and replace it using
1250 the insert method
1251
1252 &_changes is invoked if
1253 there is a new selection after an entry change
1254 or even just if redisplay is selected
1255 _changes returns a 0 to invoke an error check
1256 In main, focus is forced to follows the mouse
1257 so focus will change whenever mouse moves to a new
1258 widget. That means the _changes will be invoked at every
1259 shift of the mouse to a new widget.
1260
1261 use App::SeismicUnixGui::misc::control '0.0.3' to remove terminal quotes for values, only for display purposes;
1262 when later read again the values will be given quotes if they
1263 do not look like a number-- this occurs in a superclass
1264
1265  
1266 =cut
1267  
1268 sub redisplay_values {
1269  
1270 my ($self) = @_;
1271 my $values_w_aref = $param_widgets->{_values_w_aref};
1272 my $values_aref = $param_widgets->{_values_aref};
1273 my $first = $param_widgets->{_first_idx};
1274 my $length = scalar @{ $param_widgets->{_values_aref} };
1275  
1276 # my $length = $param_widgets->{_length};
1277 # print("param_widgets, redisplay_values, length is $length\n");
1278 if ( length($values_w_aref)
1279 and length($values_aref) )
1280 {
1281  
1282 for ( my $i = $first ; $i < $length ; $i++ ) {
1283  
1284 my $control = control->new();
1285  
1286 # print("1. param_widgets,redisplay_values,chkbtn @{$param_widgets->{_check_buttons_settings_aref}}[$i]\n");
1287 # print("param_widgets, redisplay_values, i is $i\n");
1288 # print("1. param_widgets, redisplay_values, value is @{$values_aref}[$i]\n");
1289  
1290 # remove terminal quotes for values, only for display purposes
1291 # when later read again the values will be given quotes if they
1292 # do not look like a number-- this occurs in a superclass
1293 @{$values_aref}[$i] =
1294 $control->get_no_quotes( @{$values_aref}[$i] );
1295  
1296 # print("2. param_widgets, redisplay_values, quoteless value is @{$values_aref}[$i]\n");
1297  
1298 @$values_w_aref[$i]->configure(
1299 -validate => 'focus',
1300 -validatecommand => [ \&_changes, $self, $i ],
1301 -invalidcommand => \&error_check,
1302 );
1303  
1304 my $widget = @{$values_w_aref}[$i];
1305 $widget->delete( 0, 'end' );
1306 $widget->insert( 0, @{$values_aref}[$i] );
1307  
1308 # print("2. param_widgets,redisplay_values,chkbtn @{$param_widgets->{_check_buttons_settings_aref}}[$i]\n");
1309 }
1310 }
1311 else {
1312 print("2. param_widgets,redisplay_values,missing parameters\n");
1313 }
1314  
1315 # print("param_widgets, redisplay_values, first item's value is @{$values_aref}[$first]\n");
1316 # print("param_widgets, redisplay_values, last item's values is @{$values_aref}[($length-1)]\n");
1317 # print("param_widgets, redisplay_values, last values are @{$values_aref}\n");
1318  
1319 return ();
1320 }
1321  
1322 =head2 sub set_current_program
1323  
1324 used in main by
1325 flow_select,
1326 sunix_select
1327 and delete_from_flow_button
1328  
1329 =cut
1330  
1331 sub set_current_program_name {
1332  
1333 my ( $self, $prog_name ) = @_;
1334  
1335 if ( length($prog_name) ) {
1336  
1337 $param_widgets->{_current_program_name} = $prog_name;
1338  
1339 # print("param_widgets,set_current_program, program name: $param_widgets->{_current_program_name}\n");
1340  
1341 }
1342 else {
1343 print("param_widgets,set_current_program, missing program name\n");
1344 }
1345 }
1346  
1347 =head2 sub set_first_idx
1348  
1349 =0
1350  
1351 =cut
1352  
1353 sub set_first_idx {
1354  
1355 my ($self) = @_;
1356 $param_widgets->{_first_idx} = 0;
1357  
1358 # print("param-widgets,first_idx:$param_widgets->{_first_idx}\n");
1359 return ();
1360 }
1361  
1362 =head2 sub set_labels_frame
1363  
1364 a widget reference
1365  
1366 =cut
1367  
1368 sub set_labels_frame {
1369 my ( $self, $labels_frame_href ) = @_;
1370 $param_widgets->{_labels_frame_href} = $labels_frame_href;
1371  
1372 }
1373  
1374 =head2 sub set_length
1375  
1376 override default length values
1377
1378 =cut
1379  
1380 sub set_length {
1381  
1382 my ( $self, $length ) = @_;
1383 if ($length) {
1384  
1385 $param_widgets->{_length} = $length;
1386  
1387 # print("param_widgets,set_length = $param_widgets->{_length}\n");
1388  
1389 }
1390 else {
1391  
1392 # print("param_widgets,missing length NADA\n");
1393 }
1394 }
1395  
1396 =head2 sub set_check_buttons_w_aref
1397  
1398  
1399 =cut
1400  
1401 sub set_check_buttons_w_aref {
1402 my ( $self, $check_buttons_w_aref ) = @_;
1403  
1404 if ($check_buttons_w_aref) {
1405  
1406 $param_widgets->{_check_buttons_w_aref} = $check_buttons_w_aref;
1407  
1408 # print("param_widgets,set_check_buttons_w_aref, $check_buttons_w_aref \n");
1409  
1410 }
1411 else {
1412 print(
1413 "param_widgets, set_check_buttons_w_aref,missing check_buttons_w_aref \n"
1414 );
1415  
1416 }
1417 return ();
1418 }
1419  
1420 =head2 set_labels_w_aref
1421  
1422 =cut
1423  
1424 sub set_labels_w_aref {
1425 my ( $self, $labels_w_aref ) = @_;
1426  
1427 if ($labels_w_aref) {
1428  
1429 $param_widgets->{_labels_w_aref} = $labels_w_aref;
1430  
1431 # print("param_widgets,set_labels_w_aref, $labels_w_aref \n");
1432  
1433 }
1434 else {
1435 print("param_widgets,set_labels_w_aref, missing labels_w_aref \n");
1436  
1437 }
1438 return ();
1439 }
1440  
1441 =head2 sub set_values_frame
1442  
1443 a widget reference
1444  
1445 =cut
1446  
1447 sub set_values_frame {
1448  
1449 my ( $self, $values_frame_href ) = @_;
1450  
1451 if ( defined $values_frame_href ) {
1452  
1453 $param_widgets->{_values_frame_href} = $values_frame_href;
1454  
1455 }
1456 else {
1457 print("param_widgets, set_values_frame, missing values_frame_href\n");
1458 }
1459  
1460 return ();
1461 }
1462  
1463 =head2 set_values_w_aref
1464  
1465 =cut
1466  
1467 sub set_values_w_aref {
1468 my ( $self, $values_w_aref ) = @_;
1469  
1470 if ($values_w_aref) {
1471  
1472 $param_widgets->{_values_w_aref} = $values_w_aref;
1473  
1474 # print("param_widgets,set_values_w_aref, $param_widgets->{_values_w_aref}\n");
1475  
1476 }
1477 else {
1478 print("param_widgets,set_values_w_aref, missing values_w_aref \n");
1479 }
1480 return ();
1481 }
1482  
1483 =head2 sub show_values
1484  
1485 packing
1486  
1487 =cut
1488  
1489 sub show_values {
1490 my ($self) = @_;
1491 my ( $first, $length );
1492 my (@values_w);
1493  
1494 @values_w = @{ $param_widgets->{_values_w_aref} };
1495 $first = $param_widgets->{_first_idx};
1496 $length = $param_widgets->{_length};
1497  
1498 # print("param_widgets,show_values,first:$first\n");
1499 # print("param_widgets,show_values,length:$length\n");
1500  
1501 for ( my $i = $first ; $i < $length ; $i++ ) {
1502  
1503 # print("param_widgets,show_values,values_w at $i $values_w[$i]\n");
1504 $values_w[$i]->pack(
1505 -side => 'top',
1506 -anchor => 'w',
1507 -fill => 'x'
1508 );
1509 }
1510 return ();
1511 }
1512  
1513 =head2 sub set_check_buttons_frame
1514
1515 set check_buttons by user from outside
1516  
1517 =cut
1518  
1519 sub set_check_buttons_frame {
1520 my ( $self, $check_buttons_frame_href ) = @_;
1521 $param_widgets->{_check_buttons_frame_href} = $check_buttons_frame_href;
1522  
1523 return ();
1524 }
1525  
1526 =head2 sub set_entry_change_status
1527  
1528 =cut
1529  
1530 sub set_entry_change_status {
1531 my ( $self, $status ) = @_;
1532 $param_widgets->{_changed_entry} = $status;
1533  
1534 # print("param_widgets, set_entry_change_status: to $status\n");
1535 return ();
1536 }
1537  
1538 =head2 sub set_location_in_gui
1539  
1540 set check_buttons by user from outside
1541
1542 foreach my $key (sort keys %$here) {
1543 print (" param_widgets,set_location_in_gui, key is $key, value is $here->{$key}\n");
1544 }
1545  
1546 =cut
1547  
1548 sub set_location_in_gui {
1549 my ( $self, $location_href ) = @_;
1550 my $here = $location_href;
1551  
1552 #print("param_widgets, set_location_in_gui , _values_w_aref, $param_widgets->{_values_w_aref} \n");
1553  
1554 if ( $here->{_is_flow_listbox_grey_w} && $here->{_is_add2flow} ) {
1555  
1556 _reset $param_widgets->{_is_flow_listbox_grey_w} = $true;
1557 $param_widgets->{_is_flow_listbox_color_w} = $true;
1558  
1559 # print("param_widgets, set_location_in_gui, _is_flow_listbox_grey_w and _is_add2flow \n");
1560  
1561 }
1562 elsif ( $here->{_is_flow_listbox_grey_w} ) {
1563  
1564 _reset $param_widgets->{_is_flow_listbox_grey_w} = $true;
1565 $param_widgets->{_is_flow_listbox_color_w} = $true;
1566  
1567 # print("param_widgets, set_location_in_gui, _is_flow_listbox_grey_w ++ true\n");
1568  
1569 }
1570 elsif ( $here->{_is_flow_listbox_pink_w} ) {
1571  
1572 _reset $param_widgets->{_is_flow_listbox_pink_w} = $true;
1573 $param_widgets->{_is_flow_listbox_color_w} = $true;
1574  
1575 # print("param_widgets, set_location_in_gui, _is_flow_listbox_pink_w ++\n");
1576  
1577 }
1578 elsif ( $here->{_is_flow_listbox_green_w} ) {
1579  
1580 _reset $param_widgets->{_is_flow_listbox_green_w} = $true;
1581 $param_widgets->{_is_flow_listbox_color_w} = $true;
1582  
1583 # print("param_widgets, set_location_in_gui, _is_flow_listbox_green_w ++\n");
1584  
1585 }
1586 elsif ( $here->{_is_flow_listbox_blue_w} ) {
1587  
1588 _reset $param_widgets->{_is_flow_listbox_blue_w} = $true;
1589 $param_widgets->{_is_flow_listbox_color_w} = $true;
1590  
1591 # print("param_widgets, set_location_in_gui, _is_flow_listbox_blue_w ++\n");
1592  
1593 }
1594 elsif ( $here->{_is_flow_listbox_color_w} ) {
1595  
1596 _reset $param_widgets->{_is_flow_listbox_color_w} = $true;
1597  
1598 # print("param_widgets, set_location_in_gui, _is_flow_listbox_color_w\n");
1599  
1600 }
1601 elsif ( $here->{_is_add2flow} ) {
1602  
1603 $param_widgets->{_is_new_listbox_selection} =
1604 $true; # so change not allowed
1605 # print("param_widgets, set_location_in_gui, _is_new_listbox_selection \n");
1606  
1607 }
1608 elsif ( $here->{_is_add2flow_button} ) {
1609  
1610 _reset $param_widgets->{_is_new_listbox_selection} =
1611 $true; # so change not allowed
1612 # print("param_widgets, set_location_in_gui, _is_new_listbox_selection \n");
1613  
1614 }
1615 elsif ( $here->{_is_sunix_listbox} ) {
1616  
1617 _reset();
1618 $param_widgets->{_is_new_listbox_selection} =
1619 $true; # so changes not allowed
1620 $param_widgets->{_is_sunix_listbox} = $true;
1621  
1622 # print("param_widgets, set_location_in_gui, _is_sunix_listbox and _is_new_listbox_selection\n");
1623  
1624 }
1625 elsif ( $here->{_is_moveNdrop_in_flow} ) {
1626  
1627 _reset();
1628 $param_widgets->{_is_flow_listbox_grey_w} = $true;
1629 $param_widgets->{_is_flow_listbox_pink_w} = $true;
1630 $param_widgets->{_is_flow_listbox_green_w} = $true;
1631 $param_widgets->{_is_flow_listbox_blue_w} = $true;
1632 $param_widgets->{_is_flow_listbox_color_w} = $true;
1633 $param_widgets->{_is_moveNdrop_in_flow} = $true;
1634  
1635 # print("param_widgets, set_location_in_gui, _is_moveNdrop_in_flow ++ \n");
1636  
1637 }
1638 elsif ( $here->{_is_delete_from_flow_button} ) {
1639  
1640 _reset();
1641 $param_widgets->{_is_delete_from_flow_button} = $true;
1642  
1643 # TODO double check if next 2-5 lines should be flse instead
1644 $param_widgets->{_is_flow_listbox_grey_w} = $true;
1645 $param_widgets->{_is_flow_listbox_pink_w} = $true;
1646 $param_widgets->{_is_flow_listbox_green_w} = $true;
1647 $param_widgets->{_is_flow_listbox_blue_w} = $true;
1648 $param_widgets->{_is_flow_listbox_color_w} = $true;
1649  
1650 # print("param_widgets, set_location_in_gui, _is_delete_from_flow_button ++\n");
1651  
1652 }
1653 elsif ( $here->{_is_superflow_select_button} ) {
1654  
1655 _reset
1656  
1657 # print("param_widgets,NEW set_location_in_gui, superflow_select_button\n");
1658 $param_widgets->{_is_superflow_select_button} = $true;
1659  
1660 # print("param_widgets, set_location_in_gui, _is_superflow_select_button \n")
1661  
1662 }
1663 else {
1664 print("param_widgets, set_location_in_gui, missing params \n");
1665 }
1666 return ();
1667 }
1668  
1669 =head2 sub set_labels
1670
1671 set labels by user from outside
1672  
1673 =cut
1674  
1675 sub set_labels {
1676 my ( $self, $labels_aref ) = @_;
1677  
1678 # print("param_widgets,set_labels\n");
1679 if ( defined $labels_aref ) {
1680  
1681 $param_widgets->{_labels_aref} = $labels_aref;
1682  
1683 # my $length = scalar @{ $param_widgets->{_labels_aref} };
1684 # print("param_widgets,set_labels, length=$length\n");
1685  
1686 }
1687 else {
1688 print("param_widgets,set_labels, missinglabels\n");
1689 }
1690 return ();
1691 }
1692  
1693 =head2 sub set_prog_name_sref
1694 set prog_name by user from outside
1695  
1696 =cut
1697  
1698 sub set_prog_name_sref {
1699 my ( $self, $prog_name_sref ) = @_;
1700  
1701 if ($prog_name_sref) {
1702 $param_widgets->{_prog_name_sref} = $prog_name_sref;
1703  
1704 print("param_widgets,set_prog_name_sref, $$prog_name_sref\n");
1705  
1706 }
1707 else {
1708 print("param_widgets, set_prog_name_sref, missing prog name\n");
1709 }
1710 return ();
1711 }
1712  
1713 =head2 sub set_value4entry_button_chosen
1714  
1715 assign value to Entry Buttonchosen
1716  
1717 print("param is $entry_param;\n");
1718 print ("selected widget is # $LSU->{_parameter_value_index}\");
1719 print ("label is $out\n");
1720  
1721 =cut
1722  
1723 sub set_value4entry_button_chosen {
1724 my ( $self, $value ) = @_;
1725  
1726 # first and last indices
1727 my $first = $param_widgets->{_first_idx};
1728 my $length = $param_widgets->{_length};
1729  
1730 # print("param_widgets,set_entry_button_chosen,length_=$param_widgets->{_length} \n");
1731  
1732 my $widget = $param_widgets->{_entry_button_chosen_widget};
1733 print("param_widgets,set_entry_button_chosen,widget,=$widget\n");
1734  
1735 # run through widgets until the match is made
1736 for ( my $choice = $first ; $choice < $length ; $choice++ ) {
1737 if ( $widget eq @{ $param_widgets->{_values_w_aref} }[$choice] ) {
1738  
1739 @{ $param_widgets->{_values_w_aref} }[$choice]
1740 ->configure( -text => $value );
1741  
1742 print(
1743 "param_widgets,set_entry_button_chosen,value= @{$param_widgets->{_values_w_aref}}[$choice]\n"
1744 );
1745 print("param_widgets,set_entry_button_chosen,choice= $choice\n");
1746  
1747 }
1748 }
1749 return ($value);
1750 }
1751  
1752 =head2 sub set_values
1753
1754 set values by user from outside
1755  
1756 =cut
1757  
1758 sub set_values {
1759 my ( $self, $values_aref ) = @_;
1760  
1761 if ( defined $values_aref ) {
1762  
1763 $param_widgets->{_values_aref} = $values_aref;
1764  
1765 # print("param_widgets,set_values,@{$param_widgets->{_values_aref}}\n");
1766  
1767 }
1768 else {
1769 print("param_widgets,set_values, values_aref missing\n");
1770 }
1771  
1772 return ();
1773 }
1774  
1775 =head2 sub show_check_buttons
1776  
1777 packing
1778  
1779 =cut
1780  
1781 sub show_check_buttons {
1782 my ($self) = @_;
1783 my $button_w_ref = $param_widgets->{_check_buttons_w_aref};
1784 my $first = $param_widgets->{_first_idx};
1785 my $length = $param_widgets->{_length};
1786  
1787 for ( my $i = $first ; $i < $length ; $i++ ) {
1788 @$button_w_ref[$i]->pack( -anchor => 'n', -fill => 'y' );
1789 }
1790 return ();
1791  
1792 }
1793  
1794 =head2 sub show_labels
1795
1796 specs come from local private variables
1797 uses default specs, unless overwritten
1798 specs are not fed from above
1799
1800 packing
1801  
1802 =cut
1803  
1804 sub show_labels {
1805 my ($self) = @_;
1806 my ( $first, $length );
1807 my (@labels_w);
1808  
1809 @labels_w = @{ $param_widgets->{_labels_w_aref} };
1810 $first = $param_widgets->{_first_idx};
1811 $length = $param_widgets->{_length};
1812  
1813 # print("param_widgets,show_labels,first:$first\n");
1814 # print("param_widgets,show_labels,length:$length\n");
1815 for ( my $i = $first ; $i < $length ; $i++ ) {
1816 $labels_w[$i]->pack(
1817 -side => 'top',
1818 -anchor => 'w',
1819 -fill => 'x'
1820 );
1821 }
1822 return ();
1823 }
1824  
1825 1;