File: PRCMedian.m

package info (click to toggle)
price.app 1.3.0-1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 1,800 kB
  • ctags: 44
  • sloc: objc: 8,414; ansic: 192; makefile: 40
file content (90 lines) | stat: -rw-r--r-- 2,193 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//
//  PRCMedian.m
//  PRICE
//
//  Created by Riccardo Mottola on Thu Mar 25 2004.
//  Copyright (c) 2004-2010 Carduus. All rights reserved.
//
// 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.
// 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.


#import "PRCMedian.h"
#import "PRMedian.h"
#import "MyDocument.h"


@implementation PRCMedian

- (id)init
{
    if ((self = [super init]))
    {
        filter = [[PRMedian alloc] init];
    }
    return self;
}


- (IBAction)showFilter:(id)sender
{
    [super showFilter:sender];
    
    if (!medianWindow)
        [NSBundle loadNibNamed:@"Median" owner:self];
    [medianWindow makeKeyAndOrderFront:nil];

    [self parametersChanged:self];
}

- (NSArray *)encodeParameters
{
    enum medianForms theForm;
    BOOL             isSeparable;
    int              theSize;
    NSArray          *parameters;
    
    if ([separableCheck state] == NSOnState)
        isSeparable = YES;
    else
        isSeparable = NO;
    
    switch ([[formSelect selectedItem] tag])
    {
        case 1: theForm = HORIZONTAL_F;
            break;
        case 2: theForm = VERTICAL_F;
            break;
        case 3: theForm = CROSS_F;
            break;
        case 4: theForm = BOX_F;
            break;
        default: NSLog(@"Unrecognized form selected");
            theForm = BOX_F;
    }
    
    theSize = [sizeSlider intValue];
    
    parameters = [NSArray arrayWithObjects:
        [NSNumber numberWithInt: theForm],
        [NSNumber numberWithInt: theSize],
        [NSNumber numberWithBool: isSeparable],
        nil];

    return parameters;
}


- (IBAction)changeSize:(id)sender
{
    [sizeField setIntValue :[sizeSlider intValue] * 2 + 1];
    [self parametersChanged:sender];
}

- (void)closeFilterPanel
{
    [medianWindow performClose:nil];
}


@end