################################################################################
# Copyright (C) 2012-2013 Leap Motion, Inc. All rights reserved.               #
# Leap Motion proprietary and confidential. Not for distribution.              #
# Use subject to the terms of the Leap Motion SDK Agreement available at       #
# https://developer.leapmotion.com/sdk_agreement, or another agreement         #
# between Leap Motion and you, your company or other organization.             #
################################################################################

import Leap, sys, thread, time
from Leap import CircleGesture, KeyTapGesture, ScreenTapGesture, SwipeGesture
from pymouse import PyMouse
import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import Cursor
import time
import math
import Demo


demo = Demo.Demo()



move_velocity = 100
minValue = 0.5

mpl.rcParams['legend.fontsize'] = 10

fig = plt.figure()
#ax = Axes3D(fig)
ax = fig.add_subplot(111, projection='3d')
x = []
y = []
z = []

# global variables for scaling
xMin = 0
xMax = 0
yMin = 0
yMax = 0
zMin = 0
zMax = 0
is_zoom_mode = False
curYPosition = 0

plt.ion()
plt.show()



#Smooths the mouse's position
class mouse_position_smoother(object):
    def __init__(self, smooth_aggressiveness, smooth_falloff):
        #Input validation
        if smooth_aggressiveness < 1:
            raise Exception("Smooth aggressiveness must be greater than 1.")
        if smooth_falloff < 1:
            raise Exception("Smooth falloff must be greater than 1.0.")
        self.previous_positions = []
        self.smooth_falloff = smooth_falloff
        self.smooth_aggressiveness = int(smooth_aggressiveness)
    def update(self, (x,y)):
        self.previous_positions.append((x,y))
        if len(self.previous_positions) > self.smooth_aggressiveness:
            del self.previous_positions[0]