(eclick, erelease)
eclick and erelease are the press and release events
eclick and erelease are the press and release events
eclick and erelease are the press and release events
def zoom_on_square(eclick, erelease):
    'eclick and erelease are the press and release events'
    global N,side,x0,y0,myobj,M,power
    x1, y1 = min(eclick.xdata,erelease.xdata),min( eclick.ydata,erelease.ydata)
    x2, y2 = max(eclick.xdata,erelease.xdata),max( eclick.ydata,erelease.ydata)
    #print(" The button you used were: %s %s" % (eclick.button, erelease.button))
    #print ' Nx=%d, Ny=%d, x0=%f, y0=%f'%(x1, y1, x0,y0)
    #print ' Nx=%d, Ny=%d, x0=%f, y0=%f'%(x2, y2, x0,y0)
    x_1=x0+side*(x1-N/2.)/N
    y_1=y0+side*(y1-N/2.)/N
    x_2=x0+side*(x2-N/2.)/N
    y_2=y0+side*(y2-N/2.)/N
    x0=(x_2+x_1)/2.
    y0=(y_2+y_1)/2.
    side=side*(x2-x1+y2-y1)/N/2 # Average of the 2 rectangle sides
    func(np.float64(x0),np.float64(y0),np.float64(side), np.int32(L),np.int32(power),drv.Out(M),block=(n_block,n_block,1),grid=(n_grid,n_grid,1))    
    myobj = plt.imshow(M,origin='lower',cmap=cmaps[i_cmap])
    myobj.set_data(M)
    ax.add_patch(Rectangle((1 - .1, 1 - .1), 0.2, 0.2,alpha=1, facecolor='none',fill=None, ))
    ax.set_title('Side=%.2e, x=%.2e, y=%.2e, %s, L=%d'%(side,x0,y0,cmaps[i_cmap],L))
    plt.draw()
def zoom_on_square ( eclick , erelease ) : global N , side , x0 , y0 , myobj , M , power x1 , y1 = min ( eclick . xdata , erelease . xdata ) , min ( eclick . ydata , erelease . ydata ) x2 , y2 = max ( eclick . xdata , erelease . xdata ) , max ( eclick . ydata , erelease . ydata ) #print(" The button you used were: %s %s" % (eclick.button, erelease.button)) #print ' Nx=%d, Ny=%d, x0=%f, y0=%f'%(x1, y1, x0,y0) #print ' Nx=%d, Ny=%d, x0=%f, y0=%f'%(x2, y2, x0,y0) x_1 = x0 + side * ( x1 - N / 2. ) / N y_1 = y0 + side * ( y1 - N / 2. ) / N x_2 = x0 + side * ( x2 - N / 2. ) / N y_2 = y0 + side * ( y2 - N / 2. ) / N x0 = ( x_2 + x_1 ) / 2. y0 = ( y_2 + y_1 ) / 2. side = side * ( x2 - x1 + y2 - y1 ) / N / 2 # Average of the 2 rectangle sides func ( np . float64 ( x0 ) , np . float64 ( y0 ) , np . float64 ( side ) , np . int32 ( L ) , np . int32 ( power ) , drv . Out ( M ) , block = ( n_block , n_block , 1 ) , grid = ( n_grid , n_grid , 1 ) ) myobj = plt . imshow ( M , origin = 'lower' , cmap = cmaps [ i_cmap ] ) myobj . set_data ( M ) ax . add_patch ( Rectangle ( ( 1 - .1 , 1 - .1 ) , 0.2 , 0.2 , alpha = 1 , facecolor = 'none' , fill = None , ) ) ax . set_title ( 'Side=%.2e, x=%.2e, y=%.2e, %s, L=%d' % ( side , x0 , y0 , cmaps [ i_cmap ] , L ) ) plt . draw ( )