1// 2// PRCMedian.m 3// PRICE 4// 5// Created by Riccardo Mottola on Thu Mar 25 2004. 6// Copyright (c) 2004-2010 Carduus. All rights reserved. 7// 8// This application is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 9// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 10 11 12#import "PRCMedian.h" 13#import "PRMedian.h" 14#import "MyDocument.h" 15 16 17@implementation PRCMedian 18 19- (id)init 20{ 21 if ((self = [super init])) 22 { 23 filter = [[PRMedian alloc] init]; 24 } 25 return self; 26} 27 28 29- (IBAction)showFilter:(id)sender 30{ 31 [super showFilter:sender]; 32 33 if (!medianWindow) 34 [NSBundle loadNibNamed:@"Median" owner:self]; 35 [medianWindow makeKeyAndOrderFront:nil]; 36 37 [self parametersChanged:self]; 38} 39 40- (NSArray *)encodeParameters 41{ 42 enum medianForms theForm; 43 BOOL isSeparable; 44 int theSize; 45 NSArray *parameters; 46 47 if ([separableCheck state] == NSOnState) 48 isSeparable = YES; 49 else 50 isSeparable = NO; 51 52 switch ([[formSelect selectedItem] tag]) 53 { 54 case 1: theForm = HORIZONTAL_F; 55 break; 56 case 2: theForm = VERTICAL_F; 57 break; 58 case 3: theForm = CROSS_F; 59 break; 60 case 4: theForm = BOX_F; 61 break; 62 default: NSLog(@"Unrecognized form selected"); 63 theForm = BOX_F; 64 } 65 66 theSize = [sizeSlider intValue]; 67 68 parameters = [NSArray arrayWithObjects: 69 [NSNumber numberWithInt: theForm], 70 [NSNumber numberWithInt: theSize], 71 [NSNumber numberWithBool: isSeparable], 72 nil]; 73 74 return parameters; 75} 76 77 78- (IBAction)changeSize:(id)sender 79{ 80 [sizeField setIntValue :[sizeSlider intValue] * 2 + 1]; 81 [self parametersChanged:sender]; 82} 83 84- (void)closeFilterPanel 85{ 86 [medianWindow performClose:nil]; 87} 88 89 90@end 91