Source

kinect-viewer / KinectViewerAppDelegate.m

Cliff Biffle 38960df 




Cliff Biffle 788984a 

Cliff Biffle 66e86eb 
Cliff Biffle d26d9f0 
Cliff Biffle 01e6772 

Cliff Biffle bce82f8 
Cliff Biffle 788984a 

Cliff Biffle 15fd2d0 

Cliff Biffle 788984a 
Cliff Biffle 66e86eb 
Cliff Biffle 788984a 
Cliff Biffle 15fd2d0 

Cliff Biffle a3375f9 



Cliff Biffle 66e86eb 
Cliff Biffle a3375f9 

Cliff Biffle 0416bfa 



Cliff Biffle 404e447 
Cliff Biffle d26d9f0 


Cliff Biffle 0416bfa 
Cliff Biffle 6f88052 


Cliff Biffle 05121e9 
Cliff Biffle 0416bfa 


Cliff Biffle 01e6772 












Cliff Biffle 788984a 
/*
 * Copyright 2010 Cliff L. Biffle.  All Rights Reserved.
 * Use of this source code is governed by the Apache License 2.0,
 * which can be found in the LICENSE file.
 */

#import "KinectViewerAppDelegate.h"
#import "KVDepthView.h"
#import "KVDepthPlayer.h"
#import "KVDepthRecorder.h"
#import "KVKinectHardware.h"

@implementation KinectViewerAppDelegate

#pragma mark --- Properties

@synthesize window;
@synthesize depthView;

#pragma mark --- NSApplication delegate methods

- (BOOL)applicationShouldTerminateAfterLastWindowClosed: (NSApplication *)theApplication {
  return YES;
}

- (void)applicationDidFinishLaunching: (NSNotification *)aNotification {
  [window zoom: self];
  
  NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
  NSString *replayFile = [defaults stringForKey: @"replay"];
  
  if (replayFile) {
    NSLog(@"Playing %@", replayFile);
    KVDepthPlayer *player = [[KVDepthPlayer alloc] init];
    [depthView bind: @"latestDepthSamples" toObject: player withKeyPath: @"latestDepthSamples" options: nil];
    [player open: replayFile];
  } else {
    kinect = [[KVKinectHardware alloc] init];
    [depthView bind: @"latestDepthSamples" toObject: kinect withKeyPath: @"latestDepthSamples" options: nil];
    [depthView bind: @"latestColorSamples" toObject: kinect withKeyPath: @"latestColorSamples" options: nil];
    [kinect open];
  }
}

- (IBAction) toggleRecording: sender {
  if (recorder) {
    [recorder close];
    recorder = nil;
    [sender setState: NSOffState];
  } else {
    recorder = [[KVDepthRecorder alloc] init];
    [recorder open: @"/tmp/depth-recording.bin"];
    [recorder bind: @"latestDepthSamples" toObject: kinect withKeyPath: @"latestDepthSamples" options: nil];
    [sender setState: NSOnState];
  }
}

@end