Edit Panel Elements

Introduction

Need to:

I needed the first two functions and got the missing piece from Jim Kring's "Copy-Paste Boolean Attributes", which supplies the third. Since the functions are closely related, we started to combine them in an OpenG package. For a number of reasons, the project stalled in the spring of 2003. About the same time, LabVIEW 7 supplied the first of the above functionalities in a native utility. Rather than leaving you struggling with problems that have already been solved or being passed by National Instruments in supplying the rest of the capabilities, I decided to provide this preprint (LV6 640 kbytes) of what we hope will become an OpenG package. Put the .llb in your "project" folder and three new entries will appear on your "Tools" menu:

Copy Paste Boolean Atributes..., Find Decorations..., and Resize... on Tools menu Copy Paste Boolean Attributes... Find Decorations... Resize...
Figure 1: New Entries on Tools Menu (clickable)

Resize Icon Nothing Ever Matches

How many hours have you spent trying to eliminate that one pixel gap between the third element in a cluster and the cluster frame? ...trying to get controls to line up on the left and the right simultaneously? ...trying to make an indicator the same height as the corresponding control?

LabVIEW 7 provides a "Resize Objects" tool (right next to the "Align Objects" and "Distribute Objects" tools) that will do that job. If you don't have LabVIEW 7, click on the Resize... tool to get something like the simulation of Figure 2.

A simulation of Resize.vi Resize Controls Tweak Controls
Figure 2: Resizing Controls

Untitled 1 VI has a cluster of controls of disparate widths with Autosizing set to Arrange Vertically. We've selected only the individual controls themselves.

Click on the Match Widest button in Figure 2 to neaten everything up. (Really click it! This is a simulation.) And, if you decide you'd like them all a pixel wider or narrower, click the Tweak button and you'll get a pop-out panel that can move any boundary one pixel at a time. (This is only a partial simulation, so only these two buttons are effective and only for moving among the three canned images. In the real Resize panel, Match Widest (and similar buttons) is momentary and can't be undone as it can here.)

Get a Handle on Decorations

Have you ever needed to change a decoration programatically? You can't pop-up on one and create a property node or even a label. You can get an array of references to all the decorations on a panel, but how do you know which one is which?

Click on the Find Decorations... tool and you'll get a panel that allows you to make any decoration flash by selecting its index number. Again, Figure 3 is an animation, not a functioning VI.

A simulation of Find Decorations.vi Next Decoration Previous Decoration Stop Animation
Figure 3: Finding Decorations

Click the increment and decrement arrows to select different decorations and watch them flash (even invisible ones). Read out some properties of each on the tool's front panel. Click the stop button to return the decorations to their regular state and the tool to the state it is in before a front panel is chosen. For the arrow controls, the simulation matches the real thing, but the stop button would make the real tool unload from memory and you certainly couldn't get it to run again by popping the stop button, as you can here.

This tool can't label the decorations, but it can at least discover their indices in the Decorations array for you to use manually.

Copy Paste Boolean Attributes

This whole project started with Jim Kring's Copy-Paste Boolean Attributes.vi. This VI operates on whichever VI panel has most recently been the focus of your attention. (This attachment to the frontmost VI panel was the functionality that I needed for the two tools described above.) It always floats on top in Windows systems, another useful feature for VI development tools. When I heard about this tool, I had no idea how to attach to the frontmost VI panel, so I downloaded Jim's file and studied it to find out.

Since I was going to have to understand what was going on to incorporate this functionality in my own VIs, I started twisting and turning Jim's wiring to suit my way of thinking—sort of like trying to put someone else's statement in your own words to prove that you've really understood it. Items that were repeated for each of the different attributes were condensed into a single instance, with only the code that differed changing from case to case. "Copy" and "Paste" were made two cases of the same structure, sharing the support common to both operations. The diagram shrank to a single screen where you could tell at a glance that there were "Copy" and "Paste" operations and that they were customized to each attribute. You could only see in detail how one operation worked for one attribute, but a quick click through the cases showed that all attributes were handled basically the same. Clicking back and forth between copy and paste quickly showed their commonality and complementarity. There was very little burden on (human) short-term memory from the hidden code.

With the editing functions clarified, I concentrated on the code that found the panel with focus. Profiling and execution highlighting showed that most of the time was spent examining every VI in memory to see if its panel had focus. By checking the most likely VIs first (Copy-Paste Boolean Attributes and the most recent VI with focus) and stopping the checking as soon as the VI with focus was found, I greatly reduced the time needed to find the correct VI for large projects. I also discovered that a polymorphic VI called by Jim's code introduced dozens of VIs to handle its various input data types, cluttering memory even for projects with only a single VI. Changing the polymorphic VI to a custom one sped things up tremendously in the few cases where all the VIs in memory needed to be checked. (A thread in Info-LabVIEW indicated, and I quickly verified, that LabVIEW 6 never triggered the test the polymorphic VI was executing, so I replaced the custom test with a constant.) The final code ran at least fifty times faster than the original on small projects. (The difference for large projects was even greater.) Jim claimed it was fifty times easier to understand as well.

Extension to Other Platforms

As I mentioned above, the original Copy Paste Boolean Attributes was a floating window on Windows platforms. LabVIEW 7 provides a "Floating/Auto-Hide" property that works on all platforms. I adapted the code to use this property on newer systems, use the WINUTIL function on Windows machines if it is available, and otherwise function without the floating capability without complaining.

Get It While It's Hot

If this functionality (or some of its subfunctionality) is just what you've been looking for, download this preprint (LV6 640 kbytes) of what we hope will become an OpenG package. Put the .llb in your "project" folder and browse your "Tools" menu for the three new entries. If you've got improvements or complaints, either let me know or join the OpenG development group.