LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to restore a graph to original zoom

Solved!
Go to solution

Hi,

 

Sorry if this seems like a silly question but I'm new to this!

 

Basically I have a plot that I want the user to be able to zoom into to examine a small section and then be able to click a "Reset Zoom" command button in order to go back to the original view.

 

I'm fine with the initial zooming bit, however resetting the zoom to the original is where I'm having problems. Can anyone please recommend the best way to go about this?

 

Many thanks

0 Kudos
Message 1 of 6
(5,472 Views)

There are a couple of ways on how to do it:

 

  • Let the user revert to original scale by hitting Ctrl + Spacebar one or more times
  • If you are using autoscaling, call SetAxisScalingMode with VAL_AUTOSCALE for each axis of the control
  • If you manually setting the scale, save values in some non-volatile variable or some hidden control, next restore proper scaling using those values


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 6
(5,465 Views)
Solution
Accepted by cottonb

One possibility could be to have a graph control callback with a test on EVENT_ZOOM; on the first occasion (after start or reset) you may use GetAxisScalingMode to obtain the minimum and maximum of the axis range.

In your Reset button callback you may then use these min/max values to restore the original axis range using SetAxisScalingMode.

 

Good luck, Wolfgang

0 Kudos
Message 3 of 6
(5,463 Views)

Thanks for the help guys, will give it a try.

0 Kudos
Message 4 of 6
(5,460 Views)

Also, is there any chance you know how to simulate holding the Ctrl key or if it's possible? I know you can use FakeKeystroke for a single key press but is there a way of setting a toggle switch so that while it's on it effectively holds Ctrl? I could only think of using a while loop but all that did was make it crash!

0 Kudos
Message 5 of 6
(5,453 Views)

You can simply include the Ctrl key modifier in the FakeKeystroke call. For example, to simulate Ctrl+SpaceBar, your call would look like this:

 

FakeKeystroke (VAL_MENUKEY_MODIFIER | ' ');

 

Luis

0 Kudos
Message 6 of 6
(5,444 Views)