Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

decouple zoom and range change

Hi,

I have 2 ScatterGraphs. I am trying to sync the x -axis and the zoom events of the two graphs.

When I zoom in on one graph, I'd like the other graph to zoom in by the same amount for the x-axis.  This is no problem.  However, I'd like to be able to zoom out on either graph and have both graphs restored to their original states.  This is the problem. 

Also, I'd like to be able to change the X-axis min or max values to set a new range.  However, this also seems to be considered a zoom event.  Because after I do that, I can use the Shift+Right-click to zoom back out to the original x-axis values.  Is there a way to change an axis range without it being considered a zoom?

0 Kudos
Message 1 of 8
(3,816 Views)
Hi,

For the zoom out question, what exactly isn't working?  Is it not zooming out the second graph?  You should be able to implement this exactly like you did the zoom in portion.  Is this how you implemented it?

For the axes question, I haven't been able to duplicate this behavior.  After you change the X-axis, you are able to shift-click on the graph to zoom out?  Do you see this behavior if you do not zoom in before changing the axis?
0 Kudos
Message 2 of 8
(3,798 Views)
Thanks Terry for your reply.

1. Zoom out Issue:

Assume I have 2 graphs - MagGraph and PhaseGraph, I tried to sync 2 graphs on x-axis range, here is the code fragment.

// Zoom Event Handlers
private void MagGraph_Zoom(object sender, NationalInstruments.UI.ActionEventArgs e)
        {
            if (bPhaseZoom)
            {
                bPhaseZoom = false;
                bMagZoom = false;

                double xmin = this.magXAxis.Range.Minimum;
                double xmax = this.magXAxis.Range.Maximum;

                this.phaseGraph.ZoomXY(this.PhasePlot, xmin, ymin, xmax - xmin, ymax - ymin);
            }
            else
            {
                bPhaseZoom = true;
                bMagZoom = true;
            }
        }

        private void PhaseGraph_Zoom(object sender, NationalInstruments.UI.ActionEventArgs e)
        {
            if (bMagZoom)
            {
                bMagZoom = false;
                bPhaseZoom = false;
                double xmin = this.phaseXAxis.Range.Minimum;
                double xmax = this.phaseXAxis.Range.Maximum;

                this.magGraph.ZoomXY(this.MagPlot, xmin, ymin, xmax - xmin, ymax - ymin);
            }
            else
            {
                bMagZoom = true;
                bPhaseZoom = true;
            }
        }

With these 2 functions, zoom in and out from any of the graphs are fine. However, I have to add another function to allow the user to change the x-axis range manually (set xaxis.interactionmode to be EditRange.). Here is the function.

// Range Change Event Handler

        void phaseXAxis_RangeChanged(object sender, System.EventArgs e)
        {
            this.magXAxis.Range = this.phaseXAxis.Range; 
        }

In this function, I have set magXAxis.Range = this.phaseXAxis.Range so the X-Axis of MagGraph will sync with PhaseGraph. By the way,  I am hiding the XAxis for MagGraph so the user can only change phase graph axis. That is why there is only one Range Changed Handler. After I added this function, the Zoom out sometime stop working correctly. For example, if I zoom in from phase graph and zoom out from phase graph, the mag graph doesn't revert back to original state.


2. For the axes question, I haven't been able to duplicate this behavior.  After you change the X-axis, you are able to shift-click on the graph to zoom out?  Do you see this behavior if you do not zoom in before changing the axis?

To duplicate this behavior, set the axis.interactionmode = EditRange. Then click on the X-axis label and change it to a different number. Now do Shift+right mouse click, you will see the X-Axis range reverts to previous value.  There is no zoom in is performed before changing the axis.

I am looking forward to hearing from you again.


0 Kudos
Message 3 of 8
(3,794 Views)
Hi,

I still haven't been able to duplicate this behavior.  Can you post a simple example that demonstrates this for me to try out?
0 Kudos
Message 4 of 8
(3,780 Views)
Hi Terry,

Please see the example attached in the message. It needs visual studio 2005 to run.

After you launch the application, click "plot data" -> then X axis range shows 40 to 75. Change 75 to 100. -> Shift + right mouse click -> notice the zoom out happens and the X axis range goes back to 40 to 75.

I guess this explain why the No.1 problem happens. If this can be fixed, No. 1 issue will be soloved too.

Thanks,
Sue
0 Kudos
Message 5 of 8
(3,779 Views)
Hey Sue,

Thanks for attaching the example.  I was taking a look at this, and I see the behavior you are talking about if I set the axis interactively by changing the values on the axis.  However, I do not get the ability to "zoom out" if I change it manually through the controls on the form.  Is this the same behavior you are seeing?  If so, what you are wanting is to keep the interactive change of the axes from being viewed as a "zoom"?
Pat P.
Software Engineer
National Instruments
0 Kudos
Message 6 of 8
(3,762 Views)
Hi Sue,

Thanks for posting that example program as it clearly shows the behavior you are seeing. This behavior is actually something we did by design but perhaps it could be changed in the future if requested. 

Basically, for all interactive actions that occur (zooming, panning, change the axes values, etc; anything interactive), we internally store those actions. Then when you press <Shift>+Right-Click, we undo the actions one by one.  I looked through out documentation and it doesn't appear to state this information, so I am noting this so that in the future we can make the documention more clear. 

I know its a little confusing as it appears that changing the axes ranges interactively is causing a zoom event but its actually not.  Of course, as soon as you change the axis range value and press <shift>, the cursor changes to the magnifying glass (which to me would indicate a zoom event occured).  So, what I would suggest, if you really don't like this behavior or would like to see another option or more documentation, send me a product suggestion

If you wanted to workaround this, you could probably just store the axes range values during the XAxisRangeChanged event and then restore them in the ZoomPanUndone event (
(which gets fired when you do the <shift>+right-click action). 

Hope this clears things up.

Best Regards,

Message Edited by Jonathan N on 03-16-2007 12:13 PM

Jonathan N.
National Instruments
0 Kudos
Message 7 of 8
(3,761 Views)
Thanks a lot. The information is very helpful. Now I understand what it is doing.



0 Kudos
Message 8 of 8
(3,750 Views)