02-05-2015 07:38 AM
Hi.
I'm building a HMI where I need to use a certain circular graphics file as an indicator, and rotate this indicator according to a read value.
Given that it's circular, the areas in the corners are transparent.
What is the best way of doing this? I'm trying various things with IMAQ, but I'm having problems with the transparency.
Please see the attached image for example.
02-05-2015 09:15 AM
02-05-2015 09:31 AM
Alternatively use 3D acceleration to rotate it on the fly. The only limitation is that it will have to be displayed in a 3D picture control.
http://forums.ni.com/t5/LabVIEW/Is-possible-customize-the-Gauge-Indicator/td-p/1124763
02-05-2015 10:07 AM
First, You have to make your control totally transparent.
Second, you have to create your images with a transparent background and save them as .png files.
Third, you have to import the pictures with a transparent background into LabVIEW. To make the background transparent in LabVIEW, you have to import the image as a .png. I don't know if it depends on your drawing software, but I have never been able to simply cut-and-paste an image with a transparent background. When I do so, I get a black background. The only way I know for sure works to get the transparent background in Labview is to import it from a .png file.
To import it in a control (into a pict ring for example), right-click the control, select Advanced->Customized. Go to the item you want to change (or add it) and click on the wrench. It will change to a tweezer. Right click the image and select "Import from file". Do it for all your images. Close, respond yes to "Replace the original control..." and "Save" or "Don't save" to the next dialog (if you don't save, the control modifications will still be in the VI but not in a separate control file".
Problem with the pict ring is that it tends to jump around a little bit from picture to picture. So if you cycle through the images to give the illusion of a rotating beam at a fraction of a second between pictures, the jump will be apparent. If you can live with that, you're done.
The other way it to use a 2D picture control. For this one, you have to programmatically load the images into Labview, put them in an array and index the array for each image. The 2D picture can be made transparent.
Below is how I have done it. Notice that the 2d picture is still jumping a little bit but I think that it is because I used powerpoint to do the drawing.
02-05-2015 10:11 AM
In post number 14 of the Picture Control thread Christian showed us how to rotate an image.
That will take care of the rotating part.
If you want to maintain the transparency around the center circle you will have to put together a mask.
That should do what you have asked.
BUT,
if you want to do it using the least CPU then investigate what Gerd Suggested, put the pre rotated images in a picture ring and just drive it with a quotient remaninder driven by a counter.
Ben
02-05-2015 03:07 PM
Thanks alot for all your answers!!
I think preloading the images sounds interesting, given that I can prevent it for eating up too much memory.
I've also looked at the BeauGauge package. Have any of you any experience with those ActiveX controls, in regards to responsiveness, CPU usage, memory usage, etc?
02-05-2015 04:31 PM - edited 02-05-2015 04:55 PM
I wanted to mention that we are in process of packaging/finalizing our Pebbles UI toolkit for LabVIEW, one of our special functionality component is a Rotation Control which does exactly what you're wanting to do:
http://www.batchtest.com/pebbles-ui-for-labview/
Our Rotation Control is shown on left side of the VI image, it accepts two images - one for background and another for rotation. Currently it can accept vector graphics (.SVG, .AI) and bitmaps (.PNG, .JPG, .GIF). If you don't set a background image, by default things are transparent. It rotates your graphics by a fixed angle that you specify, or it has CW/CCW continuous rotation depending on angular speed you specify. Our graphics engine uses hardware acceleration and runs in a thread separately from LabVIEW, it writes directly on LabVIEW screen.
Unfortunately we're not done packaging the toolkit (LVTN requires quite a bit of testing and documentation for a release) so it won't help you at this point but please keep it in mind if you have a future need for rotations on LabVIEW front panel. If you are local to Silicon Valley, there will be a live demo at Bay Area LabVIEW Users Group (NI location in Santa Clara) next week - Feb 10 where you can see it yourself.
-BTC
(A map image is set as background in this case, can be omitted for complete transparency. The needle with red tip rotates on it, silver round border can also be hidden through property nodes, on wire diagram it comes up as a numeric/double indicator).
Here's what it looks like on wiring diagram:
02-06-2015 03:13 AM
Your toolkit looks brilliant, BTC. NI really should have stepped up to the plate and put this functionality in the core GUI, but I'm glad to see a talented third party is stepping in in the meantime.
02-06-2015 04:34 AM - edited 02-06-2015 04:34 AM
BTC: Wow, looks nice!
I would love to see a demo of it. How about holding a live demo in Bergen, Norway?
02-06-2015 09:12 AM
I wanted to come up with another solution, one that is more universal. It should work with just about all normal image file formats (bmp, jpg, png, gif). Attached is a zip with an example image which is a PNG which has alpha layers. This means it has transparencies that aren't just 0% or 100% but inbetween. It supports scaling with stretching or fit, and the window resize is smooth. On top of that it has a rotate feature that works with these resize modes too.
The only downside is I couldn't figure out how to not display the non-rotated image. Maybe someone can figure that out. In any case just unzip all the files and run Transparent With Rotate.
Oh but I just realized, the picturebox container is foreced to be ontop of all other objects which is odd, so maybe this isn't all that useful to you after all.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord