App-PLab

 view release on metacpan or  search on metacpan

bin/PrLenS  view on Meta::CPAN

   return $ret;
}


sub show_stats {
   my $w = $_[0];
   my ( $update_window) = $_[ 2];

   my ( $sd, $norepaint);
   if ( ! ( $sd = eval { $w->Statistics})) {

      return if $update_window;

      my ( @rect) = split ' ', $w->{ ini}->{ StatisticsWindowRect};
      $sd = Prima::Window->create(
         name => 'Statistics',
         rect => [ @rect],
         owner => $w,
         onClose => sub {
            $w->{ ini}->{ StatisticsWindowRect} = join( ' ', $_[ 0]->rect);
         },
         menuItems => [
            [ '~Copy' => sub { $sd-> StatText-> copy } ],
            [ '~Font' => [
               ['~Increase' , 'Ctrl+Plus' , '^+', sub { 
                  my $f = $sd-> StatText-> font;
                  $f-> size( $f-> size + 1);
                  $w->{ini}->{StatisticsWindowFont} = $f-> size;
               }],
               ['~Decrease' , 'Ctrl+Minus' , '^-', sub { 
                  my $f = $sd-> StatText-> font;
                  $f-> size( $f-> size - 1);
                  $w->{ini}->{StatisticsWindowFont} = $f-> size;
               }],
            ]],
         ],
      );

      my %font = ( pitch => fp::Fixed );
      $font{size} = $w->{ini}->{StatisticsWindowFont} if $w->{ini}->{StatisticsWindowFont};
      $sd->insert(
         'Prima::Edit' =>
         name => 'StatText',
         readOnly => 1,
         hScroll => 1,
         vScroll => 1,
         font => \%font,
         origin => [ 0,0],
         size => [ $sd-> size],
         growMode => gm::Client,
         text => $w-> generate_statistics_text(),
         blockType => bt::Vertical,
      );

      $norepaint = 1;
   }

   $sd->StatText->text( $w-> generate_statistics_text()) unless $norepaint;
}

sub file_backup
{
   my $w = $_[0];
   my ( $cpm, $file) = ( $w-> {cypherMask}, $w-> win_extname( $w-> {file}));
   $file =~ s/\d{$cpm}(\.pls)$/$1/;
   return if Prima::MsgBox::message( "Copy $file to $file.bak?", mb::OKCancel) != mb::OK;
   return if -f "$file.bak" and Prima::MsgBox::message( "$file.bak exists. Overwrite?", mb::OKCancel) != mb::OK;
   require File::Copy;
   return if File::Copy::copy( $file, "$file.bak");
   Prima::MsgBox::message( "Error:$!", mb::OK|mb::Error);
}

sub draw_processes {
   my $w = $_[0];
   $w-> done_draw_mode;
   $w->{ binfo}->{ drawMode} = 0;
   undef $w->{ binfo}->{ nearestBranch};
   undef $w->{ binfo}->{ prevActiveRect};
   $w-> reset_mark_state(( defined( $w-> {markState}) && ( $w-> {markState} == 16) ? undef : 16))
      if defined $w-> {file};
   $w-> reset_mark_state( $w, undef) unless defined $w-> {file};
}

sub mark_cells
{
   my $w = $_[0]; 
   $w-> reset_mark_state( 1) if defined $w-> {file};
   $w-> reset_mark_state( undef) unless defined $w-> {file};
}

sub mark_processes
{
   my $w = $_[0];
   $w-> reset_mark_state( 0) if defined $w-> {file};
   $w-> reset_mark_state( undef) unless defined $w-> {file};
}


sub win_newframe
{
   my $w = $_[0];
   $w-> SUPER::win_newframe;
   for ( @{$w->{layers}}) {
      my $c = ucfirst $_;
      $w-> {$_} = [];
      $w-> {"ex$c"} = [];
      $w-> {"prevex$c"} = [];
      $w-> {"n$c"} = $w-> {"total$c"} = 0;
   }
   $w-> {branches} = [];
   $w-> modified(0);
   $w-> reset_mark_state; 
   $w-> {mirrorImage} = undef;
   $w-> {recWindow}-> RestoreBtn-> enabled( 0) if $w-> {recWindow};

   return unless defined $w-> {file};

   $w-> win_extwarn if defined $w-> {ini}-> {path} &&
      defined $w-> {oldPath} && $w-> {oldPath} ne $w-> {ini}-> {path};
   $w-> {oldPath} = $w-> {ini}-> {path};
   $w-> preprocess;

bin/PrLenS  view on Meta::CPAN

      $ssl-> {$_}  = 255 if $ssl-> {$_} > 255;
   }
   my $pi = $nbpages-> pageIndex;
   $nbpages-> pageIndex( 4);
   $nbpages-> StretchPreview-> enabled( defined($w-> {file})); 
   $nbpages-> pageIndex( $pi);
}

