
/* Generated by Interface Builder */

#import	<stdio.h>
#import	<stdlib.h>
#import	<string.h>
#import	<appkit/Matrix.h>
#import	<appkit/Application.h>
#import	"Cntrl.h"
#import	"HipsImage.h"
#import	"Mask.h"

@implementation Cntrl

- open:sender
{
  [image free];
  image = [HipsImage open: self];
  [image display];
  return self;
} 

- save:sender
{
  [[image save: self] display];
  return self;
} 

- saveAs:sender
{
  [[image saveAs: self] display];
  return self;
} 

- saveToTIFF:sender
{
  [[image saveToTIFF: self] display];
  return self;
} 

- convolve:sender
{
  
  while(![mask getsize]) {
    NXRunAlertPanel("Mask","You must open a mask",NULL,NULL,NULL);
    [mask open:self];
  }
  while(![image getrows] || ![image getcols]) {
    NXRunAlertPanel("Image","You must open an image",NULL,NULL,NULL);
    image = [HipsImage open:self];
  }
  [[image convolve: mask] display];
  return self;
}

- invert:sender
{

  while(![image getrows] || ![image getcols]) {
    NXRunAlertPanel("Image","You must open an image",NULL,NULL,NULL);
    image = [HipsImage open:self];
  }
  [[image invert] display];
  return self;
}

- threshold:sender
{
  while(![image getrows] || ![image getcols]) {
    NXRunAlertPanel("Image","You must open an image",NULL,NULL,NULL);
    image = [HipsImage open:self];
  }
  [[image threshold:[tvals intValueAt:0] :[tvals intValueAt:1]] display];
  return self;
}

- undo:sender
{
  [[image undo] display];
  return self;
}

- revert:sender
{
  [[image revert] display];
  return self;
}

@end
