lib/App/SeismicUnixGui/specs/plot/suximage_spec.pm untested

filter: Statementstmt 0.0% 0 / 163 Branchbran 0.0% 0 / 22 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 21 Podpod 0.0% 0 / 16 totaltotal 0.0% 0 / 222 CC 12 SCAR 18.3
CC
12
Cov
0%
set_incompatibles
20.0
get_max_index
6.0
get_binding_index_aref
6.0
CRAP 6.2
1 package App::SeismicUnixGui::specs::plot::suximage_spec;
2 use Moose;
3 our $VERSION = '1.0.0';
4  
5 use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants';
6  
7 use aliased 'App::SeismicUnixGui::configs::big_streams::Project_config';
8 use aliased 'App::SeismicUnixGui::sunix::plot::suximage';
9 use App::SeismicUnixGui::misc::SeismicUnix qw($su $suffix_su);
10  
11 my $get = L_SU_global_constants->new();
12 my $var = $get->var();
13  
14 my $empty_string = $var->{_empty_string};
15 my $true = $var->{_true};
16 my $false = $var->{_false};
17 my $file_dialog_type = $get->file_dialog_type_href();
18 my $flow_type = $get->flow_type_href();
19  
20 my $Project = Project_config->new();
21 my $suximage = suximage->new();
22  
23 my $DATA_SEISMIC_SU = $Project->DATA_SEISMIC_SU(); # output data directory
24 my $PL_SEISMIC = $Project->PL_SEISMIC(); # default
25 my $DATA_SEISMIC_TXT= $Project->DATA_SEISMIC_TXT();
26 my $max_index = $suximage->get_max_index();
27  
28 my $is_absclip = $false;
29 my $is_loclip = $false;
30 my $is_hiclip = $false;
31  
32 my $suximage_spec = {
33 _CONFIG => $PL_SEISMIC,
34 _DATA_DIR_OUT => $DATA_SEISMIC_SU,
35 _DATA_DIR_IN => $DATA_SEISMIC_TXT,
36 _DATA_DIR_OUT => $PL_SEISMIC, # DEFAULT
37 _binding_index_aref => '',
38 _suffix_type_in => $su,
39 _data_suffix_in => $suffix_su,
40 _suffix_type_out => $su,
41 _data_suffix_out => $suffix_su,
42 _good_labels_aref => '', # new
43 _file_dialog_type_aref => '',
44 _flow_type_aref => '',
45 _has_infile => $true,
46 _has_outpar => $false,
47 _has_pipe_in => $true,
48 _has_pipe_out => $false,
49 _has_redirect_in => $true,
50 _has_redirect_out => $false,
51 _has_subin_in => $false,
52 _has_subin_out => $false,
53 _is_data => $false,
54 _is_first_of_2 => $true,
55
56 _is_first_of_3or_more => $false,
57 _is_first_of_4or_more => $false,
58 _is_last_of_2 => $true,
59 _is_last_of_3or_more => $true,
60 _is_last_of_4or_more => $true,
61 _is_suprog => $true,
62 _is_superflow => $false,
63 _max_index => $max_index,
64 };
65  
66 # print("suximage_spec, _incompatibles: @{$suximage_spec->{_incompatibles}} \n");
67  
68 =head2 sub binding_index_aref
69  
70 curve, item index = 8, bound to $DATA_SEISMIC_TXT
71 curvefile, item index = 10, bound to $DATA_SEISMIC_TXT
72 picks/mpicks, item index = 35, bound to PL_SEISMIC by default
73  
74 =cut
75  
76 sub binding_index_aref {
77  
78 my ($self) = @_;
79  
80 my @index;
81  
82 $index[0] = 8;
83 $index[1] = 10;
84 $index[2] = 35;
85  
86 $suximage_spec->{_binding_index_aref} = \@index;
87  
88 return ();
89 }
90  
91 =head2 sub get_max_index
92  
93 =cut
94  
95 sub get_max_index {
96 my ($self) = @_;
97  
98 if ( $suximage_spec->{_max_index} ) {
99  
100 my $max_idx = $suximage->get_max_index();
101 return ($max_idx);
102  
103 }
104 else {
105 print("suximage_spec, get_max_index, missing max_index\n");
106 return ();
107 }
108 }
109  
110 =head2 sub set_good_labels
111
112 set value labels that are good
113  
114 =cut
115  
116 sub set_good_labels {
117 my ( $self, $good_labels_aref ) = @_;
118  
119 $suximage_spec->{_good_labels_aref} = $good_labels_aref;
120  
121 return ();
122 }
123  
124 =head2 sub find_incompatibles
125 not_compatible for the following cases
126 is_absclip && (is_loclip || is_hiclip)
127 1 1
128
129 set value labels that are good
130  
131 =cut
132  
133 sub set_incompatibles {
134 my ($self) = @_;
135  
136 my @good_labels_aref = $suximage_spec->{_good_labels_aref};
137  
138 my $length = scalar @good_labels_aref;
139  
140 for ( my $j = 0; $j < $length; $j++ ) {
141  
142 my $good_label = $good_labels_aref[$j];
143  
144 if ( $good_label eq 'absclip' ) {
145 $is_absclip = $true;
146  
147 }
148 elsif ( $good_label eq 'hiclip' ) {
149 $is_hiclip = $true;
150  
151 }
152 elsif ( $good_label eq 'loclip' ) {
153 $is_loclip = $true;
154  
155 }
156 else {
157 print("suximage_spec, set_incompatibles, NONE \n");
158 }
159 }
160  
161 }
162  
163 #=head2 sub get_incompatible
164 #
165 # parameters
166 #
167 #=cut
168 #
169 #sub get_incompatibles {
170 # my ($self) = @_;
171 #
172 # my (@needed);
173 # my @_need_both = ();
174 # my @_need_only_1 = ();
175 # my @_none_needed = ();
176 # my @_all_needed = ();
177 #
178 # my $params = {
179 # _need_both => \@_need_both,
180 # _need_only_1 => \@_need_only_1,
181 # _none_needed => \@_none_needed,
182 # _all_needed => \@_all_needed,
183 # };
184 #
185 # #my $number_groups = 6;
186 #
187 # my @of_two = ('clip','wperc');
188 # push @{$params->{_need_only_1}} , \@of_two;
189 #
190 #
191 #
192 ## print("sugain, get_incomatpibles $length \n");
193 #
194 # my $len_1_needed = scalar @{$params->{_need_only_1}};
195 #
196 # for (my $i=0; $i < $len_1_needed; $i++) {
197 #
198 # print("sugain, get_incompatibles,need_only_1: @{@{$params->{_need_only_1}}[$i]}\n");
199 #
200 # }
201 #
202 ## print("sugain, get_incomatpibles only_one: @only_one\n");
203 #
204 #
205 # return($params);
206 #
207 #}
208 #
209 #
210 # }
211 #
212 #=head2 sub get_incompatibles
213 # not_compatible for the following cases
214 # is_absclip && (is_loclip || is_hiclip)
215 # 1 1
216 #
217 # set value labels that are good
218 #
219 #=cut
220 #
221 #sub get_incompatibles {
222 #
223 # my ($self) = @_;
224 #
225 # if ($is_absclip && ($is_loclip || $is_hiclip)) {
226 # print("Warning: Can not have absclip and (hiclip or loclip)\n");
227 # return();
228 # } else {
229 # print("No incompatibles\n");
230 # }
231 # }
232 #
233  
234 =head2 sub get_binding_index_aref
235  
236 =cut
237  
238 sub get_binding_index_aref {
239 my ($self) = @_;
240 my @index;
241  
242 if ( $suximage_spec->{_binding_index_aref} ) {
243 my $index_aref = $suximage_spec->{_binding_index_aref};
244 return ($index_aref);
245  
246 }
247 else {
248 print(
249 "suximage_spec, get_binding_index_aref, missing binding_index_aref\n"
250 );
251 return ();
252 }
253  
254 my $index_aref = $suximage_spec->{_binding_index_aref};
255  
256 }
257  
258 =head2 sub file_dialog_type_aref
259  
260 type of dialog (Data, Flow, SaveAs) is needed by binding
261 one type of dialog for each index
262  
263 =cut
264  
265 sub file_dialog_type_aref {
266 my ($self) = @_;
267  
268 my @type;
269  
270 $type[0] = $file_dialog_type->{_Data};
271 $type[1] = $file_dialog_type->{_Data};
272 $type[2] = $file_dialog_type->{_Data}; # mpicks bound to PL_SEISMIC directory
273  
274 $suximage_spec->{_file_dialog_type_aref} = \@type;
275  
276 return ();
277  
278 }
279  
280 =head2 sub get_file_dialog_type_aref
281  
282 =cut
283  
284 sub get_file_dialog_type_aref {
285 my ($self) = @_;
286  
287 if ( $suximage_spec->{_file_dialog_type_aref} ) {
288 my @type = @{ $suximage_spec->{_file_dialog_type_aref} };
289 return ( \@type );
290 }
291 else {
292 print(
293 "suximage_spec,get_file_dialog_type_aref, missing file_dialog_type_aref\n"
294 );
295 return ();
296 }
297 }
298  
299 =head2 sub flow_type_aref
300  
301 =cut
302  
303 sub flow_type_aref {
304 my ($self) = @_;
305  
306 my @type;
307  
308 $type[0] = $flow_type->{_user_built};
309  
310 $suximage_spec->{_flow_type_aref} = \@type;
311  
312 return ();
313  
314 }
315  
316 =head2 sub get_binding_length
317  
318 =cut
319  
320 sub get_binding_length {
321 my ($self) = @_;
322  
323 if ( $suximage_spec->{_binding_index_aref} ) {
324 my $length;
325 $length = scalar @{ $suximage_spec->{_binding_index_aref} };
326 return ($length);
327  
328 }
329 else {
330  
331 print("suximage_spec, get_binding_length, missing length \n");
332 return ();
333 }
334  
335 }
336  
337 =head2 sub get_flow_type_aref
338  
339 =cut
340  
341 sub get_flow_type_aref {
342 my ($self) = @_;
343  
344 if ( $suximage_spec->{_flow_type_aref} ) {
345 my $type_aref = $suximage_spec->{_flow_type_aref};
346 return ($type_aref);
347 }
348 else {
349  
350 print("suximage_spec, get_flow_type_aref, missing flow_type_aref \n");
351 return ();
352 }
353 }
354  
355 #
356 #=head2 incompatible parameters
357 # whose product is 1
358 #
359 #=cut
360 # my @compatible_clips = ('hiclip','loclip');
361 # my @incomp_clips = ('hiclip','loclip','perc','abs');
362 #
363 # my $incompatibles = {
364 # _clips => \@incomp_clips,
365 # };
366  
367 =head2 sub get_incompatibles
368  
369 =cut
370  
371 sub get_incompatibles {
372  
373 my ($self) = @_;
374 my @needed;
375  
376 my @_need_both;
377  
378 my @_need_only_1;
379  
380 my @_none_needed;
381  
382 my @_all_needed;
383  
384 my $params = {
385  
386 _need_both => \@_need_both,
387 _need_only_1 => \@_need_only_1,
388 _none_needed => \@_none_needed,
389 _all_needed => \@_all_needed,
390  
391 };
392  
393 my @of_two = ( 'xx', 'yy' );
394 push @{ $params->{_need_only_1} }, \@of_two;
395  
396 my $len_1_needed = scalar @{ $params->{_need_only_1} };
397  
398 if ( $len_1_needed >= 1 ) {
399  
400 for ( my $i = 0; $i < $len_1_needed; $i++ ) {
401  
402 print(
403 "suximage, get_incompatibles,need_only_1: @{@{$params->{_need_only_1}}[$i]}\n"
404 );
405  
406 }
407  
408 }
409 else {
410 print("get_incompatibles, no incompatibles\n");
411 }
412  
413 return ($params);
414  
415 }
416  
417 =head2 sub get_prefix_aref
418  
419 =cut
420  
421 sub get_prefix_aref {
422  
423 my ($self) = @_;
424  
425 if ( $suximage_spec->{_prefix_aref} ) {
426  
427 my $prefix_aref = $suximage_spec->{_prefix_aref};
428 return ($prefix_aref);
429  
430 }
431 else {
432 print("suximage_spec, get_prefix_aref, missing prefix_aref\n");
433 return ();
434 }
435  
436 return ();
437 }
438  
439 =head2 sub get_suffix_aref
440  
441 =cut
442  
443 sub get_suffix_aref {
444  
445 my ($self) = @_;
446  
447 if ( $suximage_spec->{_suffix_aref} ) {
448  
449 my $suffix_aref = $suximage_spec->{_suffix_aref};
450 return ($suffix_aref);
451  
452 }
453 else {
454 print("suximage_spec, get_suffix_aref, missing suffix_aref\n");
455 return ();
456 }
457  
458 return ();
459 }
460  
461 =head2 sub prefix_aref
462  
463 Include in the Set up
464 sections of an output Poop flow.
465  
466 prefixes and suffixes to parameter labels
467 are filtered by sunix_pl
468  
469 getparstring can not parse 2 complex urve file names
470 1 curve file name with a PATH prefix will work but not 2
471 e.g., PREFIX/curve1 PREFIX/curve2
472  
473 =cut
474  
475 sub prefix_aref {
476  
477 my ($self) = @_;
478  
479 my @prefix;
480  
481 for ( my $i = 0; $i < $max_index; $i++ ) {
482  
483 $prefix[$i] = $empty_string;
484  
485 }
486
487 my $index_aref = get_binding_index_aref();
488 my @index = @$index_aref;
489 $prefix[ $index[0] ] = '$DATA_SEISMIC_TXT' . ".'/'.";
490 $prefix[ $index[1] ] = '$DATA_SEISMIC_TXT' . ".'/'.";
491 $prefix[ $index[2] ] = "";
492
493 $suximage_spec->{_prefix_aref} = \@prefix;
494 return ();
495  
496 }
497  
498 =head2 sub suffix_aref
499  
500 Initialize suffixes as empty
501 Assign specific suffixes to parameter
502 values
503  
504 =cut
505  
506 sub suffix_aref {
507  
508 my ($self) = @_;
509  
510 my @suffix;
511  
512 for ( my $i = 0; $i < $max_index; $i++ ) {
513  
514 $suffix[$i] = $empty_string;
515  
516 }
517 $suximage_spec->{_suffix_aref} = \@suffix;
518 return ();
519  
520 }
521  
522 =head2 sub variables
523  
524 return a hash array
525 with definitions
526  
527 =cut
528  
529 sub variables {
530 my ($self) = @_;
531  
532 # print("suximage_spec,variables,
533 # first_of_2,$suximage_spec->{_is_first_of_2}\n");
534 my $hash_ref = $suximage_spec;
535 return ($hash_ref);
536 }
537  
538 1;