[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Zooming in Object Graphics

Kellie Brown (mcnaronbrowk@saic.com) writes:

> I'm pretty new to object graphics and have a problem I'm trying to
> figure out.  I have a plot object that I allow a simple zooming
> capability.  To zoom, I change the value of the viewplane_rect property
> of the IDLgrView. I also track the plot coordinates (translated to data
> space) as I move the mouse within my object graphic window.
> The problem: After I zoom in (for example) and change the viewplane_rect
> property, the coordinates that are returned to me are the same values as
> before I zoom.  For example, I have a scatter plot of points and I want
> to display the coordinate of a point when I put the cursor over it.  If
> the graphic has been zoomed in, then the data range shown in my 400x400
> graphics window has changed, and I'm not getting the same coordinate
> value as before for the same point.
> I assume this is because I have not changed the [xyz]coord_conv value of
> the graphic object, but I don't know what to do to change the value.  My
> guess is I need to find out the new data range actually displayed in my
> window, but how do I do that based on the new value of viewplane_rect?
> I figure that once I determine this new data range, I can re-calculate
> the [xyz]coord_conv and, therefore, retrieve the same data coordinate
> for a point, even when it's in zoom mode.
> Am I on the right track?  If so, can anyone help me figure out how to do
> this?

After giving this quite a bit of thought (and after looking
again at how my ZPLOT program works), I'm beginning to think
you may NOT be on the right track. In fact, I think you
may have gotten on the North bound train instead of 
the South bound. (This happened to my son and I as we
were traipsing around Europe together last summer. In our
case it didn't matter because wherever we ended up was 
fine with us, but it might matter to you.)

I say this because it occurs to me that changing the
Viewport rectangle is exactly what you would do if you
wanted to zoom into a plot and NOT change the data coordinate
space. In fact, NOT changing the data coordinate space is
what *makes* this technique a zooming technique. In other
words, if the data space remains the same, and you map
less of it into the window, you have, effectively, zoomed
into the data space.

But I would argue that you want just the opposite. You want
to leave the viewport rectangle alone, but display less of
the data coordinate space in *it*. In other words, you want
to change the amount of data space that is shown in the
window, thereby zooming into the data space. The latter
is simply a matter of calculating the end-points of the
relevant axis (perhaps with a rubberband box or something
similar), and then rescaling the axis end-points into the
viewplane rectangle space. This is a simple COORD_CONV

The advantage of doing this is that data points on
the plot will now maintain their real data coordinate
values, because they will be scaled appropriately.

This little stream-of-consciousness diatribe would require 
a couple more passes to make intelligible, probably. But
I think this would put you back on the right track if you
could decipher it. :-)



David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155