App-PLab

 view release on metacpan or  search on metacpan

bin/MorphometryI  view on Meta::CPAN

      EditValidate       => [ km::Ctrl|kb::Enter , "Validate contours"], 
      EditRecSetup       => [ kb::NoKey  , "Display recognition setup dialog"],
      EditApplyContours  => [ km::Alt|kb::Enter , "Apply contours to document"],
      EditHack           => [ kb::NoKey         , "Outline convex hull of current drawing"],
      HelpAbout        => [ kb::NoKey,      'Standard about box'],
      HelpPlabApps     => [ kb::NoKey,      'Online PlabApps overview'],
      HelpContents     => [ kb::NoKey,      'Online Morphometry I overview'],
      LineWidthIncrement => [ '@+',   'Increment line width for current object'],
      LineWidthDecrement => [ '@-',   'Decrement line width for current object'],
   };
};

sub opt_changecalib
{
   my $w = $_[0];

   Prima::MsgBox::message( "No series to convert"), return if ( !defined $w-> {nextFile} && !defined $w-> {prevFile});

   my $num = $w-> {cypherMask};
   my ( $fn, $tn) = $w-> win_getseriesrange;

   return if Prima::MsgBox::message( "This will recalculate series ".
      $w-> {fileBeg}.('X' x $num).$w-> {fileEnd}." [$fn-$tn] . Proceed?",
      mb::OKCancel|mb::Information) != mb::OK;

   my $fnsave = $w->{fileNum};
   my $f;
   my $ok = 1;

   $w->{silence} = 1;
   $w->{packetAborted} = 0;

   my $userAborted = 0;

   my $statwin = $w-> insert( Dialog =>
      centered    => 1,
      text        => 'Processing',
      size        => [ 300, 60],
      onKeyDown   => sub {
         my ( $self, $code, $key, $mod) = @_;
         if ( $key == kb::Esc &&
            ( Prima::MsgBox::message("Abort process?", mb::OKCancel|mb::Warning) == mb::OK)) {
            $userAborted = 1;
            $_[0]-> text('Cancelling');
         }
      },
      onClose     => sub {
         $_[0]-> clear_event;
         return if Prima::MsgBox::message("Abort process?", mb::OKCancel|mb::Warning) != mb::OK;
         $userAborted = 1;
         $_[0]-> text('Cancelling');
      },
   );

   my $g = $statwin-> insert( Gauge =>
      origin => [ 5, 5],
      size   => [ $statwin-> width - 10, $statwin-> height - 10],
      min    => $fn,
      max    => $tn,
      value  => $fn,
      font   => {height => $statwin-> height - 16},
   );

   $statwin-> execute_shared;

   for my $i ( $fn..$tn) {
       $f = sprintf( "%s%0${num}d%s",$w->{fileBeg}, $i, $w-> {fileEnd});
       $::application-> yield;
       $ok = 0, last, if $userAborted;
       if ( !$w-> win_loadfile( $f) || $w->{packetAborted}) {
          Prima::MsgBox::message("Calibration aborted - error processing file $f", mb::OK|mb::Error);
          $ok = 0;
          last;
       }
       $w-> modified(1);

       $g-> value( $i);
   }

   $w->{silence} = 0;
   $statwin-> destroy;
   if ( $ok) {
      Prima::MsgBox::message("Queue processed", mb::OK|mb::Information);
      $w->win_loadfile( sprintf( "%s%0${num}d%s",$w->{fileBeg}, $fnsave, $w-> {fileEnd}));
   }
}

sub opt_calcdlg
{
   my $w = $_[0];
   my $d = $w->{CalcOptDialog};
   $w-> iv_cancelmode( $w-> IV);
   unless ( $d) {
      $d = Prima::Dialog-> create(
         size     => [ 320, 200],
         text     => 'Select items to calculate',
         owner    => $w,
         centered => 1,
      );
      $d-> insert( CheckList => 
         origin => [ 10, 76],
         size   => [ 300, 110],
         name   => 'CheckList',
         vector => $w-> {ini}->{CalcOptions},
         vScroll=> 1,
         items  => [
            'List of files',
            'Morphometric parameters',
            'Brightness histogram',
            'Subtract backround from histogram',
         ],
      );
      $w-> dlg_okcancel( $d);
      $w->{CalcOptDialog} = $d;
   }
   return if $d-> execute != mb::OK;
   return $w-> {ini}-> {CalcOptions} = $d-> CheckList-> vector;
}

