Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 102 lines (77 sloc) 2.319 kB
ba4545f @jlstrecker Initial commit
jlstrecker authored
1 #import "DTStructureBreakOutPatch.h"
2 #import "DTStructureBreakOutPatchUI.h"
3
4 #import <objc/runtime.h>
5
6 @implementation DTStructureBreakOutPatch
7
8 +(BOOL)isSafe
9 {
10 return YES;
11 }
12
13 +(BOOL)allowsSubpatchesWithIdentifier:(id)identifier
14 {
15 return NO;
16 }
17
18 + (Class)inspectorClassWithIdentifier:(id)fp8
19 {
20 return [DTStructureBreakOutPatchUI class];
21 }
22
23
24 -(id)initWithIdentifier:(id)identifier
25 {
26 if(self = [super initWithIdentifier:identifier])
27 {
28 [[self userInfo] setObject:@"Structure Breakout" forKey:@"name"];
29 }
30 return self;
31 }
32
33 -(BOOL)execute:(QCOpenGLContext*)context time:(double)time arguments:(NSDictionary*)arguments
34 {
35 GFList *gfl = [[inputStructure structureValue] _list];
36
37 // try to find a value for each output port as best we can
38 for(QCVirtualPort *p in [self customOutputPorts])
39 {
40 id o = [gfl objectForKey:[p key]];
41 if(!o)
42 o = [gfl objectAtIndex:[[p key] integerValue]];
43
44 [p setRawValue:o];
45 }
46
47 return YES;
48 }
49
50 -(void)configureFromInput
51 {
52 // there's no way we'll have valid structure data if we're not rendering, so prevent the user from obliterating everything.
53 if(![self isRendering])
54 return;
55
56
57 GFList *gfl = [[inputStructure structureValue] _list];
58 NSUInteger i;
59
60 for(QCPort *p in [self customOutputPorts])
61 [self deleteOutputPortForKey:[p key]];
62
63 for(i=0;i<[gfl count];++i)
64 {
65 NSString *key = [gfl keyAtIndex:i];
66 if(!key)
67 key = [NSString stringWithFormat:@"%d",i];
68
69 if(![self portForKey:key])
70 [self createOutputWithPortClass:[QCVirtualPort class] forKey:key attributes:nil];
71 }
72 }
73
74
75 - (NSDictionary*)state
76 {
77 NSUInteger ports = [[self customOutputPorts] count];
78 NSMutableDictionary *stateDict = [[NSMutableDictionary alloc] initWithCapacity:2];
79 [stateDict addEntriesFromDictionary:[super state]];
80
81 NSMutableArray *a = [[NSMutableArray alloc] initWithCapacity:ports];
82 for(QCPort *p in [self customOutputPorts])
83 [a addObject:[p key]];
84 [stateDict setObject:a forKey:@"outputPortNames"];
85 [a release];
86
87 [stateDict autorelease];
88 return stateDict;
89 }
90 - (BOOL)setState:(NSDictionary*)state
91 {
92 for(QCPort *p in [self customOutputPorts])
93 [self deleteOutputPortForKey:[p key]];
94
95 for(NSString *portKey in [state objectForKey:@"outputPortNames"])
96 [self createOutputWithPortClass:[QCVirtualPort class] forKey:portKey attributes:nil];
97
98 return [super setState:state];
99 }
100
101 @end
Something went wrong with that request. Please try again.