File: PRCConvolve55.m

package info (click to toggle)
price.app 1.3.0-3
  • links: PTS
  • area: main
  • in suites: buster
  • size: 1,828 kB
  • sloc: objc: 8,414; ansic: 192; makefile: 18
file content (257 lines) | stat: -rw-r--r-- 6,664 bytes parent folder | download | duplicates (3)
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
//
//  PRCConvolve55.m
//  PRICE
//  Convolve 5x5 Controller
//
//  Created by Riccardo Mottola on Tue Jan 21 2003.
//  Copyright (c) 2003-2014 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 "PRCConvolve55.h"
#import "MyDocument.h"
#import "PRConvolve55.h"

@implementation PRCConvolve55

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

- (IBAction)showFilter:(id)sender
{
    [super showFilter:sender];

    if (!filterWindow)
        [NSBundle loadNibNamed:@"Convolve55" owner:self];
    [filterWindow makeKeyAndOrderFront:nil];
    convMatrix[0][0] = [matField11 intValue];
    convMatrix[0][1] = [matField12 intValue];
    convMatrix[0][2] = [matField13 intValue];
    convMatrix[0][3] = [matField14 intValue];
    convMatrix[0][4] = [matField15 intValue];
    convMatrix[1][0] = [matField21 intValue];
    convMatrix[1][1] = [matField22 intValue];
    convMatrix[1][2] = [matField23 intValue];
    convMatrix[1][3] = [matField24 intValue];
    convMatrix[1][4] = [matField25 intValue];
    convMatrix[2][0] = [matField31 intValue];
    convMatrix[2][1] = [matField32 intValue];
    convMatrix[2][2] = [matField33 intValue];
    convMatrix[2][3] = [matField34 intValue];
    convMatrix[2][4] = [matField35 intValue];
    convMatrix[3][0] = [matField41 intValue];
    convMatrix[3][1] = [matField42 intValue];
    convMatrix[3][2] = [matField43 intValue];
    convMatrix[3][3] = [matField44 intValue];
    convMatrix[3][4] = [matField45 intValue];
    convMatrix[4][0] = [matField51 intValue];
    convMatrix[4][1] = [matField52 intValue];
    convMatrix[4][2] = [matField53 intValue];
    convMatrix[4][3] = [matField54 intValue];
    convMatrix[4][4] = [matField55 intValue];
    if ([autoScaleCheck state] == NSOnState)
    {
        [scaleField setEnabled:NO];
        [offsetField setEnabled:NO];
        autoScale = YES;
    } else
    {
        [scaleField setEnabled:YES];
        [offsetField setEnabled:YES];
        autoScale = NO;
    }
    offset = [offsetField intValue];
    scale = [scaleField floatValue];

    [self parametersChanged:self];
}

- (IBAction)convMatrix11:(id)sender
{
    convMatrix[0][0] = [sender intValue];
  [self parametersChanged:self];
}
- (IBAction)convMatrix12:(id)sender
{
    convMatrix[0][1] = [sender intValue];
  [self parametersChanged:self];
}
- (IBAction)convMatrix13:(id)sender
{
    convMatrix[0][2] = [sender intValue];
  [self parametersChanged:self];
}
- (IBAction)convMatrix14:(id)sender
{
    convMatrix[0][3] = [sender intValue];
  [self parametersChanged:self];
}
- (IBAction)convMatrix15:(id)sender
{
    convMatrix[0][4] = [sender intValue];
  [self parametersChanged:self];
}
- (IBAction)convMatrix21:(id)sender
{
    convMatrix[1][0] = [sender intValue];
  [self parametersChanged:self];
}
- (IBAction)convMatrix22:(id)sender
{
    convMatrix[1][1] = [sender intValue];
  [self parametersChanged:self];
}
- (IBAction)convMatrix23:(id)sender
{
    convMatrix[1][2] = [sender intValue];
  [self parametersChanged:self];
}
- (IBAction)convMatrix24:(id)sender
{
    convMatrix[1][3] = [sender intValue];
  [self parametersChanged:self];
}
- (IBAction)convMatrix25:(id)sender
{
    convMatrix[1][4] = [sender intValue];
  [self parametersChanged:self];
}
- (IBAction)convMatrix31:(id)sender
{
    convMatrix[2][0] = [sender intValue];
  [self parametersChanged:self];
}
- (IBAction)convMatrix32:(id)sender
{
    convMatrix[2][1] = [sender intValue];
  [self parametersChanged:self];
}
- (IBAction)convMatrix33:(id)sender
{
    convMatrix[2][2] = [sender intValue];
  [self parametersChanged:self];
}
- (IBAction)convMatrix34:(id)sender
{
    convMatrix[2][3] = [sender intValue];
  [self parametersChanged:self];
}
- (IBAction)convMatrix35:(id)sender
{
    convMatrix[2][4] = [sender intValue];
  [self parametersChanged:self];
}
- (IBAction)convMatrix41:(id)sender
{
    convMatrix[3][0] = [sender intValue];
  [self parametersChanged:self];
}
- (IBAction)convMatrix42:(id)sender
{
    convMatrix[3][1] = [sender intValue];
  [self parametersChanged:self];
}
- (IBAction)convMatrix43:(id)sender
{
    convMatrix[3][2] = [sender intValue];
  [self parametersChanged:self];
}
- (IBAction)convMatrix44:(id)sender
{
    convMatrix[3][3] = [sender intValue];
  [self parametersChanged:self];
}
- (IBAction)convMatrix45:(id)sender
{
    convMatrix[3][4] = [sender intValue];
  [self parametersChanged:self];
}
- (IBAction)convMatrix51:(id)sender
{
    convMatrix[4][0] = [sender intValue];
  [self parametersChanged:self];
}
- (IBAction)convMatrix52:(id)sender
{
    convMatrix[4][1] = [sender intValue];
  [self parametersChanged:self];
}
- (IBAction)convMatrix53:(id)sender
{
    convMatrix[4][2] = [sender intValue];
  [self parametersChanged:self];
}
- (IBAction)convMatrix54:(id)sender
{
    convMatrix[4][3] = [sender intValue];
  [self parametersChanged:self];
}
- (IBAction)convMatrix55:(id)sender
{
    convMatrix[4][4] = [sender intValue];
  [self parametersChanged:self];
}

- (IBAction)autoRange:(id)sender
{
    autoScale = !autoScale;
    if (autoScale)
    {
        [scaleField setEnabled:NO];
        [offsetField setEnabled:NO];
    } else
    {
        [scaleField setEnabled:YES];
        [offsetField setEnabled:YES];
    }
  [self parametersChanged:self];
}

- (IBAction)scaleFactor:(id)sender
{
    scale = [sender floatValue];
  [self parametersChanged:self];
}

- (IBAction)offsetFactor:(id)sender
{
    offset = [sender intValue];
  [self parametersChanged:self];
}

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

- (NSArray *)encodeParameters
{
    NSArray        *parameters;
    NSMutableArray *convArray;
    int            i, j;
    
    /* encode the parameters */
    convArray = [NSMutableArray arrayWithCapacity:25];
    for (i = 0; i < 5; i++)
        for (j = 0; j < 5; j++)
            [convArray addObject: [NSNumber numberWithInt: convMatrix[i][j]]];

    
    parameters = [NSArray arrayWithObjects:
        convArray,
        [NSNumber numberWithInt: offset],
        [NSNumber numberWithFloat: scale],
        [NSNumber numberWithBool: autoScale],
        nil];

    return parameters;
}

@end