corresponds to the clicked point.
'''
- #Ye Olde sorting algorithm...
- index=0
best_index=0
- best_diff=10^9 #FIXME:hope we never go over this magic number, doing best_diff=max(xvector)-min(xvector) can be better...
- for point in xvector:
- diff=abs(point-self.absolute_coords[0])
- if diff<best_diff:
+ best_dist=10**9 #should be more than enough given the scale
+
+ for index in scipy.arange(1,len(xvector),1):
+ dist=((self.absolute_coords[0]-xvector[index])**2)+(100*((self.absolute_coords[1]-yvector[index])))**2
+ #TODO, generalize? y coordinate is multiplied by 100 due to scale differences in the plot
+ if dist<best_dist:
best_index=index
- best_diff=diff
- index+=1
-
+ best_dist=dist
+
self.index=best_index
self.graph_coords=(xvector[best_index],yvector[best_index])
return
def _plug_init(self):
self.currentmacro=[]
self.auxprompt=self.prompt
- self.macrodir=os.curdir
+ self.macrodir=self.config['workdir']
if not os.path.exists(os.path.join(self.macrodir,'macros')):
try:
os.mkdir('macros')
except:
print 'Warning: cannot create macros folder.'
print 'Probably you do not have permissions in your Hooke folder, use macro at your own risk.'
- self.macrodir=os.path.join(self.macrodir,'macros')
+ self.macrodir=os.path.join(self.macrodir,'macros')
def collect(self):