undef("zoom") procedure zoom( plot[1]:graphic, ; XyPlot instance x[1]:float, ; x coordinate to zoom arround y[1]:float, ; y coordinate to zoom arround scale[1]:integer ; scale factor to zoom by ) local x0, ; holds original x coordinate of plot viewport y0, ; holds original x coordinate of plot viewport height0, ; holds original height value for the plot viewport width0, ; holds original width value for the plot viewport centerx, ; holds the NDC values of the data parameter x centery, ; holds the NDC values of the data parameter y xl, ; holds the new NDC x value for upper left corner xr, ; holds the new NDC x value for upper left corner yt, ; holds the new NDC x value for upper left corner yb, ; holds the new NDC x value for upper left corner deltax, ; NDC spacing from center point deltay, ; NDC spacing from center point new_left, ; NDC spacing from center point new_right, ; NDC spacing from center point new_top, ; NDC spacing from center point new_bottom, ; NDC spacing from center point xd_min1, ; Final minimum x data coordiante yd_min1, ; Final minimum y data coordiante xd_max1, ; Final maximum data coordiante yd_max1 ; Final maximum data coordiante begin ; ; First retrieve original values ; getvalues plot "vpXF" : x0 "vpYF" : y0 "vpHeightF" : height0 "vpWidthF" : width0 end getvalues ; ; Allocate temporary variables ; centerx = new(1,float) centery = new(1,float) xl = new(1,float) xr = new(1,float) yt = new(1,float) yb = new(1,float) ; ; compute NDC units around which the center will ; be. print(plot) print(x) print(y) print(centerx) print(centery) datatondc(plot,x,y,centerx,centery) print(x) print(centerx) print(y) print(centery) ; ; Determine NDC height and width offsets ; deltax = width0 / (2.0 * scale) deltay = height0 / (2.0 * scale) ; ; Compute new NDC edges of plot ; new_left = centerx - deltax new_right = centerx + deltax new_top = centery + deltay new_bottom = centery - deltay ; ; Map NDC to data and check if center or any of the extents are out of ; the data range then the function clips to the coorrect area. ; ndctodata(plot,new_left,new_top,xl,yt) ndctodata(plot,new_right,new_bottom,xr,yb) ; ; ndctodata fills in missing values when the input is out of range ; requireing the probgram to check the result for consisnt ; if(ismissing(xl)) new_left = x0 ndctodata(plot,new_left,new_top,xl,yt) end if if(ismissing(yt)) new_top = y0 ndctodata(plot,new_left,new_top,xl,yt) end if if(ismissing(xr)) new_right = x0 + width0 ndctodata(plot,new_right,new_bottom,xr,yb) end if if(ismissing(yb)) new_bottom = y0 - height0 ndctodata(plot,new_right,new_bottom,xr,yb) end if ; ; Figure out real min's and max's ; if(xr.lt.xl) xd_min1 = xr xd_max1 = xl else xd_min1 = xl xd_max1 = xr end if if(yt.lt.yb) yd_min1 = yt yd_max1 = yb else yd_min1 = yb yd_max1 = yt end if ; ; Final setvalues of new data extents ; setvalues plot "trXMinF" : xd_min1 "trXMaxF" : xd_max1 "trYMinF" : yd_min1 "trYMaxF" : yd_max1 end setvalues end