LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Zoom into Pic on Key Press not working

So I have a picture on my front panel. I also have a zoom control wheel attached to it. The Zoom wheel on the front panel at the top right of the picture works fine. But I want to implement a way in which the user can press a button + or - to zoom in/out of the pic that way. (the zoom wheel is a bit cumbersome) Right now I have an Event Structure with a Key Down case event and inside that is a call to the Page-Down button. The VI runs but when I press Page-Down, the pic goes complete black. I do think the pic actually is zooming in because when I use the zoom wheel to zoom and go past the 6 on it, the pic turns black there also. So I think that when I'm pressing the Page-Down key as I have it configured now, it is zooming, but it's zooming all the way. If that is the case, is there a way to tell the Key Down event to zoom incrementally? Or is there even a better way to do about this all together?

0 Kudos
Message 1 of 6
(2,937 Views)

Um.. ok. I'm not sure what you're really trying to do with your code here.

 

You have two event structures, one inside the While loop and one outside. This means the event structure outside the While loop will only wait for one event and then not go back to wait again. You also don't usually want to have two event structures because you can lock up the program when it's waiting for one or the other event to be handled.

 

You write the PageDown enum directly to the zoom factor setting... what??

Once you move that event to be part of the same event structure, pull the VKey output of the event and check if it's equal to PageDown. This boolean check should be written to a case structure where you then change the zoom.

 

You can use shift registers to store the current zoom factor, or pull the zoom factor using a property node, and multiply by a number when the PageDown or PageUp are used.

 

Zoomm Key Event Test_BD.png

 

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 2 of 6
(2,929 Views)

Okay, I followed your schematic there. But...still nothing is working. I've uploaded my latest edited version of my file. Perhaps, do you see anything that I've gotten wrong?

0 Kudos
Message 3 of 6
(2,906 Views)

The code I put above is actually a Snippet, so if you have 2014 or newer (cause that's what I saved it from) you can drag that directly on to your block diagram as code.

 

The code you made is close but not exactly right. Leave your original event structure like it was with the Zoom Factor control value change event. That shouldn't be changed because that worked fine. Now create a new event that looks like the one I made. These will be two separate events in the event structure. I should note that the event I made is: This VI > Key Down, not Zoom Factor 2 > Key Down.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 4 of 6
(2,898 Views)

Okay, thanks for the help James.Morris. I'll get to that. I'm actually wrapping up a day at work so I'll be getting to this later. Just messaging to confirm I got your suggestion. I appreciate all the help.

0 Kudos
Message 5 of 6
(2,890 Views)

Just a little more information if you were interested:

 

Discussion on having more than one event structure.

VI Snippets for code sharing

0 Kudos
Message 6 of 6
(2,857 Views)