Steen Schmidt Posted February 20, 2013 Report Share Posted February 20, 2013 Hi, I'm building a BatchEditor to bulk edit/verify for style many LV files at once (projects, VIs, controls, folders etc.). For that I need to get the 32x32 pixel connector pane image. Not the icon (I can get that with the public VI Icon.Get As Image Data method), and not the image from context help (I can get that with the private Get Conpane Image method for instance). Instead, look at the output of my VI here: I do that by scripting a new VI, dropping in my subject VI as subVI, then showing that subVI's terminal image instead, then grabbing the image from there: In case you're wondering; the 32x32 pixel "Black frame icon" is set to get correct conpane images of subVIs that are smaller than 32x32 pixels to start with... But, this entire scripting approach is slow and convoluted, do any of you guys have a better idea to get this image? Cheers, Steen Quote Link to comment
Ton Plomp Posted February 20, 2013 Report Share Posted February 20, 2013 Have you looked at the 'Export Interface' method? Ton Quote Link to comment
Steen Schmidt Posted February 20, 2013 Author Report Share Posted February 20, 2013 (edited) Yes I have, the 'Export Interface' method returns the same image as the 'Get Conpane Image' method. That is, the icon (not conpane "icon") including any controls and indicators connected to the conpane. It doesn't include the VI Description text either, which I had actually expected (to the extent that you can expect anything from private methods). That method is also a bit funny as it's marked as "Deprecated" (as in your image) when imported from an earlier LV version, even though it's still present, and selectable, with the exact same name in LV 2012 for instance. /Steen Edited February 20, 2013 by Steen Schmidt Quote Link to comment
Yair Posted February 20, 2013 Report Share Posted February 20, 2013 There is another option I can think of, but I don't know if its performance will be any better - Get the VI's connector pane reference and use that to get the reference to the controls and the pattern. Then, use those reference and call the Application class method Data Type Color to get the color for each terminal and then draw the connector yourself based on the pattern. I'm assuming that the color is the one which actually appears in the con pane. You might be able to use code people already uploaded to make editing the con pane easier (I believe Mark Balla has one in the CR). 1 Quote Link to comment
ShaunR Posted February 20, 2013 Report Share Posted February 20, 2013 I'd have a look at the icon editor. It can overlay the connector so it must get it somehow. Quote Link to comment
Phillip Brooks Posted February 20, 2013 Report Share Posted February 20, 2013 (edited) I'm not sure why the "Get Conpane Image" private method is not working. (not private in LV2012) I've seen this used in Marc Page's Polish VIs library available on the NI forums. https://decibel.ni.com/content/docs/DOC-1189 I just downloaded it and tested with both LabVIEW 8.6 and 2012 and the method worked fine. Edited February 20, 2013 by Phillip Brooks Quote Link to comment
Steen Schmidt Posted February 20, 2013 Author Report Share Posted February 20, 2013 Phillip, the 'Get Conpane Image' method works fine, it just doesn't return the image I need. Marc Page's Polish VIs library does not get the image I need either, it builds a larger version of the conpane step by step - sort of what Yair suggests, just larger. /Steen Quote Link to comment
Steen Schmidt Posted February 20, 2013 Author Report Share Posted February 20, 2013 ShaunR: The Icon Editor isn't helping either. It doesn't get the conpane image really, it builds a slightly larger terminals outline image programmatically from conpane info. This conpane info is publically available, and I could use that to create my own conpane image... And then we're at what Yair suggests, namely that I build this image manually instead of grabbing it from somewhere, and hoping this process is faster than what I do now with scripting. The programming involved is quite extensive pixel-chipping though, so I think I'll stick with what I currently have and use those hours on something else in the BatchEditor. Thanks for your suggestions :-) Cheers, Steen Quote Link to comment
Darren Posted February 20, 2013 Report Share Posted February 20, 2013 I wrote this VI a while back for a colleague. It's not perfect, but it's the closest thing I've got. Saved in LabVIEW 8.6. Get Connector Pane Data Type Image.vi 1 Quote Link to comment
Steen Schmidt Posted February 20, 2013 Author Report Share Posted February 20, 2013 Thanks again Darren, that VI basically does exactly what Yair suggested and what I turned down as too much work . /Steen Quote Link to comment
Phillip Brooks Posted February 20, 2013 Report Share Posted February 20, 2013 Maybe this would be of help? http://digital.ni.com/public.nsf/allkb/279F064F0688C114862570900057678C You might be able to get the images for each pattern and then fill them in as needed... Quote Link to comment
Steen Schmidt Posted February 20, 2013 Author Report Share Posted February 20, 2013 (edited) Thanks Phillip, I have worked a bit with Darren's VI, and it's slightly faster than scripting a subVI, but the created conpane image does not look 100% correct, as some of the terminal borders are thicker than normal (2px vs. 1px). But your link gave me an idea; I could combine Darren's approach of making the colored rectangles in an empty image, and then just superimpose the proper conpane "frame" on top of that image (instead of drawing a slightly wrong rectangle around each terminal position). The only drawback is that I'll be supporting a static set of conpane patterns then. On the other hand, once the conpane patterns eventually gets updated, my whole BatchEditor will probably have to be rewritten anyway. I'll take a look at it tomorrow - it's getting close to midnight here. Cheers, Steen Update: Superimposing the conpane frame doesn't work correctly either. Output terminals should have 2px wide borders in the conpane image, while inputs and unwired terminal borders should have 1px wide borders. And it's of course not possible to have all possible conpane image combinations of I/O prepared statically. Back to the drawing board, or stay with the scripting approach... Edited February 20, 2013 by Steen Schmidt Quote Link to comment
Darin Posted February 21, 2013 Report Share Posted February 21, 2013 I have worked a bit with Darren's VI, and it's slightly faster than scripting a subVI, but the created conpane image does not look 100% correct, as some of the terminal borders are thicker than normal (2px vs. 1px). But your link gave me an idea; I could combine Darren's approach of making the colored rectangles in an empty image, and then just superimpose the proper conpane "frame" on top of that image (instead of drawing a slightly wrong rectangle around each terminal position). Update: Superimposing the conpane frame doesn't work correctly either. Output terminals should have 2px wide borders in the conpane image, while inputs and unwired terminal borders should have 1px wide borders. And it's of course not possible to have all possible conpane image combinations of I/O prepared statically. Back to the drawing board, or stay with the scripting approach... There is a lot of funny business going on with the terminal bounds and with the Draw Rectangle vi. On the surface, it appears the TermBnds[] property is wrong because it returns value between 0,0 and 32,32 which means a size of 33x33. However, Draw Rectangle does not really use the values of right and bottom, it actually gives rectangles with the width and height specified (for line width = 1). For example, if you draw the rectangle from (0,0) to (8,8) and look at the 1-bit pixmap you will see that the pixel indices are 0,0 to 7,7. When you turn around and draw a second rectangle from (8,0) to (16,8) you get a second line at column 8 in the 1-bit pixmap, ie. a double-width line. What a mess. An easy "fix" is to compensate by adding 1 to the right and bottom values. Now you get a nice conpane outline with all single pixel lines. The only problem is that it is now 33x33 pixels (if you care). 1 Quote Link to comment
MikaelH Posted February 21, 2013 Report Share Posted February 21, 2013 It's easy to do this, just using these property nodes. I use it to show the new connector layout I'll suggest. Quote Link to comment
Darin Posted February 21, 2013 Report Share Posted February 21, 2013 It's easy to do this, just using these property nodes.q2.png That is the method that is shown in Darren's VI and that Yair suggested. Although the image is scaled so the effect is reduced in your case, you can still see that the interior lines are double thickness. Quote Link to comment
Steen Schmidt Posted February 21, 2013 Author Report Share Posted February 21, 2013 Thanks to everyone in this thread, especially you Darren, who had a VI on your shelf showing that I should just have done what Yair suggested . I've basically reworked Darren's VI, into one that creates a 100% correct conpane image. Here's the FP illustrating an example (the VI itself is attached this post if you can use it): So that's probably the fastest way in G to get the conpane image. I discovered a funny thing while coding this; the Get Image method of the SubVI class returns slightly wrong terminal colors for the conpane image! For instance "Boolean green" is RGB 0,127,0 in the BD, but the image when extracted with the Get Image method contains a slightly darker green color, namely 0,102,0 instead. So an unexpected side effect by this small exercise were even more correct conpane images . Cheers, Steen GetConpaneImage.vi 1 Quote Link to comment
Yair Posted February 21, 2013 Report Share Posted February 21, 2013 I discovered a funny thing while coding this; the Get Image method of the SubVI class returns slightly wrong terminal colors for the conpane image! I'm pretty sure that the default color depth for the method is 8 bits, so you get a limited palette. Try using 24 bits. 2 Quote Link to comment
Steen Schmidt Posted February 21, 2013 Author Report Share Posted February 21, 2013 I tried that, didn't change anything. /Steen Quote Link to comment
Yair Posted February 21, 2013 Report Share Posted February 21, 2013 I tried that, didn't change anything. I just did a manual test (I pasted the generated image into Paint.NET) and it does seem to work - feeding 24 into the Image Depth input generates an image where the boolean terminal is 0,127,0. 1 Quote Link to comment
Steen Schmidt Posted February 21, 2013 Author Report Share Posted February 21, 2013 I just did a manual test (I pasted the generated image into Paint.NET) and it does seem to work - feeding 24 into the Image Depth input generates an image where the boolean terminal is 0,127,0. I'll be...... I just tried it again and now it works? Well, must've been grimlins then. Or perhaps a Schrödinger's Cat problem... /Steen Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.