sub opt_statistics
{

bin/MorphometryI  view on Meta::CPAN

                $c .= '   N/A';
             }   
          }   
          $c .= ' | ';
          $c .= sprintf("%10.5g"x4, $sum[$i], $ave[$i], $sd[$i], $sem[$i]);
          $c .= " |\n";
       }
       $texts .= $c;
       $c =~ s/\|//g;
       $meta1 .= "\n" . $c;
       $texts .= "$xdivline\n";
   }


   sub esummary
   {
      my ( $dlg, $textRef, $w) = @_;
      my $dir = eval { Cwd::abs_path( $w-> {ini}-> {StatPath})};
      $dir = '.' if $@;
      $dir = '' unless -d $dir;
      my $d = Prima::SaveDialog-> create(
         owner   => $dlg,
         filter  => [
            ['Text files' => '*.txt'],
            ['All files' => '*']
         ],
         directory => $dir,
      );
      my $res = $d-> execute;
      if ( $res) {
         open F, '>'.$d-> fileName;
         print F $$textRef;
         close F;
      };
      $w-> {ini}-> {StatPath} = $d-> directory;
      $d-> destroy;
   }

   my $dlg = Prima::Window-> create(
      size => [ 520, 430],
      text => 'Statistic results',
      widgetClass => wc::Dialog,
      centered => 1,
      menuItems   => [
         [ '~Export' => [
            ["~Summary..." => "F2" => kb::F2 => sub { esummary( $_[0], \$meta2, $w)} ],
            ["~Experiment data..." => "Ctrl+F2" => km::Ctrl|kb::F2 => sub { esummary( $_[0], \$meta1, $w)} ],
         ]],
         [ 'Copy' => "" => kb::NoKey => sub { $::application-> Clipboard-> store( 'Text', $texts);}],
      ],
   );

   $dlg-> insert( Edit =>
      origin   => [ 1, 1],
      size     => [ $dlg-> width - 2, $dlg-> height - 2],
      text     => $texts,
      growMode => gm::Client,
      hScroll  => 1,
      vScroll  => 1,
      readOnly => 1,
      font     => { pitch => fp::Fixed},
      wordWrap => 0,
      syntaxHilite => 1,
      hiliteNumbers     => undef,
      hiliteQStrings    => undef,
      hiliteQQStrings   => undef,
      hiliteIDs         => undef,
      hiliteChars       => undef,
      hiliteREs         => [ '(N\/A)', cl::Red,
          '(([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?\*)', cl::Red],
   );

   $dlg-> select;
}


sub opt_propcreate
{
   my ( $w, $dlg, $nb, $nbpages) = @_;
   $w-> SUPER::opt_propcreate( $dlg, $nb, $nbpages);
   $nb-> tabs( @{$nb-> tabs}, 'Calculations', 'Frame');
   $nb-> insert_to_page( $nb-> pageCount - 2,
      [ Label =>
        text     => 'By default, only the area, the perimeter, the formfactor and centroid locations are calculated,though the program is perfectly capable of calculating all other parameters.  The reason for disabling the rest is that it normally ta...
        wordWrap => 1,
        designScale => [ $nbpages-> font-> width, $nbpages-> font-> height],
        valignment => ta::Top,
        name       => 'TopText',
    ],[ CheckBox =>
        origin => [ 5, 185],
        name => 'CalcBrightness',
        size => [ 300, 27],
        text => 'Calculate ~brightness',
        onCheck => sub {
           $nbpages-> EqualBrightness-> set(
              checked => ($_[0]-> checked ? $nbpages-> EqualBrightness-> checked : 0),
              enabled => $_[0]-> checked,
           );
        },   
    ],[ CheckBox =>
        origin => [ 5, 155],
        name => 'EqualBrightness',
        size => [ 300, 27],
        text => 'E~qualize brightness',
    ],[ CheckBox =>
        origin => [ 5, 125],
        name => 'CalcConvex',
        size => [ 248, 27],
        text => 'Convex ~hull derived parameters',
    ],[ Label =>
        origin => [ 5, 100],
        height => 20,
        name => 'SigRot',
        text => '~Number of rotations',
    ],[ SpinEdit =>
        origin => [ 5, 80],
        name => 'NumberOfRotations',
        size => [ 100, 20],
        min  => 1,
        max  => 256,
    ],[ CheckBox =>
        origin => [ 5, 50],
        name => 'CalcHoles',
        size => [ 248, 27],
        text => '~Process index / domain',
        onCheck => sub {
           $nbpages-> CalcConvex-> set(
              checked => ($_[0]-> checked ? 1 : $nbpages-> CalcConvex-> checked),
              enabled => !$_[0]-> checked,
           );
        },
    ],[ Label =>
        origin => [ 5, 25],
        name => 'SigPce',
        height => 20,
        text => 'Significance level for holes, %',
    ],[ SpinEdit =>
        origin => [ 5, 5],
        name => 'HolesPercent',
        size => [ 100, 20],
    ],);
   $nbpages-> TopText-> rect( 5, $nbpages-> EqualBrightness-> top, $nbpages-> width - 5, $nbpages-> height - 5);
   $nbpages-> SigPce-> focusLink( $nbpages-> HolesPercent);
   $nbpages-> SigRot-> focusLink( $nbpages-> NumberOfRotations);
   
   my @fcnt = $nb-> insert_to_page( $nb-> pageCount - 1,



( run in 0.918 second using v1.01-cache-2.11-cpan-97f6503c9c8 )