-
Notifications
You must be signed in to change notification settings - Fork 0
/
FeatureViewerAppDelegate.m
105 lines (90 loc) · 3.18 KB
/
FeatureViewerAppDelegate.m
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
//
// FeatureViewerAppDelegate.m
// FeatureViewer
//
// Created by Grogee on 9/24/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#import "FeatureViewerAppDelegate.h"
@implementation FeatureViewerAppDelegate
@synthesize window;
@synthesize controller;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
[NSBundle loadNibNamed: @"RasterWindow" owner: controller];
}
- (void)application:(NSApplication*)theApplication openFiles:(NSArray*)filenames
{
[self application: theApplication openFile:[filenames objectAtIndex:0]];
}
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
{
//check the extension of the file to determine how to open it
if( [[filename pathExtension] isEqualToString:@"bin"] )
{
//open waveforms.bin file
[controller openWaveformsFile:filename];
return YES;
}
else if( [[filename pathExtension] isEqualToString:@"fd"] )
{
//open feature file
[controller openFeatureFile:filename];
return YES;
}
else if( [[filename pathExtension] isEqualToString:@"fv"] )
{
[controller openClusterFile:filename];
return YES;
}
else if( [[filename pathExtension] isEqualToString:@"cut"] )
{
[controller openClusterFile:filename];
return YES;
}
else if( [[filename componentsSeparatedByString:@"."] containsObject:@"clu"] )
{
[controller openClusterFile:filename];
return YES;
}
else if( [[filename componentsSeparatedByString:@"."] containsObject:@"overlap"] )
{
[controller openClusterFile:filename];
return YES;
}
else if( [[filename componentsSeparatedByString:@"."] containsObject:@"fet"] )
{
//NSLog(@"filename: %@",filename);
[controller openFeatureFile:filename];
return YES;
}
else{
//File not recognized, so return FALSE to indicate we could not open the file
return NO;
}
}
-(void)applicationWillTerminate:(NSNotification *)notification
{
//ask featureview controller to archive the clusters first
[controller archiveClusters];
}
-(id)init
{
//set up user defaults
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:0], @"autoScaleAxes",
[NSNumber numberWithBool: NO], @"showFeatureAxesLabels",
[NSNumber numberWithBool: NO],@"showFeatureAxesFrame",
[NSNumber numberWithBool: NO], @"showWaveformAxesLabels",
[NSNumber numberWithBool: NO], @"showWaveformsMean",
[NSNumber numberWithBool: NO], @"showWaveformsStd",
[NSNumber numberWithBool: YES],@"stimInfo",
[NSNumber numberWithBool: YES], @"autoLoadFeatures",
[NSNumber numberWithBool: YES], @"autoLoadWaveforms",
[NSNumber numberWithInt: 5000], @"maxWaveformsDrawn",nil];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults registerDefaults:dict];
[super init];
return self;
}
@end