LabVIEW

cancel
Showing results forΒ 
Search instead forΒ 
Did you mean:Β 

One more nugget: Chart zoom with the "Mouse Over" effect

Highlighted

Hello all.

 

Just read my signature first, it might explain a lot. I do not intend to compete with Darren and I don't think this "nugget" (at least it supposed to be one) will amaze any of the LV veterans and this forum is rich of them. But maybe it will bring some new ideas to some of you or maybe it will be useful for some LV beginners (like me). It is very likely, my code will have some lapses, but please be gentle pointing that out to me. If you feel a need, you can always optimize the code and develope it further. Just don't forget to share! πŸ˜‰

 

So back to the point.

 

I am developing a project using LV. In my program there is a waveform chart which has to show 4 plots. Depending on the length of the X Scale, it sometimes gets hard to see the plots clearly because of their density.So I decided that I need a tool, which would zoom the chart in. And this is what I have came up with after a few "Google" searches to check which part of the bike is already invented and also a bit of programming by myself. 

 

Maybe you guys (at least the veterans) know the BetterVIEW Consulting LV example where they have implemented the Mouse Over effect. So a part of their example has been used in this tool and part of the credit must go to them. I thank them a lot πŸ™‚

 

This tool uses a cluster and its property of visibility to show/hide the cluster depending on if the current position of the mouse cursor is in the desired range or not. The program also gets the image of the chart and returns the subset of the image. The subset is taken for the area arounf the mouse cursor. So if you move the mouse, the zoomed in area will also chage in response. After that, the subset of the image is zoomed in for better view. 

 

The user might chage the zoom factor during the execution. Also it is possible to turn the zoom option On or Off if you don't wish to see it for the moment. 

 

This is how the front panel looks like:

Front panel.jpg

 

And this is the image of the block diagram (see the attached files for the vi, the VI Snippet tool distorts the code too much, so I haven't added it):

Chart zoom.jpg

 

I haven't found anything the same in the forum. Yet I'm a newbie here and I don't have that much experience surfing it. If it wouldn't be something new (in the forum, not necessarily to some of you personally), just ignore the thread. I hope this was worth your time and your attention. 

 

Good coding πŸ™‚

Message Edited by Giedrius.S on 02-11-2010 12:46 PM
---

While evaluating my code please have in mind that I am a LV novice. Therefore sometimes my code might violate some coding rules that I have to learn about myself. But how else could I do that... πŸ™‚

Chart zoom with "Mouse Over" effect
Message 1 of 11
(3,726 Views)
Oh, and if it would ask you for LV Toolbox library, here it is (see attached).
---

While evaluating my code please have in mind that I am a LV novice. Therefore sometimes my code might violate some coding rules that I have to learn about myself. But how else could I do that... πŸ™‚

Chart zoom with "Mouse Over" effect
0 Kudos
Message 2 of 11
(3,712 Views)

Well done!

 

This is excellent work.  You may not be as newbie as you think.. πŸ˜‰

 

RayR

 

(I will provide some positive comments later today)

Message Edited by Ray.R on 02-11-2010 08:28 AM
______________________________________________________________________
Message 3 of 11
(3,675 Views)

Very nice Giedrius.

 

It takes guts to "step up to the chalk board" so I will do what i can to give you some ideas to think about. This is similar to the type of feedback I offer durring our in-house code reviews.

 

Chart zoom.jpg

 

 

1) The floating property nodes outside the loop are not sequenced by wires so they could execute after the loop starts. Sometimes this could cause weird errors. Seq with the error cluster.

2) Property nodes can be re-sized so you can apply more than one property setting in the same call. Property node have to execute in the UI thread (which is single threaded) so using a single nodes will force a single context switch rather than one for each.

3) Setting the same property repeatedly in a loop just burns CPU. THe Scale min for both X an Y can be moved outside the loop ?

4) THe Wait Until Next ms" function does not get used in any of my code. It is not a way to get a fixed wait but rather a random wait. If you code completes 1 ms after the next multiple, the delay is double less 1 ms. If you have multiple loops using them and it f the delay for each are not unique prime numbers, then the "Wait until next ms multiple" is a good (cough cough) way of getting them all to wake up at the same time and fight for the CPU.

