« lib/App/SeismicUnixGui/sunix/statsMath/suinterp.pm
↑ Summary
lib/App/SeismicUnixGui/sunix/header/sushw.pm »
| 1 | package App::SeismicUnixGui::misc::param_flow; | ||
| 2 | |||
| 3 | =head1 DOCUMENTATION | ||
| 4 | |||
| 5 | =head2 SYNOPSIS | ||
| 6 | |||
| 7 | Perl package: param_flow.pm | ||
| 8 | AUTHOR: Juan Lorenzo | ||
| 9 | DATE: Aug 3 2017 | ||
| 10 | |||
| 11 | DESCRIPTION: | ||
| 12 | V 0.1 Aug 3 2017 | ||
| 13 | |||
| 14 | USED FOR: | ||
| 15 | |||
| 16 | BASED ON: | ||
| 17 | param_flow.pm | ||
| 18 | |||
| 19 | =cut | ||
| 20 | |||
| 21 | use Moose; | ||
| 22 | our $VERSION = '0.0.1'; | ||
| 23 | use Clone 'clone'; | ||
| 24 | |||
| 25 | =pod | ||
| 26 | |||
| 27 | private hash_ref | ||
| 28 | w for widgets | ||
| 29 | |||
| 30 | =cut | ||
| 31 | |||
| 32 | # arrays of arrays | ||
| 33 | my @program_names; | ||
| 34 | my @num_good_values; | ||
| 35 | my @num_good_labels; | ||
| 36 | my @good_labels; | ||
| 37 | my @good_values; | ||
| 38 | |||
| 39 | my @names; | ||
| 40 | my @values; | ||
| 41 | my @checkbuttons; | ||
| 42 | |||
| 43 | my $param_flow = { | ||
| 44 | _checkbuttons_aref => '', | ||
| 45 | _checkbuttons_aref2 => '', | ||
| 46 | _destination_index => '', | ||
| 47 | _end => '', | ||
| 48 | _first_idx => 0, # not a string | ||
| 49 | _good_checkbuttons_aref2 => '', | ||
| 50 | _good_labels_aref2 => '', | ||
| 51 | _good_values_aref2 => '', | ||
| 52 | _index2move => '', | ||
| 53 | _index4flow => -1, | ||
| 54 | _index4checkbuttons => -1, | ||
| 55 | _index4names => -1, | ||
| 56 | _index4values => -1, | ||
| 57 | _indices => -1, | ||
| 58 | _label_boxes_w => '', | ||
| 59 | _length => '', | ||
| 60 | _names_aref => '', | ||
| 61 | _names_aref2 => '', | ||
| 62 | _num_good_values_aref => 0, | ||
| 63 | _num_good_labels_aref => 0, | ||
| 64 | _num_items => 0, | ||
| 65 | _num_items4flow => 0, | ||
| 66 | _num_items4checkbuttons => 0, | ||
| 67 | _num_items4names => 0, | ||
| 68 | _num_items4values => 0, | ||
| 69 | _prog_names_aref => '', | ||
| 70 | _prog_version_aref => 0, | ||
| 71 | _selection_index => '', | ||
| 72 | _start => 0, | ||
| 73 | _values_aref => '', | ||
| 74 | _values_aref2 => '', | ||
| 75 | }; | ||
| 76 | |||
| 77 | use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants'; | ||
| 78 | my $get = L_SU_global_constants->new(); | ||
| 79 | my $var = $get->var(); | ||
| 80 | my $on = $var->{_on}; | ||
| 81 | my $off = $var->{_off}; | ||
| 82 | my $nu = $var->{_nu}; | ||
| 83 | |||
| 84 | =head2 sub first_idx | ||
| 85 | |||
| 86 | first usable index is set to 0 | ||
| 87 | |||
| 88 | =cut | ||
| 89 | |||
| 90 | sub first_idx { | ||
| 91 | my ($self) = @_; | ||
| 92 | |||
| 93 | $param_flow->{_first_idx} = 0; | ||
| 94 | return ( $param_flow->{_first_idx} ); | ||
| 95 | |||
| 96 | } | ||
| 97 | |||
| 98 | =head2 sub get_num_good_values_aref | ||
| 99 | |||
| 100 | =cut | ||
| 101 | |||
| 102 | sub get_num_good_values_aref { | ||
| 103 | my ($self) = @_; | ||
| 104 | |||
| 105 | if ( $param_flow->{_num_good_values_aref} ) { | ||
| 106 | my $num_good_values_aref = $param_flow->{_num_good_values_aref}; | ||
| 107 | return ($num_good_values_aref); | ||
| 108 | } | ||
| 109 | return (); | ||
| 110 | } | ||
| 111 | |||
| 112 | =head2 sub get_num_good_labels_aref | ||
| 113 | |||
| 114 | =cut | ||
| 115 | |||
| 116 | sub get_num_good_labels_aref { | ||
| 117 | my ($self) = @_; | ||
| 118 | |||
| 119 | if ( $param_flow->{_num_good_labels_aref} ) { | ||
| 120 | my $num_good_labels_aref = $param_flow->{_num_good_labels_aref}; | ||
| 121 | return ($num_good_labels_aref); | ||
| 122 | } | ||
| 123 | return (); | ||
| 124 | } | ||
| 125 | |||
| 126 | =head2 sub insert_selection | ||
| 127 | |||
| 128 | delete parameter names and values | ||
| 129 | of on one selected item | ||
| 130 | |||
| 131 | =cut | ||
| 132 | |||
| 133 | sub insert_selection { | ||
| 134 | my ($self) = @_; | ||
| 135 | my $first = 0; | ||
| 136 | my $idx2mv = $param_flow->{_index2move}; | ||
| 137 | my $destn_idx = $param_flow->{_destination_index}; | ||
| 138 | my $end = $param_flow->{_indices}; | ||
| 139 | my $num_items = $param_flow->{_num_items}; | ||
| 140 | |||
| 141 | # # print("param_flow,insert_selection start is $idx2mv\n"); | ||
| 142 | # print("param_flow,insert_selection,destn_id is $destn_idx\n"); | ||
| 143 | # print("param_flow,insert_selection, last index is $end\n"); | ||
| 144 | |||
| 145 | # print("before insertion\n"); | ||
| 146 | # view_data(); | ||
| 147 | # STEP 1 arrays for the mobile item | ||
| 148 | my ( @tmp_names_aref, @tmp_values_aref, @tmp_checkbuttons_aref ); | ||
| 149 | my ($tmp_prog_name); | ||
| 150 | my ( @swap_names_aref, @swap_values_aref, @swap_checkbuttons_aref ); | ||
| 151 | my (@swap_prog_names); | ||
| 152 | |||
| 153 | $tmp_prog_name = @{ $param_flow->{_prog_names_aref} }[$idx2mv]; | ||
| 154 | @tmp_names_aref = @{ @{ $param_flow->{_names_aref2} }[$idx2mv] }; | ||
| 155 | @tmp_values_aref = @{ @{ $param_flow->{_values_aref2} }[$idx2mv] }; | ||
| 156 | @tmp_checkbuttons_aref = | ||
| 157 | @{ @{ $param_flow->{_checkbuttons_aref2} }[$idx2mv] }; | ||
| 158 | |||
| 159 | # print(" param_flow,insert_selection,mobile prog name: $tmp_prog_name \n"); | ||
| 160 | # print(" mobile names originally at index $idx2mv is @tmp_names_aref\n"); | ||
| 161 | # print(" values: @tmp_values_aref \n"); | ||
| 162 | # print(" checkbuttons: @tmp_checkbuttons_aref \n"); | ||
| 163 | |||
| 164 | # STEP 2 intermediate vector containing everything except mobile item | ||
| 165 | # swap files have one less item than the original array | ||
| 166 | if ( $idx2mv > $first ) { | ||
| 167 | |||
| 168 | for ( my $i = $first, my $j = $first ; $j < $idx2mv ; $i++, $j++ ) { | ||
| 169 | $swap_prog_names[$i] = @{ $param_flow->{_prog_names_aref} }[$j]; | ||
| 170 | $swap_names_aref[$i] = | ||
| 171 | clone( \@{ @{ $param_flow->{_names_aref2} }[$j] } ); | ||
| 172 | $swap_values_aref[$i] = | ||
| 173 | clone( \@{ @{ $param_flow->{_values_aref2} }[$j] } ); | ||
| 174 | $swap_checkbuttons_aref[$i] = | ||
| 175 | clone( \@{ @{ $param_flow->{_checkbuttons_aref2} }[$j] } ); | ||
| 176 | |||
| 177 | # print(" 1. filling swap vector at index $i with @{$swap_names_aref[$i]}\n"); | ||
| 178 | # print(" 1. filling swap vector values t index $i with @{$swap_values_aref[$i]}\n"); | ||
| 179 | #print(" 1. filling swap vector values t index $i with $swap_prog_names[$i]\n"); | ||
| 180 | } | ||
| 181 | for ( | ||
| 182 | my $i = $idx2mv, my $j = ( $idx2mv + 1 ) ; | ||
| 183 | $j <= $end ; | ||
| 184 | $i++, $j++ | ||
| 185 | ) | ||
| 186 | { | ||
| 187 | $swap_prog_names[$i] = @{ $param_flow->{_prog_names_aref} }[$j]; | ||
| 188 | $swap_names_aref[$i] = | ||
| 189 | clone( \@{ @{ $param_flow->{_names_aref2} }[$j] } ); | ||
| 190 | $swap_values_aref[$i] = | ||
| 191 | clone( \@{ @{ $param_flow->{_values_aref2} }[$j] } ); | ||
| 192 | $swap_checkbuttons_aref[$i] = | ||
| 193 | clone( \@{ @{ $param_flow->{_checkbuttons_aref2} }[$j] } ); | ||
| 194 | |||
| 195 | # print(" 2. filling swap vector at index $i with @{$swap_names_aref[$i]}\n"); | ||
| 196 | } | ||
| 197 | } | ||
| 198 | else { # assume $idx2mv=0 | ||
| 199 | for ( my $i = $first, my $j = ( $first + 1 ) ; $j <= $end ; $i++, $j++ ) | ||
| 200 | { # idx2mv=0 | ||
| 201 | |||
| 202 | $swap_prog_names[$i] = @{ $param_flow->{_prog_names_aref} }[$j]; | ||
| 203 | $swap_names_aref[$i] = | ||
| 204 | clone( \@{ @{ $param_flow->{_names_aref2} }[$j] } ); | ||
| 205 | $swap_values_aref[$i] = | ||
| 206 | clone( \@{ @{ $param_flow->{_values_aref2} }[$j] } ); | ||
| 207 | $swap_checkbuttons_aref[$i] = | ||
| 208 | clone( \@{ @{ $param_flow->{_checkbuttons_aref2} }[$j] } ); | ||
| 209 | |||
| 210 | # print(" 3. filling intermediate vector at int. index $i with @{$swap_names_aref[$i]}\n"); | ||
| 211 | } | ||
| 212 | } | ||
| 213 | |||
| 214 | # STEP 3 insert all but mobile item | ||
| 215 | # into the final destination container | ||
| 216 | if ( $destn_idx > $first ) { # assume $destn_idx > 0 | ||
| 217 | |||
| 218 | for ( my $i = $first, my $j = $first ; $i < $destn_idx ; $i++, $j++ ) { | ||
| 219 | @{ $param_flow->{_prog_names_aref} }[$i] = $swap_prog_names[$j]; | ||
| 220 | @{ @{ $param_flow->{_names_aref2} }[$i] } = | ||
| 221 | @{ $swap_names_aref[$j] }; | ||
| 222 | @{ @{ $param_flow->{_values_aref2} }[$i] } = | ||
| 223 | @{ $swap_values_aref[$j] }; | ||
| 224 | @{ @{ $param_flow->{_checkbuttons_aref2} }[$i] } = | ||
| 225 | @{ $swap_checkbuttons_aref[$j] }; | ||
| 226 | |||
| 227 | # print(" 1. final vector at new index $i uses swap @{$swap_names_aref[$j]}\n"); | ||
| 228 | # print(" 1. final vector at new index $i is @{@{$param_flow->{_names_aref2}}[$i]}\n"); | ||
| 229 | } | ||
| 230 | |||
| 231 | for ( | ||
| 232 | my $i = ( $destn_idx + 1 ), my $j = $destn_idx ; | ||
| 233 | $i <= $end ; | ||
| 234 | $i++, $j++ | ||
| 235 | ) | ||
| 236 | { | ||
| 237 | @{ $param_flow->{_prog_names_aref} }[$i] = $swap_prog_names[$j]; | ||
| 238 | @{ @{ $param_flow->{_names_aref2} }[$i] } = | ||
| 239 | @{ $swap_names_aref[$j] }; | ||
| 240 | @{ @{ $param_flow->{_values_aref2} }[$i] } = | ||
| 241 | @{ $swap_values_aref[$j] }; | ||
| 242 | @{ @{ $param_flow->{_checkbuttons_aref2} }[$i] } = | ||
| 243 | @{ $swap_checkbuttons_aref[$j] }; | ||
| 244 | |||
| 245 | # print(" 2. final vector at new index $i with swap @{$swap_names_aref[$j]}\n"); | ||
| 246 | |||
| 247 | } | ||
| 248 | } | ||
| 249 | else { # assume $destn_idx = 0 | ||
| 250 | # swap files have one less item than the original array | ||
| 251 | # print(" 2A. destn_idx = $destn_idx\n"); | ||
| 252 | # print(" 4. swap vector index=0 with @{$swap_names_aref[0]}\n"); | ||
| 253 | # print(" 4. swap vector index=1 with @{$swap_names_aref[1]}\n"); | ||
| 254 | # print(" 4. swap vector index=2 with @{$swap_names_aref[2]}\n\n"); | ||
| 255 | |||
| 256 | for ( my $i = ( $first + 1 ), my $j = $first ; $j < $end ; $i++, $j++ ) | ||
| 257 | { | ||
| 258 | my @swp_nam_tr = @{ $swap_names_aref[$j] }; | ||
| 259 | |||
| 260 | # print(" 4. swap vector at swap index j=$j has value of @swp_nam_tr \n"); | ||
| 261 | @{ $param_flow->{_prog_names_aref} }[$i] = $swap_prog_names[$j]; | ||
| 262 | @{ @{ $param_flow->{_names_aref2} }[$i] } = @swp_nam_tr; | ||
| 263 | @{ @{ $param_flow->{_values_aref2} }[$i] } = | ||
| 264 | @{ $swap_values_aref[$j] }; | ||
| 265 | @{ @{ $param_flow->{_checkbuttons_aref2} }[$i] } = | ||
| 266 | @{ $swap_checkbuttons_aref[$j] }; | ||
| 267 | |||
| 268 | #print(" 3. swap vector at index $j, @{$swap_names_aref[$j]} names final vector at new index $i \n"); | ||
| 269 | #print(" 3. swap vector at index $j, @{$swap_values_aref[$j]} values final vector at new index $i \n"); | ||
| 270 | #print(" 3. swap vector at index $j, $swap_prog_names[$j] prog names final vector at new index $i \n"); | ||
| 271 | } | ||
| 272 | } | ||
| 273 | |||
| 274 | #STEP 4 insert the mobile item | ||
| 275 | @{ $param_flow->{_prog_names_aref} }[$destn_idx] = $tmp_prog_name; | ||
| 276 | @{ @{ $param_flow->{_names_aref2} }[$destn_idx] } = @tmp_names_aref; | ||
| 277 | @{ @{ $param_flow->{_values_aref2} }[$destn_idx] } = @tmp_values_aref; | ||
| 278 | @{ @{ $param_flow->{_checkbuttons_aref2} }[$destn_idx] } = | ||
| 279 | @tmp_checkbuttons_aref; | ||
| 280 | |||
| 281 | # print(" 4. final vector at new index $destn_idx with temp vector @tmp_names_aref\n"); | ||
| 282 | |||
| 283 | #print("data after insertion\n"); | ||
| 284 | #view_data(); | ||
| 285 | return (); | ||
| 286 | } | ||
| 287 | |||
| 288 | =head2 sub delete_selection | ||
| 289 | |||
| 290 | delete parameter names and values | ||
| 291 | belonging to one selected item | ||
| 292 | |||
| 293 | =cut | ||
| 294 | |||
| 295 | sub delete_selection { | ||
| 296 | |||
| 297 | my ( $self, $index2delete ) = @_; | ||
| 298 | my $end = $param_flow->{_indices}; | ||
| 299 | my $num_items = $param_flow->{_num_items}; | ||
| 300 | my $first = 0; | ||
| 301 | $param_flow->{_index2delete} = $index2delete; | ||
| 302 | |||
| 303 | # print("\nparam_flow,delete_selection B4 deletion,idx2delete=$index2delete\n"); | ||
| 304 | # view_data($index2delete); | ||
| 305 | |||
| 306 | # CASE 1: delete end item but not the last one | ||
| 307 | if ( $index2delete == $end && $num_items > 1 ) | ||
| 308 | { # final item but more than one item | ||
| 309 | # print("index2delete = end, idx $index2delete\n"); | ||
| 310 | # empty end index of array | ||
| 311 | pop @{ $param_flow->{_checkbuttons_aref2} }; | ||
| 312 | pop @{ $param_flow->{_names_aref2} }; | ||
| 313 | pop @{ $param_flow->{_values_aref2} }; | ||
| 314 | pop @{ $param_flow->{_prog_names_aref} }; | ||
| 315 | |||
| 316 | # no $index_after; | ||
| 317 | } | ||
| 318 | |||
| 319 | # CASE 2: GENERAL CASE | ||
| 320 | # listbox has 3 items or more | ||
| 321 | # I can delete any but final | ||
| 322 | if ( $index2delete >= 0 && $index2delete < $end ) { | ||
| 323 | my $index_after = $index2delete + 1; | ||
| 324 | |||
| 325 | # print("index2delete >= 0 , idx2delete=$index2delete end=$end \n"); | ||
| 326 | # print("index_after $index_after \n"); | ||
| 327 | |||
| 328 | for ( | ||
| 329 | my $i = $index_after, my $j = $index2delete ; | ||
| 330 | $i <= $end ; | ||
| 331 | $i++, $j++ | ||
| 332 | ) | ||
| 333 | { | ||
| 334 | # print("Prog names B4 delete @{$param_flow->{_prog_names_aref}} \n"); | ||
| 335 | |||
| 336 | @{ @{ $param_flow->{_checkbuttons_aref2} }[$j] } = | ||
| 337 | @{ @{ $param_flow->{_checkbuttons_aref2} }[$i] }; | ||
| 338 | @{ @{ $param_flow->{_names_aref2} }[$j] } = | ||
| 339 | @{ @{ $param_flow->{_names_aref2} }[$i] }; | ||
| 340 | @{ @{ $param_flow->{_values_aref2} }[$j] } = | ||
| 341 | @{ @{ $param_flow->{_values_aref2} }[$i] }; | ||
| 342 | @{ $param_flow->{_prog_names_aref} }[$j] = | ||
| 343 | @{ $param_flow->{_prog_names_aref} }[$i]; | ||
| 344 | } | ||
| 345 | |||
| 346 | # empty end index of array | ||
| 347 | # - OK JL | ||
| 348 | pop @{ $param_flow->{_checkbuttons_aref2} }; | ||
| 349 | pop @{ $param_flow->{_names_aref2} }; | ||
| 350 | pop @{ $param_flow->{_values_aref2} }; | ||
| 351 | pop @{ $param_flow->{_prog_names_aref} }; | ||
| 352 | |||
| 353 | # print("Prog names After delete @{$param_flow->{_prog_names_aref}} \n"); | ||
| 354 | } | ||
| 355 | |||
| 356 | # CASE 3: listbox has only 1 and final item left | ||
| 357 | if ( $index2delete == 0 && $num_items == 1 ) { | ||
| 358 | |||
| 359 | # print("index2delete = 0 and num_items=1, idx $index2delete\n"); | ||
| 360 | # empty end index of array | ||
| 361 | pop @{ $param_flow->{_checkbuttons_aref2} }; | ||
| 362 | pop @{ $param_flow->{_names_aref2} }; | ||
| 363 | pop @{ $param_flow->{_values_aref2} }; | ||
| 364 | pop @{ $param_flow->{_prog_names_aref} }; | ||
| 365 | |||
| 366 | # no $index_after; | ||
| 367 | } | ||
| 368 | |||
| 369 | $param_flow->{_num_items}--; | ||
| 370 | $param_flow->{_num_items4flow}--; | ||
| 371 | $param_flow->{_num_items4values}--; | ||
| 372 | $param_flow->{_num_items4names}--; | ||
| 373 | $param_flow->{_num_items4checkbuttons}--; | ||
| 374 | |||
| 375 | $param_flow->{_indices}--; | ||
| 376 | $param_flow->{_index4values}--; | ||
| 377 | $param_flow->{_index4names}--; | ||
| 378 | $param_flow->{_index4checkbuttons}--; | ||
| 379 | |||
| 380 | $param_flow->{_index4flow}--; | ||
| 381 | |||
| 382 | # print("\nAfter delete_selection, index2delete was $index2delete\n"); | ||
| 383 | #view_data($index2delete); | ||
| 384 | |||
| 385 | return (); | ||
| 386 | } | ||
| 387 | |||
| 388 | =head2 sub get_check_buttons_settings | ||
| 389 | |||
| 390 | my ($i,$j, $length); | ||
| 391 | my @on_off; | ||
| 392 | my @values_aref; | ||
| 393 | |||
| 394 | @values_aref = @{@{$param_flow->{_checkbuttons_aref2}}[$index]}; | ||
| 395 | $length = scalar @values_aref; | ||
| 396 | |||
| 397 | print("param_flow,get_check_buttons_settings: is @values_aref\n"); | ||
| 398 | |||
| 399 | #for ($i=1,$j=0; $i < $length; $i=$i+2,$j++ ) { | ||
| 400 | for ($i=0; $i < $length; $i++ ) { | ||
| 401 | #$values[$j] = $values_aref[$i]; | ||
| 402 | #print("param_flow, get_check_buttons_settings :index $j values: $values[$j]\n"); | ||
| 403 | if($values_aref[$i] eq $nu || ) { | ||
| 404 | $on_off[$i] = $off; | ||
| 405 | # print(" 1. param_flow, get_check_buttons_settings,$on_off[$i]\n"); | ||
| 406 | } | ||
| 407 | else { | ||
| 408 | $on_off[$i] = $on; | ||
| 409 | # print(" 2. param_flow, get_check_buttons_settings,$on_off[$i]\n"); | ||
| 410 | } | ||
| 411 | # print("param_flow: get_check_buttons_settings :index $i setting $nu is: $on_off[$i]\n"); | ||
| 412 | } | ||
| 413 | |||
| 414 | =cut | ||
| 415 | |||
| 416 | sub get_check_buttons_settings { | ||
| 417 | my $self = @_; | ||
| 418 | my $index = $param_flow->{_selection_index}; | ||
| 419 | my @on_off; | ||
| 420 | |||
| 421 | if ( $index >= 0 ) { | ||
| 422 | my @on_off = @{ @{ $param_flow->{_checkbuttons_aref2} }[$index] }; | ||
| 423 | print("param_flow,get_check_buttons_settings: is @on_off\n"); | ||
| 424 | |||
| 425 | return ( \@on_off ); | ||
| 426 | } | ||
| 427 | return (); | ||
| 428 | } | ||
| 429 | |||
| 430 | =head2 sub get_flow_index | ||
| 431 | |||
| 432 | get current program index | ||
| 433 | |||
| 434 | =cut | ||
| 435 | |||
| 436 | sub get_flow_index { | ||
| 437 | my ($self) = @_; | ||
| 438 | my $current_idx = $param_flow->{_index4flow}; | ||
| 439 | |||
| 440 | # print("param_flow, get flow_index, | ||
| 441 | # current_idx is $param_flow->{_index4flow}\n"); | ||
| 442 | return ($current_idx); | ||
| 443 | } | ||
| 444 | |||
| 445 | =head2 sub get_flow_prog_names_aref | ||
| 446 | |||
| 447 | extract sequential program names in flow | ||
| 448 | |||
| 449 | =cut | ||
| 450 | |||
| 451 | sub get_flow_prog_names_aref { | ||
| 452 | my ($self) = @_; | ||
| 453 | |||
| 454 | # print("param_flow, get_flow_prog_names_aref, | ||
| 455 | # @{$param_flow->{_prog_names_aref}}\n"); | ||
| 456 | my $hash->{_prog_names_aref} = $param_flow->{_prog_names_aref}; | ||
| 457 | return ( $hash->{_prog_names_aref} ); | ||
| 458 | } | ||
| 459 | |||
| 460 | =head2 sub get_good_labels_aref2 | ||
| 461 | |||
| 462 | =cut | ||
| 463 | |||
| 464 | sub get_good_labels_aref2 { | ||
| 465 | my ($self) = @_; | ||
| 466 | |||
| 467 | if ( $param_flow->{_good_labels_aref2} ) { | ||
| 468 | my $good_labels_aref2 = $param_flow->{_good_labels_aref2}; | ||
| 469 | |||
| 470 | # print(" param_flow,get_good_labels_aref2, | ||
| 471 | # good_labels for index 0= | ||
| 472 | # @{@{$param_flow->{_good_labels_aref2}}[0]}\n"); | ||
| 473 | return ($good_labels_aref2); | ||
| 474 | } | ||
| 475 | return (); | ||
| 476 | } | ||
| 477 | |||
| 478 | =head2 sub get_good_values_aref2 | ||
| 479 | |||
| 480 | =cut | ||
| 481 | |||
| 482 | sub get_good_values_aref2 { | ||
| 483 | my ($self) = @_; | ||
| 484 | |||
| 485 | if ( $param_flow->{_good_values_aref2} ) { | ||
| 486 | my $good_values_aref2 = $param_flow->{_good_values_aref2}; | ||
| 487 | |||
| 488 | # print(" param_flow,get_good_values_aref2, | ||
| 489 | # good_values for index 0= : | ||
| 490 | # @{@{$param_flow->{_good_values_aref2}}[0]}\n"); | ||
| 491 | return ($good_values_aref2); | ||
| 492 | } | ||
| 493 | return (); | ||
| 494 | } | ||
| 495 | |||
| 496 | =head2 sub get_names_aref | ||
| 497 | |||
| 498 | |||
| 499 | =cut | ||
| 500 | |||
| 501 | sub get_names_aref { | ||
| 502 | my ($self) = @_; | ||
| 503 | my $index = $param_flow->{_selection_index}; | ||
| 504 | |||
| 505 | if ( $index >= 0 ) { | ||
| 506 | my @names_aref; | ||
| 507 | my ($length); | ||
| 508 | |||
| 509 | @names_aref = @{ @{ $param_flow->{_names_aref2} }[$index] }; | ||
| 510 | $length = scalar @names_aref; | ||
| 511 | |||
| 512 | # print(" param_flow, get_names names: @names_aref, index is $index\n"); | ||
| 513 | return ( \@names_aref ); | ||
| 514 | } | ||
| 515 | } | ||
| 516 | |||
| 517 | =head2 sub get_num_items | ||
| 518 | |||
| 519 | |||
| 520 | =cut | ||
| 521 | |||
| 522 | sub get_num_items { | ||
| 523 | my ($self) = @_; | ||
| 524 | return ( $param_flow->{_num_items} ); | ||
| 525 | } | ||
| 526 | |||
| 527 | =head2 sub get_values_aref | ||
| 528 | |||
| 529 | |||
| 530 | =cut | ||
| 531 | |||
| 532 | sub get_values_aref { | ||
| 533 | my ($self) = @_; | ||
| 534 | my $index = $param_flow->{_selection_index}; | ||
| 535 | |||
| 536 | if ( $index >= 0 ) { | ||
| 537 | my ( $i, $j, $length ); | ||
| 538 | my ( @values_aref, @values ); | ||
| 539 | |||
| 540 | @values_aref = @{ @{ $param_flow->{_values_aref2} }[$index] }; | ||
| 541 | $length = scalar @values_aref; | ||
| 542 | |||
| 543 | # print("param_flow,get_values :values_aref is @values_aref\n"); | ||
| 544 | |||
| 545 | # for ($i=1,$j=0; $i < $length; $i=$i+2,$j++ ) { | ||
| 546 | # $values[$j] = $values_aref[$i]; | ||
| 547 | # #print("param_flow, get_values :index $j values: $values[$j]\n"); | ||
| 548 | # } | ||
| 549 | return ( \@values_aref ); | ||
| 550 | } | ||
| 551 | } | ||
| 552 | |||
| 553 | =head2 sub get_flow_items_version_aref | ||
| 554 | |||
| 555 | o/p is array ref of the version of each program name | ||
| 556 | |||
| 557 | =cut | ||
| 558 | |||
| 559 | sub get_flow_items_version_aref { | ||
| 560 | my ($self) = @_; | ||
| 561 | my $program_version_aref = $param_flow->{_prog_version_aref}; | ||
| 562 | |||
| 563 | # print("param_flow, get_flow_items_version_aref | ||
| 564 | # @{$param_flow->{_prog_version_aref}}\n"); | ||
| 565 | |||
| 566 | return ($program_version_aref); | ||
| 567 | } | ||
| 568 | |||
| 569 | =head2 sub length | ||
| 570 | |||
| 571 | last item number (not last index) | ||
| 572 | last item numberis equivalent to length | ||
| 573 | |||
| 574 | =cut | ||
| 575 | |||
| 576 | sub length { | ||
| 577 | my ($self) = @_; | ||
| 578 | |||
| 579 | my ( $length, $index ); | ||
| 580 | my @values_aref; | ||
| 581 | |||
| 582 | $index = $param_flow->{_selection_index}; | ||
| 583 | if ( $index >= 0 ) { | ||
| 584 | @values_aref = @{ @{ $param_flow->{_values_aref2} }[$index] }; | ||
| 585 | $length = scalar @values_aref; | ||
| 586 | |||
| 587 | # print("param_flow, length, num values: $length\n"); | ||
| 588 | # print("param_flow, index: $index\n"); | ||
| 589 | return ($length); | ||
| 590 | } | ||
| 591 | else { | ||
| 592 | print("param_flow,length, index does not exist\n"); | ||
| 593 | print("param_flow, length, num values: $length\n"); | ||
| 594 | return (); | ||
| 595 | } | ||
| 596 | } | ||
| 597 | |||
| 598 | =head2 sub private_get_good_length4item | ||
| 599 | |||
| 600 | =cut | ||
| 601 | |||
| 602 | sub private_get_good_length4item { | ||
| 603 | my ( $self, $index4flow ) = @_; | ||
| 604 | my $idx = $index4flow; | ||
| 605 | my $length = scalar @{ $param_flow->{_good_values_aref2}[$idx] }; | ||
| 606 | return ($length); | ||
| 607 | } | ||
| 608 | |||
| 609 | =head2 sub private_get_names_aref | ||
| 610 | |||
| 611 | |||
| 612 | =cut | ||
| 613 | |||
| 614 | sub private_get_names_aref { | ||
| 615 | my ($item_index) = @_; | ||
| 616 | |||
| 617 | if ( $item_index >= 0 ) { | ||
| 618 | my ( $i, $j, $length ); | ||
| 619 | my ( @names_aref, @names ); | ||
| 620 | @names_aref = @{ @{ $param_flow->{_names_aref2} }[$item_index] }; | ||
| 621 | |||
| 622 | # print("param_flow, private_get_names_aref, | ||
| 623 | #@names_aref, index=$item_index\n"); | ||
| 624 | return ( \@names_aref ); | ||
| 625 | } | ||
| 626 | } | ||
| 627 | |||
| 628 | =head2 sub private_get_values_aref | ||
| 629 | |||
| 630 | |||
| 631 | =cut | ||
| 632 | |||
| 633 | sub private_get_values_aref { | ||
| 634 | my ($item_index) = @_; | ||
| 635 | |||
| 636 | if ( $item_index >= 0 ) { | ||
| 637 | my ( $i, $j, $length ); | ||
| 638 | my ( @values_aref, @values ); | ||
| 639 | @values_aref = @{ @{ $param_flow->{_values_aref2} }[$item_index] }; | ||
| 640 | |||
| 641 | # print("param_flow, private_get_values_aref, | ||
| 642 | # @values_aref, index=$item_index\n"); | ||
| 643 | return ( \@values_aref ); | ||
| 644 | } | ||
| 645 | } | ||
| 646 | |||
| 647 | =head2 sub private_set_good_labels4item | ||
| 648 | |||
| 649 | my $num_items4flow = $param_flow->{_num_items4flow}; | ||
| 650 | |||
| 651 | =cut | ||
| 652 | |||
| 653 | sub private_set_good_labels4item { | ||
| 654 | my ($index4flow) = @_; | ||
| 655 | |||
| 656 | # print("param_flow,set_good_indices4item, | ||
| 657 | # self,index4flow: $self,$index4flow\n"); | ||
| 658 | |||
| 659 | my $idx = $index4flow; | ||
| 660 | my (@good); | ||
| 661 | my ($j); | ||
| 662 | |||
| 663 | # print("1. param_flow,private_set_good_labels4item, | ||
| 664 | # flow index:$idx, prog name: | ||
| 665 | # @{$param_flow->{_prog_names_aref}}[$idx] \n"); | ||
| 666 | |||
| 667 | # good values determine names and checkbuttons | ||
| 668 | my $values_aref = private_get_values_aref($idx); | ||
| 669 | my $length = scalar @$values_aref; | ||
| 670 | |||
| 671 | for ( my $i = 0, $j = 0 ; $i < $length ; $i++ ) { | ||
| 672 | |||
| 673 | # print("param_flow, private_set_good_labels4item: | ||
| 674 | # values_aref is @$values_aref[$i]\n"); | ||
| 675 | |||
| 676 | # don't use the following values: 'nu' , empty | ||
| 677 | if ( @$values_aref[$i] ne "'nu'" | ||
| 678 | && @$values_aref[$i] ne '' ) | ||
| 679 | { | ||
| 680 | |||
| 681 | my $name = ${ @{ $param_flow->{_names_aref2} }[$idx] }[$i]; | ||
| 682 | |||
| 683 | # print("2. param_flow,private_set_good_labels4item, | ||
| 684 | # good index #$i, name:$name \n"); | ||
| 685 | |||
| 686 | $good[$j] = $name; | ||
| 687 | $j++; | ||
| 688 | } | ||
| 689 | } | ||
| 690 | |||
| 691 | $num_good_labels[$idx] = $j; | ||
| 692 | |||
| 693 | # print("param_flow,private_set_good_labels4item, | ||
| 694 | # good_labels=@good \n"); | ||
| 695 | |||
| 696 | $param_flow->{_num_good_labels_aref} = \@num_good_labels; | ||
| 697 | $good_labels[$idx] = \@good; | ||
| 698 | $param_flow->{_good_labels_aref2} = \@good_labels; | ||
| 699 | |||
| 700 | # print(" 3. param_flow,private_set_good_labels4item, | ||
| 701 | # num_good_labels= $num_good_labels[$idx] , | ||
| 702 | # names are: @{@{$param_flow->{_good_labels_aref2}}[$idx]}\n"); | ||
| 703 | |||
| 704 | } | ||
| 705 | |||
| 706 | =head2 sub private_set_good_values4item | ||
| 707 | |||
| 708 | Set good values privately for a single item (program name) | ||
| 709 | within a flow | ||
| 710 | |||
| 711 | my $num_items4flow = $param_flow->{_num_items4flow}; | ||
| 712 | |||
| 713 | =cut | ||
| 714 | |||
| 715 | sub private_set_good_values4item { | ||
| 716 | my ($index4flow) = @_; | ||
| 717 | |||
| 718 | # print("param_flow,set_good_indices4item, | ||
| 719 | # self,index4flow: $self,$index4flow\n"); | ||
| 720 | |||
| 721 | my $idx = $index4flow; # program sequence in flow | ||
| 722 | my (@good); | ||
| 723 | my ($j); | ||
| 724 | |||
| 725 | # print("1. param_flow,private_set_good_values4item, | ||
| 726 | # flow index:$idx, | ||
| 727 | # prog name:@{$param_flow->{_prog_names_aref}}[$idx] \n"); | ||
| 728 | |||
| 729 | my $values_aref = private_get_values_aref($idx); | ||
| 730 | my $length = scalar @$values_aref; | ||
| 731 | |||
| 732 | for ( my $i = 0, $j = 0 ; $i < $length ; $i++ ) { | ||
| 733 | |||
| 734 | #print("param_flow, private_set_good_values_4item: | ||
| 735 | #values_aref is @$values_aref[$i]\n"); | ||
| 736 | |||
| 737 | if ( @$values_aref[$i] ne "'nu'" | ||
| 738 | && @$values_aref[$i] ne '' ) | ||
| 739 | { | ||
| 740 | |||
| 741 | my $value = ${ @{ $param_flow->{_values_aref2} }[$idx] }[$i]; | ||
| 742 | |||
| 743 | # print("2. param_flow,private_set_good_values4item, | ||
| 744 | # good index #$i, value:$value \n"); | ||
| 745 | |||
| 746 | $good[$j] = $value; | ||
| 747 | $j++; | ||
| 748 | } | ||
| 749 | } | ||
| 750 | |||
| 751 | $num_good_values[$idx] = $j; | ||
| 752 | |||
| 753 | #print("param_flow,private_set_good_values4item, | ||
| 754 | #good_values=@good \n"); | ||
| 755 | |||
| 756 | $param_flow->{_num_good_values_aref} = \@num_good_values; | ||
| 757 | |||
| 758 | $good_values[$idx] = \@good; | ||
| 759 | $param_flow->{_good_values_aref2} = \@good_values; | ||
| 760 | |||
| 761 | #print(" 3. param_flow,private_set_good_values4item, | ||
| 762 | #num_good_values= $num_good_values[$idx] , | ||
| 763 | #values are: @{@{$param_flow->{_good_values_aref2}}[$idx]}\n"); | ||
| 764 | |||
| 765 | } | ||
| 766 | |||
| 767 | =head2 sub set_flow_items_version_aref | ||
| 768 | |||
| 769 | i/p is array ref of the version of each program name | ||
| 770 | |||
| 771 | =cut | ||
| 772 | |||
| 773 | sub set_flow_items_version_aref { | ||
| 774 | my ( $self, $program_version_aref ) = @_; | ||
| 775 | if ($program_version_aref) { | ||
| 776 | $param_flow->{_prog_version_aref} = $program_version_aref; | ||
| 777 | |||
| 778 | #print("param_flow, set_flow_items_version_aref @{$param_flow->{_prog_version_aref}}\n"); | ||
| 779 | } | ||
| 780 | } | ||
| 781 | |||
| 782 | =head2 sub set_insert_start | ||
| 783 | |||
| 784 | move paramter names and values | ||
| 785 | of one selected item into another | ||
| 786 | space | ||
| 787 | |||
| 788 | =cut | ||
| 789 | |||
| 790 | sub set_insert_start { | ||
| 791 | my ( $self, $start ) = @_; | ||
| 792 | $param_flow->{_index2move} = $start; | ||
| 793 | |||
| 794 | # print("param_flow,set_insert_start is $start\n"); | ||
| 795 | |||
| 796 | return (); | ||
| 797 | } | ||
| 798 | |||
| 799 | =head2 sub set_insert_end | ||
| 800 | |||
| 801 | move paramter names and values | ||
| 802 | of one selected item into another | ||
| 803 | space | ||
| 804 | |||
| 805 | =cut | ||
| 806 | |||
| 807 | sub set_insert_end { | ||
| 808 | my ( $self, $end ) = @_; | ||
| 809 | $param_flow->{_destination_index} = $end; | ||
| 810 | |||
| 811 | # print("param_flow,set_insert_end $end \n"); | ||
| 812 | |||
| 813 | return (); | ||
| 814 | } | ||
| 815 | |||
| 816 | =head2 sub set_flow_index | ||
| 817 | |||
| 818 | select an item for which to extract data | ||
| 819 | print("param_flow, set flow_index, prog name is @{$param_flow->{_prog_names_aref}}[$index]\n"); | ||
| 820 | |||
| 821 | =cut | ||
| 822 | |||
| 823 | sub set_flow_index { | ||
| 824 | my ( $self, $index ) = @_; | ||
| 825 | |||
| 826 | # print("param_flow, set_flow_index,index, $index\n"); | ||
| 827 | if ( $index >= 0 ) { | ||
| 828 | |||
| 829 | $param_flow->{_selection_index} = $index; | ||
| 830 | } | ||
| 831 | else { | ||
| 832 | print( | ||
| 833 | "param_flow, set_flow_index,index does not exist, index:$index\n"); | ||
| 834 | } | ||
| 835 | return (); | ||
| 836 | } | ||
| 837 | |||
| 838 | =head2 sub set_names_aref | ||
| 839 | |||
| 840 | |||
| 841 | =cut | ||
| 842 | |||
| 843 | sub set_names_aref { | ||
| 844 | my ( $self, $names_aref ) = @_; | ||
| 845 | my $index = $param_flow->{_selection_index}; | ||
| 846 | |||
| 847 | # print(" param_flow, set_names: @{$names_aref}, index is $index\n"); | ||
| 848 | |||
| 849 | if ( $index >= 0 ) { | ||
| 850 | my @names_aref; | ||
| 851 | my ($length); | ||
| 852 | |||
| 853 | @{ $param_flow->{_names_aref2} }[$index] = $names_aref; | ||
| 854 | |||
| 855 | # $length = scalar @names_aref; | ||
| 856 | |||
| 857 | return (); | ||
| 858 | } | ||
| 859 | } | ||
| 860 | |||
| 861 | =head2 sub set_good_labels | ||
| 862 | |||
| 863 | select names with values | ||
| 864 | |||
| 865 | =cut | ||
| 866 | |||
| 867 | sub set_good_labels { | ||
| 868 | |||
| 869 | my ($self) = @_; | ||
| 870 | my $length = $param_flow->{_num_items4flow}; | ||
| 871 | |||
| 872 | # print("param_flow,set_good_labels | ||
| 873 | # num_items4flow: $param_flow->{_num_items4flow}\n"); | ||
| 874 | |||
| 875 | for ( my $i = 0 ; $i < $length ; $i++ ) { | ||
| 876 | private_set_good_labels4item($i); | ||
| 877 | } | ||
| 878 | |||
| 879 | return (); | ||
| 880 | |||
| 881 | } | ||
| 882 | |||
| 883 | =head2 sub set_good_values | ||
| 884 | |||
| 885 | find good values for ALL programs in flow | ||
| 886 | |||
| 887 | =cut | ||
| 888 | |||
| 889 | sub set_good_values { | ||
| 890 | |||
| 891 | my ($self) = @_; | ||
| 892 | my $length = $param_flow->{_num_items4flow}; | ||
| 893 | |||
| 894 | # print("param_flow,set_good_values | ||
| 895 | # num_items4flow: $param_flow->{_num_items4flow}\n"); | ||
| 896 | |||
| 897 | for ( my $i = 0 ; $i < $length ; $i++ ) { | ||
| 898 | private_set_good_values4item($i); | ||
| 899 | } | ||
| 900 | |||
| 901 | return (); | ||
| 902 | } | ||
| 903 | |||
| 904 | =head2 sub set_good_labels4item | ||
| 905 | |||
| 906 | my $num_items4flow = $param_flow->{_num_items4flow}; | ||
| 907 | |||
| 908 | =cut | ||
| 909 | |||
| 910 | sub set_good_labels4item { | ||
| 911 | my ( $self, $index4flow ) = @_; | ||
| 912 | |||
| 913 | # print("param_flow,set_good_labels4item, | ||
| 914 | # self,index4flow: $self,$index4flow\n"); | ||
| 915 | |||
| 916 | my $idx = $index4flow; | ||
| 917 | my ( @good, @good_labels ); | ||
| 918 | my ( $num_good_labels, $j ); | ||
| 919 | |||
| 920 | # print("1. param_flow,set_good_labels4item, | ||
| 921 | #flow index:$idx, prog name: | ||
| 922 | # @{$param_flow->{_prog_names_aref}}[$idx] \n"); | ||
| 923 | |||
| 924 | # good values (not names) determine good names | ||
| 925 | my $values_aref = private_get_values_aref($idx); | ||
| 926 | my $length = scalar @$values_aref; | ||
| 927 | |||
| 928 | for ( my $i = 0, $j = 0 ; $i < $length ; $i++ ) { | ||
| 929 | |||
| 930 | # print("param_flow, set_good_labels4item: | ||
| 931 | # values_aref is @$values_aref[$i]\n"); | ||
| 932 | |||
| 933 | if ( @$values_aref[$i] ne "'nu'" ) { | ||
| 934 | my $name = ${ @{ $param_flow->{_names_aref2} }[$idx] }[$i]; | ||
| 935 | |||
| 936 | #print("2. param_flow,set_good_labels4item, | ||
| 937 | #good index #$i, name:$name \n"); | ||
| 938 | |||
| 939 | $good[$j] = $name; | ||
| 940 | $j++; | ||
| 941 | } | ||
| 942 | } | ||
| 943 | |||
| 944 | $num_good_labels = $j; | ||
| 945 | |||
| 946 | # print("param_flow,set_good_labels4item, | ||
| 947 | # good_labels=@good \n"); | ||
| 948 | |||
| 949 | $good_labels[$idx] = \@good; | ||
| 950 | $param_flow->{_good_labels_aref2} = \@good_labels; | ||
| 951 | |||
| 952 | # print(" 3. param_flow,set_good_,names4item, | ||
| 953 | # num_good_labels= $num_good_labels , names are: | ||
| 954 | # @{@{$param_flow->{_good_labels_aref2}}[$idx]}\n"); | ||
| 955 | return (); | ||
| 956 | } | ||
| 957 | |||
| 958 | =head2 sub set_good_values4item | ||
| 959 | |||
| 960 | my $num_items4flow = $param_flow->{_num_items4flow}; | ||
| 961 | work on finding good values for one item | ||
| 962 | |||
| 963 | =cut | ||
| 964 | |||
| 965 | sub set_good_values4item { | ||
| 966 | my ( $self, $index4flow ) = @_; | ||
| 967 | |||
| 968 | # print("param_flow,set_good_indices4item, | ||
| 969 | # self,index4flow: $self,$index4flow\n"); | ||
| 970 | |||
| 971 | my $idx = $index4flow; | ||
| 972 | my ( @good, @good_values ); | ||
| 973 | my ( $num_good_values, $j ); | ||
| 974 | |||
| 975 | # print("1. param_flow,set_good_values4item, | ||
| 976 | # flow index:$idx, prog name: | ||
| 977 | # @{$param_flow->{_prog_names_aref}}[$idx] \n"); | ||
| 978 | |||
| 979 | my $values_aref = private_get_values_aref($idx); | ||
| 980 | my $length = scalar @$values_aref; | ||
| 981 | |||
| 982 | for ( my $i = 0, $j = 0 ; $i < $length ; $i++ ) { | ||
| 983 | |||
| 984 | # print("param_flow, set_good_values4item: | ||
| 985 | # values_aref is @$values_aref[$i]\n"); | ||
| 986 | |||
| 987 | if ( @$values_aref[$i] ne "'nu'" ) { | ||
| 988 | my $value = ${ @{ $param_flow->{_values_aref2} }[$idx] }[$i]; | ||
| 989 | |||
| 990 | # print("2. param_flow,set_good_indices4item, | ||
| 991 | # good index #$i, value:$value \n"); | ||
| 992 | |||
| 993 | $good[$j] = $value; | ||
| 994 | $j++; | ||
| 995 | } | ||
| 996 | } | ||
| 997 | |||
| 998 | $num_good_values = $j; | ||
| 999 | |||
| 1000 | # print("param_flow,set_good_values4item, | ||
| 1001 | # good_values=@good \n"); | ||
| 1002 | |||
| 1003 | $good_values[$idx] = \@good; | ||
| 1004 | $param_flow->{_good_values_aref2} = \@good_values; | ||
| 1005 | |||
| 1006 | # print(" 3. param_flow,set_good_,values4item, | ||
| 1007 | # num_good_values= $num_good_values , values are: | ||
| 1008 | # @{@{$param_flow->{_good_values_aref2}}[$idx]}\n"); | ||
| 1009 | return (); | ||
| 1010 | } | ||
| 1011 | |||
| 1012 | =head2 sub set_values_aref | ||
| 1013 | |||
| 1014 | |||
| 1015 | =cut | ||
| 1016 | |||
| 1017 | sub set_values_aref { | ||
| 1018 | my ( $self, $values_aref ) = @_; | ||
| 1019 | my $index = $param_flow->{_selection_index}; | ||
| 1020 | |||
| 1021 | if ( $index >= 0 ) { | ||
| 1022 | my ( $i, $j, $length ); | ||
| 1023 | my ( @values_aref, @values ); | ||
| 1024 | |||
| 1025 | @{ $param_flow->{_values_aref2} }[$index] = $values_aref; | ||
| 1026 | $length = scalar @values_aref; | ||
| 1027 | |||
| 1028 | # print("param_flow,set_values :values_aref is @$values_aref\n"); | ||
| 1029 | |||
| 1030 | # for ($i=1,$j=0; $i < $length; $i=$i+2,$j++ ) { | ||
| 1031 | # $values[$j] = $values_aref[$i]; | ||
| 1032 | # #print("param_flow, set_values :index $j values: $values[$j]\n"); | ||
| 1033 | # } | ||
| 1034 | return (); | ||
| 1035 | } | ||
| 1036 | } | ||
| 1037 | |||
| 1038 | =head2 sub set_check_buttons_settings | ||
| 1039 | |||
| 1040 | set check_buttons by user from outside | ||
| 1041 | |||
| 1042 | =cut | ||
| 1043 | |||
| 1044 | sub set_check_buttons_settings_aref { | ||
| 1045 | my ( $self, $check_buttons_settings_aref ) = @_; | ||
| 1046 | my $index = $param_flow->{_selection_index}; | ||
| 1047 | my $chkbut_aref = $check_buttons_settings_aref; | ||
| 1048 | |||
| 1049 | if ( $index >= 0 ) { | ||
| 1050 | my ( $i, $j, $length ); | ||
| 1051 | my @on_off; | ||
| 1052 | my @values_aref; | ||
| 1053 | |||
| 1054 | @{ $param_flow->{_checkbuttons_aref2} }[$index] = $chkbut_aref; | ||
| 1055 | |||
| 1056 | # $length = scalar @$chkbut_aref; | ||
| 1057 | |||
| 1058 | # print("param_flow,set_check_buttons_settings: is @$chkbut_aref\n"); | ||
| 1059 | |||
| 1060 | #for ($i=1,$j=0; $i < $length; $i=$i+2,$j++ ) { | ||
| 1061 | #for ($i=0; $i < $length; $i++ ) { | ||
| 1062 | #$values[$j] = $values_aref[$i]; | ||
| 1063 | #print("param_flow, set_check_buttons_settings :index $j values: $values[$j]\n"); | ||
| 1064 | #if(@$values_aref[$i] eq $nu) { | ||
| 1065 | # $on_off[$i] = $off; | ||
| 1066 | # print(" 1. param_flow, set_check_buttons_settings,$on_off[$i]\n"); | ||
| 1067 | #} | ||
| 1068 | #else { | ||
| 1069 | # $on_off[$i] = $on; | ||
| 1070 | # print(" 2. param_flow, set_check_buttons_settings,$on_off[$i]\n"); | ||
| 1071 | #} | ||
| 1072 | # print("param_flow: set_check_buttons_settings :index $i setting $nu is: $on_off[$i]\n"); | ||
| 1073 | #} | ||
| 1074 | #return(); | ||
| 1075 | } | ||
| 1076 | return (); | ||
| 1077 | } | ||
| 1078 | |||
| 1079 | =head2 sub stack_checkbuttons_aref2 | ||
| 1080 | |||
| 1081 | array of arrays | ||
| 1082 | One array if checkbuttons for each item | ||
| 1083 | DB | ||
| 1084 | #for (my $i=0; $i<=$index;$i++) { | ||
| 1085 | #print("param_flow,checkbuttons_aref,@{@{$param_flow->{_checkbuttons_aref2}}[$i]} index $i\n"); | ||
| 1086 | #} | ||
| 1087 | #print("param_flow, checkbuttons_aref2, num_items4checkbuttons $param_flow->{_num_items4checkbuttons}\n"); | ||
| 1088 | |||
| 1089 | =cut | ||
| 1090 | |||
| 1091 | sub stack_checkbuttons_aref2 { | ||
| 1092 | |||
| 1093 | my ( $self, $checkbuttons_aref ) = @_; | ||
| 1094 | my $index = $param_flow->{_index4checkbuttons} + 1; | ||
| 1095 | |||
| 1096 | $checkbuttons[$index] = $checkbuttons_aref; | ||
| 1097 | $param_flow->{_checkbuttons_aref2} = \@checkbuttons; | ||
| 1098 | |||
| 1099 | $param_flow->{_indices} = $index; | ||
| 1100 | $param_flow->{_index4checkbuttons}++; | ||
| 1101 | $param_flow->{_num_items4checkbuttons}++; | ||
| 1102 | $param_flow->{_num_items} = $param_flow->{_num_items4checkbuttons}; | ||
| 1103 | |||
| 1104 | # print("param_flow,stack_checkbuttons_aref2, @{$checkbuttons[$index]},idx $index num_items $param_flow->{_num_items}\n"); | ||
| 1105 | # print("param_flow,stack_checkbuttons_aref2, @{@{$param_flow->{_checkbuttons_aref2}}[$index]},idx $index num_items $param_flow->{_num_items}\n"); | ||
| 1106 | |||
| 1107 | return (); | ||
| 1108 | } | ||
| 1109 | |||
| 1110 | =head2 sub stack_flow_item | ||
| 1111 | |||
| 1112 | i/p is scalar ref to a program name | ||
| 1113 | keep count and increment the number of items | ||
| 1114 | encapsulate internal counters and array | ||
| 1115 | from the array shared among the package subroutines | ||
| 1116 | |||
| 1117 | count items at start in case we don't return to the subroutine | ||
| 1118 | later | ||
| 1119 | print("param_flow, stack_flow_item @{$param_flow->{_prog_names_aref}}, num_items $param_flow->{_num_items}\n"); | ||
| 1120 | print("param_flow, stack_flow_item, index: $index\n"); | ||
| 1121 | |||
| 1122 | =cut | ||
| 1123 | |||
| 1124 | sub stack_flow_item { | ||
| 1125 | my ( $self, $program_name_sref ) = @_; | ||
| 1126 | if ($program_name_sref) { | ||
| 1127 | my $index = $param_flow->{_index4flow} + 1; | ||
| 1128 | |||
| 1129 | # print("param_flow, stack_flow_item, index: $index\n"); | ||
| 1130 | |||
| 1131 | $program_names[$index] = $$program_name_sref; | ||
| 1132 | $param_flow->{_prog_names_aref} = \@program_names; | ||
| 1133 | |||
| 1134 | $param_flow->{_indices} = $index; | ||
| 1135 | $param_flow->{_index4flow} = $index; | ||
| 1136 | $param_flow->{_num_items4flow}++; | ||
| 1137 | $param_flow->{_num_items}++; | ||
| 1138 | |||
| 1139 | } | ||
| 1140 | return (); | ||
| 1141 | } | ||
| 1142 | |||
| 1143 | =head2 sub stack_names_aref2 | ||
| 1144 | |||
| 1145 | i/p array ref for values in a program | ||
| 1146 | an array of arrays is created, one array for each item | ||
| 1147 | DrBN | ||
| 1148 | # for (my $i=0; $i<=$index;$i++) { | ||
| 1149 | #print("param_flow,names_aref,@{@{$param_flow->{_names_aref2}}[$i]} item $i\n"); | ||
| 1150 | # } | ||
| 1151 | #print("param_flow, names_aref2, num_items4names $param_flow->{_num_items4names}\n"); | ||
| 1152 | |||
| 1153 | #print("param_flow,names_aref,$names[$index],item $index\n"); | ||
| 1154 | =cut | ||
| 1155 | |||
| 1156 | sub stack_names_aref2 { | ||
| 1157 | |||
| 1158 | my ( $self, $names_aref ) = @_; | ||
| 1159 | my $index = $param_flow->{_index4names} + 1; | ||
| 1160 | |||
| 1161 | $names[$index] = $names_aref; | ||
| 1162 | $param_flow->{_names_aref2} = \@names; | ||
| 1163 | |||
| 1164 | $param_flow->{_indices} = $index; | ||
| 1165 | $param_flow->{_index4names}++; | ||
| 1166 | $param_flow->{_num_items4names}++; | ||
| 1167 | $param_flow->{_num_items} = $param_flow->{_num_items4names}; | ||
| 1168 | |||
| 1169 | # print("param_flow,names_aref2, names @{$names[$index]},idx $index num_items $param_flow->{_num_items}\n"); | ||
| 1170 | for ( my $i = 0 ; $i <= $index ; $i++ ) { | ||
| 1171 | |||
| 1172 | # print("param_flow,stack_names_aref2, cumulative names @{$names[$i]},idx $index num_items $param_flow->{_num_items}\n"); | ||
| 1173 | } | ||
| 1174 | |||
| 1175 | return (); | ||
| 1176 | } | ||
| 1177 | |||
| 1178 | =head2 sub stack_values_aref2 | ||
| 1179 | |||
| 1180 | i/p array ref for values in a program | ||
| 1181 | an array of arrays is created, one array for each item | ||
| 1182 | |||
| 1183 | DB | ||
| 1184 | #for (my $i=0; $i<=$index;$i++) { | ||
| 1185 | # print("param_flow,values_aref2,@{@{$param_flow->{_values_aref2}}[$i]} index $i\n"); | ||
| 1186 | #} | ||
| 1187 | #print("param_flow,values_aref2,num_items=$param_flow->{_num_items}\n"); | ||
| 1188 | # print("param_flow,values_aref2, index $index\n"); | ||
| 1189 | |||
| 1190 | =cut | ||
| 1191 | |||
| 1192 | sub stack_values_aref2 { | ||
| 1193 | |||
| 1194 | my ( $self, $values_aref ) = @_; | ||
| 1195 | my $index = $param_flow->{_index4values} + 1; | ||
| 1196 | |||
| 1197 | $values[$index] = $values_aref; | ||
| 1198 | $param_flow->{_values_aref2} = \@values; | ||
| 1199 | |||
| 1200 | $param_flow->{_indices} = $index; | ||
| 1201 | $param_flow->{_index4values}++; | ||
| 1202 | $param_flow->{_num_items4values}++; | ||
| 1203 | $param_flow->{_num_items} = $param_flow->{_num_items4values}; | ||
| 1204 | |||
| 1205 | # print("param_flow,stack_values_aref2, values @{$values[$index]},idx $index num_items $param_flow->{_num_items}\n"); | ||
| 1206 | return (); | ||
| 1207 | } | ||
| 1208 | |||
| 1209 | =head2 sub view_data | ||
| 1210 | |||
| 1211 | Data viewer for debugging | ||
| 1212 | print("B4 delete: names are $param_flow->{_names_aref2}\n"); # ref_Array | ||
| 1213 | print("B4 delete: names are @{$param_flow->{_names_aref2}}\n"); # [ref_array0 ref_array1 .... | ||
| 1214 | print("B4 delete: names are @{$param_flow->{_names_aref2}}[0]\n"); # ref_array0 | ||
| 1215 | |||
| 1216 | print("B4 delete: names are @{$param_flow->{_names_aref2}}[1]\n"); #ref_array1 | ||
| 1217 | |||
| 1218 | print("B4 delete: names are @{@{$param_flow->{_names_aref2}}[0]}\n"); # all names in ref_array 0 | ||
| 1219 | print("B4 delete: names are @{@{$param_flow->{_names_aref2}}[1]}[0]\n"); # first name in ref_array | ||
| 1220 | print("param_flow,view_data: list for each item\n"); | ||
| 1221 | |||
| 1222 | =cut | ||
| 1223 | |||
| 1224 | sub view_data { | ||
| 1225 | my ( $self, $index2delete ) = @_; | ||
| 1226 | my @num_progs; | ||
| 1227 | |||
| 1228 | my $indices = $param_flow->{_indices}; | ||
| 1229 | $num_progs[0] = $param_flow->{_num_items}; | ||
| 1230 | |||
| 1231 | $num_progs[1] = scalar( @{ $param_flow->{_names_aref2} } ); | ||
| 1232 | $num_progs[3] = scalar( @{ $param_flow->{_values_aref2} } ); | ||
| 1233 | $num_progs[4] = scalar( @{ $param_flow->{_checkbuttons_aref2} } ); | ||
| 1234 | $num_progs[5] = scalar( @{ $param_flow->{_prog_names_aref} } ); | ||
| 1235 | |||
| 1236 | # print("\nparam_flow,view_data:number of items in list in 4-5 different ways @num_progs \n"); | ||
| 1237 | # print("param_flow,view_data:max index = $indices \n\n"); | ||
| 1238 | |||
| 1239 | print( | ||
| 1240 | "param_flow,view_data: prog_names: @{$param_flow->{_prog_names_aref}}\n" | ||
| 1241 | ); | ||
| 1242 | for ( my $i = 0 ; $i <= $indices ; $i++ ) { | ||
| 1243 | print( | ||
| 1244 | "param_flow,view_data: names: @{@{$param_flow->{_names_aref2}}[$i]}\n" | ||
| 1245 | ); | ||
| 1246 | |||
| 1247 | # print("param_flow,view_data: values: @{@{$param_flow->{_values_aref2}}[$i]}\n"); | ||
| 1248 | # print("param_flow,view_data: checkbuttons: @{@{$param_flow->{_checkbuttons_aref2}}[$i]}\n\n"); | ||
| 1249 | } | ||
| 1250 | } | ||
| 1251 | |||
| 1252 | 1; |