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

filter: Statementstmt 0.0% 0 / 29 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 42 CC 1 SCAR 6.9
CC
1
Cov
0%
_initialize
2.0
BUILD
2.0
BEGIN
2.0
CRAP 2.0
1 package App::SeismicUnixGui::misc::system;
2  
3 =head1 DOCUMENTATION
4  
5 =head2 SYNOPSIS
6  
7 PERL PROGRAM NAME: system
8 AUTHOR: Juan Lorenzo
9 DATE: December 1, 2020
10  
11  
12 DESCRIPTION
13 Basic class with system attributes
14  
15 BASED ON:
16  
17  
18 =cut
19  
20 =head2 USE
21  
22 =head3 NOTES
23  
24 =head4 Examples
25  
26 =head2 CHANGES and their DATES
27  
28 =cut
29  
30 =head2 Notes from bash
31
32 =cut
33  
34 use Moose;
35 our $VERSION = '0.0.1';
36  
37 =head2 Import modules
38  
39 =cut
40  
41 use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants';
42  
43 =head2 Instantiation
44  
45 =cut
46  
47 my $get = L_SU_global_constants->new();
48  
49 =head2 Declare Special Variables
50  
51 =cut
52  
53 my $var = $get->var();
54 my $default_param_specs = $get->param();
55 my $on = $var->{_on};
56 my $true = $var->{_true};
57 my $false = $var->{_false};
58 my $empty_string = $var->{_empty_string};
59 #my @array_ref;
60 #my @empty_array = (0); # length=1
61 #
62 #my $index_start = -1;
63 #my $earliest_index_start = -3;
64 #my $prior_index_start = -2;
65 #my $current_index_start = -1;
66 #my $next_index_start = 0;
67 #
68 #my $no_color = 'no_color';
69 #my $neutral = 'neutral';
70 #my $earliest_color_start = $no_color;
71 #my $current_color_start = $no_color;
72 #my $next_color_start = $no_color;
73 #my $prior_color_start = $no_color;
74 #
75 #my $count_start = -1;
76 #
77 #
78 #
79 #=head2 Declare attributes
80 #
81 #=cut
82 #
83 #has '_count' => (
84 # default => $count_start,
85 # is => 'ro',
86 # isa => 'Int',
87 # reader => 'get_count',
88 # writer => 'set_count',
89 # predicate => 'has_count',
90 #);
91 #
92 #has 'button' => (
93 # default => 'no_button',
94 # is => 'rw',
95 # isa => 'Str',
96 # reader => 'get_button',
97 # writer => 'set_button',
98 # predicate => 'has_button',
99 # trigger => \&_update_button,
100 #);
101 #
102 #
103 #=head2 private anonymous hashes containing
104 #sequential history
105 #
106 #=cut
107 #
108 #my $FileDialog_type_href = {
109 # _item => $empty_string,
110 # _index => $empty_string,
111 # _name => 'FileDialog_type',
112 # _most_recent => $empty_string,
113 # _earliest => $empty_string,
114 # _next => $empty_string,
115 # _prior => $empty_string,
116 #};
117 #
118 #
119 #=
120 #=head2 sub _update_button
121 #Assign new button to private key: _XXX_button
122 #
123 #print("gui_history, _update_button, ans= $ans\n");
124 #print("gui_history, _update_button, button= $button\n");
125 #
126 #=cut
127 #
128 #sub _update_button {
129 #
130 # my ( $gui_history, $new_most_recent_button, $new_new_prior_button ) = @_;
131 #
132 # # my $button = _find_button( $gui_history, $new_most_recent_button );
133 #
134 # if ( $new_most_recent_button ne $empty_string ) {
135 #
136 # if ( defined $button_href ) {
137 #
138 # # update the history of add2flow_button usage according to the color used
139 # $button_href->{_earliest} = $button_href->{_prior};
140 # $button_href->{_prior} = $button_href->{_most_recent};
141 # $button_href->{_most_recent} = $new_most_recent_button;
142 #
143 # ( $gui_history->get_defaults() )->{_button_href} = $button_href;
144 # }
145 #
146 # if ( $new_most_recent_button eq 'FileDialog_button' ) {
147 #
148 # ( $gui_history->get_defaults() )->{_is_FileDialog_button} = $true;
149 #
150 # _set_click_sequence(
151 # $gui_history,
152 # $FileDialog_button_click_seq_href
153 # );
154 #
155 # # update the history of FileDialog_button use according to click count
156 # ( $gui_history->get_defaults )->{_FileDialog_button_click_seq_href} = $FileDialog_button_click_seq_href;
157 #
158 # # print("gui_history, _update_button, button matched = $new_most_recent_button\n");
159 # return ();
160 #
161 # } elsif ( $new_most_recent_button eq 'add2flow_button' ) {
162 #
163 # ( $gui_history->get_defaults() )->{_is_add2flow_button} = $true;
164 # ( $gui_history->get_defaults() )->{_is_add2flow} = $true;
165 #
166 # _set_click_sequence(
167 # $gui_history,
168 # $add2flow_button_click_seq_href
169 # );
170 #
171 # # update the history of add2flow_button use according to click count
172 # ( $gui_history->get_defaults() )->{_add2flow_button_click_seq_href}
173 # = $add2flow_button_click_seq_href;
174 # ( $gui_history->get_defaults() )->{_is_new_listbox_selection} = $true;
175 #
176 # # print("gui_history, _update_button, button matched = $new_most_recent_button\n");
177 # return ();
178 # } elsif ( $new_most_recent_button eq 'delete_from_flow_button' ) {
179 #
180 # ( $gui_history->get_defaults() )->{_is_delete_from_flow_button} = $true;
181 #
182 # _set_click_sequence(
183 # $gui_history,
184 # $delete_from_flow_button_click_seq_href
185 # );
186 #
187 # # update the history of delete_from_flow_button use according to click count
188 # ( $gui_history->get_defaults )->{_delete_from_flow_button_click_seq_href}
189 # = $delete_from_flow_button_click_seq_href;
190 #
191 # _reset( $gui_history, 'listbox_color_w' );
192 #
193 # # find out the latest color
194 # # assume that flow select color is the latest color
195 # my $color = _get_most_recent_color_selected_in_gui($gui_history);
196 #
197 # my $key1 = '_is_flow_listbox_' . $color . '_w';
198 #
199 # ( $gui_history->get_defaults() )->{$key1} = $true;
200 # ( $gui_history->get_defaults() )->{_is_flow_listbox_color_w} = $true;
201 #
202 # # print("gui_history, _update_button, delete_from_flow_button \n");
203 #
204 # # print("gui_history, _update_button, button matched = $new_most_recent_button\n");
205 # return ();
206 #
207 # } elsif ( $new_most_recent_button eq 'flow_item_down_arrow_button' ) {
208 #
209 # ( $gui_history->get_defaults() )->{_is_flow_item_down_arrow_button}
210 # = $true;
211 #
212 # _set_click_sequence(
213 # $gui_history,
214 # $flow_item_down_arrow_button_click_seq_href
215 # );
216 #
217 # # update the history of flow_item_down_arrow_button use according to click count
218 # ( $gui_history->get_defaults )->{_flow_item_down_arrow_button_click_seq_href}
219 # = $flow_item_down_arrow_button_click_seq_href;
220 #
221 # # print("gui_history, _update_button, button matched = $new_most_recent_button\n");
222 # return ();
223 #
224 # } elsif ( $new_most_recent_button eq 'flow_item_up_arrow_button' ) {
225 #
226 # ( $gui_history->get_defaults() )->{_is_flow_item_up_arrow_button} = $true;
227 #
228 # _set_click_sequence(
229 # $gui_history,
230 # $flow_item_up_arrow_button_click_seq_href
231 # );
232 #
233 # # update the history of flow_item_up_arrow_button use according to click count
234 # ( $gui_history->get_defaults )->{_flow_item_up_arrow_button_click_seq_href}
235 # = $flow_item_up_arrow_button_click_seq_href;
236 #
237 # # print("gui_history, _update_button, button matched = $new_most_recent_button\n");
238 # return ();
239 #
240 # } elsif ( $new_most_recent_button eq 'flow_select' ) {
241 #
242 # my $ans = ( $gui_history->get_defaults() )->{_count};
243 #
244 # # print("1. gui_history, _update_button, for flow_select count=$ans\n");
245 #
246 # my $_flow_listbox_color_w = _get_flow_listbox_color_w($gui_history);
247 # my $most_recent_index = $flow_widgets->get_flow_selection($_flow_listbox_color_w);
248 #
249 # # CASE 1: flow listbox is cleared with no highlights
250 # if ( not defined $most_recent_index ) {
251 #
252 # # no change to indices
253 # # increment record sequence as total number of mouse clicks
254 # _set_click_sequence(
255 # $gui_history,
256 # $flow_select_click_seq_href
257 # );
258 #
259 # # print("2. gui_history, _update_button, for _flow_listbox_color_w=$_flow_listbox_color_w \n");
260 # ( $gui_history->get_defaults() )->{_flow_select_click_seq_href}
261 # = $flow_select_click_seq_href;
262 # }
263 #
264 # # CASE 2 flow listbox must have been selected and have highlighted an element
265 # # and the selected index must be different to the previous index
266 # # only such case among the many tracked properties of the GUI
267 # elsif ( $most_recent_index ne $empty_string
268 # and $most_recent_index ne $flow_select_index_href->{_most_recent} ) {
269 #
270 # # update the history of flow_select usage according to the index chosen
271 # $flow_select_index_href->{_earliest} = $flow_select_index_href->{_prior};
272 # $flow_select_index_href->{_prior} = $flow_select_index_href->{_most_recent};
273 # $flow_select_index_href->{_most_recent} = $most_recent_index;
274 # ( $gui_history->get_defaults() )->{_flow_select_index_href} = $flow_select_index_href;
275 #
276 # # print(
277 # # "2. gui_history, _update_button, for flow_select new most_recent_index=$most_recent_index \n");
278 # # print(
279 # # "2. gui_history, _update_button, for flow_select new prior_index=$flow_select_index_href->{_prior} \n"
280 # # );
281 #
282 # # print("gui_history, _update_button, flow_select_click_seq_href= ($gui_history->get_defaults )->{_flow_select_click_seq_href}\n");
283 # # print("3. gui_history, _update_button, flow_select most_recent_index=$most_recent_index \n");
284 #
285 # # print("gui_history, _update_button, flow_select_click_seq_href= ($gui_history->get_defaults )->{_flow_select_click_seq_href}\n");
286 # # print("3. gui_history, _update_button, button matched = $new_most_recent_button\n");
287 #
288 # } elsif ( $most_recent_index ne $empty_string
289 # and $most_recent_index eq $flow_select_index_href->{_most_recent} ) {
290 #
291 # # record sequence as total number of mouse clicks, when user reclicks the same location
292 # # However in _set_click_dequence the property indices will not be updated
293 # # only the general gui count JML 2-2020
294 # _set_click_sequence(
295 # $gui_history,
296 # $flow_select_click_seq_href
297 # );
298 #
299 # # not really reset ??? mystery
300 # ( $gui_history->get_defaults() )->{_flow_select_click_seq_href}
301 # = $flow_select_click_seq_href;
302 #
303 # } else {
304 # print(" gui_history, set_button for flow_select, unexpected result \n");
305 # }
306 #
307 # return ();
308 #
309 # } elsif ( $new_most_recent_button eq 'run_button' ) {
310 #
311 # ( $gui_history->get_defaults() )->{_is_run_button} = $true;
312 #
313 # _set_click_sequence( $gui_history, $run_button_click_seq_href );
314 #
315 # # update the history of run_button use according to click count
316 # ( $gui_history->get_defaults )->{_run_button_click_seq_href} = $run_button_click_seq_href;
317 #
318 # # print("gui_history, _update_button, button matched = $new_most_recent_button\n");
319 # return ();
320 #
321 # } elsif ( $new_most_recent_button eq 'save_button' ) {
322 #
323 # ( $gui_history->get_defaults() )->{_is_save_button} = $true;
324 #
325 # _set_click_sequence( $gui_history, $save_button_click_seq_href );
326 #
327 # # update the history of save_button use according to click count
328 # ( $gui_history->get_defaults )->{_save_button_click_seq_href} = $save_button_click_seq_href;
329 #
330 # # print("gui_history, _update_button, button matched = $new_most_recent_button\n");
331 # return ();
332 #
333 # } elsif ( $new_most_recent_button eq 'save_as_button' ) {
334 #
335 # ( $gui_history->get_defaults() )->{_is_save_as_button} = $true;
336 #
337 # _set_click_sequence( $gui_history, $save_as_button_click_seq_href );
338 #
339 # # update the history of save_as_button use according to click count
340 # ( $gui_history->get_defaults )->{_save_as_button_click_seq_href} = $save_as_button_click_seq_href;
341 #
342 # # print("gui_history, _update_button, button matched = $new_most_recent_button\n");
343 # return ();
344 #
345 # } elsif ( $new_most_recent_button eq 'sunix_select' ) {
346 #
347 # ( $gui_history->get_defaults() )->{_is_sunix_select} = $true;
348 # ( $gui_history->get_defaults() )->{_is_new_listbox_selection} = $true; # so changes not allowed
349 # ( $gui_history->get_defaults() )->{_is_sunix_listbox} = $true;
350 #
351 # # history and sequence is handled by sunix_prog_group_click_seq_href and sunix_select_prog_group_href
352 #
353 # # print("gui_history, _update_button, button matched = $new_most_recent_button\n");
354 # return ();
355 #
356 # } elsif ( $new_most_recent_button eq 'superflow_select_button' ) {
357 #
358 # ( $gui_history->get_defaults() )->{_is_superflow_select_button} = $true;
359 # ( $gui_history->get_defaults() )->{_is_superflow} = $true;
360 # ( $gui_history->get_defaults() )->{_is_pre_built_superflow} = $true;
361 #
362 # _set_click_sequence(
363 # $gui_history,
364 # $superflow_select_button_click_seq_href
365 # );
366 #
367 # # update the history of superflow_select_button use according to click count
368 # ( $gui_history->get_defaults )->{_superflow_select_button_click_seq_href}
369 # = $superflow_select_button_click_seq_href;
370 #
371 # # print("gui_history, _update_button, button matched = $new_most_recent_button\n");
372 # return ();
373 #
374 # } elsif ( $new_most_recent_button eq 'wipe_plots_button' ) {
375 #
376 # ( $gui_history->get_defaults() )->{_is_wipe_plots_button} = $true;
377 #
378 # _set_click_sequence(
379 # $gui_history,
380 # $wipe_plots_button_click_seq_href
381 # );
382 #
383 # # update the history of wipe_plots_button use according to click count
384 # ( $gui_history->get_defaults )->{_wipe_plots_button_click_seq_href} = $wipe_plots_button_click_seq_href;
385 #
386 # # print("gui_history, _update_button, button matched = $new_most_recent_button\n");
387 # return ();
388 #
389 # } else {
390 # print("gui_history,_update_button, button unmatched NADA\n");
391 # return ();
392 # }
393 # } else {
394 # print("gui_history,_update_button, button not found:\n");
395 # return ();
396 # }
397 #}
398 #=head2 sub _get_flow_listbox_color_w
399 #
400 #
401 #=cut
402 #
403 #sub _get_flow_listbox_color_w {
404 # my ($gui_history) = @_;
405 #
406 # my $flow_color = ( $gui_history->get_defaults() )->{_flow_color};
407 #
408 # my $key = '_flow_listbox_' . $flow_color . '_w';
409 #
410 # my $this_flow_listbox_color_w = ( $gui_history->get_defaults() )->{$key};
411 #
412 # return ($this_flow_listbox_color_w);
413 #}
414 #
415 #
416 #
417 #=head2 sub _increment_count
418 #
419 # increment the counter
420 #
421 #=cut
422 #
423 #sub _increment_count {
424 #
425 # my ($gui_history) = @_;
426 #
427 # my $old_count = ( $gui_history->get_defaults() )->{_count};
428 #
429 # # print("gui_history, _increment_count,main_hash old_count=$old_count\n");
430 #
431 # if ( defined $old_count ) {
432 #
433 # my $new_value = $old_count + 1;
434 #
435 # # increment the
436 # # $hash key value whose reference is stored in an attribute
437 # # called defaults
438 # # and increment the '_count' attribute
439 # ( $gui_history->get_defaults() )->{_count} = $new_value;
440 # $gui_history->set_count($new_value);
441 #
442 # my $ans = ( $gui_history->get_defaults() )->{_count};
443 #
444 # # print("gui_history, _increment_count,new value: $ans\n");
445 # } else {
446 # print("gui_history, _increment_count, count missing \n");
447 # }
448 #
449 # # print("gui_history, _increment_count, attribute new value: $ans\n");
450 # return ();
451 #}
452  
453 =head2 sub _initialize
454 Default Tk settings
455 =cut
456  
457 sub _initialize {
458 my ($gui_history) = @_;
459
460 #** @method public _initialize ($)
461 # ....
462 #*
463  
464 my $markers_href = {
465  
466 _Data_menubutton => '',
467 _FileDialog_button_click_seq_href => '',
468 _FileDialog_option => '',
469 _FileDialog_sub_ref => '',
470
471 };
472 my $result = $markers_href;
473  
474 # print(" gui_history, _initialize, result = $result \n ");
475 # if (ref $result) {
476 # print(" gui_history, _initialize, result is a reference \n ");
477 # print(" gui_history, _initialize, = $gui_history \n ");
478 # } else {
479 # print(" gui_history, _initialize, result is NOT a reference \n ");
480 # }
481  
482 $gui_history->set_defaults($result);
483 return ();
484  
485 }
486  
487 =head2 BUILDARGS
488 Initialize contents
489 before instantiation.
490 so superclass definitions
491  
492 =cut
493  
494 around BUILDARGS => sub {
495  
496 my ( $orig, $gui_history, @args ) = @_;
497  
498 if ( scalar @args >= 1 && not ref $args[0] ) {
499  
500 # print(" BUILDARGS initializing with args = @args \n ");
501 # print(" BUILDARGS initializing with orig = $orig \n ");
502 # print(" BUILDARGS initializing with gui_history = $gui_history \n ");
503  
504 return $gui_history->$orig( item => $args[0] );
505 return $gui_history->$orig( indexx => $args[1] );
506  
507 # my $item = $gui_history->get_item();
508 # print(" 1. BUILDARGS item = $item \n ");
509  
510 # foreach my $key ( sort keys %$orig ) {
511 # print(" gui_history, BUILDARGS, key is $key, value is $orig->{$key} \n ");
512 # }
513  
514 } else {
515  
516 # print(" gui_history,BUILDARGS, unexpected external default value(s) NADA\n");
517 my $result = $gui_history->$orig(@_);
518 return ($result);
519 }
520 };
521  
522 =head2 BUILD
523 Initial checking after instantiation
524  
525 =cut
526  
527 sub BUILD {
528 my ($gui_history) = @_;
529  
530 # _defaults attribute start empty
531 # print("1. gui_history,BUILD,initializing with: $gui_history()\n");
532 _initialize($gui_history);
533  
534 # print("2. gui_history,BUILD,initializing with: $gui_history->get_defaults()\n");
535  
536 }
537  
538 __PACKAGE__->meta->make_immutable;
539 1;