« lib/App/SeismicUnixGui/sunix/plot/spsplot.pm
↑ Summary
lib/App/SeismicUnixGui/sunix/migration/sutifowler.pm »
| 1 | package App::SeismicUnixGui::misc::program_name; | ||
| 2 | |||
| 3 | =head1 DOCUMENTATION | ||
| 4 | |||
| 5 | =head2 SYNOPSIS | ||
| 6 | |||
| 7 | |||
| 8 | PROGRAM NAME: program_name | ||
| 9 | AUTHOR: Juan Lorenzo | ||
| 10 | |||
| 11 | =head2 CHANGES and their DATES | ||
| 12 | |||
| 13 | DATE: July 2024 | ||
| 14 | Version 1.0.1 July 29 2016 | ||
| 15 | |||
| 16 | |||
| 17 | =head2 DESCRIPTION | ||
| 18 | |||
| 19 | handle program name exchanges between | ||
| 20 | gui and internal representations | ||
| 21 | |||
| 22 | For example for the user: fk | ||
| 23 | for the program: Sudipfilt | ||
| 24 | |||
| 25 | =head2 REQUIRES | ||
| 26 | |||
| 27 | |||
| 28 | =head2 Examples | ||
| 29 | |||
| 30 | |||
| 31 | |||
| 32 | =head2 STEPS | ||
| 33 | |||
| 34 | |||
| 35 | |||
| 36 | =head2 NOTES | ||
| 37 | |||
| 38 | We are using Moose. | ||
| 39 | Moose already declares that you need debuggers turned on | ||
| 40 | so you don't need a line like the following: | ||
| 41 | use warnings; | ||
| 42 | |||
| 43 | |||
| 44 | =cut | ||
| 45 | |||
| 46 | use Moose; | ||
| 47 | our $VERSION = '0.0.1'; | ||
| 48 | |||
| 49 | =head2 private hash control | ||
| 50 | |||
| 51 | |||
| 52 | =cut | ||
| 53 | |||
| 54 | my $program_name = { | ||
| 55 | |||
| 56 | _in => '', | ||
| 57 | |||
| 58 | }; | ||
| 59 | |||
| 60 | =head2 definitions copied from L_SU_global constants | ||
| 61 | |||
| 62 | =cut | ||
| 63 | |||
| 64 | my $superflow_internal_names_h = { | ||
| 65 | _fk => 'Sudipfilt', | ||
| 66 | _Sudipfilt => 'Sudipfilt', | ||
| 67 | _ProjectVariables => 'ProjectVariables', | ||
| 68 | _iPick => 'iPick', | ||
| 69 | _SetProject => 'SetProject', | ||
| 70 | _iSpectralAnalysis => 'iSpectralAnalysis', | ||
| 71 | _iVelAnalysis => 'iVA', | ||
| 72 | _iVA => 'iVA', | ||
| 73 | _iTopMute => 'iTopMute', | ||
| 74 | _iBottomMute => 'iBottomMute', | ||
| 75 | _Project => 'Project', | ||
| 76 | _Synseis => 'Synseis', | ||
| 77 | _Sseg2su => 'Sseg2su', | ||
| 78 | _Sucat => 'Sucat', | ||
| 79 | _immodpg => 'immodpg', | ||
| 80 | _BackupProject => 'BackupProject', | ||
| 81 | _ProjectBackup => 'BackupProject', | ||
| 82 | _ProjectRestore => 'RestoreProject', | ||
| 83 | _RestoreProject => 'RestoreProject', | ||
| 84 | _temp => 'temp', # make last | ||
| 85 | }; | ||
| 86 | |||
| 87 | =head2 | ||
| 88 | |||
| 89 | as shown in gui | ||
| 90 | |||
| 91 | =cut | ||
| 92 | |||
| 93 | my @superflow_names_gui; | ||
| 94 | |||
| 95 | $superflow_names_gui[0] = 'Project'; | ||
| 96 | $superflow_names_gui[1] = 'Sseg2su'; | ||
| 97 | $superflow_names_gui[2] = 'Sucat'; | ||
| 98 | $superflow_names_gui[3] = 'iSpectralAnalysis'; | ||
| 99 | $superflow_names_gui[4] = 'iVelAnalysis'; | ||
| 100 | $superflow_names_gui[5] = 'iTopMute'; | ||
| 101 | $superflow_names_gui[6] = 'iBottomMute'; | ||
| 102 | $superflow_names_gui[7] = 'fk'; | ||
| 103 | $superflow_names_gui[8] = 'Synseis'; | ||
| 104 | $superflow_names_gui[9] = 'iPick'; | ||
| 105 | $superflow_names_gui[10] = 'immodpg'; | ||
| 106 | $superflow_names_gui[11] = 'Project_Backup'; | ||
| 107 | $superflow_names_gui[12] = 'Project_Restore'; | ||
| 108 | $superflow_names_gui[13] = 'temp'; # make last | ||
| 109 | |||
| 110 | my $num_superflow_names_gui = scalar @superflow_names_gui; | ||
| 111 | |||
| 112 | my $developer_Tools_categories_h ={ | ||
| 113 | _Project => '.', | ||
| 114 | _Sseg2su => 'big_streams', | ||
| 115 | _SetProject => '.', | ||
| 116 | _Sucat => 'big_streams', | ||
| 117 | _iSpectralAnalysis => 'big_streams', | ||
| 118 | _iVelAnalysis => 'big_streams', | ||
| 119 | _iVA => 'big_streams', | ||
| 120 | _iTopMute => 'big_streams', | ||
| 121 | _iBottomMute => 'big_streams', | ||
| 122 | _Sudipfilt => 'big_streams', | ||
| 123 | _fk => 'big_streams', | ||
| 124 | _Synseis => 'big_streams', | ||
| 125 | _iPick => 'big_streams', | ||
| 126 | _immodpg => 'big_streams', | ||
| 127 | _ProjectBackup => 'big_streams', | ||
| 128 | _BackupProject => 'big_streams', | ||
| 129 | _ProjectRestore => 'big_streams', | ||
| 130 | _RestoreProject => 'big_streams', | ||
| 131 | _temp => 'temp', # make last | ||
| 132 | |||
| 133 | }; | ||
| 134 | |||
| 135 | =head2 sub _internal | ||
| 136 | |||
| 137 | =cut | ||
| 138 | |||
| 139 | sub _internal { | ||
| 140 | my ($external_name) = @_; | ||
| 141 | |||
| 142 | my $result; | ||
| 143 | |||
| 144 | if ( length $external_name ) { | ||
| 145 | |||
| 146 | # remove any underscores | ||
| 147 | $external_name =~ s/_/\ /; | ||
| 148 | |||
| 149 | # remove any spaces | ||
| 150 | $external_name =~ s/\ //; | ||
| 151 | |||
| 152 | # print("corrected external name = $external_name\n"); | ||
| 153 | |||
| 154 | # look for corresponding internal version of this shorter name | ||
| 155 | $external_name = '_' . $external_name; | ||
| 156 | my $internal_name = $superflow_internal_names_h->{$external_name}; | ||
| 157 | $result = $internal_name; | ||
| 158 | |||
| 159 | } | ||
| 160 | else { | ||
| 161 | print("program_name, _internal,missing value\n"); | ||
| 162 | $result = (); | ||
| 163 | |||
| 164 | } | ||
| 165 | |||
| 166 | return ($result); | ||
| 167 | } | ||
| 168 | |||
| 169 | =head2 sub set | ||
| 170 | |||
| 171 | =cut | ||
| 172 | |||
| 173 | sub set { | ||
| 174 | my ( $self, $name ) = @_; | ||
| 175 | |||
| 176 | if ( length $name ) { | ||
| 177 | |||
| 178 | $program_name->{_in} = $name; | ||
| 179 | |||
| 180 | } | ||
| 181 | else { | ||
| 182 | print("program_name, set, missing value\n"); | ||
| 183 | } | ||
| 184 | } | ||
| 185 | |||
| 186 | =head2 sub get | ||
| 187 | |||
| 188 | =cut | ||
| 189 | |||
| 190 | sub get { | ||
| 191 | my ($self) = @_; | ||
| 192 | |||
| 193 | my $result; | ||
| 194 | |||
| 195 | if ( length $program_name->{_in} ) { | ||
| 196 | |||
| 197 | my $out = _internal( $program_name->{_in} ); | ||
| 198 | |||
| 199 | $program_name->{_out} = $out; | ||
| 200 | $result = $out; | ||
| 201 | |||
| 202 | } | ||
| 203 | else { | ||
| 204 | print("program_name, get,missing value\n"); | ||
| 205 | $result = (); | ||
| 206 | |||
| 207 | } | ||
| 208 | } | ||
| 209 | |||
| 210 | =head2 sub category | ||
| 211 | |||
| 212 | =cut | ||
| 213 | |||
| 214 | sub category{ | ||
| 215 | my ($self) = @_; | ||
| 216 | |||
| 217 | my $result; | ||
| 218 | |||
| 219 | if ( length $program_name->{_in} ) { | ||
| 220 | |||
| 221 | my $external_name = $program_name->{_in}; | ||
| 222 | |||
| 223 | # remove any underscores | ||
| 224 | $external_name =~ s/_/\ /; | ||
| 225 | |||
| 226 | # remove any spaces | ||
| 227 | $external_name =~ s/\ //; | ||
| 228 | |||
| 229 | # look for corresponding internal version of this shorter name | ||
| 230 | my $key = '_' . $external_name; | ||
| 231 | my $category = $developer_Tools_categories_h->{$key}; | ||
| 232 | $result = $category; | ||
| 233 | # print("1. program_name, program_category $external_name(corrected) is $result\n"); | ||
| 234 | |||
| 235 | } | ||
| 236 | else { | ||
| 237 | print("program_name, get,missing value\n"); | ||
| 238 | $result = (); | ||
| 239 | |||
| 240 | } | ||
| 241 | |||
| 242 | return ($result); | ||
| 243 | } | ||
| 244 | 1; |