-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathDTStructureBreakOutPatch.m
101 lines (77 loc) · 2.26 KB
/
DTStructureBreakOutPatch.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
#import "DTStructureBreakOutPatch.h"
#import "DTStructureBreakOutPatchUI.h"
#import <objc/runtime.h>
@implementation DTStructureBreakOutPatch
+(BOOL)isSafe
{
return YES;
}
+(BOOL)allowsSubpatchesWithIdentifier:(id)identifier
{
return NO;
}
+ (Class)inspectorClassWithIdentifier:(id)fp8
{
return [DTStructureBreakOutPatchUI class];
}
-(id)initWithIdentifier:(id)identifier
{
if(self = [super initWithIdentifier:identifier])
{
[[self userInfo] setObject:@"Structure Breakout" forKey:@"name"];
}
return self;
}
-(BOOL)execute:(QCOpenGLContext*)context time:(double)time arguments:(NSDictionary*)arguments
{
GFList *gfl = [[inputStructure structureValue] _list];
// try to find a value for each output port as best we can
for(QCVirtualPort *p in [self customOutputPorts])
{
id o = [gfl objectForKey:[p key]];
if(!o)
o = [gfl objectAtIndex:[[p key] integerValue]];
[p setRawValue:o];
}
return YES;
}
-(void)configureFromInput
{
// there's no way we'll have valid structure data if we're not rendering, so prevent the user from obliterating everything.
if(![self isRendering])
return;
GFList *gfl = [[inputStructure structureValue] _list];
NSUInteger i;
for(QCPort *p in [self customOutputPorts])
[self deleteOutputPortForKey:[p key]];
for(i=0;i<[gfl count];++i)
{
NSString *key = [gfl keyAtIndex:i];
if(!key)
key = [NSString stringWithFormat:@"%d",i];
if(![self portForKey:key])
[self createOutputWithPortClass:[QCVirtualPort class] forKey:key attributes:nil];
}
}
- (NSDictionary*)state
{
NSUInteger ports = [[self customOutputPorts] count];
NSMutableDictionary *stateDict = [[NSMutableDictionary alloc] initWithCapacity:2];
[stateDict addEntriesFromDictionary:[super state]];
NSMutableArray *a = [[NSMutableArray alloc] initWithCapacity:ports];
for(QCPort *p in [self customOutputPorts])
[a addObject:[p key]];
[stateDict setObject:a forKey:@"outputPortNames"];
[a release];
[stateDict autorelease];
return stateDict;
}
- (BOOL)setState:(NSDictionary*)state
{
for(QCPort *p in [self customOutputPorts])
[self deleteOutputPortForKey:[p key]];
for(NSString *portKey in [state objectForKey:@"outputPortNames"])
[self createOutputWithPortClass:[QCVirtualPort class] forKey:portKey attributes:nil];
return [super setState:state];
}
@end