LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Fit Meter to Pane Resize Behavior

Okay can someone tell me why controls don't always behave properly when set to fit to pane?  Tables, Graphs, Trees, Listboxes, all seem to work as expected, but a Meter, thermometer, and tank all exhibit weirness that is making this difficult.  Do I need to write code to set the control size to get around this weirdness?

 

Attached is a VI that has two meters each set to fit to the pane size.  They will keep the specified aspect ratio which is fine I guess.  But after resizing it a bit it always ends up doing weird things and no longer fitting right.  I added code to fit the control to the pane as it resizes and this didn't help.  This part of the code is disabled at the moment.  Just run the VI, then make the window larger and smaller in multiple directions.  Then make it go back to the smallest size it allows and now the controls are all weird.  I've seen similar weirdness trying to get tanks, and thermometers fitting to panes and suspect it might have something to do with the aspect ratio being locked, or these are just old controls that don't get much attention anymore.

0 Kudos
Message 1 of 9
(3,206 Views)

@Hooovahh wrote:

Okay can someone tell me why controls don't always behave properly when set to fit to pane?  Tables, Graphs, Trees, Listboxes, all seem to work as expected, but a Meter, thermometer, and tank all exhibit weirness that is making this difficult.  Do I need to write code to set the control size to get around this weirdness?

 

Attached is a VI that has two meters each set to fit to the pane size.  They will keep the specified aspect ratio which is fine I guess.  But after resizing it a bit it always ends up doing weird things and no longer fitting right.  I added code to fit the control to the pane as it resizes and this didn't help.  This part of the code is disabled at the moment.  Just run the VI, then make the window larger and smaller in multiple directions.  Then make it go back to the smallest size it allows and now the controls are all weird.  I've seen similar weirdness trying to get tanks, and thermometers fitting to panes and suspect it might have something to do with the aspect ratio being locked, or these are just old controls that don't get much attention anymore.


New controls show the same weirdness. I remember once to get around this problem, rather than use the scale, I calculated the size the size of the object I wanted to scale based on the pane size. I just used the size border I wanted with respect to the pane size. (See below) This worked, but it would have been nice if native LabVIEW scale to pane just worked. Note that you may want to reset the origin of the control also, as when you do resize it tends to move from its original spot.

 

mcduff

Snap4.png

 

 

 

0 Kudos
Message 2 of 9
(3,195 Views)

Thanks for that suggestion, and I think that would be a viable option if I can figure out how to properly resize it at run-time.  There is a "Housing Size" property which does in fact seem to set the set the size of the housing which is the outer part of the control.  However setting this seems to still mess with the position of the inner control elements in ways that pretty quickly makes them cut off or not visible.  Attached is an update which tries to set this for the first meter.

 

The other option I've been exploring is what it would take to recreate a meter with a picture control...yeah...Anyone really good at math and knows how to wrap a 2D picture around a curve?...

0 Kudos
Message 3 of 9
(3,187 Views)

Okay so I went down that rabbit whole and came out with something...it ain't pretty but it is something.  The attached zip contains code which will generate a meter which visually looks similar to the NI meter but this one is down into a picture control.  It only supports one needle and there is some hackery in there but does draw the gradients with ranges, and best of all centers in the picture control and tries to take up as much as it can scaling decently.  It should be in an XControl, and keep track of the size and only redraw the needle if the value changed instead of redrawing the whole control.  And I couldn't think of a good way to figure out what the major ticks should be at so I'm using a hidden control that I set then read the increments it has.  Even so maybe someone will find this useful and more importantly.  Still I'd rather all of this not be necessary and NI's control work right.  I also found the tank, and thermometer experience similar crap scaling weirdness and I'll likely look into making those picture controls...

0 Kudos
Message 4 of 9
(3,122 Views)

Could you back save it to LV 2016 or so?

 

Not seeing your code I can only think out loud...

 

Use an off-screen meter to the set the value and then use a invoke node get image method to insert in a picture control.

 

Then use the "Zoom Factor" Property of the picture control to se the size.

 

Ben

 

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 5 of 9
(3,114 Views)

Oh zoom factor is an interesting solution, not sure which would work better but certainly less coding involved.  Oh and I realize now wrapping my drawing meter code into a class is probably a better first step than XControl.

0 Kudos
Message 6 of 9
(3,106 Views)

Here's my idea.

"If you weren't supposed to push it, it wouldn't be a button."
Message 7 of 9
(3,093 Views)

Okay minor update, I went and tried doing the same thing for a Thermometer control but this time thought it would work better in a class, and made a state machine for some of the important bits.  So attached is a class and demo with New, Draw, and Close public VIs.  You can set the size, range, font, etc.  And you can even set the range colors unlike the real thermometer.  Now by default if your value is under 0 the scale is blue and if it is above it is red.  But again the best part in my opinion is it scales better and centers in the size constraints.  Anyone from NI want to convince me this isn't a bug?  Or want to track with a CAR?

Message 8 of 9
(3,041 Views)

Hi Hooovahh,

 

This certainly looks like a bug to me, and I was able to reproduce it easily here with your initial VI that you attached. That said I went ahead and created a new CAR for this #725914.

 

Thanks!

Tyler C.
Technical Support Engineering
National Instruments
Message 9 of 9
(2,989 Views)