Commit 167cdb61 authored by Matheus Müller's avatar Matheus Müller

Adicao de pontos agora operacional, remocao ainda em falta

parent cec599b4
......@@ -6,7 +6,6 @@ from scipy.interpolate import interp1d
from scipy import interpolate
from pylab import *
import Tkinter as tk
#import pickle
listay = list()
listax = list()
......@@ -16,13 +15,12 @@ ax = fig.add_subplot(111)
recursivecontrol = 0
filename = raw_input()
#######################################################################################################
# Add square
def add_square(x):
global listay, drs, ax
rect = ax.bar(x, 0.03, width=0.5)
rect = ax.bar(x, 0.02, width=0.3)
for rec in rect:
dr = DraggableRectangle(rec)
dr.connect()
......@@ -40,23 +38,12 @@ def remove_square():
#######################################################################################################
class DraggableRectangle:
lock = None # only one can be animated at a time
class voidfunctions:
def __init__(self, rect):
self.rect = rect
self.press = None
self.background = None
self.rect.set_y(0.1)
def connect(self):
'connect to all the events we need'
self.cidpress = self.rect.figure.canvas.mpl_connect(
'button_press_event', self.on_press)
self.cidrelease = self.rect.figure.canvas.mpl_connect(
'button_release_event', self.on_release)
self.cidmotion = self.rect.figure.canvas.mpl_connect(
'motion_notify_event', self.on_motion)
self.cida = self.rect.figure.canvas.mpl_connect(
'key_release_event', self.on_a)
self.cidr = self.rect.figure.canvas.mpl_connect(
......@@ -66,15 +53,36 @@ class DraggableRectangle:
if event.key=='a':
if not event.inaxes: return
add_square(float(event.xdata))
print event.xdata
# NAO FUNCIONA (DELETA TUDO)
# NAO FUNCIONA (DELETA TUDO)
def on_r(self, event):
if event.key=='r':
if not event.inaxes: return
remove_square()
def disconnect(self):
'disconnect all the stored connection ids'
self.rect.figure.canvas.mpl_disconnect(self.cida)
self.rect.figure.canvas.mpl_disconnect(self.cidr)
class DraggableRectangle:
lock = None # only one can be animated at a time
def __init__(self, rect):
self.rect = rect
self.press = None
self.background = None
self.rect.set_y(0.1)
def connect(self):
'connect to all the events we need'
self.cidpress = self.rect.figure.canvas.mpl_connect(
'button_press_event', self.on_press)
self.cidrelease = self.rect.figure.canvas.mpl_connect(
'button_release_event', self.on_release)
self.cidmotion = self.rect.figure.canvas.mpl_connect(
'motion_notify_event', self.on_motion)
def on_press(self, event):
global drs, recursivecontrol
k = 0
......@@ -83,21 +91,7 @@ class DraggableRectangle:
if DraggableRectangle.lock is not None: return
contains, attrd = self.rect.contains(event)
if not contains: return
# if recursivecontrol == 1:
# recursivecontrol = 0
# return 1
# for rec in drs:
# if recursivecontrol == 0:
# recursivecontrol = 1
# k = k + rec.on_press(event)
# if k == (len(drs)):
# recursivecontrol = 0
# return 1
#print 'event contains', self.rect.xy
x0, y0 = self.rect.xy
self.press = x0, y0, event.xdata, event.ydata
......@@ -112,7 +106,6 @@ class DraggableRectangle:
# now redraw just the rectangle
axes.draw_artist(self.rect)
# and blit just the redrawn area
canvas.blit(axes.bbox)
......@@ -133,14 +126,12 @@ class DraggableRectangle:
# redraw just the current rectangle
axes.draw_artist(self.rect)
# blit just the redrawn area
canvas.blit(axes.bbox)
def on_release(self, event):
'on release we reset the press data'
if DraggableRectangle.lock is not self:
return
if DraggableRectangle.lock is not self: return
self.press = None
DraggableRectangle.lock = None
......@@ -155,25 +146,21 @@ class DraggableRectangle:
for i in range(len(listay)):
(listax[i], listay[i]) = drs[i].rect.xy
#pickle.dump(" ", data)
#pickle.dump(listay[i], data)
print listax, listay
data = open(filename , 'w')
for i in range(len(listay)):
print>>data, listax[i], listay[i]
#data.write("(%s, %s)" %(str(listax[i]), str(listay[i])) )
#dot_pickle = pickle.dumps(listay)
def disconnect(self):
'disconnect all the stored connection ids'
self.rect.figure.canvas.mpl_disconnect(self.cidpress)
self.rect.figure.canvas.mpl_disconnect(self.cidrelease)
self.rect.figure.canvas.mpl_disconnect(self.cidmotion)
self.rect.figure.canvas.mpl_disconnect(self.cida)
self.rect.figure.canvas.mpl_disconnect(self.cidr)
voidrect = ax.bar(0, 0, width=0)
for void in voidrect:
vf = voidfunctions(void)
vf.connect()
add_square(2)
plt.show()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment