Darren's Weekly Nugget 10/30/2006

Darren's Weekly Nugget 10/30/2006

Post by Darre » Wed, 01 Nov 2006 03:10:09


have been working on a project for a while that makes extensive use of the <a href="http://zone.ni.com/reference/en-XX/help/371361B-01/lvconcepts/using_the_picture_indicator/" target="_blank">Picture Control</a> (or "Picture Indicator", depending on what you want to call it).  This was my first big project that involved the picture control, and so far it's been a whole lot of fun!  For those of you Picture Control veterans out there, these might seem obvious, but I figured for this week's nugget I would post some tips and tricks I have picked up along the way that may be useful for those of you who may need some pointers when using the Picture Control for the first time:

- One of the first things I noticed was that my picture updates much more quickly and smoothly when I have "Erase First" deselected on the Picture Control's right-click menu.  If I need to change something on the picture, I try to only redraw the necessary portion of the picture, leaving the rest unchanged.  So if you have a big grid of objects, and you have Erase First deselected, you can draw individual cells of the grid when they need changing, as opposed to redrawing the entire grid.

- If you do need to redraw your entire picture, you will need to erase it first (otherwise the new drawing will overlap the old drawing).  Thankfully, you can simply use the <a href="http://zone.ni.com/reference/en-XX/help/371361B-01/lvprop/picture_erase_first/" target="_blank">Erase First</a> property of the picture control with a "1" wired in...this basically will erase the picture one time, without changing the actual "Erase First" setting.

- In my project, I'm doing a lot of dragging and dropping on my Picture Control.  One slick thing I've been able to do is actually mimic "move" behavior, where when you click and drag an "object" in the picture, it will actually appear to "move" with the mouse cursor until I "drop" the object.  There are two ways to approach this problem...one way would be to actually redraw the image in the main picture control as you're moving the object.  There is another way which seems to perform a lot faster...specifically, you can have a second picture control...it's a transparent picture control whose borders are also transparent.  In this case, you draw the "object" you want to move in this second picture control.  Then, you change the position of the second picture control to be "under" the mouse cursor.  Then, as <a href="http://zone.ni.com/reference/en-XX/help/371361B-01/lvprop/pane_mouse_move/" target="_blank">Mouse Move</a> events fire, you simply change the position of the transparent picture to stay with the mouse cursor.  It turns out that this approach is *much* faster than redrawing the main picture on every Mouse Move.  Oh, and it looks really, really cool.  :)

- There are a ton of functions in the <a href="http://zone.ni.com/reference/en-XX/help/371361B-01/lvpict/picture_vis/" target="_blank">Picture Functions</a> palette to draw objects in a picture control...<a href="http://zone.ni.com/reference/en-XX/help/371361B-01/lvpict/draw_point/" target="_blank">Draw Point</a>, <a href="http://zone.ni.com/reference/en-XX/help/371361B-01/lvpict/draw_line/" target="_blank">Draw Line</a>, <a href="http://zone.ni.com/reference/en-XX/help/371361B-01/lvpict/draw_rect/" target="_b
 
 
 

Darren's Weekly Nugget 10/30/2006

Post by Ben » Wed, 01 Nov 2006 03:40:09

..and to help sell the versitility of the picture control, here is a collection of just some of the GUI I've developed using the picture control.
Annotated graph (in LV 6.1)
<img src=" http://www.yqcomputer.com/ %20Graph.JPG">
Derivative of a bear (one of my wifes favorites)
<img src=" http://www.yqcomputer.com/ ">
Reconfigurable fume hood image 1
<img src=" http://www.yqcomputer.com/ ">
fume hood image 2
<img src=" http://www.yqcomputer.com/ ">
Protocol analyzer display
<img src=" http://www.yqcomputer.com/ %20analyzer.JPG">
Rotating graph (projected behind band while playing)
<img src=" http://www.yqcomputer.com/ %20graph.JPG">
And my first serious attempt at using the picture control, my model railroad
<img src=" http://www.yqcomputer.com/ ">
BenMessage Edited by Ben on 10-30-2006 12:32 PM

 
 
 

Darren's Weekly Nugget 10/30/2006

Post by MIG » Wed, 01 Nov 2006 06:10:07

One thing I discovered about the picture control the other day, that I never knew before, is that you can use the 'Concatenate Strings' function to concatenate the output from the Picture Function VIs, and display them on a single picture.Or you can feed an array of pictures into Concatenate strings to concatenate the pictures.<img alt="" src="file:///C:/DOCUME%7E1/MARKGU%7E1.NEU/LOCALS%7E1/Temp/moz-screenshot.jpg">


Picture1.png:
http://www.yqcomputer.com/


Picture2.png:
http://www.yqcomputer.com/
 
 
 

Darren's Weekly Nugget 10/30/2006

Post by Ben » Thu, 02 Nov 2006 02:40:08

Thank you for sharing that Matt!
I will embed the image here.
<img src=" http://www.yqcomputer.com/ ">
The above image shows part of the UI that is available in a 21-CFR-11 complient Environmental monitoring system that is commercially available and allows the end users to import a set of map of their facility. They can define the position of icons assocated with the physical location of sensors that are integrated using networks of cFP nodes.
Mouse-ver an icon gives you the name of the sensor (Ice Bath) and the current reading.
Right-click on the icon gives you a plot of the variable vs time.
Left-Click (by an authorized user) allows access to the configuration of the sensor.
Note:
Due to the high channel count of this application, the picture control allowed us to by-pass the " max 550 controls on FP" limitation that existed in earlier version of LV.
Ben
 
 
 

Darren's Weekly Nugget 10/30/2006

Post by NJKirchne » Fri, 03 Nov 2006 04:10:14

Although I may not have a flashy FP to show at this moment, I think I have you all topped out for working w/ the picture control.
I'll try to keep this short but I'm really e *** d to talk about it so we'll see how it goes.
It all started w/ needing to stream a picture from a frame grabber to the front panel on a really crappy PC.
Taking the data as an array of u8 and doing the conversion w/ the LV VIs and redrawing for each frame was really slow, about 8fps.
I couldn't use the vision toolkit as it needed to be platform independent.
Solution: Totally disect framework of the picutre control on a byte level (flatten to string), do a repace on the existing string w/ the new data from the camera(inplace function(no new memory)), and then do a concantenate string w/ a blank picture and redraw to the picture control
Result: over 45fps
All that disection....wait let me explain what disection meant
Disection(verb): Opening up every LV picture VI, seeing how the data is structured within each picture type and its appropriate opCode, and then keeping track of each element that was drawn on a picture control so thatt if I needed to modify, say the color of a line amidst 200 lines. I didn't need to redraw all 200 lines w/ 1 haveing the new color, I would just recall the location in the byte stream of where the the line is and the color for that specific line was stored and then change it to the appropriate value.
ex: Picture control framework [32 bits defining total size of following data for entire control][16 bits: opCode(picture part)][32bits: size of data for specific opCode][data of opCode]REPEAT last 3 for every part in control
opCode:NAME4: set pixel5: Pen move 6: Pen Move to7: Line8: Line to16: Poly-Line17: Fill Poly41: Select Pen10: Rect Fill9: Rect Frame15: Gray out Rect25: Round Rect Fill24: Round Rect Frame12: Oval Fill11: Oval Frame14: Arc Fill13: Arc Frame18: Text Box31: New Font29: Copy Pixmap40: Copy PIxmap w/ maskThe long and the short of it, is that because NI has left the structure of the picture control open, we are free to create our own tools to push the control to the limits. If I was ever able to create a tool that showed handles on individual items that were drawn already, using these techniques you could do a 'free transform' on something like a triangle poly, and move individual joints aoround.
I've got way more to say but I've gone on too long alreday. oooh Wait I've got Pictures too
~,~ The Captain Was Here
Norm KirchnerCLD (Certified LV Dancer)


picureCtl-inplace-replace.jpg:
http://www.yqcomputer.com/


picureCtl-recolor.jpg:
http://www.yqcomputer.com/
 
 
 

Darren's Weekly Nugget 10/30/2006

Post by Ben » Fri, 03 Nov 2006 04:40:08

It is an honour to be trumped by the Captain*!
I saved your posting off-line for further study.
Thank you Norm. Please feel free to tump me any day!
Ben
* For those of you who are not familiar with "The Captain", Norm Kirchner was the first (to the best of my knowledge) person to teach the world how to write a VI using a VI aka "scripting", is very active on the LAVA forum, and demonstrated his dancing at NI-Week 2006.
<a href=" http://www.yqcomputer.com/ " target="_blank"> http://www.yqcomputer.com/ ;/a>
 
 
 

Darren's Weekly Nugget 10/30/2006

Post by tst » Fri, 03 Nov 2006 05:10:06


I've got way more to say but I've gone on too long alreday.


No you haven't.
You haven't even began to scratch the surface.
I dare you I double dare you - take your time, write a good paper about this. Upload some VIs to nicely demonstrate this and we will all be very happy.
The only thing I am afraid of about this is that NI might finally reach the conclusion one day that the picture control format is not efficient enough and change its internal implementation. Then, all these VIs using internal Opcodes will have to be rewritten, at the very least. On the other hand, I don't see that happening real soon.



CLD (Certified LV Dancer)

:smileyvery-happy:
 
 
 

Darren's Weekly Nugget 10/30/2006

Post by NJKirchne » Fri, 03 Nov 2006 05:40:10

I can't take all the credit for the find/announcement
<a href=" http://www.yqcomputer.com/ " target="_blank"> http://www.yqcomputer.com/ ;/a>
Someone 'PJM Lv' announced it to infoLV w/ much greater detail before myself. Not being an active member at that time, I thought I stumbled onto something first.
~,~
 
 
 

Darren's Weekly Nugget 10/30/2006

Post by tst » Fri, 03 Nov 2006 06:10:08


I have 3 pages of notes on the different structures for the opCodes. Untill I can write a white paper, I may just have to scan them in and post here.

I guess that'll have to do for now. If you can combine some VIs with it, it would be even better.
 
 
 

Darren's Weekly Nugget 10/30/2006

Post by Ben » Fri, 03 Nov 2006 23:10:08

"Ben can kick in some of his knowledge?"
 
I am not qualified to carry the ball on this one but I can kick it around a little.
 
The KB article on LAVA is a good idea. I'll watch for it and contribute what I can.
 
I'll see what  I can do to support Paul Ausitn's* invention.
 
BTW:
This Q reveals my age but did anyone else notice the similarties between HPGL and the Picture Control data format?
 
<a href=" http://www.yqcomputer.com/ ~pbourke/dataformats/hpgl/" target="_blank"> http://www.yqcomputer.com/ ~pbourke/dataformats/hpgl/</a>
 
Ben
 
* Paul Austin (to the best of my knowlwdge) invented the Picture control and hold the patent on same.