procedure xy_zoom( plot[1]:graphic, ; XyPlot instance x[1]:float, ; x coordinate to zoom around y[1]:float, ; y coordinate to zoom around 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 coordinate yd_min1, ; Final minimum y data coordinate xd_max1, ; Final maximum data coordinate yd_max1 ; Final maximum data coordinate 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 unit around which the center will be. ; datatondc(plot,x,y,centerx,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. Check for center or any of the extents being out of ; the data range; if so, clip to the correct 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, ; requiring the program 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 ; ; Determine real minimums and maximums. ; 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 ; ; Set final values of new data extents. ; setvalues plot "xyXMinF" : xd_min1 "xyXMaxF" : xd_max1 "xyYMinF" : yd_min1 "xyYMaxF" : yd_max1 end setvalues end