5)An Event Struture to monitor mouse enter/leave and mouse move (this would have to be a sepearte loop) is easier on the CPU than polling.

6) Is that math in the case to handle the Chart position on the FP? If so then using the property nodes for the chart to find its postion will let you code adapt to GUI changes.

7) Right to left wires are not well recieved.

😎 A Bundle by Name is prefered over a "Bundle" since it is self documenting. I know the Picture function so I can see that is the rectangle you are specifying but reader not famliar with that function would not be able to "READ" the code without poking at it.

9) THe event structure would also help with setting the Zoom factor. Only poke it when you have to.

 

That is all that comes to mind at the moment.

 

Again thank you!

 

Ben

 

Message 4 of 11
(3,662 Views)

Ben beat me to it.  And I agree with Ben's comments.

 

He's also more thorough... I looked at the png image I captured and looked at it while compiling code.  I did not look at the posted code, yet.

 

See the comment within the attached image (below).  

 

 

Message Edited by Ray.R on 02-11-2010 11:37 AM
______________________________________________________________________
Message 5 of 11
(3,620 Views)

This is some very nice code.

 

Two thoughts,

  1. it is a hard way to get a VI ref. If it's placed inside a Reentrant VI it won't work at all.
  2. This screams XControl

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Message 6 of 11
(3,584 Views)

TCPlomp wrote:

This is some very nice code.

 

Two thoughts,

  1. it is a hard way to get a VI ref. If it's placed inside a Reentrant VI it won't work at all.
  2. This screams XControl

Ton


My thought exactly although I did not post that idea eralier. If that example that Yair developed for non-rectagular FPs was used for the zoomed picture, it could look like a magnifying glass.

 

Bonus point if the edge of the magnifying glass exibited distotion around the edges.

 

Ben

0 Kudos
Message 7 of 11
(3,579 Views)

Ben wrote:

TCPlomp wrote:

This is some very nice code.

 

Two thoughts,

  1. it is a hard way to get a VI ref. If it's placed inside a Reentrant VI it won't work at all.
  2. This screams XControl

Ton


My thought exactly although I did not post that idea eralier. If that example that Yair developed for non-rectagular FPs was used for the zoomed picture, it could look like a magnifying glass.

 

Bonus point if the edge of the magnifying glass exibited distotion around the edges.

 

Ben


Thank you all for the input. I will edit the code for it to meet the criterias you have pointed out. And Ben, could I get a link to that exampe you have mentioned? Would like to check it out.

 

XControls is a topic I still should fathom better. I will do that as soon as I will have more spare time. 

 

At the moment I am trying to update the zoom tool for the zoom cluster's window to include X and Y Scales, which would be dynamic - that means they should not be distorted by the zoom factor or the movement of the mouse. These scales would allow to follow not only the plots themselves, but also to orient what value the're indicating. I have completed the vast majority of this task already. But I won't finish it today, because I also can't forget my studies (even if LV coding attracks me much more) πŸ™‚

---

While evaluating my code please have in mind that I am a LV novice. Therefore sometimes my code might violate some coding rules that I have to learn about myself. But how else could I do that... πŸ™‚

Chart zoom with "Mouse Over" effect
0 Kudos
Message 8 of 11
(3,567 Views)

My memory has a connection between the round GUI and Yair (tst) and this thread looks promising.

 

Ben

Message 9 of 11
(3,551 Views)

TCPlomp wrote:
  1. it is a hard way to get a VI ref. If it's placed inside a Reentrant VI it won't work at all.

When accessing properties of the current VI I usually don't wire a reference to the property/invoke node (default is 'self'). I never checked for performance, but I don't expect big differences.

 

@Giedrius: nice nugget. Looking forward to finally switch to LV 2009 (still stuck at 8.5...).

 

Daniel

 

Message Edited by dan_u on 02-11-2010 11:32 PM
0 Kudos
Message 10 of 11
(3,519 Views)