LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Resizing controls on a tab control within a pane.

I am trying to create a resizeable user interface in LabVIEW. The interface will have three panes: a display pane containing a tab control containing graphs (waveform and intensity), a control pane containing a tab control containing path, string, numeric controls, and a heading pane containing a logo and time/date. I want to have the ONLY the controls in the display pane (bottom right in attached images) to resize with the front panel. In other words, I just want the graphs to get larger or smaller when the front panel is resized. I have tried to do this by setting the pane sizing to "Scale all Objects with Pane" and "Scale Objects While Resizing." When I do this, the controls seem to move slightly every time the front panel is resized. This becomes a problem after these shifts accumulate and cause the controls to move out of view (please see the attached before and after figures). The images I've included show what happens when you resize the front panel a few times. Also, the axis labels begin to shift so that they are not centered on the plot area width and height. Any ideas how to get around this? Or perhaps an alternative method to creating a resizeable front panel with various types of controls that will behave nicely when resized?

Download All
0 Kudos
Message 1 of 6
(6,903 Views)

I actually programmatically resize the screens.  This allows me to only resize those things that need resizing.  If you use the event structure, one of the events is "Panel Resize".  In this event case, resize the controls/indicators you want based on the screen size.

 

I'm actually planning on putting together a demo of this for a user group, so give me a day to put that together.  There are some tricks you need to know to make it work right, but once you know those tricks, it works pretty slick.  I'll post the code and a description of the tricks/gotchas.

Tom Brass
Certified LabVIEW Architect
Choose Movement Consulting, Inc.
www.choose-mc.com
Message 2 of 6
(6,889 Views)

I've attached an example of resizing a graph and repositioning some controls based on the size of the screen.  There are some things to consider:

 

1.  At the beginning I set the size of the screen, so that the screen size will always start out the same.  This ensures that I always return to my original screen size.  You could change this to store the value, if you wanted to hold on to the new screen size.

2.  When the user is resizing the screen, you will get several Panel Resize events.  You know the user is done resizing when the New Bounds equals the Old Bounds.

3.  The Active State tells you if the screen is Normal, Minimized, or Maximized.  You'll want to resize the graph if the screen is Maximized, but not Minimized.

4.  The Previous State tells you what state the screen was in.  If the screen was Maximized, but is now Normal, you'll want to resize the graph accordingly.

5.  Finally, the calculations for resizing the graphs and moving the controls are pretty straight forward, just use the New Bounds and add/subtract as needed.  This is mostly trial and error, but doesn't take too long.  I could probably figure out a fancier way of doing it, but this is simple and doesn't take too long to implement.

6.  One final note, if you are using multiple panes, each pane has its own Panel Resize event.  You can use this to resize only the objects inside that pane.  Just use the same principal, but on a per-panel basis.

Tom Brass
Certified LabVIEW Architect
Choose Movement Consulting, Inc.
www.choose-mc.com
Message 3 of 6
(6,885 Views)

One key point, and the reason that your controls get away from their original sizing and position the more you resize, is that you are scaling on the previous position, and the results have to be an integer value, even when the scale isn't.  Screen coordinates and sizes are all integer numbers of pixels, you can't have fraction pixels.  So if you have something at the position of 3, and it cuts in half, it is going to wind up at 2 (1.5 rounded up).  But then if you double, you are going to wind up at 4 instead of the original 3.

 

So when doing positioning and size, you should base it on some original optimal size and position, and not on the previous size and position, so that scaling and round off don't stack up over time.

0 Kudos
Message 4 of 6
(6,877 Views)

The graph is resizing properly, but the legend moves around without much logic. Sometimes it is completely out of the vi panel.

0 Kudos
Message 5 of 6
(6,762 Views)

If you are programmatically resizing the graph, depending on where you position the legend, you may want to programmatically position/resize the legend as well.  The legend has its own set of properties, including position, size, number of visible rows, etc.

Tom Brass
Certified LabVIEW Architect
Choose Movement Consulting, Inc.
www.choose-mc.com
0 Kudos
Message 6 of 6
(6,754 Views)