Jump to content
News about the LabVIEW Wiki! Read more... ×
hooovahh

Vector Boolean Creator

Recommended Posts

A little while ago I posted some code on how to create boolean controls with images that scale well because the images are vector based and can scale up or down better than a static image like a PNG.  After making that I made a utility that allows for selecting an image, and a control template and it creates the control.  I showed this off to Danielle Hamburger and she encouraged me to clean it up and post it to the community.  I'm still putting this in the In Development section just because there are several external tools needed that working around would be ideal if this were to be finished but for now it works and I use it often.

 

Vector Boolean Control Creator.png

So it works like you'd think.  There is a library of vector images you select from, pick the one you want, then pick the Control Type (which is a folder of CTLs), then click create and it creates the control setting the decal button, VI description (adding License text if needed) and sets the icon editor icon.

Dependencies

If you just run the Vector Boolean Control Creator you'll need OpenG Time, OpenG File, and the JKI State Machine toolkit installed in LabVIEW 2015 or newer.  The included libraries will work without anything else as long as you are in Windows (more on that later).  If you want to include your own controls there are a few more steps and I left a text file explaining that in the Template Controls folder, but I included several already.  If you want to add your own images I also left instructions in the Libraries folder.  I wrote a VI that can convert from SVGs to the needed PNG and EMF files as long as you download inkscape (again instruction text files included).  But inkscape is only a dependency if you want to use that utility to add your own libraries which are in SVG.

Demo

For good measure I made a Jing video showing how it works.

Windows Only...

So the Windows only part is an interesting one.  I started with my UI being just a single 2D picture control and as you type your search in the top, it would go and open each image that matched the result, shift them into rows and columns, detect the number of columns shown, then detect and show mouse selection, and all the other stuff that would be needed.  To say the least it was slow.  I tried several ways to improve it, but in the end it was slow and I couldn't come up with a solution I liked.  I could have added a search button but I really like the live search of typing it in and seeing it update as you type just like the icon editor glyphs do.

So for a first release I went with the cheap and hacky solution and that was to leverage some .Net to embed a Windows Explorer window into my front panel, which is just the search results of a folder on disk.  This now means you see the PNG images on the front panel, but it will only use that to show the UI to you, but then use the vector based EMF file when creating the control.

Doing the search was a bit weird too since I couldn't figure out how invoke a search with the Explorer .Net so instead I wrote to a temp location a saved search that is XML, which I tell the UI to navigate to which then shows the search results.

Oh and there is some .Net GDI resize going on so the PNG image is used as icon editor icon for the control but dependency could likely be removed with some G work.

Anyway hope people find this useful.

Vector Boolean Creator.zip

  • Like 2

Share this post


Link to post
Share on other sites

What are some of your environment versions?  I've tested this on Windows 7 x64 LabVIEW 2015, 2016, 2017 32-bit, and with some success on Server 2012 x64 LabVIEW 2015.  I say some because it runs and works, but the preview images aren't shown in the selection UI.  Really that is just a terrible hacky solution and I regret doing it.  If I get some time I may try to revert back to the picture control solution.  You're issue definitely has to do with the .net stuff.

Share this post


Link to post
Share on other sites

So far only a single Windows 10 enterprise 2016 64 bit machine, with LV 2017 32 and 64bit. Uhm, how am I supposed to understand which .NET I got?

Share this post


Link to post
Share on other sites

Oh the mysteries of .Net.  It seems Windows 10 comes with at least 4.6.  The code I developed is based on the link you provided, which is why I'm also confused why that works and mine doesn't.

Share this post


Link to post
Share on other sites

That is very nice, now I don't have to waste hours of time for this buttons :)

 

Edit, I have only one problem - for some images size of the generated control is 200KB or greater, for me this is fine but LV seems to have the problem and slow down significantly during edit time...

Edited by pawhan11

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

By using this site, you agree to our Terms of Use.