lib/App/SeismicUnixGui/specs/shapeNcut/suwind_spec.pm untested

filter: Statementstmt 0.0% 0 / 131 Branchbran 0.0% 0 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 17 Podpod 0.0% 0 / 13 totaltotal 0.0% 0 / 175 CC 8 SCAR 14.7
CC
8
Cov
0%
get_binding_index_aref
6.0
get_binding_length
6.0
get_file_dialog_type_aref
6.0
CRAP 4.3
1 package App::SeismicUnixGui::specs::shapeNcut::suwind_spec;
2 use Moose;
3 our $VERSION = '1.0.0';
4 use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants';
5 use aliased 'App::SeismicUnixGui::configs::big_streams::Project_config';
6 use App::SeismicUnixGui::misc::SeismicUnix qw($su $suffix_su $suffix_txt $txt);
7  
8 my $get = L_SU_global_constants->new();
9 my $var = $get->var();
10 my $file_dialog_type = $get->file_dialog_type_href();
11 my $flow_type = $get->flow_type_href();
12  
13 my $empty_string = $var->{_empty_string};
14 my $true = $var->{_true};
15 my $false = $var->{_false};
16  
17 my $Project = Project_config->new();
18  
19 my $DATA_SEISMIC_SU = $Project->DATA_SEISMIC_SU(); # output data directory
20 my $DATA_SEISMIC_TXT = $Project->DATA_SEISMIC_TXT(); # output data directory
21  
22 my $PL_SEISMIC = $Project->PL_SEISMIC();
23 my $max_index = 17;
24  
25 my $suwind_spec = {
26 _CONFIG => $PL_SEISMIC,
27 _DATA_DIR_IN => $DATA_SEISMIC_SU,
28 _DATA_DIR_OUT => $DATA_SEISMIC_SU,
29 _binding_index_aref => '',
30 _suffix_type_in => $su,
31 _data_suffix_in => $suffix_su,
32 _suffix_type_out => $su,
33 _data_suffix_out => $suffix_su,
34 _file_dialog_type_aref => '',
35 _flow_type_aref => '',
36 _has_pipe_in => $true,
37 _has_outpar => $false,
38 _has_pipe_out => $true,
39 _has_redirect_in => $true,
40 _has_redirect_out => $true,
41 _has_subin_in => $false,
42 _has_subin_out => $false,
43 _is_data => $false,
44 _is_first_of_2 => $false,
45 _is_first_of_3or_more => $true,
46 _is_first_of_4or_more => $true,
47 _is_last_of_2 => $false,
48 _is_last_of_3or_more => $false,
49 _is_last_of_4or_more => $false,
50 _is_suprog => $true,
51 _is_superflow => $false,
52 _max_index => $max_index,
53 };
54  
55 =head2 sub binding_index_aref
56  
57 starts at index=0, as per perl
58 but index refers to the index of the value in
59 the listbox. e.g. the fifth value down is index=4
60 of the listbox, although it may be in the index
61 0 of the variable index only because there is only 1
62 of variable that needs binding
63  
64 =cut
65  
66 sub binding_index_aref {
67 my ($self) = @_;
68 my @index;
69  
70 $index[0] = 2; # first item is ound to DATA_DIR_IN
71  
72 $suwind_spec->{_binding_index_aref} = \@index;
73  
74 return ();
75 }
76  
77 =head2 sub file_dialog_type_aref
78  
79 starts at type[0] but
80 refers to an index
81 within a listbox and not the index of the
82 variable: type
83
84 =cut
85  
86 sub file_dialog_type_aref {
87 my ($self) = @_;
88  
89 my @type;
90  
91 my $index_aref = get_binding_index_aref();
92 my @index = @$index_aref;
93  
94 $type[ $index[0]] = $file_dialog_type->{_Data};
95  
96 $suwind_spec->{_file_dialog_type_aref} = \@type;
97 return ();
98  
99 }
100  
101 =head2 sub flow_type_aref
102  
103 =cut
104  
105 sub flow_type_aref {
106 my ($self) = @_;
107  
108 my @type;
109  
110 $type[0] = $flow_type->{_user_built};
111  
112 $suwind_spec->{_flow_type_aref} = \@type;
113  
114 return ();
115  
116 }
117  
118 =head2 sub get_binding_index_aref
119  
120 =cut
121  
122 sub get_binding_index_aref {
123 my ($self) = @_;
124 my @index;
125  
126 if ( $suwind_spec->{_binding_index_aref} ) {
127
128 my $index_aref = $suwind_spec->{_binding_index_aref};
129 return ($index_aref);
130  
131 }
132 else {
133 print(
134 "suwind_spec, get_binding_index_aref, missing binding_index_aref\n"
135 );
136 return ();
137 }
138  
139 my $index_aref = $suwind_spec->{_binding_index_aref};
140  
141 }
142  
143 #=head2 sub get_max_index
144 #
145 #=cut
146 #
147 #sub get_max_index {
148 # my ($self) = @_;
149 #
150 # if ( $suwind_spec->{_max_index} ) {
151 #
152 # my $max_idx = $suwind_spec->{_max_index};
153 # return ($max_idx);
154 #
155 # }
156 # else {
157 # print("suwind_spec, get_max_index, missing max_index\n");
158 # return ();
159 # }
160 #}
161  
162 =head2 sub get_binding_length
163  
164 =cut
165  
166 sub get_binding_length {
167
168 my ($self) = @_;
169  
170 if ( $suwind_spec->{_binding_index_aref} ) {
171
172 my $binding_length = scalar @{ $suwind_spec->{_binding_index_aref} };
173 return ($binding_length);
174  
175 }
176 else {
177  
178 print("suwind_spec, get_binding_length, missing length \n");
179 return ();
180 }
181  
182 }
183  
184 =head2 sub get_file_dialog_type_aref
185  
186 =cut
187  
188 sub get_file_dialog_type_aref {
189
190 my ($self) = @_;
191 if ( $suwind_spec->{_file_dialog_type_aref} ) {
192
193 my $index_aref = $suwind_spec->{_file_dialog_type_aref};
194 return ( $index_aref );
195 }
196 else {
197 print(
198 "suwind_spec,get_file_dialog_type_aref, missing file_dialog_type_aref\n"
199 );
200 return ();
201 }
202 }
203  
204  
205 =head2 sub get_flow_type_aref
206  
207 =cut
208  
209 sub get_flow_type_aref {
210
211 my ($self) = @_;
212  
213 if ( $suwind_spec->{_flow_type_aref} ) {
214
215 my $index_aref = $suwind_spec->{_flow_index_aref};
216 return ($index_aref);
217
218 }
219 else {
220  
221 print("suwind_spec, get_flow_type_aref, missing flow_type_aref \n");
222 return ();
223 }
224 }
225  
226 =head2 sub get_incompatibles
227  
228 =cut
229  
230 sub get_incompatibles {
231  
232 my ($self) = @_;
233 my @needed;
234  
235 my @_need_both;
236  
237 my @_need_only_1;
238  
239 my @_none_needed;
240  
241 my @_all_needed;
242  
243 my $params = {
244  
245 _need_both => \@_need_both,
246 _need_only_1 => \@_need_only_1,
247 _none_needed => \@_none_needed,
248 _all_needed => \@_all_needed,
249  
250 };
251  
252 my @of_two = ( 'xx', 'yy' );
253 push @{ $params->{_need_only_1} }, \@of_two;
254  
255 my $len_1_needed = scalar @{ $params->{_need_only_1} };
256  
257 if ( $len_1_needed >= 1 ) {
258  
259 for ( my $i = 0 ; $i < $len_1_needed ; $i++ ) {
260  
261 print(
262 "suwind, get_incompatibles,need_only_1: @{@{$params->{_need_only_1}}[$i]}\n"
263 );
264  
265 }
266  
267 }
268 else {
269 print("get_incompatibles, no incompatibles\n");
270 }
271  
272 return ($params);
273  
274 }
275  
276 =head2 sub get_prefix_aref
277  
278 =cut
279  
280 sub get_prefix_aref {
281  
282 my ($self) = @_;
283  
284 if ( $suwind_spec->{_prefix_aref} ) {
285  
286 my $prefix_aref = $suwind_spec->{_prefix_aref};
287 return ($prefix_aref);
288  
289 }
290 else {
291 print("suwind_spec, get_prefix_aref, missing prefix_aref\n");
292 return ();
293 }
294  
295 return ();
296 }
297  
298 =head2 sub get_suffix_aref
299  
300 =cut
301  
302 sub get_suffix_aref {
303  
304 my ($self) = @_;
305  
306 if ( $suwind_spec->{_suffix_aref} ) {
307  
308 my $suffix_aref = $suwind_spec->{_suffix_aref};
309 return ($suffix_aref);
310  
311 }
312 else {
313 print("suwind_spec, get_suffix_aref, missing suffix_aref\n");
314 return ();
315 }
316  
317 return ();
318 }
319  
320 =head2 sub prefix_aref
321  
322 Include in the Set up
323 sections of an output Poop flow.
324  
325 prefixes and suffixes to parameter labels
326 are filtered by sunix_pl
327  
328 =cut
329  
330 sub prefix_aref {
331  
332 my ($self) = @_;
333  
334 my @prefix;
335  
336 for ( my $i = 0 ; $i < $max_index ; $i++ ) {
337  
338 $prefix[$i] = $empty_string;
339  
340 }
341
342 my $index_aref = get_binding_index_aref();
343 my @index = @$index_aref;
344  
345 # third label in GUI is input list file name and needs a home directory
346 $prefix[ $index[0] ] = '$DATA_SEISMIC_TXT' . ".'/'.";
347
348 $suwind_spec->{_prefix_aref} = \@prefix;
349 return ();
350  
351 }
352  
353 =head2 sub suffix_aref
354  
355 Initialize suffixes as empty
356 Assign specific suffixes to parameter
357 values
358  
359 =cut
360  
361 sub suffix_aref {
362  
363 my ($self) = @_;
364  
365 my @suffix;
366  
367 for ( my $i = 0 ; $i < $max_index ; $i++ ) {
368  
369 $suffix[$i] = $empty_string;
370  
371 }
372
373 my $index_aref = get_binding_index_aref();
374 my @index = @$index_aref;
375  
376 # label 3 in GUI is input file list name and needs a home directory
377 $suffix[ $index[0] ] = '' . '' . '$suffix_txt';
378
379
380 $suwind_spec->{_suffix_aref} = \@suffix;
381 return ();
382  
383 }
384  
385 =head2 sub variables
386 return a hash array
387 with definitions
388  
389 =cut
390  
391 sub variables {
392 my $self = @_;
393 my $hash_ref = $suwind_spec;
394 return ($hash_ref);
395 }
396  
397 1;