sub opt_proppop
{
   my ( $w, $dlg, $nb, $nbpages, $mr) = @_;
   $w-> SUPER::opt_proppop( $dlg, $nb, $nbpages, $mr);
   my $ssl = $nbpages-> StretchSlider;
   if ( $mr) {
      $w->{ini}->{nLines} = $nbpages-> nLines-> value;
      $w->{ini}->{PointSize} = $nbpages-> PointSize-> value;
      my $ad = $w->{ini}->{active_datasets};
      $w->{ini}->{active_datasets} = $nbpages-> Datasets-> value;
      if ( $ad != $w->{ini}->{active_datasets}) {
         $w-> modified(1) if defined $w-> {file};
         $w-> reset_mark_state( 0) if defined $w-> {markState} && $w-> {markState} >= $w->{ini}->{active_datasets};
         $w-> {layers} = [ map { $w-> {ini}-> {"dataset_${_}_name"}} 0 .. $w->{ini}->{active_datasets} - 1];
         for ( @{$w-> {layers}}) {
            my $u = ucfirst $_;
            $w->{$_} ||= [];
            $w->{"ex$u"} ||= [];
            $w->{"prevex$u"} ||= [];
            $w->{"$_$u"} ||= 0 for qw(n total);
         }
      }
      $w-> {ini}-> {ShowExtras} = $nbpages-> ShowExtras-> checked;
      $w-> {ini}-> {ShowPrevExtras} = $nbpages-> ShowPrevExtras-> checked;
      my ( $a, $b) = ($ssl-> {min},$ssl-> {max});
      if ( ($w->{ini}->{SpectrumMin} != $a) ||
           ($w->{ini}->{SpectrumMax} != $b)) {
         $w->{ini}->{SpectrumMin} = $a;
         $w->{ini}->{SpectrumMax} = $b;
         $w-> preprocess;
      }
      $w-> {ini}-> {visible_datasets} = unpack('I*', $nbpages-> Hyperset-> vector);
      $w-> IV-> repaint;
   } else {
      if ( ($w->{ini}->{SpectrumMin} != $ssl-> {saveMin}) ||
           ($w->{ini}->{SpectrumMax} != $ssl-> {saveMax})) {
         $w->{ini}->{SpectrumMin} = $ssl-> {saveMin};
         $w->{ini}->{SpectrumMax} = $ssl-> {saveMax};
         $w-> preprocess;
         $w-> IV-> repaint;
      }
   }
}

# OPT_END

package Run;


my $wfil = App::PLab::ImageAppWindow::winmenu_file();
splice( @{$$wfil[1]}, -1, 0,
   [ '-FileStats'  => "~Statistics"   => q(show_stats)],
   [ '-FileBackup' => "~Backup results" => q(file_backup)],
   [],
   
);

my $wedt = App::PLab::ImageAppWindow::winmenu_edit();
splice( @{$$wedt[2]}, 0, 0,
   [ EditAutoCrispening => "~Auto crispening" => q(crispen_state_changed) ],
   [ EditAutoStretching => "Auto stretching"  => q(stretching_state_changed) ],
   [ EditRemoveAll => "Remove all frame data"  => q(remove_frame_data) ],
   [],
   [ EditRecSetup => "Recognition ~setup"  => q(win_showrec), ],   
   [ -EditProcess => "~Automatic recognition" => q(process)],
   [ -EditProcessSeries => "Automatic ~series recognition" => q(process_series)],
   [],
);

my $w = LenWindow-> create(
   menuItems => [
      $wfil,
      $wedt,
      App::PLab::ImageAppWindow::winmenu_view(),
      [],["~Help" => [
         [ HelpAbout =>  "~About" => sub {Prima::MsgBox::message("PLab application series, Process Lengths, version $App::PLab::VERSION", mb::OK|mb::Information)}],
         [ HelpPlabApps => "~PLab Apps" => sub { $_[0]-> open_help(); }],
      ]],
   ],
);
$w-> IV-> delegations(['Paint', 'MouseClick']);
$w-> sb_text("Started OK");
$w-> visible(1);
$w-> select;

$w-> win_extwarn;

$w-> win_loadfile( $ARGV[0]) if @ARGV;

run Prima;



( run in 0.955 second using v1.01-cache-2.11-cpan-39bf76dae61 )