« lib/App/SeismicUnixGui/misc/manage_files_by.pm
↑ Summary
lib/App/SeismicUnixGui/script/L_SU_project_selector.pl »
| 1 | |||
| 2 | =head1 DOCUMENTATION | ||
| 3 | |||
| 4 | =head2 SYNOPSIS | ||
| 5 | |||
| 6 | PROGRAM NAME: iVA | ||
| 7 | AUTHOR: Juan Lorenzo | ||
| 8 | DATE: April 2 2009 | ||
| 9 | October 2014 | ||
| 10 | July 2015 updated to oop | ||
| 11 | August 2015 introduced Tk widgets | ||
| 12 | August 16 made all event-driven | ||
| 13 | Aug 18 2016 made configuration files simple | ||
| 14 | |||
| 15 | DESCRIPTION: Interactively test NMO in data | ||
| 16 | Verstion 2.0 MainWIndow in subroutine | ||
| 17 | leads to multiple segementation faults | ||
| 18 | when MainWindow is destroyed > 1 | ||
| 19 | Version: 2.1 is fully event driven | ||
| 20 | |||
| 21 | =head2 USE | ||
| 22 | |||
| 23 | =head3 NOTES | ||
| 24 | |||
| 25 | =head4 | ||
| 26 | Examples | ||
| 27 | |||
| 28 | =head3 SEISMIC UNIX NOTES | ||
| 29 | =head4 CHANGES and their DATES | ||
| 30 | |||
| 31 | |||
| 32 | =cut | ||
| 33 | |||
| 34 | |||
| 35 | =head2 STEPS | ||
| 36 | |||
| 37 | 1. use the local library of the user | ||
| 38 | 1.1 bring is user variables from a local file | ||
| 39 | 2. create instances of the needed subroutines | ||
| 40 | |||
| 41 | =cut | ||
| 42 | |||
| 43 | =head2 Import | ||
| 44 | |||
| 45 | packages | ||
| 46 | |||
| 47 | =cut | ||
| 48 | |||
| 49 | use Moose; | ||
| 50 | our $VERSION = '0.0.1'; | ||
| 51 | use Tk; | ||
| 52 | use aliased 'App::SeismicUnixGui::big_streams::iVA'; | ||
| 53 | use App::SeismicUnixGui::misc::SeismicUnix qw($true $false ); | ||
| 54 | |||
| 55 | =head2 instantiate methods | ||
| 56 | |||
| 57 | =cut | ||
| 58 | |||
| 59 | my $iVA = iVA->new(); | ||
| 60 | |||
| 61 | =head2 Declare variables | ||
| 62 | |||
| 63 | in local memory space | ||
| 64 | |||
| 65 | =cut | ||
| 66 | |||
| 67 | my $iVA_Tk = {_prompt => ''}; | ||
| 68 | |||
| 69 | my ( $calc_rb, $exit_rb, $pick_rb, $next_rb, $saveNcont_rb ); | ||
| 70 | my $rb_value = "red"; | ||
| 71 | my $old_data; | ||
| 72 | my $next_step = 'stop'; | ||
| 73 | my $number_of_tries = 0; | ||
| 74 | our $mw; | ||
| 75 | |||
| 76 | =head2 Check | ||
| 77 | |||
| 78 | for old data | ||
| 79 | |||
| 80 | =cut | ||
| 81 | |||
| 82 | $old_data = $iVA->old_data('velan'); | ||
| 83 | |||
| 84 | =head2 Create Main Window | ||
| 85 | |||
| 86 | and start event-driven loop | ||
| 87 | Interaction with user | ||
| 88 | initialize values | ||
| 89 | If picks are new, show | ||
| 90 | message to user on how to pick data | ||
| 91 | -Based on semblance, | ||
| 92 | decide whether to PICK or move on to NEXT CDP | ||
| 93 | -radio_buttons stop flow | ||
| 94 | Must be AFTR semblance | ||
| 95 | |||
| 96 | set the prompt value according | ||
| 97 | to which button is pressed | ||
| 98 | then exit the MainLoop | ||
| 99 | destroy the main window after the prompt | ||
| 100 | is properly set | ||
| 101 | |||
| 102 | =cut | ||
| 103 | |||
| 104 | if ( !$old_data ) { | ||
| 105 | |||
| 106 | print("iVelocityAnalysis, no old data\n"); | ||
| 107 | $iVA->start(); | ||
| 108 | |||
| 109 | $mw = MainWindow->new; | ||
| 110 | $mw->title("Options"); | ||
| 111 | $mw->geometry("300x50+40+0"); | ||
| 112 | $mw->title("iVA"); | ||
| 113 | |||
| 114 | $calc_rb = $mw->Radiobutton( | ||
| 115 | -text => 'CALC', | ||
| 116 | -value => 'calc', | ||
| 117 | -variable => \$rb_value, | ||
| 118 | -command => [ \&set_calc ] | ||
| 119 | )->pack( -side => 'left' ); | ||
| 120 | |||
| 121 | $next_rb = $mw->Radiobutton( | ||
| 122 | -text => 'NEXT', | ||
| 123 | -value => 'next', | ||
| 124 | -variable => \$rb_value, | ||
| 125 | -command => [ \&set_next ] | ||
| 126 | )->pack( -side => 'left' ); | ||
| 127 | |||
| 128 | $pick_rb = $mw->Radiobutton( | ||
| 129 | -text => 'PICK', | ||
| 130 | -value => 'pick', | ||
| 131 | -variable => \$rb_value, | ||
| 132 | -command => [ \&set_pick ] | ||
| 133 | )->pack( -side => 'left' ); | ||
| 134 | |||
| 135 | |||
| 136 | $exit_rb = $mw->Radiobutton( | ||
| 137 | -text => 'EXIT', | ||
| 138 | -value => 'exit', | ||
| 139 | -variable => \$rb_value, | ||
| 140 | -command => [ \&set_exit ] | ||
| 141 | )->pack( -side => 'bottom' ); | ||
| 142 | |||
| 143 | MainLoop; # for Tk widgets | ||
| 144 | |||
| 145 | } # for new data | ||
| 146 | |||
| 147 | |||
| 148 | =pod sub set_pick | ||
| 149 | |||
| 150 | A callback to: | ||
| 151 | send cdp number to $iVA | ||
| 152 | delete output of previous semblance | ||
| 153 | plus more callbacks following... | ||
| 154 | |||
| 155 | =cut | ||
| 156 | |||
| 157 | sub set_pick { | ||
| 158 | |||
| 159 | my $pick = 'pick'; | ||
| 160 | $next_rb->configure( -state => 'disabled' ); | ||
| 161 | |||
| 162 | #$pick_rb->configure(-state => 'normal'); | ||
| 163 | $calc_rb->configure( -state => 'normal' ); | ||
| 164 | $iVA_Tk->{_prompt} = $pick; | ||
| 165 | $iVA->pick(); | ||
| 166 | } | ||
| 167 | |||
| 168 | =pod sub set_calc | ||
| 169 | |||
| 170 | -PRESS the CALC button | ||
| 171 | -Increment number of tries to make | ||
| 172 | semblance display interact and show old picks | ||
| 173 | (number_of_tries >1) | ||
| 174 | -radio_buttons stop flow | ||
| 175 | Must be AFTR semblance | ||
| 176 | B4 iWrite_All_iva_out | ||
| 177 | |||
| 178 | =cut | ||
| 179 | |||
| 180 | sub set_calc { | ||
| 181 | |||
| 182 | my $calc = 'calc'; | ||
| 183 | $next_rb->configure( -state => 'normal' ); | ||
| 184 | $iVA_Tk->{_prompt} = $calc; | ||
| 185 | $iVA->calc(); | ||
| 186 | |||
| 187 | } | ||
| 188 | |||
| 189 | =pod sub set_next | ||
| 190 | |||
| 191 | In this case the $variable is empty | ||
| 192 | 1. increment cdp | ||
| 193 | Exit if beyond last cdp | ||
| 194 | 2. reset prompt | ||
| 195 | 3. Otherwise display the first sembance | ||
| 196 | 4 ... see following callbacks | ||
| 197 | |||
| 198 | =cut | ||
| 199 | |||
| 200 | |||
| 201 | sub set_next { | ||
| 202 | print("Next...\n"); | ||
| 203 | $next_rb->configure( -state => 'normal' ); | ||
| 204 | $calc_rb->configure( -state => 'disabled' ); | ||
| 205 | my $next = ''; | ||
| 206 | $iVA_Tk->{_prompt} = $next; | ||
| 207 | $iVA->next(); | ||
| 208 | |||
| 209 | } | ||
| 210 | |||
| 211 | =pod sub set_exit | ||
| 212 | |||
| 213 | saying goodbye | ||
| 214 | clear old images | ||
| 215 | kill window | ||
| 216 | stop script | ||
| 217 | |||
| 218 | =cut | ||
| 219 | |||
| 220 | sub set_exit { | ||
| 221 | my $exit = 'exit'; | ||
| 222 | $exit_rb->configure( -state => 'normal' ); | ||
| 223 | $iVA_Tk->{_prompt} = $exit; | ||
| 224 | $mw->destroy() if Tk::Exists($mw); | ||
| 225 | $iVA->exit(); | ||
| 226 | } | ||
| 227 | |||
| 228 | =pod sub prompt | ||
| 229 | |||
| 230 | return which prompt has been set | ||
| 231 | |||
| 232 | =cut | ||
| 233 | |||
| 234 | sub prompt { | ||
| 235 | our $variable = $iVA_Tk->{_prompt}; | ||
| 236 | return ($variable); | ||
| 237 | } |